1 # SPDX-License-Identifier: GPL-2.0
4 # Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
5 # leading /, it's relative to $(srctree).
6 fwdir
:= $(CONFIG_EXTRA_FIRMWARE_DIR
)
7 fwdir
:= $(addprefix $(srctree
)/,$(filter-out /%,$(fwdir
)))$(filter /%,$(fwdir
))
9 firmware
:= $(addsuffix .gen.o
, $(CONFIG_EXTRA_FIRMWARE
))
12 FWNAME
= $(patsubst $(obj
)/%.gen.S
,%,$@
)
13 FWSTR
= $(subst $(comma
),_
,$(subst /,_
,$(subst .
,_
,$(subst -,_
,$(FWNAME
)))))
14 ASM_WORD
= $(if
$(CONFIG_64BIT
),.quad
,.long
)
15 ASM_ALIGN
= $(if
$(CONFIG_64BIT
),3,2)
16 PROGBITS
= $(if
$(CONFIG_ARM
),%,@
)progbits
19 echo
"/* Generated by $(src)/Makefile */" ;\
20 echo
" .section .rodata" ;\
22 echo
"_fw_$(FWSTR)_bin:" ;\
23 echo
" .incbin \"$(fwdir)/$(FWNAME)\"" ;\
25 echo
" .section .rodata.str,\"aMS\",$(PROGBITS),1" ;\
26 echo
" .p2align $(ASM_ALIGN)" ;\
27 echo
"_fw_$(FWSTR)_name:" ;\
28 echo
" .string \"$(FWNAME)\"" ;\
29 echo
" .section .builtin_fw,\"a\",$(PROGBITS)" ;\
30 echo
" .p2align $(ASM_ALIGN)" ;\
31 echo
" $(ASM_WORD) _fw_$(FWSTR)_name" ;\
32 echo
" $(ASM_WORD) _fw_$(FWSTR)_bin" ;\
33 echo
" $(ASM_WORD) _fw_end - _fw_$(FWSTR)_bin"
38 # The .o files depend on the binaries directly; the .S files don't.
39 $(addprefix $(obj
)/, $(firmware
)): $(obj
)/%.gen.o
: $(fwdir
)/%
41 targets
:= $(patsubst $(obj
)/%,%, \
42 $(shell find
$(obj
) -name \
*.gen.S
2>/dev
/null
))