aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.headersinst158
-rwxr-xr-xscripts/checkversion.pl7
-rwxr-xr-xscripts/hdrcheck.sh8
3 files changed, 169 insertions, 4 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 @@
1# ==========================================================================
2# Installing headers
3#
4# header-y files will be installed verbatim
5# unifdef-y are the files where unifdef will be run before installing files
6# objhdr-y are generated files that will be installed verbatim
7#
8# ==========================================================================
9
10UNIFDEF := unifdef -U__KERNEL__
11
12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \
14 -e "s/[[:space:]]__user[[:space:]]\+/ /g" \
15 -e "s/(__user[[:space:]]\+/ (/g" \
16 -e "s/[[:space:]]__force[[:space:]]\+/ /g" \
17 -e "s/(__force[[:space:]]\+/ (/g" \
18 -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \
19 -e "s/(__iomem[[:space:]]\+/ (/g" \
20 -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \
21 -e "s/[[:space:]]__attribute_const__$$//" \
22 -e "/^\#include <linux\/compiler.h>/d"
23
24_dst := $(if $(dst),$(dst),$(obj))
25
26.PHONY: __headersinst
27__headersinst:
28
29
30ifeq (,$(patsubst include/asm/%,,$(obj)/))
31# For producing the generated stuff in include/asm for biarch builds, include
32# both sets of Kbuild files; we'll generate anything which is mentioned in
33# _either_ arch, and recurse into subdirectories which are mentioned in either
34# arch. Since some directories may exist in one but not the other, we must
35# use '-include'.
36GENASM := 1
37archasm := $(subst include/asm,asm-$(ARCH),$(obj))
38altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
39-include $(srctree)/include/$(archasm)/Kbuild
40-include $(srctree)/include/$(altarchasm)/Kbuild
41else
42include $(srctree)/$(obj)/Kbuild
43endif
44
45include scripts/Kbuild.include
46
47# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then
48# override $(_dst) so that we install to include/asm directly.
49ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH))
50 _dst := include/asm
51endif
52
53header-y := $(sort $(header-y))
54unifdef-y := $(sort $(unifdef-y))
55subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
56header-y := $(filter-out %/, $(header-y))
57header-y := $(filter-out $(unifdef-y),$(header-y))
58
59ifdef ALTARCH
60ifeq ($(obj),include/asm-$(ARCH))
61altarch-y := altarch-dir
62endif
63endif
64
65# Make the definitions visible for recursive make invocations
66export ALTARCH
67export ARCHDEF
68export ALTARCHDEF
69
70quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@
71 cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst)
72
73quiet_cmd_headers_install = INSTALL $(_dst)/$@
74 cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \
75 > $(INSTALL_HDR_PATH)/$(_dst)/$@
76
77quiet_cmd_unifdef = UNIFDEF $(_dst)/$@
78 cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \
79 > $(INSTALL_HDR_PATH)/$(_dst)/$@ || :
80
81quiet_cmd_check = CHECK $(_dst)/$@
82 cmd_check = $(srctree)/scripts/hdrcheck.sh \
83 $(INSTALL_HDR_PATH)/include \
84 $(INSTALL_HDR_PATH)/$(_dst)/$@
85
86quiet_cmd_mkdir = MKDIR $@
87 cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@
88
89quiet_cmd_gen = GEN $(_dst)/$@
90 cmd_gen = \
91STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \
92(echo "/* File autogenerated by 'make headers_install' */" ; \
93echo "\#ifndef $$STUBDEF" ; \
94echo "\#define $$STUBDEF" ; \
95echo "\# if $(ARCHDEF)" ; \
96if [ -r $(srctree)/include/$(archasm)/$@ ]; then \
97 echo "\# include <$(archasm)/$@>" ; \
98else \
99 echo "\# error $(archasm)/$@ does not exist in" \
100 "the $(ARCH) architecture" ; \
101fi ; \
102echo "\# elif $(ALTARCHDEF)" ; \
103if [ -r $(srctree)/include/$(altarchasm)/$@ ]; then \
104 echo "\# include <$(altarchasm)/$@>" ; \
105else \
106 echo "\# error $(altarchasm)/$@ does not exist in" \
107 "the $(ALTARCH) architecture" ; \
108fi ; \
109echo "\# else" ; \
110echo "\# warning This machine appears to be" \
111 "neither $(ARCH) nor $(ALTARCH)." ; \
112echo "\# endif" ; \
113echo "\#endif /* $$STUBDEF */" ; \
114) > $(INSTALL_HDR_PATH)/$(_dst)/$@
115
116__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
117
118.PHONY: $(header-y) $(unifdef-y) $(subdir-y)
119
120ifdef HDRCHECK
121# Rules for checking headers
122$(objhdr-y) $(header-y) $(unifdef-y):
123 $(call cmd,check)
124else
125# Rules for installing headers
126
127$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst)
128
129.PHONY: $(_dst)
130$(_dst):
131 $(call cmd,mkdir)
132
133ifdef GENASM
134$(objhdr-y) $(header-y) $(unifdef-y):
135 $(call cmd,gen)
136
137else
138$(objhdr-y):
139 $(call cmd,o_hdr_install)
140
141$(header-y):
142 $(call cmd,headers_install)
143
144$(unifdef-y):
145 $(call cmd,unifdef)
146endif
147endif
148
149hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
150
151.PHONY: altarch-dir
152altarch-dir:
153 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
154 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm
155
156# Recursion
157$(subdir-y):
158 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)
diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl
index 9f84e562318d..ec7d21161bdc 100755
--- a/scripts/checkversion.pl
+++ b/scripts/checkversion.pl
@@ -1,7 +1,7 @@
1#! /usr/bin/perl 1#! /usr/bin/perl
2# 2#
3# checkversion find uses of LINUX_VERSION_CODE, KERNEL_VERSION, or 3# checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION
4# UTS_RELEASE without including <linux/version.h>, or cases of 4# without including <linux/version.h>, or cases of
5# including <linux/version.h> that don't need it. 5# including <linux/version.h> that don't need it.
6# Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net> 6# Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net>
7 7
@@ -41,8 +41,7 @@ foreach $file (@ARGV)
41 } 41 }
42 42
43 # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE 43 # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE
44 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/) || 44 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) {
45 ($_ =~ /UTS_RELEASE/)) {
46 $fUseVersion = 1; 45 $fUseVersion = 1;
47 last LINE if $iLinuxVersion; 46 last LINE if $iLinuxVersion;
48 } 47 }
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 @@
1#!/bin/sh
2
3for FILE in `grep '^#include <' $2 | cut -f2 -d\< | cut -f1 -d\> | egrep ^linux\|^asm` ; do
4 if [ ! -r $1/$FILE ]; then
5 echo $2 requires $FILE, which does not exist
6 exit 1
7 fi
8done