Merge tag 'trace-v6.13-rc7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[linux.git] / drivers / base / firmware_loader / builtin / Makefile
blob6c067dedc01ecf827ee8d00fb31ecc0c8a9ea743
1 # SPDX-License-Identifier: GPL-2.0
2 obj-y += main.o
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))
10 obj-y += $(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
18 filechk_fwbin = \
19 echo "/* Generated by $(src)/Makefile */" ;\
20 echo " .section .rodata" ;\
21 echo " .p2align 4" ;\
22 echo "_fw_$(FWSTR)_bin:" ;\
23 echo " .incbin \"$(fwdir)/$(FWNAME)\"" ;\
24 echo "_fw_end:" ;\
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"
35 $(obj)/%.gen.S: FORCE
36 $(call filechk,fwbin)
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))