summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-07-04 12:55:45 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-04 12:55:45 -0700
commit6fa0cb1141da80eed4f86155fb51931bc1c31888 (patch)
treedf9b3c378ae4f44260eaae1a4b9d5c4ccf7bb641 /scripts
parentc6482dde1c2811afba289b2344268f850595f350 (diff)
parent257a5bdeb0441789d8e34e1b3e92b26d0f51bbf0 (diff)
Merge git://git.infradead.org/hdrinstall-2.6
* git://git.infradead.org/hdrinstall-2.6: Remove export of include/linux/isdn/tpam.h Remove <linux/i2c-id.h> and <linux/i2c-algo-ite.h> from userspace export Restrict headers exported to userspace for SPARC and SPARC64 Add empty Kbuild files for 'make headers_install' in remaining arches. Add Kbuild file for Alpha 'make headers_install' Add Kbuild file for SPARC 'make headers_install' Add Kbuild file for IA64 'make headers_install' Add Kbuild file for S390 'make headers_install' Add Kbuild file for i386 'make headers_install' Add Kbuild file for x86_64 'make headers_install' Add Kbuild file for PowerPC 'make headers_install' Add generic Kbuild files for 'make headers_install' Basic implementation of 'make headers_check' Basic implementation of 'make headers_install'
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.headersinst158
-rwxr-xr-xscripts/hdrcheck.sh8
2 files changed, 166 insertions, 0 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
new file mode 100644
index 000000000000..aa9990a3ccd6
--- /dev/null
+++ b/scripts/Makefile.headersinst
@@ -0,0 +1,158 @@
+# ==========================================================================
+# Installing headers
+#
+# header-y files will be installed verbatim
+# unifdef-y are the files where unifdef will be run before installing files
+# objhdr-y are generated files that will be installed verbatim
+#
+# ==========================================================================
+
+UNIFDEF := unifdef -U__KERNEL__
+
+# Eliminate the contents of (and inclusions of) compiler.h
+HDRSED := sed -e "s/ inline / __inline__ /g" \
+ -e "s/[[:space:]]__user[[:space:]]\+/ /g" \
+ -e "s/(__user[[:space:]]\+/ (/g" \
+ -e "s/[[:space:]]__force[[:space:]]\+/ /g" \
+ -e "s/(__force[[:space:]]\+/ (/g" \
+ -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \
+ -e "s/(__iomem[[:space:]]\+/ (/g" \
+ -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \
+ -e "s/[[:space:]]__attribute_const__$$//" \
+ -e "/^\#include <linux\/compiler.h>/d"
+
+_dst := $(if $(dst),$(dst),$(obj))
+
+.PHONY: __headersinst
+__headersinst:
+
+
+ifeq (,$(patsubst include/asm/%,,$(obj)/))
+# For producing the generated stuff in include/asm for biarch builds, include
+# both sets of Kbuild files; we'll generate anything which is mentioned in
+# _either_ arch, and recurse into subdirectories which are mentioned in either
+# arch. Since some directories may exist in one but not the other, we must
+# use '-include'.
+GENASM := 1
+archasm := $(subst include/asm,asm-$(ARCH),$(obj))
+altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
+-include $(srctree)/include/$(archasm)/Kbuild
+-include $(srctree)/include/$(altarchasm)/Kbuild
+else
+include $(srctree)/$(obj)/Kbuild
+endif
+
+include scripts/Kbuild.include
+
+# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then
+# override $(_dst) so that we install to include/asm directly.
+ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH))
+ _dst := include/asm
+endif
+
+header-y := $(sort $(header-y))
+unifdef-y := $(sort $(unifdef-y))
+subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
+header-y := $(filter-out %/, $(header-y))
+header-y := $(filter-out $(unifdef-y),$(header-y))
+
+ifdef ALTARCH
+ifeq ($(obj),include/asm-$(ARCH))
+altarch-y := altarch-dir
+endif
+endif
+
+# Make the definitions visible for recursive make invocations
+export ALTARCH
+export ARCHDEF
+export ALTARCHDEF
+
+quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@
+ cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst)
+
+quiet_cmd_headers_install = INSTALL $(_dst)/$@
+ cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \
+ > $(INSTALL_HDR_PATH)/$(_dst)/$@
+
+quiet_cmd_unifdef = UNIFDEF $(_dst)/$@
+ cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \
+ > $(INSTALL_HDR_PATH)/$(_dst)/$@ || :
+
+quiet_cmd_check = CHECK $(_dst)/$@
+ cmd_check = $(srctree)/scripts/hdrcheck.sh \
+ $(INSTALL_HDR_PATH)/include \
+ $(INSTALL_HDR_PATH)/$(_dst)/$@
+
+quiet_cmd_mkdir = MKDIR $@
+ cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@
+
+quiet_cmd_gen = GEN $(_dst)/$@
+ cmd_gen = \
+STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \
+(echo "/* File autogenerated by 'make headers_install' */" ; \
+echo "\#ifndef $$STUBDEF" ; \
+echo "\#define $$STUBDEF" ; \
+echo "\# if $(ARCHDEF)" ; \
+if [ -r $(srctree)/include/$(archasm)/$@ ]; then \
+ echo "\# include <$(archasm)/$@>" ; \
+else \
+ echo "\# error $(archasm)/$@ does not exist in" \
+ "the $(ARCH) architecture" ; \
+fi ; \
+echo "\# elif $(ALTARCHDEF)" ; \
+if [ -r $(srctree)/include/$(altarchasm)/$@ ]; then \
+ echo "\# include <$(altarchasm)/$@>" ; \
+else \
+ echo "\# error $(altarchasm)/$@ does not exist in" \
+ "the $(ALTARCH) architecture" ; \
+fi ; \
+echo "\# else" ; \
+echo "\# warning This machine appears to be" \
+ "neither $(ARCH) nor $(ALTARCH)." ; \
+echo "\# endif" ; \
+echo "\#endif /* $$STUBDEF */" ; \
+) > $(INSTALL_HDR_PATH)/$(_dst)/$@
+
+__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
+
+.PHONY: $(header-y) $(unifdef-y) $(subdir-y)
+
+ifdef HDRCHECK
+# Rules for checking headers
+$(objhdr-y) $(header-y) $(unifdef-y):
+ $(call cmd,check)
+else
+# Rules for installing headers
+
+$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst)
+
+.PHONY: $(_dst)
+$(_dst):
+ $(call cmd,mkdir)
+
+ifdef GENASM
+$(objhdr-y) $(header-y) $(unifdef-y):
+ $(call cmd,gen)
+
+else
+$(objhdr-y):
+ $(call cmd,o_hdr_install)
+
+$(header-y):
+ $(call cmd,headers_install)
+
+$(unifdef-y):
+ $(call cmd,unifdef)
+endif
+endif
+
+hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
+
+.PHONY: altarch-dir
+altarch-dir:
+ $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
+ $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm
+
+# Recursion
+$(subdir-y):
+ $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)
diff --git a/scripts/hdrcheck.sh b/scripts/hdrcheck.sh
new file mode 100755
index 000000000000..b3bb683b56b6
--- /dev/null
+++ b/scripts/hdrcheck.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+for FILE in `grep '^#include <' $2 | cut -f2 -d\< | cut -f1 -d\> | egrep ^linux\|^asm` ; do
+ if [ ! -r $1/$FILE ]; then
+ echo $2 requires $FILE, which does not exist
+ exit 1
+ fi
+done