173c99d4eSJuan Castillo# 22d51b55eSBalint Dobszay# Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. 373c99d4eSJuan Castillo# 482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause 573c99d4eSJuan Castillo# 673c99d4eSJuan Castillo 71670d9dfSEvan Lloyd# Report an error if the eval make function is not available. 81670d9dfSEvan Lloyd$(eval eval_available := T) 91670d9dfSEvan Lloydifneq (${eval_available},T) 101670d9dfSEvan Lloyd $(error This makefile only works with a Make program that supports $$(eval)) 111670d9dfSEvan Lloydendif 121670d9dfSEvan Lloyd 13231c1470SEvan Lloyd# Some utility macros for manipulating awkward (whitespace) characters. 14231c1470SEvan Lloydblank := 15231c1470SEvan Lloydspace :=${blank} ${blank} 16231c1470SEvan Lloyd 17231c1470SEvan Lloyd# A user defined function to recursively search for a filename below a directory 18231c1470SEvan Lloyd# $1 is the directory root of the recursive search (blank for current directory). 19231c1470SEvan Lloyd# $2 is the file name to search for. 20231c1470SEvan Lloyddefine rwildcard 21231c1470SEvan Lloyd$(strip $(foreach d,$(wildcard ${1}*),$(call rwildcard,${d}/,${2}) $(filter $(subst *,%,%${2}),${d}))) 22231c1470SEvan Lloydendef 23231c1470SEvan Lloyd 245ba8f669SYatharth Kochar# This table is used in converting lower case to upper case. 255ba8f669SYatharth Kocharuppercase_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 265ba8f669SYatharth Kochar 275ba8f669SYatharth Kochar# Internal macro used for converting lower case to upper case. 285ba8f669SYatharth Kochar# $(1) = upper case table 295ba8f669SYatharth Kochar# $(2) = String to convert 305ba8f669SYatharth Kochardefine uppercase_internal 315ba8f669SYatharth Kochar$(if $(1),$$(subst $(firstword $(1)),$(call uppercase_internal,$(wordlist 2,$(words $(1)),$(1)),$(2))),$(2)) 325ba8f669SYatharth Kocharendef 335ba8f669SYatharth Kochar 345ba8f669SYatharth Kochar# A macro for converting a string to upper case 355ba8f669SYatharth Kochar# $(1) = String to convert 365ba8f669SYatharth Kochardefine uppercase 375ba8f669SYatharth Kochar$(eval uppercase_result:=$(call uppercase_internal,$(uppercase_table),$(1)))$(uppercase_result) 385ba8f669SYatharth Kocharendef 395ba8f669SYatharth Kochar 4073c99d4eSJuan Castillo# Convenience function for adding build definitions 4173c99d4eSJuan Castillo# $(eval $(call add_define,FOO)) will have: 4273c99d4eSJuan Castillo# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise 4373c99d4eSJuan Castillodefine add_define 4473c99d4eSJuan Castillo DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) 4573c99d4eSJuan Castilloendef 4673c99d4eSJuan Castillo 47*327131c4SLeonardo Sandoval 48*327131c4SLeonardo Sandoval# Convenience function for addding multiple build definitions 49*327131c4SLeonardo Sandoval# $(eval $(call add_defines,FOO BOO)) 50*327131c4SLeonardo Sandovaldefine add_defines 51*327131c4SLeonardo Sandoval $(foreach def,$1,$(eval $(call add_define,$(def)))) 52*327131c4SLeonardo Sandovalendef 53*327131c4SLeonardo Sandoval 548eadeb4aSSoren Brinkmann# Convenience function for adding build definitions 558eadeb4aSSoren Brinkmann# $(eval $(call add_define_val,FOO,BAR)) will have: 568eadeb4aSSoren Brinkmann# -DFOO=BAR 578eadeb4aSSoren Brinkmanndefine add_define_val 588eadeb4aSSoren Brinkmann DEFINES += -D$(1)=$(2) 598eadeb4aSSoren Brinkmannendef 608eadeb4aSSoren Brinkmann 6173c99d4eSJuan Castillo# Convenience function for verifying option has a boolean value 6273c99d4eSJuan Castillo# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1 6373c99d4eSJuan Castillodefine assert_boolean 64be4cd40eSMasahiro Yamada $(if $(filter-out 0 1,$($1)),$(error $1 must be boolean)) 6573c99d4eSJuan Castilloendef 6673c99d4eSJuan Castillo 67*327131c4SLeonardo Sandoval# Convenience function for verifying options have boolean values 68*327131c4SLeonardo Sandoval# $(eval $(call assert_booleans,FOO BOO)) will assert FOO and BOO for 0 or 1 values 69*327131c4SLeonardo Sandovaldefine assert_booleans 70*327131c4SLeonardo Sandoval $(foreach bool,$1,$(eval $(call assert_boolean,$(bool)))) 71*327131c4SLeonardo Sandovalendef 72*327131c4SLeonardo Sandoval 73c877b414SJeenu Viswambharan0-9 := 0 1 2 3 4 5 6 7 8 9 74c877b414SJeenu Viswambharan 75c877b414SJeenu Viswambharan# Function to verify that a given option $(1) contains a numeric value 76c877b414SJeenu Viswambharandefine assert_numeric 77c877b414SJeenu Viswambharan$(if $($(1)),,$(error $(1) must not be empty)) 78c877b414SJeenu Viswambharan$(eval __numeric := $($(1))) 79c877b414SJeenu Viswambharan$(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric)))) 80c877b414SJeenu Viswambharan$(if $(__numeric),$(error $(1) must be numeric)) 81c877b414SJeenu Viswambharanendef 82c877b414SJeenu Viswambharan 83*327131c4SLeonardo Sandoval# Convenience function for verifying options have numeric values 84*327131c4SLeonardo Sandoval# $(eval $(call assert_numerics,FOO BOO)) will assert FOO and BOO contain numeric values 85*327131c4SLeonardo Sandovaldefine assert_numerics 86*327131c4SLeonardo Sandoval $(foreach num,$1,$(eval $(call assert_numeric,$(num)))) 87*327131c4SLeonardo Sandovalendef 88*327131c4SLeonardo Sandoval 898c7b944aSVijayenthiran Subramaniam# CREATE_SEQ is a recursive function to create sequence of numbers from 1 to 908c7b944aSVijayenthiran Subramaniam# $(2) and assign the sequence to $(1) 918c7b944aSVijayenthiran Subramaniamdefine CREATE_SEQ 928c7b944aSVijayenthiran Subramaniam$(if $(word $(2), $($(1))),\ 938c7b944aSVijayenthiran Subramaniam $(eval $(1) += $(words $($(1))))\ 948c7b944aSVijayenthiran Subramaniam $(eval $(1) := $(filter-out 0,$($(1)))),\ 958c7b944aSVijayenthiran Subramaniam $(eval $(1) += $(words $($(1))))\ 968c7b944aSVijayenthiran Subramaniam $(call CREATE_SEQ,$(1),$(2))\ 978c7b944aSVijayenthiran Subramaniam) 988c7b944aSVijayenthiran Subramaniamendef 998c7b944aSVijayenthiran Subramaniam 10073c99d4eSJuan Castillo# IMG_LINKERFILE defines the linker script corresponding to a BL stage 101d7db9a6aSMasahiro Yamada# $(1) = BL stage (1, 2, 2u, 31, 32) 10273c99d4eSJuan Castillodefine IMG_LINKERFILE 10373c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).ld 10473c99d4eSJuan Castilloendef 10573c99d4eSJuan Castillo 10673c99d4eSJuan Castillo# IMG_MAPFILE defines the output file describing the memory map corresponding 10773c99d4eSJuan Castillo# to a BL stage 108d7db9a6aSMasahiro Yamada# $(1) = BL stage (1, 2, 2u, 31, 32) 10973c99d4eSJuan Castillodefine IMG_MAPFILE 11073c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).map 11173c99d4eSJuan Castilloendef 11273c99d4eSJuan Castillo 11373c99d4eSJuan Castillo# IMG_ELF defines the elf file corresponding to a BL stage 114d7db9a6aSMasahiro Yamada# $(1) = BL stage (1, 2, 2u, 31, 32) 11573c99d4eSJuan Castillodefine IMG_ELF 11673c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).elf 11773c99d4eSJuan Castilloendef 11873c99d4eSJuan Castillo 11973c99d4eSJuan Castillo# IMG_DUMP defines the symbols dump file corresponding to a BL stage 120d7db9a6aSMasahiro Yamada# $(1) = BL stage (1, 2, 2u, 31, 32) 12173c99d4eSJuan Castillodefine IMG_DUMP 12273c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).dump 12373c99d4eSJuan Castilloendef 12473c99d4eSJuan Castillo 12573c99d4eSJuan Castillo# IMG_BIN defines the default image file corresponding to a BL stage 126d7db9a6aSMasahiro Yamada# $(1) = BL stage (1, 2, 2u, 31, 32) 12773c99d4eSJuan Castillodefine IMG_BIN 12873c99d4eSJuan Castillo ${BUILD_PLAT}/bl$(1).bin 12973c99d4eSJuan Castilloendef 13073c99d4eSJuan Castillo 131c6ba9b45SSumit Garg# IMG_ENC_BIN defines the default encrypted image file corresponding to a 132c6ba9b45SSumit Garg# BL stage 133c6ba9b45SSumit Garg# $(1) = BL stage (2, 30, 31, 32, 33) 134c6ba9b45SSumit Gargdefine IMG_ENC_BIN 135c6ba9b45SSumit Garg ${BUILD_PLAT}/bl$(1)_enc.bin 136c6ba9b45SSumit Gargendef 137c6ba9b45SSumit Garg 138c6ba9b45SSumit Garg# ENCRYPT_FW invokes enctool to encrypt firmware binary 139c6ba9b45SSumit Garg# $(1) = input firmware binary 140c6ba9b45SSumit Garg# $(2) = output encrypted firmware binary 141c6ba9b45SSumit Gargdefine ENCRYPT_FW 142c6ba9b45SSumit Garg$(2): $(1) enctool 143c6ba9b45SSumit Garg $$(ECHO) " ENC $$<" 144c6ba9b45SSumit Garg $$(Q)$$(ENCTOOL) $$(ENC_ARGS) -i $$< -o $$@ 145c6ba9b45SSumit Gargendef 146c6ba9b45SSumit Garg 14710cea934SMasahiro Yamada# TOOL_ADD_PAYLOAD appends the command line arguments required by fiptool to 14810cea934SMasahiro Yamada# package a new payload and/or by cert_create to generate certificate. 14910cea934SMasahiro Yamada# Optionally, it adds the dependency on this payload 15073c99d4eSJuan Castillo# $(1) = payload filename (i.e. bl31.bin) 1511e0c0784SMasahiro Yamada# $(2) = command line option for the specified payload (i.e. --soc-fw) 15236af3455SMasahiro Yamada# $(3) = tool target dependency (optional) (ex. build/fvp/release/bl31.bin) 1531dc0714fSMasahiro Yamada# $(4) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip) 154c6ba9b45SSumit Garg# $(5) = encrypted payload (optional) (ex. build/fvp/release/bl31_enc.bin) 15510cea934SMasahiro Yamadadefine TOOL_ADD_PAYLOAD 156c6ba9b45SSumit Gargifneq ($(5),) 157c6ba9b45SSumit Garg $(4)FIP_ARGS += $(2) $(5) 158c6ba9b45SSumit Garg $(if $(3),$(4)CRT_DEPS += $(1)) 159c6ba9b45SSumit Gargelse 160945b316fSMasahiro Yamada $(4)FIP_ARGS += $(2) $(1) 161c6ba9b45SSumit Garg $(if $(3),$(4)CRT_DEPS += $(3)) 162c6ba9b45SSumit Gargendif 163945b316fSMasahiro Yamada $(if $(3),$(4)FIP_DEPS += $(3)) 164f30ee0b9SMasahiro Yamada $(4)CRT_ARGS += $(2) $(1) 16573c99d4eSJuan Castilloendef 16673c99d4eSJuan Castillo 1672da522bbSMasahiro Yamada# TOOL_ADD_IMG_PAYLOAD works like TOOL_ADD_PAYLOAD, but applies image filters 1682da522bbSMasahiro Yamada# before passing them to host tools if BL*_PRE_TOOL_FILTER is defined. 1692da522bbSMasahiro Yamada# $(1) = image_type (scp_bl2, bl33, etc.) 1702da522bbSMasahiro Yamada# $(2) = payload filepath (ex. build/fvp/release/bl31.bin) 1712da522bbSMasahiro Yamada# $(3) = command line option for the specified payload (ex. --soc-fw) 1722da522bbSMasahiro Yamada# $(4) = tool target dependency (optional) (ex. build/fvp/release/bl31.bin) 1732da522bbSMasahiro Yamada# $(5) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip) 174c6ba9b45SSumit Garg# $(6) = encrypted payload (optional) (ex. build/fvp/release/bl31_enc.bin) 1752da522bbSMasahiro Yamada 1762da522bbSMasahiro Yamadadefine TOOL_ADD_IMG_PAYLOAD 1772da522bbSMasahiro Yamada 1782da522bbSMasahiro Yamada$(eval PRE_TOOL_FILTER := $($(call uppercase,$(1))_PRE_TOOL_FILTER)) 1792da522bbSMasahiro Yamada 1802da522bbSMasahiro Yamadaifneq ($(PRE_TOOL_FILTER),) 1812da522bbSMasahiro Yamada 1822da522bbSMasahiro Yamada$(eval PROCESSED_PATH := $(BUILD_PLAT)/$(1).bin$($(PRE_TOOL_FILTER)_SUFFIX)) 1832da522bbSMasahiro Yamada 1842da522bbSMasahiro Yamada$(call $(PRE_TOOL_FILTER)_RULE,$(PROCESSED_PATH),$(2)) 1852da522bbSMasahiro Yamada 1862da522bbSMasahiro Yamada$(PROCESSED_PATH): $(4) 1872da522bbSMasahiro Yamada 188c6ba9b45SSumit Garg$(call TOOL_ADD_PAYLOAD,$(PROCESSED_PATH),$(3),$(PROCESSED_PATH),$(5),$(6)) 1892da522bbSMasahiro Yamada 1902da522bbSMasahiro Yamadaelse 191c6ba9b45SSumit Garg$(call TOOL_ADD_PAYLOAD,$(2),$(3),$(4),$(5),$(6)) 1922da522bbSMasahiro Yamadaendif 1932da522bbSMasahiro Yamadaendef 1942da522bbSMasahiro Yamada 1950191262dSYatharth Kochar# CERT_ADD_CMD_OPT adds a new command line option to the cert_create invocation 19673c99d4eSJuan Castillo# $(1) = parameter filename 19773c99d4eSJuan Castillo# $(2) = cert_create command line option for the specified parameter 19891704d9dSMasahiro Yamada# $(3) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip) 19973c99d4eSJuan Castillodefine CERT_ADD_CMD_OPT 20091704d9dSMasahiro Yamada $(3)CRT_ARGS += $(2) $(1) 20173c99d4eSJuan Castilloendef 20273c99d4eSJuan Castillo 203c939d13aSMasahiro Yamada# TOOL_ADD_IMG allows the platform to specify an external image to be packed 204c939d13aSMasahiro Yamada# in the FIP and/or for which certificate is generated. It also adds a 205c939d13aSMasahiro Yamada# dependency on the image file, aborting the build if the file does not exist. 20633950dd8SMasahiro Yamada# $(1) = image_type (scp_bl2, bl33, etc.) 2071e0c0784SMasahiro Yamada# $(2) = command line option for fiptool (--scp-fw, --nt-fw, etc) 2081dc0714fSMasahiro Yamada# $(3) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip) 209c6ba9b45SSumit Garg# $(4) = Image encryption flag (optional) (0, 1) 21073c99d4eSJuan Castillo# Example: 21133950dd8SMasahiro Yamada# $(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 212c939d13aSMasahiro Yamadadefine TOOL_ADD_IMG 21333950dd8SMasahiro Yamada # Build option to specify the image filename (SCP_BL2, BL33, etc) 21433950dd8SMasahiro Yamada # This is the uppercase form of the first parameter 21533950dd8SMasahiro Yamada $(eval _V := $(call uppercase,$(1))) 21633950dd8SMasahiro Yamada 217945b316fSMasahiro Yamada $(3)CRT_DEPS += check_$(1) 218945b316fSMasahiro Yamada $(3)FIP_DEPS += check_$(1) 219c6ba9b45SSumit Gargifeq ($(4),1) 220c6ba9b45SSumit Garg $(eval ENC_BIN := ${BUILD_PLAT}/$(1)_enc.bin) 221c6ba9b45SSumit Garg $(call ENCRYPT_FW,$(value $(_V)),$(ENC_BIN)) 222c6ba9b45SSumit Garg $(call TOOL_ADD_IMG_PAYLOAD,$(1),$(value $(_V)),$(2),$(ENC_BIN),$(3), \ 223c6ba9b45SSumit Garg $(ENC_BIN)) 224c6ba9b45SSumit Gargelse 2252da522bbSMasahiro Yamada $(call TOOL_ADD_IMG_PAYLOAD,$(1),$(value $(_V)),$(2),,$(3)) 226c6ba9b45SSumit Gargendif 2270191262dSYatharth Kochar 22887ebd20dSMasahiro Yamada.PHONY: check_$(1) 2290191262dSYatharth Kocharcheck_$(1): 23033950dd8SMasahiro Yamada $$(if $(value $(_V)),,$$(error "Platform '${PLAT}' requires $(_V). Please set $(_V) to point to the right file")) 23133950dd8SMasahiro Yamada $$(if $(wildcard $(value $(_V))),,$$(error '$(_V)=$(value $(_V))' was specified, but '$(value $(_V))' does not exist)) 2320191262dSYatharth Kocharendef 23373c99d4eSJuan Castillo 23473c99d4eSJuan Castillo################################################################################ 23514db8908SMasahiro Yamada# Generic image processing filters 23614db8908SMasahiro Yamada################################################################################ 23714db8908SMasahiro Yamada 23814db8908SMasahiro Yamada# GZIP 23914db8908SMasahiro Yamadadefine GZIP_RULE 24014db8908SMasahiro Yamada$(1): $(2) 241ee1ba6d4SAndre Przywara $(ECHO) " GZIP $$@" 24214db8908SMasahiro Yamada $(Q)gzip -n -f -9 $$< --stdout > $$@ 24314db8908SMasahiro Yamadaendef 24414db8908SMasahiro Yamada 24514db8908SMasahiro YamadaGZIP_SUFFIX := .gz 24614db8908SMasahiro Yamada 24714db8908SMasahiro Yamada################################################################################ 24873c99d4eSJuan Castillo# Auxiliary macros to build TF images from sources 24973c99d4eSJuan Castillo################################################################################ 25073c99d4eSJuan Castillo 2511d274ab0SMasahiro YamadaMAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ -MP 25273c99d4eSJuan Castillo 2535fee0287SRoberto Vargas 2545fee0287SRoberto Vargas# MAKE_C_LIB builds a C source file and generates the dependency file 2555fee0287SRoberto Vargas# $(1) = output directory 2565fee0287SRoberto Vargas# $(2) = source file (%.c) 2575fee0287SRoberto Vargas# $(3) = library name 2585fee0287SRoberto Vargasdefine MAKE_C_LIB 2595fee0287SRoberto Vargas$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) 2605fee0287SRoberto Vargas$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 2615fee0287SRoberto Vargas 2625fee0287SRoberto Vargas$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | lib$(3)_dirs 263ee1ba6d4SAndre Przywara $$(ECHO) " CC $$<" 2645fee0287SRoberto Vargas $$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) $(MAKE_DEP) -c $$< -o $$@ 2655fee0287SRoberto Vargas 2665fee0287SRoberto Vargas-include $(DEP) 2675fee0287SRoberto Vargas 2685fee0287SRoberto Vargasendef 2695fee0287SRoberto Vargas 27070b0f278SAntonio Nino Diaz# MAKE_S_LIB builds an assembly source file and generates the dependency file 27170b0f278SAntonio Nino Diaz# $(1) = output directory 27270b0f278SAntonio Nino Diaz# $(2) = source file (%.S) 27370b0f278SAntonio Nino Diaz# $(3) = library name 27470b0f278SAntonio Nino Diazdefine MAKE_S_LIB 27570b0f278SAntonio Nino Diaz$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) 27670b0f278SAntonio Nino Diaz$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 27770b0f278SAntonio Nino Diaz 27870b0f278SAntonio Nino Diaz$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | lib$(3)_dirs 27970b0f278SAntonio Nino Diaz $$(ECHO) " AS $$<" 28070b0f278SAntonio Nino Diaz $$(Q)$$(AS) $$(ASFLAGS) $(MAKE_DEP) -c $$< -o $$@ 28170b0f278SAntonio Nino Diaz 28270b0f278SAntonio Nino Diaz-include $(DEP) 28370b0f278SAntonio Nino Diaz 28470b0f278SAntonio Nino Diazendef 28570b0f278SAntonio Nino Diaz 2865fee0287SRoberto Vargas 28773c99d4eSJuan Castillo# MAKE_C builds a C source file and generates the dependency file 28873c99d4eSJuan Castillo# $(1) = output directory 28973c99d4eSJuan Castillo# $(2) = source file (%.c) 290d7db9a6aSMasahiro Yamada# $(3) = BL stage (1, 2, 2u, 31, 32) 29173c99d4eSJuan Castillodefine MAKE_C 29273c99d4eSJuan Castillo 29373c99d4eSJuan Castillo$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) 294710ea1d0SMasahiro Yamada$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 295848a7e8cSMasahiro Yamada$(eval BL_CPPFLAGS := $(BL$(call uppercase,$(3))_CPPFLAGS) -DIMAGE_BL$(call uppercase,$(3))) 2963661f16cSJeenu Viswambharan$(eval BL_CFLAGS := $(BL$(call uppercase,$(3))_CFLAGS)) 29773c99d4eSJuan Castillo 2986bc1a30cSStephen Warren$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | bl$(3)_dirs 299ee1ba6d4SAndre Przywara $$(ECHO) " CC $$<" 300848a7e8cSMasahiro Yamada $$(Q)$$(CC) $$(LTO_CFLAGS) $$(TF_CFLAGS) $$(CFLAGS) $(BL_CPPFLAGS) $(BL_CFLAGS) $(MAKE_DEP) -c $$< -o $$@ 30173c99d4eSJuan Castillo 302710ea1d0SMasahiro Yamada-include $(DEP) 30373c99d4eSJuan Castillo 30473c99d4eSJuan Castilloendef 30573c99d4eSJuan Castillo 30673c99d4eSJuan Castillo 30773c99d4eSJuan Castillo# MAKE_S builds an assembly source file and generates the dependency file 30873c99d4eSJuan Castillo# $(1) = output directory 30973c99d4eSJuan Castillo# $(2) = assembly file (%.S) 310d7db9a6aSMasahiro Yamada# $(3) = BL stage (1, 2, 2u, 31, 32) 31173c99d4eSJuan Castillodefine MAKE_S 31273c99d4eSJuan Castillo 31373c99d4eSJuan Castillo$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) 314710ea1d0SMasahiro Yamada$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 315848a7e8cSMasahiro Yamada$(eval BL_CPPFLAGS := $(BL$(call uppercase,$(3))_CPPFLAGS) -DIMAGE_BL$(call uppercase,$(3))) 316848a7e8cSMasahiro Yamada$(eval BL_ASFLAGS := $(BL$(call uppercase,$(3))_ASFLAGS)) 31773c99d4eSJuan Castillo 3186bc1a30cSStephen Warren$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | bl$(3)_dirs 319ee1ba6d4SAndre Przywara $$(ECHO) " AS $$<" 320848a7e8cSMasahiro Yamada $$(Q)$$(AS) $$(ASFLAGS) $(BL_CPPFLAGS) $(BL_ASFLAGS) $(MAKE_DEP) -c $$< -o $$@ 32173c99d4eSJuan Castillo 322710ea1d0SMasahiro Yamada-include $(DEP) 32373c99d4eSJuan Castillo 32473c99d4eSJuan Castilloendef 32573c99d4eSJuan Castillo 32673c99d4eSJuan Castillo 32773c99d4eSJuan Castillo# MAKE_LD generate the linker script using the C preprocessor 32873c99d4eSJuan Castillo# $(1) = output linker script 32973c99d4eSJuan Castillo# $(2) = input template 330d7db9a6aSMasahiro Yamada# $(3) = BL stage (1, 2, 2u, 31, 32) 33173c99d4eSJuan Castillodefine MAKE_LD 33273c99d4eSJuan Castillo 333710ea1d0SMasahiro Yamada$(eval DEP := $(1).d) 334848a7e8cSMasahiro Yamada$(eval BL_CPPFLAGS := $(BL$(call uppercase,$(3))_CPPFLAGS) -DIMAGE_BL$(call uppercase,$(3))) 33573c99d4eSJuan Castillo 3366bc1a30cSStephen Warren$(1): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | bl$(3)_dirs 337ee1ba6d4SAndre Przywara $$(ECHO) " PP $$<" 338848a7e8cSMasahiro Yamada $$(Q)$$(CPP) $$(CPPFLAGS) $(BL_CPPFLAGS) $(TF_CFLAGS_$(ARCH)) -P -x assembler-with-cpp -D__LINKER__ $(MAKE_DEP) -o $$@ $$< 33973c99d4eSJuan Castillo 340710ea1d0SMasahiro Yamada-include $(DEP) 34173c99d4eSJuan Castillo 34273c99d4eSJuan Castilloendef 34373c99d4eSJuan Castillo 34470b0f278SAntonio Nino Diaz# MAKE_LIB_OBJS builds both C and assembly source files 3455fee0287SRoberto Vargas# $(1) = output directory 3465fee0287SRoberto Vargas# $(2) = list of source files 3475fee0287SRoberto Vargas# $(3) = name of the library 3485fee0287SRoberto Vargasdefine MAKE_LIB_OBJS 3495fee0287SRoberto Vargas $(eval C_OBJS := $(filter %.c,$(2))) 3505fee0287SRoberto Vargas $(eval REMAIN := $(filter-out %.c,$(2))) 3515fee0287SRoberto Vargas $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C_LIB,$(1),$(obj),$(3)))) 3525fee0287SRoberto Vargas 35370b0f278SAntonio Nino Diaz $(eval S_OBJS := $(filter %.S,$(REMAIN))) 35470b0f278SAntonio Nino Diaz $(eval REMAIN := $(filter-out %.S,$(REMAIN))) 35570b0f278SAntonio Nino Diaz $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S_LIB,$(1),$(obj),$(3)))) 35670b0f278SAntonio Nino Diaz 3575fee0287SRoberto Vargas $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN))) 3585fee0287SRoberto Vargasendef 3595fee0287SRoberto Vargas 36073c99d4eSJuan Castillo 36173c99d4eSJuan Castillo# MAKE_OBJS builds both C and assembly source files 36273c99d4eSJuan Castillo# $(1) = output directory 36373c99d4eSJuan Castillo# $(2) = list of source files (both C and assembly) 364d7db9a6aSMasahiro Yamada# $(3) = BL stage (1, 2, 2u, 31, 32) 36573c99d4eSJuan Castillodefine MAKE_OBJS 36673c99d4eSJuan Castillo $(eval C_OBJS := $(filter %.c,$(2))) 36773c99d4eSJuan Castillo $(eval REMAIN := $(filter-out %.c,$(2))) 36873c99d4eSJuan Castillo $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3)))) 36973c99d4eSJuan Castillo 37073c99d4eSJuan Castillo $(eval S_OBJS := $(filter %.S,$(REMAIN))) 37173c99d4eSJuan Castillo $(eval REMAIN := $(filter-out %.S,$(REMAIN))) 37273c99d4eSJuan Castillo $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3)))) 37373c99d4eSJuan Castillo 37473c99d4eSJuan Castillo $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN))) 37573c99d4eSJuan Castilloendef 37673c99d4eSJuan Castillo 37773c99d4eSJuan Castillo 37873c99d4eSJuan Castillo# NOTE: The line continuation '\' is required in the next define otherwise we 37973c99d4eSJuan Castillo# end up with a line-feed characer at the end of the last c filename. 380e7f54dbdSEvan Lloyd# Also bear this issue in mind if extending the list of supported filetypes. 38173c99d4eSJuan Castillodefine SOURCES_TO_OBJS 38273c99d4eSJuan Castillo $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \ 38373c99d4eSJuan Castillo $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1)))) 38473c99d4eSJuan Castilloendef 38573c99d4eSJuan Castillo 3862f5d4a48SPatrick Georgi# Allow overriding the timestamp, for example for reproducible builds, or to 3872f5d4a48SPatrick Georgi# synchronize timestamps across multiple projects. 3882f5d4a48SPatrick Georgi# This must be set to a C string (including quotes where applicable). 3892f5d4a48SPatrick GeorgiBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ 39073c99d4eSJuan Castillo 3915fee0287SRoberto Vargas.PHONY: libraries 3925fee0287SRoberto Vargas 3935accce5bSRoberto Vargas# MAKE_LIB_DIRS macro defines the target for the directory where 3945fee0287SRoberto Vargas# libraries are created 3955accce5bSRoberto Vargasdefine MAKE_LIB_DIRS 3965fee0287SRoberto Vargas $(eval LIB_DIR := ${BUILD_PLAT}/lib) 3975accce5bSRoberto Vargas $(eval ROMLIB_DIR := ${BUILD_PLAT}/romlib) 3985accce5bSRoberto Vargas $(eval LIBWRAPPER_DIR := ${BUILD_PLAT}/libwrapper) 3995fee0287SRoberto Vargas $(eval $(call MAKE_PREREQ_DIR,${LIB_DIR},${BUILD_PLAT})) 4005accce5bSRoberto Vargas $(eval $(call MAKE_PREREQ_DIR,${ROMLIB_DIR},${BUILD_PLAT})) 4015accce5bSRoberto Vargas $(eval $(call MAKE_PREREQ_DIR,${LIBWRAPPER_DIR},${BUILD_PLAT})) 4025fee0287SRoberto Vargasendef 4035fee0287SRoberto Vargas 4045fee0287SRoberto Vargas# MAKE_LIB macro defines the targets and options to build each BL image. 4055fee0287SRoberto Vargas# Arguments: 4065fee0287SRoberto Vargas# $(1) = Library name 4075fee0287SRoberto Vargasdefine MAKE_LIB 4085fee0287SRoberto Vargas $(eval BUILD_DIR := ${BUILD_PLAT}/lib$(1)) 4095fee0287SRoberto Vargas $(eval LIB_DIR := ${BUILD_PLAT}/lib) 4105accce5bSRoberto Vargas $(eval ROMLIB_DIR := ${BUILD_PLAT}/romlib) 4115fee0287SRoberto Vargas $(eval SOURCES := $(LIB$(call uppercase,$(1))_SRCS)) 4125fee0287SRoberto Vargas $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES)))) 4135fee0287SRoberto Vargas 4145fee0287SRoberto Vargas$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT})) 4155fee0287SRoberto Vargas$(eval $(call MAKE_LIB_OBJS,$(BUILD_DIR),$(SOURCES),$(1))) 4165fee0287SRoberto Vargas 4175fee0287SRoberto Vargas.PHONY : lib${1}_dirs 4185accce5bSRoberto Vargaslib${1}_dirs: | ${BUILD_DIR} ${LIB_DIR} ${ROMLIB_DIR} ${LIBWRAPPER_DIR} 4195fee0287SRoberto Vargaslibraries: ${LIB_DIR}/lib$(1).a 420c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 421c2ad38ceSVarun WadekarLDPATHS = --userlibpath=${LIB_DIR} 422c2ad38ceSVarun WadekarLDLIBS += --library=$(1) 423c2ad38ceSVarun Wadekarelse 4245fee0287SRoberto VargasLDPATHS = -L${LIB_DIR} 4255fee0287SRoberto VargasLDLIBS += -l$(1) 426c2ad38ceSVarun Wadekarendif 4275fee0287SRoberto Vargas 4285accce5bSRoberto Vargasifeq ($(USE_ROMLIB),1) 4296baf85b3SSathees BalyaLIBWRAPPER = -lwrappers 4305accce5bSRoberto Vargasendif 4315accce5bSRoberto Vargas 4325fee0287SRoberto Vargasall: ${LIB_DIR}/lib$(1).a 4335fee0287SRoberto Vargas 4345fee0287SRoberto Vargas${LIB_DIR}/lib$(1).a: $(OBJS) 435ee1ba6d4SAndre Przywara $$(ECHO) " AR $$@" 4365fee0287SRoberto Vargas $$(Q)$$(AR) cr $$@ $$? 4375fee0287SRoberto Vargasendef 4385fee0287SRoberto Vargas 43973c99d4eSJuan Castillo# MAKE_BL macro defines the targets and options to build each BL image. 44073c99d4eSJuan Castillo# Arguments: 441d7db9a6aSMasahiro Yamada# $(1) = BL stage (1, 2, 2u, 31, 32) 4428f0617efSJuan Castillo# $(2) = FIP command line option (if empty, image will not be included in the FIP) 4431dc0714fSMasahiro Yamada# $(3) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip) 444c6ba9b45SSumit Garg# $(4) = BL encryption flag (optional) (0, 1) 44573c99d4eSJuan Castillodefine MAKE_BL 44673c99d4eSJuan Castillo $(eval BUILD_DIR := ${BUILD_PLAT}/bl$(1)) 4475ba8f669SYatharth Kochar $(eval BL_SOURCES := $(BL$(call uppercase,$(1))_SOURCES)) 4485ba8f669SYatharth Kochar $(eval SOURCES := $(BL_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES)) 44973c99d4eSJuan Castillo $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES)))) 45073c99d4eSJuan Castillo $(eval LINKERFILE := $(call IMG_LINKERFILE,$(1))) 45173c99d4eSJuan Castillo $(eval MAPFILE := $(call IMG_MAPFILE,$(1))) 45273c99d4eSJuan Castillo $(eval ELF := $(call IMG_ELF,$(1))) 45373c99d4eSJuan Castillo $(eval DUMP := $(call IMG_DUMP,$(1))) 45473c99d4eSJuan Castillo $(eval BIN := $(call IMG_BIN,$(1))) 455c6ba9b45SSumit Garg $(eval ENC_BIN := $(call IMG_ENC_BIN,$(1))) 4565ba8f669SYatharth Kochar $(eval BL_LINKERFILE := $(BL$(call uppercase,$(1))_LINKERFILE)) 45723e0fe52SKonstantin Porotchkin $(eval BL_LIBS := $(BL$(call uppercase,$(1))_LIBS)) 45851b27702SEvan Lloyd # We use sort only to get a list of unique object directory names. 45951b27702SEvan Lloyd # ordering is not relevant but sort removes duplicates. 4606ba7d274SEvan Lloyd $(eval TEMP_OBJ_DIRS := $(sort $(dir ${OBJS} ${LINKERFILE}))) 46151b27702SEvan Lloyd # The $(dir ) function leaves a trailing / on the directory names 462d014ea6cSMasahiro Yamada # Rip off the / to match directory names with make rule targets. 463d014ea6cSMasahiro Yamada $(eval OBJ_DIRS := $(patsubst %/,%,$(TEMP_OBJ_DIRS))) 46451b27702SEvan Lloyd 46551b27702SEvan Lloyd# Create generators for object directory structure 46651b27702SEvan Lloyd 4678012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT})) 4686ba7d274SEvan Lloyd 4696ba7d274SEvan Lloyd$(eval $(foreach objd,${OBJ_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR}))) 47051b27702SEvan Lloyd 47151b27702SEvan Lloyd.PHONY : bl${1}_dirs 47251b27702SEvan Lloyd 47351b27702SEvan Lloyd# We use order-only prerequisites to ensure that directories are created, 47451b27702SEvan Lloyd# but do not cause re-builds every time a file is written. 47551b27702SEvan Lloydbl${1}_dirs: | ${OBJ_DIRS} 47673c99d4eSJuan Castillo 47773c99d4eSJuan Castillo$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1))) 478a6ca7888SMasahiro Yamada$(eval $(call MAKE_LD,$(LINKERFILE),$(BL_LINKERFILE),$(1))) 479d986bae4SMasahiro Yamada$(eval BL_LDFLAGS := $(BL$(call uppercase,$(1))_LDFLAGS)) 48073c99d4eSJuan Castillo 4815accce5bSRoberto Vargasifeq ($(USE_ROMLIB),1) 4825accce5bSRoberto Vargas$(ELF): romlib.bin 4835accce5bSRoberto Vargasendif 4845accce5bSRoberto Vargas 4855fee0287SRoberto Vargas$(ELF): $(OBJS) $(LINKERFILE) | bl$(1)_dirs libraries $(BL_LIBS) 486ee1ba6d4SAndre Przywara $$(ECHO) " LD $$@" 487414ab853SEvan Lloydifdef MAKE_BUILD_STRINGS 488414ab853SEvan Lloyd $(call MAKE_BUILD_STRINGS, $(BUILD_DIR)/build_message.o) 489414ab853SEvan Lloydelse 4902f5d4a48SPatrick Georgi @echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP); \ 49173c99d4eSJuan Castillo const char version_string[] = "${VERSION_STRING}";' | \ 492f2e1d57eSMasahiro Yamada $$(CC) $$(TF_CFLAGS) $$(CFLAGS) -xc -c - -o $(BUILD_DIR)/build_message.o 493414ab853SEvan Lloydendif 494c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 495d986bae4SMasahiro Yamada $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) --entry=bl${1}_entrypoint \ 496c2ad38ceSVarun Wadekar --predefine="-D__LINKER__=$(__LINKER__)" \ 497c2ad38ceSVarun Wadekar --predefine="-DTF_CFLAGS=$(TF_CFLAGS)" \ 498c2ad38ceSVarun Wadekar --map --list="$(MAPFILE)" --scatter=${PLAT_DIR}/scat/bl${1}.scat \ 499c2ad38ceSVarun Wadekar $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) \ 500c2ad38ceSVarun Wadekar $(BUILD_DIR)/build_message.o $(OBJS) 501edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 502edbce9aaSzelalem-aweke $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Wl,-Map=$(MAPFILE) \ 503edbce9aaSzelalem-aweke -Wl,-T$(LINKERFILE) $(BUILD_DIR)/build_message.o \ 504edbce9aaSzelalem-aweke $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) 505c2ad38ceSVarun Wadekarelse 506d986bae4SMasahiro Yamada $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) -Map=$(MAPFILE) \ 5075fee0287SRoberto Vargas --script $(LINKERFILE) $(BUILD_DIR)/build_message.o \ 5086baf85b3SSathees Balya $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) 509c2ad38ceSVarun Wadekarendif 5109e4609f1SChristoph Müllnerifeq ($(DISABLE_BIN_GENERATION),1) 5119e4609f1SChristoph Müllner @${ECHO_BLANK_LINE} 5129e4609f1SChristoph Müllner @echo "Built $$@ successfully" 5139e4609f1SChristoph Müllner @${ECHO_BLANK_LINE} 5149e4609f1SChristoph Müllnerendif 51573c99d4eSJuan Castillo 51673c99d4eSJuan Castillo$(DUMP): $(ELF) 517ee1ba6d4SAndre Przywara $${ECHO} " OD $$@" 51873c99d4eSJuan Castillo $${Q}$${OD} -dx $$< > $$@ 51973c99d4eSJuan Castillo 52073c99d4eSJuan Castillo$(BIN): $(ELF) 521ee1ba6d4SAndre Przywara $${ECHO} " BIN $$@" 52273c99d4eSJuan Castillo $$(Q)$$(OC) -O binary $$< $$@ 523052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 52473c99d4eSJuan Castillo @echo "Built $$@ successfully" 525052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 52673c99d4eSJuan Castillo 52773c99d4eSJuan Castillo.PHONY: bl$(1) 5289e4609f1SChristoph Müllnerifeq ($(DISABLE_BIN_GENERATION),1) 5299e4609f1SChristoph Müllnerbl$(1): $(ELF) $(DUMP) 5309e4609f1SChristoph Müllnerelse 53151b27702SEvan Lloydbl$(1): $(BIN) $(DUMP) 5329e4609f1SChristoph Müllnerendif 53373c99d4eSJuan Castillo 53473c99d4eSJuan Castilloall: bl$(1) 53573c99d4eSJuan Castillo 536c6ba9b45SSumit Gargifeq ($(4),1) 537c6ba9b45SSumit Garg$(call ENCRYPT_FW,$(BIN),$(ENC_BIN)) 538c6ba9b45SSumit Garg$(if $(2),$(call TOOL_ADD_IMG_PAYLOAD,bl$(1),$(BIN),--$(2),$(ENC_BIN),$(3), \ 539c6ba9b45SSumit Garg $(ENC_BIN))) 540c6ba9b45SSumit Gargelse 5412da522bbSMasahiro Yamada$(if $(2),$(call TOOL_ADD_IMG_PAYLOAD,bl$(1),$(BIN),--$(2),$(BIN),$(3))) 542c6ba9b45SSumit Gargendif 54373c99d4eSJuan Castillo 54473c99d4eSJuan Castilloendef 54573c99d4eSJuan Castillo 54638c14d88SSoby Mathew# Convert device tree source file names to matching blobs 54738c14d88SSoby Mathew# $(1) = input dts 54803b397a8SNishanth Menondefine SOURCES_TO_DTBS 54903b397a8SNishanth Menon $(notdir $(patsubst %.dts,%.dtb,$(filter %.dts,$(1)))) 55003b397a8SNishanth Menonendef 55103b397a8SNishanth Menon 55238c14d88SSoby Mathew# MAKE_FDT_DIRS macro creates the prerequisite directories that host the 55338c14d88SSoby Mathew# FDT binaries 55438c14d88SSoby Mathew# $(1) = output directory 55538c14d88SSoby Mathew# $(2) = input dts 55638c14d88SSoby Mathewdefine MAKE_FDT_DIRS 55738c14d88SSoby Mathew $(eval DTBS := $(addprefix $(1)/,$(call SOURCES_TO_DTBS,$(2)))) 55803b397a8SNishanth Menon $(eval TEMP_DTB_DIRS := $(sort $(dir ${DTBS}))) 55903b397a8SNishanth Menon # The $(dir ) function leaves a trailing / on the directory names 56003b397a8SNishanth Menon # Rip off the / to match directory names with make rule targets. 56103b397a8SNishanth Menon $(eval DTB_DIRS := $(patsubst %/,%,$(TEMP_DTB_DIRS))) 56203b397a8SNishanth Menon 56303b397a8SNishanth Menon$(eval $(foreach objd,${DTB_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR}))) 56403b397a8SNishanth Menon 56503b397a8SNishanth Menonfdt_dirs: ${DTB_DIRS} 56603b397a8SNishanth Menonendef 56703b397a8SNishanth Menon 56838c14d88SSoby Mathew# MAKE_DTB generate the Flattened device tree binary 56903b397a8SNishanth Menon# $(1) = output directory 57003b397a8SNishanth Menon# $(2) = input dts 57103b397a8SNishanth Menondefine MAKE_DTB 57203b397a8SNishanth Menon 573077b3e9aSYann Gautier# List of DTB file(s) to generate, based on DTS file basename list 57438c14d88SSoby Mathew$(eval DOBJ := $(addprefix $(1)/,$(call SOURCES_TO_DTBS,$(2)))) 575077b3e9aSYann Gautier# List of the pre-compiled DTS file(s) 57601d237cbSYann Gautier$(eval DPRE := $(addprefix $(1)/,$(patsubst %.dts,%.pre.dts,$(notdir $(2))))) 577077b3e9aSYann Gautier# Dependencies of the pre-compiled DTS file(s) on its source and included files 578077b3e9aSYann Gautier$(eval DTSDEP := $(patsubst %.dtb,%.o.d,$(DOBJ))) 579077b3e9aSYann Gautier# Dependencies of the DT compilation on its pre-compiled DTS 580077b3e9aSYann Gautier$(eval DTBDEP := $(patsubst %.dtb,%.d,$(DOBJ))) 58103b397a8SNishanth Menon 5826bc1a30cSStephen Warren$(DOBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | fdt_dirs 583ee1ba6d4SAndre Przywara $${ECHO} " CPP $$<" 584077b3e9aSYann Gautier $(eval DTBS := $(addprefix $(1)/,$(call SOURCES_TO_DTBS,$(2)))) 5857e94a699SManish Pandey $$(Q)$$(PP) $$(DTC_CPPFLAGS) -MT $(DTBS) -MMD -MF $(DTSDEP) -o $(DPRE) $$< 586ee1ba6d4SAndre Przywara $${ECHO} " DTC $$<" 5872d51b55eSBalint Dobszay $$(Q)$$(DTC) $$(DTC_FLAGS) -d $(DTBDEP) -o $$@ $(DPRE) 58803b397a8SNishanth Menon 589077b3e9aSYann Gautier-include $(DTBDEP) 590077b3e9aSYann Gautier-include $(DTSDEP) 59103b397a8SNishanth Menon 59203b397a8SNishanth Menonendef 59303b397a8SNishanth Menon 59403b397a8SNishanth Menon# MAKE_DTBS builds flattened device tree sources 59503b397a8SNishanth Menon# $(1) = output directory 59603b397a8SNishanth Menon# $(2) = list of flattened device tree source files 59703b397a8SNishanth Menondefine MAKE_DTBS 59803b397a8SNishanth Menon $(eval DOBJS := $(filter %.dts,$(2))) 59903b397a8SNishanth Menon $(eval REMAIN := $(filter-out %.dts,$(2))) 60038c14d88SSoby Mathew $(and $(REMAIN),$(error FDT_SOURCES contain non-DTS files: $(REMAIN))) 60103b397a8SNishanth Menon $(eval $(foreach obj,$(DOBJS),$(call MAKE_DTB,$(1),$(obj)))) 60203b397a8SNishanth Menon 60338c14d88SSoby Mathew $(eval $(call MAKE_FDT_DIRS,$(1),$(2))) 60438c14d88SSoby Mathew 60538c14d88SSoby Mathewdtbs: $(DTBS) 60638c14d88SSoby Mathewall: dtbs 60703b397a8SNishanth Menonendef 608