Blame view
scripts/Makefile.headersinst
4.65 KB
8d730cfb5
|
1 2 3 |
# ========================================================================== # Installing headers # |
7712401ae
|
4 5 |
# header-y - list files to be installed. They are preprocessed # to remove __KERNEL__ section of the file |
40f1d4c20
|
6 |
# genhdr-y - Same as header-y but in a generated/ directory |
8d730cfb5
|
7 8 |
# # ========================================================================== |
cb97914b0
|
9 10 |
# generated header directory gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) |
283039fb7
|
11 12 |
kbuild-file := $(srctree)/$(obj)/Kbuild include $(kbuild-file) |
8d730cfb5
|
13 |
|
9b58b9281
|
14 |
# called may set destination dir (when installing to asm/) |
c4619bc6f
|
15 |
_dst := $(if $(destination-y),$(destination-y),$(if $(dst),$(dst),$(obj))) |
9b58b9281
|
16 |
|
10b63956f
|
17 18 19 20 |
old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild ifneq ($(wildcard $(old-kbuild-file)),) include $(old-kbuild-file) endif |
c7bb349e7
|
21 |
|
283039fb7
|
22 |
include scripts/Kbuild.include |
de7891258
|
23 |
|
10b63956f
|
24 |
installdir := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst)) |
8d730cfb5
|
25 |
|
7cfddeef3
|
26 |
header-y := $(sort $(header-y)) |
7712401ae
|
27 28 |
subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) header-y := $(filter-out %/, $(header-y)) |
de7891258
|
29 |
|
7712401ae
|
30 |
# files used to track state of install/check |
10b63956f
|
31 32 |
install-file := $(installdir)/.install check-file := $(installdir)/.check |
de7891258
|
33 |
|
d8ecc5cd8
|
34 35 36 |
# generic-y list all files an architecture uses from asm-generic # Use this to build a list of headers which require a wrapper wrapper-files := $(filter $(header-y), $(generic-y)) |
10b63956f
|
37 38 39 40 |
srcdir := $(srctree)/$(obj) gendir := $(objtree)/$(gen) oldsrcdir := $(srctree)/$(subst /uapi,,$(obj)) |
7712401ae
|
41 |
# all headers files for this dir |
d8ecc5cd8
|
42 |
header-y := $(filter-out $(generic-y), $(header-y)) |
40f1d4c20
|
43 |
all-files := $(header-y) $(genhdr-y) $(wrapper-files) |
10b63956f
|
44 |
output-files := $(addprefix $(installdir)/, $(all-files)) |
c0ff68f16
|
45 |
input-files1 := $(foreach hdr, $(header-y), \ |
c4619bc6f
|
46 |
$(if $(wildcard $(srcdir)/$(hdr)), \ |
c0ff68f16
|
47 48 49 50 51 |
$(wildcard $(srcdir)/$(hdr))) \ ) input-files1-name := $(notdir $(input-files1)) input-files2 := $(foreach hdr, $(header-y), \ $(if $(wildcard $(srcdir)/$(hdr)),, \ |
c4619bc6f
|
52 53 54 |
$(if $(wildcard $(oldsrcdir)/$(hdr)), \ $(wildcard $(oldsrcdir)/$(hdr)), \ $(error Missing UAPI file $(srcdir)/$(hdr))) \ |
c0ff68f16
|
55 56 57 |
)) input-files2-name := $(notdir $(input-files2)) input-files3 := $(foreach hdr, $(genhdr-y), \ |
c4619bc6f
|
58 |
$(if $(wildcard $(gendir)/$(hdr)), \ |
10b63956f
|
59 60 61 |
$(wildcard $(gendir)/$(hdr)), \ $(error Missing generated UAPI file $(gendir)/$(hdr)) \ )) |
c0ff68f16
|
62 |
input-files3-name := $(notdir $(input-files3)) |
de7891258
|
63 |
|
7712401ae
|
64 |
# Work out what needs to be removed |
10b63956f
|
65 |
oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) |
7712401ae
|
66 |
unwanted := $(filter-out $(all-files),$(oldheaders)) |
8d730cfb5
|
67 |
|
7712401ae
|
68 |
# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
10b63956f
|
69 |
unwanted-file := $(addprefix $(installdir)/, $(unwanted)) |
de7891258
|
70 |
|
7712401ae
|
71 |
printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
684753599
|
72 |
|
7712401ae
|
73 74 |
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) |
db1bec4f5
|
75 |
cmd_install = \ |
c0ff68f16
|
76 77 78 |
$(CONFIG_SHELL) $< $(installdir) $(srcdir) $(input-files1-name); \ $(CONFIG_SHELL) $< $(installdir) $(oldsrcdir) $(input-files2-name); \ $(CONFIG_SHELL) $< $(installdir) $(gendir) $(input-files3-name); \ |
d8ecc5cd8
|
79 |
for F in $(wrapper-files); do \ |
10b63956f
|
80 |
echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ |
d8ecc5cd8
|
81 |
done; \ |
db1bec4f5
|
82 |
touch $@ |
8d730cfb5
|
83 |
|
7712401ae
|
84 85 |
quiet_cmd_remove = REMOVE $(unwanted) cmd_remove = rm -f $(unwanted-file) |
8d730cfb5
|
86 |
|
7712401ae
|
87 |
quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
7211b8b90
|
88 89 90 |
# Headers list can be pretty long, xargs helps to avoid # the "Argument list too long" error. cmd_check = for f in $(all-files); do \ |
10b63956f
|
91 |
echo "$(installdir)/$${f}"; done \ |
7211b8b90
|
92 93 |
| xargs \ $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ |
7712401ae
|
94 |
touch $@ |
de7891258
|
95 |
|
7712401ae
|
96 |
PHONY += __headersinst __headerscheck |
de7891258
|
97 |
|
7712401ae
|
98 99 100 101 |
ifndef HDRCHECK # Rules for installing headers __headersinst: $(subdirs) $(install-file) @: |
de7891258
|
102 |
|
7712401ae
|
103 |
targets += $(install-file) |
c0ff68f16
|
104 |
$(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE |
7712401ae
|
105 106 107 |
$(if $(unwanted),$(call cmd,remove),) $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) $(call if_changed,install) |
de7891258
|
108 |
|
684753599
|
109 |
else |
7712401ae
|
110 111 |
__headerscheck: $(subdirs) $(check-file) @: |
8d730cfb5
|
112 |
|
7712401ae
|
113 114 115 |
targets += $(check-file) $(check-file): scripts/headers_check.pl $(output-files) FORCE $(call if_changed,check) |
8d730cfb5
|
116 |
|
7712401ae
|
117 |
endif |
de7891258
|
118 |
|
7712401ae
|
119 |
# Recursion |
7712401ae
|
120 121 122 |
.PHONY: $(subdirs) $(subdirs): $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ |
8d730cfb5
|
123 |
|
7712401ae
|
124 125 126 |
targets := $(wildcard $(sort $(targets))) cmd_files := $(wildcard \ $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
4e420aa94
|
127 |
|
7712401ae
|
128 129 |
ifneq ($(cmd_files),) include $(cmd_files) |
8d730cfb5
|
130 |
endif |
7712401ae
|
131 132 133 |
.PHONY: $(PHONY) PHONY += FORCE FORCE: ; |