blob: bf8425fae2bf19788c4daae6df2c983c667a40a1 [file] [log] [blame]
Juan Castillo73c99d42015-08-18 14:23:04 +01001#
Juan Pablo Condecf2dd172022-10-25 19:41:02 -04002# Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.
Juan Castillo73c99d42015-08-18 14:23:04 +01003#
dp-arm82cb2c12017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Juan Castillo73c99d42015-08-18 14:23:04 +01005#
6
Evan Lloyd1670d9d2015-12-02 18:41:22 +00007# Report an error if the eval make function is not available.
8$(eval eval_available := T)
9ifneq (${eval_available},T)
10 $(error This makefile only works with a Make program that supports $$(eval))
11endif
12
Evan Lloyd231c1472015-12-02 18:17:37 +000013# Some utility macros for manipulating awkward (whitespace) characters.
14blank :=
15space :=${blank} ${blank}
16
17# A user defined function to recursively search for a filename below a directory
18# $1 is the directory root of the recursive search (blank for current directory).
19# $2 is the file name to search for.
20define rwildcard
21$(strip $(foreach d,$(wildcard ${1}*),$(call rwildcard,${d}/,${2}) $(filter $(subst *,%,%${2}),${d})))
22endef
23
Yatharth Kochar5ba8f662015-10-02 13:58:52 +010024# This table is used in converting lower case to upper case.
25uppercase_table:=a,A b,B c,C d,D e,E f,F g,G h,H i,I j,J k,K l,L m,M n,N o,O p,P q,Q r,R s,S t,T u,U v,V w,W x,X y,Y z,Z
26
27# Internal macro used for converting lower case to upper case.
28# $(1) = upper case table
29# $(2) = String to convert
30define uppercase_internal
31$(if $(1),$$(subst $(firstword $(1)),$(call uppercase_internal,$(wordlist 2,$(words $(1)),$(1)),$(2))),$(2))
32endef
33
34# A macro for converting a string to upper case
35# $(1) = String to convert
36define uppercase
37$(eval uppercase_result:=$(call uppercase_internal,$(uppercase_table),$(1)))$(uppercase_result)
38endef
39
Boyan Karatoteve31060c2022-11-17 12:01:29 +000040# Convenience function for setting a variable to 0 if not previously set
41# $(eval $(call default_zero,FOO))
42define default_zero
43 $(eval $(1) ?= 0)
44endef
45
46# Convenience function for setting a list of variables to 0 if not previously set
47# $(eval $(call default_zeros,FOO BAR))
48define default_zeros
49 $(foreach var,$1,$(eval $(call default_zero,$(var))))
50endef
51
Juan Castillo73c99d42015-08-18 14:23:04 +010052# Convenience function for adding build definitions
53# $(eval $(call add_define,FOO)) will have:
54# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
55define add_define
56 DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
57endef
58
Leonardo Sandoval327131c2020-09-10 12:18:27 -050059# Convenience function for addding multiple build definitions
60# $(eval $(call add_defines,FOO BOO))
61define add_defines
62 $(foreach def,$1,$(eval $(call add_define,$(def))))
63endef
64
Soren Brinkmann8eadeb42016-06-09 13:36:27 -070065# Convenience function for adding build definitions
66# $(eval $(call add_define_val,FOO,BAR)) will have:
67# -DFOO=BAR
68define add_define_val
69 DEFINES += -D$(1)=$(2)
70endef
71
Juan Castillo73c99d42015-08-18 14:23:04 +010072# Convenience function for verifying option has a boolean value
73# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1
74define assert_boolean
Masahiro Yamadabe4cd402017-05-23 23:45:01 +090075 $(if $(filter-out 0 1,$($1)),$(error $1 must be boolean))
Juan Castillo73c99d42015-08-18 14:23:04 +010076endef
77
Leonardo Sandoval327131c2020-09-10 12:18:27 -050078# Convenience function for verifying options have boolean values
79# $(eval $(call assert_booleans,FOO BOO)) will assert FOO and BOO for 0 or 1 values
80define assert_booleans
81 $(foreach bool,$1,$(eval $(call assert_boolean,$(bool))))
82endef
83
Jeenu Viswambharanc877b412017-01-16 16:52:35 +0000840-9 := 0 1 2 3 4 5 6 7 8 9
85
86# Function to verify that a given option $(1) contains a numeric value
87define assert_numeric
88$(if $($(1)),,$(error $(1) must not be empty))
89$(eval __numeric := $($(1)))
90$(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric))))
91$(if $(__numeric),$(error $(1) must be numeric))
92endef
93
Leonardo Sandoval327131c2020-09-10 12:18:27 -050094# Convenience function for verifying options have numeric values
95# $(eval $(call assert_numerics,FOO BOO)) will assert FOO and BOO contain numeric values
96define assert_numerics
97 $(foreach num,$1,$(eval $(call assert_numeric,$(num))))
98endef
99
Vijayenthiran Subramaniam8c7b9442020-02-08 21:27:30 +0530100# CREATE_SEQ is a recursive function to create sequence of numbers from 1 to
101# $(2) and assign the sequence to $(1)
102define CREATE_SEQ
103$(if $(word $(2), $($(1))),\
104 $(eval $(1) += $(words $($(1))))\
105 $(eval $(1) := $(filter-out 0,$($(1)))),\
106 $(eval $(1) += $(words $($(1))))\
107 $(call CREATE_SEQ,$(1),$(2))\
108)
109endef
110
Juan Castillo73c99d42015-08-18 14:23:04 +0100111# IMG_LINKERFILE defines the linker script corresponding to a BL stage
Zelalem Aweke434d0492021-07-11 17:25:48 -0500112# $(1) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100113define IMG_LINKERFILE
Zelalem Aweke434d0492021-07-11 17:25:48 -0500114 ${BUILD_DIR}/$(1).ld
Juan Castillo73c99d42015-08-18 14:23:04 +0100115endef
116
117# IMG_MAPFILE defines the output file describing the memory map corresponding
118# to a BL stage
Zelalem Aweke434d0492021-07-11 17:25:48 -0500119# $(1) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100120define IMG_MAPFILE
Zelalem Aweke434d0492021-07-11 17:25:48 -0500121 ${BUILD_DIR}/$(1).map
Juan Castillo73c99d42015-08-18 14:23:04 +0100122endef
123
124# IMG_ELF defines the elf file corresponding to a BL stage
Zelalem Aweke434d0492021-07-11 17:25:48 -0500125# $(1) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100126define IMG_ELF
Zelalem Aweke434d0492021-07-11 17:25:48 -0500127 ${BUILD_DIR}/$(1).elf
Juan Castillo73c99d42015-08-18 14:23:04 +0100128endef
129
130# IMG_DUMP defines the symbols dump file corresponding to a BL stage
Zelalem Aweke434d0492021-07-11 17:25:48 -0500131# $(1) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100132define IMG_DUMP
Zelalem Aweke434d0492021-07-11 17:25:48 -0500133 ${BUILD_DIR}/$(1).dump
Juan Castillo73c99d42015-08-18 14:23:04 +0100134endef
135
136# IMG_BIN defines the default image file corresponding to a BL stage
Zelalem Aweke434d0492021-07-11 17:25:48 -0500137# $(1) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100138define IMG_BIN
Zelalem Aweke434d0492021-07-11 17:25:48 -0500139 ${BUILD_PLAT}/$(1).bin
Juan Castillo73c99d42015-08-18 14:23:04 +0100140endef
141
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530142# IMG_ENC_BIN defines the default encrypted image file corresponding to a
143# BL stage
Zelalem Aweke434d0492021-07-11 17:25:48 -0500144# $(1) = BL stage
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530145define IMG_ENC_BIN
Zelalem Aweke434d0492021-07-11 17:25:48 -0500146 ${BUILD_PLAT}/$(1)_enc.bin
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530147endef
148
149# ENCRYPT_FW invokes enctool to encrypt firmware binary
150# $(1) = input firmware binary
151# $(2) = output encrypted firmware binary
152define ENCRYPT_FW
153$(2): $(1) enctool
154 $$(ECHO) " ENC $$<"
155 $$(Q)$$(ENCTOOL) $$(ENC_ARGS) -i $$< -o $$@
156endef
157
Masahiro Yamada10cea932018-01-26 11:42:01 +0900158# TOOL_ADD_PAYLOAD appends the command line arguments required by fiptool to
159# package a new payload and/or by cert_create to generate certificate.
160# Optionally, it adds the dependency on this payload
Juan Castillo73c99d42015-08-18 14:23:04 +0100161# $(1) = payload filename (i.e. bl31.bin)
Masahiro Yamada1e0c0782017-12-23 23:56:18 +0900162# $(2) = command line option for the specified payload (i.e. --soc-fw)
Masahiro Yamada36af3452018-01-26 11:42:01 +0900163# $(3) = tool target dependency (optional) (ex. build/fvp/release/bl31.bin)
Masahiro Yamada1dc07142018-01-26 11:42:01 +0900164# $(4) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip)
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530165# $(5) = encrypted payload (optional) (ex. build/fvp/release/bl31_enc.bin)
Masahiro Yamada10cea932018-01-26 11:42:01 +0900166define TOOL_ADD_PAYLOAD
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530167ifneq ($(5),)
168 $(4)FIP_ARGS += $(2) $(5)
169 $(if $(3),$(4)CRT_DEPS += $(1))
170else
Masahiro Yamada945b3162018-01-26 11:42:01 +0900171 $(4)FIP_ARGS += $(2) $(1)
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530172 $(if $(3),$(4)CRT_DEPS += $(3))
173endif
Masahiro Yamada945b3162018-01-26 11:42:01 +0900174 $(if $(3),$(4)FIP_DEPS += $(3))
Masahiro Yamadaf30ee0b2018-01-26 11:42:01 +0900175 $(4)CRT_ARGS += $(2) $(1)
Juan Castillo73c99d42015-08-18 14:23:04 +0100176endef
177
Masahiro Yamada2da522b2018-02-01 16:31:09 +0900178# TOOL_ADD_IMG_PAYLOAD works like TOOL_ADD_PAYLOAD, but applies image filters
179# before passing them to host tools if BL*_PRE_TOOL_FILTER is defined.
180# $(1) = image_type (scp_bl2, bl33, etc.)
181# $(2) = payload filepath (ex. build/fvp/release/bl31.bin)
182# $(3) = command line option for the specified payload (ex. --soc-fw)
183# $(4) = tool target dependency (optional) (ex. build/fvp/release/bl31.bin)
184# $(5) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip)
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530185# $(6) = encrypted payload (optional) (ex. build/fvp/release/bl31_enc.bin)
Masahiro Yamada2da522b2018-02-01 16:31:09 +0900186
187define TOOL_ADD_IMG_PAYLOAD
188
189$(eval PRE_TOOL_FILTER := $($(call uppercase,$(1))_PRE_TOOL_FILTER))
190
191ifneq ($(PRE_TOOL_FILTER),)
192
193$(eval PROCESSED_PATH := $(BUILD_PLAT)/$(1).bin$($(PRE_TOOL_FILTER)_SUFFIX))
194
195$(call $(PRE_TOOL_FILTER)_RULE,$(PROCESSED_PATH),$(2))
196
197$(PROCESSED_PATH): $(4)
198
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530199$(call TOOL_ADD_PAYLOAD,$(PROCESSED_PATH),$(3),$(PROCESSED_PATH),$(5),$(6))
Masahiro Yamada2da522b2018-02-01 16:31:09 +0900200
201else
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530202$(call TOOL_ADD_PAYLOAD,$(2),$(3),$(4),$(5),$(6))
Masahiro Yamada2da522b2018-02-01 16:31:09 +0900203endif
204endef
205
Yatharth Kochar01912622015-10-12 12:33:47 +0100206# CERT_ADD_CMD_OPT adds a new command line option to the cert_create invocation
Juan Castillo73c99d42015-08-18 14:23:04 +0100207# $(1) = parameter filename
208# $(2) = cert_create command line option for the specified parameter
Masahiro Yamada91704d92018-01-26 11:42:01 +0900209# $(3) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip)
Juan Castillo73c99d42015-08-18 14:23:04 +0100210define CERT_ADD_CMD_OPT
Masahiro Yamada91704d92018-01-26 11:42:01 +0900211 $(3)CRT_ARGS += $(2) $(1)
Juan Castillo73c99d42015-08-18 14:23:04 +0100212endef
213
Masahiro Yamadac939d132018-01-26 11:42:01 +0900214# TOOL_ADD_IMG allows the platform to specify an external image to be packed
215# in the FIP and/or for which certificate is generated. It also adds a
216# dependency on the image file, aborting the build if the file does not exist.
Masahiro Yamada33950dd2018-01-26 11:42:01 +0900217# $(1) = image_type (scp_bl2, bl33, etc.)
Masahiro Yamada1e0c0782017-12-23 23:56:18 +0900218# $(2) = command line option for fiptool (--scp-fw, --nt-fw, etc)
Masahiro Yamada1dc07142018-01-26 11:42:01 +0900219# $(3) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip)
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530220# $(4) = Image encryption flag (optional) (0, 1)
Juan Castillo73c99d42015-08-18 14:23:04 +0100221# Example:
Masahiro Yamada33950dd2018-01-26 11:42:01 +0900222# $(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Masahiro Yamadac939d132018-01-26 11:42:01 +0900223define TOOL_ADD_IMG
Masahiro Yamada33950dd2018-01-26 11:42:01 +0900224 # Build option to specify the image filename (SCP_BL2, BL33, etc)
225 # This is the uppercase form of the first parameter
226 $(eval _V := $(call uppercase,$(1)))
227
Pali Rohár4727fd12020-11-24 16:53:04 +0100228 # $(check_$(1)_cmd) variable is executed in the check_$(1) target and also
229 # is put into the ${CHECK_$(3)FIP_CMD} variable which is executed by the
230 # target ${BUILD_PLAT}/${$(3)FIP_NAME}.
231 $(eval check_$(1)_cmd := \
232 $(if $(value $(_V)),,$$$$(error "Platform '${PLAT}' requires $(_V). Please set $(_V) to point to the right file")) \
233 $(if $(wildcard $(value $(_V))),,$$$$(error '$(_V)=$(value $(_V))' was specified, but '$(value $(_V))' does not exist)) \
234 )
235
Masahiro Yamada945b3162018-01-26 11:42:01 +0900236 $(3)CRT_DEPS += check_$(1)
Pali Rohár4727fd12020-11-24 16:53:04 +0100237 CHECK_$(3)FIP_CMD += $$(check_$(1)_cmd)
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530238ifeq ($(4),1)
239 $(eval ENC_BIN := ${BUILD_PLAT}/$(1)_enc.bin)
240 $(call ENCRYPT_FW,$(value $(_V)),$(ENC_BIN))
241 $(call TOOL_ADD_IMG_PAYLOAD,$(1),$(value $(_V)),$(2),$(ENC_BIN),$(3), \
242 $(ENC_BIN))
243else
Pali Rohár4727fd12020-11-24 16:53:04 +0100244 $(call TOOL_ADD_IMG_PAYLOAD,$(1),$(value $(_V)),$(2),$(if $(wildcard $(value $(_V))),$(value $(_V)),FORCE),$(3))
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530245endif
Yatharth Kochar01912622015-10-12 12:33:47 +0100246
Masahiro Yamada87ebd202017-12-24 13:08:00 +0900247.PHONY: check_$(1)
Yatharth Kochar01912622015-10-12 12:33:47 +0100248check_$(1):
Pali Rohár4727fd12020-11-24 16:53:04 +0100249 $(check_$(1)_cmd)
Yatharth Kochar01912622015-10-12 12:33:47 +0100250endef
Juan Castillo73c99d42015-08-18 14:23:04 +0100251
Juan Pablo Condecf2dd172022-10-25 19:41:02 -0400252# SELECT_OPENSSL_API_VERSION selects the OpenSSL API version to be used to
253# build the host tools by checking the version of OpenSSL located under
254# the path defined by the OPENSSL_DIR variable. It receives no parameters.
255define SELECT_OPENSSL_API_VERSION
256 # Set default value for USING_OPENSSL3 macro to 0
257 $(eval USING_OPENSSL3 = 0)
258 # Obtain the OpenSSL version for the build located under OPENSSL_DIR
259 $(eval OPENSSL_INFO := $(shell LD_LIBRARY_PATH=${OPENSSL_DIR}:${OPENSSL_DIR}/lib ${OPENSSL_BIN_PATH}/openssl version))
260 $(eval OPENSSL_CURRENT_VER = $(word 2, ${OPENSSL_INFO}))
261 $(eval OPENSSL_CURRENT_VER_MAJOR = $(firstword $(subst ., ,$(OPENSSL_CURRENT_VER))))
262 # If OpenSSL version is 3.x, then set USING_OPENSSL3 flag to 1
263 $(if $(filter 3,$(OPENSSL_CURRENT_VER_MAJOR)), $(eval USING_OPENSSL3 = 1))
264endef
265
Juan Castillo73c99d42015-08-18 14:23:04 +0100266################################################################################
Masahiro Yamada14db8902018-01-26 11:42:01 +0900267# Generic image processing filters
268################################################################################
269
270# GZIP
271define GZIP_RULE
272$(1): $(2)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100273 $(ECHO) " GZIP $$@"
Masahiro Yamada14db8902018-01-26 11:42:01 +0900274 $(Q)gzip -n -f -9 $$< --stdout > $$@
275endef
276
277GZIP_SUFFIX := .gz
278
279################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100280# Auxiliary macros to build TF images from sources
281################################################################################
282
Masahiro Yamada1d274ab2016-12-22 15:23:05 +0900283MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ -MP
Juan Castillo73c99d42015-08-18 14:23:04 +0100284
Roberto Vargas5fee0282018-05-08 10:27:10 +0100285
286# MAKE_C_LIB builds a C source file and generates the dependency file
287# $(1) = output directory
288# $(2) = source file (%.c)
289# $(3) = library name
290define MAKE_C_LIB
291$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
292$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
293
294$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | lib$(3)_dirs
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100295 $$(ECHO) " CC $$<"
Roberto Vargas5fee0282018-05-08 10:27:10 +0100296 $$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) $(MAKE_DEP) -c $$< -o $$@
297
298-include $(DEP)
299
300endef
301
Antonio Nino Diaz70b0f272019-02-08 13:20:37 +0000302# MAKE_S_LIB builds an assembly source file and generates the dependency file
303# $(1) = output directory
304# $(2) = source file (%.S)
305# $(3) = library name
306define MAKE_S_LIB
307$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
308$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
309
310$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | lib$(3)_dirs
311 $$(ECHO) " AS $$<"
312 $$(Q)$$(AS) $$(ASFLAGS) $(MAKE_DEP) -c $$< -o $$@
313
314-include $(DEP)
315
316endef
317
Roberto Vargas5fee0282018-05-08 10:27:10 +0100318
Juan Castillo73c99d42015-08-18 14:23:04 +0100319# MAKE_C builds a C source file and generates the dependency file
320# $(1) = output directory
321# $(2) = source file (%.c)
Zelalem Aweke434d0492021-07-11 17:25:48 -0500322# $(3) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100323define MAKE_C
324
325$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
Masahiro Yamada710ea1d2016-12-22 14:02:27 +0900326$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
Zelalem Aweke434d0492021-07-11 17:25:48 -0500327$(eval BL_CPPFLAGS := $($(call uppercase,$(3))_CPPFLAGS) -DIMAGE_$(call uppercase,$(3)))
328$(eval BL_CFLAGS := $($(call uppercase,$(3))_CFLAGS))
Juan Castillo73c99d42015-08-18 14:23:04 +0100329
Zelalem Aweke434d0492021-07-11 17:25:48 -0500330$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | $(3)_dirs
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100331 $$(ECHO) " CC $$<"
Masahiro Yamada848a7e82020-03-25 16:55:28 +0900332 $$(Q)$$(CC) $$(LTO_CFLAGS) $$(TF_CFLAGS) $$(CFLAGS) $(BL_CPPFLAGS) $(BL_CFLAGS) $(MAKE_DEP) -c $$< -o $$@
Juan Castillo73c99d42015-08-18 14:23:04 +0100333
Masahiro Yamada710ea1d2016-12-22 14:02:27 +0900334-include $(DEP)
Juan Castillo73c99d42015-08-18 14:23:04 +0100335
336endef
337
338
339# MAKE_S builds an assembly source file and generates the dependency file
340# $(1) = output directory
341# $(2) = assembly file (%.S)
Zelalem Aweke434d0492021-07-11 17:25:48 -0500342# $(3) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100343define MAKE_S
344
345$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
Masahiro Yamada710ea1d2016-12-22 14:02:27 +0900346$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
Zelalem Aweke434d0492021-07-11 17:25:48 -0500347$(eval BL_CPPFLAGS := $($(call uppercase,$(3))_CPPFLAGS) -DIMAGE_$(call uppercase,$(3)))
348$(eval BL_ASFLAGS := $($(call uppercase,$(3))_ASFLAGS))
Juan Castillo73c99d42015-08-18 14:23:04 +0100349
Zelalem Aweke434d0492021-07-11 17:25:48 -0500350$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | $(3)_dirs
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100351 $$(ECHO) " AS $$<"
Masahiro Yamada848a7e82020-03-25 16:55:28 +0900352 $$(Q)$$(AS) $$(ASFLAGS) $(BL_CPPFLAGS) $(BL_ASFLAGS) $(MAKE_DEP) -c $$< -o $$@
Juan Castillo73c99d42015-08-18 14:23:04 +0100353
Masahiro Yamada710ea1d2016-12-22 14:02:27 +0900354-include $(DEP)
Juan Castillo73c99d42015-08-18 14:23:04 +0100355
356endef
357
358
359# MAKE_LD generate the linker script using the C preprocessor
360# $(1) = output linker script
361# $(2) = input template
Zelalem Aweke434d0492021-07-11 17:25:48 -0500362# $(3) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100363define MAKE_LD
364
Masahiro Yamada710ea1d2016-12-22 14:02:27 +0900365$(eval DEP := $(1).d)
Zelalem Aweke434d0492021-07-11 17:25:48 -0500366$(eval BL_CPPFLAGS := $($(call uppercase,$(3))_CPPFLAGS) -DIMAGE_$(call uppercase,$(3)))
Juan Castillo73c99d42015-08-18 14:23:04 +0100367
Zelalem Aweke434d0492021-07-11 17:25:48 -0500368$(1): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | $(3)_dirs
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100369 $$(ECHO) " PP $$<"
Masahiro Yamada848a7e82020-03-25 16:55:28 +0900370 $$(Q)$$(CPP) $$(CPPFLAGS) $(BL_CPPFLAGS) $(TF_CFLAGS_$(ARCH)) -P -x assembler-with-cpp -D__LINKER__ $(MAKE_DEP) -o $$@ $$<
Juan Castillo73c99d42015-08-18 14:23:04 +0100371
Masahiro Yamada710ea1d2016-12-22 14:02:27 +0900372-include $(DEP)
Juan Castillo73c99d42015-08-18 14:23:04 +0100373
374endef
375
Antonio Nino Diaz70b0f272019-02-08 13:20:37 +0000376# MAKE_LIB_OBJS builds both C and assembly source files
Roberto Vargas5fee0282018-05-08 10:27:10 +0100377# $(1) = output directory
378# $(2) = list of source files
379# $(3) = name of the library
380define MAKE_LIB_OBJS
381 $(eval C_OBJS := $(filter %.c,$(2)))
382 $(eval REMAIN := $(filter-out %.c,$(2)))
383 $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C_LIB,$(1),$(obj),$(3))))
384
Antonio Nino Diaz70b0f272019-02-08 13:20:37 +0000385 $(eval S_OBJS := $(filter %.S,$(REMAIN)))
386 $(eval REMAIN := $(filter-out %.S,$(REMAIN)))
387 $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S_LIB,$(1),$(obj),$(3))))
388
Roberto Vargas5fee0282018-05-08 10:27:10 +0100389 $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
390endef
391
Juan Castillo73c99d42015-08-18 14:23:04 +0100392
393# MAKE_OBJS builds both C and assembly source files
394# $(1) = output directory
395# $(2) = list of source files (both C and assembly)
Zelalem Aweke434d0492021-07-11 17:25:48 -0500396# $(3) = BL stage
Juan Castillo73c99d42015-08-18 14:23:04 +0100397define MAKE_OBJS
398 $(eval C_OBJS := $(filter %.c,$(2)))
399 $(eval REMAIN := $(filter-out %.c,$(2)))
400 $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3))))
401
402 $(eval S_OBJS := $(filter %.S,$(REMAIN)))
403 $(eval REMAIN := $(filter-out %.S,$(REMAIN)))
404 $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3))))
405
406 $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
407endef
408
409
410# NOTE: The line continuation '\' is required in the next define otherwise we
411# end up with a line-feed characer at the end of the last c filename.
Evan Lloyde7f54db2015-12-02 18:56:06 +0000412# Also bear this issue in mind if extending the list of supported filetypes.
Juan Castillo73c99d42015-08-18 14:23:04 +0100413define SOURCES_TO_OBJS
414 $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \
415 $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1))))
416endef
417
Patrick Georgi2f5d4a42016-01-28 14:46:18 +0100418# Allow overriding the timestamp, for example for reproducible builds, or to
419# synchronize timestamps across multiple projects.
420# This must be set to a C string (including quotes where applicable).
421BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
Juan Castillo73c99d42015-08-18 14:23:04 +0100422
Roberto Vargas5fee0282018-05-08 10:27:10 +0100423.PHONY: libraries
424
Roberto Vargas5accce52018-05-22 16:05:42 +0100425# MAKE_LIB_DIRS macro defines the target for the directory where
Roberto Vargas5fee0282018-05-08 10:27:10 +0100426# libraries are created
Roberto Vargas5accce52018-05-22 16:05:42 +0100427define MAKE_LIB_DIRS
Roberto Vargas5fee0282018-05-08 10:27:10 +0100428 $(eval LIB_DIR := ${BUILD_PLAT}/lib)
Roberto Vargas5accce52018-05-22 16:05:42 +0100429 $(eval ROMLIB_DIR := ${BUILD_PLAT}/romlib)
430 $(eval LIBWRAPPER_DIR := ${BUILD_PLAT}/libwrapper)
431 $(eval $(call MAKE_PREREQ_DIR,${LIB_DIR},${BUILD_PLAT}))
432 $(eval $(call MAKE_PREREQ_DIR,${ROMLIB_DIR},${BUILD_PLAT}))
433 $(eval $(call MAKE_PREREQ_DIR,${LIBWRAPPER_DIR},${BUILD_PLAT}))
Roberto Vargas5fee0282018-05-08 10:27:10 +0100434endef
435
436# MAKE_LIB macro defines the targets and options to build each BL image.
437# Arguments:
438# $(1) = Library name
439define MAKE_LIB
440 $(eval BUILD_DIR := ${BUILD_PLAT}/lib$(1))
441 $(eval LIB_DIR := ${BUILD_PLAT}/lib)
Roberto Vargas5accce52018-05-22 16:05:42 +0100442 $(eval ROMLIB_DIR := ${BUILD_PLAT}/romlib)
Roberto Vargas5fee0282018-05-08 10:27:10 +0100443 $(eval SOURCES := $(LIB$(call uppercase,$(1))_SRCS))
444 $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
445
446$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT}))
447$(eval $(call MAKE_LIB_OBJS,$(BUILD_DIR),$(SOURCES),$(1)))
448
449.PHONY : lib${1}_dirs
Roberto Vargas5accce52018-05-22 16:05:42 +0100450lib${1}_dirs: | ${BUILD_DIR} ${LIB_DIR} ${ROMLIB_DIR} ${LIBWRAPPER_DIR}
Roberto Vargas5fee0282018-05-08 10:27:10 +0100451libraries: ${LIB_DIR}/lib$(1).a
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800452ifneq ($(findstring armlink,$(notdir $(LD))),)
453LDPATHS = --userlibpath=${LIB_DIR}
454LDLIBS += --library=$(1)
455else
Roberto Vargas5fee0282018-05-08 10:27:10 +0100456LDPATHS = -L${LIB_DIR}
457LDLIBS += -l$(1)
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800458endif
Roberto Vargas5fee0282018-05-08 10:27:10 +0100459
Roberto Vargas5accce52018-05-22 16:05:42 +0100460ifeq ($(USE_ROMLIB),1)
Sathees Balya6baf85b2018-10-18 19:14:21 +0100461LIBWRAPPER = -lwrappers
Roberto Vargas5accce52018-05-22 16:05:42 +0100462endif
463
Roberto Vargas5fee0282018-05-08 10:27:10 +0100464all: ${LIB_DIR}/lib$(1).a
465
466${LIB_DIR}/lib$(1).a: $(OBJS)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100467 $$(ECHO) " AR $$@"
Roberto Vargas5fee0282018-05-08 10:27:10 +0100468 $$(Q)$$(AR) cr $$@ $$?
469endef
470
Juan Castillo73c99d42015-08-18 14:23:04 +0100471# MAKE_BL macro defines the targets and options to build each BL image.
472# Arguments:
Zelalem Aweke434d0492021-07-11 17:25:48 -0500473# $(1) = BL stage
Juan Castillo8f0617e2016-01-05 11:55:36 +0000474# $(2) = FIP command line option (if empty, image will not be included in the FIP)
Masahiro Yamada1dc07142018-01-26 11:42:01 +0900475# $(3) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip)
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530476# $(4) = BL encryption flag (optional) (0, 1)
Juan Castillo73c99d42015-08-18 14:23:04 +0100477define MAKE_BL
Zelalem Aweke434d0492021-07-11 17:25:48 -0500478 $(eval BUILD_DIR := ${BUILD_PLAT}/$(1))
479 $(eval BL_SOURCES := $($(call uppercase,$(1))_SOURCES))
Yatharth Kochar5ba8f662015-10-02 13:58:52 +0100480 $(eval SOURCES := $(BL_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES))
Juan Castillo73c99d42015-08-18 14:23:04 +0100481 $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
482 $(eval LINKERFILE := $(call IMG_LINKERFILE,$(1)))
483 $(eval MAPFILE := $(call IMG_MAPFILE,$(1)))
484 $(eval ELF := $(call IMG_ELF,$(1)))
485 $(eval DUMP := $(call IMG_DUMP,$(1)))
486 $(eval BIN := $(call IMG_BIN,$(1)))
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530487 $(eval ENC_BIN := $(call IMG_ENC_BIN,$(1)))
Zelalem Aweke434d0492021-07-11 17:25:48 -0500488 $(eval BL_LINKERFILE := $($(call uppercase,$(1))_LINKERFILE))
489 $(eval BL_LIBS := $($(call uppercase,$(1))_LIBS))
Evan Lloyd51b27702015-12-03 12:19:30 +0000490 # We use sort only to get a list of unique object directory names.
491 # ordering is not relevant but sort removes duplicates.
Evan Lloyd6ba7d272017-04-07 16:58:57 +0100492 $(eval TEMP_OBJ_DIRS := $(sort $(dir ${OBJS} ${LINKERFILE})))
Evan Lloyd51b27702015-12-03 12:19:30 +0000493 # The $(dir ) function leaves a trailing / on the directory names
Masahiro Yamadad014ea62017-01-19 19:31:00 +0900494 # Rip off the / to match directory names with make rule targets.
495 $(eval OBJ_DIRS := $(patsubst %/,%,$(TEMP_OBJ_DIRS)))
Juan Castillo73c99d42015-08-18 14:23:04 +0100496
Evan Lloyd51b27702015-12-03 12:19:30 +0000497# Create generators for object directory structure
Juan Castillo73c99d42015-08-18 14:23:04 +0100498
Masahiro Yamada8012cc52017-11-04 03:12:28 +0900499$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT}))
Evan Lloyd6ba7d272017-04-07 16:58:57 +0100500
501$(eval $(foreach objd,${OBJ_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR})))
Juan Castillo73c99d42015-08-18 14:23:04 +0100502
Zelalem Aweke434d0492021-07-11 17:25:48 -0500503.PHONY : ${1}_dirs
Evan Lloyd51b27702015-12-03 12:19:30 +0000504
505# We use order-only prerequisites to ensure that directories are created,
506# but do not cause re-builds every time a file is written.
Zelalem Aweke434d0492021-07-11 17:25:48 -0500507${1}_dirs: | ${OBJ_DIRS}
Evan Lloyd51b27702015-12-03 12:19:30 +0000508
509$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1)))
Masahiro Yamadaa6ca7882017-01-12 10:48:22 +0900510$(eval $(call MAKE_LD,$(LINKERFILE),$(BL_LINKERFILE),$(1)))
Zelalem Aweke434d0492021-07-11 17:25:48 -0500511$(eval BL_LDFLAGS := $($(call uppercase,$(1))_LDFLAGS))
Evan Lloyd51b27702015-12-03 12:19:30 +0000512
Roberto Vargas5accce52018-05-22 16:05:42 +0100513ifeq ($(USE_ROMLIB),1)
514$(ELF): romlib.bin
515endif
516
Leon Chen8dccddc2022-03-23 18:51:48 +0800517# MODULE_OBJS can be assigned by vendors with different compiled
518# object file path, and prebuilt object file path.
519$(eval OBJS += $(MODULE_OBJS))
520
Zelalem Aweke434d0492021-07-11 17:25:48 -0500521$(ELF): $(OBJS) $(LINKERFILE) | $(1)_dirs libraries $(BL_LIBS)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100522 $$(ECHO) " LD $$@"
Evan Lloyd414ab852015-12-03 12:58:52 +0000523ifdef MAKE_BUILD_STRINGS
524 $(call MAKE_BUILD_STRINGS, $(BUILD_DIR)/build_message.o)
525else
Patrick Georgi2f5d4a42016-01-28 14:46:18 +0100526 @echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP); \
laurenw-armdddf4282022-07-12 10:12:05 -0500527 const char version_string[] = "${VERSION_STRING}"; \
528 const char version[] = "${VERSION}";' | \
Masahiro Yamadaf2e1d572016-12-22 12:39:55 +0900529 $$(CC) $$(TF_CFLAGS) $$(CFLAGS) -xc -c - -o $(BUILD_DIR)/build_message.o
Evan Lloyd414ab852015-12-03 12:58:52 +0000530endif
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800531ifneq ($(findstring armlink,$(notdir $(LD))),)
Zelalem Aweke434d0492021-07-11 17:25:48 -0500532 $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) --entry=${1}_entrypoint \
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800533 --predefine="-D__LINKER__=$(__LINKER__)" \
534 --predefine="-DTF_CFLAGS=$(TF_CFLAGS)" \
Zelalem Aweke434d0492021-07-11 17:25:48 -0500535 --map --list="$(MAPFILE)" --scatter=${PLAT_DIR}/scat/${1}.scat \
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800536 $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) \
537 $(BUILD_DIR)/build_message.o $(OBJS)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600538else ifneq ($(findstring gcc,$(notdir $(LD))),)
539 $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Wl,-Map=$(MAPFILE) \
Leon Chen8dccddc2022-03-23 18:51:48 +0800540 -Wl,-dT $(LINKERFILE) $(EXTRA_LINKERFILE) $(BUILD_DIR)/build_message.o \
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600541 $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS)
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800542else
Masahiro Yamadad986bae2020-01-17 13:44:20 +0900543 $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) -Map=$(MAPFILE) \
Roberto Vargas5fee0282018-05-08 10:27:10 +0100544 --script $(LINKERFILE) $(BUILD_DIR)/build_message.o \
Sathees Balya6baf85b2018-10-18 19:14:21 +0100545 $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS)
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800546endif
Christoph Müllner9e4609f2019-04-24 09:45:30 +0200547ifeq ($(DISABLE_BIN_GENERATION),1)
548 @${ECHO_BLANK_LINE}
549 @echo "Built $$@ successfully"
550 @${ECHO_BLANK_LINE}
551endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100552
553$(DUMP): $(ELF)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100554 $${ECHO} " OD $$@"
Juan Castillo73c99d42015-08-18 14:23:04 +0100555 $${Q}$${OD} -dx $$< > $$@
556
557$(BIN): $(ELF)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100558 $${ECHO} " BIN $$@"
Juan Castillo73c99d42015-08-18 14:23:04 +0100559 $$(Q)$$(OC) -O binary $$< $$@
Evan Lloyd052ab522017-04-11 16:52:00 +0100560 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +0100561 @echo "Built $$@ successfully"
Evan Lloyd052ab522017-04-11 16:52:00 +0100562 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +0100563
Zelalem Aweke434d0492021-07-11 17:25:48 -0500564.PHONY: $(1)
Christoph Müllner9e4609f2019-04-24 09:45:30 +0200565ifeq ($(DISABLE_BIN_GENERATION),1)
Zelalem Aweke434d0492021-07-11 17:25:48 -0500566$(1): $(ELF) $(DUMP)
Christoph Müllner9e4609f2019-04-24 09:45:30 +0200567else
Zelalem Aweke434d0492021-07-11 17:25:48 -0500568$(1): $(BIN) $(DUMP)
Christoph Müllner9e4609f2019-04-24 09:45:30 +0200569endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100570
Zelalem Aweke434d0492021-07-11 17:25:48 -0500571all: $(1)
Juan Castillo73c99d42015-08-18 14:23:04 +0100572
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530573ifeq ($(4),1)
574$(call ENCRYPT_FW,$(BIN),$(ENC_BIN))
Zelalem Aweke434d0492021-07-11 17:25:48 -0500575$(if $(2),$(call TOOL_ADD_IMG_PAYLOAD,$(1),$(BIN),--$(2),$(ENC_BIN),$(3), \
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530576 $(ENC_BIN)))
577else
Zelalem Aweke434d0492021-07-11 17:25:48 -0500578$(if $(2),$(call TOOL_ADD_IMG_PAYLOAD,$(1),$(BIN),--$(2),$(BIN),$(3)))
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530579endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100580
581endef
582
Soby Mathew38c14d82017-12-14 17:44:56 +0000583# Convert device tree source file names to matching blobs
584# $(1) = input dts
Nishanth Menon03b397a2016-10-14 01:13:57 +0000585define SOURCES_TO_DTBS
586 $(notdir $(patsubst %.dts,%.dtb,$(filter %.dts,$(1))))
587endef
588
Soby Mathew38c14d82017-12-14 17:44:56 +0000589# MAKE_FDT_DIRS macro creates the prerequisite directories that host the
590# FDT binaries
591# $(1) = output directory
592# $(2) = input dts
593define MAKE_FDT_DIRS
594 $(eval DTBS := $(addprefix $(1)/,$(call SOURCES_TO_DTBS,$(2))))
Nishanth Menon03b397a2016-10-14 01:13:57 +0000595 $(eval TEMP_DTB_DIRS := $(sort $(dir ${DTBS})))
596 # The $(dir ) function leaves a trailing / on the directory names
597 # Rip off the / to match directory names with make rule targets.
598 $(eval DTB_DIRS := $(patsubst %/,%,$(TEMP_DTB_DIRS)))
599
600$(eval $(foreach objd,${DTB_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR})))
601
602fdt_dirs: ${DTB_DIRS}
Nishanth Menon03b397a2016-10-14 01:13:57 +0000603endef
604
Soby Mathew38c14d82017-12-14 17:44:56 +0000605# MAKE_DTB generate the Flattened device tree binary
Nishanth Menon03b397a2016-10-14 01:13:57 +0000606# $(1) = output directory
607# $(2) = input dts
608define MAKE_DTB
609
Yann Gautier077b3e92018-09-04 10:44:00 +0200610# List of DTB file(s) to generate, based on DTS file basename list
Soby Mathew38c14d82017-12-14 17:44:56 +0000611$(eval DOBJ := $(addprefix $(1)/,$(call SOURCES_TO_DTBS,$(2))))
Yann Gautier077b3e92018-09-04 10:44:00 +0200612# List of the pre-compiled DTS file(s)
Yann Gautier01d237c2018-06-18 16:00:23 +0200613$(eval DPRE := $(addprefix $(1)/,$(patsubst %.dts,%.pre.dts,$(notdir $(2)))))
Yann Gautier077b3e92018-09-04 10:44:00 +0200614# Dependencies of the pre-compiled DTS file(s) on its source and included files
615$(eval DTSDEP := $(patsubst %.dtb,%.o.d,$(DOBJ)))
616# Dependencies of the DT compilation on its pre-compiled DTS
617$(eval DTBDEP := $(patsubst %.dtb,%.d,$(DOBJ)))
Nishanth Menon03b397a2016-10-14 01:13:57 +0000618
Stephen Warren6bc1a302018-02-21 17:13:50 -0700619$(DOBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | fdt_dirs
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100620 $${ECHO} " CPP $$<"
Yann Gautier077b3e92018-09-04 10:44:00 +0200621 $(eval DTBS := $(addprefix $(1)/,$(call SOURCES_TO_DTBS,$(2))))
Manish Pandey7e94a692019-01-21 14:50:10 +0000622 $$(Q)$$(PP) $$(DTC_CPPFLAGS) -MT $(DTBS) -MMD -MF $(DTSDEP) -o $(DPRE) $$<
Andre Przywaraee1ba6d2018-09-27 10:56:05 +0100623 $${ECHO} " DTC $$<"
Balint Dobszay2d51b552020-01-10 17:16:27 +0100624 $$(Q)$$(DTC) $$(DTC_FLAGS) -d $(DTBDEP) -o $$@ $(DPRE)
Nishanth Menon03b397a2016-10-14 01:13:57 +0000625
Yann Gautier077b3e92018-09-04 10:44:00 +0200626-include $(DTBDEP)
627-include $(DTSDEP)
Nishanth Menon03b397a2016-10-14 01:13:57 +0000628
629endef
630
631# MAKE_DTBS builds flattened device tree sources
632# $(1) = output directory
633# $(2) = list of flattened device tree source files
634define MAKE_DTBS
635 $(eval DOBJS := $(filter %.dts,$(2)))
636 $(eval REMAIN := $(filter-out %.dts,$(2)))
Soby Mathew38c14d82017-12-14 17:44:56 +0000637 $(and $(REMAIN),$(error FDT_SOURCES contain non-DTS files: $(REMAIN)))
Nishanth Menon03b397a2016-10-14 01:13:57 +0000638 $(eval $(foreach obj,$(DOBJS),$(call MAKE_DTB,$(1),$(obj))))
639
Soby Mathew38c14d82017-12-14 17:44:56 +0000640 $(eval $(call MAKE_FDT_DIRS,$(1),$(2)))
641
642dtbs: $(DTBS)
643all: dtbs
Nishanth Menon03b397a2016-10-14 01:13:57 +0000644endef