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