From 06300b21f4c79fd1578f4b7ca4b314fbab61a383 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 25 Jan 2006 07:13:18 +0100 Subject: kbuild: support building individual files for external modules Support building individual files when dealing with separate modules. So say you have a module named "foo" which consist of two .o files bar.o and fun.o. You can then do: make -C $KERNELSRC M=`pwd` bar.o make -C $KERNELSRC M=`pwd` bar.lst make -C $KERNELSRC M=`pwd` bar.i make -C $KERNELSRC M=`pwd` / <= will build all .o files and link foo.o make -C $KERNELSRC M=`pwd` foo.ko <= will build the module and do the modpost step to create foo.ko The above will also work if the external module is placed in a subdirectory using a hirachy of kbuild files. Thanks to Andreas Gruenbacher for initial feature request / bug report. Signed-off-by: Sam Ravnborg --- Makefile | 66 ++++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 77a448c8e77..639d8a48bbd 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,7 @@ objtree := $(CURDIR) src := $(srctree) obj := $(objtree) -VPATH := $(srctree) +VPATH := $(srctree):$(KBUILD_EXTMOD) export srctree objtree VPATH TOPDIR @@ -849,27 +849,6 @@ prepare prepare-all: prepare0 export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) -# Single targets -# --------------------------------------------------------------------------- - -%.s: %.c scripts FORCE - $(Q)$(MAKE) $(build)=$(@D) $@ -%.i: %.c scripts FORCE - $(Q)$(MAKE) $(build)=$(@D) $@ -%.o: %.c scripts FORCE - $(Q)$(MAKE) $(build)=$(@D) $@ -%.ko: scripts FORCE - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D) $(@:.ko=.o) - $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost -%/: scripts prepare FORCE - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D) -%.lst: %.c scripts FORCE - $(Q)$(MAKE) $(build)=$(@D) $@ -%.s: %.S scripts FORCE - $(Q)$(MAKE) $(build)=$(@D) $@ -%.o: %.S scripts FORCE - $(Q)$(MAKE) $(build)=$(@D) $@ - # FIXME: The asm symlink changes when $(ARCH) changes. That's # hard to detect, but I suppose "make mrproper" is a good idea # before switching between archs anyway. @@ -1192,6 +1171,11 @@ help: @echo ' modules_install - install the module' @echo ' clean - remove generated files in module directory only' @echo '' + +# Dummies... +.PHONY: prepare scripts +prepare: ; +scripts: ; endif # KBUILD_EXTMOD # Generate tags for editors @@ -1313,6 +1297,44 @@ kernelrelease: kernelversion: @echo $(KERNELVERSION) +# Single targets +# --------------------------------------------------------------------------- +# The directory part is taken from first prerequisite, so this +# works even with external modules +%.s: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.i: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.o: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.lst: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.s: %.S scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.o: %.S scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) + +# For external modules we shall include any directory of the target, +# but usual case there is no directory part. +# make M=`pwd` module.o => $(dir $@)=./ +# make M=`pwd` foo/module.o => $(dir $@)=foo/ +# make M=`pwd` / => $(dir $@)=/ + +ifeq ($(KBUILD_EXTMOD),) + target-dir = $(@D) +else + zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) + target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) +endif + +/ %/: scripts prepare FORCE + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(target-dir) +%.ko: scripts FORCE + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(target-dir) $(@:.ko=.o) + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost + # FIXME Should go into a make.lib or something # =========================================================================== -- cgit v1.2.3 From 8999257c292cb757828ae3def9f5e9d894a24741 Mon Sep 17 00:00:00 2001 From: Martin Michlmayr Date: Sat, 28 Jan 2006 18:38:15 +0000 Subject: kbuild: Accept various mips sub-types in SUBARCH uname -m on MIPS can give a number of results, such as mips64. We need to add another substitution to the sed call for SUBARCH in the main Makefile. Signed-off-by: Martin Michlmayr Signed-off-by: Sam Ravnborg --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 639d8a48bbd..1db819ef0da 100644 --- a/Makefile +++ b/Makefile @@ -151,7 +151,7 @@ export srctree objtree VPATH TOPDIR SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ ) + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- -- cgit v1.2.3 From fb3cbd2e575f9ac0700bfa1e7cb9f4119fbd0abd Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 28 Jan 2006 23:08:40 +0100 Subject: kbuild: avoid stale modules in $(MODVERDIR) for external modules To avoid stale modules located in $(MODVERDIR) aka .tmp_versions/ always delete the directory when building an external module. Signed-off-by: Sam Ravnborg --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1db819ef0da..fdb3dac3e70 100644 --- a/Makefile +++ b/Makefile @@ -1126,6 +1126,7 @@ else # KBUILD_EXTMOD KBUILD_MODULES := 1 .PHONY: crmodverdir crmodverdir: + $(Q)rm -rf $(MODVERDIR) $(Q)mkdir -p $(MODVERDIR) .PHONY: $(objtree)/Module.symvers -- cgit v1.2.3 From a67dc21a38055ec2d8d85b2f64d98091748569b3 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 28 Jan 2006 23:51:57 +0100 Subject: kbuild: run depmod when installing external modules Following patch enables depmod support when installing external modules. Signed-off-by: Sam Ravnborg --- Makefile | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index fdb3dac3e70..c55d0f1b85e 100644 --- a/Makefile +++ b/Makefile @@ -1147,9 +1147,28 @@ modules: $(module-dirs) $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost .PHONY: modules_install -modules_install: +modules_install: _emodinst_ _emodinst_post + +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) +.PHONY: _emodinst_ +_emodinst_: + $(Q)rm -rf $(MODLIB)/$(install-dir) + $(Q)mkdir -p $(MODLIB)/$(install-dir) $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst +# Run depmod only is we have System.map and depmod is executable +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \ + $(DEPMOD) -ae -F System.map \ + $(if $(strip $(INSTALL_MOD_PATH)), \ + -b $(INSTALL_MOD_PATH) -r) \ + $(KERNELRELEASE); \ + fi + +.PHONY: _emodinst_post +_emodinst_post: _emodinst_ + $(call cmd,depmod) + clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) .PHONY: $(clean-dirs) clean -- cgit v1.2.3 From 20a468b51325b3636785a8ca0047ae514b39cbd5 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 22 Jan 2006 13:34:15 +0100 Subject: kbuild: make cc-version available in kbuild files Move $(CC) support functions to Kbuild.include so they are available in the kbuild files. In addition the following was done: o as-option documented in Documentation/kbuild/makefiles.txt o Moved documentation to new section to match new scope of functions o added cc-ifversion used to conditionally select a text string dependent on actual $(CC) version o documented cc-ifversion o change so Kbuild.include is read before the kbuild file Signed-off-by: Sam Ravnborg --- Documentation/kbuild/makefiles.txt | 166 ++++++++++++++++++++++--------------- Makefile | 32 ------- scripts/Kbuild.include | 37 +++++++++ scripts/Makefile.build | 3 +- 4 files changed, 136 insertions(+), 102 deletions(-) (limited to 'Makefile') diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 443230b43e0..99d51a5bb0d 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -17,6 +17,7 @@ This document describes the Linux kernel Makefiles. --- 3.8 Command line dependency --- 3.9 Dependency tracking --- 3.10 Special Rules + --- 3.11 $(CC) support functions === 4 Host Program support --- 4.1 Simple Host Program @@ -38,7 +39,6 @@ This document describes the Linux kernel Makefiles. --- 6.6 Commands useful for building a boot image --- 6.7 Custom kbuild commands --- 6.8 Preprocessing linker scripts - --- 6.9 $(CC) support functions === 7 Kbuild Variables === 8 Makefile language @@ -385,6 +385,102 @@ more details, with real examples. to prerequisites are referenced with $(src) (because they are not generated files). +--- 3.11 $(CC) support functions + + The kernel may be build with several different versions of + $(CC), each supporting a unique set of features and options. + kbuild provide basic support to check for valid options for $(CC). + $(CC) is useally the gcc compiler, but other alternatives are + available. + + as-option + as-option is used to check if $(CC) when used to compile + assembler (*.S) files supports the given option. An optional + second option may be specified if first option are not supported. + + Example: + #arch/sh/Makefile + cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) + + In the above example cflags-y will be assinged the the option + -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC). + The second argument is optional, and if supplied will be used + if first argument is not supported. + + cc-option + cc-option is used to check if $(CC) support a given option, and not + supported to use an optional second option. + + Example: + #arch/i386/Makefile + cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586) + + In the above example cflags-y will be assigned the option + -march=pentium-mmx if supported by $(CC), otherwise -march-i586. + The second argument to cc-option is optional, and if omitted + cflags-y will be assigned no value if first option is not supported. + + cc-option-yn + cc-option-yn is used to check if gcc supports a given option + and return 'y' if supported, otherwise 'n'. + + Example: + #arch/ppc/Makefile + biarch := $(call cc-option-yn, -m32) + aflags-$(biarch) += -a32 + cflags-$(biarch) += -m32 + + In the above example $(biarch) is set to y if $(CC) supports the -m32 + option. When $(biarch) equals to y the expanded variables $(aflags-y) + and $(cflags-y) will be assigned the values -a32 and -m32. + + cc-option-align + gcc version >= 3.0 shifted type of options used to speify + alignment of functions, loops etc. $(cc-option-align) whrn used + as prefix to the align options will select the right prefix: + gcc < 3.00 + cc-option-align = -malign + gcc >= 3.00 + cc-option-align = -falign + + Example: + CFLAGS += $(cc-option-align)-functions=4 + + In the above example the option -falign-functions=4 is used for + gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used. + + cc-version + cc-version return a numerical version of the $(CC) compiler version. + The format is where both are two digits. So for example + gcc 3.41 would return 0341. + cc-version is useful when a specific $(CC) version is faulty in one + area, for example the -mregparm=3 were broken in some gcc version + even though the option was accepted by gcc. + + Example: + #arch/i386/Makefile + cflags-y += $(shell \ + if [ $(call cc-version) -ge 0300 ] ; then \ + echo "-mregparm=3"; fi ;) + + In the above example -mregparm=3 is only used for gcc version greater + than or equal to gcc 3.0. + + cc-ifversion + cc-ifversion test the version of $(CC) and equals last argument if + version expression is true. + + Example: + #fs/reiserfs/Makefile + EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1) + + In this example EXTRA_CFLAGS will be assigned the value -O1 if the + $(CC) version is less than 4.2. + cc-ifversion takes all the shell operators: + -eq, -ne, -lt, -le, -gt, and -ge + The third parameter may be a text as in this example, but it may also + be an expanded variable or a macro. + === 4 Host Program support @@ -973,74 +1069,6 @@ When kbuild executes the following steps are followed (roughly): architecture specific files. ---- 6.9 $(CC) support functions - - The kernel may be build with several different versions of - $(CC), each supporting a unique set of features and options. - kbuild provide basic support to check for valid options for $(CC). - $(CC) is useally the gcc compiler, but other alternatives are - available. - - cc-option - cc-option is used to check if $(CC) support a given option, and not - supported to use an optional second option. - - Example: - #arch/i386/Makefile - cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586) - - In the above example cflags-y will be assigned the option - -march=pentium-mmx if supported by $(CC), otherwise -march-i586. - The second argument to cc-option is optional, and if omitted - cflags-y will be assigned no value if first option is not supported. - - cc-option-yn - cc-option-yn is used to check if gcc supports a given option - and return 'y' if supported, otherwise 'n'. - - Example: - #arch/ppc/Makefile - biarch := $(call cc-option-yn, -m32) - aflags-$(biarch) += -a32 - cflags-$(biarch) += -m32 - - In the above example $(biarch) is set to y if $(CC) supports the -m32 - option. When $(biarch) equals to y the expanded variables $(aflags-y) - and $(cflags-y) will be assigned the values -a32 and -m32. - - cc-option-align - gcc version >= 3.0 shifted type of options used to speify - alignment of functions, loops etc. $(cc-option-align) whrn used - as prefix to the align options will select the right prefix: - gcc < 3.00 - cc-option-align = -malign - gcc >= 3.00 - cc-option-align = -falign - - Example: - CFLAGS += $(cc-option-align)-functions=4 - - In the above example the option -falign-functions=4 is used for - gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used. - - cc-version - cc-version return a numerical version of the $(CC) compiler version. - The format is where both are two digits. So for example - gcc 3.41 would return 0341. - cc-version is useful when a specific $(CC) version is faulty in one - area, for example the -mregparm=3 were broken in some gcc version - even though the option was accepted by gcc. - - Example: - #arch/i386/Makefile - cflags-y += $(shell \ - if [ $(call cc-version) -ge 0300 ] ; then \ - echo "-mregparm=3"; fi ;) - - In the above example -mregparm=3 is only used for gcc version greater - than or equal to gcc 3.0. - - === 7 Kbuild Variables The top Makefile exports the following variables: diff --git a/Makefile b/Makefile index c55d0f1b85e..05b451a1b76 100644 --- a/Makefile +++ b/Makefile @@ -258,38 +258,6 @@ endif export quiet Q KBUILD_VERBOSE -###### -# cc support functions to be used (only) in arch/$(ARCH)/Makefile -# See documentation in Documentation/kbuild/makefiles.txt - -# as-option -# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,) - -as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ - -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ - else echo "$(2)"; fi ;) - -# cc-option -# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) - -cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ - > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) - -# cc-option-yn -# Usage: flag := $(call cc-option-yn, -march=winchip-c6) -cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ - > /dev/null 2>&1; then echo "y"; else echo "n"; fi;) - -# cc-option-align -# Prefix align with either -falign or -malign -cc-option-align = $(subst -functions=0,,\ - $(call cc-option,-falign-functions=0,-malign-functions=0)) - -# cc-version -# Usage gcc-ver := $(call cc-version $(CC)) -cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \ - $(if $(1), $(1), $(CC))) - # Look for make include files relative to root of kernel src MAKEFLAGS += --include-dir=$(srctree) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 0168d6c3707..92ce94b58bd 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -44,6 +44,43 @@ define filechk fi endef +###### +# cc support functions to be used (only) in arch/$(ARCH)/Makefile +# See documentation in Documentation/kbuild/makefiles.txt + +# as-option +# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,) + +as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ + -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ + else echo "$(2)"; fi ;) + +# cc-option +# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) + +cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ + > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) + +# cc-option-yn +# Usage: flag := $(call cc-option-yn, -march=winchip-c6) +cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ + > /dev/null 2>&1; then echo "y"; else echo "n"; fi;) + +# cc-option-align +# Prefix align with either -falign or -malign +cc-option-align = $(subst -functions=0,,\ + $(call cc-option,-falign-functions=0,-malign-functions=0)) + +# cc-version +# Usage gcc-ver := $(call cc-version, $(CC)) +cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \ + $(if $(1), $(1), $(CC))) + +# cc-ifversion +# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) +cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \ + echo $(3); fi;) + ### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= # Usage: diff --git a/scripts/Makefile.build b/scripts/Makefile.build index c33e62bde6b..2737765f2fb 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -10,11 +10,12 @@ __build: # Read .config if it exist, otherwise ignore -include .config +include scripts/Kbuild.include + # The filename Kbuild has precedence over Makefile kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) -include scripts/Kbuild.include include scripts/Makefile.lib ifdef host-progs -- cgit v1.2.3 From e63046630c8a73825896cef140fbf49af233fd2a Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 14 Feb 2006 15:58:15 +0100 Subject: kbuild: remove a tab from an empty line Emacs warns if an otherwise empty line starts with a tab. Signed-off-by: Adrian Bunk Signed-off-by: Sam Ravnborg --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 05b451a1b76..a55a1e4e6cd 100644 --- a/Makefile +++ b/Makefile @@ -1116,7 +1116,7 @@ modules: $(module-dirs) .PHONY: modules_install modules_install: _emodinst_ _emodinst_post - + install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) .PHONY: _emodinst_ _emodinst_: -- cgit v1.2.3 From 0f558c333445a0181f33f9e6f996ce7cf008206a Mon Sep 17 00:00:00 2001 From: Mattia Dongili Date: Sun, 19 Feb 2006 13:50:37 +0100 Subject: kbuild: fix a cscope bug (make cscope segfaults) Workaround a cscope bug where a trailing ':' in VPATH makes it segfault and let it build the cross-reference succesfully. VPATH=/home/mattia/devel/kernel/git/linux-2.6: cscope -b [1] 17555 segmentation fault VPATH=/home/mattia/devel/kernel/git/linux-2.6: cscope -b Signed-off-by: Mattia Dongili Signed-off-by: Sam Ravnborg --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a55a1e4e6cd..7a95f4f8ef1 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,7 @@ objtree := $(CURDIR) src := $(srctree) obj := $(objtree) -VPATH := $(srctree):$(KBUILD_EXTMOD) +VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) export srctree objtree VPATH TOPDIR -- cgit v1.2.3 From c3f9da90b6e63c968070aa72057fe15356b3f7b5 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 22 Feb 2006 13:29:04 +0100 Subject: kbuild: version.h should depend on .kernelrelease Rebuilding a previously built tree while using make's -j options from time to time results in the version.h check running at the same time as the updating of .kernelrelease, resulting in UTS_RELEASE remaining an empty string (and as a side effect causing the entire kernel to be rebuilt). Signed-Off-By: Jan Beulich Signed-off-by: Sam Ravnborg --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 7a95f4f8ef1..ce2bfbdeb96 100644 --- a/Makefile +++ b/Makefile @@ -852,7 +852,7 @@ define filechk_version.h ) endef -include/linux/version.h: $(srctree)/Makefile .config FORCE +include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE $(call filechk,version.h) # --------------------------------------------------------------------------- -- cgit v1.2.3 From f6ecebd6592ea70e9450ec70efb24220dd961ebc Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 5 Mar 2006 12:10:58 +0100 Subject: kbuild: fix make dir/file.xx when asm symlink is missing Added a dependency so we do full preparation before trying to build single file targets. This fixes a case where Andrew Morton did: make kernel/sched.o rm include/asm make kernel/sched.o -> splat Signed-off-by: Sam Ravnborg --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ce2bfbdeb96..12c8d714777 100644 --- a/Makefile +++ b/Makefile @@ -1289,17 +1289,17 @@ kernelversion: # --------------------------------------------------------------------------- # The directory part is taken from first prerequisite, so this # works even with external modules -%.s: %.c scripts FORCE +%.s: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) -%.i: %.c scripts FORCE +%.i: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) -%.o: %.c scripts FORCE +%.o: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) -%.lst: %.c scripts FORCE +%.lst: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) -%.s: %.S scripts FORCE +%.s: %.S prepare scripts FORCE $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) -%.o: %.S scripts FORCE +%.o: %.S prepare scripts FORCE $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) # For external modules we shall include any directory of the target, -- cgit v1.2.3 From 4f1933620f57145212cdbb1ac6ce099eeeb21c5a Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 5 Mar 2006 17:14:10 -0500 Subject: 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 Signed-off-by: Sam Ravnborg --- Documentation/DocBook/Makefile | 8 ++++- Makefile | 64 ++++++++++++++++++++----------------- arch/arm/Makefile | 5 ++- arch/arm/boot/Makefile | 5 ++- arch/arm/boot/bootp/Makefile | 5 ++- arch/arm26/Makefile | 7 ++-- arch/arm26/boot/Makefile | 5 ++- arch/i386/Makefile | 4 +-- arch/ia64/Makefile | 5 ++- arch/m32r/Makefile | 5 ++- arch/powerpc/Makefile | 2 +- arch/ppc/Makefile | 2 +- arch/ppc/boot/Makefile | 5 ++- arch/ppc/boot/openfirmware/Makefile | 7 ++-- arch/sh/Makefile | 2 +- arch/um/Makefile | 7 ++-- arch/x86_64/Makefile | 4 +-- scripts/Kbuild.include | 13 +++++--- scripts/Makefile.build | 12 +++++-- scripts/Makefile.clean | 10 ++++-- scripts/Makefile.modinst | 10 ++++-- scripts/Makefile.modpost | 12 +++++-- scripts/kconfig/Makefile | 4 +-- scripts/kconfig/lxdialog/Makefile | 6 ++-- scripts/package/Makefile | 10 +++--- 25 files changed, 144 insertions(+), 75 deletions(-) (limited to 'Makefile') diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 1c955883cf5..2c6f66dea65 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile @@ -28,7 +28,7 @@ PS_METHOD = $(prefer-db2x) ### # The targets that may be used. -.PHONY: xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs +PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs BOOKS := $(addprefix $(obj)/,$(DOCBOOKS)) xmldocs: $(BOOKS) @@ -211,3 +211,9 @@ clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) #man put files in man subdir - traverse down subdir- := man/ + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/Makefile b/Makefile index 12c8d714777..a59c1e2d0c2 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,7 @@ ifdef O endif # That's our default target when none is given on the command line -.PHONY: _all +PHONY := _all _all: ifneq ($(KBUILD_OUTPUT),) @@ -106,7 +106,7 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) $(if $(KBUILD_OUTPUT),, \ $(error output directory "$(saved-output)" does not exist)) -.PHONY: $(MAKECMDGOALS) +PHONY += $(MAKECMDGOALS) $(filter-out _all,$(MAKECMDGOALS)) _all: $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ @@ -123,7 +123,7 @@ ifeq ($(skip-makefile),) # If building an external module we do not care about the all: rule # but instead _all depend on modules -.PHONY: all +PHONY += all ifeq ($(KBUILD_EXTMOD),) _all: all else @@ -337,14 +337,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc # Rules shared between *config targets and build targets # Basic helpers built in scripts/ -.PHONY: scripts_basic +PHONY += scripts_basic scripts_basic: $(Q)$(MAKE) $(build)=scripts/basic # To avoid any implicit rule to kick in, define an empty command. scripts/basic/%: scripts_basic ; -.PHONY: outputmakefile +PHONY += outputmakefile # outputmakefile generate a Makefile to be placed in output directory, if # using a seperate output directory. This allows convinient use # of make in output directory @@ -420,7 +420,7 @@ ifeq ($(KBUILD_EXTMOD),) # Additional helpers built in scripts/ # Carefully list dependencies so we do not try to build scripts twice # in parrallel -.PHONY: scripts +PHONY += scripts scripts: scripts_basic include/config/MARKER $(Q)$(MAKE) $(build)=$(@) @@ -720,7 +720,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; # make menuconfig etc. # Error messages still appears in the original language -.PHONY: $(vmlinux-dirs) +PHONY += $(vmlinux-dirs) $(vmlinux-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@ @@ -773,10 +773,10 @@ kernelrelease = $(KERNELVERSION)$(localver-full) # version.h and scripts_basic is processed / created. # Listed in dependency order -.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 # prepare-all is deprecated, use prepare as valid replacement -.PHONY: prepare-all +PHONY += prepare-all # prepare3 is used to check if we are building in a separate output directory, # and if so do: @@ -857,7 +857,7 @@ include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE # --------------------------------------------------------------------------- -.PHONY: depend dep +PHONY += depend dep depend dep: @echo '*** Warning: make $@ is unnecessary now.' @@ -872,21 +872,21 @@ all: modules # Build modules -.PHONY: modules +PHONY += modules modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) @echo ' Building modules, stage 2.'; $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost # Target to prepare building external modules -.PHONY: modules_prepare +PHONY += modules_prepare modules_prepare: prepare scripts # Target to install modules -.PHONY: modules_install +PHONY += modules_install modules_install: _modinst_ _modinst_post -.PHONY: _modinst_ +PHONY += _modinst_ _modinst_: @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ echo "Warning: you may need to install module-init-tools"; \ @@ -913,7 +913,7 @@ depmod_opts := else depmod_opts := -b $(INSTALL_MOD_PATH) -r endif -.PHONY: _modinst_post +PHONY += _modinst_post _modinst_post: _modinst_ if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi @@ -956,7 +956,7 @@ clean: rm-dirs := $(CLEAN_DIRS) clean: rm-files := $(CLEAN_FILES) clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) -.PHONY: $(clean-dirs) clean archclean +PHONY += $(clean-dirs) clean archclean $(clean-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) @@ -974,7 +974,7 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) -.PHONY: $(mrproper-dirs) mrproper archmrproper +PHONY += $(mrproper-dirs) mrproper archmrproper $(mrproper-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) @@ -984,7 +984,7 @@ mrproper: clean archmrproper $(mrproper-dirs) # distclean # -.PHONY: distclean +PHONY += distclean distclean: mrproper @find $(srctree) $(RCS_FIND_IGNORE) \ @@ -1000,7 +1000,7 @@ distclean: mrproper # rpm target kept for backward compatibility package-dir := $(srctree)/scripts/package -.PHONY: %-pkg rpm +PHONY += %-pkg rpm %pkg: FORCE $(Q)$(MAKE) -f $(package-dir)/Makefile $@ @@ -1092,12 +1092,12 @@ else # KBUILD_EXTMOD # We are always building modules KBUILD_MODULES := 1 -.PHONY: crmodverdir +PHONY += crmodverdir crmodverdir: $(Q)rm -rf $(MODVERDIR) $(Q)mkdir -p $(MODVERDIR) -.PHONY: $(objtree)/Module.symvers +PHONY += $(objtree)/Module.symvers $(objtree)/Module.symvers: @test -e $(objtree)/Module.symvers || ( \ echo; \ @@ -1106,7 +1106,7 @@ $(objtree)/Module.symvers: echo ) module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) -.PHONY: $(module-dirs) modules +PHONY += $(module-dirs) modules $(module-dirs): crmodverdir $(objtree)/Module.symvers $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) @@ -1114,11 +1114,11 @@ modules: $(module-dirs) @echo ' Building modules, stage 2.'; $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost -.PHONY: modules_install +PHONY += modules_install modules_install: _emodinst_ _emodinst_post -install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) -.PHONY: _emodinst_ +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) +PHONY += _emodinst_ _emodinst_: $(Q)rm -rf $(MODLIB)/$(install-dir) $(Q)mkdir -p $(MODLIB)/$(install-dir) @@ -1133,13 +1133,13 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) $(KERNELRELEASE); \ fi -.PHONY: _emodinst_post +PHONY += _emodinst_post _emodinst_post: _emodinst_ $(call cmd,depmod) clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) -.PHONY: $(clean-dirs) clean +PHONY += $(clean-dirs) clean $(clean-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) @@ -1161,7 +1161,7 @@ help: @echo '' # Dummies... -.PHONY: prepare scripts +PHONY += prepare scripts prepare: ; scripts: ; endif # KBUILD_EXTMOD @@ -1274,7 +1274,7 @@ namespacecheck: endif #ifeq ($(config-targets),1) endif #ifeq ($(mixed-targets),1) -.PHONY: checkstack +PHONY += checkstack checkstack: $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ $(PERL) $(src)/scripts/checkstack.pl $(ARCH) @@ -1357,4 +1357,10 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj endif # skip-makefile +PHONY += FORCE FORCE: + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. +.PHONY: $(PHONY) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index fbfc14a56b9..585d334234f 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -1,6 +1,9 @@ # # arch/arm/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details. @@ -176,7 +179,7 @@ endif archprepare: maketools -.PHONY: maketools FORCE +PHONY += maketools FORCE maketools: include/linux/version.h include/asm-arm/.arch FORCE $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile index a174d63395e..ec9c400c7f8 100644 --- a/arch/arm/boot/Makefile +++ b/arch/arm/boot/Makefile @@ -1,6 +1,9 @@ # # arch/arm/boot/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details. @@ -73,7 +76,7 @@ $(obj)/bootpImage: $(obj)/bootp/bootp FORCE $(call if_changed,objcopy) @echo ' Kernel: $@ is ready' -.PHONY: initrd FORCE +PHONY += initrd FORCE initrd: @test "$(INITRD_PHYS)" != "" || \ (echo This machine does not support INITRD; exit -1) diff --git a/arch/arm/boot/bootp/Makefile b/arch/arm/boot/bootp/Makefile index 8e8879b6b3d..c394e305447 100644 --- a/arch/arm/boot/bootp/Makefile +++ b/arch/arm/boot/bootp/Makefile @@ -1,6 +1,9 @@ # # linux/arch/arm/boot/bootp/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# LDFLAGS_bootp :=-p --no-undefined -X \ --defsym initrd_phys=$(INITRD_PHYS) \ @@ -21,4 +24,4 @@ $(obj)/kernel.o: arch/arm/boot/zImage FORCE $(obj)/initrd.o: $(INITRD) FORCE -.PHONY: $(INITRD) FORCE +PHONY += $(INITRD) FORCE diff --git a/arch/arm26/Makefile b/arch/arm26/Makefile index 844a9e46886..fe91eda98a9 100644 --- a/arch/arm26/Makefile +++ b/arch/arm26/Makefile @@ -1,6 +1,9 @@ # # arch/arm26/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details. @@ -49,9 +52,9 @@ all: zImage boot := arch/arm26/boot -.PHONY: maketools FORCE +PHONY += maketools FORCE maketools: FORCE - + # Convert bzImage to zImage bzImage: vmlinux diff --git a/arch/arm26/boot/Makefile b/arch/arm26/boot/Makefile index b5c2277654d..68acb7b0d47 100644 --- a/arch/arm26/boot/Makefile +++ b/arch/arm26/boot/Makefile @@ -1,6 +1,9 @@ # # arch/arm26/boot/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details. @@ -60,7 +63,7 @@ $(obj)/xipImage: vmlinux FORCE @echo ' Kernel: $@ is ready' endif -.PHONY: initrd +PHONY += initrd initrd: @test "$(INITRD_PHYS)" != "" || \ (echo This machine does not support INITRD; exit -1) diff --git a/arch/i386/Makefile b/arch/i386/Makefile index 36bef6543ac..ff6973a85c8 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -99,8 +99,8 @@ AFLAGS += $(mflags-y) boot := arch/i386/boot -.PHONY: zImage bzImage compressed zlilo bzlilo \ - zdisk bzdisk fdimage fdimage144 fdimage288 install +PHONY += zImage bzImage compressed zlilo bzlilo \ + zdisk bzdisk fdimage fdimage144 fdimage288 install all: bzImage diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index f722e1a2594..80ea7506fa1 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -1,6 +1,9 @@ # # ia64/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details. @@ -62,7 +65,7 @@ drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/ boot := arch/ia64/hp/sim/boot -.PHONY: boot compressed check +PHONY += boot compressed check all: compressed unwcheck diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile index 983d438b14b..229f66fc8e5 100644 --- a/arch/m32r/Makefile +++ b/arch/m32r/Makefile @@ -1,6 +1,9 @@ # # m32r/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# LDFLAGS := OBJCOPYFLAGS := -O binary -R .note -R .comment -S @@ -39,7 +42,7 @@ drivers-$(CONFIG_OPROFILE) += arch/m32r/oprofile/ boot := arch/m32r/boot -.PHONY: zImage +PHONY += zImage all: zImage diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 5500ab55d04..5787d55a20b 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -150,7 +150,7 @@ CPPFLAGS_vmlinux.lds := -Upowerpc BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage -.PHONY: $(BOOT_TARGETS) +PHONY += $(BOOT_TARGETS) boot := arch/$(ARCH)/boot diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile index 98e940beeb3..9fbdf54ba2b 100644 --- a/arch/ppc/Makefile +++ b/arch/ppc/Makefile @@ -82,7 +82,7 @@ drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/ BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm -.PHONY: $(BOOT_TARGETS) +PHONY += $(BOOT_TARGETS) all: uImage zImage diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile index efd8ce515d5..84eec0bef93 100644 --- a/arch/ppc/boot/Makefile +++ b/arch/ppc/boot/Makefile @@ -1,6 +1,9 @@ # # arch/ppc/boot/Makefile # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details. @@ -25,7 +28,7 @@ subdir- += simple openfirmware hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) -.PHONY: $(BOOT_TARGETS) $(bootdir-y) +PHONY += $(BOOT_TARGETS) $(bootdir-y) $(BOOT_TARGETS): $(bootdir-y) diff --git a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile index 2a411ec2e65..66b73974375 100644 --- a/arch/ppc/boot/openfirmware/Makefile +++ b/arch/ppc/boot/openfirmware/Makefile @@ -1,5 +1,8 @@ # Makefile for making bootable images on various OpenFirmware machines. # +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # Paul Mackerras January 1997 # XCOFF bootable images for PowerMacs # Geert Uytterhoeven September 1997 @@ -86,7 +89,7 @@ $(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \ # The targets used on the make command-line -.PHONY: zImage zImage.initrd +PHONY += zImage zImage.initrd zImage: $(images)/zImage.chrp \ $(images)/zImage.chrp-rs6k @echo ' kernel: $@ is ready ($<)' @@ -96,7 +99,7 @@ zImage.initrd: $(images)/zImage.initrd.chrp \ TFTPIMAGE := /tftpboot/zImage -.PHONY: znetboot znetboot.initrd +PHONY += znetboot znetboot.initrd znetboot: $(images)/zImage.chrp cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) @echo ' kernel: $@ is ready ($<)' diff --git a/arch/sh/Makefile b/arch/sh/Makefile index 08c9515c480..c72e17a96ee 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile @@ -172,7 +172,7 @@ include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/MARKER archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach -.PHONY: maketools FORCE +PHONY += maketools FORCE maketools: include/linux/version.h FORCE $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h diff --git a/arch/um/Makefile b/arch/um/Makefile index c58b657f009..8d14c7a831b 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -1,4 +1,7 @@ -# +# +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. +# # Copyright (C) 2002 Jeff Dike (jdike@karaya.com) # Licensed under the GPL # @@ -88,7 +91,7 @@ CONFIG_KERNEL_HALF_GIGS ?= 0 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) -.PHONY: linux +PHONY += linux all: linux diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile index d7fd46479c5..7405dfd6522 100644 --- a/arch/x86_64/Makefile +++ b/arch/x86_64/Makefile @@ -67,8 +67,8 @@ drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/ boot := arch/x86_64/boot -.PHONY: bzImage bzlilo install archmrproper \ - fdimage fdimage144 fdimage288 archclean +PHONY += bzImage bzlilo install archmrproper \ + fdimage fdimage144 fdimage288 archclean #Default target when executing "make" all: bzImage diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index c3d2e4e068c..59620b1554e 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -116,16 +116,18 @@ make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) # function to only execute the passed command if necessary # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars -# -if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ +# +if_changed = $(if $(strip $(filter-out $(PHONY),$?) \ + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) # execute the command and also postprocess generated .d dependencies # file -if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ +if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \ + $(filter-out FORCE $(wildcard $^),$^) \ + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ @@ -135,6 +137,7 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ # Usage: $(call if_changed_rule,foo) # will check if $(cmd_foo) changed, or any of the prequisites changed, # and if so will execute $(rule_foo) -if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ +if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \ + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ @set -e; \ $(rule_$(1))) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 6ac96ea92bf..7afe3e76cb5 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -4,7 +4,7 @@ src := $(obj) -.PHONY: __build +PHONY := __build __build: # Read .config if it exist, otherwise ignore @@ -308,14 +308,14 @@ targets += $(multi-used-y) $(multi-used-m) # Descending # --------------------------------------------------------------------------- -.PHONY: $(subdir-ym) +PHONY += $(subdir-ym) $(subdir-ym): $(Q)$(MAKE) $(build)=$@ # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- -.PHONY: FORCE +PHONY += FORCE FORCE: @@ -330,3 +330,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 8974ea5fc87..cff33498fa1 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -4,7 +4,7 @@ src := $(obj) -.PHONY: __clean +PHONY := __clean __clean: # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir @@ -87,10 +87,16 @@ endif # Descending # --------------------------------------------------------------------------- -.PHONY: $(subdir-ymn) +PHONY += $(subdir-ymn) $(subdir-ymn): $(Q)$(MAKE) $(clean)=$@ # If quiet is set, only print short version of command cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 23fd1bdc25c..2686dd5dce8 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -2,7 +2,7 @@ # Installing modules # ========================================================================== -.PHONY: __modinst +PHONY := __modinst __modinst: include scripts/Kbuild.include @@ -12,7 +12,7 @@ include scripts/Kbuild.include __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) -.PHONY: $(modules) +PHONY += $(modules) __modinst: $(modules) @: @@ -27,3 +27,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) $(modules): $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 563e3c5bd8d..0cfbe1cf243 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -32,7 +32,7 @@ # Step 4 is solely used to allow module versioning in external modules, # where the CRC of each module is retrieved from the Module.symers file. -.PHONY: _modpost +PHONY := _modpost _modpost: __modpost include .config @@ -60,7 +60,7 @@ quiet_cmd_modpost = MODPOST $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(filter-out FORCE,$^) -.PHONY: __modpost +PHONY += __modpost __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE $(call cmd,modpost) @@ -97,7 +97,7 @@ targets += $(modules) # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- -.PHONY: FORCE +PHONY += FORCE FORCE: @@ -112,3 +112,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 52809450bee..e6499db4c8c 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -2,7 +2,7 @@ # Kernel configuration targets # These targets are used from top-level makefile -.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config +PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config xconfig: $(obj)/qconf $< arch/$(ARCH)/Kconfig @@ -42,7 +42,7 @@ update-po-config: $(obj)/kxgettext $(Q)rm -f arch/um/Kconfig_arch $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot -.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig +PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig randconfig: $(obj)/conf $< -r arch/$(ARCH)/Kconfig diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile index bbf4887cff7..a8b02632624 100644 --- a/scripts/kconfig/lxdialog/Makefile +++ b/scripts/kconfig/lxdialog/Makefile @@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh # we really need to do so. (Do not call gcc as part of make mrproper) HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) - -HOST_EXTRACFLAGS += -DLOCALE -.PHONY: dochecklxdialog +HOST_EXTRACFLAGS += -DLOCALE + +PHONY += dochecklxdialog $(obj)/dochecklxdialog: $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) diff --git a/scripts/package/Makefile b/scripts/package/Makefile index c201ef001f0..d3038b7643a 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -32,7 +32,7 @@ MKSPEC := $(srctree)/scripts/package/mkspec PREV := set -e; cd ..; # rpm-pkg -.PHONY: rpm-pkg rpm +PHONY += rpm-pkg rpm $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) > $@ @@ -54,10 +54,10 @@ rpm-pkg rpm: $(objtree)/kernel.spec clean-files := $(objtree)/kernel.spec # binrpm-pkg -.PHONY: binrpm-pkg +PHONY += binrpm-pkg $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ - + binrpm-pkg: $(objtree)/binkernel.spec $(MAKE) KBUILD_SRC= set -e; \ @@ -72,7 +72,7 @@ clean-files += $(objtree)/binkernel.spec # Deb target # --------------------------------------------------------------------------- # -.PHONY: deb-pkg +PHONY += deb-pkg deb-pkg: $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb @@ -82,7 +82,7 @@ clean-dirs += $(objtree)/debian/ # tarball targets # --------------------------------------------------------------------------- -.PHONY: tar%pkg +PHONY += tar%pkg tar%pkg: $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ -- cgit v1.2.3 From 0131705d589e2341dbc5e8946a60f83d8c1773dc Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 8 Mar 2006 18:39:05 +0100 Subject: kbuild: replace PHONY with FORCE .PHONY: does not take patterns so use FORCE to achive same effect. Thanks to "Paul D. Smith" for noticing this. Signed-off-by: Sam Ravnborg --- Makefile | 2 -- scripts/package/Makefile | 18 +++++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a59c1e2d0c2..eca667b4098 100644 --- a/Makefile +++ b/Makefile @@ -1000,8 +1000,6 @@ distclean: mrproper # rpm target kept for backward compatibility package-dir := $(srctree)/scripts/package -PHONY += %-pkg rpm - %pkg: FORCE $(Q)$(MAKE) -f $(package-dir)/Makefile $@ rpm: FORCE diff --git a/scripts/package/Makefile b/scripts/package/Makefile index d3038b7643a..7c434e037e7 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -32,12 +32,11 @@ MKSPEC := $(srctree)/scripts/package/mkspec PREV := set -e; cd ..; # rpm-pkg -PHONY += rpm-pkg rpm - +# --------------------------------------------------------------------------- $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) > $@ -rpm-pkg rpm: $(objtree)/kernel.spec +rpm-pkg rpm: $(objtree)/kernel.spec FORCE $(MAKE) clean $(PREV) ln -sf $(srctree) $(KERNELPATH) $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. @@ -54,11 +53,11 @@ rpm-pkg rpm: $(objtree)/kernel.spec clean-files := $(objtree)/kernel.spec # binrpm-pkg -PHONY += binrpm-pkg +# --------------------------------------------------------------------------- $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ -binrpm-pkg: $(objtree)/binkernel.spec +binrpm-pkg: $(objtree)/binkernel.spec FORCE $(MAKE) KBUILD_SRC= set -e; \ $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version @@ -71,9 +70,7 @@ clean-files += $(objtree)/binkernel.spec # Deb target # --------------------------------------------------------------------------- -# -PHONY += deb-pkg -deb-pkg: +deb-pkg: FORCE $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb @@ -82,8 +79,7 @@ clean-dirs += $(objtree)/debian/ # tarball targets # --------------------------------------------------------------------------- -PHONY += tar%pkg -tar%pkg: +tar%pkg: FORCE $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ @@ -92,7 +88,7 @@ clean-dirs += $(objtree)/tar-install/ # Help text displayed when executing 'make help' # --------------------------------------------------------------------------- -help: +help: FORCE @echo ' rpm-pkg - Build the kernel as an RPM package' @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel' @echo ' and modules' -- cgit v1.2.3 From 8cab77a2f851363e35089b9720373b964f64550e Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 7 Mar 2006 23:58:36 -0800 Subject: Kconfig: remove the CONFIG_CC_ALIGN_* options I don't see any use case for the CONFIG_CC_ALIGN_* options: - they are only available if EMBEDDED - people using EMBEDDED will most likely also enable CC_OPTIMIZE_FOR_SIZE - the default for -Os is to disable alignment In case someone is doing performance comparisons and discovers that the default settings gcc chooses aren't good, the only sane thing is to discuss whether it makes sense to change this, not through offering options to change this locally. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- Makefile | 7 ------- init/Kconfig | 37 ------------------------------------- 2 files changed, 44 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index eca667b4098..3dbaac6d521 100644 --- a/Makefile +++ b/Makefile @@ -472,13 +472,6 @@ else CFLAGS += -O2 endif -#Add align options if CONFIG_CC_* is not equal to 0 -add-align = $(if $(filter-out 0,$($(1))),$(cc-option-align)$(2)=$($(1))) -CFLAGS += $(call add-align,CONFIG_CC_ALIGN_FUNCTIONS,-functions) -CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LABELS,-labels) -CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops) -CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps) - ifdef CONFIG_FRAME_POINTER CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) else diff --git a/init/Kconfig b/init/Kconfig index 38416a199de..411600cac88 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -354,43 +354,6 @@ config SHMEM option replaces shmem and tmpfs with the much simpler ramfs code, which may be appropriate on small systems without swap. -config CC_ALIGN_FUNCTIONS - int "Function alignment" if EMBEDDED - default 0 - help - Align the start of functions to the next power-of-two greater than n, - skipping up to n bytes. For instance, 32 aligns functions - to the next 32-byte boundary, but 24 would align to the next - 32-byte boundary only if this can be done by skipping 23 bytes or less. - Zero means use compiler's default. - -config CC_ALIGN_LABELS - int "Label alignment" if EMBEDDED - default 0 - help - Align all branch targets to a power-of-two boundary, skipping - up to n bytes like ALIGN_FUNCTIONS. This option can easily - make code slower, because it must insert dummy operations for - when the branch target is reached in the usual flow of the code. - Zero means use compiler's default. - -config CC_ALIGN_LOOPS - int "Loop alignment" if EMBEDDED - default 0 - help - Align loops to a power-of-two boundary, skipping up to n bytes. - Zero means use compiler's default. - -config CC_ALIGN_JUMPS - int "Jump alignment" if EMBEDDED - default 0 - help - Align branch targets to a power-of-two boundary, for branch - targets where the targets can only be reached by jumping, - skipping up to n bytes like ALIGN_FUNCTIONS. In this case, - no dummy operations need be executed. - Zero means use compiler's default. - config SLAB default y bool "Use full SLAB allocator" if EMBEDDED -- cgit v1.2.3 From 6c2133e11b422b7379b5a660c639f7d53d18ca3b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 21 Mar 2006 07:22:35 +0100 Subject: kbuild: fix make help & make *pkg FORCE was not defined => error. Use kbuild infrastructure to call down to the relevant Makefile. This enables us to use the FORCE definition from kbuild. Signed-off-by: Sam Ravnborg --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3dbaac6d521..0c223dfd302 100644 --- a/Makefile +++ b/Makefile @@ -994,9 +994,9 @@ distclean: mrproper package-dir := $(srctree)/scripts/package %pkg: FORCE - $(Q)$(MAKE) -f $(package-dir)/Makefile $@ + $(Q)$(MAKE) $(build)=$(package-dir) $@ rpm: FORCE - $(Q)$(MAKE) -f $(package-dir)/Makefile $@ + $(Q)$(MAKE) $(build)=$(package-dir) $@ # Brief documentation of the typical targets used @@ -1034,7 +1034,7 @@ help: @echo ' namespacecheck - Name space analysis on compiled kernel' @echo '' @echo 'Kernel packaging:' - @$(MAKE) -f $(package-dir)/Makefile help + @$(MAKE) $(build)=$(package-dir) help @echo '' @echo 'Documentation targets:' @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp -- cgit v1.2.3 From eae0f536f640bb95f2ad437a57c40c7d5683d1ac Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 21 Mar 2006 07:28:24 +0100 Subject: kbuild: remove obsoleted scripts/reference_* files The checks performed by scripts/reference_* has been moved to modpost. Remove the files and their reference in top-level Makefile. Signed-off-by: Sam Ravnborg --- Makefile | 6 --- scripts/reference_discarded.pl | 112 ----------------------------------------- scripts/reference_init.pl | 108 --------------------------------------- 3 files changed, 226 deletions(-) delete mode 100644 scripts/reference_discarded.pl delete mode 100644 scripts/reference_init.pl (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0c223dfd302..6df94f9168c 100644 --- a/Makefile +++ b/Makefile @@ -1028,8 +1028,6 @@ help: @echo ' kernelversion - Output the version stored in Makefile' @echo '' @echo 'Static analysers' - @echo ' buildcheck - List dangling references to vmlinux discarded sections' - @echo ' and init sections from non-init sections' @echo ' checkstack - Generate a list of stack hogs' @echo ' namespacecheck - Name space analysis on compiled kernel' @echo '' @@ -1255,10 +1253,6 @@ versioncheck: -name '*.[hcS]' -type f -print | sort \ | xargs $(PERL) -w scripts/checkversion.pl -buildcheck: - $(PERL) $(srctree)/scripts/reference_discarded.pl - $(PERL) $(srctree)/scripts/reference_init.pl - namespacecheck: $(PERL) $(srctree)/scripts/namespace.pl diff --git a/scripts/reference_discarded.pl b/scripts/reference_discarded.pl deleted file mode 100644 index 4ee6ab2135b..00000000000 --- a/scripts/reference_discarded.pl +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/perl -w -# -# reference_discarded.pl (C) Keith Owens 2001 -# -# Released under GPL V2. -# -# List dangling references to vmlinux discarded sections. - -use strict; -die($0 . " takes no arguments\n") if($#ARGV >= 0); - -my %object; -my $object; -my $line; -my $ignore; -my $errorcount; - -$| = 1; - -# printf("Finding objects, "); -open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed"; -while (defined($line = )) { - chomp($line); - if ($line =~ /:\s+file format/) { - ($object = $line) =~ s/:.*//; - $object{$object}->{'module'} = 0; - $object{$object}->{'size'} = 0; - $object{$object}->{'off'} = 0; - } - if ($line =~ /^\s*\d+\s+\.modinfo\s+/) { - $object{$object}->{'module'} = 1; - } - if ($line =~ /^\s*\d+\s+\.comment\s+/) { - ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5]; - } -} -close(OBJDUMP_LIST); -# printf("%d objects, ", scalar keys(%object)); -$ignore = 0; -foreach $object (keys(%object)) { - if ($object{$object}->{'module'}) { - ++$ignore; - delete($object{$object}); - } -} -# printf("ignoring %d module(s)\n", $ignore); - -# Ignore conglomerate objects, they have been built from multiple objects and we -# only care about the individual objects. If an object has more than one GCC: -# string in the comment section then it is conglomerate. This does not filter -# out conglomerates that consist of exactly one object, can't be helped. - -# printf("Finding conglomerates, "); -$ignore = 0; -foreach $object (keys(%object)) { - if (exists($object{$object}->{'off'})) { - my ($off, $size, $comment, $l); - $off = hex($object{$object}->{'off'}); - $size = hex($object{$object}->{'size'}); - open(OBJECT, "<$object") || die "cannot read $object"; - seek(OBJECT, $off, 0) || die "seek to $off in $object failed"; - $l = read(OBJECT, $comment, $size); - die "read $size bytes from $object .comment failed" if ($l != $size); - close(OBJECT); - if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) { - ++$ignore; - delete($object{$object}); - } - } -} -# printf("ignoring %d conglomerate(s)\n", $ignore); - -# printf("Scanning objects\n"); - -# Keith Ownes commented: -# For our future {in}sanity, add a comment that this is the ppc .opd -# section, not the ia64 .opd section. -# ia64 .opd should not point to discarded sections. -$errorcount = 0; -foreach $object (keys(%object)) { - my $from; - open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object"; - while (defined($line = )) { - chomp($line); - if ($line =~ /RELOCATION RECORDS FOR /) { - ($from = $line) =~ s/.*\[([^]]*).*/$1/; - } - if (($line =~ /\.text\.exit$/ || - $line =~ /\.exit\.text$/ || - $line =~ /\.data\.exit$/ || - $line =~ /\.exit\.data$/ || - $line =~ /\.exitcall\.exit$/) && - ($from !~ /\.text\.exit$/ && - $from !~ /\.exit\.text$/ && - $from !~ /\.data\.exit$/ && - $from !~ /\.opd$/ && - $from !~ /\.exit\.data$/ && - $from !~ /\.altinstructions$/ && - $from !~ /\.pdr$/ && - $from !~ /\.debug_.*$/ && - $from !~ /\.exitcall\.exit$/ && - $from !~ /\.eh_frame$/ && - $from !~ /\.stab$/)) { - printf("Error: %s %s refers to %s\n", $object, $from, $line); - $errorcount = $errorcount + 1; - } - } - close(OBJDUMP); -} -# printf("Done\n"); - -exit(0); diff --git a/scripts/reference_init.pl b/scripts/reference_init.pl deleted file mode 100644 index 7f6960b175a..00000000000 --- a/scripts/reference_init.pl +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/perl -w -# -# reference_init.pl (C) Keith Owens 2002 -# -# List references to vmlinux init sections from non-init sections. - -# Unfortunately I had to exclude references from read only data to .init -# sections, almost all of these are false positives, they are created by -# gcc. The downside of excluding rodata is that there really are some -# user references from rodata to init code, e.g. drivers/video/vgacon.c -# -# const struct consw vga_con = { -# con_startup: vgacon_startup, -# -# where vgacon_startup is __init. If you want to wade through the false -# positives, take out the check for rodata. - -use strict; -die($0 . " takes no arguments\n") if($#ARGV >= 0); - -my %object; -my $object; -my $line; -my $ignore; - -$| = 1; - -printf("Finding objects, "); -open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed"; -while (defined($line = )) { - chomp($line); - if ($line =~ /:\s+file format/) { - ($object = $line) =~ s/:.*//; - $object{$object}->{'module'} = 0; - $object{$object}->{'size'} = 0; - $object{$object}->{'off'} = 0; - } - if ($line =~ /^\s*\d+\s+\.modinfo\s+/) { - $object{$object}->{'module'} = 1; - } - if ($line =~ /^\s*\d+\s+\.comment\s+/) { - ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5]; - } -} -close(OBJDUMP_LIST); -printf("%d objects, ", scalar keys(%object)); -$ignore = 0; -foreach $object (keys(%object)) { - if ($object{$object}->{'module'}) { - ++$ignore; - delete($object{$object}); - } -} -printf("ignoring %d module(s)\n", $ignore); - -# Ignore conglomerate objects, they have been built from multiple objects and we -# only care about the individual objects. If an object has more than one GCC: -# string in the comment section then it is conglomerate. This does not filter -# out conglomerates that consist of exactly one object, can't be helped. - -printf("Finding conglomerates, "); -$ignore = 0; -foreach $object (keys(%object)) { - if (exists($object{$object}->{'off'})) { - my ($off, $size, $comment, $l); - $off = hex($object{$object}->{'off'}); - $size = hex($object{$object}->{'size'}); - open(OBJECT, "<$object") || die "cannot read $object"; - seek(OBJECT, $off, 0) || die "seek to $off in $object failed"; - $l = read(OBJECT, $comment, $size); - die "read $size bytes from $object .comment failed" if ($l != $size); - close(OBJECT); - if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) { - ++$ignore; - delete($object{$object}); - } - } -} -printf("ignoring %d conglomerate(s)\n", $ignore); - -printf("Scanning objects\n"); -foreach $object (sort(keys(%object))) { - my $from; - open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object"; - while (defined($line = )) { - chomp($line); - if ($line =~ /RELOCATION RECORDS FOR /) { - ($from = $line) =~ s/.*\[([^]]*).*/$1/; - } - if (($line =~ /\.init$/ || $line =~ /\.init\./) && - ($from !~ /\.init$/ && - $from !~ /\.init\./ && - $from !~ /\.stab$/ && - $from !~ /\.rodata$/ && - $from !~ /\.text\.lock$/ && - $from !~ /\.pci_fixup_header$/ && - $from !~ /\.pci_fixup_final$/ && - $from !~ /\.pdr$/ && - $from !~ /\__param$/ && - $from !~ /\.altinstructions/ && - $from !~ /\.eh_frame/ && - $from !~ /\.debug_/)) { - printf("Error: %s %s refers to %s\n", $object, $from, $line); - } - } - close(OBJDUMP); -} -printf("Done\n"); -- cgit v1.2.3