diff options
-rw-r--r-- | Makefile | 74 | ||||
-rw-r--r-- | scripts/Kbuild.include | 96 | ||||
-rw-r--r-- | scripts/Makefile.build | 1 | ||||
-rw-r--r-- | scripts/Makefile.lib | 94 | ||||
-rw-r--r-- | scripts/Makefile.modinst | 2 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 1 | ||||
-rw-r--r-- | usr/Makefile | 2 |
7 files changed, 103 insertions, 167 deletions
@@ -309,6 +309,9 @@ cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \ | |||
309 | # Look for make include files relative to root of kernel src | 309 | # Look for make include files relative to root of kernel src |
310 | MAKEFLAGS += --include-dir=$(srctree) | 310 | MAKEFLAGS += --include-dir=$(srctree) |
311 | 311 | ||
312 | # We need some generic definitions | ||
313 | include scripts/Kbuild.include | ||
314 | |||
312 | # For maximum performance (+ possibly random breakage, uncomment | 315 | # For maximum performance (+ possibly random breakage, uncomment |
313 | # the following) | 316 | # the following) |
314 | 317 | ||
@@ -367,11 +370,6 @@ export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE | |||
367 | # even be read-only. | 370 | # even be read-only. |
368 | export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions | 371 | export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions |
369 | 372 | ||
370 | # The temporary file to save gcc -MD generated dependencies must not | ||
371 | # contain a comma | ||
372 | comma := , | ||
373 | depfile = $(subst $(comma),_,$(@D)/.$(@F).d) | ||
374 | |||
375 | # Files to ignore in find ... statements | 373 | # Files to ignore in find ... statements |
376 | 374 | ||
377 | RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc \) -prune -o | 375 | RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc \) -prune -o |
@@ -1285,72 +1283,6 @@ ifneq ($(cmd_files),) | |||
1285 | include $(cmd_files) | 1283 | include $(cmd_files) |
1286 | endif | 1284 | endif |
1287 | 1285 | ||
1288 | # Execute command and generate cmd file | ||
1289 | if_changed = $(if $(strip $? \ | ||
1290 | $(filter-out $(cmd_$(1)),$(cmd_$@))\ | ||
1291 | $(filter-out $(cmd_$@),$(cmd_$(1)))),\ | ||
1292 | @set -e; \ | ||
1293 | $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \ | ||
1294 | $(cmd_$(1)); \ | ||
1295 | echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd) | ||
1296 | |||
1297 | |||
1298 | # execute the command and also postprocess generated .d dependencies | ||
1299 | # file | ||
1300 | if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ | ||
1301 | $(filter-out $(cmd_$(1)),$(cmd_$@))\ | ||
1302 | $(filter-out $(cmd_$@),$(cmd_$(1)))),\ | ||
1303 | $(Q)set -e; \ | ||
1304 | $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \ | ||
1305 | $(cmd_$(1)); \ | ||
1306 | scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \ | ||
1307 | rm -f $(depfile); \ | ||
1308 | mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) | ||
1309 | |||
1310 | # Usage: $(call if_changed_rule,foo) | ||
1311 | # will check if $(cmd_foo) changed, or any of the prequisites changed, | ||
1312 | # and if so will execute $(rule_foo) | ||
1313 | |||
1314 | if_changed_rule = $(if $(strip $? \ | ||
1315 | $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\ | ||
1316 | $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\ | ||
1317 | $(Q)$(rule_$(1))) | ||
1318 | |||
1319 | # If quiet is set, only print short version of command | ||
1320 | |||
1321 | cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) | ||
1322 | |||
1323 | # filechk is used to check if the content of a generated file is updated. | ||
1324 | # Sample usage: | ||
1325 | # define filechk_sample | ||
1326 | # echo $KERNELRELEASE | ||
1327 | # endef | ||
1328 | # version.h : Makefile | ||
1329 | # $(call filechk,sample) | ||
1330 | # The rule defined shall write to stdout the content of the new file. | ||
1331 | # The existing file will be compared with the new one. | ||
1332 | # - If no file exist it is created | ||
1333 | # - If the content differ the new file is used | ||
1334 | # - If they are equal no change, and no timestamp update | ||
1335 | |||
1336 | define filechk | ||
1337 | @set -e; \ | ||
1338 | echo ' CHK $@'; \ | ||
1339 | mkdir -p $(dir $@); \ | ||
1340 | $(filechk_$(1)) < $< > $@.tmp; \ | ||
1341 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | ||
1342 | rm -f $@.tmp; \ | ||
1343 | else \ | ||
1344 | echo ' UPD $@'; \ | ||
1345 | mv -f $@.tmp $@; \ | ||
1346 | fi | ||
1347 | endef | ||
1348 | |||
1349 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir | ||
1350 | # Usage: | ||
1351 | # $(Q)$(MAKE) $(build)=dir | ||
1352 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj | ||
1353 | |||
1354 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir | 1286 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir |
1355 | # Usage: | 1287 | # Usage: |
1356 | # $(Q)$(MAKE) $(clean)=dir | 1288 | # $(Q)$(MAKE) $(clean)=dir |
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include new file mode 100644 index 000000000000..9087273abf91 --- /dev/null +++ b/scripts/Kbuild.include | |||
@@ -0,0 +1,96 @@ | |||
1 | #### | ||
2 | # kbuild: Generic definitions | ||
3 | |||
4 | # Convinient variables | ||
5 | comma := , | ||
6 | empty := | ||
7 | space := $(empty) $(empty) | ||
8 | |||
9 | ### | ||
10 | # The temporary file to save gcc -MD generated dependencies must not | ||
11 | # contain a comma | ||
12 | depfile = $(subst $(comma),_,$(@D)/.$(@F).d) | ||
13 | |||
14 | ### | ||
15 | # filechk is used to check if the content of a generated file is updated. | ||
16 | # Sample usage: | ||
17 | # define filechk_sample | ||
18 | # echo $KERNELRELEASE | ||
19 | # endef | ||
20 | # version.h : Makefile | ||
21 | # $(call filechk,sample) | ||
22 | # The rule defined shall write to stdout the content of the new file. | ||
23 | # The existing file will be compared with the new one. | ||
24 | # - If no file exist it is created | ||
25 | # - If the content differ the new file is used | ||
26 | # - If they are equal no change, and no timestamp update | ||
27 | # - stdin is piped in from the first prerequisite ($<) so one has | ||
28 | # to specify a valid file as first prerequisite (often the kbuild file) | ||
29 | define filechk | ||
30 | $(Q)set -e; \ | ||
31 | echo ' CHK $@'; \ | ||
32 | mkdir -p $(dir $@); \ | ||
33 | $(filechk_$(1)) < $< > $@.tmp; \ | ||
34 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | ||
35 | rm -f $@.tmp; \ | ||
36 | else \ | ||
37 | echo ' UPD $@'; \ | ||
38 | mv -f $@.tmp $@; \ | ||
39 | fi | ||
40 | endef | ||
41 | |||
42 | ### | ||
43 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= | ||
44 | # Usage: | ||
45 | # $(Q)$(MAKE) $(build)=dir | ||
46 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj | ||
47 | |||
48 | # If quiet is set, only print short version of command | ||
49 | cmd = @$(if $($(quiet)cmd_$(1)),\ | ||
50 | echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1)) | ||
51 | |||
52 | ### | ||
53 | # if_changed - execute command if any prerequisite is newer than | ||
54 | # target, or command line has changed | ||
55 | # if_changed_dep - as if_changed, but uses fixdep to reveal dependencies | ||
56 | # including used config symbols | ||
57 | # if_changed_rule - as if_changed but execute rule instead | ||
58 | # See Documentation/kbuild/makefiles.txt for more info | ||
59 | |||
60 | ifneq ($(KBUILD_NOCMDDEP),1) | ||
61 | # Check if both arguments has same arguments. Result in empty string if equal | ||
62 | # User may override this check using make KBUILD_NOCMDDEP=1 | ||
63 | arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) ) | ||
64 | endif | ||
65 | |||
66 | # echo command. Short version is $(quiet) equals quiet, otherwise full command | ||
67 | echo-cmd = $(if $($(quiet)cmd_$(1)), \ | ||
68 | echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) | ||
69 | |||
70 | # function to only execute the passed command if necessary | ||
71 | # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file | ||
72 | # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars | ||
73 | # | ||
74 | if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ | ||
75 | @set -e; \ | ||
76 | $(echo-cmd) \ | ||
77 | $(cmd_$(1)); \ | ||
78 | echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd) | ||
79 | |||
80 | # execute the command and also postprocess generated .d dependencies | ||
81 | # file | ||
82 | if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ | ||
83 | $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ | ||
84 | @set -e; \ | ||
85 | $(echo-cmd) \ | ||
86 | $(cmd_$(1)); \ | ||
87 | scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \ | ||
88 | rm -f $(depfile); \ | ||
89 | mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) | ||
90 | |||
91 | # Usage: $(call if_changed_rule,foo) | ||
92 | # will check if $(cmd_foo) changed, or any of the prequisites changed, | ||
93 | # and if so will execute $(rule_foo) | ||
94 | if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ | ||
95 | @set -e; \ | ||
96 | $(rule_$(1))) | ||
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 282bfb310f5b..ebed6a41bc69 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -12,6 +12,7 @@ __build: | |||
12 | 12 | ||
13 | include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile) | 13 | include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile) |
14 | 14 | ||
15 | include scripts/Kbuild.include | ||
15 | include scripts/Makefile.lib | 16 | include scripts/Makefile.lib |
16 | 17 | ||
17 | ifdef host-progs | 18 | ifdef host-progs |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 6e079f38a2c6..0f81dcfd6909 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -1,13 +1,3 @@ | |||
1 | # =========================================================================== | ||
2 | # kbuild: Generic definitions | ||
3 | # =========================================================================== | ||
4 | |||
5 | # Standard vars | ||
6 | |||
7 | comma := , | ||
8 | empty := | ||
9 | space := $(empty) $(empty) | ||
10 | |||
11 | # Backward compatibility - to be removed... | 1 | # Backward compatibility - to be removed... |
12 | extra-y += $(EXTRA_TARGETS) | 2 | extra-y += $(EXTRA_TARGETS) |
13 | # Figure out what we need to build from the various variables | 3 | # Figure out what we need to build from the various variables |
@@ -84,10 +74,6 @@ multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) | |||
84 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) | 74 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) |
85 | obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) | 75 | obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) |
86 | 76 | ||
87 | # The temporary file to save gcc -MD generated dependencies must not | ||
88 | # contain a comma | ||
89 | depfile = $(subst $(comma),_,$(@D)/.$(@F).d) | ||
90 | |||
91 | # These flags are needed for modversions and compiling, so we define them here | 77 | # These flags are needed for modversions and compiling, so we define them here |
92 | # already | 78 | # already |
93 | # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will | 79 | # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will |
@@ -179,84 +165,4 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ | |||
179 | quiet_cmd_gzip = GZIP $@ | 165 | quiet_cmd_gzip = GZIP $@ |
180 | cmd_gzip = gzip -f -9 < $< > $@ | 166 | cmd_gzip = gzip -f -9 < $< > $@ |
181 | 167 | ||
182 | # =========================================================================== | ||
183 | # Generic stuff | ||
184 | # =========================================================================== | ||
185 | |||
186 | ifneq ($(KBUILD_NOCMDDEP),1) | ||
187 | # Check if both arguments has same arguments. Result in empty string if equal | ||
188 | # User may override this check using make KBUILD_NOCMDDEP=1 | ||
189 | arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) ) | ||
190 | |||
191 | endif | ||
192 | |||
193 | # echo command. Short version is $(quiet) equals quiet, otherwise full command | ||
194 | echo-cmd = $(if $($(quiet)cmd_$(1)), \ | ||
195 | echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) | ||
196 | |||
197 | # function to only execute the passed command if necessary | ||
198 | # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file | ||
199 | # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars | ||
200 | # | ||
201 | if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ | ||
202 | @set -e; \ | ||
203 | $(echo-cmd) \ | ||
204 | $(cmd_$(1)); \ | ||
205 | echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd) | ||
206 | |||
207 | |||
208 | # execute the command and also postprocess generated .d dependencies | ||
209 | # file | ||
210 | |||
211 | if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ | ||
212 | $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ | ||
213 | @set -e; \ | ||
214 | $(echo-cmd) \ | ||
215 | $(cmd_$(1)); \ | ||
216 | scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \ | ||
217 | rm -f $(depfile); \ | ||
218 | mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) | ||
219 | |||
220 | # Usage: $(call if_changed_rule,foo) | ||
221 | # will check if $(cmd_foo) changed, or any of the prequisites changed, | ||
222 | # and if so will execute $(rule_foo) | ||
223 | |||
224 | if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ | ||
225 | @set -e; \ | ||
226 | $(rule_$(1))) | ||
227 | |||
228 | # If quiet is set, only print short version of command | ||
229 | |||
230 | cmd = @$(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1)) | ||
231 | |||
232 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= | ||
233 | # Usage: | ||
234 | # $(Q)$(MAKE) $(build)=dir | ||
235 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj | ||
236 | |||
237 | # filechk is used to check if the content of a generated file is updated. | ||
238 | # Sample usage: | ||
239 | # define filechk_sample | ||
240 | # echo $KERNELRELEASE | ||
241 | # endef | ||
242 | # version.h : Makefile | ||
243 | # $(call filechk,sample) | ||
244 | # The rule defined shall write to stdout the content of the new file. | ||
245 | # The existing file will be compared with the new one. | ||
246 | # - If no file exist it is created | ||
247 | # - If the content differ the new file is used | ||
248 | # - If they are equal no change, and no timestamp update | ||
249 | |||
250 | define filechk | ||
251 | $(Q)set -e; \ | ||
252 | echo ' CHK $@'; \ | ||
253 | mkdir -p $(dir $@); \ | ||
254 | $(filechk_$(1)) $(2) > $@.tmp; \ | ||
255 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | ||
256 | rm -f $@.tmp; \ | ||
257 | else \ | ||
258 | echo ' UPD $@'; \ | ||
259 | mv -f $@.tmp $@; \ | ||
260 | fi | ||
261 | endef | ||
262 | 168 | ||
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 85d6494e3c24..23fd1bdc25ce 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst | |||
@@ -5,7 +5,7 @@ | |||
5 | .PHONY: __modinst | 5 | .PHONY: __modinst |
6 | __modinst: | 6 | __modinst: |
7 | 7 | ||
8 | include scripts/Makefile.lib | 8 | include scripts/Kbuild.include |
9 | 9 | ||
10 | # | 10 | # |
11 | 11 | ||
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 94b550e21be8..0c4f3a9f2ea9 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -36,6 +36,7 @@ | |||
36 | _modpost: __modpost | 36 | _modpost: __modpost |
37 | 37 | ||
38 | include .config | 38 | include .config |
39 | include scripts/Kbuild.include | ||
39 | include scripts/Makefile.lib | 40 | include scripts/Makefile.lib |
40 | 41 | ||
41 | symverfile := $(objtree)/Module.symvers | 42 | symverfile := $(objtree)/Module.symvers |
diff --git a/usr/Makefile b/usr/Makefile index 248d5551029d..e2129cb570bb 100644 --- a/usr/Makefile +++ b/usr/Makefile | |||
@@ -27,7 +27,7 @@ quotefixed_initramfs_source := $(shell echo $(CONFIG_INITRAMFS_SOURCE)) | |||
27 | filechk_initramfs_list = $(CONFIG_SHELL) \ | 27 | filechk_initramfs_list = $(CONFIG_SHELL) \ |
28 | $(srctree)/scripts/gen_initramfs_list.sh $(gen_initramfs_args) $(quotefixed_initramfs_source) | 28 | $(srctree)/scripts/gen_initramfs_list.sh $(gen_initramfs_args) $(quotefixed_initramfs_source) |
29 | 29 | ||
30 | $(obj)/initramfs_list: FORCE | 30 | $(obj)/initramfs_list: $(obj)/Makefile FORCE |
31 | $(call filechk,initramfs_list) | 31 | $(call filechk,initramfs_list) |
32 | 32 | ||
33 | quiet_cmd_cpio = CPIO $@ | 33 | quiet_cmd_cpio = CPIO $@ |