diff options
author | Michal Marek <mmarek@suse.cz> | 2014-04-29 05:54:47 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2014-05-14 16:43:04 -0400 |
commit | 5180d5f483486859c0a822c9020ec459f4504b59 (patch) | |
tree | 311341f201df4f2ce9d99a1fd1ed6ffc8aa84bec /firmware/Makefile | |
parent | 3fbb43df983acf6f10a122e43e73daf6528ad7ed (diff) |
firmware: Simplify directory creation
When building the firmware blobs, use a simple loop to create
directories in $(objtree), like in Makefile.build. This simplifies the
rules and also makes it possible to set $(objtree) to '.' later. Before
this change, a dependency on $(objtree)/<dir> would be satisfied by
<dir> in $(srctree).
When installing the firmware blobs, call mkdir like in Makefile.modinst.
Cc: David Woodhouse <dwmw2@infradead.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'firmware/Makefile')
-rw-r--r-- | firmware/Makefile | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/firmware/Makefile b/firmware/Makefile index cbb09ce9730a..6af62cf6e285 100644 --- a/firmware/Makefile +++ b/firmware/Makefile | |||
@@ -138,12 +138,6 @@ fw-shipped-$(CONFIG_YAM) += yam/1200.bin yam/9600.bin | |||
138 | 138 | ||
139 | fw-shipped-all := $(fw-shipped-y) $(fw-shipped-m) $(fw-shipped-) | 139 | fw-shipped-all := $(fw-shipped-y) $(fw-shipped-m) $(fw-shipped-) |
140 | 140 | ||
141 | # Directories which we _might_ need to create, so we have a rule for them. | ||
142 | firmware-dirs := $(sort $(addprefix $(objtree)/$(obj)/,$(dir $(fw-external-y) $(fw-shipped-all)))) | ||
143 | |||
144 | quiet_cmd_mkdir = MKDIR $(patsubst $(objtree)/%,%,$@) | ||
145 | cmd_mkdir = mkdir -p $@ | ||
146 | |||
147 | quiet_cmd_ihex = IHEX $@ | 141 | quiet_cmd_ihex = IHEX $@ |
148 | cmd_ihex = $(OBJCOPY) -Iihex -Obinary $< $@ | 142 | cmd_ihex = $(OBJCOPY) -Iihex -Obinary $< $@ |
149 | 143 | ||
@@ -184,21 +178,10 @@ wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \ | |||
184 | include/config/superh32.h include/config/superh64.h \ | 178 | include/config/superh32.h include/config/superh64.h \ |
185 | include/config/x86_32.h include/config/x86_64.h) | 179 | include/config/x86_32.h include/config/x86_64.h) |
186 | 180 | ||
187 | # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. | 181 | $(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps) |
188 | # It'll end up depending on these targets, so make them a PHONY rule which | ||
189 | # depends on _all_ the directories in $(firmware-dirs), and it'll work out OK. | ||
190 | PHONY += $(objtree)/$$(%) $(objtree)/$(obj)/$$(%) | ||
191 | $(objtree)/$$(%) $(objtree)/$(obj)/$$(%): $(firmware-dirs) | ||
192 | @true | ||
193 | |||
194 | # For the $$(dir %) trick, where we need % to be expanded first. | ||
195 | .SECONDEXPANSION: | ||
196 | |||
197 | $(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps) \ | ||
198 | | $(objtree)/$$(dir %) | ||
199 | $(call cmd,fwbin,$(patsubst %.gen.S,%,$@)) | 182 | $(call cmd,fwbin,$(patsubst %.gen.S,%,$@)) |
200 | $(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \ | 183 | $(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \ |
201 | include/config/extra/firmware/dir.h | $(objtree)/$$(dir %) | 184 | include/config/extra/firmware/dir.h |
202 | $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@)) | 185 | $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@)) |
203 | 186 | ||
204 | # The .o files depend on the binaries directly; the .S files don't. | 187 | # The .o files depend on the binaries directly; the .S files don't. |
@@ -207,7 +190,7 @@ $(patsubst %,$(obj)/%.gen.o, $(fw-external-y)): $(obj)/%.gen.o: $(fwdir)/% | |||
207 | 190 | ||
208 | # .ihex is used just as a simple way to hold binary files in a source tree | 191 | # .ihex is used just as a simple way to hold binary files in a source tree |
209 | # where binaries are frowned upon. They are directly converted with objcopy. | 192 | # where binaries are frowned upon. They are directly converted with objcopy. |
210 | $(obj)/%: $(obj)/%.ihex | $(objtree)/$(obj)/$$(dir %) | 193 | $(obj)/%: $(obj)/%.ihex |
211 | $(call cmd,ihex) | 194 | $(call cmd,ihex) |
212 | 195 | ||
213 | # Don't depend on ihex2fw if we're installing and it already exists. | 196 | # Don't depend on ihex2fw if we're installing and it already exists. |
@@ -226,16 +209,13 @@ endif | |||
226 | # is actually meaningful, because the firmware has to be loaded in a certain | 209 | # is actually meaningful, because the firmware has to be loaded in a certain |
227 | # order rather than as a single binary blob. Thus, we convert them into our | 210 | # order rather than as a single binary blob. Thus, we convert them into our |
228 | # more compact binary representation of ihex records (<linux/ihex.h>) | 211 | # more compact binary representation of ihex records (<linux/ihex.h>) |
229 | $(obj)/%.fw: $(obj)/%.HEX $(ihex2fw_dep) | $(objtree)/$(obj)/$$(dir %) | 212 | $(obj)/%.fw: $(obj)/%.HEX $(ihex2fw_dep) |
230 | $(call cmd,ihex2fw) | 213 | $(call cmd,ihex2fw) |
231 | 214 | ||
232 | # .H16 is our own modified form of Intel HEX, with 16-bit length for records. | 215 | # .H16 is our own modified form of Intel HEX, with 16-bit length for records. |
233 | $(obj)/%.fw: $(obj)/%.H16 $(ihex2fw_dep) | $(objtree)/$(obj)/$$(dir %) | 216 | $(obj)/%.fw: $(obj)/%.H16 $(ihex2fw_dep) |
234 | $(call cmd,h16tofw) | 217 | $(call cmd,h16tofw) |
235 | 218 | ||
236 | $(firmware-dirs): | ||
237 | $(call cmd,mkdir) | ||
238 | |||
239 | obj-y += $(patsubst %,%.gen.o, $(fw-external-y)) | 219 | obj-y += $(patsubst %,%.gen.o, $(fw-external-y)) |
240 | obj-$(CONFIG_FIRMWARE_IN_KERNEL) += $(patsubst %,%.gen.o, $(fw-shipped-y)) | 220 | obj-$(CONFIG_FIRMWARE_IN_KERNEL) += $(patsubst %,%.gen.o, $(fw-shipped-y)) |
241 | 221 | ||