diff options
-rw-r--r-- | firmware/Makefile | 30 | ||||
-rw-r--r-- | scripts/Makefile.fwinst | 24 |
2 files changed, 16 insertions, 38 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 | ||
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst index 2c1d69c4345c..d8e335eed226 100644 --- a/scripts/Makefile.fwinst +++ b/scripts/Makefile.fwinst | |||
@@ -24,25 +24,23 @@ ifndef CONFIG_FIRMWARE_IN_KERNEL | |||
24 | mod-fw += $(fw-shipped-y) | 24 | mod-fw += $(fw-shipped-y) |
25 | endif | 25 | endif |
26 | 26 | ||
27 | ifneq ($(KBUILD_SRC),) | ||
28 | # Create output directory if not already present | ||
29 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) | ||
30 | |||
31 | firmware-dirs := $(sort $(addprefix $(objtree)/$(obj)/,$(dir $(fw-external-y) $(fw-shipped-all)))) | ||
32 | # Create directories for firmware in subdirectories | ||
33 | _dummy := $(foreach d,$(firmware-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) | ||
34 | endif | ||
35 | |||
27 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) | 36 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) |
28 | 37 | ||
29 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) | 38 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) |
30 | installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./ | ||
31 | |||
32 | # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. | ||
33 | PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs | ||
34 | $(INSTALL_FW_PATH)/$$(%): install-all-dirs | ||
35 | @true | ||
36 | install-all-dirs: $(installed-fw-dirs) | ||
37 | @true | ||
38 | 39 | ||
39 | quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) | 40 | quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) |
40 | cmd_install = $(INSTALL) -m0644 $< $@ | 41 | cmd_install = mkdir -p $(@D); $(INSTALL) -m0644 $< $@ |
41 | |||
42 | $(installed-fw-dirs): | ||
43 | $(call cmd,mkdir) | ||
44 | 42 | ||
45 | $(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %) | 43 | $(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% |
46 | $(call cmd,install) | 44 | $(call cmd,install) |
47 | 45 | ||
48 | PHONY += __fw_install __fw_modinst FORCE | 46 | PHONY += __fw_install __fw_modinst FORCE |