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