xref: /rk3399_ARM-atf/Makefile (revision 27bc1386f00a2a5089e27ff00f97b41821dc08ed)
14f6ad66aSAchin Gupta#
2c3273703SChris Kay# Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
34f6ad66aSAchin Gupta#
482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
54f6ad66aSAchin Gupta#
64f6ad66aSAchin Gupta
7e35c4045SJeenu Viswambharan#
8aaa3e722SJuan Castillo# Trusted Firmware Version
9aaa3e722SJuan Castillo#
101a0f1121SSoby MathewVERSION_MAJOR			:= 2
111c26b186SArvind Ram PrakashVERSION_MINOR			:= 14
12c25d1ccfSYann Gautier# VERSION_PATCH is only used for LTS releases
13c25d1ccfSYann GautierVERSION_PATCH			:= 0
14055ebecaSYann GautierVERSION				:= ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
15aaa3e722SJuan Castillo
1688154678SJuan Castillo# Default goal is build all images
1788154678SJuan Castillo.DEFAULT_GOAL			:= all
1888154678SJuan Castillo
1972fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to
2072fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
2172fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual.
2272fc70edSDouglas RaillardMAKEOVERRIDES =
2372fc70edSDouglas Raillard
24231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/
25231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
26f4dd18c2SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}build-rules.mk
277c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk
2873c99d4eSJuan Castillo
2973c99d4eSJuan Castillo################################################################################
302fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies
3173c99d4eSJuan Castillo################################################################################
32e35c4045SJeenu Viswambharan
332fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
3428973741SBoyan Karatotev# Include the CPU specific operations makefile, which provides default
3528973741SBoyan Karatotev# values for all CPU errata workarounds and CPU specific optimisations.
3628973741SBoyan Karatotev# This can be overridden by the platform.
3728973741SBoyan Karatotevinclude lib/cpus/cpu-ops.mk
3828973741SBoyan Karatotev
39422b181fSYann GautierPLAT				:= ${DEFAULT_PLAT}
401b2fb6adSAndrey Skvortsovinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
411b2fb6adSAndrey Skvortsov
421b2fb6adSAndrey Skvortsov# To be able to set platform specific defaults
431b2fb6adSAndrey Skvortsovifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
441b2fb6adSAndrey Skvortsovinclude ${PLAT_DEFAULTS_MAKEFILE_FULL}
451b2fb6adSAndrey Skvortsovendif
46872be88aSdp-arm
47cc277de8SChris Kay################################################################################
48cc277de8SChris Kay# Configure the toolchains used to build TF-A and its tools
49cc277de8SChris Kay################################################################################
50cc277de8SChris Kay
51cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk
52cc277de8SChris Kay
53cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default
54cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS		:= ${DEBUG}
552fae4b1eSJeenu ViswambharanENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
5673c99d4eSJuan Castillo
5773c99d4eSJuan Castillo################################################################################
5873c99d4eSJuan Castillo# Checkpatch script options
5973c99d4eSJuan Castillo################################################################################
6073c99d4eSJuan Castillo
61f607739cSSandrine BailleuxCHECKCODE_ARGS		:=	--no-patch
62f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files
634501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
644501843fSGilad Ben-Yossef					include/drivers/arm,		\
654501843fSGilad Ben-Yossef					$(wildcard include/drivers/*)))
66f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
6718818426SChris Kay					lib/libfdt		\
6861f72a34SRoberto Vargas					include/lib/libc,		\
69f0b489c1SDan Handley					$(wildcard include/lib/*)))
70f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
714501843fSGilad Ben-Yossef					include/lib			\
724501843fSGilad Ben-Yossef					include/drivers,		\
73f0b489c1SDan Handley					$(wildcard include/*)))
74f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
75d801fbb0Sdp-arm					lib/compiler-rt			\
7655cdcf75SAntonio Nino Diaz					lib/libfdt%			\
7761f72a34SRoberto Vargas					lib/libc,			\
78a194255dSDaniel Boulby					lib/zlib			\
79f0b489c1SDan Handley					$(wildcard lib/*)))
80f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
81f0b489c1SDan Handley					lib				\
82f0b489c1SDan Handley					include				\
83f0b489c1SDan Handley					docs				\
841ef35512SPaul Beesley					%.rst,				\
85f0b489c1SDan Handley					$(wildcard *)))
86f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
87f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
88f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
894501843fSGilad Ben-Yossef				${LIB_DIRS_TO_CHECK}			\
904501843fSGilad Ben-Yossef				${INC_DRV_DIRS_TO_CHECK}		\
914501843fSGilad Ben-Yossef				${INC_ARM_DIRS_TO_CHECK}
9236eaaf37SIan Spray
9373c99d4eSJuan Castillo################################################################################
9473c99d4eSJuan Castillo# Process build options
9573c99d4eSJuan Castillo################################################################################
9673c99d4eSJuan Castillo
977c4e1eeaSChris Kayifeq ($(verbose),)
9836eaaf37SIan Spray	CHECKCODE_ARGS	+=	--no-summary --terse
994f6ad66aSAchin Guptaendif
100ee1ba6d4SAndre Przywara
10173c99d4eSJuan Castillo################################################################################
102c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc)
103c5e1da83SJayanth Dodderi Chidanand################################################################################
104c5e1da83SJayanth Dodderi Chidanand
105c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool
106c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH		?=	tools/cert_create
107f4595e6eSBoyan KaratotevCRTTOOL			?=	${BUILD_PLAT}/${CRTTOOLPATH}/cert_create$(.exe)
108c5e1da83SJayanth Dodderi Chidanand
109c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool
110c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH		?=	tools/encrypt_fw
11196fbe884SBoyan KaratotevENCTOOL			?=	${BUILD_PLAT}/${ENCTOOLPATH}/encrypt_fw$(.exe)
112c5e1da83SJayanth Dodderi Chidanand
113c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package
114c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH		?=	tools/fiptool
115cbd6cec3SBoyan KaratotevFIPTOOL			?=	${BUILD_PLAT}/${FIPTOOLPATH}/fiptool$(.exe)
116c5e1da83SJayanth Dodderi Chidanand
117c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool
118c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH		?=	tools/sptool
119c5e1da83SJayanth Dodderi ChidanandSPTOOL			?=	${SPTOOLPATH}/sptool.py
120c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
12120629b31SKarl MeakinSP_DTS_LIST_FRAGMENT	?=	${BUILD_PLAT}/sp_list_fragment.dts
122c5e1da83SJayanth Dodderi Chidanand
1230fe374efSJ-Alves# Variables for use with sptool
1240fe374efSJ-AlvesTLCTOOL 		?=	poetry run tlc
1250fe374efSJ-Alves
126c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB
127c5e1da83SJayanth Dodderi ChidanandROMLIBPATH		?=	lib/romlib
128c5e1da83SJayanth Dodderi Chidanand
129c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python
130c5e1da83SJayanth Dodderi ChidanandPYTHON			?=	python3
131c5e1da83SJayanth Dodderi Chidanand
132c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool
133c5e1da83SJayanth Dodderi ChidanandDOCS_PATH		?=	docs
134c5e1da83SJayanth Dodderi Chidanand
13532b209bfSAhmad Fatoum# Process Debug flag
13632b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
13732b209bfSAhmad Fatoum	BUILD_TYPE	:=	debug
13832b209bfSAhmad Fatoum	# Use LOG_LEVEL_INFO by default for debug builds
13932b209bfSAhmad Fatoum	LOG_LEVEL	:=	40
14032b209bfSAhmad Fatoumelse
14132b209bfSAhmad Fatoum	BUILD_TYPE	:=	release
14232b209bfSAhmad Fatoum	# Use LOG_LEVEL_NOTICE by default for release builds
14332b209bfSAhmad Fatoum	LOG_LEVEL	:=	20
144fa28b3afSBoyan Karatotev        # Enable link-time optimization (AKA "inter-procedural optimization")
145fa28b3afSBoyan Karatotev        ifeq (${ARCH},aarch64)
146fa28b3afSBoyan Karatotev                ifeq ($($(ARCH)-ld-id),$($(ARCH)-cc-id))
147fa28b3afSBoyan Karatotev                        ENABLE_LTO :=	1
148fa28b3afSBoyan Karatotev                endif
149fa28b3afSBoyan Karatotev        endif
150c5e1da83SJayanth Dodderi Chidanandendif #(Debug)
15132b209bfSAhmad Fatoum
152f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
153f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
154f1de4c8fSPeiyuan Song	BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
155f1de4c8fSPeiyuan Songendif
156dddf4283Slaurenw-armVERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
157f1de4c8fSPeiyuan Song
158d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues
159d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings
160d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed
161d75a9ecdSBoyan Karatotevifdef W
162d75a9ecdSBoyan Karatotev	ifneq (${W},0)
163d75a9ecdSBoyan Karatotev		E	 ?= 0
164d75a9ecdSBoyan Karatotev	endif
165d75a9ecdSBoyan Karatotevendif
166d75a9ecdSBoyan Karatotev
16773c99d4eSJuan Castillo################################################################################
168f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features.
169f5211420SGovindraj Raja################################################################################
170f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
1717d5fc98fSAlexeiFedorov	ARM_ARCH_MAJOR := 9
1727d5fc98fSAlexeiFedorov	ARM_ARCH_MINOR := 2
173f5211420SGovindraj Rajaendif
174f5211420SGovindraj Raja
175f5211420SGovindraj Raja################################################################################
17673c99d4eSJuan Castillo# Common sources and include directories
17773c99d4eSJuan Castillo################################################################################
178d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
17973c99d4eSJuan Castillo
180758ccb80SChris Kay# Allow overriding the timestamp, for example for reproducible builds, or to
181758ccb80SChris Kay# synchronize timestamps across multiple projects.
182758ccb80SChris Kay# This must be set to a C string (including quotes where applicable).
183758ccb80SChris KayBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
184758ccb80SChris Kay
185758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
186758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
187758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
188758ccb80SChris Kay
18973c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
1907f56e9a3SSoby Mathew				common/tf_log.c				\
1919d29c227SSoby Mathew				common/${ARCH}/debug.S			\
19291b48c9fSJulius Werner				drivers/console/multi_console.c		\
1939d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
1949d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
195c73686a1SBoyan Karatotev				lib/extensions/pmuv3/${ARCH}/pmuv3.c	\
19638e580e6SBoyan Karatotev				lib/locks/exclusive/${ARCH}/spinlock.c	\
197566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
1987f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
19975311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
2009d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
20161f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
202d7a6b0f8SRyan Harkin
2038620bd0bSChris Kayifeq ($($(ARCH)-cc-id),arm-clang)
2048422a840SAntonio Nino Diaz	BL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
2058422a840SAntonio Nino Diazendif
2068422a840SAntonio Nino Diaz
2071f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
2081f461979SJustin Chadwell	BL_COMMON_SOURCES	+=	plat/common/ubsan.c
2091f461979SJustin Chadwellendif
2101f461979SJustin Chadwell
21101d237cbSYann GautierINCLUDES		+=	-Iinclude				\
212f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
21309d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
21409d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
21509d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
21609d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
21709d40e0eSAntonio Nino Diaz
2189c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
2199c6d1c50SAntonio Nino Diaz
22073c99d4eSJuan Castillo################################################################################
2213547270fSGovindraj Raja# Generic definitions
2223547270fSGovindraj Raja################################################################################
2233547270fSGovindraj Raja
2243547270fSGovindraj Rajaifeq (${BUILD_BASE},)
2253547270fSGovindraj Raja     BUILD_BASE		:=	./build
2263547270fSGovindraj Rajaendif
2273547270fSGovindraj RajaBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
2283547270fSGovindraj Raja
2293547270fSGovindraj RajaSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
2303547270fSGovindraj Raja
2313547270fSGovindraj Raja# Platforms providing their own TBB makefile may override this value
2323547270fSGovindraj RajaINCLUDE_TBBR_MK		:=	1
2333547270fSGovindraj Raja
2343547270fSGovindraj Raja################################################################################
2353547270fSGovindraj Raja# Include SPD Makefile if one has been specified
2363547270fSGovindraj Raja################################################################################
2373547270fSGovindraj Raja
2383547270fSGovindraj Rajaifneq (${SPD},none)
2393547270fSGovindraj Raja	ifeq (${SPD},spmd)
2403547270fSGovindraj Raja	# SPMD is located in std_svc directory
2413547270fSGovindraj Raja		SPD_DIR := std_svc
2423547270fSGovindraj Raja
2433547270fSGovindraj Raja		ifeq ($(SPMD_SPM_AT_SEL2),1)
2443547270fSGovindraj Raja			CTX_INCLUDE_EL2_REGS := 1
2453547270fSGovindraj Raja		endif
2463547270fSGovindraj Raja
2473547270fSGovindraj Raja		ifneq ($(SP_LAYOUT_FILE),)
2483547270fSGovindraj Raja		BL2_ENABLE_SP_LOAD := 1
2493547270fSGovindraj Raja		endif
2503547270fSGovindraj Raja	else
2513547270fSGovindraj Raja		# All other SPDs in spd directory
2523547270fSGovindraj Raja		SPD_DIR := spd
2533547270fSGovindraj Raja	endif #(SPD)
2543547270fSGovindraj Raja
2553547270fSGovindraj Raja	# We expect to locate an spd.mk under the specified SPD directory
2563547270fSGovindraj Raja	SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
2573547270fSGovindraj Raja
2583547270fSGovindraj Raja	ifeq (${SPD_MAKE},)
2593547270fSGovindraj Raja                $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
2603547270fSGovindraj Raja	endif
2613547270fSGovindraj Raja        $(info Including ${SPD_MAKE})
2623547270fSGovindraj Raja        include ${SPD_MAKE}
2633547270fSGovindraj Raja
2643547270fSGovindraj Raja	# If there's BL32 companion for the chosen SPD, we expect that the SPD's
2653547270fSGovindraj Raja	# Makefile would set NEED_BL32 to "yes". In this case, the build system
2663547270fSGovindraj Raja	# supports two mutually exclusive options:
2673547270fSGovindraj Raja	# * BL32 is built from source: then BL32_SOURCES must contain the list
2683547270fSGovindraj Raja	#   of source files to build BL32
2693547270fSGovindraj Raja	# * BL32 is a prebuilt binary: then BL32 must point to the image file
2703547270fSGovindraj Raja	#   that will be included in the FIP
2713547270fSGovindraj Raja	# If both BL32_SOURCES and BL32 are defined, the binary takes precedence
2723547270fSGovindraj Raja	# over the sources.
2733547270fSGovindraj Rajaendif #(SPD=none)
2743547270fSGovindraj Raja
2753547270fSGovindraj Raja################################################################################
276696ed168SOlivier Deprez# Include the platform specific Makefile after the SPD Makefile (the platform
277696ed168SOlivier Deprez# makefile may use all previous definitions in this file)
278696ed168SOlivier Deprez################################################################################
279696ed168SOlivier Deprezinclude ${PLAT_MAKEFILE_FULL}
280696ed168SOlivier Deprez
281696ed168SOlivier Deprez################################################################################
2828d9f5f25SBoyan Karatotev# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
2838d9f5f25SBoyan Karatotev# platform.
2848d9f5f25SBoyan Karatotev################################################################################
2858d9f5f25SBoyan Karatotev
2868d9f5f25SBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
2878d9f5f25SBoyan Karatotev################################################################################
288f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set
289f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags
290f5211420SGovindraj Raja################################################################################
291f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0)
292f5211420SGovindraj Raja	# Default value turns off all types of branch protection
293f5211420SGovindraj Raja	BP_OPTION := none
294f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64)
295f5211420SGovindraj Raja        $(error BRANCH_PROTECTION requires AArch64)
296f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1)
297f5211420SGovindraj Raja	# Enables all types of branch protection features
298f5211420SGovindraj Raja	BP_OPTION := standard
299f5211420SGovindraj Raja	ENABLE_BTI := 1
300f5211420SGovindraj Raja	ENABLE_PAUTH := 1
301f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2)
302f5211420SGovindraj Raja	# Return address signing to its standard level
303f5211420SGovindraj Raja	BP_OPTION := pac-ret
304f5211420SGovindraj Raja	ENABLE_PAUTH := 1
305f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3)
306f5211420SGovindraj Raja	# Extend the signing to include leaf functions
307f5211420SGovindraj Raja	BP_OPTION := pac-ret+leaf
308f5211420SGovindraj Raja	ENABLE_PAUTH := 1
309f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4)
310f5211420SGovindraj Raja	# Turn on branch target identification mechanism
311f5211420SGovindraj Raja	BP_OPTION := bti
312f5211420SGovindraj Raja	ENABLE_BTI := 1
3138d9f5f25SBoyan Karatotevelse ifeq (${BRANCH_PROTECTION},5)
3148d9f5f25SBoyan Karatotev	# Turn on branch target identification mechanism
3158d9f5f25SBoyan Karatotev	BP_OPTION := standard
3168d9f5f25SBoyan Karatotev	ENABLE_BTI := 2
3178d9f5f25SBoyan Karatotev	ENABLE_PAUTH := 2
318f5211420SGovindraj Rajaelse
319f5211420SGovindraj Raja        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
320f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION)
321f5211420SGovindraj Raja
3228d9f5f25SBoyan Karatotevifneq ($(ENABLE_PAUTH),0)
3238d9f5f25SBoyan Karatotev	CTX_INCLUDE_PAUTH_REGS	:= ${ENABLE_PAUTH}
324f5211420SGovindraj Rajaendif
325f5211420SGovindraj Raja
326f5211420SGovindraj Raja# Pointer Authentication sources
3278d9f5f25SBoyan Karatotevifneq (${ENABLE_PAUTH},0)
328f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
329f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms
3308d9f5f25SBoyan Karatotev	BL_COMMON_SOURCES	+=	lib/extensions/pauth/pauth.c
331f5211420SGovindraj Rajaendif
332f5211420SGovindraj Raja
333f5211420SGovindraj Raja################################################################################
334f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME.
335f5211420SGovindraj Raja################################################################################
336f5211420SGovindraj Raja# FEAT_RME
337f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
338cbba59c4SSona Mathew	# RMM relies on SMCCC_ARCH_FEATURE_AVAILABILITY to discover EL3 enablement
339cbba59c4SSona Mathew	ARCH_FEATURE_AVAILABILITY := 1
340cbba59c4SSona Mathew
341f5211420SGovindraj Raja	# RME requires el2 context to be saved for now.
342f5211420SGovindraj Raja	CTX_INCLUDE_EL2_REGS := 1
343f5211420SGovindraj Raja	CTX_INCLUDE_AARCH32_REGS := 0
344f5211420SGovindraj Raja	CTX_INCLUDE_PAUTH_REGS := 1
345f5211420SGovindraj Raja
346d048af0dSJavier Almansa Sobrino	ifneq ($(ENABLE_FEAT_MPAM), 0)
347d048af0dSJavier Almansa Sobrino		CTX_INCLUDE_MPAM_REGS := 1
348d048af0dSJavier Almansa Sobrino	endif
34938e580e6SBoyan Karatotev	# bitlocks are only useful with atomics
35038e580e6SBoyan Karatotev	ifneq ($(RME_GPT_BITLOCK_BLOCK), 0)
35138e580e6SBoyan Karatotev		USE_SPINLOCK_CAS := 1
35238e580e6SBoyan Karatotev	endif
353d048af0dSJavier Almansa Sobrino
354f5211420SGovindraj Raja	# RME enables CSV2_2 extension by default.
355f5211420SGovindraj Raja	ENABLE_FEAT_CSV2_2 = 1
356f5211420SGovindraj Rajaendif #(FEAT_RME)
357f5211420SGovindraj Raja
358f5211420SGovindraj Raja################################################################################
3595b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled
3605b18de09SZelalem Aweke################################################################################
3615b18de09SZelalem Awekeifneq (${ENABLE_RME},0)
3625b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk
3635b18de09SZelalem Aweke$(warning "RME is an experimental feature")
3645b18de09SZelalem Awekeendif
3655b18de09SZelalem Aweke
3667e84f3cfSTushar Khandelwal################################################################################
36730655136SGovindraj Raja# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
36830655136SGovindraj Raja################################################################################
36930655136SGovindraj Rajaifneq (${ENABLE_FEAT_D128}, 0)
37030655136SGovindraj Raja        BL_COMMON_SOURCES       +=      lib/extensions/sysreg128/sysreg128.S
37130655136SGovindraj Rajaendif
37230655136SGovindraj Raja
37342d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios
37442d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios -
37542d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running
37642d4d3baSArvind Ram Prakash# BL2 in EL3
37742d4d3baSArvind Ram Prakash
37842d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1)
37942d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
38042d4d3baSArvind Ram Prakash	ifeq (${ENABLE_RME},1)
381c5e1da83SJayanth Dodderi Chidanand                $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
382c5e1da83SJayanth Dodderi Chidanand                supported at the moment.)
38342d4d3baSArvind Ram Prakash	endif
38442d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1)
38542d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
38642d4d3baSArvind Ram Prakashelse
38742d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	0
38842d4d3baSArvind Ram Prakashendif
38942d4d3baSArvind Ram Prakash
390f87e54f7SManish Pandey# This internal flag is set to 1 when Firmware First handling of External aborts
391f87e54f7SManish Pandey# is required by lowe ELs. Currently only NS requires this support.
392f87e54f7SManish Pandeyifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
393f87e54f7SManish Pandey	FFH_SUPPORT := 1
394f87e54f7SManish Pandeyelse
395f87e54f7SManish Pandey	FFH_SUPPORT := 0
396f87e54f7SManish Pandeyendif
397f87e54f7SManish Pandey
398c2dc5129SBoyan Karatotevifneq ($(filter 1,${ERRATA_A53_1530924} ${ERRATA_A55_1530923}	\
3998177e1efSXialin Liu        ${ERRATA_A57_1319537} ${ERRATA_A65_1541130} ${ERRATA_A72_1319367}	\
4008177e1efSXialin Liu		${ERRATA_A76_1165522}),)
401c2dc5129SBoyan KaratotevERRATA_SPECULATIVE_AT	:= 1
402c2dc5129SBoyan Karatotevelse
403c2dc5129SBoyan KaratotevERRATA_SPECULATIVE_AT	:= 0
404c2dc5129SBoyan Karatotevendif
405c2dc5129SBoyan Karatotev
406a4409008Sdp-arm################################################################################
407a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
408a4409008Sdp-arm################################################################################
409c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32)
410c5e1da83SJayanth Dodderi Chidanand        NEED_BL32 := yes
411c5e1da83SJayanth Dodderi Chidanand
412a4409008Sdp-arm        ifneq (${AARCH32_SP},none)
413a4409008Sdp-arm        # We expect to locate an sp.mk under the specified AARCH32_SP directory
414a4409008Sdp-arm		AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
415a4409008Sdp-arm
416a4409008Sdp-arm                ifeq (${AARCH32_SP_MAKE},)
417a4409008Sdp-arm                        $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
418a4409008Sdp-arm                endif
419a4409008Sdp-arm                $(info Including ${AARCH32_SP_MAKE})
420a4409008Sdp-arm                include ${AARCH32_SP_MAKE}
421a4409008Sdp-arm        endif
422c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
4234f6ad66aSAchin Gupta
42473c99d4eSJuan Castillo################################################################################
42577f1f7a1SVarun Wadekar# Include libc if not overridden
42677f1f7a1SVarun Wadekar################################################################################
42777f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
42877f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
42977f1f7a1SVarun Wadekarendif
43077f1f7a1SVarun Wadekar
4315d893410SBoyan Karatotevifneq (${USE_GIC_DRIVER},0)
4325d893410SBoyan Karatotevinclude drivers/arm/gic/gic.mk
4335d893410SBoyan Karatotevendif
4345d893410SBoyan Karatotev
43577f1f7a1SVarun Wadekar################################################################################
436c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies
437cf2c8a33SAntonio Nino Diaz################################################################################
438b14987cfSBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}constraints.mk
439c5e1da83SJayanth Dodderi Chidanand
440c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the
441c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all
442c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0)
443c5e1da83SJayanth Dodderi Chidanand    FIP_DEPS += certificates
444c5e1da83SJayanth Dodderi Chidanand    FWU_FIP_DEPS += fwu_certificates
445d57362bdSXialin Liu    BL2_FIP_DEPS += bl2_certificates
446c5e1da83SJayanth Dodderi Chidanandendif
447c5e1da83SJayanth Dodderi Chidanand
448c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none)
449c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -f ${FW_ENC_STATUS}
450c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -k ${ENC_KEY}
451c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -n ${ENC_NONCE}
452c5e1da83SJayanth Dodderi Chidanand	FIP_DEPS += enctool
453c5e1da83SJayanth Dodderi Chidanand	FWU_FIP_DEPS += enctool
454d57362bdSXialin Liu	BL2_FIP_DEPS += enctool
455c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
456c5e1da83SJayanth Dodderi Chidanand
457cf2c8a33SAntonio Nino Diaz################################################################################
45873c99d4eSJuan Castillo# Process platform overrideable behaviour
45973c99d4eSJuan Castillo################################################################################
4604f6ad66aSAchin Gupta
4615f24ce96SManish Pandeyifdef BL1_SOURCES
4625f24ce96SManish Pandey	NEED_BL1 := yes
463c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES)
4645f24ce96SManish Pandey
4655f24ce96SManish Pandeyifdef BL2_SOURCES
4665f24ce96SManish Pandey	NEED_BL2 := yes
4675f24ce96SManish Pandey
468bd97f83aSJohn Tsichritzis	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
469bd97f83aSJohn Tsichritzis	# Certificate generation tools. This flag can be overridden by the platform.
470cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
471cf2c8a33SAntonio Nino Diaz		# If booting an EL3 payload there is no need for a BL33 image
472cf2c8a33SAntonio Nino Diaz		# in the FIP file.
4734c117f6cSSandrine Bailleux		NEED_BL33		:=	no
474cf2c8a33SAntonio Nino Diaz	else
47568450a6dSAntonio Nino Diaz		ifdef PRELOADED_BL33_BASE
476cf2c8a33SAntonio Nino Diaz			# If booting a BL33 preloaded image there is no need of
477cf2c8a33SAntonio Nino Diaz			# another one in the FIP file.
478cf2c8a33SAntonio Nino Diaz			NEED_BL33		:=	no
479cf2c8a33SAntonio Nino Diaz		else
480cf2c8a33SAntonio Nino Diaz			NEED_BL33		?=	yes
481cf2c8a33SAntonio Nino Diaz		endif
4824c117f6cSSandrine Bailleux	endif
483c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES)
4846f971622SJuan Castillo
4855f24ce96SManish Pandeyifdef BL2U_SOURCES
4865f24ce96SManish Pandey	NEED_BL2U := yes
487c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES)
4885f24ce96SManish Pandey
4894d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
4904d045d0eSMasahiro Yamadaifdef SCP_BL2
4914d045d0eSMasahiro Yamada	NEED_SCP_BL2		:=	yes
492c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2)
4934d045d0eSMasahiro Yamada
4945744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
4955744e874SSoby Mathewifneq (${ARCH},aarch32)
4965744e874SSoby Mathew	ifdef BL31_SOURCES
497c5e1da83SJayanth Dodderi Chidanand	# When booting an EL3 payload, there is no need to compile the BL31
498c5e1da83SJayanth Dodderi Chidanand	# image nor put it in the FIP.
4995744e874SSoby Mathew		ifndef EL3_PAYLOAD_BASE
5005744e874SSoby Mathew			NEED_BL31 := yes
5015744e874SSoby Mathew		endif
5025744e874SSoby Mathew	endif
503c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64)
5045744e874SSoby Mathew
50573c99d4eSJuan Castillo# Process TBB related flags
5066f971622SJuan Castilloifneq (${GENERATE_COT},0)
50773c99d4eSJuan Castillo    # Common cert_create options
5086f971622SJuan Castillo    ifneq (${CREATE_KEYS},0)
5096f971622SJuan Castillo        $(eval CRT_ARGS += -n)
5100191262dSYatharth Kochar        $(eval FWU_CRT_ARGS += -n)
511d57362bdSXialin Liu        $(eval BL2_CRT_ARGS += -n)
512fd34e7baSJuan Castillo        ifneq (${SAVE_KEYS},0)
513fd34e7baSJuan Castillo            $(eval CRT_ARGS += -k)
5140191262dSYatharth Kochar            $(eval FWU_CRT_ARGS += -k)
515d57362bdSXialin Liu            $(eval BL2_CRT_ARGS += -k)
516fd34e7baSJuan Castillo        endif
5176f971622SJuan Castillo    endif
51873c99d4eSJuan Castillo    # Include TBBR makefile (unless the platform indicates otherwise)
51973c99d4eSJuan Castillo    ifeq (${INCLUDE_TBBR_MK},1)
52073c99d4eSJuan Castillo        include make_helpers/tbbr/tbbr_tools.mk
52173c99d4eSJuan Castillo    endif
522c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
5236f971622SJuan Castillo
5241c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
5251c75d5dfSMasahiro Yamada	FIP_ARGS += --align ${FIP_ALIGN}
526c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN)
5271c75d5dfSMasahiro Yamada
5285f24ce96SManish Pandeyifdef FDT_SOURCES
5295f24ce96SManish Pandey	NEED_FDT := yes
530c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES)
5315f24ce96SManish Pandey
53273c99d4eSJuan Castillo################################################################################
53346e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
53446e5e035SMichalis Pappas################################################################################
53546e5e035SMichalis Pappas
53646e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
53746e5e035SMichalis Pappas
53846e5e035SMichalis Pappas################################################################################
5398a86052dSSoby Mathew# Include BL specific makefiles
5408a86052dSSoby Mathew################################################################################
5415f24ce96SManish Pandey
5425f24ce96SManish Pandeyifeq (${NEED_BL1},yes)
5438a86052dSSoby Mathewinclude bl1/bl1.mk
5448a86052dSSoby Mathewendif
5458a86052dSSoby Mathew
5465f24ce96SManish Pandeyifeq (${NEED_BL2},yes)
5478a86052dSSoby Mathewinclude bl2/bl2.mk
5488a86052dSSoby Mathewendif
5498a86052dSSoby Mathew
5505f24ce96SManish Pandeyifeq (${NEED_BL2U},yes)
5518a86052dSSoby Mathewinclude bl2u/bl2u.mk
5528a86052dSSoby Mathewendif
5538a86052dSSoby Mathew
5545744e874SSoby Mathewifeq (${NEED_BL31},yes)
5558a86052dSSoby Mathewinclude bl31/bl31.mk
5568a86052dSSoby Mathewendif
55703b397a8SNishanth Menon
55873c99d4eSJuan Castillo################################################################################
55973c99d4eSJuan Castillo# Build options checks
56073c99d4eSJuan Castillo################################################################################
56173c99d4eSJuan Castillo
562c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags
563327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
564327131c4SLeonardo Sandoval    $(sort \
565327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
56646789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
567327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
56828973741SBoyan Karatotev	$(CPU_FLAG_LIST) \
569327131c4SLeonardo Sandoval	CREATE_KEYS \
570327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
571327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
57242422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
573327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
5749acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
575327131c4SLeonardo Sandoval	DEBUG \
576327131c4SLeonardo Sandoval	DYN_DISABLE_AUTH \
577327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
5781fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
579873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
580327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
581327131c4SLeonardo Sandoval	ENABLE_PIE \
582327131c4SLeonardo Sandoval	ENABLE_PMF \
583327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
584327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
585dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
5860c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
5878cef63d6SBoyan Karatotev	ENABLE_FEAT_GCIE \
588970a4a8dSManish Pandey	ENABLE_FEAT_RAS	\
589f87e54f7SManish Pandey	FFH_SUPPORT	\
590327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
591327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
592327131c4SLeonardo Sandoval	GENERATE_COT \
593327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
59446cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
595538516f5SBipin Ravi	HARDEN_SLS \
596327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
597327131c4SLeonardo Sandoval	MEASURED_BOOT \
59836e3d877SAbhi.Singh	DISCRETE_TPM \
599e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
6006a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
6012132c707SSona Mathew	RMMD_ENABLE_IDE_KEY_PROG \
60200e28874SManish V Badarkhe	DRTM_SUPPORT \
603327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
604327131c4SLeonardo Sandoval	OVERRIDE_LIBC \
605327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
6065be66449SBoyan Karatotev	PLAT_EXTRA_LD_SCRIPT \
607327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
608327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
60964b4710bSWing Li	PSCI_OS_INIT_MODE \
6108db17052SBoyan Karatotev	ARCH_FEATURE_AVAILABILITY \
611327131c4SLeonardo Sandoval	RESET_TO_BL31 \
612327131c4SLeonardo Sandoval	SAVE_KEYS \
613327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
61496a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
615327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
61686acbbe2SYe Li	SEPARATE_RWDATA_REGION \
617308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
618327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
619327131c4SLeonardo Sandoval	SPM_MM \
6201d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
621801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
622327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
623890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
6243ba2c151SRaymond Mao	TRANSFER_LIST \
625327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
626327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
627327131c4SLeonardo Sandoval	USE_DEBUGFS \
628291e493dSHarrison Mutai	USE_KERNEL_DT_CONVENTION \
629327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
630327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
631327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
632327131c4SLeonardo Sandoval	USE_ROMLIB \
633327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
634327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
63542d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
636327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
637327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
638327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
639327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
640327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
64145c7328cSBoyan Karatotev	ERRATA_SME_POWER_DOWN \
64200e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
643327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
644327131c4SLeonardo Sandoval	USE_SP804_TIMER \
645396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
64611d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
64768120783SChris Kay	ENABLE_MPMM \
6486a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
6490b22e591SJayanth Dodderi Chidanand	TRNG_SUPPORT \
650593ae354SBoyan Karatotev	ENABLE_ERRATA_ALL \
651ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
652ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
65304c7303bSOkash Khawaja	CONDITIONAL_CMO \
6545782b890SManish V Badarkhe	PSA_CRYPTO	\
65585bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
656183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
657bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
658ae770fedSYann Gautier	EARLY_CONSOLE \
659f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
6608953568aSLevi Yun	HOB_LIST \
661cf48f49fSManish V Badarkhe	LFA_SUPPORT \
662327131c4SLeonardo Sandoval)))
66373c99d4eSJuan Castillo
664c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags
665327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
666327131c4SLeonardo Sandoval    $(sort \
667327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
668327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
669327131c4SLeonardo Sandoval	BRANCH_PROTECTION \
6706a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_PAUTH_REGS \
6716a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_NEVE_REGS \
67283a4dae1SBoyan Karatotev	DISABLE_MTPMU \
6731298f2f1SJayanth Dodderi Chidanand	ENABLE_BRBE_FOR_NS \
67447c681b7SJayanth Dodderi Chidanand	ENABLE_TRBE_FOR_NS \
6756a0da736SJayanth Dodderi Chidanand	ENABLE_BTI \
6766a0da736SJayanth Dodderi Chidanand	ENABLE_PAUTH \
677025b1b81SJohn Powell	ENABLE_FEAT_PAUTH_LR \
678cc2523bbSAndre Przywara	ENABLE_FEAT_AIE \
679d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
6806a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
681d6affea1SGovindraj Raja	ENABLE_FEAT_CLRBHB \
682a1032bebSJohn Powell	ENABLE_FEAT_CPA2 \
6836a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
68430019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
68583271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
6866a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_DIT \
6876a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
688714a1a93SManish Pandey	ENABLE_FEAT_EBEP \
6896a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
69033e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
6914286d16fSArvind Ram Prakash	ENABLE_FEAT_UINJ \
6924274b526SArvind Ram Prakash	ENABLE_FEAT_FGWTE3 \
693a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
6946a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_HCX \
695f396aec8SArvind Ram Prakash	ENABLE_FEAT_IDTE3 \
69619d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
6977e84f3cfSTushar Khandelwal	ENABLE_FEAT_MEC \
6986b8df7b9SArvind Ram Prakash	ENABLE_FEAT_MOPS \
699*27bc1386SManoj Kumar	ENABLE_FEAT_MORELLO \
7008e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
7016a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
702b3bcfd12SAndre Przywara	ENABLE_FEAT_PFAR \
7036a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_RNG \
704ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
7056a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
706d3331603SMark Brown	ENABLE_FEAT_TCR2 \
7076d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
7080e4daed2SGovindraj Raja	ENABLE_FEAT_SB \
709062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
710062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
711062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
712062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
7134ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
71430655136SGovindraj Raja	ENABLE_FEAT_D128 \
7155e827bf0STimothy Hayes	ENABLE_FEAT_RME_GDI \
716688ab57bSMark Brown	ENABLE_FEAT_GCS \
7176a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
718edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
719c42aefd3SArvind Ram Prakash	ENABLE_FEAT_MPAM_PE_BW_CTRL \
7206a0da736SJayanth Dodderi Chidanand	ENABLE_RME \
7216437a09aSAndre Przywara	ENABLE_SPE_FOR_NS \
722603a0c6fSAndre Przywara	ENABLE_SYS_REG_TRACE_FOR_NS \
72345007acdSJayanth Dodderi Chidanand	ENABLE_SME_FOR_NS \
72403d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
7252b0bc4e0SJayanth Dodderi Chidanand	ENABLE_SVE_FOR_NS \
7266a0da736SJayanth Dodderi Chidanand	ENABLE_TRF_FOR_NS \
727327131c4SLeonardo Sandoval	FW_ENC_STATUS \
7285357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
7295357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
7300322d7afSJay Monkman	SPMC_AT_EL3_PARTITION_MAX_UUIDS \
731781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
732781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
733bebcf27fSMark Brown	SVE_VECTOR_LEN \
73438e580e6SBoyan Karatotev	USE_SPINLOCK_CAS \
7350ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
736ee580c2dSBoyan Karatotev	W \
737327131c4SLeonardo Sandoval)))
738c877b414SJeenu Viswambharan
739aacff749SJustin Chadwellifdef KEY_SIZE
740aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
741aacff749SJustin Chadwellendif
742aacff749SJustin Chadwell
7431f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
7441f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
7451f461979SJustin Chadwellendif
7461f461979SJustin Chadwell
74773c99d4eSJuan Castillo################################################################################
74873c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
74973c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
75073c99d4eSJuan Castillo# platform to overwrite the default options
75173c99d4eSJuan Castillo################################################################################
75273c99d4eSJuan Castillo
753327131c4SLeonardo Sandoval$(eval $(call add_defines,\
754327131c4SLeonardo Sandoval    $(sort \
755327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
756327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
757327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
75846789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
759327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
76028973741SBoyan Karatotev	$(CPU_FLAG_LIST) \
761327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
762327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
76342422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
764327131c4SLeonardo Sandoval	CTX_INCLUDE_PAUTH_REGS \
7659acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
766327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
767327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
768062f8aafSArunachalam Ganapathy	CTX_INCLUDE_NEVE_REGS \
769ee580c2dSBoyan Karatotev	DEBUG \
770327131c4SLeonardo Sandoval	DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
7710063dd17SJavier Almansa Sobrino	DISABLE_MTPMU \
772d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
7731fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
774873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
775327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
776327131c4SLeonardo Sandoval	ENABLE_BTI \
77783271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
778f396aec8SArvind Ram Prakash	ENABLE_FEAT_IDTE3 \
779edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
780c42aefd3SArvind Ram Prakash	ENABLE_FEAT_MPAM_PE_BW_CTRL \
781327131c4SLeonardo Sandoval	ENABLE_PAUTH \
782025b1b81SJohn Powell	ENABLE_FEAT_PAUTH_LR \
783327131c4SLeonardo Sandoval	ENABLE_PIE \
784327131c4SLeonardo Sandoval	ENABLE_PMF \
785327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
7865b18de09SZelalem Aweke	ENABLE_RME \
7876a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
7882132c707SSona Mathew	RMMD_ENABLE_IDE_KEY_PROG \
789327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
790dc78e62dSjohpow01	ENABLE_SME_FOR_NS \
79103d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
792dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
79390118bb5SAndre Przywara	ENABLE_SPE_FOR_NS \
794327131c4SLeonardo Sandoval	ENABLE_SVE_FOR_NS \
7950c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
796970a4a8dSManish Pandey	ENABLE_FEAT_RAS \
797f87e54f7SManish Pandey	FFH_SUPPORT \
798327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
799327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
800327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
801327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
802327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
80346cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
804327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
805327131c4SLeonardo Sandoval	LOG_LEVEL \
806327131c4SLeonardo Sandoval	MEASURED_BOOT \
80736e3d877SAbhi.Singh	DISCRETE_TPM \
808e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
80900e28874SManish V Badarkhe	DRTM_SUPPORT \
810327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
8117256cf0aSRohit Mathew	PLATFORM_NODE_COUNT \
812327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
8135be66449SBoyan Karatotev	PLAT_EXTRA_LD_SCRIPT \
814327131c4SLeonardo Sandoval	PLAT_${PLAT} \
815327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
816327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
81764b4710bSWing Li	PSCI_OS_INIT_MODE \
8188db17052SBoyan Karatotev	ARCH_FEATURE_AVAILABILITY \
819327131c4SLeonardo Sandoval	RESET_TO_BL31 \
820d766084fSAlexeiFedorov	RME_GPT_BITLOCK_BLOCK \
821ec0088bbSAlexeiFedorov	RME_GPT_MAX_BLOCK \
822327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
8235ce4ee1aSXialin Liu	SEPARATE_BL2_FIP \
82496a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
825327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
82686acbbe2SYe Li	SEPARATE_RWDATA_REGION \
827308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
828327131c4SLeonardo Sandoval	RECLAIM_INIT_CODE \
829327131c4SLeonardo Sandoval	SPD_${SPD} \
830327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
831327131c4SLeonardo Sandoval	SPM_MM \
8321d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
8330322d7afSJay Monkman	SPMC_AT_EL3_PARTITION_MAX_UUIDS \
834801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
835327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
8363ba2c151SRaymond Mao	TRANSFER_LIST \
837327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
8387dfb9911SJimmy Brisson	TRNG_SUPPORT \
839ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
840ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
841327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
842327131c4SLeonardo Sandoval	USE_DEBUGFS \
843327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
844327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
845327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
846327131c4SLeonardo Sandoval	USE_ROMLIB \
847327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
848291e493dSHarrison Mutai	USE_KERNEL_DT_CONVENTION \
849327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
85042d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
85142d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	\
852327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
853327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
854327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
855327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
85645c7328cSBoyan Karatotev	ERRATA_SME_POWER_DOWN \
85700e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
858327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
859327131c4SLeonardo Sandoval	USE_SP804_TIMER \
86012cd65e0STomas Pilar	ENABLE_FEAT_RNG \
861ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
8624e04478aSChris Kay	ENABLE_FEAT_SB \
8637d33ffe4SDaniel Boulby	ENABLE_FEAT_DIT \
8645357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
8655357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
866396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
86711d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
868744ad974Sjohpow01	ENABLE_BRBE_FOR_NS \
869813524eaSManish V Badarkhe	ENABLE_TRBE_FOR_NS \
870d4582d30SManish V Badarkhe	ENABLE_SYS_REG_TRACE_FOR_NS \
8718fcd3d96SManish V Badarkhe	ENABLE_TRF_FOR_NS \
872cc2523bbSAndre Przywara	ENABLE_FEAT_AIE \
873cb4ec47bSjohpow01	ENABLE_FEAT_HCX \
87468120783SChris Kay	ENABLE_MPMM \
875f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
87633e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
8774286d16fSArvind Ram Prakash	ENABLE_FEAT_UINJ \
8784274b526SArvind Ram Prakash	ENABLE_FEAT_FGWTE3 \
879a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
880f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
881714a1a93SManish Pandey	ENABLE_FEAT_EBEP \
8826a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
8836a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
8846a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
885d6affea1SGovindraj Raja	ENABLE_FEAT_CLRBHB \
886a1032bebSJohn Powell	ENABLE_FEAT_CPA2 \
8876a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
88830019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
88919d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
8907e84f3cfSTushar Khandelwal	ENABLE_FEAT_MEC \
891*27bc1386SManoj Kumar	ENABLE_FEAT_MORELLO \
8926a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
893d3331603SMark Brown	ENABLE_FEAT_TCR2 \
8946d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
895062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
896062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
897062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
898062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
8994ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
90030655136SGovindraj Raja	ENABLE_FEAT_D128 \
9015e827bf0STimothy Hayes	ENABLE_FEAT_RME_GDI \
902688ab57bSMark Brown	ENABLE_FEAT_GCS \
9036b8df7b9SArvind Ram Prakash	ENABLE_FEAT_MOPS \
9048cef63d6SBoyan Karatotev	ENABLE_FEAT_GCIE \
9058e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
906b3bcfd12SAndre Przywara	ENABLE_FEAT_PFAR \
9076a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
908781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
909781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
91004c7303bSOkash Khawaja	CONDITIONAL_CMO \
9110ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
912a8cf6faeSJayanth Dodderi Chidanand	SVE_VECTOR_LEN \
913890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
9145782b890SManish V Badarkhe	PSA_CRYPTO	\
91585bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
916183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
917bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
918ae770fedSYann Gautier	EARLY_CONSOLE \
919f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
9208953568aSLevi Yun	HOB_LIST \
9212f5fd826SHarrison Mutai	HW_CONFIG_BASE \
922cf48f49fSManish V Badarkhe	LFA_SUPPORT \
923327131c4SLeonardo Sandoval)))
9242fae4b1eSJeenu Viswambharan
925bfef8b90SJuan Pablo Condeifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
926bfef8b90SJuan Pablo Condeifeq (${DEBUG}, 0)
927bfef8b90SJuan Pablo Conde        $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
928bfef8b90SJuan Pablo Conde        override PLATFORM_REPORT_CTX_MEM_USE := 0
929bfef8b90SJuan Pablo Condeendif
930bfef8b90SJuan Pablo Condeendif
931bfef8b90SJuan Pablo Conde
9321f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
9331f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
934c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB)
9351f461979SJustin Chadwell
9364c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
9374c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
9384c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
939cf2c8a33SAntonio Nino Diazelse
94068450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and
94168450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority.
94268450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
94368450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
9444c117f6cSSandrine Bailleux	endif
945c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
94673c99d4eSJuan Castillo
947209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
948209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
949209a60ccSSoby Mathew        $(eval $(call add_define,DYN_DISABLE_AUTH))
950209a60ccSSoby Mathewendif
951209a60ccSSoby Mathew
9528620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link)
953c2ad38ceSVarun Wadekar        $(eval $(call add_define,USE_ARM_LINK))
954c2ad38ceSVarun Wadekarendif
955c2ad38ceSVarun Wadekar
956ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
957ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
958c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
959ce2b1ec6SManish Pandey	-include $(BUILD_PLAT)/sp_gen.mk
960ce2b1ec6SManish Pandey	FIP_DEPS += sp
96107c44475SManish Pandey	CRT_DEPS += sp
962ce2b1ec6SManish Pandey	NEED_SP_PKG := yes
963ce2b1ec6SManish Pandeyelse
964c33ff198SOlivier Deprez	ifeq (${SPMD_SPM_AT_SEL2},1)
965c33ff198SOlivier Deprez                $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
966c33ff198SOlivier Deprez	endif
967c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE)
968c5e1da83SJayanth Dodderi Chidanandendif #(SPD)
969ce2b1ec6SManish Pandey
97073c99d4eSJuan Castillo################################################################################
9713df79ae7SBoyan Karatotev# Configure the flags for the specified compiler and linker
9723df79ae7SBoyan Karatotev################################################################################
9733df79ae7SBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}cflags.mk
9743df79ae7SBoyan Karatotev
9753df79ae7SBoyan Karatotev################################################################################
97673c99d4eSJuan Castillo# Build targets
97773c99d4eSJuan Castillo################################################################################
97873c99d4eSJuan Castillo
9792329e22bSHarrison Mutai.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
98073c99d4eSJuan Castillo
98173c99d4eSJuan Castilloall: msg_start
98273c99d4eSJuan Castillo
98373c99d4eSJuan Castillomsg_start:
9847c4e1eeaSChris Kay	$(s)echo "Building ${PLAT}"
98573c99d4eSJuan Castillo
98661f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
9875fee0287SRoberto Vargas
98873c99d4eSJuan Castillo# Expand build macros for the different images
98973c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
990b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES})
991434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1))
992c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1)
99373c99d4eSJuan Castillo
99473c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
995c5e1da83SJayanth Dodderi Chidanand
99642d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0)
997c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
998c9b31ae8SRoberto Vargasendif
999c9b31ae8SRoberto Vargas
1000eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES})
1001eb1acfb6SChris Kay
1002d57362bdSXialin Liuifeq (${SEPARATE_BL2_FIP},1)
1003d57362bdSXialin Liu$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS},BL2_)), \
1004d57362bdSXialin Liu	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS},BL2_)))
1005d57362bdSXialin Liuelse
100633950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})), \
1007434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1008d57362bdSXialin Liuendif #(SEPARATE_BL2_FIP)
1009c5e1da83SJayanth Dodderi Chidanand
1010c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2)
101173c99d4eSJuan Castillo
10124d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
101333950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1014c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2)
10154d045d0eSMasahiro Yamada
101673c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
101773c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
101826d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
101926d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1020c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1021c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1022434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1023c6ba9b45SSumit Gargelse
102433950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1025434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw)))
1026c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1027c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31)
102873c99d4eSJuan Castillo
102970d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1030c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
103170d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
103273c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
103326d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
103426d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
10359cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
10369cd15239SMasahiro Yamada
1037c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1038434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1039c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1040c6ba9b45SSumit Gargelse
1041434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
104233950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1043c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1044c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32)
104573c99d4eSJuan Castillo
10465b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
10475b18de09SZelalem Aweke# needs to be built from RMM_SOURCES.
10485b18de09SZelalem Awekeifeq (${NEED_RMM},yes)
10495b18de09SZelalem Aweke# Sort RMM source files to remove duplicates
10505b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES})
10515b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
10525b18de09SZelalem Aweke
10535b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
10545b18de09SZelalem Aweke	 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1055c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM)
10565b18de09SZelalem Aweke
105773c99d4eSJuan Castillo# Add the BL33 image if required by the platform
105873c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
105933950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1060c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
1061db6071c9SJuan Castillo
10629003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
106333950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1064434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1065c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U)
10669003fa0bSYatharth Kochar
106703b397a8SNishanth Menon# Expand build macros for the different images
106803b397a8SNishanth Menonifeq (${NEED_FDT},yes)
106903b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
10701c08ff32SSalman Nabi
10711c08ff32SSalman Nabi    ifneq (${INITRD_SIZE}${INITRD_PATH},)
10721c08ff32SSalman Nabi        ifndef INITRD_BASE
10731c08ff32SSalman Nabi            $(error INITRD_BASE must be set when inserting initrd properties to the DTB.)
10741c08ff32SSalman Nabi        endif
10751c08ff32SSalman Nabi
10761c08ff32SSalman Nabi        INITRD_SIZE ?= $(shell printf "0x%x\n" $$(stat -Lc %s $(INITRD_PATH)))
10771c08ff32SSalman Nabi        initrd_end = $(shell printf "0x%x\n" $$(expr $$(($(INITRD_BASE) + $(INITRD_SIZE)))))
10781c08ff32SSalman Nabi
10791c08ff32SSalman Nabi        define $(HW_CONFIG)-after +=
10801c08ff32SSalman Nabi            $(s)echo "  INITRD  $(HW_CONFIG)"
10811c08ff32SSalman Nabi            $(q)fdtput -t x $@ /chosen linux,initrd-start $(INITRD_BASE)
10821c08ff32SSalman Nabi            $(q)fdtput -t x $@ /chosen linux,initrd-end $(initrd_end)
10831c08ff32SSalman Nabi        endef
10841c08ff32SSalman Nabi    endif
1085c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT)
108603b397a8SNishanth Menon
1087ce2b1ec6SManish Pandey# Add Secure Partition packages
1088ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1089fd74ca0dSChris Kay$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
1090679e27ceSChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
1091dd816235SKathleen Capella	$(q)$(if $(host-poetry),poetry run )${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
1092822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
10937c4e1eeaSChris Kay	$(s)echo
10947c4e1eeaSChris Kay	$(s)echo "Built SP Images successfully"
10957c4e1eeaSChris Kay	$(s)echo
1096c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG)
1097ce2b1ec6SManish Pandey
109836eaaf37SIan Spraylocate-checkpatch:
109936eaaf37SIan Sprayifndef CHECKPATCH
110066079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
110136eaaf37SIan Sprayelse
110236eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
110366079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
110436eaaf37SIan Sprayendif
1105c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH)
110636eaaf37SIan Spray
11074f6ad66aSAchin Guptaclean:
11087c4e1eeaSChris Kay	$(s)echo "  CLEAN"
1109c3273703SChris Kay	$(q)rm -rf $(BUILD_PLAT)
1110cbd6cec3SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean
1111cbd6cec3SBoyan Karatotev	$(q)rm -rf ${FIPTOOLPATH}/fiptool
1112f4595e6eSBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1113f4595e6eSBoyan Karatotev	$(q)rm -rf ${CRTTOOLPATH}/cert_create
111496fbe884SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
11157c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11164f6ad66aSAchin Gupta
1117eaaeece2SJames Morrisseyrealclean distclean:
11187c4e1eeaSChris Kay	$(s)echo "  REALCLEAN"
1119c3273703SChris Kay	$(q)rm -rf $(BUILD_BASE)
1120c3273703SChris Kay	$(q)rm -rf $(CURDIR)/cscope.*
1121cbd6cec3SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean
1122cbd6cec3SBoyan Karatotev	$(q)rm -rf ${FIPTOOLPATH}/fiptool
1123f4595e6eSBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1124f4595e6eSBoyan Karatotev	$(q)rm -rf ${CRTTOOLPATH}/cert_create
112596fbe884SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
11267c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11274f6ad66aSAchin Gupta
112836eaaf37SIan Spraycheckcodebase:		locate-checkpatch
11297c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
11307c4e1eeaSChris Kay	$(q)if test -d .git ; then						\
11311ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
11321a41e8c1SDan Handley		while read GIT_FILE ;					\
11331a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
11341a41e8c1SDan Handley		done ;							\
113536eaaf37SIan Spray	else								\
11361a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
11371a41e8c1SDan Handley		 -not -iwholename "*build*"				\
11381a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
113961f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
11401a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
11411ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
11421a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
114336eaaf37SIan Spray	fi
114436eaaf37SIan Spray
114536eaaf37SIan Spraycheckpatch:		locate-checkpatch
11467c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
11477c4e1eeaSChris Kay	$(q)if test -n "${CHECKPATCH_OPTS}"; then				\
114802a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
114902a76d5fSYann Gautier	fi
11507c4e1eeaSChris Kay	$(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
115177a0a7f1SYann Gautier	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
115277a0a7f1SYann Gautier	do								\
115351d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
11541a721748SYann Gautier		( git log --format=email "$$commit~..$$commit"		\
11551a721748SYann Gautier			-- ${CHECK_PATHS} ;				\
115651d28937SAntonio Nino Diaz		  git diff --format=email "$$commit~..$$commit"		\
11571a721748SYann Gautier			-- ${CHECK_PATHS}; ) |				\
115802a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
115951d28937SAntonio Nino Diaz	done
116036eaaf37SIan Spray
116173c99d4eSJuan Castillocerttool: ${CRTTOOL}
116273c99d4eSJuan Castillo
1163774fb379SBoyan Karatotev${CRTTOOL}: FORCE | $$(@D)/
1164f4595e6eSBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all
1165f4595e6eSBoyan Karatotev	$(q)ln -sf ${CRTTOOL} ${CRTTOOLPATH}/cert_create
11667c4e1eeaSChris Kay	$(s)echo
11677c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
11687c4e1eeaSChris Kay	$(s)echo
11696f971622SJuan Castillo
11706f971622SJuan Castilloifneq (${GENERATE_COT},0)
1171f02135a3SFabien Lehousselcertificates: ${CRT_DEPS} ${CRTTOOL} ${DTBS}
11727c4e1eeaSChris Kay	$(q)${CRTTOOL} ${CRT_ARGS}
11737c4e1eeaSChris Kay	$(s)echo
11747c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
11757c4e1eeaSChris Kay	$(s)echo "Certificates can be found in ${BUILD_PLAT}"
11767c4e1eeaSChris Kay	$(s)echo
1177c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
117827713fb4SSoby Mathew
1179d57362bdSXialin Liuifeq (${SEPARATE_BL2_FIP},1)
1180774fb379SBoyan Karatotev${BUILD_PLAT}/${BL2_FIP_NAME}: ${BL2_FIP_DEPS} ${FIPTOOL} | $$(@D)/
1181d57362bdSXialin Liu	$(eval ${CHECK_BL2_FIP_CMD})
1182d57362bdSXialin Liu	$(q)${FIPTOOL} create ${BL2_FIP_ARGS} $@
1183d57362bdSXialin Liu	$(q)${FIPTOOL} info $@
1184d57362bdSXialin Liu	$(s)echo
1185d57362bdSXialin Liu	$(s)echo "Built $@ successfully"
1186d57362bdSXialin Liu	$(s)echo
1187d57362bdSXialin Liuendif #(SEPARATE_BL2_FIP)
1188d57362bdSXialin Liu
1189774fb379SBoyan Karatotev${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} | $$(@D)/
11904727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
11917c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FIP_ARGS} $@
11927c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
11937c4e1eeaSChris Kay	$(s)echo
11947c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
11957c4e1eeaSChris Kay	$(s)echo
1196f58ad36fSHarry Liebel
11970191262dSYatharth Kocharifneq (${GENERATE_COT},0)
11980191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
11997c4e1eeaSChris Kay	$(q)${CRTTOOL} ${FWU_CRT_ARGS}
12007c4e1eeaSChris Kay	$(s)echo
12017c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
12027c4e1eeaSChris Kay	$(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
12037c4e1eeaSChris Kay	$(s)echo
1204c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
12050191262dSYatharth Kochar
1206d57362bdSXialin Liuifneq (${GENERATE_COT},0)
1207774fb379SBoyan Karatotevbl2_certificates: ${BUILD_PLAT}/${FIP_NAME} ${BL2_CRT_DEPS} ${CRTTOOL} | ${BUILD_PLAT}/
1208d57362bdSXialin Liu	$(q)${CRTTOOL} ${BL2_CRT_ARGS}
1209d57362bdSXialin Liu	$(s)echo
1210d57362bdSXialin Liu	$(s)echo "Built $@ successfully"
1211d57362bdSXialin Liu	$(s)echo "BL2 certificates can be found in ${BUILD_PLAT}"
1212d57362bdSXialin Liu	$(s)echo
1213d57362bdSXialin Liuendif #(GENERATE_COT)
1214d57362bdSXialin Liu
1215774fb379SBoyan Karatotev${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} | $$(@D)/
12164727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
12177c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
12187c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
12197c4e1eeaSChris Kay	$(s)echo
12207c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
12217c4e1eeaSChris Kay	$(s)echo
12220191262dSYatharth Kochar
122373c99d4eSJuan Castillofiptool: ${FIPTOOL}
1224d57362bdSXialin Liuifeq (${SEPARATE_BL2_FIP},1)
1225d57362bdSXialin Liubl2_fip: ${BUILD_PLAT}/${BL2_FIP_NAME}
1226d57362bdSXialin Liufip: bl2_fip
1227d57362bdSXialin Liuelse
122873c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
1229d57362bdSXialin Liuendif #(SEPARATE_BL2_FIP)
12300191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
123173c99d4eSJuan Castillo
1232cbd6cec3SBoyan Karatotev# symlink for compatibility before tools were in the build directory
1233774fb379SBoyan Karatotev${FIPTOOL}: FORCE | $$(@D)/
1234cbd6cec3SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
1235cbd6cec3SBoyan Karatotev	$(q)ln -sf ${FIPTOOL} ${FIPTOOLPATH}/fiptool
1236f58ad36fSHarry Liebel
1237774fb379SBoyan Karatotev$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB) | $$(@D)/
12386e2fe623SLauren Wehrmeister	$(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_LIB=$(CRYPTO_LIB) ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
12395accce5bSRoberto Vargas
1240cfe83910SLouis Mayencourtmemmap: all
1241c25405d6SChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
12424aa3f18dSChris Kay	$(q)$(if $(host-poetry),poetry run )memory --root ${BUILD_PLAT} symbols
1243cfe83910SLouis Mayencourt
12442329e22bSHarrison Mutaitl: ${BUILD_PLAT}/tl.bin
1245774fb379SBoyan Karatotev${BUILD_PLAT}/tl.bin: ${HW_CONFIG} | $$(@D)/
1246c25405d6SChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
1247d2867397SChris Kay	$(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
12482329e22bSHarrison Mutai
12496de32378SMadhukar Pappireddydoc:
12507c4e1eeaSChris Kay	$(s)echo "  BUILD DOCUMENTATION"
1251c61c9a31SHarrison Mutai	$(if $(host-poetry),$(q)poetry -q install --with docs --no-root)
1252725a80d7SBoyan Karatotev	$(q)$(if $(host-poetry),poetry run )${MAKE} --no-print-directory -C ${DOCS_PATH} BUILDDIR=$(abspath ${BUILD_BASE}/docs) html
12536de32378SMadhukar Pappireddy
125490aa901fSSumit Gargenctool: ${ENCTOOL}
125590aa901fSSumit Garg
1256774fb379SBoyan Karatotev${ENCTOOL}: FORCE | $$(@D)/
125796fbe884SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
12587c4e1eeaSChris Kay	$(s)echo
12597c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
12607c4e1eeaSChris Kay	$(s)echo
126190aa901fSSumit Garg
126235fab8c9SJoakim Bechcscope:
12637c4e1eeaSChris Kay	$(s)echo "  CSCOPE"
12647c4e1eeaSChris Kay	$(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
12657c4e1eeaSChris Kay	$(q)cscope -b -q -k
126635fab8c9SJoakim Bech
126772ee3314SRyan Harkinhelp:
12687c4e1eeaSChris Kay	$(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
12697c4e1eeaSChris Kay	$(s)echo ""
12707c4e1eeaSChris Kay	$(s)echo "PLAT is used to specify which platform you wish to build."
12717c4e1eeaSChris Kay	$(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
12727c4e1eeaSChris Kay	$(s)echo ""
12737c4e1eeaSChris Kay	$(s)echo "platform = ${PLATFORM_LIST}"
12747c4e1eeaSChris Kay	$(s)echo ""
12757c4e1eeaSChris Kay	$(s)echo "Please refer to the User Guide for a list of all supported options."
12767c4e1eeaSChris Kay	$(s)echo "Note that the build system doesn't track dependencies for build "
12777c4e1eeaSChris Kay	$(s)echo "options. Therefore, if any of the build options are changed "
12787c4e1eeaSChris Kay	$(s)echo "from a previous build, a clean build must be performed."
12797c4e1eeaSChris Kay	$(s)echo ""
12807c4e1eeaSChris Kay	$(s)echo "Supported Targets:"
12817c4e1eeaSChris Kay	$(s)echo "  all            Build all individual bootloader binaries"
12827c4e1eeaSChris Kay	$(s)echo "  bl1            Build the BL1 binary"
12837c4e1eeaSChris Kay	$(s)echo "  bl2            Build the BL2 binary"
12847c4e1eeaSChris Kay	$(s)echo "  bl2u           Build the BL2U binary"
12857c4e1eeaSChris Kay	$(s)echo "  bl31           Build the BL31 binary"
12867c4e1eeaSChris Kay	$(s)echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
12877c4e1eeaSChris Kay	$(s)echo "                 this builds secure payload specified by AARCH32_SP"
12887c4e1eeaSChris Kay	$(s)echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
12897c4e1eeaSChris Kay	$(s)echo "  fip            Build the Firmware Image Package (FIP)"
12907c4e1eeaSChris Kay	$(s)echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
12917c4e1eeaSChris Kay	$(s)echo "  checkcodebase  Check the coding style of the entire source tree"
12927c4e1eeaSChris Kay	$(s)echo "  checkpatch     Check the coding style on changes in the current"
12937c4e1eeaSChris Kay	$(s)echo "                 branch against BASE_COMMIT (default origin/master)"
12947c4e1eeaSChris Kay	$(s)echo "  clean          Clean the build for the selected platform"
12957c4e1eeaSChris Kay	$(s)echo "  cscope         Generate cscope index"
12967c4e1eeaSChris Kay	$(s)echo "  distclean      Remove all build artifacts for all platforms"
12977c4e1eeaSChris Kay	$(s)echo "  certtool       Build the Certificate generation tool"
12987c4e1eeaSChris Kay	$(s)echo "  enctool        Build the Firmware encryption tool"
12997c4e1eeaSChris Kay	$(s)echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
13007c4e1eeaSChris Kay	$(s)echo "  sp             Build the Secure Partition Packages"
13017c4e1eeaSChris Kay	$(s)echo "  sptool         Build the Secure Partition Package creation tool"
13027c4e1eeaSChris Kay	$(s)echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
13037c4e1eeaSChris Kay	$(s)echo "  memmap         Print the memory map of the built binaries"
13047c4e1eeaSChris Kay	$(s)echo "  doc            Build html based documentation using Sphinx tool"
13057c4e1eeaSChris Kay	$(s)echo ""
13067c4e1eeaSChris Kay	$(s)echo "Note: most build targets require PLAT to be set to a specific platform."
13077c4e1eeaSChris Kay	$(s)echo ""
13087c4e1eeaSChris Kay	$(s)echo "example: build all targets for the FVP platform:"
13097c4e1eeaSChris Kay	$(s)echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1310a9812206SPali Rohár
1311a9812206SPali Rohár.PHONY: FORCE
1312a9812206SPali RohárFORCE:;
1313