]>
Commit | Line | Data |
---|---|---|
8d730cfb DW |
1 | # ========================================================================== |
2 | # Installing headers | |
3 | # | |
fcc8487d | 4 | # All headers under include/uapi, include/generated/uapi, |
61562f98 | 5 | # arch/<arch>/include/uapi and arch/<arch>/include/generated/uapi are |
fcc8487d ND |
6 | # exported. |
7 | # They are preprocessed to remove __KERNEL__ section of the file. | |
8d730cfb DW |
8 | # |
9 | # ========================================================================== | |
10 | ||
cb97914b PA |
11 | # generated header directory |
12 | gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) | |
13 | ||
fcc8487d | 14 | # Kbuild file is optional |
283039fb | 15 | kbuild-file := $(srctree)/$(obj)/Kbuild |
fcc8487d | 16 | -include $(kbuild-file) |
8d730cfb | 17 | |
9b58b928 | 18 | # called may set destination dir (when installing to asm/) |
bd73a328 | 19 | _dst := $(if $(dst),$(dst),$(obj)) |
9b58b928 | 20 | |
10b63956 DH |
21 | old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild |
22 | ifneq ($(wildcard $(old-kbuild-file)),) | |
23 | include $(old-kbuild-file) | |
24 | endif | |
c7bb349e | 25 | |
283039fb | 26 | include scripts/Kbuild.include |
de789125 | 27 | |
10b63956 | 28 | installdir := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst)) |
8d730cfb | 29 | |
fcc8487d ND |
30 | srcdir := $(srctree)/$(obj) |
31 | gendir := $(objtree)/$(gen) | |
32 | subdirs := $(patsubst $(srcdir)/%/.,%,$(wildcard $(srcdir)/*/.)) | |
fcc8487d ND |
33 | header-files := $(notdir $(wildcard $(srcdir)/*.h)) |
34 | header-files += $(notdir $(wildcard $(srcdir)/*.agh)) | |
35 | header-files := $(filter-out $(no-export-headers), $(header-files)) | |
36 | genhdr-files := $(notdir $(wildcard $(gendir)/*.h)) | |
37 | genhdr-files := $(filter-out $(header-files), $(genhdr-files)) | |
de789125 | 38 | |
7712401a | 39 | # files used to track state of install/check |
10b63956 DH |
40 | install-file := $(installdir)/.install |
41 | check-file := $(installdir)/.check | |
de789125 | 42 | |
d8ecc5cd SR |
43 | # generic-y list all files an architecture uses from asm-generic |
44 | # Use this to build a list of headers which require a wrapper | |
fcc8487d ND |
45 | generic-files := $(notdir $(wildcard $(srctree)/include/uapi/asm-generic/*.h)) |
46 | wrapper-files := $(filter $(generic-files), $(generic-y)) | |
47 | wrapper-files := $(filter-out $(header-files), $(wrapper-files)) | |
10b63956 | 48 | |
7712401a | 49 | # all headers files for this dir |
fcc8487d | 50 | all-files := $(header-files) $(genhdr-files) $(wrapper-files) |
10b63956 DH |
51 | output-files := $(addprefix $(installdir)/, $(all-files)) |
52 | ||
fcc8487d ND |
53 | ifneq ($(mandatory-y),) |
54 | missing := $(filter-out $(all-files),$(mandatory-y)) | |
55 | ifneq ($(missing),) | |
56 | $(error Some mandatory headers ($(missing)) are missing in $(obj)) | |
57 | endif | |
58 | endif | |
de789125 | 59 | |
7712401a | 60 | # Work out what needs to be removed |
10b63956 | 61 | oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) |
7712401a | 62 | unwanted := $(filter-out $(all-files),$(oldheaders)) |
8d730cfb | 63 | |
7712401a | 64 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
10b63956 | 65 | unwanted-file := $(addprefix $(installdir)/, $(unwanted)) |
de789125 | 66 | |
7712401a | 67 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
68475359 | 68 | |
7712401a SR |
69 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ |
70 | file$(if $(word 2, $(all-files)),s)) | |
db1bec4f | 71 | cmd_install = \ |
fcc8487d ND |
72 | $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(header-files); \ |
73 | $(CONFIG_SHELL) $< $(installdir) $(gendir) $(genhdr-files); \ | |
d8ecc5cd | 74 | for F in $(wrapper-files); do \ |
10b63956 | 75 | echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ |
d8ecc5cd | 76 | done; \ |
db1bec4f | 77 | touch $@ |
8d730cfb | 78 | |
7712401a SR |
79 | quiet_cmd_remove = REMOVE $(unwanted) |
80 | cmd_remove = rm -f $(unwanted-file) | |
8d730cfb | 81 | |
7712401a | 82 | quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
7211b8b9 SP |
83 | # Headers list can be pretty long, xargs helps to avoid |
84 | # the "Argument list too long" error. | |
85 | cmd_check = for f in $(all-files); do \ | |
10b63956 | 86 | echo "$(installdir)/$${f}"; done \ |
7211b8b9 SP |
87 | | xargs \ |
88 | $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ | |
7712401a | 89 | touch $@ |
de789125 | 90 | |
7712401a | 91 | PHONY += __headersinst __headerscheck |
de789125 | 92 | |
7712401a SR |
93 | ifndef HDRCHECK |
94 | # Rules for installing headers | |
95 | __headersinst: $(subdirs) $(install-file) | |
96 | @: | |
de789125 | 97 | |
7712401a | 98 | targets += $(install-file) |
7c025b2a | 99 | $(install-file): scripts/headers_install.sh \ |
fcc8487d ND |
100 | $(addprefix $(srcdir)/,$(header-files)) \ |
101 | $(addprefix $(gendir)/,$(genhdr-files)) FORCE | |
7712401a SR |
102 | $(if $(unwanted),$(call cmd,remove),) |
103 | $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) | |
104 | $(call if_changed,install) | |
de789125 | 105 | |
68475359 | 106 | else |
7712401a SR |
107 | __headerscheck: $(subdirs) $(check-file) |
108 | @: | |
8d730cfb | 109 | |
7712401a SR |
110 | targets += $(check-file) |
111 | $(check-file): scripts/headers_check.pl $(output-files) FORCE | |
112 | $(call if_changed,check) | |
8d730cfb | 113 | |
7712401a | 114 | endif |
de789125 | 115 | |
7712401a | 116 | # Recursion |
7712401a SR |
117 | .PHONY: $(subdirs) |
118 | $(subdirs): | |
119 | $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ | |
8d730cfb | 120 | |
7712401a SR |
121 | targets := $(wildcard $(sort $(targets))) |
122 | cmd_files := $(wildcard \ | |
123 | $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) | |
4e420aa9 | 124 | |
7712401a SR |
125 | ifneq ($(cmd_files),) |
126 | include $(cmd_files) | |
8d730cfb DW |
127 | endif |
128 | ||
7712401a SR |
129 | .PHONY: $(PHONY) |
130 | PHONY += FORCE | |
131 | FORCE: ; |