173c99d4eSJuan Castillo# 2*802d2dd2SMasahiro Yamada# Copyright (c) 2015-2018, 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 478eadeb4aSSoren Brinkmann# Convenience function for adding build definitions 488eadeb4aSSoren Brinkmann# $(eval $(call add_define_val,FOO,BAR)) will have: 498eadeb4aSSoren Brinkmann# -DFOO=BAR 508eadeb4aSSoren Brinkmanndefine add_define_val 518eadeb4aSSoren Brinkmann DEFINES += -D$(1)=$(2) 528eadeb4aSSoren Brinkmannendef 538eadeb4aSSoren Brinkmann 5473c99d4eSJuan Castillo# Convenience function for verifying option has a boolean value 5573c99d4eSJuan Castillo# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1 5673c99d4eSJuan Castillodefine assert_boolean 57be4cd40eSMasahiro Yamada $(if $(filter-out 0 1,$($1)),$(error $1 must be boolean)) 5873c99d4eSJuan Castilloendef 5973c99d4eSJuan Castillo 60c877b414SJeenu Viswambharan0-9 := 0 1 2 3 4 5 6 7 8 9 61c877b414SJeenu Viswambharan 62c877b414SJeenu Viswambharan# Function to verify that a given option $(1) contains a numeric value 63c877b414SJeenu Viswambharandefine assert_numeric 64c877b414SJeenu Viswambharan$(if $($(1)),,$(error $(1) must not be empty)) 65c877b414SJeenu Viswambharan$(eval __numeric := $($(1))) 66c877b414SJeenu Viswambharan$(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric)))) 67c877b414SJeenu Viswambharan$(if $(__numeric),$(error $(1) must be numeric)) 68c877b414SJeenu Viswambharanendef 69c877b414SJeenu Viswambharan 7073c99d4eSJuan Castillo# IMG_LINKERFILE defines the linker script corresponding to a BL stage 7173c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 7273c99d4eSJuan Castillodefine IMG_LINKERFILE 7373c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).ld 7473c99d4eSJuan Castilloendef 7573c99d4eSJuan Castillo 7673c99d4eSJuan Castillo# IMG_MAPFILE defines the output file describing the memory map corresponding 7773c99d4eSJuan Castillo# to a BL stage 7873c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 7973c99d4eSJuan Castillodefine IMG_MAPFILE 8073c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).map 8173c99d4eSJuan Castilloendef 8273c99d4eSJuan Castillo 8373c99d4eSJuan Castillo# IMG_ELF defines the elf file corresponding to a BL stage 8473c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 8573c99d4eSJuan Castillodefine IMG_ELF 8673c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).elf 8773c99d4eSJuan Castilloendef 8873c99d4eSJuan Castillo 8973c99d4eSJuan Castillo# IMG_DUMP defines the symbols dump file corresponding to a BL stage 9073c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 9173c99d4eSJuan Castillodefine IMG_DUMP 9273c99d4eSJuan Castillo ${BUILD_DIR}/bl$(1).dump 9373c99d4eSJuan Castilloendef 9473c99d4eSJuan Castillo 9573c99d4eSJuan Castillo# IMG_BIN defines the default image file corresponding to a BL stage 9673c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 9773c99d4eSJuan Castillodefine IMG_BIN 9873c99d4eSJuan Castillo ${BUILD_PLAT}/bl$(1).bin 9973c99d4eSJuan Castilloendef 10073c99d4eSJuan Castillo 101819281eeSdp-arm# FIP_ADD_PAYLOAD appends the command line arguments required by fiptool 10273c99d4eSJuan Castillo# to package a new payload. Optionally, it adds the dependency on this payload 10373c99d4eSJuan Castillo# $(1) = payload filename (i.e. bl31.bin) 1041e0c0784SMasahiro Yamada# $(2) = command line option for the specified payload (i.e. --soc-fw) 10573c99d4eSJuan Castillo# $(3) = fip target dependency (optional) (i.e. bl31) 10673c99d4eSJuan Castillodefine FIP_ADD_PAYLOAD 10773c99d4eSJuan Castillo $(eval FIP_ARGS += $(2) $(1)) 10873c99d4eSJuan Castillo $(eval $(if $(3),FIP_DEPS += $(3))) 10973c99d4eSJuan Castilloendef 11073c99d4eSJuan Castillo 1110191262dSYatharth Kochar# CERT_ADD_CMD_OPT adds a new command line option to the cert_create invocation 11273c99d4eSJuan Castillo# $(1) = parameter filename 11373c99d4eSJuan Castillo# $(2) = cert_create command line option for the specified parameter 11473c99d4eSJuan Castillo# $(3) = input parameter (false if empty) 11573c99d4eSJuan Castillodefine CERT_ADD_CMD_OPT 11673c99d4eSJuan Castillo $(eval $(if $(3),CRT_DEPS += $(1))) 11773c99d4eSJuan Castillo $(eval CRT_ARGS += $(2) $(1)) 11873c99d4eSJuan Castilloendef 11973c99d4eSJuan Castillo 12073c99d4eSJuan Castillo# FIP_ADD_IMG allows the platform to specify an image to be packed in the FIP 12173c99d4eSJuan Castillo# using a build option. It also adds a dependency on the image file, aborting 12273c99d4eSJuan Castillo# the build if the file does not exist. 123f59821d5SJuan Castillo# $(1) = build option to specify the image filename (SCP_BL2, BL33, etc) 1241e0c0784SMasahiro Yamada# $(2) = command line option for fiptool (--scp-fw, --nt-fw, etc) 12573c99d4eSJuan Castillo# Example: 1261e0c0784SMasahiro Yamada# $(eval $(call FIP_ADD_IMG,BL33,--nt-fw)) 12773c99d4eSJuan Castillodefine FIP_ADD_IMG 12873c99d4eSJuan Castillo CRT_DEPS += check_$(1) 12973c99d4eSJuan Castillo FIP_DEPS += check_$(1) 13073c99d4eSJuan Castillo $(call FIP_ADD_PAYLOAD,$(value $(1)),$(2)) 13173c99d4eSJuan Castillo 13287ebd20dSMasahiro Yamada.PHONY: check_$(1) 13373c99d4eSJuan Castillocheck_$(1): 13473c99d4eSJuan Castillo $$(if $(value $(1)),,$$(error "Platform '${PLAT}' requires $(1). Please set $(1) to point to the right file")) 135*802d2dd2SMasahiro Yamada $$(if $(wildcard $(value $(1))),,$$(error '$(1)=$(value $(1))' was specified, but '$(value $(1))' does not exist)) 13673c99d4eSJuan Castilloendef 13773c99d4eSJuan Castillo 138819281eeSdp-arm# FWU_FIP_ADD_PAYLOAD appends the command line arguments required by fiptool 1390191262dSYatharth Kochar# to package a new FWU payload. Optionally, it adds the dependency on this payload 1400191262dSYatharth Kochar# $(1) = payload filename (e.g. ns_bl2u.bin) 1418f0617efSJuan Castillo# $(2) = command line option for the specified payload (e.g. --fwu) 1420191262dSYatharth Kochar# $(3) = fip target dependency (optional) (e.g. ns_bl2u) 1430191262dSYatharth Kochardefine FWU_FIP_ADD_PAYLOAD 1440191262dSYatharth Kochar $(eval $(if $(3),FWU_FIP_DEPS += $(3))) 1450191262dSYatharth Kochar $(eval FWU_FIP_ARGS += $(2) $(1)) 1460191262dSYatharth Kocharendef 1470191262dSYatharth Kochar 1480191262dSYatharth Kochar# FWU_CERT_ADD_CMD_OPT adds a new command line option to the cert_create invocation 1490191262dSYatharth Kochar# $(1) = parameter filename 1500191262dSYatharth Kochar# $(2) = cert_create command line option for the specified parameter 1510191262dSYatharth Kochar# $(3) = input parameter (false if empty) 1520191262dSYatharth Kochardefine FWU_CERT_ADD_CMD_OPT 1530191262dSYatharth Kochar $(eval $(if $(3),FWU_CRT_DEPS += $(1))) 1540191262dSYatharth Kochar $(eval FWU_CRT_ARGS += $(2) $(1)) 1550191262dSYatharth Kocharendef 1560191262dSYatharth Kochar 1570191262dSYatharth Kochar# FWU_FIP_ADD_IMG allows the platform to pack a binary image in the FWU FIP 1580191262dSYatharth Kochar# $(1) build option to specify the image filename (BL2U, NS_BL2U, etc) 1591e0c0784SMasahiro Yamada# $(2) command line option for fiptool (--ap-fwu-cfg, --fwu, etc) 1600191262dSYatharth Kochar# Example: 1611e0c0784SMasahiro Yamada# $(eval $(call FWU_FIP_ADD_IMG,BL2U,--ap-fwu-cfg)) 1620191262dSYatharth Kochardefine FWU_FIP_ADD_IMG 1630191262dSYatharth Kochar FWU_CRT_DEPS += check_$(1) 1640191262dSYatharth Kochar FWU_FIP_DEPS += check_$(1) 1650191262dSYatharth Kochar $(call FWU_FIP_ADD_PAYLOAD,$(value $(1)),$(2)) 1660191262dSYatharth Kochar 16787ebd20dSMasahiro Yamada.PHONY: check_$(1) 1680191262dSYatharth Kocharcheck_$(1): 1690191262dSYatharth Kochar $$(if $(value $(1)),,$$(error "Platform '${PLAT}' requires $(1). Please set $(1) to point to the right file")) 170*802d2dd2SMasahiro Yamada $$(if $(wildcard $(value $(1))),,$$(error '$(1)=$(value $(1))' was specified, but '$(value $(1))' does not exist)) 1710191262dSYatharth Kocharendef 17273c99d4eSJuan Castillo 17373c99d4eSJuan Castillo################################################################################ 17473c99d4eSJuan Castillo# Auxiliary macros to build TF images from sources 17573c99d4eSJuan Castillo################################################################################ 17673c99d4eSJuan Castillo 1771d274ab0SMasahiro YamadaMAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ -MP 17873c99d4eSJuan Castillo 17973c99d4eSJuan Castillo# MAKE_C builds a C source file and generates the dependency file 18073c99d4eSJuan Castillo# $(1) = output directory 18173c99d4eSJuan Castillo# $(2) = source file (%.c) 1825ba8f669SYatharth Kochar# $(3) = BL stage (2, 2u, 30, 31, 32, 33) 18373c99d4eSJuan Castillodefine MAKE_C 18473c99d4eSJuan Castillo 18573c99d4eSJuan Castillo$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) 186710ea1d0SMasahiro Yamada$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 1875ba8f669SYatharth Kochar$(eval IMAGE := IMAGE_BL$(call uppercase,$(3))) 18873c99d4eSJuan Castillo 189710ea1d0SMasahiro Yamada$(OBJ): $(2) | bl$(3)_dirs 19073c99d4eSJuan Castillo @echo " CC $$<" 191710ea1d0SMasahiro Yamada $$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@ 19273c99d4eSJuan Castillo 193710ea1d0SMasahiro Yamada-include $(DEP) 19473c99d4eSJuan Castillo 19573c99d4eSJuan Castilloendef 19673c99d4eSJuan Castillo 19773c99d4eSJuan Castillo 19873c99d4eSJuan Castillo# MAKE_S builds an assembly source file and generates the dependency file 19973c99d4eSJuan Castillo# $(1) = output directory 20073c99d4eSJuan Castillo# $(2) = assembly file (%.S) 2015ba8f669SYatharth Kochar# $(3) = BL stage (2, 2u, 30, 31, 32, 33) 20273c99d4eSJuan Castillodefine MAKE_S 20373c99d4eSJuan Castillo 20473c99d4eSJuan Castillo$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) 205710ea1d0SMasahiro Yamada$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) 2065ba8f669SYatharth Kochar$(eval IMAGE := IMAGE_BL$(call uppercase,$(3))) 20773c99d4eSJuan Castillo 208710ea1d0SMasahiro Yamada$(OBJ): $(2) | bl$(3)_dirs 20973c99d4eSJuan Castillo @echo " AS $$<" 210710ea1d0SMasahiro Yamada $$(Q)$$(AS) $$(ASFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@ 21173c99d4eSJuan Castillo 212710ea1d0SMasahiro Yamada-include $(DEP) 21373c99d4eSJuan Castillo 21473c99d4eSJuan Castilloendef 21573c99d4eSJuan Castillo 21673c99d4eSJuan Castillo 21773c99d4eSJuan Castillo# MAKE_LD generate the linker script using the C preprocessor 21873c99d4eSJuan Castillo# $(1) = output linker script 21973c99d4eSJuan Castillo# $(2) = input template 220a6ca7888SMasahiro Yamada# $(3) = BL stage (2, 2u, 30, 31, 32, 33) 22173c99d4eSJuan Castillodefine MAKE_LD 22273c99d4eSJuan Castillo 223710ea1d0SMasahiro Yamada$(eval DEP := $(1).d) 22473c99d4eSJuan Castillo 225a6ca7888SMasahiro Yamada$(1): $(2) | bl$(3)_dirs 22673c99d4eSJuan Castillo @echo " PP $$<" 227710ea1d0SMasahiro Yamada $$(Q)$$(CPP) $$(CPPFLAGS) -P -D__ASSEMBLY__ -D__LINKER__ $(MAKE_DEP) -o $$@ $$< 22873c99d4eSJuan Castillo 229710ea1d0SMasahiro Yamada-include $(DEP) 23073c99d4eSJuan Castillo 23173c99d4eSJuan Castilloendef 23273c99d4eSJuan Castillo 23373c99d4eSJuan Castillo 23473c99d4eSJuan Castillo# MAKE_OBJS builds both C and assembly source files 23573c99d4eSJuan Castillo# $(1) = output directory 23673c99d4eSJuan Castillo# $(2) = list of source files (both C and assembly) 23773c99d4eSJuan Castillo# $(3) = BL stage (2, 30, 31, 32, 33) 23873c99d4eSJuan Castillodefine MAKE_OBJS 23973c99d4eSJuan Castillo $(eval C_OBJS := $(filter %.c,$(2))) 24073c99d4eSJuan Castillo $(eval REMAIN := $(filter-out %.c,$(2))) 24173c99d4eSJuan Castillo $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3)))) 24273c99d4eSJuan Castillo 24373c99d4eSJuan Castillo $(eval S_OBJS := $(filter %.S,$(REMAIN))) 24473c99d4eSJuan Castillo $(eval REMAIN := $(filter-out %.S,$(REMAIN))) 24573c99d4eSJuan Castillo $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3)))) 24673c99d4eSJuan Castillo 24773c99d4eSJuan Castillo $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN))) 24873c99d4eSJuan Castilloendef 24973c99d4eSJuan Castillo 25073c99d4eSJuan Castillo 25173c99d4eSJuan Castillo# NOTE: The line continuation '\' is required in the next define otherwise we 25273c99d4eSJuan Castillo# end up with a line-feed characer at the end of the last c filename. 253e7f54dbdSEvan Lloyd# Also bear this issue in mind if extending the list of supported filetypes. 25473c99d4eSJuan Castillodefine SOURCES_TO_OBJS 25573c99d4eSJuan Castillo $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \ 25673c99d4eSJuan Castillo $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1)))) 25773c99d4eSJuan Castilloendef 25873c99d4eSJuan Castillo 25973c99d4eSJuan Castillo 260819281eeSdp-arm# MAKE_TOOL_ARGS macro defines the command line arguments for fiptool for 26173c99d4eSJuan Castillo# each BL image. Arguments: 26273c99d4eSJuan Castillo# $(1) = BL stage (2, 30, 31, 32, 33) 26373c99d4eSJuan Castillo# $(2) = Binary file 2648f0617efSJuan Castillo# $(3) = FIP command line option (if empty, image will not be included in the FIP) 26573c99d4eSJuan Castillodefine MAKE_TOOL_ARGS 2668f0617efSJuan Castillo $(if $(3),$(eval $(call FIP_ADD_PAYLOAD,$(2),--$(3),bl$(1)))) 26773c99d4eSJuan Castilloendef 26873c99d4eSJuan Castillo 2692f5d4a48SPatrick Georgi# Allow overriding the timestamp, for example for reproducible builds, or to 2702f5d4a48SPatrick Georgi# synchronize timestamps across multiple projects. 2712f5d4a48SPatrick Georgi# This must be set to a C string (including quotes where applicable). 2722f5d4a48SPatrick GeorgiBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ 27373c99d4eSJuan Castillo 27473c99d4eSJuan Castillo# MAKE_BL macro defines the targets and options to build each BL image. 27573c99d4eSJuan Castillo# Arguments: 2765ba8f669SYatharth Kochar# $(1) = BL stage (2, 2u, 30, 31, 32, 33) 2778f0617efSJuan Castillo# $(2) = FIP command line option (if empty, image will not be included in the FIP) 27873c99d4eSJuan Castillodefine MAKE_BL 27973c99d4eSJuan Castillo $(eval BUILD_DIR := ${BUILD_PLAT}/bl$(1)) 2805ba8f669SYatharth Kochar $(eval BL_SOURCES := $(BL$(call uppercase,$(1))_SOURCES)) 2815ba8f669SYatharth Kochar $(eval SOURCES := $(BL_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES)) 28273c99d4eSJuan Castillo $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES)))) 28373c99d4eSJuan Castillo $(eval LINKERFILE := $(call IMG_LINKERFILE,$(1))) 28473c99d4eSJuan Castillo $(eval MAPFILE := $(call IMG_MAPFILE,$(1))) 28573c99d4eSJuan Castillo $(eval ELF := $(call IMG_ELF,$(1))) 28673c99d4eSJuan Castillo $(eval DUMP := $(call IMG_DUMP,$(1))) 28773c99d4eSJuan Castillo $(eval BIN := $(call IMG_BIN,$(1))) 2885ba8f669SYatharth Kochar $(eval BL_LINKERFILE := $(BL$(call uppercase,$(1))_LINKERFILE)) 28951b27702SEvan Lloyd # We use sort only to get a list of unique object directory names. 29051b27702SEvan Lloyd # ordering is not relevant but sort removes duplicates. 2916ba7d274SEvan Lloyd $(eval TEMP_OBJ_DIRS := $(sort $(dir ${OBJS} ${LINKERFILE}))) 29251b27702SEvan Lloyd # The $(dir ) function leaves a trailing / on the directory names 293d014ea6cSMasahiro Yamada # Rip off the / to match directory names with make rule targets. 294d014ea6cSMasahiro Yamada $(eval OBJ_DIRS := $(patsubst %/,%,$(TEMP_OBJ_DIRS))) 29551b27702SEvan Lloyd 29651b27702SEvan Lloyd# Create generators for object directory structure 29751b27702SEvan Lloyd 2988012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT})) 2996ba7d274SEvan Lloyd 3006ba7d274SEvan Lloyd$(eval $(foreach objd,${OBJ_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR}))) 30151b27702SEvan Lloyd 30251b27702SEvan Lloyd.PHONY : bl${1}_dirs 30351b27702SEvan Lloyd 30451b27702SEvan Lloyd# We use order-only prerequisites to ensure that directories are created, 30551b27702SEvan Lloyd# but do not cause re-builds every time a file is written. 30651b27702SEvan Lloydbl${1}_dirs: | ${OBJ_DIRS} 30773c99d4eSJuan Castillo 30873c99d4eSJuan Castillo$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1))) 309a6ca7888SMasahiro Yamada$(eval $(call MAKE_LD,$(LINKERFILE),$(BL_LINKERFILE),$(1))) 31073c99d4eSJuan Castillo 31151b27702SEvan Lloyd$(ELF): $(OBJS) $(LINKERFILE) | bl$(1)_dirs 31273c99d4eSJuan Castillo @echo " LD $$@" 313414ab853SEvan Lloydifdef MAKE_BUILD_STRINGS 314414ab853SEvan Lloyd $(call MAKE_BUILD_STRINGS, $(BUILD_DIR)/build_message.o) 315414ab853SEvan Lloydelse 3162f5d4a48SPatrick Georgi @echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP); \ 31773c99d4eSJuan Castillo const char version_string[] = "${VERSION_STRING}";' | \ 318f2e1d57eSMasahiro Yamada $$(CC) $$(TF_CFLAGS) $$(CFLAGS) -xc -c - -o $(BUILD_DIR)/build_message.o 319414ab853SEvan Lloydendif 320c2b8806fSDouglas Raillard $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Map=$(MAPFILE) \ 321048531d7SSoby Mathew --script $(LINKERFILE) $(BUILD_DIR)/build_message.o $(OBJS) $(LDLIBS) 32273c99d4eSJuan Castillo 32373c99d4eSJuan Castillo$(DUMP): $(ELF) 32473c99d4eSJuan Castillo @echo " OD $$@" 32573c99d4eSJuan Castillo $${Q}$${OD} -dx $$< > $$@ 32673c99d4eSJuan Castillo 32773c99d4eSJuan Castillo$(BIN): $(ELF) 32873c99d4eSJuan Castillo @echo " BIN $$@" 32973c99d4eSJuan Castillo $$(Q)$$(OC) -O binary $$< $$@ 330052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 33173c99d4eSJuan Castillo @echo "Built $$@ successfully" 332052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 33373c99d4eSJuan Castillo 33473c99d4eSJuan Castillo.PHONY: bl$(1) 33551b27702SEvan Lloydbl$(1): $(BIN) $(DUMP) 33673c99d4eSJuan Castillo 33773c99d4eSJuan Castilloall: bl$(1) 33873c99d4eSJuan Castillo 33973c99d4eSJuan Castillo$(eval $(call MAKE_TOOL_ARGS,$(1),$(BIN),$(2))) 34073c99d4eSJuan Castillo 34173c99d4eSJuan Castilloendef 34273c99d4eSJuan Castillo 34303b397a8SNishanth Menondefine SOURCES_TO_DTBS 34403b397a8SNishanth Menon $(notdir $(patsubst %.dts,%.dtb,$(filter %.dts,$(1)))) 34503b397a8SNishanth Menonendef 34603b397a8SNishanth Menon 34703b397a8SNishanth Menon# MAKE_FDT macro defines the targets and options to build each FDT binary 34803b397a8SNishanth Menon# Arguments: (none) 34903b397a8SNishanth Menondefine MAKE_FDT 35003b397a8SNishanth Menon $(eval DTB_BUILD_DIR := ${BUILD_PLAT}/fdts) 35103b397a8SNishanth Menon $(eval DTBS := $(addprefix $(DTB_BUILD_DIR)/,$(call SOURCES_TO_DTBS,$(FDT_SOURCES)))) 35203b397a8SNishanth Menon $(eval TEMP_DTB_DIRS := $(sort $(dir ${DTBS}))) 35303b397a8SNishanth Menon # The $(dir ) function leaves a trailing / on the directory names 35403b397a8SNishanth Menon # Rip off the / to match directory names with make rule targets. 35503b397a8SNishanth Menon $(eval DTB_DIRS := $(patsubst %/,%,$(TEMP_DTB_DIRS))) 35603b397a8SNishanth Menon 35703b397a8SNishanth Menon$(eval $(foreach objd,${DTB_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR}))) 35803b397a8SNishanth Menon 35903b397a8SNishanth Menonfdt_dirs: ${DTB_DIRS} 36003b397a8SNishanth Menon 36103b397a8SNishanth Menonendef 36203b397a8SNishanth Menon 36303b397a8SNishanth Menon# MAKE_DTB generate the Flattened device tree binary (device tree binary) 36403b397a8SNishanth Menon# $(1) = output directory 36503b397a8SNishanth Menon# $(2) = input dts 36603b397a8SNishanth Menondefine MAKE_DTB 36703b397a8SNishanth Menon 36803b397a8SNishanth Menon$(eval DOBJ := $(1)/$(patsubst %.dts,%.dtb,$(notdir $(2)))) 36903b397a8SNishanth Menon$(eval DEP := $(patsubst %.dtb,%.d,$(DOBJ))) 37003b397a8SNishanth Menon 37103b397a8SNishanth Menon$(DOBJ): $(2) | fdt_dirs 37203b397a8SNishanth Menon @echo " DTC $$<" 37303b397a8SNishanth Menon $$(Q)$$(DTC) $$(DTC_FLAGS) -d $(DEP) -o $$@ $$< 37403b397a8SNishanth Menon 37503b397a8SNishanth Menon-include $(DEP) 37603b397a8SNishanth Menon 37703b397a8SNishanth Menonendef 37803b397a8SNishanth Menon 37903b397a8SNishanth Menon# MAKE_DTBS builds flattened device tree sources 38003b397a8SNishanth Menon# $(1) = output directory 38103b397a8SNishanth Menon# $(2) = list of flattened device tree source files 38203b397a8SNishanth Menondefine MAKE_DTBS 38303b397a8SNishanth Menon $(eval DOBJS := $(filter %.dts,$(2))) 38403b397a8SNishanth Menon $(eval REMAIN := $(filter-out %.dts,$(2))) 38503b397a8SNishanth Menon $(eval $(foreach obj,$(DOBJS),$(call MAKE_DTB,$(1),$(obj)))) 38603b397a8SNishanth Menon 38703b397a8SNishanth Menon $(and $(REMAIN),$(error Unexpected s present: $(REMAIN))) 38803b397a8SNishanth Menonendef 389