aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2008-06-07 07:18:26 -0400
committerSam Ravnborg <sam@ravnborg.org>2008-07-25 16:08:40 -0400
commit62284a37dcd6725921410fb75446d270cc726b4f (patch)
tree40c0a2e7a7b5dd1f4030fb38b4278ace2feadecf
parent283039fb7ded6b863eacc9cfd67232297622e52d (diff)
kbuild: code refactoring in Makefile.headerinst
No functional changes just improved readability Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r--scripts/Makefile.headersinst64
1 files changed, 35 insertions, 29 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 1fb8c003920f..599adc63b84c 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -10,7 +10,7 @@
10UNIFDEF := scripts/unifdef -U__KERNEL__ 10UNIFDEF := scripts/unifdef -U__KERNEL__
11 11
12# Eliminate the contents of (and inclusions of) compiler.h 12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \ 13HDRSED := sed -e "s/ inline / __inline__ /g" \
14 -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ 14 -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
15 -e "s/(__user[[:space:]]\{1,\}/ (/g" \ 15 -e "s/(__user[[:space:]]\{1,\}/ (/g" \
16 -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ 16 -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
@@ -37,6 +37,8 @@ ifeq ($(obj),include/asm-$(ARCH)$(BIASMDIR))
37 _dst := include/asm 37 _dst := include/asm
38endif 38endif
39 39
40install := $(INSTALL_HDR_PATH)/$(_dst)
41
40header-y := $(sort $(header-y) $(unifdef-y)) 42header-y := $(sort $(header-y) $(unifdef-y))
41subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) 43subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
42header-y := $(filter-out %/, $(header-y)) 44header-y := $(filter-out %/, $(header-y))
@@ -45,34 +47,34 @@ header-y := $(filter-out %/, $(header-y))
45check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) 47check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y))
46 48
47# Work out what needs to be removed 49# Work out what needs to be removed
48oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) 50oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
49unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders)) 51unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders))
50 52
51oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) 53oldcheckstamps := $(patsubst $(install)/%,%,$(wildcard $(install)/.check.*.h))
52unwanted += $(filter-out $(check-y),$(oldcheckstamps)) 54unwanted += $(filter-out $(check-y),$(oldcheckstamps))
53 55
54# Prefix them all with full paths to $(INSTALL_HDR_PATH) 56# Prefix them all with full paths to $(INSTALL_HDR_PATH)
55header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y)) 57header-y := $(patsubst %,$(install)/%,$(header-y))
56objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y)) 58objhdr-y := $(patsubst %,$(install)/%,$(objhdr-y))
57check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y)) 59check-y := $(patsubst %,$(install)/%,$(check-y))
58 60
59quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) 61quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
60 cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \ 62 cmd_o_hdr_install = cp $(patsubst $(install)/%,$(objtree)/$(obj)/%,$@) \
61 $(INSTALL_HDR_PATH)/$(_dst) 63 $(install)
62 64
63quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) 65quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
64 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ 66 cmd_unifdef = $(UNIFDEF) $(patsubst $(install)/%,$(srctree)/$(obj)/%,$@)\
65 | $(HDRSED) > $@ || : 67 | $(HDRSED) > $@ || :
66 68
67quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@) 69quiet_cmd_check = CHECK $(patsubst $(install)/.check.%,$(_dst)/%,$@)
68 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \ 70 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
69 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ 71 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
70 72
71quiet_cmd_remove = REMOVE $(_dst)/$@ 73quiet_cmd_remove = REMOVE $(_dst)/$@
72 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@ 74 cmd_remove = rm -f $(install)/$@
73 75
74quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) 76quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
75 cmd_mkdir = mkdir -p $@ 77 cmd_mkdir = mkdir -p $@
76 78
77.PHONY: __headersinst __headerscheck 79.PHONY: __headersinst __headerscheck
78 80
@@ -80,13 +82,14 @@ ifdef HDRCHECK
80__headerscheck: $(subdir-y) $(check-y) 82__headerscheck: $(subdir-y) $(check-y)
81 @true 83 @true
82 84
83$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h 85$(check-y) : $(install)/.check.%.h : $(install)/%.h
84 $(call cmd,check) 86 $(call cmd,check)
85 87
86# Other dependencies for $(check-y) 88# Other dependencies for $(check-y)
87include /dev/null $(wildcard $(check-y)) 89include /dev/null $(wildcard $(check-y))
88 90
89# ... but leave $(check-y) as .PHONY for now until those deps are actually correct. 91# but leave $(check-y) as .PHONY for now until those
92# deps are actually correct.
90.PHONY: $(check-y) 93.PHONY: $(check-y)
91 94
92else 95else
@@ -94,26 +97,29 @@ else
94__headersinst: $(subdir-y) $(header-y) $(objhdr-y) 97__headersinst: $(subdir-y) $(header-y) $(objhdr-y)
95 @true 98 @true
96 99
97$(objhdr-y) $(subdir-y) $(header-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) 100$(objhdr-y) $(subdir-y) $(header-y): | $(install) $(unwanted)
98 101
99$(INSTALL_HDR_PATH)/$(_dst): 102$(install):
100 $(call cmd,mkdir) 103 $(call cmd,mkdir)
101 104
105# Rules for removing unwanted header files
102.PHONY: $(unwanted) 106.PHONY: $(unwanted)
103$(unwanted): 107$(unwanted):
104 $(call cmd,remove) 108 $(call cmd,remove)
105 109
106$(objhdr-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file) 110# Install generated files
111$(objhdr-y): $(install)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file)
107 $(call cmd,o_hdr_install) 112 $(call cmd,o_hdr_install)
108 113
109$(header-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file) 114# Unifdef header files and install them
115$(header-y): $(install)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file)
110 $(call cmd,unifdef) 116 $(call cmd,unifdef)
111 117
112endif 118endif
113 119
114hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj 120hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
115 121
116# Recursion 122# Recursion
117.PHONY: $(subdir-y) 123.PHONY: $(subdir-y)
118$(subdir-y): 124$(subdir-y):
119 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) 125 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@