]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - scripts/Makefile.headersinst
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
[mirror_ubuntu-zesty-kernel.git] / scripts / Makefile.headersinst
CommitLineData
8d730cfb
DW
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
07aea3a7 10UNIFDEF := scripts/unifdef -U__KERNEL__
8d730cfb
DW
11
12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \
c0519037
MF
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" \
8d730cfb
DW
21 -e "s/[[:space:]]__attribute_const__$$//" \
22 -e "/^\#include <linux\/compiler.h>/d"
23
24_dst := $(if $(dst),$(dst),$(obj))
25
8d730cfb
DW
26ifeq (,$(patsubst include/asm/%,,$(obj)/))
27# For producing the generated stuff in include/asm for biarch builds, include
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
de789125 31# use $(wildcard...).
8d730cfb
DW
32GENASM := 1
33archasm := $(subst include/asm,asm-$(ARCH),$(obj))
34altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
de789125 35KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild)
8d730cfb 36else
de789125 37KBUILDFILES := $(srctree)/$(obj)/Kbuild
8d730cfb
DW
38endif
39
de789125
DW
40include $(KBUILDFILES)
41
42include scripts/Kbuild.include
8d730cfb
DW
43
44# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then
45# override $(_dst) so that we install to include/asm directly.
de789125
DW
46# Unless $(BIASMDIR) is set, in which case we're probably doing
47# a 'headers_install_all' build and we should keep the -$(ARCH)
48# in the directory name.
49ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR))
8d730cfb
DW
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
de789125
DW
59# stamp files for header checks
60check-y := $(patsubst %,.check.%,$(header-y) $(unifdef-y) $(objhdr-y))
61
62# Work out what needs to be removed
63oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h))
64unwanted := $(filter-out $(header-y) $(unifdef-y) $(objhdr-y),$(oldheaders))
65
66oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h))
67unwanted += $(filter-out $(check-y),$(oldcheckstamps))
68
69# Prefix them all with full paths to $(INSTALL_HDR_PATH)
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
75
8d730cfb
DW
76ifdef ALTARCH
77ifeq ($(obj),include/asm-$(ARCH))
78altarch-y := altarch-dir
79endif
80endif
81
82# Make the definitions visible for recursive make invocations
83export ALTARCH
84export ARCHDEF
85export ALTARCHDEF
86
de789125
DW
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)
8d730cfb 90
de789125
DW
91quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
92 cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
93 > $@
8d730cfb 94
de789125
DW
95quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
96 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
97 | $(HDRSED) > $@ || :
8d730cfb 98
de789125 99quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
4e776b1d 100 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
de789125
DW
101 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
102
103quiet_cmd_remove = REMOVE $(_dst)/$@
104 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
68475359 105
de789125
DW
106quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
107 cmd_mkdir = mkdir -p $@
8d730cfb 108
de789125 109quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
8d730cfb 110 cmd_gen = \
0db19c41 111FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@); \
ec268be3 112STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \
8d730cfb
DW
113(echo "/* File autogenerated by 'make headers_install' */" ; \
114echo "\#ifndef $$STUBDEF" ; \
115echo "\#define $$STUBDEF" ; \
116echo "\# if $(ARCHDEF)" ; \
de789125
DW
117if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \
118 echo "\# include <$(archasm)/$$FNAME>" ; \
8d730cfb 119else \
de789125 120 echo "\# error $(archasm)/$$FNAME does not exist in" \
8d730cfb
DW
121 "the $(ARCH) architecture" ; \
122fi ; \
123echo "\# elif $(ALTARCHDEF)" ; \
de789125
DW
124if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \
125 echo "\# include <$(altarchasm)/$$FNAME>" ; \
8d730cfb 126else \
de789125 127 echo "\# error $(altarchasm)/$$FNAME does not exist in" \
8d730cfb
DW
128 "the $(ALTARCH) architecture" ; \
129fi ; \
130echo "\# else" ; \
131echo "\# warning This machine appears to be" \
132 "neither $(ARCH) nor $(ALTARCH)." ; \
133echo "\# endif" ; \
134echo "\#endif /* $$STUBDEF */" ; \
de789125 135) > $@
8d730cfb 136
de789125 137.PHONY: __headersinst __headerscheck
8d730cfb 138
68475359 139ifdef HDRCHECK
de789125
DW
140__headerscheck: $(subdir-y) $(check-y)
141 @true
142
143$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h
68475359 144 $(call cmd,check)
de789125
DW
145
146# Other dependencies for $(check-y)
df5f6311 147include /dev/null $(wildcard $(check-y))
de789125
DW
148
149# ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
150.PHONY: $(check-y)
151
68475359 152else
8d730cfb 153# Rules for installing headers
de789125
DW
154__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
155 @true
8d730cfb 156
de789125 157$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted)
8d730cfb 158
de789125 159$(INSTALL_HDR_PATH)/$(_dst):
8d730cfb
DW
160 $(call cmd,mkdir)
161
de789125
DW
162.PHONY: $(unwanted)
163$(unwanted):
164 $(call cmd,remove)
165
8d730cfb 166ifdef GENASM
de789125 167$(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES)
8d730cfb
DW
168 $(call cmd,gen)
169
170else
308ba5fc 171$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(KBUILDFILES)
8d730cfb
DW
172 $(call cmd,o_hdr_install)
173
de789125 174$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
8d730cfb
DW
175 $(call cmd,headers_install)
176
de789125 177$(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
8d730cfb
DW
178 $(call cmd,unifdef)
179endif
68475359 180endif
8d730cfb
DW
181
182hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
183
184.PHONY: altarch-dir
b5122177
DW
185# All the files in the normal arch dir must be created first, since we test
186# for their existence.
187altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y)
8d730cfb 188 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
de789125 189 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR)
8d730cfb
DW
190
191# Recursion
de789125 192.PHONY: $(subdir-y)
8d730cfb
DW
193$(subdir-y):
194 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)