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 := scripts/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:]]\{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"
24 _dst := $(if $(dst),$(dst),$(obj))
26 kbuild-file := $(srctree)/$(obj)/Kbuild
27 include $(kbuild-file)
29 include scripts/Kbuild.include
31 # If this is include/asm-$(ARCH) then override $(_dst) so that
32 # we install to include/asm directly.
33 # Unless $(BIASMDIR) is set, in which case we're probably doing
34 # a 'headers_install_all' build and we should keep the -$(ARCH)
35 # in the directory name.
36 ifeq ($(obj),include/asm-$(ARCH)$(BIASMDIR))
40 header-y := $(sort $(header-y) $(unifdef-y))
41 subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
42 header-y := $(filter-out %/, $(header-y))
44 # stamp files for header checks
45 check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y))
47 # Work out what needs to be removed
48 oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h))
49 unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders))
51 oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h))
52 unwanted += $(filter-out $(check-y),$(oldcheckstamps))
54 # Prefix them all with full paths to $(INSTALL_HDR_PATH)
55 header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y))
56 objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y))
57 check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y))
59 quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
60 cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \
61 $(INSTALL_HDR_PATH)/$(_dst)
63 quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
64 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
67 quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
68 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
69 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
71 quiet_cmd_remove = REMOVE $(_dst)/$@
72 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
74 quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
75 cmd_mkdir = mkdir -p $@
77 .PHONY: __headersinst __headerscheck
80 __headerscheck: $(subdir-y) $(check-y)
83 $(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h
86 # Other dependencies for $(check-y)
87 include /dev/null $(wildcard $(check-y))
89 # ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
93 # Rules for installing headers
94 __headersinst: $(subdir-y) $(header-y) $(objhdr-y)
97 $(objhdr-y) $(subdir-y) $(header-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted)
99 $(INSTALL_HDR_PATH)/$(_dst):
106 $(objhdr-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file)
107 $(call cmd,o_hdr_install)
109 $(header-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file)
114 hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
119 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)