Commit 4f1933620f57145212cdbb1ac6ce099eeeb21c5a

Authored by Paul Smith
Committed by Sam Ravnborg
1 parent 7b75b13cda

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>

Showing 25 changed files with 144 additions and 75 deletions Side-by-side Diff

Documentation/DocBook/Makefile
... ... @@ -28,7 +28,7 @@
28 28  
29 29 ###
30 30 # The targets that may be used.
31   -.PHONY: xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
  31 +PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
32 32  
33 33 BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
34 34 xmldocs: $(BOOKS)
... ... @@ -211,4 +211,10 @@
211 211  
212 212 #man put files in man subdir - traverse down
213 213 subdir- := man/
  214 +
  215 +
  216 +# Declare the contents of the .PHONY variable as phony. We keep that
  217 +# information in a variable se we can use it in if_changed and friends.
  218 +
  219 +.PHONY: $(PHONY)
... ... @@ -95,7 +95,7 @@
95 95 endif
96 96  
97 97 # That's our default target when none is given on the command line
98   -.PHONY: _all
  98 +PHONY := _all
99 99 _all:
100 100  
101 101 ifneq ($(KBUILD_OUTPUT),)
... ... @@ -106,7 +106,7 @@
106 106 $(if $(KBUILD_OUTPUT),, \
107 107 $(error output directory "$(saved-output)" does not exist))
108 108  
109   -.PHONY: $(MAKECMDGOALS)
  109 +PHONY += $(MAKECMDGOALS)
110 110  
111 111 $(filter-out _all,$(MAKECMDGOALS)) _all:
112 112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
... ... @@ -123,7 +123,7 @@
123 123  
124 124 # If building an external module we do not care about the all: rule
125 125 # but instead _all depend on modules
126   -.PHONY: all
  126 +PHONY += all
127 127 ifeq ($(KBUILD_EXTMOD),)
128 128 _all: all
129 129 else
130 130  
... ... @@ -337,14 +337,14 @@
337 337 # Rules shared between *config targets and build targets
338 338  
339 339 # Basic helpers built in scripts/
340   -.PHONY: scripts_basic
  340 +PHONY += scripts_basic
341 341 scripts_basic:
342 342 $(Q)$(MAKE) $(build)=scripts/basic
343 343  
344 344 # To avoid any implicit rule to kick in, define an empty command.
345 345 scripts/basic/%: scripts_basic ;
346 346  
347   -.PHONY: outputmakefile
  347 +PHONY += outputmakefile
348 348 # outputmakefile generate a Makefile to be placed in output directory, if
349 349 # using a seperate output directory. This allows convinient use
350 350 # of make in output directory
... ... @@ -420,7 +420,7 @@
420 420 # Additional helpers built in scripts/
421 421 # Carefully list dependencies so we do not try to build scripts twice
422 422 # in parrallel
423   -.PHONY: scripts
  423 +PHONY += scripts
424 424 scripts: scripts_basic include/config/MARKER
425 425 $(Q)$(MAKE) $(build)=$(@)
426 426  
... ... @@ -720,7 +720,7 @@
720 720 # make menuconfig etc.
721 721 # Error messages still appears in the original language
722 722  
723   -.PHONY: $(vmlinux-dirs)
  723 +PHONY += $(vmlinux-dirs)
724 724 $(vmlinux-dirs): prepare scripts
725 725 $(Q)$(MAKE) $(build)=$@
726 726  
727 727  
... ... @@ -773,10 +773,10 @@
773 773 # version.h and scripts_basic is processed / created.
774 774  
775 775 # Listed in dependency order
776   -.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3
  776 +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
777 777  
778 778 # prepare-all is deprecated, use prepare as valid replacement
779   -.PHONY: prepare-all
  779 +PHONY += prepare-all
780 780  
781 781 # prepare3 is used to check if we are building in a separate output directory,
782 782 # and if so do:
... ... @@ -857,7 +857,7 @@
857 857  
858 858 # ---------------------------------------------------------------------------
859 859  
860   -.PHONY: depend dep
  860 +PHONY += depend dep
861 861 depend dep:
862 862 @echo '*** Warning: make $@ is unnecessary now.'
863 863  
864 864  
865 865  
866 866  
... ... @@ -872,21 +872,21 @@
872 872  
873 873 # Build modules
874 874  
875   -.PHONY: modules
  875 +PHONY += modules
876 876 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
877 877 @echo ' Building modules, stage 2.';
878 878 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
879 879  
880 880  
881 881 # Target to prepare building external modules
882   -.PHONY: modules_prepare
  882 +PHONY += modules_prepare
883 883 modules_prepare: prepare scripts
884 884  
885 885 # Target to install modules
886   -.PHONY: modules_install
  886 +PHONY += modules_install
887 887 modules_install: _modinst_ _modinst_post
888 888  
889   -.PHONY: _modinst_
  889 +PHONY += _modinst_
890 890 _modinst_:
891 891 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
892 892 echo "Warning: you may need to install module-init-tools"; \
... ... @@ -913,7 +913,7 @@
913 913 else
914 914 depmod_opts := -b $(INSTALL_MOD_PATH) -r
915 915 endif
916   -.PHONY: _modinst_post
  916 +PHONY += _modinst_post
917 917 _modinst_post: _modinst_
918 918 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
919 919  
... ... @@ -956,7 +956,7 @@
956 956 clean: rm-files := $(CLEAN_FILES)
957 957 clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
958 958  
959   -.PHONY: $(clean-dirs) clean archclean
  959 +PHONY += $(clean-dirs) clean archclean
960 960 $(clean-dirs):
961 961 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
962 962  
... ... @@ -974,7 +974,7 @@
974 974 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
975 975 mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
976 976  
977   -.PHONY: $(mrproper-dirs) mrproper archmrproper
  977 +PHONY += $(mrproper-dirs) mrproper archmrproper
978 978 $(mrproper-dirs):
979 979 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
980 980  
... ... @@ -984,7 +984,7 @@
984 984  
985 985 # distclean
986 986 #
987   -.PHONY: distclean
  987 +PHONY += distclean
988 988  
989 989 distclean: mrproper
990 990 @find $(srctree) $(RCS_FIND_IGNORE) \
... ... @@ -1000,7 +1000,7 @@
1000 1000 # rpm target kept for backward compatibility
1001 1001 package-dir := $(srctree)/scripts/package
1002 1002  
1003   -.PHONY: %-pkg rpm
  1003 +PHONY += %-pkg rpm
1004 1004  
1005 1005 %pkg: FORCE
1006 1006 $(Q)$(MAKE) -f $(package-dir)/Makefile $@
1007 1007  
... ... @@ -1092,12 +1092,12 @@
1092 1092  
1093 1093 # We are always building modules
1094 1094 KBUILD_MODULES := 1
1095   -.PHONY: crmodverdir
  1095 +PHONY += crmodverdir
1096 1096 crmodverdir:
1097 1097 $(Q)rm -rf $(MODVERDIR)
1098 1098 $(Q)mkdir -p $(MODVERDIR)
1099 1099  
1100   -.PHONY: $(objtree)/Module.symvers
  1100 +PHONY += $(objtree)/Module.symvers
1101 1101 $(objtree)/Module.symvers:
1102 1102 @test -e $(objtree)/Module.symvers || ( \
1103 1103 echo; \
... ... @@ -1106,7 +1106,7 @@
1106 1106 echo )
1107 1107  
1108 1108 module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1109   -.PHONY: $(module-dirs) modules
  1109 +PHONY += $(module-dirs) modules
1110 1110 $(module-dirs): crmodverdir $(objtree)/Module.symvers
1111 1111 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1112 1112  
1113 1113  
... ... @@ -1114,11 +1114,11 @@
1114 1114 @echo ' Building modules, stage 2.';
1115 1115 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1116 1116  
1117   -.PHONY: modules_install
  1117 +PHONY += modules_install
1118 1118 modules_install: _emodinst_ _emodinst_post
1119 1119  
1120   -install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1121   -.PHONY: _emodinst_
  1120 +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
  1121 +PHONY += _emodinst_
1122 1122 _emodinst_:
1123 1123 $(Q)rm -rf $(MODLIB)/$(install-dir)
1124 1124 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1125 1125  
... ... @@ -1133,13 +1133,13 @@
1133 1133 $(KERNELRELEASE); \
1134 1134 fi
1135 1135  
1136   -.PHONY: _emodinst_post
  1136 +PHONY += _emodinst_post
1137 1137 _emodinst_post: _emodinst_
1138 1138 $(call cmd,depmod)
1139 1139  
1140 1140 clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1141 1141  
1142   -.PHONY: $(clean-dirs) clean
  1142 +PHONY += $(clean-dirs) clean
1143 1143 $(clean-dirs):
1144 1144 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1145 1145  
... ... @@ -1161,7 +1161,7 @@
1161 1161 @echo ''
1162 1162  
1163 1163 # Dummies...
1164   -.PHONY: prepare scripts
  1164 +PHONY += prepare scripts
1165 1165 prepare: ;
1166 1166 scripts: ;
1167 1167 endif # KBUILD_EXTMOD
... ... @@ -1274,7 +1274,7 @@
1274 1274 endif #ifeq ($(config-targets),1)
1275 1275 endif #ifeq ($(mixed-targets),1)
1276 1276  
1277   -.PHONY: checkstack
  1277 +PHONY += checkstack
1278 1278 checkstack:
1279 1279 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1280 1280 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
1281 1281  
... ... @@ -1357,5 +1357,11 @@
1357 1357  
1358 1358 endif # skip-makefile
1359 1359  
  1360 +PHONY += FORCE
1360 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)
1 1 #
2 2 # arch/arm/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7 # This file is subject to the terms and conditions of the GNU General Public
5 8 # License. See the file "COPYING" in the main directory of this archive
6 9 # for more details.
... ... @@ -176,7 +179,7 @@
176 179  
177 180 archprepare: maketools
178 181  
179   -.PHONY: maketools FORCE
  182 +PHONY += maketools FORCE
180 183 maketools: include/linux/version.h include/asm-arm/.arch FORCE
181 184 $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h
182 185  
arch/arm/boot/Makefile
1 1 #
2 2 # arch/arm/boot/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7 # This file is subject to the terms and conditions of the GNU General Public
5 8 # License. See the file "COPYING" in the main directory of this archive
6 9 # for more details.
... ... @@ -73,7 +76,7 @@
73 76 $(call if_changed,objcopy)
74 77 @echo ' Kernel: $@ is ready'
75 78  
76   -.PHONY: initrd FORCE
  79 +PHONY += initrd FORCE
77 80 initrd:
78 81 @test "$(INITRD_PHYS)" != "" || \
79 82 (echo This machine does not support INITRD; exit -1)
arch/arm/boot/bootp/Makefile
1 1 #
2 2 # linux/arch/arm/boot/bootp/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7  
5 8 LDFLAGS_bootp :=-p --no-undefined -X \
6 9 --defsym initrd_phys=$(INITRD_PHYS) \
... ... @@ -21,5 +24,5 @@
21 24  
22 25 $(obj)/initrd.o: $(INITRD) FORCE
23 26  
24   -.PHONY: $(INITRD) FORCE
  27 +PHONY += $(INITRD) FORCE
1 1 #
2 2 # arch/arm26/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7 # This file is subject to the terms and conditions of the GNU General Public
5 8 # License. See the file "COPYING" in the main directory of this archive
6 9 # for more details.
7 10  
... ... @@ -49,9 +52,9 @@
49 52  
50 53 boot := arch/arm26/boot
51 54  
52   -.PHONY: maketools FORCE
  55 +PHONY += maketools FORCE
53 56 maketools: FORCE
54   -
  57 +
55 58  
56 59 # Convert bzImage to zImage
57 60 bzImage: vmlinux
arch/arm26/boot/Makefile
1 1 #
2 2 # arch/arm26/boot/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7 # This file is subject to the terms and conditions of the GNU General Public
5 8 # License. See the file "COPYING" in the main directory of this archive
6 9 # for more details.
... ... @@ -60,7 +63,7 @@
60 63 @echo ' Kernel: $@ is ready'
61 64 endif
62 65  
63   -.PHONY: initrd
  66 +PHONY += initrd
64 67 initrd:
65 68 @test "$(INITRD_PHYS)" != "" || \
66 69 (echo This machine does not support INITRD; exit -1)
... ... @@ -99,8 +99,8 @@
99 99  
100 100 boot := arch/i386/boot
101 101  
102   -.PHONY: zImage bzImage compressed zlilo bzlilo \
103   - zdisk bzdisk fdimage fdimage144 fdimage288 install
  102 +PHONY += zImage bzImage compressed zlilo bzlilo \
  103 + zdisk bzdisk fdimage fdimage144 fdimage288 install
104 104  
105 105 all: bzImage
106 106  
1 1 #
2 2 # ia64/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7 # This file is subject to the terms and conditions of the GNU General Public
5 8 # License. See the file "COPYING" in the main directory of this archive
6 9 # for more details.
... ... @@ -62,7 +65,7 @@
62 65  
63 66 boot := arch/ia64/hp/sim/boot
64 67  
65   -.PHONY: boot compressed check
  68 +PHONY += boot compressed check
66 69  
67 70 all: compressed unwcheck
68 71  
1 1 #
2 2 # m32r/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7  
5 8 LDFLAGS :=
6 9 OBJCOPYFLAGS := -O binary -R .note -R .comment -S
... ... @@ -39,7 +42,7 @@
39 42  
40 43 boot := arch/m32r/boot
41 44  
42   -.PHONY: zImage
  45 +PHONY += zImage
43 46  
44 47 all: zImage
45 48  
arch/powerpc/Makefile
... ... @@ -150,7 +150,7 @@
150 150  
151 151 BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage
152 152  
153   -.PHONY: $(BOOT_TARGETS)
  153 +PHONY += $(BOOT_TARGETS)
154 154  
155 155 boot := arch/$(ARCH)/boot
156 156  
... ... @@ -82,7 +82,7 @@
82 82  
83 83 BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm
84 84  
85   -.PHONY: $(BOOT_TARGETS)
  85 +PHONY += $(BOOT_TARGETS)
86 86  
87 87 all: uImage zImage
88 88  
arch/ppc/boot/Makefile
1 1 #
2 2 # arch/ppc/boot/Makefile
3 3 #
  4 +# This file is included by the global makefile so that you can add your own
  5 +# architecture-specific flags and dependencies.
  6 +#
4 7 # This file is subject to the terms and conditions of the GNU General Public
5 8 # License. See the file "COPYING" in the main directory of this archive
6 9 # for more details.
... ... @@ -25,7 +28,7 @@
25 28  
26 29 hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree)
27 30  
28   -.PHONY: $(BOOT_TARGETS) $(bootdir-y)
  31 +PHONY += $(BOOT_TARGETS) $(bootdir-y)
29 32  
30 33 $(BOOT_TARGETS): $(bootdir-y)
31 34  
arch/ppc/boot/openfirmware/Makefile
1 1 # Makefile for making bootable images on various OpenFirmware machines.
2 2 #
  3 +# This file is included by the global makefile so that you can add your own
  4 +# architecture-specific flags and dependencies.
  5 +#
3 6 # Paul Mackerras January 1997
4 7 # XCOFF bootable images for PowerMacs
5 8 # Geert Uytterhoeven September 1997
... ... @@ -86,7 +89,7 @@
86 89  
87 90 # The targets used on the make command-line
88 91  
89   -.PHONY: zImage zImage.initrd
  92 +PHONY += zImage zImage.initrd
90 93 zImage: $(images)/zImage.chrp \
91 94 $(images)/zImage.chrp-rs6k
92 95 @echo ' kernel: $@ is ready ($<)'
... ... @@ -96,7 +99,7 @@
96 99  
97 100 TFTPIMAGE := /tftpboot/zImage
98 101  
99   -.PHONY: znetboot znetboot.initrd
  102 +PHONY += znetboot znetboot.initrd
100 103 znetboot: $(images)/zImage.chrp
101 104 cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END)
102 105 @echo ' kernel: $@ is ready ($<)'
... ... @@ -172,7 +172,7 @@
172 172  
173 173 archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach
174 174  
175   -.PHONY: maketools FORCE
  175 +PHONY += maketools FORCE
176 176 maketools: include/linux/version.h FORCE
177 177 $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
178 178  
1   -#
  1 +#
  2 +# This file is included by the global makefile so that you can add your own
  3 +# architecture-specific flags and dependencies.
  4 +#
2 5 # Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 6 # Licensed under the GPL
4 7 #
... ... @@ -88,7 +91,7 @@
88 91  
89 92 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
90 93  
91   -.PHONY: linux
  94 +PHONY += linux
92 95  
93 96 all: linux
94 97  
arch/x86_64/Makefile
... ... @@ -67,8 +67,8 @@
67 67  
68 68 boot := arch/x86_64/boot
69 69  
70   -.PHONY: bzImage bzlilo install archmrproper \
71   - fdimage fdimage144 fdimage288 archclean
  70 +PHONY += bzImage bzlilo install archmrproper \
  71 + fdimage fdimage144 fdimage288 archclean
72 72  
73 73 #Default target when executing "make"
74 74 all: bzImage
scripts/Kbuild.include
... ... @@ -116,16 +116,18 @@
116 116 # function to only execute the passed command if necessary
117 117 # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
118 118 # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
119   -#
120   -if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
  119 +#
  120 +if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
  121 + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
121 122 @set -e; \
122 123 $(echo-cmd) $(cmd_$(1)); \
123 124 echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
124 125  
125 126 # execute the command and also postprocess generated .d dependencies
126 127 # file
127   -if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
128   - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
  128 +if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
  129 + $(filter-out FORCE $(wildcard $^),$^) \
  130 + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
129 131 @set -e; \
130 132 $(echo-cmd) $(cmd_$(1)); \
131 133 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
... ... @@ -135,7 +137,8 @@
135 137 # Usage: $(call if_changed_rule,foo)
136 138 # will check if $(cmd_foo) changed, or any of the prequisites changed,
137 139 # and if so will execute $(rule_foo)
138   -if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
  140 +if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
  141 + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
139 142 @set -e; \
140 143 $(rule_$(1)))
scripts/Makefile.build
... ... @@ -4,7 +4,7 @@
4 4  
5 5 src := $(obj)
6 6  
7   -.PHONY: __build
  7 +PHONY := __build
8 8 __build:
9 9  
10 10 # Read .config if it exist, otherwise ignore
11 11  
... ... @@ -308,14 +308,14 @@
308 308 # Descending
309 309 # ---------------------------------------------------------------------------
310 310  
311   -.PHONY: $(subdir-ym)
  311 +PHONY += $(subdir-ym)
312 312 $(subdir-ym):
313 313 $(Q)$(MAKE) $(build)=$@
314 314  
315 315 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
316 316 # ---------------------------------------------------------------------------
317 317  
318   -.PHONY: FORCE
  318 +PHONY += FORCE
319 319  
320 320 FORCE:
321 321  
... ... @@ -330,4 +330,10 @@
330 330 ifneq ($(cmd_files),)
331 331 include $(cmd_files)
332 332 endif
  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)
scripts/Makefile.clean
... ... @@ -4,7 +4,7 @@
4 4  
5 5 src := $(obj)
6 6  
7   -.PHONY: __clean
  7 +PHONY := __clean
8 8 __clean:
9 9  
10 10 # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
11 11  
... ... @@ -87,11 +87,17 @@
87 87 # Descending
88 88 # ---------------------------------------------------------------------------
89 89  
90   -.PHONY: $(subdir-ymn)
  90 +PHONY += $(subdir-ymn)
91 91 $(subdir-ymn):
92 92 $(Q)$(MAKE) $(clean)=$@
93 93  
94 94 # If quiet is set, only print short version of command
95 95  
96 96 cmd = @$(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)
scripts/Makefile.modinst
... ... @@ -2,7 +2,7 @@
2 2 # Installing modules
3 3 # ==========================================================================
4 4  
5   -.PHONY: __modinst
  5 +PHONY := __modinst
6 6 __modinst:
7 7  
8 8 include scripts/Kbuild.include
... ... @@ -12,7 +12,7 @@
12 12 __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
13 13 modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
14 14  
15   -.PHONY: $(modules)
  15 +PHONY += $(modules)
16 16 __modinst: $(modules)
17 17 @:
18 18  
... ... @@ -27,4 +27,10 @@
27 27  
28 28 $(modules):
29 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)
scripts/Makefile.modpost
... ... @@ -32,7 +32,7 @@
32 32 # Step 4 is solely used to allow module versioning in external modules,
33 33 # where the CRC of each module is retrieved from the Module.symers file.
34 34  
35   -.PHONY: _modpost
  35 +PHONY := _modpost
36 36 _modpost: __modpost
37 37  
38 38 include .config
... ... @@ -60,7 +60,7 @@
60 60 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
61 61 $(filter-out FORCE,$^)
62 62  
63   -.PHONY: __modpost
  63 +PHONY += __modpost
64 64 __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
65 65 $(call cmd,modpost)
66 66  
... ... @@ -97,7 +97,7 @@
97 97 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
98 98 # ---------------------------------------------------------------------------
99 99  
100   -.PHONY: FORCE
  100 +PHONY += FORCE
101 101  
102 102 FORCE:
103 103  
... ... @@ -112,4 +112,10 @@
112 112 ifneq ($(cmd_files),)
113 113 include $(cmd_files)
114 114 endif
  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)
scripts/kconfig/Makefile
... ... @@ -2,7 +2,7 @@
2 2 # Kernel configuration targets
3 3 # These targets are used from top-level makefile
4 4  
5   -.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
  5 +PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
6 6  
7 7 xconfig: $(obj)/qconf
8 8 $< arch/$(ARCH)/Kconfig
... ... @@ -42,7 +42,7 @@
42 42 $(Q)rm -f arch/um/Kconfig_arch
43 43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
44 44  
45   -.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
  45 +PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
46 46  
47 47 randconfig: $(obj)/conf
48 48 $< -r arch/$(ARCH)/Kconfig
scripts/kconfig/lxdialog/Makefile
... ... @@ -7,10 +7,10 @@
7 7 # we really need to do so. (Do not call gcc as part of make mrproper)
8 8 HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
9 9 HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
10   -
11   -HOST_EXTRACFLAGS += -DLOCALE
12 10  
13   -.PHONY: dochecklxdialog
  11 +HOST_EXTRACFLAGS += -DLOCALE
  12 +
  13 +PHONY += dochecklxdialog
14 14 $(obj)/dochecklxdialog:
15 15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
16 16  
scripts/package/Makefile
... ... @@ -32,7 +32,7 @@
32 32 PREV := set -e; cd ..;
33 33  
34 34 # rpm-pkg
35   -.PHONY: rpm-pkg rpm
  35 +PHONY += rpm-pkg rpm
36 36  
37 37 $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
38 38 $(CONFIG_SHELL) $(MKSPEC) > $@
39 39  
... ... @@ -54,10 +54,10 @@
54 54 clean-files := $(objtree)/kernel.spec
55 55  
56 56 # binrpm-pkg
57   -.PHONY: binrpm-pkg
  57 +PHONY += binrpm-pkg
58 58 $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
59 59 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
60   -
  60 +
61 61 binrpm-pkg: $(objtree)/binkernel.spec
62 62 $(MAKE) KBUILD_SRC=
63 63 set -e; \
... ... @@ -72,7 +72,7 @@
72 72 # Deb target
73 73 # ---------------------------------------------------------------------------
74 74 #
75   -.PHONY: deb-pkg
  75 +PHONY += deb-pkg
76 76 deb-pkg:
77 77 $(MAKE) KBUILD_SRC=
78 78 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
... ... @@ -82,7 +82,7 @@
82 82  
83 83 # tarball targets
84 84 # ---------------------------------------------------------------------------
85   -.PHONY: tar%pkg
  85 +PHONY += tar%pkg
86 86 tar%pkg:
87 87 $(MAKE) KBUILD_SRC=
88 88 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@