aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include13
-rw-r--r--scripts/Makefile.build4
2 files changed, 11 insertions, 6 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index db3c708e546b..0168d6c37075 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -3,6 +3,7 @@
3 3
4# Convinient variables 4# Convinient variables
5comma := , 5comma := ,
6squote := '
6empty := 7empty :=
7space := $(empty) $(empty) 8space := $(empty) $(empty)
8 9
@@ -12,6 +13,10 @@ space := $(empty) $(empty)
12depfile = $(subst $(comma),_,$(@D)/.$(@F).d) 13depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
13 14
14### 15###
16# Escape single quote for use in echo statements
17escsq = $(subst $(squote),'\$(squote)',$1)
18
19###
15# filechk is used to check if the content of a generated file is updated. 20# filechk is used to check if the content of a generated file is updated.
16# Sample usage: 21# Sample usage:
17# define filechk_sample 22# define filechk_sample
@@ -47,7 +52,7 @@ build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
47 52
48# If quiet is set, only print short version of command 53# If quiet is set, only print short version of command
49cmd = @$(if $($(quiet)cmd_$(1)),\ 54cmd = @$(if $($(quiet)cmd_$(1)),\
50 echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1)) 55 echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
51 56
52# Add $(obj)/ for paths that is not absolute 57# Add $(obj)/ for paths that is not absolute
53objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) 58objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
@@ -68,7 +73,7 @@ endif
68 73
69# echo command. Short version is $(quiet) equals quiet, otherwise full command 74# echo command. Short version is $(quiet) equals quiet, otherwise full command
70echo-cmd = $(if $($(quiet)cmd_$(1)), \ 75echo-cmd = $(if $($(quiet)cmd_$(1)), \
71 echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) 76 echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
72 77
73# function to only execute the passed command if necessary 78# function to only execute the passed command if necessary
74# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file 79# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
@@ -78,7 +83,7 @@ if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
78 @set -e; \ 83 @set -e; \
79 $(echo-cmd) \ 84 $(echo-cmd) \
80 $(cmd_$(1)); \ 85 $(cmd_$(1)); \
81 echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd) 86 echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
82 87
83# execute the command and also postprocess generated .d dependencies 88# execute the command and also postprocess generated .d dependencies
84# file 89# file
@@ -87,7 +92,7 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
87 @set -e; \ 92 @set -e; \
88 $(echo-cmd) \ 93 $(echo-cmd) \
89 $(cmd_$(1)); \ 94 $(cmd_$(1)); \
90 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \ 95 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
91 rm -f $(depfile); \ 96 rm -f $(depfile); \
92 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) 97 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
93 98
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 506e3f3befe3..c33e62bde6b0 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -179,10 +179,10 @@ endif
179define rule_cc_o_c 179define rule_cc_o_c
180 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \ 180 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \
181 $(cmd_checksrc) \ 181 $(cmd_checksrc) \
182 $(if $($(quiet)cmd_cc_o_c),echo ' $(subst ','\'',$($(quiet)cmd_cc_o_c))';) \ 182 $(if $($(quiet)cmd_cc_o_c),echo ' $(call escsq,$($(quiet)cmd_cc_o_c))';) \
183 $(cmd_cc_o_c); \ 183 $(cmd_cc_o_c); \
184 $(cmd_modversions) \ 184 $(cmd_modversions) \
185 scripts/basic/fixdep $(depfile) $@ '$(subst ','\'',$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \ 185 scripts/basic/fixdep $(depfile) $@ '$(call escsq,$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \
186 rm -f $(depfile); \ 186 rm -f $(depfile); \
187 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd 187 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
188endef 188endef