aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.headersinst
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-28 15:14:43 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-28 15:14:43 -0400
commit414f746d232d41ed6ae8632c4495ae795373c44b (patch)
tree167f9bc8f139c6e82e6732b38c7a938b8a9d31cd /scripts/Makefile.headersinst
parent5a7a201c51c324876d00a54e7208af6af12d1ca4 (diff)
parentc9272c4f9fbe2087beb3392f526dc5b19efaa56b (diff)
Merge branch 'linus' into cpus4096
Diffstat (limited to 'scripts/Makefile.headersinst')
-rw-r--r--scripts/Makefile.headersinst230
1 files changed, 67 insertions, 163 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 53dae3eb3d1f..612dc13ddd85 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -1,194 +1,98 @@
1# ========================================================================== 1# ==========================================================================
2# Installing headers 2# Installing headers
3# 3#
4# header-y files will be installed verbatim 4# header-y - list files to be installed. They are preprocessed
5# unifdef-y are the files where unifdef will be run before installing files 5# to remove __KERNEL__ section of the file
6# objhdr-y are generated files that will be installed verbatim 6# unifdef-y - Same as header-y. Obsolete
7# objhdr-y - Same as header-y but for generated files
7# 8#
8# ========================================================================== 9# ==========================================================================
9 10
10UNIFDEF := scripts/unifdef -U__KERNEL__ 11# called may set destination dir (when installing to asm/)
11
12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \
14 -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
15 -e "s/(__user[[:space:]]\{1,\}/ (/g" \
16 -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
17 -e "s/(__force[[:space:]]\{1,\}/ (/g" \
18 -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \
19 -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \
20 -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \
21 -e "s/[[:space:]]__attribute_const__$$//" \
22 -e "/^\#include <linux\/compiler.h>/d"
23
24_dst := $(if $(dst),$(dst),$(obj)) 12_dst := $(if $(dst),$(dst),$(obj))
25 13
26ifeq (,$(patsubst include/asm/%,,$(obj)/)) 14kbuild-file := $(srctree)/$(obj)/Kbuild
27# For producing the generated stuff in include/asm for biarch builds, include 15include $(kbuild-file)
28# both sets of Kbuild files; we'll generate anything which is mentioned in
29# _either_ arch, and recurse into subdirectories which are mentioned in either
30# arch. Since some directories may exist in one but not the other, we must
31# use $(wildcard...).
32GENASM := 1
33archasm := $(subst include/asm,asm-$(ARCH),$(obj))
34altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
35KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild)
36else
37KBUILDFILES := $(srctree)/$(obj)/Kbuild
38endif
39 16
40include $(KBUILDFILES) 17include scripts/Kbuild.include
41 18
42include scripts/Kbuild.include 19install := $(INSTALL_HDR_PATH)/$(_dst)
43 20
44# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then 21header-y := $(sort $(header-y) $(unifdef-y))
45# override $(_dst) so that we install to include/asm directly. 22subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
46# Unless $(BIASMDIR) is set, in which case we're probably doing 23header-y := $(filter-out %/, $(header-y))
47# a 'headers_install_all' build and we should keep the -$(ARCH)
48# in the directory name.
49ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR))
50 _dst := include/asm
51endif
52 24
53header-y := $(sort $(header-y)) 25# files used to track state of install/check
54unifdef-y := $(sort $(unifdef-y)) 26install-file := $(install)/.install
55subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) 27check-file := $(install)/.check
56header-y := $(filter-out %/, $(header-y))
57header-y := $(filter-out $(unifdef-y),$(header-y))
58 28
59# stamp files for header checks 29# all headers files for this dir
60check-y := $(patsubst %,.check.%,$(header-y) $(unifdef-y) $(objhdr-y)) 30all-files := $(header-y) $(objhdr-y)
31input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
32 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
33output-files := $(addprefix $(install)/, $(all-files))
61 34
62# Work out what needs to be removed 35# Work out what needs to be removed
63oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) 36oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
64unwanted := $(filter-out $(header-y) $(unifdef-y) $(objhdr-y),$(oldheaders)) 37unwanted := $(filter-out $(all-files),$(oldheaders))
65 38
66oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) 39# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
67unwanted += $(filter-out $(check-y),$(oldcheckstamps)) 40unwanted-file := $(addprefix $(install)/, $(unwanted))
68 41
69# Prefix them all with full paths to $(INSTALL_HDR_PATH) 42printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
70header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y))
71unifdef-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(unifdef-y))
72objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y))
73check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y))
74 43
44quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
45 file$(if $(word 2, $(all-files)),s))
46 cmd_install = \
47 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
48 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
49 touch $@
75 50
76ifdef ALTARCH 51quiet_cmd_remove = REMOVE $(unwanted)
77ifeq ($(obj),include/asm-$(ARCH)) 52 cmd_remove = rm -f $(unwanted-file)
78altarch-y := altarch-dir
79endif
80endif
81 53
82# Make the definitions visible for recursive make invocations 54quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
83export ALTARCH 55 cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \
84export ARCHDEF 56 $(addprefix $(install)/, $(all-files)); \
85export ALTARCHDEF 57 touch $@
86
87quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
88 cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \
89 $(INSTALL_HDR_PATH)/$(_dst)
90
91quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
92 cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
93 > $@
94
95quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
96 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
97 | $(HDRSED) > $@ || :
98
99quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
100 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
101 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
102
103quiet_cmd_remove = REMOVE $(_dst)/$@
104 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
105
106quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
107 cmd_mkdir = mkdir -p $@
108
109quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
110 cmd_gen = \
111FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@); \
112STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \
113(echo "/* File autogenerated by 'make headers_install' */" ; \
114echo "\#ifndef $$STUBDEF" ; \
115echo "\#define $$STUBDEF" ; \
116echo "\# if $(ARCHDEF)" ; \
117if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \
118 echo "\# include <$(archasm)/$$FNAME>" ; \
119else \
120 echo "\# error $(archasm)/$$FNAME does not exist in" \
121 "the $(ARCH) architecture" ; \
122fi ; \
123echo "\# elif $(ALTARCHDEF)" ; \
124if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \
125 echo "\# include <$(altarchasm)/$$FNAME>" ; \
126else \
127 echo "\# error $(altarchasm)/$$FNAME does not exist in" \
128 "the $(ALTARCH) architecture" ; \
129fi ; \
130echo "\# else" ; \
131echo "\# warning This machine appears to be" \
132 "neither $(ARCH) nor $(ALTARCH)." ; \
133echo "\# endif" ; \
134echo "\#endif /* $$STUBDEF */" ; \
135) > $@
136
137.PHONY: __headersinst __headerscheck
138
139ifdef HDRCHECK
140__headerscheck: $(subdir-y) $(check-y)
141 @true
142
143$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h
144 $(call cmd,check)
145
146# Other dependencies for $(check-y)
147include /dev/null $(wildcard $(check-y))
148
149# ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
150.PHONY: $(check-y)
151 58
152else 59PHONY += __headersinst __headerscheck
153# Rules for installing headers
154__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
155 @true
156 60
157$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) 61ifndef HDRCHECK
158 62# Rules for installing headers
159$(INSTALL_HDR_PATH)/$(_dst): 63__headersinst: $(subdirs) $(install-file)
160 $(call cmd,mkdir) 64 @:
161
162.PHONY: $(unwanted)
163$(unwanted):
164 $(call cmd,remove)
165 65
166ifdef GENASM 66targets += $(install-file)
167$(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES) 67$(install-file): scripts/headers_install.pl $(input-files) FORCE
168 $(call cmd,gen) 68 $(if $(unwanted),$(call cmd,remove),)
69 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
70 $(call if_changed,install)
169 71
170else 72else
171$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(KBUILDFILES) 73__headerscheck: $(subdirs) $(check-file)
172 $(call cmd,o_hdr_install) 74 @:
173 75
174$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) 76targets += $(check-file)
175 $(call cmd,headers_install) 77$(check-file): scripts/headers_check.pl $(output-files) FORCE
78 $(call if_changed,check)
176 79
177$(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
178 $(call cmd,unifdef)
179endif
180endif 80endif
181 81
182hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj 82# Recursion
83hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
84.PHONY: $(subdirs)
85$(subdirs):
86 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
183 87
184.PHONY: altarch-dir 88targets := $(wildcard $(sort $(targets)))
185# All the files in the normal arch dir must be created first, since we test 89cmd_files := $(wildcard \
186# for their existence. 90 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
187altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y)
188 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
189 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR)
190 91
191# Recursion 92ifneq ($(cmd_files),)
192.PHONY: $(subdir-y) 93 include $(cmd_files)
193$(subdir-y): 94endif
194 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) 95
96.PHONY: $(PHONY)
97PHONY += FORCE
98FORCE: ;