From e6883b187920e71ae57bbc9c07885afdd83ddc4e Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 5 Jun 2008 16:43:46 +0200 Subject: kbuild: refactor headers_* targets in Makefile o Use lower case for local variables o Add a helper target for common targets o Use $(hdr-inst)= ... to make Make invocations simpler o Add -rR to make invocations In total this adds more lines than it removes but the benefit is better readability Signed-off-by: Sam Ravnborg Cc: David Woodhouse --- Makefile | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4bcd1cf90cb..f95066176dd 100644 --- a/Makefile +++ b/Makefile @@ -1010,36 +1010,43 @@ firmware_install: FORCE # --------------------------------------------------------------------------- # Kernel headers -INSTALL_HDR_PATH=$(objtree)/usr -export INSTALL_HDR_PATH -HDRFILTER=generic i386 x86_64 -HDRARCHES=$(filter-out $(HDRFILTER),$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) +#Default location for installed headers +export INSTALL_HDR_PATH = $(objtree)/usr -PHONY += headers_install_all -headers_install_all: include/linux/version.h scripts_basic FORCE +hdr-filter := generic um ppc +hdr-archs := $(filter-out $(hdr-filter), \ + $(patsubst $(srctree)/include/asm-%/Kbuild,%, \ + $(wildcard $(srctree)/include/asm-*/Kbuild))) +hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj + +PHONY += __headers +__headers: include/linux/version.h scripts_basic FORCE $(Q)$(MAKE) $(build)=scripts scripts/unifdef - $(Q)for arch in $(HDRARCHES); do \ - $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch ;\ + +PHONY += headers_install_all +headers_install_all: __headers + $(Q)for arch in $(hdr-archs); do \ + $(MAKE) ARCH=$$arch $(hdr-inst)=include BIASMDIR=-bi-$$arch ;\ done PHONY += headers_install -headers_install: include/linux/version.h scripts_basic FORCE - @if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ +headers_install: __headers + $(Q)if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ echo '*** Error: Headers not exportable for this architecture ($(SRCARCH))'; \ - exit 1 ; fi - $(Q)$(MAKE) $(build)=scripts scripts/unifdef - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include + exit 1 ; \ + fi + $(Q)$(MAKE) $(hdr-inst)=include ARCH=$(SRCARCH) PHONY += headers_check_all headers_check_all: headers_install_all - $(Q)for arch in $(HDRARCHES); do \ - $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ + $(Q)for arch in $(hdr-archs); do \ + $(MAKE) ARCH=$$arch $(hdr-inst)=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ done PHONY += headers_check headers_check: headers_install - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include HDRCHECK=1 + $(Q)$(MAKE) $(hdr-inst)=include ARCH=$(SRCARCH) HDRCHECK=1 # --------------------------------------------------------------------------- # Modules -- cgit v1.2.3 From f6ecd4c84a279a7c82f45687a612302becd7b844 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 8 Jun 2008 12:28:22 +0200 Subject: kbuild: error out early in make headers_install Fix the a.out.h case by setting SRCARCH and error out early in case of an error. The a.out.h case failed with the *_all targets. Signed-off-by: Sam Ravnborg --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f95066176dd..33e735c9065 100644 --- a/Makefile +++ b/Makefile @@ -1026,8 +1026,9 @@ __headers: include/linux/version.h scripts_basic FORCE PHONY += headers_install_all headers_install_all: __headers - $(Q)for arch in $(hdr-archs); do \ - $(MAKE) ARCH=$$arch $(hdr-inst)=include BIASMDIR=-bi-$$arch ;\ + $(Q)set -e; for arch in $(hdr-archs); do \ + $(MAKE) ARCH=$$arch SRCARCH=$$arch $(hdr-inst)=include \ + BIASMDIR=-bi-$$arch ;\ done PHONY += headers_install @@ -1040,8 +1041,9 @@ headers_install: __headers PHONY += headers_check_all headers_check_all: headers_install_all - $(Q)for arch in $(hdr-archs); do \ - $(MAKE) ARCH=$$arch $(hdr-inst)=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ + $(Q)set -e; for arch in $(hdr-archs); do \ + $(MAKE) ARCH=$$arch SRCARCH=$$arch $(hdr-inst)=include \ + BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ done PHONY += headers_check -- cgit v1.2.3 From 88181ec30f58a28cd78b26aaac38bef4062b23dc Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 9 Jun 2008 21:24:28 +0200 Subject: kbuild: only one call for include/ in make headers_* Move it to the top-level file to decide if we install/check the generic headers or the arch specific headers. This revealed a long standing bug where "make headers_check_all" relied on the files in asm/ for the current architecture. So make headers_check_all is now broken by this commit. In addition: o add a simpler way to detect if an arch support exporting header files. o add 'set -e;' so we error out early if make headers_check_all fails. o add sparc64 and cris to arch we do not process in make headers_*_all because: sparc64 - use sparc to export headers cris - is know seriously broken Includes suggestions from: David Woodhouse . Signed-off-by: Sam Ravnborg Cc: David Woodhouse --- Makefile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 33e735c9065..2f0136401ba 100644 --- a/Makefile +++ b/Makefile @@ -1014,7 +1014,7 @@ firmware_install: FORCE #Default location for installed headers export INSTALL_HDR_PATH = $(objtree)/usr -hdr-filter := generic um ppc +hdr-filter := generic um ppc sparc64 cris hdr-archs := $(filter-out $(hdr-filter), \ $(patsubst $(srctree)/include/asm-%/Kbuild,%, \ $(wildcard $(srctree)/include/asm-*/Kbuild))) @@ -1026,29 +1026,31 @@ __headers: include/linux/version.h scripts_basic FORCE PHONY += headers_install_all headers_install_all: __headers + $(Q)$(MAKE) $(hdr-inst)=include $(Q)set -e; for arch in $(hdr-archs); do \ - $(MAKE) ARCH=$$arch SRCARCH=$$arch $(hdr-inst)=include \ - BIASMDIR=-bi-$$arch ;\ + $(MAKE) $(hdr-inst)=include/asm-$$arch \ + SRCARCH=$$arch dst=include/asm-$$arch; \ done PHONY += headers_install headers_install: __headers - $(Q)if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ - echo '*** Error: Headers not exportable for this architecture ($(SRCARCH))'; \ - exit 1 ; \ - fi - $(Q)$(MAKE) $(hdr-inst)=include ARCH=$(SRCARCH) + $(if $(wildcard $(srctree)/include/asm-$(SRCARCH)/Kbuild),, \ + $(error Headers not exportable for this architecture ($(SRCARCH)))) + $(Q)$(MAKE) $(hdr-inst)=include + $(Q)$(MAKE) $(hdr-inst)=include/asm-$(SRCARCH) dst=include/asm PHONY += headers_check_all headers_check_all: headers_install_all + $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1 $(Q)set -e; for arch in $(hdr-archs); do \ - $(MAKE) ARCH=$$arch SRCARCH=$$arch $(hdr-inst)=include \ - BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ + $(MAKE) SRCARCH=$$arch $(hdr-inst)=include/asm-$$arch HDRCHECK=1 ;\ done PHONY += headers_check headers_check: headers_install - $(Q)$(MAKE) $(hdr-inst)=include ARCH=$(SRCARCH) HDRCHECK=1 + $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1 + $(Q)$(MAKE) $(hdr-inst)=include/asm-$(SRCARCH) \ + dst=include/asm HDRCHECK=1 # --------------------------------------------------------------------------- # Modules -- cgit v1.2.3 From 6b36ab27d7161bc233e014ff38d8b17ae9975dee Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sat, 7 Jun 2008 01:47:09 +0400 Subject: kbuild: make clean removes *.o.* as well Those are left presumably from aborted ccache(1) compilations: arch/x86/kernel/.tmp_io_apic_64.o.T5veul arch/x86/kvm/.tmp_x86.o.SZWn69 arch/x86/mm/.tmp_pgtable.o.sL1LTf drivers/ieee1394/.tmp_ieee1394_transactions.o.bUj6o1 drivers/infiniband/hw/mlx4/.tmp_main.o.vy0ep6 BTW, with git there is nice way to check for such nuisainces: make mrproper git-ls-files -o should give empty output. More precise wildcard spec from: Jan Engelhardt Signed-off-by: Alexey Dobriyan Signed-off-by: Sam Ravnborg Cc: Jan Engelhardt --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2f0136401ba..3f0a3ca5be8 100644 --- a/Makefile +++ b/Makefile @@ -1160,7 +1160,7 @@ clean: archclean $(clean-dirs) \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.symtypes' -o -name 'modules.order' \ - -o -name 'Module.markers' \) \ + -o -name 'Module.markers' -o -name '.tmp_*.o.*' \) \ -type f -print | xargs rm -f # mrproper - Delete all generated files, including .config -- cgit v1.2.3 From 2fb9b1bd9dd7f4455407dc1bec74fb8ae0d3138e Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 21 Jun 2008 00:24:17 +0200 Subject: kbuild: prepare headers_* for arch/$ARCH/include Factor out the headers_*_all support to a seperate shell script and add support for arch specific header files can be located in either arch/$ARCH/include/asm or include/asm-$ARCH/ In "make help" always display the headers_* targets. Signed-off-by: Sam Ravnborg --- Makefile | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3f0a3ca5be8..c5ab2b8a138 100644 --- a/Makefile +++ b/Makefile @@ -205,6 +205,9 @@ ifeq ($(ARCH),x86_64) SRCARCH := x86 endif +# Where to locate arch specific headers +hdr-arch := $(SRCARCH) + KCONFIG_CONFIG ?= .config # SHELL used by kbuild @@ -1014,43 +1017,39 @@ firmware_install: FORCE #Default location for installed headers export INSTALL_HDR_PATH = $(objtree)/usr -hdr-filter := generic um ppc sparc64 cris -hdr-archs := $(filter-out $(hdr-filter), \ - $(patsubst $(srctree)/include/asm-%/Kbuild,%, \ - $(wildcard $(srctree)/include/asm-*/Kbuild))) hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj +# Find out where the Kbuild file is located to support +# arch/$(ARCH)/include/asm +hdr-dir = $(strip \ + $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild), \ + arch/$(hdr-arch)/include/asm, include/asm-$(hdr-arch))) + +# If we do an all arch process set dst to asm-$(hdr-arch) +hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm) PHONY += __headers __headers: include/linux/version.h scripts_basic FORCE $(Q)$(MAKE) $(build)=scripts scripts/unifdef PHONY += headers_install_all -headers_install_all: __headers - $(Q)$(MAKE) $(hdr-inst)=include - $(Q)set -e; for arch in $(hdr-archs); do \ - $(MAKE) $(hdr-inst)=include/asm-$$arch \ - SRCARCH=$$arch dst=include/asm-$$arch; \ - done +headers_install_all: + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install PHONY += headers_install headers_install: __headers - $(if $(wildcard $(srctree)/include/asm-$(SRCARCH)/Kbuild),, \ - $(error Headers not exportable for this architecture ($(SRCARCH)))) + $(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \ + $(error Headers not exportable for the $(SRCARCH) architecture)) $(Q)$(MAKE) $(hdr-inst)=include - $(Q)$(MAKE) $(hdr-inst)=include/asm-$(SRCARCH) dst=include/asm + $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) PHONY += headers_check_all headers_check_all: headers_install_all - $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1 - $(Q)set -e; for arch in $(hdr-archs); do \ - $(MAKE) SRCARCH=$$arch $(hdr-inst)=include/asm-$$arch HDRCHECK=1 ;\ - done + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check PHONY += headers_check headers_check: headers_install $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1 - $(Q)$(MAKE) $(hdr-inst)=include/asm-$(SRCARCH) \ - dst=include/asm HDRCHECK=1 + $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) HDRCHECK=1 # --------------------------------------------------------------------------- # Modules @@ -1234,21 +1233,17 @@ help: @echo ' cscope - Generate cscope index' @echo ' kernelrelease - Output the release version string' @echo ' kernelversion - Output the version stored in Makefile' - @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ - echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ + @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ echo ' (default: $(INSTALL_HDR_PATH))'; \ - fi - @echo '' + echo '' @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' @echo ' namespacecheck - Name space analysis on compiled kernel' @echo ' versioncheck - Sanity check on version.h usage' @echo ' includecheck - Check for duplicate included header files' @echo ' export_report - List the usages of all exported symbols' - @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ - echo ' headers_check - Sanity check on exported headers'; \ - fi - @echo '' + @echo ' headers_check - Sanity check on exported headers'; \ + echo '' @echo 'Kernel packaging:' @$(MAKE) $(build)=$(package-dir) help @echo '' -- cgit v1.2.3 From a53ce098a763a33311b60c53161572f5789d5594 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 22 Jun 2008 21:41:13 +0200 Subject: kbuild: support arch/$ARCH/include for tags, cscope Signed-off-by: Sam Ravnborg --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c5ab2b8a138..ad0533b9a0d 100644 --- a/Makefile +++ b/Makefile @@ -1416,7 +1416,11 @@ define find-sources \( -name config -o -name 'asm-*' \) -prune \ -o -name $1 -print; \ for arch in $(ALLINCLUDE_ARCHS) ; do \ - find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \ + test -e $(__srctree)include/asm-$${arch} && \ + find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + test -e $(__srctree)arch/$${arch}/include/asm && \ + find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \ -name $1 -print; \ done ; \ find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ -- cgit v1.2.3 From 2e57d051160dd61776461637f767df19036b1186 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 22 Jun 2008 21:42:06 +0200 Subject: kbuild: asm symlink support for arch/$ARCH/include Adjust the asm symlink support so we do not create the symlink unless really needed. We check the precense of include/asm-$ARCH by checking for the system.h file. We may end up with a stale directory so it is not enough to check if the directory is present. Signed-off-by: Sam Ravnborg --- Makefile | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ad0533b9a0d..f6fcad704d2 100644 --- a/Makefile +++ b/Makefile @@ -925,7 +925,9 @@ ifneq ($(KBUILD_SRC),) /bin/false; \ fi; $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; - $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm + $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/system.h ]; then \ + ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \ + fi endif # prepare2 creates a makefile if using a separate output directory @@ -951,22 +953,34 @@ export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) # The asm symlink changes when $(ARCH) changes. # Detect this and ask user to run make mrproper - -include/asm: FORCE - $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ - if [ -L include/asm ]; then \ - if [ "$$asmlink" != "$(SRCARCH)" ]; then \ +define check-symlink + set -e; \ + if [ -L include/asm ]; then \ + asmlink=`readlink include/asm | cut -d '-' -f 2`; \ + if [ "$$asmlink" != "$(SRCARCH)" ]; then \ echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ - exit 1; \ - fi; \ - else \ - echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ - if [ ! -d include ]; then \ - mkdir -p include; \ - fi; \ - ln -fsn asm-$(SRCARCH) $@; \ + exit 1; \ + fi; \ + fi +endef + +# We create the target directory of the symlink if it does +# not exist so the test in chack-symlink works and we have a +# directory for generated filesas used by some architectures. +define create-symlink + if [ ! -L include/asm ]; then \ + echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ + if [ ! -d include/asm-$(SRCARCH) ]; then \ + mkdir -p include/asm-$(SRCARCH); \ + fi; \ + ln -fsn asm-$(SRCARCH) $@; \ fi +endef + +include/asm: FORCE + $(Q)$(check-symlink) + $(Q)$(create-symlink) # Generate some files # --------------------------------------------------------------------------- -- cgit v1.2.3 From 5e4786f75d885dd1a5f9fe12f3385ece7656b0c9 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 22 Jun 2008 21:48:26 +0200 Subject: kbuild: add arch/$ARCH/include to search path This patch conclude the support for arch/$ARCH/include Note: The individual architectures will most likely require a few minor patches to support locating header files in arch/$ARCH/include Testing shows that it worked out-of-the-box for sparc. x86 required a few trivial changes in the arch specific Makefile and a few include paths had to be adjusted. Signed-off-by: Sam Ravnborg --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f6fcad704d2..828c838e025 100644 --- a/Makefile +++ b/Makefile @@ -329,7 +329,8 @@ AFLAGS_KERNEL = # Needed to be compatible with the O= option LINUXINCLUDE := -Iinclude \ $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ - -include include/linux/autoconf.h + -I$(srctree)/arch/$(hdr-arch)/include \ + -include include/linux/autoconf.h KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) -- cgit v1.2.3 From c28ca3aaa1f08877ac0da7efcfead71a08490d65 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 23 Jun 2008 04:05:40 +0400 Subject: kbuild: remove Module.markers during mrproper Signed-off-by: Alexey Dobriyan Signed-off-by: Sam Ravnborg --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 828c838e025..b4a52d218f9 100644 --- a/Makefile +++ b/Makefile @@ -1155,7 +1155,7 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \ include/linux/autoconf.h include/linux/version.h \ include/linux/utsrelease.h \ include/linux/bounds.h include/asm*/asm-offsets.h \ - Module.symvers tags TAGS cscope* + Module.symvers Module.markers tags TAGS cscope* # clean - Delete most, but leave enough to build external modules # -- cgit v1.2.3