aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2014-08-07 15:39:57 -0400
committerMichal Marek <mmarek@suse.cz>2014-08-07 15:53:20 -0400
commit164f0d2efaaef835473e74b162eae750341d6a8c (patch)
tree0b52bfad6c24aa14603694471e2b7d54a8ce5366 /scripts
parent26ea6bb1fef06c686be771903ecab0518af5c2de (diff)
kbuild: Fix handling of backslashes in *.cmd files
Commit c353acba ("kbuild: make: fix if_changed when command contains backslashes") attempted to handle backslashes in *.cmd files, but it only handled double backslashes for some reason. Changing make-cmd to also handle single backslashes fixes rebuilds with dash, but it breaks bash again. The reason is that the two shells disagree about the interpretation of backslash sequences in the echo builtin. The way out of this is to print the command with printf '%s\n'. While at it, document what the individual parts of make-cmd do and why. Reported-and-tested-by: Konstantin Khlebnikov <koct9i@gmail.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include14
1 files changed, 8 insertions, 6 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 122f95c95869..8a9a4e1c7eab 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -215,11 +215,13 @@ else
215arg-check = $(if $(strip $(cmd_$@)),,1) 215arg-check = $(if $(strip $(cmd_$@)),,1)
216endif 216endif
217 217
218# >'< substitution is for echo to work, 218# Replace >$< with >$$< to preserve $ when reloading the .cmd file
219# >$< substitution to preserve $ when reloading .cmd file 219# (needed for make)
220# note: when using inline perl scripts [perl -e '...$$t=1;...'] 220# Replace >#< with >\#< to avoid starting a comment in the .cmd file
221# in $(cmd_xxx) double $$ your perl vars 221# (needed for make)
222make-cmd = $(subst \\,\\\\,$(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))) 222# Replace >'< with >'\''< to be able to enclose the whole string in '...'
223# (needed for the shell)
224make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
223 225
224# Find any prerequisites that is newer than target or that does not exist. 226# Find any prerequisites that is newer than target or that does not exist.
225# PHONY targets skipped in both cases. 227# PHONY targets skipped in both cases.
@@ -230,7 +232,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
230if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ 232if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
231 @set -e; \ 233 @set -e; \
232 $(echo-cmd) $(cmd_$(1)); \ 234 $(echo-cmd) $(cmd_$(1)); \
233 echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) 235 printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
234 236
235# Execute the command and also postprocess generated .d dependencies file. 237# Execute the command and also postprocess generated .d dependencies file.
236if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ 238if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \