Blame view
scripts/Makefile.headersinst
3.2 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 |
|
7712401ae
|
27 28 29 30 31 |
# all headers files for this dir all-files := $(header-y) $(objhdr-y) input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) output-files := $(addprefix $(install)/, $(all-files)) |
de7891258
|
32 |
|
7712401ae
|
33 34 35 |
# Work out what needs to be removed oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) unwanted := $(filter-out $(all-files),$(oldheaders)) |
8d730cfb5
|
36 |
|
7712401ae
|
37 38 |
# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) unwanted-file := $(addprefix $(install)/, $(unwanted)) |
de7891258
|
39 |
|
7712401ae
|
40 |
printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
684753599
|
41 |
|
7712401ae
|
42 43 |
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) |
db1bec4f5
|
44 45 46 47 |
cmd_install = \ $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ touch $@ |
8d730cfb5
|
48 |
|
7712401ae
|
49 50 |
quiet_cmd_remove = REMOVE $(unwanted) cmd_remove = rm -f $(unwanted-file) |
8d730cfb5
|
51 |
|
7712401ae
|
52 |
quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
7211b8b90
|
53 54 55 56 57 58 |
# 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
|
59 |
touch $@ |
de7891258
|
60 |
|
7712401ae
|
61 |
PHONY += __headersinst __headerscheck |
de7891258
|
62 |
|
7712401ae
|
63 64 65 66 |
ifndef HDRCHECK # Rules for installing headers __headersinst: $(subdirs) $(install-file) @: |
de7891258
|
67 |
|
7712401ae
|
68 69 70 71 72 |
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
|
73 |
|
684753599
|
74 |
else |
7712401ae
|
75 76 |
__headerscheck: $(subdirs) $(check-file) @: |
8d730cfb5
|
77 |
|
7712401ae
|
78 79 80 |
targets += $(check-file) $(check-file): scripts/headers_check.pl $(output-files) FORCE $(call if_changed,check) |
8d730cfb5
|
81 |
|
7712401ae
|
82 |
endif |
de7891258
|
83 |
|
7712401ae
|
84 85 86 87 88 |
# Recursion hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj .PHONY: $(subdirs) $(subdirs): $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ |
8d730cfb5
|
89 |
|
7712401ae
|
90 91 92 |
targets := $(wildcard $(sort $(targets))) cmd_files := $(wildcard \ $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
4e420aa94
|
93 |
|
7712401ae
|
94 95 |
ifneq ($(cmd_files),) include $(cmd_files) |
8d730cfb5
|
96 |
endif |
7712401ae
|
97 98 99 |
.PHONY: $(PHONY) PHONY += FORCE FORCE: ; |