diff options
Diffstat (limited to 'scripts/Makefile.headersinst')
-rw-r--r-- | scripts/Makefile.headersinst | 145 |
1 files changed, 63 insertions, 82 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 599503f0e5f2..be2b70c48a3b 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
@@ -1,26 +1,14 @@ | |||
1 | # ========================================================================== | 1 | # ========================================================================== |
2 | # Installing headers | 2 | # Installing headers |
3 | # | 3 | # |
4 | # header-y files will be installed verbatim | 4 | # header-y - list files to be installed. They are preprocessed |
5 | # unifdef-y are the files where unifdef will be run before installing files | 5 | # to remove __KERNEL__ section of the file |
6 | # objhdr-y are generated files that will be installed verbatim | 6 | # unifdef-y - Same as header-y. Obsolete |
7 | # objhdr-y - Same as header-y but for generated files | ||
7 | # | 8 | # |
8 | # ========================================================================== | 9 | # ========================================================================== |
9 | 10 | ||
10 | UNIFDEF := scripts/unifdef -U__KERNEL__ | 11 | # called may set destination dir (when installing to asm/) |
11 | |||
12 | # Eliminate the contents of (and inclusions of) compiler.h | ||
13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ | ||
14 | -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ | ||
15 | -e "s/(__user[[:space:]]\{1,\}/ (/g" \ | ||
16 | -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ | ||
17 | -e "s/(__force[[:space:]]\{1,\}/ (/g" \ | ||
18 | -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \ | ||
19 | -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \ | ||
20 | -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \ | ||
21 | -e "s/[[:space:]]__attribute_const__$$//" \ | ||
22 | -e "/^\#include <linux\/compiler.h>/d" | ||
23 | |||
24 | _dst := $(if $(dst),$(dst),$(obj)) | 12 | _dst := $(if $(dst),$(dst),$(obj)) |
25 | 13 | ||
26 | kbuild-file := $(srctree)/$(obj)/Kbuild | 14 | kbuild-file := $(srctree)/$(obj)/Kbuild |
@@ -28,89 +16,82 @@ include $(kbuild-file) | |||
28 | 16 | ||
29 | include scripts/Kbuild.include | 17 | include scripts/Kbuild.include |
30 | 18 | ||
31 | install := $(INSTALL_HDR_PATH)/$(_dst) | 19 | install := $(INSTALL_HDR_PATH)/$(_dst) |
32 | |||
33 | header-y := $(sort $(header-y) $(unifdef-y)) | ||
34 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) | ||
35 | header-y := $(filter-out %/, $(header-y)) | ||
36 | 20 | ||
37 | # stamp files for header checks | 21 | header-y := $(sort $(header-y) $(unifdef-y)) |
38 | check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) | 22 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) |
39 | 23 | header-y := $(filter-out %/, $(header-y)) | |
40 | # Work out what needs to be removed | ||
41 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) | ||
42 | unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders)) | ||
43 | 24 | ||
44 | oldcheckstamps := $(patsubst $(install)/%,%,$(wildcard $(install)/.check.*.h)) | 25 | # files used to track state of install/check |
45 | unwanted += $(filter-out $(check-y),$(oldcheckstamps)) | 26 | install-file := $(install)/.install |
27 | check-file := $(install)/.check | ||
46 | 28 | ||
47 | # Prefix them all with full paths to $(INSTALL_HDR_PATH) | 29 | # all headers files for this dir |
48 | header-y := $(patsubst %,$(install)/%,$(header-y)) | 30 | all-files := $(header-y) $(objhdr-y) |
49 | objhdr-y := $(patsubst %,$(install)/%,$(objhdr-y)) | 31 | input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ |
50 | check-y := $(patsubst %,$(install)/%,$(check-y)) | 32 | $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) |
33 | output-files := $(addprefix $(install)/, $(all-files)) | ||
51 | 34 | ||
52 | quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) | 35 | # Work out what needs to be removed |
53 | cmd_o_hdr_install = cp $(patsubst $(install)/%,$(objtree)/$(obj)/%,$@) \ | 36 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) |
54 | $(install) | 37 | unwanted := $(filter-out $(all-files),$(oldheaders)) |
55 | |||
56 | quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) | ||
57 | cmd_unifdef = $(UNIFDEF) $(patsubst $(install)/%,$(srctree)/$(obj)/%,$@)\ | ||
58 | | $(HDRSED) > $@ || : | ||
59 | 38 | ||
60 | quiet_cmd_check = CHECK $(patsubst $(install)/.check.%,$(_dst)/%,$@) | 39 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
61 | cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \ | 40 | unwanted-file := $(addprefix $(install)/, $(unwanted)) |
62 | $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ | ||
63 | 41 | ||
64 | quiet_cmd_remove = REMOVE $(_dst)/$@ | 42 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
65 | cmd_remove = rm -f $(install)/$@ | ||
66 | 43 | ||
67 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) | 44 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ |
68 | cmd_mkdir = mkdir -p $@ | 45 | file$(if $(word 2, $(all-files)),s)) |
46 | cmd_install = $(PERL) $< $(srctree)/$(obj) $(install) $(header-y); \ | ||
47 | $(PERL) $< $(objtree)/$(obj) $(install) $(objhdr-y); \ | ||
48 | touch $@ | ||
69 | 49 | ||
70 | .PHONY: __headersinst __headerscheck | 50 | quiet_cmd_remove = REMOVE $(unwanted) |
51 | cmd_remove = rm -f $(unwanted-file) | ||
71 | 52 | ||
72 | ifdef HDRCHECK | 53 | quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
73 | __headerscheck: $(subdir-y) $(check-y) | 54 | cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \ |
74 | @true | 55 | $(addprefix $(install)/, $(all-files)); \ |
56 | touch $@ | ||
75 | 57 | ||
76 | $(check-y) : $(install)/.check.%.h : $(install)/%.h | 58 | PHONY += __headersinst __headerscheck |
77 | $(call cmd,check) | ||
78 | 59 | ||
79 | # Other dependencies for $(check-y) | 60 | ifndef HDRCHECK |
80 | include /dev/null $(wildcard $(check-y)) | 61 | # Rules for installing headers |
62 | __headersinst: $(subdirs) $(install-file) | ||
63 | @: | ||
81 | 64 | ||
82 | # but leave $(check-y) as .PHONY for now until those | 65 | targets += $(install-file) |
83 | # deps are actually correct. | 66 | $(install-file): scripts/headers_install.pl $(input-files) FORCE |
84 | .PHONY: $(check-y) | 67 | $(if $(unwanted),$(call cmd,remove),) |
68 | $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) | ||
69 | $(call if_changed,install) | ||
85 | 70 | ||
86 | else | 71 | else |
87 | # Rules for installing headers | 72 | __headerscheck: $(subdirs) $(check-file) |
88 | __headersinst: $(subdir-y) $(header-y) $(objhdr-y) | 73 | @: |
89 | @true | ||
90 | 74 | ||
91 | $(objhdr-y) $(subdir-y) $(header-y): | $(install) $(unwanted) | 75 | targets += $(check-file) |
76 | $(check-file): scripts/headers_check.pl $(output-files) FORCE | ||
77 | $(call if_changed,check) | ||
92 | 78 | ||
93 | $(install): | 79 | endif |
94 | $(call cmd,mkdir) | ||
95 | |||
96 | # Rules for removing unwanted header files | ||
97 | .PHONY: $(unwanted) | ||
98 | $(unwanted): | ||
99 | $(call cmd,remove) | ||
100 | 80 | ||
101 | # Install generated files | 81 | # Recursion |
102 | $(objhdr-y): $(install)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file) | 82 | hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj |
103 | $(call cmd,o_hdr_install) | 83 | .PHONY: $(subdirs) |
84 | $(subdirs): | ||
85 | $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ | ||
104 | 86 | ||
105 | # Unifdef header files and install them | 87 | targets := $(wildcard $(sort $(targets))) |
106 | $(header-y): $(install)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file) | 88 | cmd_files := $(wildcard \ |
107 | $(call cmd,unifdef) | 89 | $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
108 | 90 | ||
91 | ifneq ($(cmd_files),) | ||
92 | include $(cmd_files) | ||
109 | endif | 93 | endif |
110 | 94 | ||
111 | hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj | 95 | .PHONY: $(PHONY) |
112 | 96 | PHONY += FORCE | |
113 | # Recursion | 97 | FORCE: ; |
114 | .PHONY: $(subdir-y) | ||
115 | $(subdir-y): | ||
116 | $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ | ||