Blame view
scripts/Makefile.headersinst
3.97 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 |
7712401ae kbuild: optimize ... |
6 |
# objhdr-y - Same as header-y but for generated files |
cb97914b0 kbuild: Add suppo... |
7 |
# genhdr-y - Same as objhdr-y but in a generated/ directory |
8d730cfb5 Basic implementat... |
8 9 |
# # ========================================================================== |
7712401ae kbuild: optimize ... |
10 |
# called may set destination dir (when installing to asm/) |
8d730cfb5 Basic implementat... |
11 |
_dst := $(if $(dst),$(dst),$(obj)) |
cb97914b0 kbuild: Add suppo... |
12 13 |
# generated header directory gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) |
283039fb7 kbuild: drop supp... |
14 15 |
kbuild-file := $(srctree)/$(obj)/Kbuild include $(kbuild-file) |
8d730cfb5 Basic implementat... |
16 |
|
c7bb349e7 kbuild: introduce... |
17 |
_dst := $(if $(destination-y),$(destination-y),$(_dst)) |
283039fb7 kbuild: drop supp... |
18 |
include scripts/Kbuild.include |
de7891258 Use dependencies ... |
19 |
|
7712401ae kbuild: optimize ... |
20 |
install := $(INSTALL_HDR_PATH)/$(_dst) |
8d730cfb5 Basic implementat... |
21 |
|
7cfddeef3 kbuild: drop unif... |
22 |
header-y := $(sort $(header-y)) |
7712401ae kbuild: optimize ... |
23 24 |
subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) header-y := $(filter-out %/, $(header-y)) |
de7891258 Use dependencies ... |
25 |
|
7712401ae kbuild: optimize ... |
26 27 28 |
# files used to track state of install/check install-file := $(install)/.install check-file := $(install)/.check |
de7891258 Use dependencies ... |
29 |
|
d8ecc5cd8 kbuild: asm-gener... |
30 31 32 |
# 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)) |
7712401ae kbuild: optimize ... |
33 |
# all headers files for this dir |
d8ecc5cd8 kbuild: asm-gener... |
34 |
header-y := $(filter-out $(generic-y), $(header-y)) |
cb97914b0 kbuild: Add suppo... |
35 |
all-files := $(header-y) $(objhdr-y) $(genhdr-y) $(wrapper-files) |
7712401ae kbuild: optimize ... |
36 |
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ |
cb97914b0 kbuild: Add suppo... |
37 38 |
$(addprefix $(objtree)/$(obj)/,$(objhdr-y)) \ $(addprefix $(objtree)/$(gen)/,$(genhdr-y)) |
7712401ae kbuild: optimize ... |
39 |
output-files := $(addprefix $(install)/, $(all-files)) |
de7891258 Use dependencies ... |
40 |
|
7712401ae kbuild: optimize ... |
41 42 43 |
# Work out what needs to be removed oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) unwanted := $(filter-out $(all-files),$(oldheaders)) |
8d730cfb5 Basic implementat... |
44 |
|
7712401ae kbuild: optimize ... |
45 46 |
# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) unwanted-file := $(addprefix $(install)/, $(unwanted)) |
de7891258 Use dependencies ... |
47 |
|
7712401ae kbuild: optimize ... |
48 |
printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
684753599 Basic implementat... |
49 |
|
7712401ae kbuild: optimize ... |
50 51 |
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) |
db1bec4f5 kbuild: install a... |
52 53 54 |
cmd_install = \ $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ |
cb97914b0 kbuild: Add suppo... |
55 |
$(PERL) $< $(objtree)/$(gen) $(install) $(SRCARCH) $(genhdr-y); \ |
d8ecc5cd8 kbuild: asm-gener... |
56 57 58 |
for F in $(wrapper-files); do \ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \ done; \ |
db1bec4f5 kbuild: install a... |
59 |
touch $@ |
8d730cfb5 Basic implementat... |
60 |
|
7712401ae kbuild: optimize ... |
61 62 |
quiet_cmd_remove = REMOVE $(unwanted) cmd_remove = rm -f $(unwanted-file) |
8d730cfb5 Basic implementat... |
63 |
|
7712401ae kbuild: optimize ... |
64 |
quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
7211b8b90 kbuild: fix "Argu... |
65 66 67 68 69 70 |
# Headers list can be pretty long, xargs helps to avoid # the "Argument list too long" error. cmd_check = for f in $(all-files); do \ echo "$(install)/$${f}"; done \ | xargs \ $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ |
7712401ae kbuild: optimize ... |
71 |
touch $@ |
de7891258 Use dependencies ... |
72 |
|
7712401ae kbuild: optimize ... |
73 |
PHONY += __headersinst __headerscheck |
de7891258 Use dependencies ... |
74 |
|
7712401ae kbuild: optimize ... |
75 76 77 78 |
ifndef HDRCHECK # Rules for installing headers __headersinst: $(subdirs) $(install-file) @: |
de7891258 Use dependencies ... |
79 |
|
7712401ae kbuild: optimize ... |
80 81 82 83 84 |
targets += $(install-file) $(install-file): scripts/headers_install.pl $(input-files) FORCE $(if $(unwanted),$(call cmd,remove),) $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) $(call if_changed,install) |
de7891258 Use dependencies ... |
85 |
|
684753599 Basic implementat... |
86 |
else |
7712401ae kbuild: optimize ... |
87 88 |
__headerscheck: $(subdirs) $(check-file) @: |
8d730cfb5 Basic implementat... |
89 |
|
7712401ae kbuild: optimize ... |
90 91 92 |
targets += $(check-file) $(check-file): scripts/headers_check.pl $(output-files) FORCE $(call if_changed,check) |
8d730cfb5 Basic implementat... |
93 |
|
7712401ae kbuild: optimize ... |
94 |
endif |
de7891258 Use dependencies ... |
95 |
|
7712401ae kbuild: optimize ... |
96 97 98 99 100 |
# Recursion hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj .PHONY: $(subdirs) $(subdirs): $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ |
8d730cfb5 Basic implementat... |
101 |
|
7712401ae kbuild: optimize ... |
102 103 104 |
targets := $(wildcard $(sort $(targets))) cmd_files := $(wildcard \ $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
4e420aa94 kbuild: always un... |
105 |
|
7712401ae kbuild: optimize ... |
106 107 |
ifneq ($(cmd_files),) include $(cmd_files) |
8d730cfb5 Basic implementat... |
108 |
endif |
7712401ae kbuild: optimize ... |
109 110 111 |
.PHONY: $(PHONY) PHONY += FORCE FORCE: ; |