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# ---------------------------------------------------------------------------
99 99
100.PHONY: FORCE 100PHONY += FORCE
101 101
102FORCE: 102FORCE:
103 103
@@ -112,3 +112,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
112ifneq ($(cmd_files),) 112ifneq ($(cmd_files),)
113 include $(cmd_files) 113 include $(cmd_files)
114endif 114endif
115
116
117# Declare the contents of the .PHONY variable as phony. We keep that
118# information in a variable se we can use it in if_changed and friends.
119
120.PHONY: $(PHONY)
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 52809450bee4..e6499db4c8cc 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,7 +2,7 @@
2# Kernel configuration targets 2# Kernel configuration targets
3# These targets are used from top-level makefile 3# These targets are used from top-level makefile
4 4
5.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config 5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
6 6
7xconfig: $(obj)/qconf 7xconfig: $(obj)/qconf
8 $< arch/$(ARCH)/Kconfig 8 $< arch/$(ARCH)/Kconfig
@@ -42,7 +42,7 @@ update-po-config: $(obj)/kxgettext
42 $(Q)rm -f arch/um/Kconfig_arch 42 $(Q)rm -f arch/um/Kconfig_arch
43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot 43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
44 44
45.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig 45PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
46 46
47randconfig: $(obj)/conf 47randconfig: $(obj)/conf
48 $< -r arch/$(ARCH)/Kconfig 48 $< -r arch/$(ARCH)/Kconfig
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile
index bbf4887cff74..a8b026326247 100644
--- a/scripts/kconfig/lxdialog/Makefile
+++ b/scripts/kconfig/lxdialog/Makefile
@@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
7# we really need to do so. (Do not call gcc as part of make mrproper) 7# we really need to do so. (Do not call gcc as part of make mrproper)
8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) 8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
10
11HOST_EXTRACFLAGS += -DLOCALE
12 10
13.PHONY: dochecklxdialog 11HOST_EXTRACFLAGS += -DLOCALE
12
13PHONY += dochecklxdialog
14$(obj)/dochecklxdialog: 14$(obj)/dochecklxdialog:
15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) 15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
16 16
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index c201ef001f09..d3038b7643ae 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -32,7 +32,7 @@ MKSPEC := $(srctree)/scripts/package/mkspec
32PREV := set -e; cd ..; 32PREV := set -e; cd ..;
33 33
34# rpm-pkg 34# rpm-pkg
35.PHONY: rpm-pkg rpm 35PHONY += rpm-pkg rpm
36 36
37$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile 37$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
38 $(CONFIG_SHELL) $(MKSPEC) > $@ 38 $(CONFIG_SHELL) $(MKSPEC) > $@
@@ -54,10 +54,10 @@ rpm-pkg rpm: $(objtree)/kernel.spec
54clean-files := $(objtree)/kernel.spec 54clean-files := $(objtree)/kernel.spec
55 55
56# binrpm-pkg 56# binrpm-pkg
57.PHONY: binrpm-pkg 57PHONY += binrpm-pkg
58$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile 58$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
59 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ 59 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
60 60
61binrpm-pkg: $(objtree)/binkernel.spec 61binrpm-pkg: $(objtree)/binkernel.spec
62 $(MAKE) KBUILD_SRC= 62 $(MAKE) KBUILD_SRC=
63 set -e; \ 63 set -e; \
@@ -72,7 +72,7 @@ clean-files += $(objtree)/binkernel.spec
72# Deb target 72# Deb target
73# --------------------------------------------------------------------------- 73# ---------------------------------------------------------------------------
74# 74#
75.PHONY: deb-pkg 75PHONY += deb-pkg
76deb-pkg: 76deb-pkg:
77 $(MAKE) KBUILD_SRC= 77 $(MAKE) KBUILD_SRC=
78 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 78 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
@@ -82,7 +82,7 @@ clean-dirs += $(objtree)/debian/
82 82
83# tarball targets 83# tarball targets
84# --------------------------------------------------------------------------- 84# ---------------------------------------------------------------------------
85.PHONY: tar%pkg 85PHONY += tar%pkg
86tar%pkg: 86tar%pkg:
87 $(MAKE) KBUILD_SRC= 87 $(MAKE) KBUILD_SRC=
88 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ 88 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@