173c99d4eSJuan Castillo# 2231c1470SEvan Lloyd# Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. 373c99d4eSJuan Castillo# 473c99d4eSJuan Castillo# Redistribution and use in source and binary forms, with or without 573c99d4eSJuan Castillo# modification, are permitted provided that the following conditions are met: 673c99d4eSJuan Castillo# 773c99d4eSJuan Castillo# Redistributions of source code must retain the above copyright notice, this 873c99d4eSJuan Castillo# list of conditions and the following disclaimer. 973c99d4eSJuan Castillo# 1073c99d4eSJuan Castillo# Redistributions in binary form must reproduce the above copyright notice, 1173c99d4eSJuan Castillo# this list of conditions and the following disclaimer in the documentation 1273c99d4eSJuan Castillo# and/or other materials provided with the distribution. 1373c99d4eSJuan Castillo# 1473c99d4eSJuan Castillo# Neither the name of ARM nor the names of its contributors may be used 1573c99d4eSJuan Castillo# to endorse or promote products derived from this software without specific 1673c99d4eSJuan Castillo# prior written permission. 1773c99d4eSJuan Castillo# 1873c99d4eSJuan Castillo# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1973c99d4eSJuan Castillo# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2073c99d4eSJuan Castillo# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2173c99d4eSJuan Castillo# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 2273c99d4eSJuan Castillo# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2373c99d4eSJuan Castillo# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2473c99d4eSJuan Castillo# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2573c99d4eSJuan Castillo# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2673c99d4eSJuan Castillo# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2773c99d4eSJuan Castillo# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2873c99d4eSJuan Castillo# POSSIBILITY OF SUCH DAMAGE. 2973c99d4eSJuan Castillo# 3073c99d4eSJuan Castillo 311670d9dfSEvan Lloyd# Report an error if the eval make function is not available. 321670d9dfSEvan Lloyd$(eval eval_available := T) 331670d9dfSEvan Lloydifneq (${eval_available},T) 341670d9dfSEvan Lloyd $(error This makefile only works with a Make program that supports $$(eval)) 351670d9dfSEvan Lloydendif 361670d9dfSEvan Lloyd 37231c1470SEvan Lloyd# Some utility macros for manipulating awkward (whitespace) characters. 38231c1470SEvan Lloydblank := 39231c1470SEvan Lloydspace :=${blank} ${blank} 40231c1470SEvan Lloyd 41231c1470SEvan Lloyd# A user defined function to recursively search for a filename below a directory 42231c1470SEvan Lloyd# $1 is the directory root of the recursive search (blank for current directory). 43231c1470SEvan Lloyd# $2 is the file name to search for. 44231c1470SEvan Lloyddefine rwildcard 45231c1470SEvan Lloyd$(strip $(foreach d,$(wildcard ${1}*),$(call rwildcard,${d}/,${2}) $(filter $(subst *,%,%${2}),${d}))) 46231c1470SEvan Lloydendef 47231c1470SEvan Lloyd 485ba8f669SYatharth Kochar# This table is used in converting lower case to upper case. 495ba8f669SYatharth 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 505ba8f669SYatharth Kochar 515ba8f669SYatharth Kochar# Internal macro used for converting lower case to upper case. 525ba8f669SYatharth Kochar# $(1) = upper case table 535ba8f669SYatharth Kochar# $(2) = String to convert 545ba8f669SYatharth Kochardefine uppercase_internal 555ba8f669SYatharth Kochar$(if $(1),$$(subst $(firstword $(1)),$(call uppercase_internal,$(wordlist 2,$(words $(1)),$(1)),$(2))),$(2)) 565ba8f669SYatharth Kocharendef 575ba8f669SYatharth Kochar 585ba8f669SYatharth Kochar# A macro for converting a string to upper case 595ba8f669SYatharth Kochar# $(1) = String to convert 605ba8f669SYatharth Kochardefine uppercase 615ba8f669SYatharth Kochar$(eval uppercase_result:=$(call uppercase_internal,$(uppercase_table),$(1)))$(uppercase_result) 625ba8f669SYatharth Kocharendef 635ba8f669SYatharth Kochar 6473c99d4eSJuan Castillo# Convenience function for adding build definitions 6573c99d4eSJuan Castillo# $(eval $(call add_define,FOO)) will have: 6673c99d4eSJuan Castillo# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise 6773c99d4eSJuan Castillodefine add_define 6873c99d4eSJuan Castillo DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) 6973c99d4eSJuan Castilloendef 7073c99d4eSJuan Castillo 718eadeb4aSSoren Brinkmann# Convenience function for adding build definitions 728eadeb4aSSoren Brinkmann# $(eval $(call add_define_val,FOO,BAR)) will have: 738eadeb4aSSoren Brinkmann# -DFOO=BAR 748eadeb4aSSoren Brinkmanndefine add_define_val 758eadeb4aSSoren Brinkmann DEFINES += -D$(1)=$(2) 768eadeb4aSSoren Brinkmannendef 778eadeb4aSSoren Brinkmann 7873c99d4eSJuan Castillo# Convenience function for verifying option has a boolean value 7973c99d4eSJuan Castillo# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1 8073c99d4eSJuan Castillodefine assert_boolean 8173c99d4eSJuan Castillo $(and $(patsubst 0,,$(value $(1))),$(patsubst 1,,$(value $(1))),$(error $(1) must be boolean)) 8273c99d4eSJuan Castilloendef 8373c99d4eSJuan Castillo 8473c99d4eSJuan Castillo# IMG_LINKERFILE defines the linker script corresponding to a BL stage 8573c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 8673c99d4eSJuan Castillodefine IMG_LINKERFILE 8773c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).ld 8873c99d4eSJuan Castilloendef 8973c99d4eSJuan Castillo 9073c99d4eSJuan Castillo# IMG_MAPFILE defines the output file describing the memory map corresponding 9173c99d4eSJuan Castillo# to a BL stage 9273c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 9373c99d4eSJuan Castillodefine IMG_MAPFILE 9473c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).map 9573c99d4eSJuan Castilloendef 9673c99d4eSJuan Castillo 9773c99d4eSJuan Castillo# IMG_ELF defines the elf file corresponding to a BL stage 9873c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 9973c99d4eSJuan Castillodefine IMG_ELF 10073c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).elf 10173c99d4eSJuan Castilloendef 10273c99d4eSJuan Castillo 10373c99d4eSJuan Castillo# IMG_DUMP defines the symbols dump file corresponding to a BL stage 10473c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 10573c99d4eSJuan Castillodefine IMG_DUMP 10673c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).dump 10773c99d4eSJuan Castilloendef 10873c99d4eSJuan Castillo 10973c99d4eSJuan Castillo# IMG_BIN defines the default image file corresponding to a BL stage 11073c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 11173c99d4eSJuan Castillodefine IMG_BIN 11273c99d4eSJuan Castillo ${BUILD_PLAT}/bl$(1).bin 11373c99d4eSJuan Castilloendef 11473c99d4eSJuan Castillo 115819281eeSdp-arm# FIP_ADD_PAYLOAD appends the command line arguments required by fiptool 11673c99d4eSJuan Castillo# to package a new payload. Optionally, it adds the dependency on this payload 11773c99d4eSJuan Castillo# $(1) = payload filename (i.e. bl31.bin) 11873c99d4eSJuan Castillo# $(2) = command line option for the specified payload (i.e. --bl31) 11973c99d4eSJuan Castillo# $(3) = fip target dependency (optional) (i.e. bl31) 12073c99d4eSJuan Castillodefine FIP_ADD_PAYLOAD 12173c99d4eSJuan Castillo $(eval FIP_ARGS += $(2) $(1)) 12273c99d4eSJuan Castillo $(eval $(if $(3),FIP_DEPS += $(3))) 12373c99d4eSJuan Castilloendef 12473c99d4eSJuan Castillo 1250191262dSYatharth Kochar# CERT_ADD_CMD_OPT adds a new command line option to the cert_create invocation 12673c99d4eSJuan Castillo# $(1) = parameter filename 12773c99d4eSJuan Castillo# $(2) = cert_create command line option for the specified parameter 12873c99d4eSJuan Castillo# $(3) = input parameter (false if empty) 12973c99d4eSJuan Castillodefine CERT_ADD_CMD_OPT 13073c99d4eSJuan Castillo $(eval $(if $(3),CRT_DEPS += $(1))) 13173c99d4eSJuan Castillo $(eval CRT_ARGS += $(2) $(1)) 13273c99d4eSJuan Castilloendef 13373c99d4eSJuan Castillo 13473c99d4eSJuan Castillo# FIP_ADD_IMG allows the platform to specify an image to be packed in the FIP 13573c99d4eSJuan Castillo# using a build option. It also adds a dependency on the image file, aborting 13673c99d4eSJuan Castillo# the build if the file does not exist. 137f59821d5SJuan Castillo# $(1) = build option to specify the image filename (SCP_BL2, BL33, etc) 138819281eeSdp-arm# $(2) = command line option for fiptool (scp_bl2, bl33, etc) 13973c99d4eSJuan Castillo# Example: 14073c99d4eSJuan Castillo# $(eval $(call FIP_ADD_IMG,BL33,--bl33)) 14173c99d4eSJuan Castillodefine FIP_ADD_IMG 14273c99d4eSJuan Castillo CRT_DEPS += check_$(1) 14373c99d4eSJuan Castillo FIP_DEPS += check_$(1) 14473c99d4eSJuan Castillo $(call FIP_ADD_PAYLOAD,$(value $(1)),$(2)) 14573c99d4eSJuan Castillo 14673c99d4eSJuan Castillocheck_$(1): 14773c99d4eSJuan Castillo $$(if $(value $(1)),,$$(error "Platform '${PLAT}' requires $(1). Please set $(1) to point to the right file")) 14873c99d4eSJuan Castilloendef 14973c99d4eSJuan Castillo 150819281eeSdp-arm# FWU_FIP_ADD_PAYLOAD appends the command line arguments required by fiptool 1510191262dSYatharth Kochar# to package a new FWU payload. Optionally, it adds the dependency on this payload 1520191262dSYatharth Kochar# $(1) = payload filename (e.g. ns_bl2u.bin) 1538f0617efSJuan Castillo# $(2) = command line option for the specified payload (e.g. --fwu) 1540191262dSYatharth Kochar# $(3) = fip target dependency (optional) (e.g. ns_bl2u) 1550191262dSYatharth Kochardefine FWU_FIP_ADD_PAYLOAD 1560191262dSYatharth Kochar $(eval $(if $(3),FWU_FIP_DEPS += $(3))) 1570191262dSYatharth Kochar $(eval FWU_FIP_ARGS += $(2) $(1)) 1580191262dSYatharth Kocharendef 1590191262dSYatharth Kochar 1600191262dSYatharth Kochar# FWU_CERT_ADD_CMD_OPT adds a new command line option to the cert_create invocation 1610191262dSYatharth Kochar# $(1) = parameter filename 1620191262dSYatharth Kochar# $(2) = cert_create command line option for the specified parameter 1630191262dSYatharth Kochar# $(3) = input parameter (false if empty) 1640191262dSYatharth Kochardefine FWU_CERT_ADD_CMD_OPT 1650191262dSYatharth Kochar $(eval $(if $(3),FWU_CRT_DEPS += $(1))) 1660191262dSYatharth Kochar $(eval FWU_CRT_ARGS += $(2) $(1)) 1670191262dSYatharth Kocharendef 1680191262dSYatharth Kochar 1690191262dSYatharth Kochar# FWU_FIP_ADD_IMG allows the platform to pack a binary image in the FWU FIP 1700191262dSYatharth Kochar# $(1) build option to specify the image filename (BL2U, NS_BL2U, etc) 171819281eeSdp-arm# $(2) command line option for fiptool (bl2u, ns_bl2u, etc) 1720191262dSYatharth Kochar# Example: 1730191262dSYatharth Kochar# $(eval $(call FWU_FIP_ADD_IMG,BL2U,--bl2u)) 1740191262dSYatharth Kochardefine FWU_FIP_ADD_IMG 1750191262dSYatharth Kochar FWU_CRT_DEPS += check_$(1) 1760191262dSYatharth Kochar FWU_FIP_DEPS += check_$(1) 1770191262dSYatharth Kochar $(call FWU_FIP_ADD_PAYLOAD,$(value $(1)),$(2)) 1780191262dSYatharth Kochar 1790191262dSYatharth Kocharcheck_$(1): 1800191262dSYatharth Kochar $$(if $(value $(1)),,$$(error "Platform '${PLAT}' requires $(1). Please set $(1) to point to the right file")) 1810191262dSYatharth Kocharendef 18273c99d4eSJuan Castillo 18373c99d4eSJuan Castillo################################################################################ 18473c99d4eSJuan Castillo# Auxiliary macros to build TF images from sources 18573c99d4eSJuan Castillo################################################################################ 18673c99d4eSJuan Castillo 187*710ea1d0SMasahiro YamadaMAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ 18873c99d4eSJuan Castillo 18973c99d4eSJuan Castillo# MAKE_C builds a C source file and generates the dependency file 19073c99d4eSJuan Castillo# $(1) = output directory 19173c99d4eSJuan Castillo# $(2) = source file (%.c) 1925ba8f669SYatharth Kochar# $(3) = BL stage (2, 2u, 30, 31, 32, 33) 19373c99d4eSJuan Castillodefine MAKE_C 19473c99d4eSJuan Castillo 19573c99d4eSJuan Castillo$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) 196*710ea1d0SMasahiro Yamada$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 1975ba8f669SYatharth Kochar$(eval IMAGE := IMAGE_BL$(call uppercase,$(3))) 19873c99d4eSJuan Castillo 199*710ea1d0SMasahiro Yamada$(OBJ): $(2) | bl$(3)_dirs 20073c99d4eSJuan Castillo @echo " CC $$<" 201*710ea1d0SMasahiro Yamada $$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@ 20273c99d4eSJuan Castillo 203*710ea1d0SMasahiro Yamada-include $(DEP) 20473c99d4eSJuan Castillo 20573c99d4eSJuan Castilloendef 20673c99d4eSJuan Castillo 20773c99d4eSJuan Castillo 20873c99d4eSJuan Castillo# MAKE_S builds an assembly source file and generates the dependency file 20973c99d4eSJuan Castillo# $(1) = output directory 21073c99d4eSJuan Castillo# $(2) = assembly file (%.S) 2115ba8f669SYatharth Kochar# $(3) = BL stage (2, 2u, 30, 31, 32, 33) 21273c99d4eSJuan Castillodefine MAKE_S 21373c99d4eSJuan Castillo 21473c99d4eSJuan Castillo$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) 215*710ea1d0SMasahiro Yamada$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 2165ba8f669SYatharth Kochar$(eval IMAGE := IMAGE_BL$(call uppercase,$(3))) 21773c99d4eSJuan Castillo 218*710ea1d0SMasahiro Yamada$(OBJ): $(2) | bl$(3)_dirs 21973c99d4eSJuan Castillo @echo " AS $$<" 220*710ea1d0SMasahiro Yamada $$(Q)$$(AS) $$(ASFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@ 22173c99d4eSJuan Castillo 222*710ea1d0SMasahiro Yamada-include $(DEP) 22373c99d4eSJuan Castillo 22473c99d4eSJuan Castilloendef 22573c99d4eSJuan Castillo 22673c99d4eSJuan Castillo 22773c99d4eSJuan Castillo# MAKE_LD generate the linker script using the C preprocessor 22873c99d4eSJuan Castillo# $(1) = output linker script 22973c99d4eSJuan Castillo# $(2) = input template 23073c99d4eSJuan Castillodefine MAKE_LD 23173c99d4eSJuan Castillo 232*710ea1d0SMasahiro Yamada$(eval DEP := $(1).d) 23373c99d4eSJuan Castillo 234*710ea1d0SMasahiro Yamada$(1): $(2) | $(dir ${1}) 23573c99d4eSJuan Castillo @echo " PP $$<" 236*710ea1d0SMasahiro Yamada $$(Q)$$(CPP) $$(CPPFLAGS) -P -D__ASSEMBLY__ -D__LINKER__ $(MAKE_DEP) -o $$@ $$< 23773c99d4eSJuan Castillo 238*710ea1d0SMasahiro Yamada-include $(DEP) 23973c99d4eSJuan Castillo 24073c99d4eSJuan Castilloendef 24173c99d4eSJuan Castillo 24273c99d4eSJuan Castillo 24373c99d4eSJuan Castillo# MAKE_OBJS builds both C and assembly source files 24473c99d4eSJuan Castillo# $(1) = output directory 24573c99d4eSJuan Castillo# $(2) = list of source files (both C and assembly) 24673c99d4eSJuan Castillo# $(3) = BL stage (2, 30, 31, 32, 33) 24773c99d4eSJuan Castillodefine MAKE_OBJS 24873c99d4eSJuan Castillo $(eval C_OBJS := $(filter %.c,$(2))) 24973c99d4eSJuan Castillo $(eval REMAIN := $(filter-out %.c,$(2))) 25073c99d4eSJuan Castillo $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3)))) 25173c99d4eSJuan Castillo 25273c99d4eSJuan Castillo $(eval S_OBJS := $(filter %.S,$(REMAIN))) 25373c99d4eSJuan Castillo $(eval REMAIN := $(filter-out %.S,$(REMAIN))) 25473c99d4eSJuan Castillo $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3)))) 25573c99d4eSJuan Castillo 25673c99d4eSJuan Castillo $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN))) 25773c99d4eSJuan Castilloendef 25873c99d4eSJuan Castillo 25973c99d4eSJuan Castillo 26073c99d4eSJuan Castillo# NOTE: The line continuation '\' is required in the next define otherwise we 26173c99d4eSJuan Castillo# end up with a line-feed characer at the end of the last c filename. 262e7f54dbdSEvan Lloyd# Also bear this issue in mind if extending the list of supported filetypes. 26373c99d4eSJuan Castillodefine SOURCES_TO_OBJS 26473c99d4eSJuan Castillo $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \ 26573c99d4eSJuan Castillo $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1)))) 26673c99d4eSJuan Castilloendef 26773c99d4eSJuan Castillo 26873c99d4eSJuan Castillo 269819281eeSdp-arm# MAKE_TOOL_ARGS macro defines the command line arguments for fiptool for 27073c99d4eSJuan Castillo# each BL image. Arguments: 27173c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 27273c99d4eSJuan Castillo# $(2) = Binary file 2738f0617efSJuan Castillo# $(3) = FIP command line option (if empty, image will not be included in the FIP) 27473c99d4eSJuan Castillodefine MAKE_TOOL_ARGS 2758f0617efSJuan Castillo $(if $(3),$(eval $(call FIP_ADD_PAYLOAD,$(2),--$(3),bl$(1)))) 27673c99d4eSJuan Castilloendef 27773c99d4eSJuan Castillo 2782f5d4a48SPatrick Georgi# Allow overriding the timestamp, for example for reproducible builds, or to 2792f5d4a48SPatrick Georgi# synchronize timestamps across multiple projects. 2802f5d4a48SPatrick Georgi# This must be set to a C string (including quotes where applicable). 2812f5d4a48SPatrick GeorgiBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ 28273c99d4eSJuan Castillo 28373c99d4eSJuan Castillo# MAKE_BL macro defines the targets and options to build each BL image. 28473c99d4eSJuan Castillo# Arguments: 2855ba8f669SYatharth Kochar# $(1) = BL stage (2, 2u, 30, 31, 32, 33) 2868f0617efSJuan Castillo# $(2) = FIP command line option (if empty, image will not be included in the FIP) 28773c99d4eSJuan Castillodefine MAKE_BL 28873c99d4eSJuan Castillo $(eval BUILD_DIR := ${BUILD_PLAT}/bl$(1)) 2895ba8f669SYatharth Kochar $(eval BL_SOURCES := $(BL$(call uppercase,$(1))_SOURCES)) 2905ba8f669SYatharth Kochar $(eval SOURCES := $(BL_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES)) 29173c99d4eSJuan Castillo $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES)))) 29273c99d4eSJuan Castillo $(eval LINKERFILE := $(call IMG_LINKERFILE,$(1))) 29373c99d4eSJuan Castillo $(eval MAPFILE := $(call IMG_MAPFILE,$(1))) 29473c99d4eSJuan Castillo $(eval ELF := $(call IMG_ELF,$(1))) 29573c99d4eSJuan Castillo $(eval DUMP := $(call IMG_DUMP,$(1))) 29673c99d4eSJuan Castillo $(eval BIN := $(call IMG_BIN,$(1))) 2975ba8f669SYatharth Kochar $(eval BL_LINKERFILE := $(BL$(call uppercase,$(1))_LINKERFILE)) 29851b27702SEvan Lloyd # We use sort only to get a list of unique object directory names. 29951b27702SEvan Lloyd # ordering is not relevant but sort removes duplicates. 30051b27702SEvan Lloyd $(eval TEMP_OBJ_DIRS := $(sort $(BUILD_DIR)/ $(dir ${OBJS}))) 30151b27702SEvan Lloyd # The $(dir ) function leaves a trailing / on the directory names 30251b27702SEvan Lloyd # We append a . then strip /. from each, to remove the trailing / characters 30351b27702SEvan Lloyd # This gives names suitable for use as make rule targets. 30451b27702SEvan Lloyd $(eval OBJ_DIRS := $(subst /.,,$(addsuffix .,$(TEMP_OBJ_DIRS)))) 30551b27702SEvan Lloyd 30651b27702SEvan Lloyd# Create generators for object directory structure 30751b27702SEvan Lloyd 30851b27702SEvan Lloyd$(eval $(foreach objd,${OBJ_DIRS},$(call MAKE_PREREQ_DIR,${objd},))) 30951b27702SEvan Lloyd 31051b27702SEvan Lloyd.PHONY : bl${1}_dirs 31151b27702SEvan Lloyd 31251b27702SEvan Lloyd# We use order-only prerequisites to ensure that directories are created, 31351b27702SEvan Lloyd# but do not cause re-builds every time a file is written. 31451b27702SEvan Lloydbl${1}_dirs: | ${OBJ_DIRS} 31573c99d4eSJuan Castillo 31673c99d4eSJuan Castillo$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1))) 3175ba8f669SYatharth Kochar$(eval $(call MAKE_LD,$(LINKERFILE),$(BL_LINKERFILE))) 31873c99d4eSJuan Castillo 31951b27702SEvan Lloyd$(ELF): $(OBJS) $(LINKERFILE) | bl$(1)_dirs 32073c99d4eSJuan Castillo @echo " LD $$@" 321414ab853SEvan Lloydifdef MAKE_BUILD_STRINGS 322414ab853SEvan Lloyd $(call MAKE_BUILD_STRINGS, $(BUILD_DIR)/build_message.o) 323414ab853SEvan Lloydelse 3242f5d4a48SPatrick Georgi @echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP); \ 32573c99d4eSJuan Castillo const char version_string[] = "${VERSION_STRING}";' | \ 326f2e1d57eSMasahiro Yamada $$(CC) $$(TF_CFLAGS) $$(CFLAGS) -xc -c - -o $(BUILD_DIR)/build_message.o 327414ab853SEvan Lloydendif 32873c99d4eSJuan Castillo $$(Q)$$(LD) -o $$@ $$(LDFLAGS) -Map=$(MAPFILE) --script $(LINKERFILE) \ 32973c99d4eSJuan Castillo $(BUILD_DIR)/build_message.o $(OBJS) 33073c99d4eSJuan Castillo 33173c99d4eSJuan Castillo$(DUMP): $(ELF) 33273c99d4eSJuan Castillo @echo " OD $$@" 33373c99d4eSJuan Castillo $${Q}$${OD} -dx $$< > $$@ 33473c99d4eSJuan Castillo 33573c99d4eSJuan Castillo$(BIN): $(ELF) 33673c99d4eSJuan Castillo @echo " BIN $$@" 33773c99d4eSJuan Castillo $$(Q)$$(OC) -O binary $$< $$@ 33873c99d4eSJuan Castillo @echo 33973c99d4eSJuan Castillo @echo "Built $$@ successfully" 34073c99d4eSJuan Castillo @echo 34173c99d4eSJuan Castillo 34273c99d4eSJuan Castillo.PHONY: bl$(1) 34351b27702SEvan Lloydbl$(1): $(BIN) $(DUMP) 34473c99d4eSJuan Castillo 34573c99d4eSJuan Castilloall: bl$(1) 34673c99d4eSJuan Castillo 34773c99d4eSJuan Castillo$(eval $(call MAKE_TOOL_ARGS,$(1),$(BIN),$(2))) 34873c99d4eSJuan Castillo 34973c99d4eSJuan Castilloendef 35073c99d4eSJuan Castillo 351