ACPI: constify tables in pci_irq.c
[linux-block.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
6# unifdef-y - Same as header-y. Obsolete
7# objhdr-y - Same as header-y but for generated files
8d730cfb
DW
8#
9# ==========================================================================
10
7712401a 11# called may set destination dir (when installing to asm/)
8d730cfb
DW
12_dst := $(if $(dst),$(dst),$(obj))
13
283039fb
SR
14kbuild-file := $(srctree)/$(obj)/Kbuild
15include $(kbuild-file)
8d730cfb 16
283039fb 17include scripts/Kbuild.include
de789125 18
7712401a 19install := $(INSTALL_HDR_PATH)/$(_dst)
8d730cfb 20
7712401a
SR
21header-y := $(sort $(header-y) $(unifdef-y))
22subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
23header-y := $(filter-out %/, $(header-y))
de789125 24
7712401a
SR
25# files used to track state of install/check
26install-file := $(install)/.install
27check-file := $(install)/.check
de789125 28
7712401a
SR
29# all headers files for this dir
30all-files := $(header-y) $(objhdr-y)
31input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
32 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
33output-files := $(addprefix $(install)/, $(all-files))
de789125 34
7712401a
SR
35# Work out what needs to be removed
36oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
37unwanted := $(filter-out $(all-files),$(oldheaders))
8d730cfb 38
7712401a
SR
39# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
40unwanted-file := $(addprefix $(install)/, $(unwanted))
de789125 41
7712401a 42printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
68475359 43
7712401a
SR
44quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
45 file$(if $(word 2, $(all-files)),s))
db1bec4f
SR
46 cmd_install = \
47 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
48 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
49 touch $@
8d730cfb 50
7712401a
SR
51quiet_cmd_remove = REMOVE $(unwanted)
52 cmd_remove = rm -f $(unwanted-file)
8d730cfb 53
7712401a
SR
54quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
55 cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \
56 $(addprefix $(install)/, $(all-files)); \
57 touch $@
de789125 58
7712401a 59PHONY += __headersinst __headerscheck
de789125 60
7712401a
SR
61ifndef HDRCHECK
62# Rules for installing headers
63__headersinst: $(subdirs) $(install-file)
64 @:
de789125 65
7712401a
SR
66targets += $(install-file)
67$(install-file): scripts/headers_install.pl $(input-files) FORCE
68 $(if $(unwanted),$(call cmd,remove),)
69 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
70 $(call if_changed,install)
de789125 71
68475359 72else
7712401a
SR
73__headerscheck: $(subdirs) $(check-file)
74 @:
8d730cfb 75
7712401a
SR
76targets += $(check-file)
77$(check-file): scripts/headers_check.pl $(output-files) FORCE
78 $(call if_changed,check)
8d730cfb 79
7712401a 80endif
de789125 81
7712401a
SR
82# Recursion
83hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
84.PHONY: $(subdirs)
85$(subdirs):
86 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
8d730cfb 87
7712401a
SR
88targets := $(wildcard $(sort $(targets)))
89cmd_files := $(wildcard \
90 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
4e420aa9 91
7712401a
SR
92ifneq ($(cmd_files),)
93 include $(cmd_files)
8d730cfb
DW
94endif
95
7712401a
SR
96.PHONY: $(PHONY)
97PHONY += FORCE
98FORCE: ;