Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: resolve symlinks for O= properly

Currently, Kbuild follows the logical chain of directories for the O=
option, just like 'cd' (or 'realpath --logical') does.

Example:

$ mkdir -p /tmp/a /tmp/x/y
$ ln -s /tmp/x/y /tmp/a/b
$ realpath /tmp/a/b/..
/tmp/x
$ realpath --logical /tmp/a/b/..
/tmp/a
$ make O=/tmp/a/b/.. defconfig
make[1]: Entering directory '/tmp/a'
[snip]
make[1]: Leaving directory '/tmp/a'

'make O=/tmp/a/b/.. defconfig' creates the kernel configuration in
/tmp/a instead of /tmp/x despite /tmp/a/b/.. resolves to /tmp/x.

This is because Kbuild internally uses the 'cd ... && pwd' for the
path resolution, but this behavior is not predictable for users.
Additionally, it is not consistent with how the Kbuild handles the
M= option or GNU Make works with 'make -C /tmp/a/b/..'.

Using the physical directory structure for the O= option seems more
reasonable.

The comment says "expand a shell special character '~'", but it has
already been expanded to the home directory in the command line.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>

+4 -7
+4 -7
Makefile
··· 190 190 endif 191 191 192 192 ifneq ($(KBUILD_OUTPUT),) 193 - # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot 194 - # expand a shell special character '~'. We use a somewhat tedious way here. 195 - abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) 196 - $(if $(abs_objtree),, \ 197 - $(error failed to create output directory "$(KBUILD_OUTPUT)")) 198 - 193 + # $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' first. 194 + $(shell mkdir -p "$(KBUILD_OUTPUT)") 199 195 # $(realpath ...) resolves symlinks 200 - abs_objtree := $(realpath $(abs_objtree)) 196 + abs_objtree := $(realpath $(KBUILD_OUTPUT)) 197 + $(if $(abs_objtree),,$(error failed to create output directory "$(KBUILD_OUTPUT)")) 201 198 endif # ifneq ($(KBUILD_OUTPUT),) 202 199 203 200 ifneq ($(words $(subst :, ,$(abs_srctree))), 1)