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