mirror of
https://github.com/torvalds/linux
synced 2024-09-06 18:01:05 +00:00
kbuild: revert $(realpath ...) to $(shell cd ... && /bin/pwd)
I thought commit8e9b466799
("kbuild: use $(abspath ...) instead of $(shell cd ... && /bin/pwd)") was a safe conversion, but it changed the behavior. $(abspath ...) / $(realpath ...) does not expand shell special characters, such as '~'. Here is a simple Makefile example: ---------------->8---------------- $(info /bin/pwd: $(shell cd ~/; /bin/pwd)) $(info abspath: $(abspath ~/)) $(info realpath: $(realpath ~/)) all: @: ---------------->8---------------- $ make /bin/pwd: /home/masahiro abspath: /home/masahiro/workspace/~ realpath: This can be a real problem if 'make O=~/foo' is invoked from another Makefile or primitive shell like dash. This commit partially reverts8e9b466799
. Fixes:8e9b466799
("kbuild: use $(abspath ...) instead of $(shell cd ... && /bin/pwd)") Reported-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Tested-by: Julien Grall <julien.grall@arm.com>
This commit is contained in:
parent
9e66317d3c
commit
028568d84d
4
Makefile
4
Makefile
|
@ -130,8 +130,8 @@ endif
|
||||||
ifneq ($(KBUILD_OUTPUT),)
|
ifneq ($(KBUILD_OUTPUT),)
|
||||||
# check that the output directory actually exists
|
# check that the output directory actually exists
|
||||||
saved-output := $(KBUILD_OUTPUT)
|
saved-output := $(KBUILD_OUTPUT)
|
||||||
$(shell [ -d $(KBUILD_OUTPUT) ] || mkdir -p $(KBUILD_OUTPUT))
|
KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
|
||||||
KBUILD_OUTPUT := $(realpath $(KBUILD_OUTPUT))
|
&& /bin/pwd)
|
||||||
$(if $(KBUILD_OUTPUT),, \
|
$(if $(KBUILD_OUTPUT),, \
|
||||||
$(error failed to create output directory "$(saved-output)"))
|
$(error failed to create output directory "$(saved-output)"))
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ endif
|
||||||
|
|
||||||
ifneq ($(OUTPUT),)
|
ifneq ($(OUTPUT),)
|
||||||
# check that the output directory actually exists
|
# check that the output directory actually exists
|
||||||
OUTDIR := $(realpath $(OUTPUT))
|
OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
|
||||||
$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
|
$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
ifneq ($(O),)
|
ifneq ($(O),)
|
||||||
ifeq ($(origin O), command line)
|
ifeq ($(origin O), command line)
|
||||||
ABSOLUTE_O := $(realpath $(O))
|
dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
|
||||||
dummy := $(if $(ABSOLUTE_O),,$(error O=$(O) does not exist))
|
ABSOLUTE_O := $(shell cd $(O) ; pwd)
|
||||||
OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
|
OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
|
||||||
COMMAND_O := O=$(ABSOLUTE_O)
|
COMMAND_O := O=$(ABSOLUTE_O)
|
||||||
ifeq ($(objtree),)
|
ifeq ($(objtree),)
|
||||||
|
@ -12,7 +12,7 @@ endif
|
||||||
|
|
||||||
# check that the output directory actually exists
|
# check that the output directory actually exists
|
||||||
ifneq ($(OUTPUT),)
|
ifneq ($(OUTPUT),)
|
||||||
OUTDIR := $(realpath $(OUTPUT))
|
OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
|
||||||
$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
|
$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue