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