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