1 # ==========================================================================
4 # header-y - list files to be installed. They are preprocessed
5 # to remove __KERNEL__ section of the file
6 # unifdef-y - Same as header-y. Obsolete
7 # objhdr-y - Same as header-y but for generated files
9 # ==========================================================================
11 # called may set destination dir (when installing to asm/)
12 _dst := $(if $(dst),$(dst),$(obj))
14 kbuild-file := $(srctree)/$(obj)/Kbuild
15 include $(kbuild-file)
17 _dst := $(if $(destination-y),$(destination-y),$(_dst))
19 include scripts/Kbuild.include
21 install := $(INSTALL_HDR_PATH)/$(_dst)
23 header-y := $(sort $(header-y) $(unifdef-y))
24 subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
25 header-y := $(filter-out %/, $(header-y))
27 # files used to track state of install/check
28 install-file := $(install)/.install
29 check-file := $(install)/.check
31 # all headers files for this dir
32 all-files := $(header-y) $(objhdr-y)
33 input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
34 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
35 output-files := $(addprefix $(install)/, $(all-files))
37 # Work out what needs to be removed
38 oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
39 unwanted := $(filter-out $(all-files),$(oldheaders))
41 # Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
42 unwanted-file := $(addprefix $(install)/, $(unwanted))
44 printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
46 quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
47 file$(if $(word 2, $(all-files)),s))
49 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
50 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
53 quiet_cmd_remove = REMOVE $(unwanted)
54 cmd_remove = rm -f $(unwanted-file)
56 quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
57 cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \
58 $(addprefix $(install)/, $(all-files)); \
61 PHONY += __headersinst __headerscheck
64 # Rules for installing headers
65 __headersinst: $(subdirs) $(install-file)
68 targets += $(install-file)
69 $(install-file): scripts/headers_install.pl $(input-files) FORCE
70 $(if $(unwanted),$(call cmd,remove),)
71 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
72 $(call if_changed,install)
75 __headerscheck: $(subdirs) $(check-file)
78 targets += $(check-file)
79 $(check-file): scripts/headers_check.pl $(output-files) FORCE
80 $(call if_changed,check)
85 hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
88 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
90 targets := $(wildcard $(sort $(targets)))
91 cmd_files := $(wildcard \
92 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))