1 # ==========================================================================
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
8 # ==========================================================================
10 UNIFDEF := unifdef -U__KERNEL__
12 # Eliminate the contents of (and inclusions of) compiler.h
13 HDRSED := 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"
24 _dst := $(if $(dst),$(dst),$(obj))
30 ifeq (,$(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
37 archasm := $(subst include/asm,asm-$(ARCH),$(obj))
38 altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
39 -include $(srctree)/include/$(archasm)/Kbuild
40 -include $(srctree)/include/$(altarchasm)/Kbuild
42 include $(srctree)/$(obj)/Kbuild
45 include scripts/Kbuild.include
47 # If this is include/asm-$(ARCH) and there's no $(ALTARCH), then
48 # override $(_dst) so that we install to include/asm directly.
49 ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH))
53 header-y := $(sort $(header-y))
54 unifdef-y := $(sort $(unifdef-y))
55 subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
56 header-y := $(filter-out %/, $(header-y))
57 header-y := $(filter-out $(unifdef-y),$(header-y))
60 ifeq ($(obj),include/asm-$(ARCH))
61 altarch-y := altarch-dir
65 # Make the definitions visible for recursive make invocations
70 quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@
71 cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst)
73 quiet_cmd_headers_install = INSTALL $(_dst)/$@
74 cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \
75 > $(INSTALL_HDR_PATH)/$(_dst)/$@
77 quiet_cmd_unifdef = UNIFDEF $(_dst)/$@
78 cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \
79 > $(INSTALL_HDR_PATH)/$(_dst)/$@ || :
81 quiet_cmd_mkdir = MKDIR $@
82 cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@
84 quiet_cmd_gen = GEN $(_dst)/$@
86 STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \
87 (echo "/* File autogenerated by 'make headers_install' */" ; \
88 echo "\#ifndef $$STUBDEF" ; \
89 echo "\#define $$STUBDEF" ; \
90 echo "\# if $(ARCHDEF)" ; \
91 if [ -r $(srctree)/include/$(archasm)/$@ ]; then \
92 echo "\# include <$(archasm)/$@>" ; \
94 echo "\# error $(archasm)/$@ does not exist in" \
95 "the $(ARCH) architecture" ; \
97 echo "\# elif $(ALTARCHDEF)" ; \
98 if [ -r $(srctree)/include/$(altarchasm)/$@ ]; then \
99 echo "\# include <$(altarchasm)/$@>" ; \
101 echo "\# error $(altarchasm)/$@ does not exist in" \
102 "the $(ALTARCH) architecture" ; \
105 echo "\# warning This machine appears to be" \
106 "neither $(ARCH) nor $(ALTARCH)." ; \
108 echo "\#endif /* $$STUBDEF */" ; \
109 ) > $(INSTALL_HDR_PATH)/$(_dst)/$@
111 __headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
113 .PHONY: $(header-y) $(unifdef-y) $(subdir-y)
115 # Rules for installing headers
117 $(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst)
124 $(objhdr-y) $(header-y) $(unifdef-y):
129 $(call cmd,o_hdr_install)
132 $(call cmd,headers_install)
138 hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
142 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
143 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm
147 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)