1# SPDX-License-Identifier: GPL-2.0 2obj-y += main.o 3 4# Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a 5# leading /, it's relative to $(srctree). 6fwdir := $(CONFIG_EXTRA_FIRMWARE_DIR) 7fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir)) 8 9firmware := $(addsuffix .gen.o, $(CONFIG_EXTRA_FIRMWARE)) 10obj-y += $(firmware) 11 12FWNAME = $(patsubst $(obj)/%.gen.S,%,$@) 13FWSTR = $(subst $(comma),_,$(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))) 14ASM_WORD = $(if $(CONFIG_64BIT),.quad,.long) 15ASM_ALIGN = $(if $(CONFIG_64BIT),3,2) 16PROGBITS = $(if $(CONFIG_ARM),%,@)progbits 17 18filechk_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" 34 35$(obj)/%.gen.S: FORCE 36 $(call filechk,fwbin) 37 38# The .o files depend on the binaries directly; the .S files don't. 39$(addprefix $(obj)/, $(firmware)): $(obj)/%.gen.o: $(fwdir)/% 40 41targets := $(patsubst $(obj)/%,%, \ 42 $(shell find $(obj) -name \*.gen.S 2>/dev/null)) 43