diff options
author | Paul Smith <psmith@gnu.org> | 2006-03-05 17:14:10 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-03-05 18:09:51 -0500 |
commit | 4f1933620f57145212cdbb1ac6ce099eeeb21c5a (patch) | |
tree | c083cce1f0acedd92be2ac6eb5e6c49ebd84ac46 /Makefile | |
parent | 7b75b13cda8bd21e8636ea985f76e1ce5bd1a470 (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 'Makefile')
-rw-r--r-- | Makefile | 64 |
1 files changed, 35 insertions, 29 deletions
@@ -95,7 +95,7 @@ ifdef O | |||
95 | endif | 95 | endif |
96 | 96 | ||
97 | # That's our default target when none is given on the command line | 97 | # That's our default target when none is given on the command line |
98 | .PHONY: _all | 98 | PHONY := _all |
99 | _all: | 99 | _all: |
100 | 100 | ||
101 | ifneq ($(KBUILD_OUTPUT),) | 101 | ifneq ($(KBUILD_OUTPUT),) |
@@ -106,7 +106,7 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) | |||
106 | $(if $(KBUILD_OUTPUT),, \ | 106 | $(if $(KBUILD_OUTPUT),, \ |
107 | $(error output directory "$(saved-output)" does not exist)) | 107 | $(error output directory "$(saved-output)" does not exist)) |
108 | 108 | ||
109 | .PHONY: $(MAKECMDGOALS) | 109 | PHONY += $(MAKECMDGOALS) |
110 | 110 | ||
111 | $(filter-out _all,$(MAKECMDGOALS)) _all: | 111 | $(filter-out _all,$(MAKECMDGOALS)) _all: |
112 | $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ | 112 | $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ |
@@ -123,7 +123,7 @@ ifeq ($(skip-makefile),) | |||
123 | 123 | ||
124 | # If building an external module we do not care about the all: rule | 124 | # If building an external module we do not care about the all: rule |
125 | # but instead _all depend on modules | 125 | # but instead _all depend on modules |
126 | .PHONY: all | 126 | PHONY += all |
127 | ifeq ($(KBUILD_EXTMOD),) | 127 | ifeq ($(KBUILD_EXTMOD),) |
128 | _all: all | 128 | _all: all |
129 | else | 129 | else |
@@ -337,14 +337,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc | |||
337 | # Rules shared between *config targets and build targets | 337 | # Rules shared between *config targets and build targets |
338 | 338 | ||
339 | # Basic helpers built in scripts/ | 339 | # Basic helpers built in scripts/ |
340 | .PHONY: scripts_basic | 340 | PHONY += scripts_basic |
341 | scripts_basic: | 341 | scripts_basic: |
342 | $(Q)$(MAKE) $(build)=scripts/basic | 342 | $(Q)$(MAKE) $(build)=scripts/basic |
343 | 343 | ||
344 | # To avoid any implicit rule to kick in, define an empty command. | 344 | # To avoid any implicit rule to kick in, define an empty command. |
345 | scripts/basic/%: scripts_basic ; | 345 | scripts/basic/%: scripts_basic ; |
346 | 346 | ||
347 | .PHONY: outputmakefile | 347 | PHONY += outputmakefile |
348 | # outputmakefile generate a Makefile to be placed in output directory, if | 348 | # outputmakefile generate a Makefile to be placed in output directory, if |
349 | # using a seperate output directory. This allows convinient use | 349 | # using a seperate output directory. This allows convinient use |
350 | # of make in output directory | 350 | # of make in output directory |
@@ -420,7 +420,7 @@ ifeq ($(KBUILD_EXTMOD),) | |||
420 | # Additional helpers built in scripts/ | 420 | # Additional helpers built in scripts/ |
421 | # Carefully list dependencies so we do not try to build scripts twice | 421 | # Carefully list dependencies so we do not try to build scripts twice |
422 | # in parrallel | 422 | # in parrallel |
423 | .PHONY: scripts | 423 | PHONY += scripts |
424 | scripts: scripts_basic include/config/MARKER | 424 | scripts: scripts_basic include/config/MARKER |
425 | $(Q)$(MAKE) $(build)=$(@) | 425 | $(Q)$(MAKE) $(build)=$(@) |
426 | 426 | ||
@@ -720,7 +720,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; | |||
720 | # make menuconfig etc. | 720 | # make menuconfig etc. |
721 | # Error messages still appears in the original language | 721 | # Error messages still appears in the original language |
722 | 722 | ||
723 | .PHONY: $(vmlinux-dirs) | 723 | PHONY += $(vmlinux-dirs) |
724 | $(vmlinux-dirs): prepare scripts | 724 | $(vmlinux-dirs): prepare scripts |
725 | $(Q)$(MAKE) $(build)=$@ | 725 | $(Q)$(MAKE) $(build)=$@ |
726 | 726 | ||
@@ -773,10 +773,10 @@ kernelrelease = $(KERNELVERSION)$(localver-full) | |||
773 | # version.h and scripts_basic is processed / created. | 773 | # version.h and scripts_basic is processed / created. |
774 | 774 | ||
775 | # Listed in dependency order | 775 | # Listed in dependency order |
776 | .PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 | 776 | PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 |
777 | 777 | ||
778 | # prepare-all is deprecated, use prepare as valid replacement | 778 | # prepare-all is deprecated, use prepare as valid replacement |
779 | .PHONY: prepare-all | 779 | PHONY += prepare-all |
780 | 780 | ||
781 | # prepare3 is used to check if we are building in a separate output directory, | 781 | # prepare3 is used to check if we are building in a separate output directory, |
782 | # and if so do: | 782 | # and if so do: |
@@ -857,7 +857,7 @@ include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE | |||
857 | 857 | ||
858 | # --------------------------------------------------------------------------- | 858 | # --------------------------------------------------------------------------- |
859 | 859 | ||
860 | .PHONY: depend dep | 860 | PHONY += depend dep |
861 | depend dep: | 861 | depend dep: |
862 | @echo '*** Warning: make $@ is unnecessary now.' | 862 | @echo '*** Warning: make $@ is unnecessary now.' |
863 | 863 | ||
@@ -872,21 +872,21 @@ all: modules | |||
872 | 872 | ||
873 | # Build modules | 873 | # Build modules |
874 | 874 | ||
875 | .PHONY: modules | 875 | PHONY += modules |
876 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) | 876 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) |
877 | @echo ' Building modules, stage 2.'; | 877 | @echo ' Building modules, stage 2.'; |
878 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost | 878 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost |
879 | 879 | ||
880 | 880 | ||
881 | # Target to prepare building external modules | 881 | # Target to prepare building external modules |
882 | .PHONY: modules_prepare | 882 | PHONY += modules_prepare |
883 | modules_prepare: prepare scripts | 883 | modules_prepare: prepare scripts |
884 | 884 | ||
885 | # Target to install modules | 885 | # Target to install modules |
886 | .PHONY: modules_install | 886 | PHONY += modules_install |
887 | modules_install: _modinst_ _modinst_post | 887 | modules_install: _modinst_ _modinst_post |
888 | 888 | ||
889 | .PHONY: _modinst_ | 889 | PHONY += _modinst_ |
890 | _modinst_: | 890 | _modinst_: |
891 | @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ | 891 | @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ |
892 | echo "Warning: you may need to install module-init-tools"; \ | 892 | echo "Warning: you may need to install module-init-tools"; \ |
@@ -913,7 +913,7 @@ depmod_opts := | |||
913 | else | 913 | else |
914 | depmod_opts := -b $(INSTALL_MOD_PATH) -r | 914 | depmod_opts := -b $(INSTALL_MOD_PATH) -r |
915 | endif | 915 | endif |
916 | .PHONY: _modinst_post | 916 | PHONY += _modinst_post |
917 | _modinst_post: _modinst_ | 917 | _modinst_post: _modinst_ |
918 | if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi | 918 | if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi |
919 | 919 | ||
@@ -956,7 +956,7 @@ clean: rm-dirs := $(CLEAN_DIRS) | |||
956 | clean: rm-files := $(CLEAN_FILES) | 956 | clean: rm-files := $(CLEAN_FILES) |
957 | clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) | 957 | clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) |
958 | 958 | ||
959 | .PHONY: $(clean-dirs) clean archclean | 959 | PHONY += $(clean-dirs) clean archclean |
960 | $(clean-dirs): | 960 | $(clean-dirs): |
961 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) | 961 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
962 | 962 | ||
@@ -974,7 +974,7 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) | |||
974 | mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) | 974 | mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) |
975 | mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) | 975 | mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) |
976 | 976 | ||
977 | .PHONY: $(mrproper-dirs) mrproper archmrproper | 977 | PHONY += $(mrproper-dirs) mrproper archmrproper |
978 | $(mrproper-dirs): | 978 | $(mrproper-dirs): |
979 | $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) | 979 | $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) |
980 | 980 | ||
@@ -984,7 +984,7 @@ mrproper: clean archmrproper $(mrproper-dirs) | |||
984 | 984 | ||
985 | # distclean | 985 | # distclean |
986 | # | 986 | # |
987 | .PHONY: distclean | 987 | PHONY += distclean |
988 | 988 | ||
989 | distclean: mrproper | 989 | distclean: mrproper |
990 | @find $(srctree) $(RCS_FIND_IGNORE) \ | 990 | @find $(srctree) $(RCS_FIND_IGNORE) \ |
@@ -1000,7 +1000,7 @@ distclean: mrproper | |||
1000 | # rpm target kept for backward compatibility | 1000 | # rpm target kept for backward compatibility |
1001 | package-dir := $(srctree)/scripts/package | 1001 | package-dir := $(srctree)/scripts/package |
1002 | 1002 | ||
1003 | .PHONY: %-pkg rpm | 1003 | PHONY += %-pkg rpm |
1004 | 1004 | ||
1005 | %pkg: FORCE | 1005 | %pkg: FORCE |
1006 | $(Q)$(MAKE) -f $(package-dir)/Makefile $@ | 1006 | $(Q)$(MAKE) -f $(package-dir)/Makefile $@ |
@@ -1092,12 +1092,12 @@ else # KBUILD_EXTMOD | |||
1092 | 1092 | ||
1093 | # We are always building modules | 1093 | # We are always building modules |
1094 | KBUILD_MODULES := 1 | 1094 | KBUILD_MODULES := 1 |
1095 | .PHONY: crmodverdir | 1095 | PHONY += crmodverdir |
1096 | crmodverdir: | 1096 | crmodverdir: |
1097 | $(Q)rm -rf $(MODVERDIR) | 1097 | $(Q)rm -rf $(MODVERDIR) |
1098 | $(Q)mkdir -p $(MODVERDIR) | 1098 | $(Q)mkdir -p $(MODVERDIR) |
1099 | 1099 | ||
1100 | .PHONY: $(objtree)/Module.symvers | 1100 | PHONY += $(objtree)/Module.symvers |
1101 | $(objtree)/Module.symvers: | 1101 | $(objtree)/Module.symvers: |
1102 | @test -e $(objtree)/Module.symvers || ( \ | 1102 | @test -e $(objtree)/Module.symvers || ( \ |
1103 | echo; \ | 1103 | echo; \ |
@@ -1106,7 +1106,7 @@ $(objtree)/Module.symvers: | |||
1106 | echo ) | 1106 | echo ) |
1107 | 1107 | ||
1108 | module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) | 1108 | module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) |
1109 | .PHONY: $(module-dirs) modules | 1109 | PHONY += $(module-dirs) modules |
1110 | $(module-dirs): crmodverdir $(objtree)/Module.symvers | 1110 | $(module-dirs): crmodverdir $(objtree)/Module.symvers |
1111 | $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) | 1111 | $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) |
1112 | 1112 | ||
@@ -1114,11 +1114,11 @@ modules: $(module-dirs) | |||
1114 | @echo ' Building modules, stage 2.'; | 1114 | @echo ' Building modules, stage 2.'; |
1115 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost | 1115 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost |
1116 | 1116 | ||
1117 | .PHONY: modules_install | 1117 | PHONY += modules_install |
1118 | modules_install: _emodinst_ _emodinst_post | 1118 | modules_install: _emodinst_ _emodinst_post |
1119 | 1119 | ||
1120 | install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) | 1120 | install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) |
1121 | .PHONY: _emodinst_ | 1121 | PHONY += _emodinst_ |
1122 | _emodinst_: | 1122 | _emodinst_: |
1123 | $(Q)rm -rf $(MODLIB)/$(install-dir) | 1123 | $(Q)rm -rf $(MODLIB)/$(install-dir) |
1124 | $(Q)mkdir -p $(MODLIB)/$(install-dir) | 1124 | $(Q)mkdir -p $(MODLIB)/$(install-dir) |
@@ -1133,13 +1133,13 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) | |||
1133 | $(KERNELRELEASE); \ | 1133 | $(KERNELRELEASE); \ |
1134 | fi | 1134 | fi |
1135 | 1135 | ||
1136 | .PHONY: _emodinst_post | 1136 | PHONY += _emodinst_post |
1137 | _emodinst_post: _emodinst_ | 1137 | _emodinst_post: _emodinst_ |
1138 | $(call cmd,depmod) | 1138 | $(call cmd,depmod) |
1139 | 1139 | ||
1140 | clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) | 1140 | clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) |
1141 | 1141 | ||
1142 | .PHONY: $(clean-dirs) clean | 1142 | PHONY += $(clean-dirs) clean |
1143 | $(clean-dirs): | 1143 | $(clean-dirs): |
1144 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) | 1144 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
1145 | 1145 | ||
@@ -1161,7 +1161,7 @@ help: | |||
1161 | @echo '' | 1161 | @echo '' |
1162 | 1162 | ||
1163 | # Dummies... | 1163 | # Dummies... |
1164 | .PHONY: prepare scripts | 1164 | PHONY += prepare scripts |
1165 | prepare: ; | 1165 | prepare: ; |
1166 | scripts: ; | 1166 | scripts: ; |
1167 | endif # KBUILD_EXTMOD | 1167 | endif # KBUILD_EXTMOD |
@@ -1274,7 +1274,7 @@ namespacecheck: | |||
1274 | endif #ifeq ($(config-targets),1) | 1274 | endif #ifeq ($(config-targets),1) |
1275 | endif #ifeq ($(mixed-targets),1) | 1275 | endif #ifeq ($(mixed-targets),1) |
1276 | 1276 | ||
1277 | .PHONY: checkstack | 1277 | PHONY += checkstack |
1278 | checkstack: | 1278 | checkstack: |
1279 | $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ | 1279 | $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ |
1280 | $(PERL) $(src)/scripts/checkstack.pl $(ARCH) | 1280 | $(PERL) $(src)/scripts/checkstack.pl $(ARCH) |
@@ -1357,4 +1357,10 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj | |||
1357 | 1357 | ||
1358 | endif # skip-makefile | 1358 | endif # skip-makefile |
1359 | 1359 | ||
1360 | PHONY += FORCE | ||
1360 | FORCE: | 1361 | FORCE: |
1362 | |||
1363 | |||
1364 | # Declare the contents of the .PHONY variable as phony. We keep that | ||
1365 | # information in a variable se we can use it in if_changed and friends. | ||
1366 | .PHONY: $(PHONY) | ||