diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-09-24 17:15:14 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-09-24 17:15:14 -0400 |
commit | de78912582bc1f95733d53e0d40779c0cd7b0686 (patch) | |
tree | cf7c7872e8e7fb80f4212ff0212a0208fdf43417 | |
parent | b4daf69722c49670d355d66439abda5ab5d4c5db (diff) |
Use dependencies for 'make headers_install'.
Re-export header files only if either they or their controlling Kbuild
file has actually changed. Also allow for similar dependencies with
'headers_check', once we properly create the dependencies for those.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | scripts/Makefile.headersinst | 124 | ||||
-rwxr-xr-x | scripts/hdrcheck.sh | 2 |
3 files changed, 81 insertions, 46 deletions
@@ -898,7 +898,6 @@ headers_install: include/linux/version.h | |||
898 | echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \ | 898 | echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \ |
899 | exit 1 ; fi | 899 | exit 1 ; fi |
900 | $(Q)unifdef -Ux /dev/null | 900 | $(Q)unifdef -Ux /dev/null |
901 | $(Q)rm -rf $(INSTALL_HDR_PATH)/include | ||
902 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include | 901 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include |
903 | 902 | ||
904 | PHONY += headers_check | 903 | PHONY += headers_check |
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 12e1daf875c8..07004c41e30e 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
@@ -23,30 +23,30 @@ HDRSED := sed -e "s/ inline / __inline__ /g" \ | |||
23 | 23 | ||
24 | _dst := $(if $(dst),$(dst),$(obj)) | 24 | _dst := $(if $(dst),$(dst),$(obj)) |
25 | 25 | ||
26 | .PHONY: __headersinst | ||
27 | __headersinst: | ||
28 | |||
29 | |||
30 | ifeq (,$(patsubst include/asm/%,,$(obj)/)) | 26 | ifeq (,$(patsubst include/asm/%,,$(obj)/)) |
31 | # For producing the generated stuff in include/asm for biarch builds, include | 27 | # For producing the generated stuff in include/asm for biarch builds, include |
32 | # both sets of Kbuild files; we'll generate anything which is mentioned in | 28 | # both sets of Kbuild files; we'll generate anything which is mentioned in |
33 | # _either_ arch, and recurse into subdirectories which are mentioned in either | 29 | # _either_ arch, and recurse into subdirectories which are mentioned in either |
34 | # arch. Since some directories may exist in one but not the other, we must | 30 | # arch. Since some directories may exist in one but not the other, we must |
35 | # use '-include'. | 31 | # use $(wildcard...). |
36 | GENASM := 1 | 32 | GENASM := 1 |
37 | archasm := $(subst include/asm,asm-$(ARCH),$(obj)) | 33 | archasm := $(subst include/asm,asm-$(ARCH),$(obj)) |
38 | altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) | 34 | altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) |
39 | -include $(srctree)/include/$(archasm)/Kbuild | 35 | KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild) |
40 | -include $(srctree)/include/$(altarchasm)/Kbuild | ||
41 | else | 36 | else |
42 | include $(srctree)/$(obj)/Kbuild | 37 | KBUILDFILES := $(srctree)/$(obj)/Kbuild |
43 | endif | 38 | endif |
44 | 39 | ||
45 | include scripts/Kbuild.include | 40 | include $(KBUILDFILES) |
41 | |||
42 | include scripts/Kbuild.include | ||
46 | 43 | ||
47 | # If this is include/asm-$(ARCH) and there's no $(ALTARCH), then | 44 | # If this is include/asm-$(ARCH) and there's no $(ALTARCH), then |
48 | # override $(_dst) so that we install to include/asm directly. | 45 | # override $(_dst) so that we install to include/asm directly. |
49 | ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)) | 46 | # Unless $(BIASMDIR) is set, in which case we're probably doing |
47 | # a 'headers_install_all' build and we should keep the -$(ARCH) | ||
48 | # in the directory name. | ||
49 | ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR)) | ||
50 | _dst := include/asm | 50 | _dst := include/asm |
51 | endif | 51 | endif |
52 | 52 | ||
@@ -56,6 +56,23 @@ subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) | |||
56 | header-y := $(filter-out %/, $(header-y)) | 56 | header-y := $(filter-out %/, $(header-y)) |
57 | header-y := $(filter-out $(unifdef-y),$(header-y)) | 57 | header-y := $(filter-out $(unifdef-y),$(header-y)) |
58 | 58 | ||
59 | # stamp files for header checks | ||
60 | check-y := $(patsubst %,.check.%,$(header-y) $(unifdef-y) $(objhdr-y)) | ||
61 | |||
62 | # Work out what needs to be removed | ||
63 | oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) | ||
64 | unwanted := $(filter-out $(header-y) $(unifdef-y) $(objhdr-y),$(oldheaders)) | ||
65 | |||
66 | oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) | ||
67 | unwanted += $(filter-out $(check-y),$(oldcheckstamps)) | ||
68 | |||
69 | # Prefix them all with full paths to $(INSTALL_HDR_PATH) | ||
70 | header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y)) | ||
71 | unifdef-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(unifdef-y)) | ||
72 | objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y)) | ||
73 | check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y)) | ||
74 | |||
75 | |||
59 | ifdef ALTARCH | 76 | ifdef ALTARCH |
60 | ifeq ($(obj),include/asm-$(ARCH)) | 77 | ifeq ($(obj),include/asm-$(ARCH)) |
61 | altarch-y := altarch-dir | 78 | altarch-y := altarch-dir |
@@ -67,43 +84,47 @@ export ALTARCH | |||
67 | export ARCHDEF | 84 | export ARCHDEF |
68 | export ALTARCHDEF | 85 | export ALTARCHDEF |
69 | 86 | ||
70 | quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@ | 87 | quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
71 | cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst) | 88 | cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \ |
89 | $(INSTALL_HDR_PATH)/$(_dst) | ||
72 | 90 | ||
73 | quiet_cmd_headers_install = INSTALL $(_dst)/$@ | 91 | quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
74 | cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \ | 92 | cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ |
75 | > $(INSTALL_HDR_PATH)/$(_dst)/$@ | 93 | > $@ |
76 | 94 | ||
77 | quiet_cmd_unifdef = UNIFDEF $(_dst)/$@ | 95 | quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
78 | cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \ | 96 | cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ |
79 | > $(INSTALL_HDR_PATH)/$(_dst)/$@ || : | 97 | | $(HDRSED) > $@ || : |
80 | 98 | ||
81 | quiet_cmd_check = CHECK $(_dst)/$@ | 99 | quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@) |
82 | cmd_check = $(srctree)/scripts/hdrcheck.sh \ | 100 | cmd_check = $(srctree)/scripts/hdrcheck.sh \ |
83 | $(INSTALL_HDR_PATH)/include \ | 101 | $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ |
84 | $(INSTALL_HDR_PATH)/$(_dst)/$@ | 102 | |
103 | quiet_cmd_remove = REMOVE $(_dst)/$@ | ||
104 | cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@ | ||
85 | 105 | ||
86 | quiet_cmd_mkdir = MKDIR $@ | 106 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
87 | cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@ | 107 | cmd_mkdir = mkdir -p $@ |
88 | 108 | ||
89 | quiet_cmd_gen = GEN $(_dst)/$@ | 109 | quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
90 | cmd_gen = \ | 110 | cmd_gen = \ |
91 | STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \ | 111 | FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@) \ |
112 | STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z. A-Z_`; \ | ||
92 | (echo "/* File autogenerated by 'make headers_install' */" ; \ | 113 | (echo "/* File autogenerated by 'make headers_install' */" ; \ |
93 | echo "\#ifndef $$STUBDEF" ; \ | 114 | echo "\#ifndef $$STUBDEF" ; \ |
94 | echo "\#define $$STUBDEF" ; \ | 115 | echo "\#define $$STUBDEF" ; \ |
95 | echo "\# if $(ARCHDEF)" ; \ | 116 | echo "\# if $(ARCHDEF)" ; \ |
96 | if [ -r $(INSTALL_HDR_PATH)/include/$(archasm)/$@ ]; then \ | 117 | if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \ |
97 | echo "\# include <$(archasm)/$@>" ; \ | 118 | echo "\# include <$(archasm)/$$FNAME>" ; \ |
98 | else \ | 119 | else \ |
99 | echo "\# error $(archasm)/$@ does not exist in" \ | 120 | echo "\# error $(archasm)/$$FNAME does not exist in" \ |
100 | "the $(ARCH) architecture" ; \ | 121 | "the $(ARCH) architecture" ; \ |
101 | fi ; \ | 122 | fi ; \ |
102 | echo "\# elif $(ALTARCHDEF)" ; \ | 123 | echo "\# elif $(ALTARCHDEF)" ; \ |
103 | if [ -r $(INSTALL_HDR_PATH)/include/$(altarchasm)/$@ ]; then \ | 124 | if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \ |
104 | echo "\# include <$(altarchasm)/$@>" ; \ | 125 | echo "\# include <$(altarchasm)/$$FNAME>" ; \ |
105 | else \ | 126 | else \ |
106 | echo "\# error $(altarchasm)/$@ does not exist in" \ | 127 | echo "\# error $(altarchasm)/$$FNAME does not exist in" \ |
107 | "the $(ALTARCH) architecture" ; \ | 128 | "the $(ALTARCH) architecture" ; \ |
108 | fi ; \ | 129 | fi ; \ |
109 | echo "\# else" ; \ | 130 | echo "\# else" ; \ |
@@ -111,37 +132,49 @@ echo "\# warning This machine appears to be" \ | |||
111 | "neither $(ARCH) nor $(ALTARCH)." ; \ | 132 | "neither $(ARCH) nor $(ALTARCH)." ; \ |
112 | echo "\# endif" ; \ | 133 | echo "\# endif" ; \ |
113 | echo "\#endif /* $$STUBDEF */" ; \ | 134 | echo "\#endif /* $$STUBDEF */" ; \ |
114 | ) > $(INSTALL_HDR_PATH)/$(_dst)/$@ | 135 | ) > $@ |
115 | 136 | ||
116 | __headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) | 137 | .PHONY: __headersinst __headerscheck |
117 | |||
118 | .PHONY: $(header-y) $(unifdef-y) $(subdir-y) | ||
119 | 138 | ||
120 | ifdef HDRCHECK | 139 | ifdef HDRCHECK |
121 | # Rules for checking headers | 140 | __headerscheck: $(subdir-y) $(check-y) |
122 | $(objhdr-y) $(header-y) $(unifdef-y): | 141 | @true |
142 | |||
143 | $(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h | ||
123 | $(call cmd,check) | 144 | $(call cmd,check) |
145 | |||
146 | # Other dependencies for $(check-y) | ||
147 | -include /dev/null $(check-y) | ||
148 | |||
149 | # ... but leave $(check-y) as .PHONY for now until those deps are actually correct. | ||
150 | .PHONY: $(check-y) | ||
151 | |||
124 | else | 152 | else |
125 | # Rules for installing headers | 153 | # Rules for installing headers |
154 | __headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) | ||
155 | @true | ||
126 | 156 | ||
127 | $(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst) | 157 | $(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) |
128 | 158 | ||
129 | .PHONY: $(_dst) | 159 | $(INSTALL_HDR_PATH)/$(_dst): |
130 | $(_dst): | ||
131 | $(call cmd,mkdir) | 160 | $(call cmd,mkdir) |
132 | 161 | ||
162 | .PHONY: $(unwanted) | ||
163 | $(unwanted): | ||
164 | $(call cmd,remove) | ||
165 | |||
133 | ifdef GENASM | 166 | ifdef GENASM |
134 | $(objhdr-y) $(header-y) $(unifdef-y): | 167 | $(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES) |
135 | $(call cmd,gen) | 168 | $(call cmd,gen) |
136 | 169 | ||
137 | else | 170 | else |
138 | $(objhdr-y): | 171 | $(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) |
139 | $(call cmd,o_hdr_install) | 172 | $(call cmd,o_hdr_install) |
140 | 173 | ||
141 | $(header-y): | 174 | $(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) |
142 | $(call cmd,headers_install) | 175 | $(call cmd,headers_install) |
143 | 176 | ||
144 | $(unifdef-y): | 177 | $(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) |
145 | $(call cmd,unifdef) | 178 | $(call cmd,unifdef) |
146 | endif | 179 | endif |
147 | endif | 180 | endif |
@@ -153,8 +186,9 @@ hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj | |||
153 | # for their existence. | 186 | # for their existence. |
154 | altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y) | 187 | altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y) |
155 | $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) | 188 | $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) |
156 | $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm | 189 | $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR) |
157 | 190 | ||
158 | # Recursion | 191 | # Recursion |
192 | .PHONY: $(subdir-y) | ||
159 | $(subdir-y): | 193 | $(subdir-y): |
160 | $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) | 194 | $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) |
diff --git a/scripts/hdrcheck.sh b/scripts/hdrcheck.sh index b5ca35aa1741..31598584f871 100755 --- a/scripts/hdrcheck.sh +++ b/scripts/hdrcheck.sh | |||
@@ -6,3 +6,5 @@ for FILE in `grep '^[ \t]*#[ \t]*include[ \t]*<' $2 | cut -f2 -d\< | cut -f1 -d\ | |||
6 | exit 1 | 6 | exit 1 |
7 | fi | 7 | fi |
8 | done | 8 | done |
9 | # FIXME: List dependencies into $3 | ||
10 | touch $3 | ||