blob: 37e5ae387400abbf984a90d67b72ee246460c32b [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +02002
Masahiro Yamada3470d9e2018-12-21 12:12:41 +09003# Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +02004# leading /, it's relative to $(srctree).
5fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR))
Masahiro Yamada3470d9e2018-12-21 12:12:41 +09006fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir))
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +02007
Masahiro Yamada3470d9e2018-12-21 12:12:41 +09008obj-y := $(addsuffix .gen.o, $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE)))
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +02009
Masahiro Yamada3470d9e2018-12-21 12:12:41 +090010FWNAME = $(patsubst $(obj)/%.gen.S,%,$@)
11FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))
12ASM_WORD = $(if $(CONFIG_64BIT),.quad,.long)
13ASM_ALIGN = $(if $(CONFIG_64BIT),3,2)
14PROGBITS = $(if $(CONFIG_ARM),%,@)progbits
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +020015
Masahiro Yamadaad774082018-12-31 17:24:09 +090016filechk_fwbin = \
Masahiro Yamada3470d9e2018-12-21 12:12:41 +090017 echo "/* Generated by $(src)/Makefile */" ;\
18 echo " .section .rodata" ;\
19 echo " .p2align $(ASM_ALIGN)" ;\
20 echo "_fw_$(FWSTR)_bin:" ;\
21 echo " .incbin \"$(fwdir)/$(FWNAME)\"" ;\
22 echo "_fw_end:" ;\
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" ;\
Masahiro Yamadaad774082018-12-31 17:24:09 +090031 echo " $(ASM_WORD) _fw_end - _fw_$(FWSTR)_bin"
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +020032
Masahiro Yamada3470d9e2018-12-21 12:12:41 +090033$(obj)/%.gen.S: FORCE
34 $(call filechk,fwbin)
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +020035
36# The .o files depend on the binaries directly; the .S files don't.
Masahiro Yamada3470d9e2018-12-21 12:12:41 +090037$(addprefix $(obj)/, $(obj-y)): $(obj)/%.gen.o: $(fwdir)/%
Markus Trippelsdorfdf85b2d2017-09-16 11:01:16 +020038
39targets := $(patsubst $(obj)/%,%, \
40 $(shell find $(obj) -name \*.gen.S 2>/dev/null))