diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2008-06-15 15:41:09 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-07-25 16:12:16 -0400 |
commit | 7712401ae9006fc9d9b9a3e7861dc73781429a89 (patch) | |
tree | cb0989cc5a1db8b7e4f490eef8e33225a2e40e93 /scripts/Makefile.headersinst | |
parent | 88181ec30f58a28cd78b26aaac38bef4062b23dc (diff) |
kbuild: optimize headers_* targets
Move the core functionality of headers_install
and headers_check to two small perl scripts.
The makefile is adapted to use the perl scrip and
changed to operate on all files in a directory.
So if one file is changed then all files in the
directory is processed.
perl were chosen for the helper scripts because this
is pure text processing which perl is good at and
especially the headers_check.pl script are expected to
see changes / new checks implmented.
The speed is ~300% faster on this box.
And the output generated to the screen is now down to
two lines per directory (one for install, one for check)
so it is easier to scroll back after a kernel build.
The perl scripts has been brought to sanity by patient
feedback from: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
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)/$@ | ||