Blame view
scripts/Makefile.headersinst
3.26 KB
8d730cfb5 Basic implementat... |
1 2 3 |
# ========================================================================== # Installing headers # |
7712401ae kbuild: optimize ... |
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 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)) |
283039fb7 kbuild: drop supp... |
12 13 |
kbuild-file := $(srctree)/$(obj)/Kbuild include $(kbuild-file) |
8d730cfb5 Basic implementat... |
14 |
|
c7bb349e7 kbuild: introduce... |
15 |
_dst := $(if $(destination-y),$(destination-y),$(_dst)) |
283039fb7 kbuild: drop supp... |
16 |
include scripts/Kbuild.include |
de7891258 Use dependencies ... |
17 |
|
7712401ae kbuild: optimize ... |
18 |
install := $(INSTALL_HDR_PATH)/$(_dst) |
8d730cfb5 Basic implementat... |
19 |
|
7712401ae kbuild: optimize ... |
20 21 22 |
header-y := $(sort $(header-y) $(unifdef-y)) subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) header-y := $(filter-out %/, $(header-y)) |
de7891258 Use dependencies ... |
23 |
|
7712401ae kbuild: optimize ... |
24 25 26 |
# files used to track state of install/check install-file := $(install)/.install check-file := $(install)/.check |
de7891258 Use dependencies ... |
27 |
|
7712401ae kbuild: optimize ... |
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 Use dependencies ... |
33 |
|
7712401ae kbuild: optimize ... |
34 35 36 |
# Work out what needs to be removed oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) unwanted := $(filter-out $(all-files),$(oldheaders)) |
8d730cfb5 Basic implementat... |
37 |
|
7712401ae kbuild: optimize ... |
38 39 |
# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) unwanted-file := $(addprefix $(install)/, $(unwanted)) |
de7891258 Use dependencies ... |
40 |
|
7712401ae kbuild: optimize ... |
41 |
printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
684753599 Basic implementat... |
42 |
|
7712401ae kbuild: optimize ... |
43 44 |
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) |
db1bec4f5 kbuild: install a... |
45 46 47 48 |
cmd_install = \ $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ touch $@ |
8d730cfb5 Basic implementat... |
49 |
|
7712401ae kbuild: optimize ... |
50 51 |
quiet_cmd_remove = REMOVE $(unwanted) cmd_remove = rm -f $(unwanted-file) |
8d730cfb5 Basic implementat... |
52 |
|
7712401ae kbuild: optimize ... |
53 |
quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
7211b8b90 kbuild: fix "Argu... |
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 kbuild: optimize ... |
60 |
touch $@ |
de7891258 Use dependencies ... |
61 |
|
7712401ae kbuild: optimize ... |
62 |
PHONY += __headersinst __headerscheck |
de7891258 Use dependencies ... |
63 |
|
7712401ae kbuild: optimize ... |
64 65 66 67 |
ifndef HDRCHECK # Rules for installing headers __headersinst: $(subdirs) $(install-file) @: |
de7891258 Use dependencies ... |
68 |
|
7712401ae kbuild: optimize ... |
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 Use dependencies ... |
74 |
|
684753599 Basic implementat... |
75 |
else |
7712401ae kbuild: optimize ... |
76 77 |
__headerscheck: $(subdirs) $(check-file) @: |
8d730cfb5 Basic implementat... |
78 |
|
7712401ae kbuild: optimize ... |
79 80 81 |
targets += $(check-file) $(check-file): scripts/headers_check.pl $(output-files) FORCE $(call if_changed,check) |
8d730cfb5 Basic implementat... |
82 |
|
7712401ae kbuild: optimize ... |
83 |
endif |
de7891258 Use dependencies ... |
84 |
|
7712401ae kbuild: optimize ... |
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 Basic implementat... |
90 |
|
7712401ae kbuild: optimize ... |
91 92 93 |
targets := $(wildcard $(sort $(targets))) cmd_files := $(wildcard \ $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
4e420aa94 kbuild: always un... |
94 |
|
7712401ae kbuild: optimize ... |
95 96 |
ifneq ($(cmd_files),) include $(cmd_files) |
8d730cfb5 Basic implementat... |
97 |
endif |
7712401ae kbuild: optimize ... |
98 99 100 |
.PHONY: $(PHONY) PHONY += FORCE FORCE: ; |