summaryrefslogtreecommitdiff
path: root/scripts/Makefile.lib
diff options
context:
space:
mode:
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2003-02-10 09:27:47 -0600
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2003-02-10 09:27:47 -0600
commite9dfd3da8182d4f5ae6b2b1662ba5d33b4ddba7e (patch)
tree8ebc87657e37fe26dbd3110f9bbd89dec1163a2a /scripts/Makefile.lib
parent2c6837426285edc940ea621140d33765de9e41e5 (diff)
kbuild: Allow for ',$ in commands
Quote ',$ before passing them to the shell - ' must be escaped for echo, $$ will be converted to $ by make. This allows to use e.g. perl commands in the build with support from the generic $(call if_changed,...). by Konrad Eisele
Diffstat (limited to 'scripts/Makefile.lib')
-rw-r--r--scripts/Makefile.lib10
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 8c55475739ae..6877b8bd9c85 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -178,14 +178,16 @@ cmd_gzip = gzip -f -9 < $< > $@
# ===========================================================================
# function to only execute the passed command if necessary
+# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
+# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
if_changed = $(if $(strip $? \
$(filter-out $(cmd_$(1)),$(cmd_$@))\
$(filter-out $(cmd_$@),$(cmd_$(1)))),\
@set -e; \
- $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \
+ $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \
$(cmd_$(1)); \
- echo 'cmd_$@ := $(cmd_$(1))' > $(@D)/.$(@F).cmd)
+ echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
# execute the command and also postprocess generated .d dependencies
@@ -195,9 +197,9 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
$(filter-out $(cmd_$(1)),$(cmd_$@))\
$(filter-out $(cmd_$@),$(cmd_$(1)))),\
@set -e; \
- $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \
+ $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \
$(cmd_$(1)); \
- scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \
+ scripts/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
rm -f $(depfile); \
mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)