Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 2 | |
Masahiro Yamada | 3470d9e | 2018-12-21 12:12:41 +0900 | [diff] [blame] | 3 | # Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 4 | # leading /, it's relative to $(srctree). |
| 5 | fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR)) |
Masahiro Yamada | 3470d9e | 2018-12-21 12:12:41 +0900 | [diff] [blame] | 6 | fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir)) |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 7 | |
Masahiro Yamada | 3470d9e | 2018-12-21 12:12:41 +0900 | [diff] [blame] | 8 | obj-y := $(addsuffix .gen.o, $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE))) |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 9 | |
Masahiro Yamada | 3470d9e | 2018-12-21 12:12:41 +0900 | [diff] [blame] | 10 | FWNAME = $(patsubst $(obj)/%.gen.S,%,$@) |
| 11 | FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME)))) |
| 12 | ASM_WORD = $(if $(CONFIG_64BIT),.quad,.long) |
| 13 | ASM_ALIGN = $(if $(CONFIG_64BIT),3,2) |
| 14 | PROGBITS = $(if $(CONFIG_ARM),%,@)progbits |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 15 | |
Masahiro Yamada | ad77408 | 2018-12-31 17:24:09 +0900 | [diff] [blame] | 16 | filechk_fwbin = \ |
Masahiro Yamada | 3470d9e | 2018-12-21 12:12:41 +0900 | [diff] [blame] | 17 | 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 Yamada | ad77408 | 2018-12-31 17:24:09 +0900 | [diff] [blame] | 31 | echo " $(ASM_WORD) _fw_end - _fw_$(FWSTR)_bin" |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 32 | |
Masahiro Yamada | 3470d9e | 2018-12-21 12:12:41 +0900 | [diff] [blame] | 33 | $(obj)/%.gen.S: FORCE |
| 34 | $(call filechk,fwbin) |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 35 | |
| 36 | # The .o files depend on the binaries directly; the .S files don't. |
Masahiro Yamada | 3470d9e | 2018-12-21 12:12:41 +0900 | [diff] [blame] | 37 | $(addprefix $(obj)/, $(obj-y)): $(obj)/%.gen.o: $(fwdir)/% |
Markus Trippelsdorf | df85b2d | 2017-09-16 11:01:16 +0200 | [diff] [blame] | 38 | |
| 39 | targets := $(patsubst $(obj)/%,%, \ |
| 40 | $(shell find $(obj) -name \*.gen.S 2>/dev/null)) |