Commit 5180d5f483486859c0a822c9020ec459f4504b59
1 parent
3fbb43df98
Exists in
smarc_imx_lf-5.15.y
and in
32 other branches
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>
Showing 2 changed files with 16 additions and 38 deletions Side-by-side Diff
firmware/Makefile
... | ... | @@ -138,12 +138,6 @@ |
138 | 138 | |
139 | 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 | 141 | quiet_cmd_ihex = IHEX $@ |
148 | 142 | cmd_ihex = $(OBJCOPY) -Iihex -Obinary $< $@ |
149 | 143 | |
150 | 144 | |
... | ... | @@ -184,21 +178,10 @@ |
184 | 178 | include/config/superh32.h include/config/superh64.h \ |
185 | 179 | include/config/x86_32.h include/config/x86_64.h) |
186 | 180 | |
187 | -# Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. | |
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 %) | |
181 | +$(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps) | |
199 | 182 | $(call cmd,fwbin,$(patsubst %.gen.S,%,$@)) |
200 | 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 | 185 | $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@)) |
203 | 186 | |
204 | 187 | # The .o files depend on the binaries directly; the .S files don't. |
... | ... | @@ -207,7 +190,7 @@ |
207 | 190 | |
208 | 191 | # .ihex is used just as a simple way to hold binary files in a source tree |
209 | 192 | # where binaries are frowned upon. They are directly converted with objcopy. |
210 | -$(obj)/%: $(obj)/%.ihex | $(objtree)/$(obj)/$$(dir %) | |
193 | +$(obj)/%: $(obj)/%.ihex | |
211 | 194 | $(call cmd,ihex) |
212 | 195 | |
213 | 196 | # Don't depend on ihex2fw if we're installing and it already exists. |
214 | 197 | |
215 | 198 | |
... | ... | @@ -226,15 +209,12 @@ |
226 | 209 | # is actually meaningful, because the firmware has to be loaded in a certain |
227 | 210 | # order rather than as a single binary blob. Thus, we convert them into our |
228 | 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 | 213 | $(call cmd,ihex2fw) |
231 | 214 | |
232 | 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 | 217 | $(call cmd,h16tofw) |
235 | - | |
236 | -$(firmware-dirs): | |
237 | - $(call cmd,mkdir) | |
238 | 218 | |
239 | 219 | obj-y += $(patsubst %,%.gen.o, $(fw-external-y)) |
240 | 220 | obj-$(CONFIG_FIRMWARE_IN_KERNEL) += $(patsubst %,%.gen.o, $(fw-shipped-y)) |
scripts/Makefile.fwinst
... | ... | @@ -24,25 +24,23 @@ |
24 | 24 | mod-fw += $(fw-shipped-y) |
25 | 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 | 36 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) |
28 | 37 | |
29 | 38 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) |
30 | -installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./ | |
31 | 39 | |
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 | 40 | quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) |
40 | - cmd_install = $(INSTALL) -m0644 $< $@ | |
41 | + cmd_install = mkdir -p $(@D); $(INSTALL) -m0644 $< $@ | |
41 | 42 | |
42 | -$(installed-fw-dirs): | |
43 | - $(call cmd,mkdir) | |
44 | - | |
45 | -$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %) | |
43 | +$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | |
46 | 44 | $(call cmd,install) |
47 | 45 | |
48 | 46 | PHONY += __fw_install __fw_modinst FORCE |