Commit 2fb9b1bd authored by Sam Ravnborg's avatar Sam Ravnborg

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: default avatarSam Ravnborg <sam@ravnborg.org>
parent db1bec4f
...@@ -205,6 +205,9 @@ ifeq ($(ARCH),x86_64) ...@@ -205,6 +205,9 @@ ifeq ($(ARCH),x86_64)
SRCARCH := x86 SRCARCH := x86
endif endif
# Where to locate arch specific headers
hdr-arch := $(SRCARCH)
KCONFIG_CONFIG ?= .config KCONFIG_CONFIG ?= .config
# SHELL used by kbuild # SHELL used by kbuild
...@@ -1014,43 +1017,39 @@ firmware_install: FORCE ...@@ -1014,43 +1017,39 @@ firmware_install: FORCE
#Default location for installed headers #Default location for installed headers
export INSTALL_HDR_PATH = $(objtree)/usr 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 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 PHONY += __headers
__headers: include/linux/version.h scripts_basic FORCE __headers: include/linux/version.h scripts_basic FORCE
$(Q)$(MAKE) $(build)=scripts scripts/unifdef $(Q)$(MAKE) $(build)=scripts scripts/unifdef
PHONY += headers_install_all PHONY += headers_install_all
headers_install_all: __headers headers_install_all:
$(Q)$(MAKE) $(hdr-inst)=include $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
$(Q)set -e; for arch in $(hdr-archs); do \
$(MAKE) $(hdr-inst)=include/asm-$$arch \
SRCARCH=$$arch dst=include/asm-$$arch; \
done
PHONY += headers_install PHONY += headers_install
headers_install: __headers headers_install: __headers
$(if $(wildcard $(srctree)/include/asm-$(SRCARCH)/Kbuild),, \ $(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \
$(error Headers not exportable for this architecture ($(SRCARCH)))) $(error Headers not exportable for the $(SRCARCH) architecture))
$(Q)$(MAKE) $(hdr-inst)=include $(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 PHONY += headers_check_all
headers_check_all: headers_install_all headers_check_all: headers_install_all
$(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
$(Q)set -e; for arch in $(hdr-archs); do \
$(MAKE) SRCARCH=$$arch $(hdr-inst)=include/asm-$$arch HDRCHECK=1 ;\
done
PHONY += headers_check PHONY += headers_check
headers_check: headers_install headers_check: headers_install
$(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1 $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1
$(Q)$(MAKE) $(hdr-inst)=include/asm-$(SRCARCH) \ $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) HDRCHECK=1
dst=include/asm HDRCHECK=1
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Modules # Modules
...@@ -1234,21 +1233,17 @@ help: ...@@ -1234,21 +1233,17 @@ help:
@echo ' cscope - Generate cscope index' @echo ' cscope - Generate cscope index'
@echo ' kernelrelease - Output the release version string' @echo ' kernelrelease - Output the release version string'
@echo ' kernelversion - Output the version stored in Makefile' @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))'; \ echo ' (default: $(INSTALL_HDR_PATH))'; \
fi echo ''
@echo ''
@echo 'Static analysers' @echo 'Static analysers'
@echo ' checkstack - Generate a list of stack hogs' @echo ' checkstack - Generate a list of stack hogs'
@echo ' namespacecheck - Name space analysis on compiled kernel' @echo ' namespacecheck - Name space analysis on compiled kernel'
@echo ' versioncheck - Sanity check on version.h usage' @echo ' versioncheck - Sanity check on version.h usage'
@echo ' includecheck - Check for duplicate included header files' @echo ' includecheck - Check for duplicate included header files'
@echo ' export_report - List the usages of all exported symbols' @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'; \
echo ' headers_check - Sanity check on exported headers'; \ echo ''
fi
@echo ''
@echo 'Kernel packaging:' @echo 'Kernel packaging:'
@$(MAKE) $(build)=$(package-dir) help @$(MAKE) $(build)=$(package-dir) help
@echo '' @echo ''
......
#!/bin/sh
# Run headers_$1 command for all suitable architectures
# Stop on error
set -e
do_command()
{
if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
elif [ -f ${srctree}/include/asm-$2/Kbuild ]; then
make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
else
printf "Ignoring arch: %s\n" ${arch}
fi
}
# Do not try this architecture
drop="generic um ppc sparc64 cris"
archs=$(ls ${srctree}/arch)
for arch in ${archs}; do
case ${arch} in
um) # no userspace export
;;
ppc) # headers exported by powerpc
;;
sparc64) # headers exported by sparc
;;
cris) # headers export are known broken
;;
*)
if [ -d ${srctree}/arch/${arch} ]; then
do_command $1 ${arch}
fi
;;
esac
done
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment