aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/Kbuild.include52
-rw-r--r--scripts/Makefile.build5
-rw-r--r--usr/Makefile2
3 files changed, 35 insertions, 24 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index bb19c1561f1e..1d6ffb26e20f 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -8,9 +8,13 @@ empty :=
8space := $(empty) $(empty) 8space := $(empty) $(empty)
9 9
10### 10###
11# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
12dot-target = $(dir $@).$(notdir $@)
13
14###
11# The temporary file to save gcc -MD generated dependencies must not 15# The temporary file to save gcc -MD generated dependencies must not
12# contain a comma 16# contain a comma
13depfile = $(subst $(comma),_,$(@D)/.$(@F).d) 17depfile = $(subst $(comma),_,$(dot-target).d)
14 18
15### 19###
16# filename of target with directory and extension stripped 20# filename of target with directory and extension stripped
@@ -119,40 +123,44 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
119ifneq ($(KBUILD_NOCMDDEP),1) 123ifneq ($(KBUILD_NOCMDDEP),1)
120# Check if both arguments has same arguments. Result in empty string if equal 124# Check if both arguments has same arguments. Result in empty string if equal
121# User may override this check using make KBUILD_NOCMDDEP=1 125# User may override this check using make KBUILD_NOCMDDEP=1
122arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) ) 126arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
127 $(filter-out $(cmd_$@), $(cmd_$(1))) )
123endif 128endif
124 129
125# echo command. Short version is $(quiet) equals quiet, otherwise full command 130# echo command. Short version is $(quiet) equals quiet, otherwise full command
126echo-cmd = $(if $($(quiet)cmd_$(1)), \ 131echo-cmd = $(if $($(quiet)cmd_$(1)), \
127 echo ' $(call escsq,$($(quiet)cmd_$(1)))';) 132 echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
128 133
134# >'< substitution is for echo to work,
135# >$< substitution to preserve $ when reloading .cmd file
136# note: when using inline perl scripts [perl -e '...$$t=1;...']
137# in $(cmd_xxx) double $$ your perl vars
129make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) 138make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
130 139
131# function to only execute the passed command if necessary 140# Find any prerequisites that is newer than target or that does not exist.
132# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file 141# PHONY targets skipped in both cases.
133# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars 142any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
143
144# Execute command if command has changed or prerequisitei(s) are updated
134# 145#
135if_changed = $(if $(strip $(filter-out $(PHONY),$?) \ 146if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
136 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 147 @set -e; \
137 @set -e; \ 148 $(echo-cmd) $(cmd_$(1)); \
138 $(echo-cmd) $(cmd_$(1)); \ 149 echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
139 echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
140 150
141# execute the command and also postprocess generated .d dependencies 151# execute the command and also postprocess generated .d dependencies
142# file 152# file
143if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \ 153if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
144 $(filter-out FORCE $(wildcard $^),$^) \ 154 @set -e; \
145 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 155 $(echo-cmd) $(cmd_$(1)); \
146 @set -e; \ 156 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
147 $(echo-cmd) $(cmd_$(1)); \ 157 rm -f $(depfile); \
148 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ 158 mv -f $(dot-target).tmp $(dot-target).cmd)
149 rm -f $(depfile); \
150 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
151 159
152# Usage: $(call if_changed_rule,foo) 160# Usage: $(call if_changed_rule,foo)
153# will check if $(cmd_foo) changed, or any of the prequisites changed, 161# will check if $(cmd_foo) changed, or any of the prequisites changed,
154# and if so will execute $(rule_foo) 162# and if so will execute $(rule_foo)
155if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \ 163if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \
156 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ 164 @set -e; \
157 @set -e; \ 165 $(rule_$(1)))
158 $(rule_$(1))) 166
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 3cb445cc7432..e2ad2dccccdb 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -191,9 +191,10 @@ define rule_cc_o_c
191 $(call echo-cmd,checksrc) $(cmd_checksrc) \ 191 $(call echo-cmd,checksrc) $(cmd_checksrc) \
192 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ 192 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
193 $(cmd_modversions) \ 193 $(cmd_modversions) \
194 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \ 194 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
195 $(dot-target).tmp; \
195 rm -f $(depfile); \ 196 rm -f $(depfile); \
196 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd 197 mv -f $(dot-target).tmp $(dot-target).cmd
197endef 198endef
198 199
199# Built-in and composite module parts 200# Built-in and composite module parts
diff --git a/usr/Makefile b/usr/Makefile
index 5b31c0b61c76..e338e7bedb29 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -3,6 +3,8 @@
3# 3#
4 4
5klibcdirs:; 5klibcdirs:;
6PHONY += klibcdirs
7
6 8
7# Generate builtin.o based on initramfs_data.o 9# Generate builtin.o based on initramfs_data.o
8obj-y := initramfs_data.o 10obj-y := initramfs_data.o