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