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