Commit 2fb9b1bd9dd7f4455407dc1bec74fb8ae0d3138e

Authored by Sam Ravnborg
1 parent db1bec4f52

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 <sam@ravnborg.org>

Showing 2 changed files with 63 additions and 27 deletions Side-by-side Diff

... ... @@ -205,6 +205,9 @@
205 205 SRCARCH := x86
206 206 endif
207 207  
  208 +# Where to locate arch specific headers
  209 +hdr-arch := $(SRCARCH)
  210 +
208 211 KCONFIG_CONFIG ?= .config
209 212  
210 213 # SHELL used by kbuild
211 214  
212 215  
213 216  
214 217  
215 218  
216 219  
217 220  
... ... @@ -1014,43 +1017,39 @@
1014 1017 #Default location for installed headers
1015 1018 export INSTALL_HDR_PATH = $(objtree)/usr
1016 1019  
1017   -hdr-filter := generic um ppc sparc64 cris
1018   -hdr-archs := $(filter-out $(hdr-filter), \
1019   - $(patsubst $(srctree)/include/asm-%/Kbuild,%, \
1020   - $(wildcard $(srctree)/include/asm-*/Kbuild)))
1021 1020 hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
  1021 +# Find out where the Kbuild file is located to support
  1022 +# arch/$(ARCH)/include/asm
  1023 +hdr-dir = $(strip \
  1024 + $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild), \
  1025 + arch/$(hdr-arch)/include/asm, include/asm-$(hdr-arch)))
1022 1026  
  1027 +# If we do an all arch process set dst to asm-$(hdr-arch)
  1028 +hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
  1029 +
1023 1030 PHONY += __headers
1024 1031 __headers: include/linux/version.h scripts_basic FORCE
1025 1032 $(Q)$(MAKE) $(build)=scripts scripts/unifdef
1026 1033  
1027 1034 PHONY += headers_install_all
1028   -headers_install_all: __headers
1029   - $(Q)$(MAKE) $(hdr-inst)=include
1030   - $(Q)set -e; for arch in $(hdr-archs); do \
1031   - $(MAKE) $(hdr-inst)=include/asm-$$arch \
1032   - SRCARCH=$$arch dst=include/asm-$$arch; \
1033   - done
  1035 +headers_install_all:
  1036 + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
1034 1037  
1035 1038 PHONY += headers_install
1036 1039 headers_install: __headers
1037   - $(if $(wildcard $(srctree)/include/asm-$(SRCARCH)/Kbuild),, \
1038   - $(error Headers not exportable for this architecture ($(SRCARCH))))
  1040 + $(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \
  1041 + $(error Headers not exportable for the $(SRCARCH) architecture))
1039 1042 $(Q)$(MAKE) $(hdr-inst)=include
1040   - $(Q)$(MAKE) $(hdr-inst)=include/asm-$(SRCARCH) dst=include/asm
  1043 + $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst)
1041 1044  
1042 1045 PHONY += headers_check_all
1043 1046 headers_check_all: headers_install_all
1044   - $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1
1045   - $(Q)set -e; for arch in $(hdr-archs); do \
1046   - $(MAKE) SRCARCH=$$arch $(hdr-inst)=include/asm-$$arch HDRCHECK=1 ;\
1047   - done
  1047 + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
1048 1048  
1049 1049 PHONY += headers_check
1050 1050 headers_check: headers_install
1051 1051 $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1
1052   - $(Q)$(MAKE) $(hdr-inst)=include/asm-$(SRCARCH) \
1053   - dst=include/asm HDRCHECK=1
  1052 + $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) HDRCHECK=1
1054 1053  
1055 1054 # ---------------------------------------------------------------------------
1056 1055 # Modules
1057 1056  
1058 1057  
... ... @@ -1234,21 +1233,17 @@
1234 1233 @echo ' cscope - Generate cscope index'
1235 1234 @echo ' kernelrelease - Output the release version string'
1236 1235 @echo ' kernelversion - Output the version stored in Makefile'
1237   - @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \
1238   - echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
  1236 + @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1239 1237 echo ' (default: $(INSTALL_HDR_PATH))'; \
1240   - fi
1241   - @echo ''
  1238 + echo ''
1242 1239 @echo 'Static analysers'
1243 1240 @echo ' checkstack - Generate a list of stack hogs'
1244 1241 @echo ' namespacecheck - Name space analysis on compiled kernel'
1245 1242 @echo ' versioncheck - Sanity check on version.h usage'
1246 1243 @echo ' includecheck - Check for duplicate included header files'
1247 1244 @echo ' export_report - List the usages of all exported symbols'
1248   - @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \
1249   - echo ' headers_check - Sanity check on exported headers'; \
1250   - fi
1251   - @echo ''
  1245 + @echo ' headers_check - Sanity check on exported headers'; \
  1246 + echo ''
1252 1247 @echo 'Kernel packaging:'
1253 1248 @$(MAKE) $(build)=$(package-dir) help
1254 1249 @echo ''
  1 +#!/bin/sh
  2 +# Run headers_$1 command for all suitable architectures
  3 +
  4 +# Stop on error
  5 +set -e
  6 +
  7 +do_command()
  8 +{
  9 + if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
  10 + make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
  11 + elif [ -f ${srctree}/include/asm-$2/Kbuild ]; then
  12 + make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
  13 + else
  14 + printf "Ignoring arch: %s\n" ${arch}
  15 + fi
  16 +}
  17 +
  18 +# Do not try this architecture
  19 +drop="generic um ppc sparc64 cris"
  20 +
  21 +archs=$(ls ${srctree}/arch)
  22 +
  23 +for arch in ${archs}; do
  24 + case ${arch} in
  25 + um) # no userspace export
  26 + ;;
  27 + ppc) # headers exported by powerpc
  28 + ;;
  29 + sparc64) # headers exported by sparc
  30 + ;;
  31 + cris) # headers export are known broken
  32 + ;;
  33 + *)
  34 + if [ -d ${srctree}/arch/${arch} ]; then
  35 + do_command $1 ${arch}
  36 + fi
  37 + ;;
  38 + esac
  39 +done