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