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