aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.headersinst
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Makefile.headersinst')
-rw-r--r--scripts/Makefile.headersinst124
1 files changed, 79 insertions, 45 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 12e1daf875c8..07004c41e30e 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -23,30 +23,30 @@ HDRSED := sed -e "s/ inline / __inline__ /g" \
23 23
24_dst := $(if $(dst),$(dst),$(obj)) 24_dst := $(if $(dst),$(dst),$(obj))
25 25
26.PHONY: __headersinst
27__headersinst:
28
29
30ifeq (,$(patsubst include/asm/%,,$(obj)/)) 26ifeq (,$(patsubst include/asm/%,,$(obj)/))
31# For producing the generated stuff in include/asm for biarch builds, include 27# 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 28# 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 29# _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 30# arch. Since some directories may exist in one but not the other, we must
35# use '-include'. 31# use $(wildcard...).
36GENASM := 1 32GENASM := 1
37archasm := $(subst include/asm,asm-$(ARCH),$(obj)) 33archasm := $(subst include/asm,asm-$(ARCH),$(obj))
38altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) 34altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
39-include $(srctree)/include/$(archasm)/Kbuild 35KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild)
40-include $(srctree)/include/$(altarchasm)/Kbuild
41else 36else
42include $(srctree)/$(obj)/Kbuild 37KBUILDFILES := $(srctree)/$(obj)/Kbuild
43endif 38endif
44 39
45include scripts/Kbuild.include 40include $(KBUILDFILES)
41
42include scripts/Kbuild.include
46 43
47# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then 44# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then
48# override $(_dst) so that we install to include/asm directly. 45# override $(_dst) so that we install to include/asm directly.
49ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)) 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))
50 _dst := include/asm 50 _dst := include/asm
51endif 51endif
52 52
@@ -56,6 +56,23 @@ subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
56header-y := $(filter-out %/, $(header-y)) 56header-y := $(filter-out %/, $(header-y))
57header-y := $(filter-out $(unifdef-y),$(header-y)) 57header-y := $(filter-out $(unifdef-y),$(header-y))
58 58
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
59ifdef ALTARCH 76ifdef ALTARCH
60ifeq ($(obj),include/asm-$(ARCH)) 77ifeq ($(obj),include/asm-$(ARCH))
61altarch-y := altarch-dir 78altarch-y := altarch-dir
@@ -67,43 +84,47 @@ export ALTARCH
67export ARCHDEF 84export ARCHDEF
68export ALTARCHDEF 85export ALTARCHDEF
69 86
70quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@ 87quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
71 cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst) 88 cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \
89 $(INSTALL_HDR_PATH)/$(_dst)
72 90
73quiet_cmd_headers_install = INSTALL $(_dst)/$@ 91quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
74 cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \ 92 cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
75 > $(INSTALL_HDR_PATH)/$(_dst)/$@ 93 > $@
76 94
77quiet_cmd_unifdef = UNIFDEF $(_dst)/$@ 95quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
78 cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \ 96 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
79 > $(INSTALL_HDR_PATH)/$(_dst)/$@ || : 97 | $(HDRSED) > $@ || :
80 98
81quiet_cmd_check = CHECK $(_dst)/$@ 99quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
82 cmd_check = $(srctree)/scripts/hdrcheck.sh \ 100 cmd_check = $(srctree)/scripts/hdrcheck.sh \
83 $(INSTALL_HDR_PATH)/include \ 101 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
84 $(INSTALL_HDR_PATH)/$(_dst)/$@ 102
103quiet_cmd_remove = REMOVE $(_dst)/$@
104 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
85 105
86quiet_cmd_mkdir = MKDIR $@ 106quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
87 cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@ 107 cmd_mkdir = mkdir -p $@
88 108
89quiet_cmd_gen = GEN $(_dst)/$@ 109quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
90 cmd_gen = \ 110 cmd_gen = \
91STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \ 111FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@) \
112STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z. A-Z_`; \
92(echo "/* File autogenerated by 'make headers_install' */" ; \ 113(echo "/* File autogenerated by 'make headers_install' */" ; \
93echo "\#ifndef $$STUBDEF" ; \ 114echo "\#ifndef $$STUBDEF" ; \
94echo "\#define $$STUBDEF" ; \ 115echo "\#define $$STUBDEF" ; \
95echo "\# if $(ARCHDEF)" ; \ 116echo "\# if $(ARCHDEF)" ; \
96if [ -r $(INSTALL_HDR_PATH)/include/$(archasm)/$@ ]; then \ 117if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \
97 echo "\# include <$(archasm)/$@>" ; \ 118 echo "\# include <$(archasm)/$$FNAME>" ; \
98else \ 119else \
99 echo "\# error $(archasm)/$@ does not exist in" \ 120 echo "\# error $(archasm)/$$FNAME does not exist in" \
100 "the $(ARCH) architecture" ; \ 121 "the $(ARCH) architecture" ; \
101fi ; \ 122fi ; \
102echo "\# elif $(ALTARCHDEF)" ; \ 123echo "\# elif $(ALTARCHDEF)" ; \
103if [ -r $(INSTALL_HDR_PATH)/include/$(altarchasm)/$@ ]; then \ 124if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \
104 echo "\# include <$(altarchasm)/$@>" ; \ 125 echo "\# include <$(altarchasm)/$$FNAME>" ; \
105else \ 126else \
106 echo "\# error $(altarchasm)/$@ does not exist in" \ 127 echo "\# error $(altarchasm)/$$FNAME does not exist in" \
107 "the $(ALTARCH) architecture" ; \ 128 "the $(ALTARCH) architecture" ; \
108fi ; \ 129fi ; \
109echo "\# else" ; \ 130echo "\# else" ; \
@@ -111,37 +132,49 @@ echo "\# warning This machine appears to be" \
111 "neither $(ARCH) nor $(ALTARCH)." ; \ 132 "neither $(ARCH) nor $(ALTARCH)." ; \
112echo "\# endif" ; \ 133echo "\# endif" ; \
113echo "\#endif /* $$STUBDEF */" ; \ 134echo "\#endif /* $$STUBDEF */" ; \
114) > $(INSTALL_HDR_PATH)/$(_dst)/$@ 135) > $@
115 136
116__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) 137.PHONY: __headersinst __headerscheck
117
118.PHONY: $(header-y) $(unifdef-y) $(subdir-y)
119 138
120ifdef HDRCHECK 139ifdef HDRCHECK
121# Rules for checking headers 140__headerscheck: $(subdir-y) $(check-y)
122$(objhdr-y) $(header-y) $(unifdef-y): 141 @true
142
143$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h
123 $(call cmd,check) 144 $(call cmd,check)
145
146# Other dependencies for $(check-y)
147-include /dev/null $(check-y)
148
149# ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
150.PHONY: $(check-y)
151
124else 152else
125# Rules for installing headers 153# Rules for installing headers
154__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
155 @true
126 156
127$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst) 157$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted)
128 158
129.PHONY: $(_dst) 159$(INSTALL_HDR_PATH)/$(_dst):
130$(_dst):
131 $(call cmd,mkdir) 160 $(call cmd,mkdir)
132 161
162.PHONY: $(unwanted)
163$(unwanted):
164 $(call cmd,remove)
165
133ifdef GENASM 166ifdef GENASM
134$(objhdr-y) $(header-y) $(unifdef-y): 167$(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES)
135 $(call cmd,gen) 168 $(call cmd,gen)
136 169
137else 170else
138$(objhdr-y): 171$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
139 $(call cmd,o_hdr_install) 172 $(call cmd,o_hdr_install)
140 173
141$(header-y): 174$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
142 $(call cmd,headers_install) 175 $(call cmd,headers_install)
143 176
144$(unifdef-y): 177$(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
145 $(call cmd,unifdef) 178 $(call cmd,unifdef)
146endif 179endif
147endif 180endif
@@ -153,8 +186,9 @@ hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
153# for their existence. 186# for their existence.
154altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y) 187altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y)
155 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) 188 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
156 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm 189 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR)
157 190
158# Recursion 191# Recursion
192.PHONY: $(subdir-y)
159$(subdir-y): 193$(subdir-y):
160 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) 194 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)