aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2006-03-05 17:14:10 -0500
committerSam Ravnborg <sam@mars.ravnborg.org>2006-03-05 18:09:51 -0500
commit4f1933620f57145212cdbb1ac6ce099eeeb21c5a (patch)
treec083cce1f0acedd92be2ac6eb5e6c49ebd84ac46 /scripts
parent7b75b13cda8bd21e8636ea985f76e1ce5bd1a470 (diff)
kbuild: change kbuild to not rely on incorrect GNU make behavior
The kbuild system takes advantage of an incorrect behavior in GNU make. Once this behavior is fixed, all files in the kernel rebuild every time, even if nothing has changed. This patch ensures kbuild works with both the incorrect and correct behaviors of GNU make. For more details on the incorrect behavior, see: http://lists.gnu.org/archive/html/bug-make/2006-03/msg00003.html Changes in this patch: - Keep all targets that are to be marked .PHONY in a variable, PHONY. - Add .PHONY: $(PHONY) to mark them properly. - Remove any $(PHONY) files from the $? list when determining whether targets are up-to-date or not. Signed-off-by: Paul Smith <psmith@gnu.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include13
-rw-r--r--scripts/Makefile.build12
-rw-r--r--scripts/Makefile.clean10
-rw-r--r--scripts/Makefile.modinst10
-rw-r--r--scripts/Makefile.modpost12
-rw-r--r--scripts/kconfig/Makefile4
-rw-r--r--scripts/kconfig/lxdialog/Makefile6
-rw-r--r--scripts/package/Makefile10
8 files changed, 52 insertions, 25 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index c3d2e4e068c4..59620b1554e0 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -116,16 +116,18 @@ make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
116# function to only execute the passed command if necessary 116# function to only execute the passed command if necessary
117# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file 117# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
118# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars 118# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
119# 119#
120if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 120if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
121 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
121 @set -e; \ 122 @set -e; \
122 $(echo-cmd) $(cmd_$(1)); \ 123 $(echo-cmd) $(cmd_$(1)); \
123 echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) 124 echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
124 125
125# execute the command and also postprocess generated .d dependencies 126# execute the command and also postprocess generated .d dependencies
126# file 127# file
127if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ 128if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
128 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 129 $(filter-out FORCE $(wildcard $^),$^) \
130 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
129 @set -e; \ 131 @set -e; \
130 $(echo-cmd) $(cmd_$(1)); \ 132 $(echo-cmd) $(cmd_$(1)); \
131 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ 133 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
@@ -135,6 +137,7 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
135# Usage: $(call if_changed_rule,foo) 137# Usage: $(call if_changed_rule,foo)
136# will check if $(cmd_foo) changed, or any of the prequisites changed, 138# will check if $(cmd_foo) changed, or any of the prequisites changed,
137# and if so will execute $(rule_foo) 139# and if so will execute $(rule_foo)
138if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ 140if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
141 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
139 @set -e; \ 142 @set -e; \
140 $(rule_$(1))) 143 $(rule_$(1)))
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 6ac96ea92bfc..7afe3e76cb5a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -4,7 +4,7 @@
4 4
5src := $(obj) 5src := $(obj)
6 6
7.PHONY: __build 7PHONY := __build
8__build: 8__build:
9 9
10# Read .config if it exist, otherwise ignore 10# Read .config if it exist, otherwise ignore
@@ -308,14 +308,14 @@ targets += $(multi-used-y) $(multi-used-m)
308# Descending 308# Descending
309# --------------------------------------------------------------------------- 309# ---------------------------------------------------------------------------
310 310
311.PHONY: $(subdir-ym) 311PHONY += $(subdir-ym)
312$(subdir-ym): 312$(subdir-ym):
313 $(Q)$(MAKE) $(build)=$@ 313 $(Q)$(MAKE) $(build)=$@
314 314
315# Add FORCE to the prequisites of a target to force it to be always rebuilt. 315# Add FORCE to the prequisites of a target to force it to be always rebuilt.
316# --------------------------------------------------------------------------- 316# ---------------------------------------------------------------------------
317 317
318.PHONY: FORCE 318PHONY += FORCE
319 319
320FORCE: 320FORCE:
321 321
@@ -330,3 +330,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
330ifneq ($(cmd_files),) 330ifneq ($(cmd_files),)
331 include $(cmd_files) 331 include $(cmd_files)
332endif 332endif
333
334
335# Declare the contents of the .PHONY variable as phony. We keep that
336# information in a variable se we can use it in if_changed and friends.
337
338.PHONY: $(PHONY)
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 8974ea5fc878..cff33498fa16 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -4,7 +4,7 @@
4 4
5src := $(obj) 5src := $(obj)
6 6
7.PHONY: __clean 7PHONY := __clean
8__clean: 8__clean:
9 9
10# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir 10# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
@@ -87,10 +87,16 @@ endif
87# Descending 87# Descending
88# --------------------------------------------------------------------------- 88# ---------------------------------------------------------------------------
89 89
90.PHONY: $(subdir-ymn) 90PHONY += $(subdir-ymn)
91$(subdir-ymn): 91$(subdir-ymn):
92 $(Q)$(MAKE) $(clean)=$@ 92 $(Q)$(MAKE) $(clean)=$@
93 93
94# If quiet is set, only print short version of command 94# If quiet is set, only print short version of command
95 95
96cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) 96cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
97
98
99# Declare the contents of the .PHONY variable as phony. We keep that
100# information in a variable se we can use it in if_changed and friends.
101
102.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 23fd1bdc25ce..2686dd5dce8c 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -2,7 +2,7 @@
2# Installing modules 2# Installing modules
3# ========================================================================== 3# ==========================================================================
4 4
5.PHONY: __modinst 5PHONY := __modinst
6__modinst: 6__modinst:
7 7
8include scripts/Kbuild.include 8include scripts/Kbuild.include
@@ -12,7 +12,7 @@ include scripts/Kbuild.include
12__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 12__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
13modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) 13modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
14 14
15.PHONY: $(modules) 15PHONY += $(modules)
16__modinst: $(modules) 16__modinst: $(modules)
17 @: 17 @:
18 18
@@ -27,3 +27,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
27 27
28$(modules): 28$(modules):
29 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) 29 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
30
31
32# Declare the contents of the .PHONY variable as phony. We keep that
33# information in a variable se we can use it in if_changed and friends.
34
35.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 563e3c5bd8dd..0cfbe1cf2433 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -32,7 +32,7 @@
32# Step 4 is solely used to allow module versioning in external modules, 32# Step 4 is solely used to allow module versioning in external modules,
33# where the CRC of each module is retrieved from the Module.symers file. 33# where the CRC of each module is retrieved from the Module.symers file.
34 34
35.PHONY: _modpost 35PHONY := _modpost
36_modpost: __modpost 36_modpost: __modpost
37 37
38include .config 38include .config
@@ -60,7 +60,7 @@ quiet_cmd_modpost = MODPOST
60 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ 60 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
61 $(filter-out FORCE,$^) 61 $(filter-out FORCE,$^)
62 62
63.PHONY: __modpost 63PHONY += __modpost
64__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE 64__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
65 $(call cmd,modpost) 65 $(call cmd,modpost)
66 66
@@ -97,7 +97,7 @@ targets += $(modules)
97# Add FORCE to the prequisites of a target to force it to be always rebuilt. 97# Add FORCE to the prequisites of a target to force it to be always rebuilt.
98# --------------------------------------------------------------------------- 98# ---------------------------------------------------------------------------