1 # SPDX-License-Identifier: GPL-2.0
3 # kbuild file for firmware/
6 # Create $(fwabs) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
7 # leading /, it's relative to $(srctree).
8 fwdir
:= $(subst $(quote
),,$(CONFIG_EXTRA_FIRMWARE_DIR
))
9 fwabs
:= $(addprefix $(srctree
)/,$(filter-out /%,$(fwdir
)))$(filter /%,$(fwdir
))
11 fw-external-y
:= $(subst $(quote
),,$(CONFIG_EXTRA_FIRMWARE
))
13 quiet_cmd_fwbin
= MK_FW
$@
14 cmd_fwbin
= FWNAME
="$(patsubst firmware/%.gen.S,%,$@)"; \
15 FWSTR
="$(subst /,_,$(subst .,_,$(subst -,_,$(patsubst \
16 firmware/%.gen.S,%,$@))))"; \
17 ASM_WORD
=$(if
$(CONFIG_64BIT
),.quad
,.long
); \
18 ASM_ALIGN
=$(if
$(CONFIG_64BIT
),3,2); \
19 PROGBITS
=$(if
$(CONFIG_ARM
),%,@
)progbits
; \
20 echo
"/* Generated by firmware/Makefile */" > $@
;\
21 echo
" .section .rodata" >>$@
;\
22 echo
" .p2align 4" >>$@
;\
23 echo
"_fw_$${FWSTR}_bin:" >>$@
;\
24 echo
" .incbin \"$(2)\"" >>$@
;\
25 echo
"_fw_end:" >>$@
;\
26 echo
" .section .rodata.str,\"aMS\",$${PROGBITS},1" >>$@
;\
27 echo
" .p2align $${ASM_ALIGN}" >>$@
;\
28 echo
"_fw_$${FWSTR}_name:" >>$@
;\
29 echo
" .string \"$$FWNAME\"" >>$@
;\
30 echo
" .section .builtin_fw,\"a\",$${PROGBITS}" >>$@
;\
31 echo
" .p2align $${ASM_ALIGN}" >>$@
;\
32 echo
" $${ASM_WORD} _fw_$${FWSTR}_name" >>$@
;\
33 echo
" $${ASM_WORD} _fw_$${FWSTR}_bin" >>$@
;\
34 echo
" $${ASM_WORD} _fw_end - _fw_$${FWSTR}_bin" >>$@
;
36 # One of these files will change, or come into existence, whenever
37 # the configuration changes between 32-bit and 64-bit. The .S files
38 # need to change when that happens.
39 wordsize_deps
:= $(wildcard include/config
/64bit.h
include/config
/32bit.h \
40 include/config
/ppc32.h
include/config
/ppc64.h \
41 include/config
/superh32.h
include/config
/superh64.h \
42 include/config
/x86_32.h
include/config
/x86_64.h \
45 $(patsubst %,$(obj
)/%.gen.S
, $(fw-external-y
)): %: $(wordsize_deps
) \
46 include/config
/extra
/firmware
/dir.h
47 $(call cmd
,fwbin
,$(fwabs
)/$(patsubst $(obj
)/%.gen.S
,%,$@
))
49 # The .o files depend on the binaries directly; the .S files don't.
50 $(patsubst %,$(obj
)/%.gen.o
, $(fw-external-y
)): $(obj
)/%.gen.o
: $(fwdir
)/%
52 obj-y
+= $(patsubst %,%.gen.o
, $(fw-external-y
))
55 # Makefile.build only creates subdirectories for O= builds, but external
56 # firmware might live outside the kernel source tree
57 _dummy
:= $(foreach d
,$(addprefix $(obj
)/,$(dir $(fw-external-y
))), $(shell [ -d
$(d
) ] || mkdir
-p
$(d
)))
60 targets
:= $(patsubst $(obj
)/%,%, \
61 $(shell find
$(obj
) -name \
*.gen.S
2>/dev
/null
))
62 # Without this, built-in.o won't be created when it's empty, and the
63 # final vmlinux link will fail.