]> bbs.cooldavid.org Git - net-next-2.6.git/blame - scripts/Makefile.headersinst
xps: Transmit Packet Steering
[net-next-2.6.git] / scripts / Makefile.headersinst
CommitLineData
8d730cfb
DW
1# ==========================================================================
2# Installing headers
3#
7712401a
SR
4# header-y - list files to be installed. They are preprocessed
5# to remove __KERNEL__ section of the file
7712401a 6# objhdr-y - Same as header-y but for generated files
8d730cfb
DW
7#
8# ==========================================================================
9
7712401a 10# called may set destination dir (when installing to asm/)
8d730cfb
DW
11_dst := $(if $(dst),$(dst),$(obj))
12
283039fb
SR
13kbuild-file := $(srctree)/$(obj)/Kbuild
14include $(kbuild-file)
8d730cfb 15
c7bb349e
SR
16_dst := $(if $(destination-y),$(destination-y),$(_dst))
17
283039fb 18include scripts/Kbuild.include
de789125 19
7712401a 20install := $(INSTALL_HDR_PATH)/$(_dst)
8d730cfb 21
7cfddeef 22header-y := $(sort $(header-y))
7712401a
SR
23subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
24header-y := $(filter-out %/, $(header-y))
de789125 25
7712401a
SR
26# files used to track state of install/check
27install-file := $(install)/.install
28check-file := $(install)/.check
de789125 29
7712401a
SR
30# all headers files for this dir
31all-files := $(header-y) $(objhdr-y)
32input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
33 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
34output-files := $(addprefix $(install)/, $(all-files))
de789125 35
7712401a
SR
36# Work out what needs to be removed
37oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
38unwanted := $(filter-out $(all-files),$(oldheaders))
8d730cfb 39
7712401a
SR
40# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
41unwanted-file := $(addprefix $(install)/, $(unwanted))
de789125 42
7712401a 43printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
68475359 44
7712401a
SR
45quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
46 file$(if $(word 2, $(all-files)),s))
db1bec4f
SR
47 cmd_install = \
48 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
49 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
50 touch $@
8d730cfb 51
7712401a
SR
52quiet_cmd_remove = REMOVE $(unwanted)
53 cmd_remove = rm -f $(unwanted-file)
8d730cfb 54
7712401a 55quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
7211b8b9
SP
56# Headers list can be pretty long, xargs helps to avoid
57# the "Argument list too long" error.
58 cmd_check = for f in $(all-files); do \
59 echo "$(install)/$${f}"; done \
60 | xargs \
61 $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \
7712401a 62 touch $@
de789125 63
7712401a 64PHONY += __headersinst __headerscheck
de789125 65
7712401a
SR
66ifndef HDRCHECK
67# Rules for installing headers
68__headersinst: $(subdirs) $(install-file)
69 @:
de789125 70
7712401a
SR
71targets += $(install-file)
72$(install-file): scripts/headers_install.pl $(input-files) FORCE
73 $(if $(unwanted),$(call cmd,remove),)
74 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
75 $(call if_changed,install)
de789125 76
68475359 77else
7712401a
SR
78__headerscheck: $(subdirs) $(check-file)
79 @:
8d730cfb 80
7712401a
SR
81targets += $(check-file)
82$(check-file): scripts/headers_check.pl $(output-files) FORCE
83 $(call if_changed,check)
8d730cfb 84
7712401a 85endif
de789125 86
7712401a
SR
87# Recursion
88hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
89.PHONY: $(subdirs)
90$(subdirs):
91 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
8d730cfb 92
7712401a
SR
93targets := $(wildcard $(sort $(targets)))
94cmd_files := $(wildcard \
95 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
4e420aa9 96
7712401a
SR
97ifneq ($(cmd_files),)
98 include $(cmd_files)
8d730cfb
DW
99endif
100
7712401a
SR
101.PHONY: $(PHONY)
102PHONY += FORCE
103FORCE: ;