aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.headersinst
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2008-06-15 15:41:09 -0400
committerSam Ravnborg <sam@ravnborg.org>2008-07-25 16:12:16 -0400
commit7712401ae9006fc9d9b9a3e7861dc73781429a89 (patch)
treecb0989cc5a1db8b7e4f490eef8e33225a2e40e93 /scripts/Makefile.headersinst
parent88181ec30f58a28cd78b26aaac38bef4062b23dc (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.headersinst145
1 files changed, 63 insertions, 82 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 599503f0e5f..be2b70c48a3 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
10UNIFDEF := 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
13HDRSED := 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
26kbuild-file := $(srctree)/$(obj)/Kbuild 14kbuild-file := $(srctree)/$(obj)/Kbuild
@@ -28,89 +16,82 @@ include $(kbuild-file)
28 16
29include scripts/Kbuild.include 17include scripts/Kbuild.include
30 18
31install := $(INSTALL_HDR_PATH)/$(_dst) 19install := $(INSTALL_HDR_PATH)/$(_dst)
32
33header-y := $(sort $(header-y) $(unifdef-y))
34subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
35header-y := $(filter-out %/, $(header-y))
36 20
37# stamp files for header checks 21header-y := $(sort $(header-y) $(unifdef-y))
38check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) 22subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
39 23header-y := $(filter-out %/, $(header-y))
40# Work out what needs to be removed
41oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
42unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders))
43 24
44oldcheckstamps := $(patsubst $(install)/%,%,$(wildcard $(install)/.check.*.h)) 25# files used to track state of install/check
45unwanted += $(filter-out $(check-y),$(oldcheckstamps)) 26install-file := $(install)/.install
27check-file := $(install)/.check
46 28
47# Prefix them all with full paths to $(INSTALL_HDR_PATH) 29# all headers files for this dir
48header-y := $(patsubst %,$(install)/%,$(header-y)) 30all-files := $(header-y) $(objhdr-y)
49objhdr-y := $(patsubst %,$(install)/%,$(objhdr-y)) 31input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
50check-y := $(patsubst %,$(install)/%,$(check-y)) 32 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
33output-files := $(addprefix $(install)/, $(all-files))
51 34
52quiet_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)/%,$@) \ 36oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
54 $(install) 37unwanted := $(filter-out $(all-files),$(oldheaders))
55
56quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
57 cmd_unifdef = $(UNIFDEF) $(patsubst $(install)/%,$(srctree)/$(obj)/%,$@)\
58 | $(HDRSED) > $@ || :
59 38
60quiet_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 \ 40unwanted-file := $(addprefix $(install)/, $(unwanted))
62 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
63 41
64quiet_cmd_remove = REMOVE $(_dst)/$@ 42printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
65 cmd_remove = rm -f $(install)/$@
66 43
67quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) 44quiet_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 50quiet_cmd_remove = REMOVE $(unwanted)
51 cmd_remove = rm -f $(unwanted-file)
71 52
72ifdef HDRCHECK 53quiet_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 58PHONY += __headersinst __headerscheck
77 $(call cmd,check)
78 59
79# Other dependencies for $(check-y) 60ifndef HDRCHECK
80include /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 65targets += $(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
86else 71else
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) 75targets += $(check-file)
76$(check-file): scripts/headers_check.pl $(output-files) FORCE
77 $(call if_changed,check)
92 78
93$(install): 79endif
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) 82hdr-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 87targets := $(wildcard $(sort $(targets)))
106$(header-y): $(install)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file) 88cmd_files := $(wildcard \
107 $(call cmd,unifdef) 89 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
108 90
91ifneq ($(cmd_files),)
92 include $(cmd_files)
109endif 93endif
110 94
111hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj 95.PHONY: $(PHONY)
112 96PHONY += FORCE
113# Recursion 97FORCE: ;
114.PHONY: $(subdir-y)
115$(subdir-y):
116 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@