xref: /rk3399_ARM-atf/Makefile (revision 5d893410026b590aa8af8d6f7009d3c2e000fe3e)
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
1107a6a654SGovindraj RajaVERSION_MINOR			:= 12
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
34422b181fSYann GautierPLAT				:= ${DEFAULT_PLAT}
351b2fb6adSAndrey Skvortsovinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
361b2fb6adSAndrey Skvortsov
371b2fb6adSAndrey Skvortsov# To be able to set platform specific defaults
381b2fb6adSAndrey Skvortsovifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
391b2fb6adSAndrey Skvortsovinclude ${PLAT_DEFAULTS_MAKEFILE_FULL}
401b2fb6adSAndrey Skvortsovendif
41872be88aSdp-arm
42cc277de8SChris Kay################################################################################
43cc277de8SChris Kay# Configure the toolchains used to build TF-A and its tools
44cc277de8SChris Kay################################################################################
45cc277de8SChris Kay
46cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk
47cc277de8SChris Kay
48cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default
49cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS		:= ${DEBUG}
502fae4b1eSJeenu ViswambharanENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
5173c99d4eSJuan Castillo
5273c99d4eSJuan Castillo################################################################################
5373c99d4eSJuan Castillo# Checkpatch script options
5473c99d4eSJuan Castillo################################################################################
5573c99d4eSJuan Castillo
56f607739cSSandrine BailleuxCHECKCODE_ARGS		:=	--no-patch
57f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files
584501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
594501843fSGilad Ben-Yossef					include/drivers/arm,		\
604501843fSGilad Ben-Yossef					$(wildcard include/drivers/*)))
61f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
621a41e8c1SDan Handley					include/lib/libfdt		\
6361f72a34SRoberto Vargas					include/lib/libc,		\
64f0b489c1SDan Handley					$(wildcard include/lib/*)))
65f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
664501843fSGilad Ben-Yossef					include/lib			\
674501843fSGilad Ben-Yossef					include/drivers,		\
68f0b489c1SDan Handley					$(wildcard include/*)))
69f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
70d801fbb0Sdp-arm					lib/compiler-rt			\
7155cdcf75SAntonio Nino Diaz					lib/libfdt%			\
7261f72a34SRoberto Vargas					lib/libc,			\
73a194255dSDaniel Boulby					lib/zlib			\
74f0b489c1SDan Handley					$(wildcard lib/*)))
75f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
76f0b489c1SDan Handley					lib				\
77f0b489c1SDan Handley					include				\
78f0b489c1SDan Handley					docs				\
791ef35512SPaul Beesley					%.rst,				\
80f0b489c1SDan Handley					$(wildcard *)))
81f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
82f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
83f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
844501843fSGilad Ben-Yossef				${LIB_DIRS_TO_CHECK}			\
854501843fSGilad Ben-Yossef				${INC_DRV_DIRS_TO_CHECK}		\
864501843fSGilad Ben-Yossef				${INC_ARM_DIRS_TO_CHECK}
8736eaaf37SIan Spray
8873c99d4eSJuan Castillo################################################################################
8973c99d4eSJuan Castillo# Process build options
9073c99d4eSJuan Castillo################################################################################
9173c99d4eSJuan Castillo
927c4e1eeaSChris Kayifeq ($(verbose),)
9336eaaf37SIan Spray	CHECKCODE_ARGS	+=	--no-summary --terse
944f6ad66aSAchin Guptaendif
95ee1ba6d4SAndre Przywara
9673c99d4eSJuan Castillo################################################################################
97c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc)
98c5e1da83SJayanth Dodderi Chidanand################################################################################
99c5e1da83SJayanth Dodderi Chidanand
100c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool
101c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH		?=	tools/cert_create
102c3273703SChris KayCRTTOOL			?=	${CRTTOOLPATH}/cert_create$(.exe)
103c5e1da83SJayanth Dodderi Chidanand
104c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool
105c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH		?=	tools/encrypt_fw
106c3273703SChris KayENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw$(.exe)
107c5e1da83SJayanth Dodderi Chidanand
108c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package
109c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH		?=	tools/fiptool
110c3273703SChris KayFIPTOOL			?=	${FIPTOOLPATH}/fiptool$(.exe)
111c5e1da83SJayanth Dodderi Chidanand
112c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool
113c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH		?=	tools/sptool
114c5e1da83SJayanth Dodderi ChidanandSPTOOL			?=	${SPTOOLPATH}/sptool.py
115c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
11620629b31SKarl MeakinSP_DTS_LIST_FRAGMENT	?=	${BUILD_PLAT}/sp_list_fragment.dts
117c5e1da83SJayanth Dodderi Chidanand
1180fe374efSJ-Alves# Variables for use with sptool
1190fe374efSJ-AlvesTLCTOOL 		?=	poetry run tlc
1200fe374efSJ-Alves
121c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB
122c5e1da83SJayanth Dodderi ChidanandROMLIBPATH		?=	lib/romlib
123c5e1da83SJayanth Dodderi Chidanand
124c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python
125c5e1da83SJayanth Dodderi ChidanandPYTHON			?=	python3
126c5e1da83SJayanth Dodderi Chidanand
127c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool
128c5e1da83SJayanth Dodderi ChidanandDOCS_PATH		?=	docs
129c5e1da83SJayanth Dodderi Chidanand
130c5e1da83SJayanth Dodderi Chidanand################################################################################
131c5e1da83SJayanth Dodderi Chidanand# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
132c5e1da83SJayanth Dodderi Chidanand################################################################################
13326e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
13426e63c44SEtienne Carriere	target32-directive	= 	-target arm-none-eabi
135d4089fb8SGovindraj Raja# Will set march-directive from platform configuration
13626e63c44SEtienne Carriereelse
13726e63c44SEtienne Carriere	target32-directive	= 	-target armv8a-none-eabi
138c5e1da83SJayanth Dodderi Chidanandendif #(ARM_ARCH_MAJOR)
139c5e1da83SJayanth Dodderi Chidanand
140c5e1da83SJayanth Dodderi Chidanand################################################################################
141c5e1da83SJayanth Dodderi Chidanand# Get Architecture Feature Modifiers
142c5e1da83SJayanth Dodderi Chidanand################################################################################
143c5e1da83SJayanth Dodderi Chidanandarch-features		=	${ARM_ARCH_FEATURE}
144c5e1da83SJayanth Dodderi Chidanand
1458620bd0bSChris Kayifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
1468620bd0bSChris Kay	ifeq ($($(ARCH)-cc-id),arm-clang)
1477794d6c8SGovindraj Raja		TF_CFLAGS_aarch32	:=	-target arm-arm-none-eabi
1487794d6c8SGovindraj Raja		TF_CFLAGS_aarch64	:=	-target aarch64-arm-none-eabi
149c8a992fdSorigin	else
1507794d6c8SGovindraj Raja		TF_CFLAGS_aarch32	=	$(target32-directive)
151af8947feSYann Gautier		TF_CFLAGS_aarch64	:=	-target aarch64-unknown-none-elf
152641f16e7SAmbroise Vincent	endif
153c8a992fdSorigin
1548620bd0bSChris Kayelse ifeq ($($(ARCH)-cc-id),gnu-gcc)
155edbce9aaSzelalem-aweke	# Enable LTO only for aarch64
156edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
157fa402f38SChris Kay		LTO_CFLAGS	=	$(if $(filter-out 0,$(ENABLE_LTO)),-flto)
158edbce9aaSzelalem-aweke	endif
159c5e1da83SJayanth Dodderi Chidanandendif #(clang)
160d5461857Sdp-arm
16132b209bfSAhmad Fatoum# Process Debug flag
16232b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
16332b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
16432b209bfSAhmad Fatoum	BUILD_TYPE	:=	debug
1654466cf82SDaniel Boulby	TF_CFLAGS	+=	-g -gdwarf-4
1664466cf82SDaniel Boulby	ASFLAGS		+=	-g -Wa,-gdwarf-4
16732b209bfSAhmad Fatoum
16832b209bfSAhmad Fatoum	# Use LOG_LEVEL_INFO by default for debug builds
16932b209bfSAhmad Fatoum	LOG_LEVEL	:=	40
17032b209bfSAhmad Fatoumelse
17132b209bfSAhmad Fatoum	BUILD_TYPE	:=	release
17232b209bfSAhmad Fatoum	# Use LOG_LEVEL_NOTICE by default for release builds
17332b209bfSAhmad Fatoum	LOG_LEVEL	:=	20
174c5e1da83SJayanth Dodderi Chidanandendif #(Debug)
17532b209bfSAhmad Fatoum
176f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
177f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
178f1de4c8fSPeiyuan Song	BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
179f1de4c8fSPeiyuan Songendif
180dddf4283Slaurenw-armVERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
181f1de4c8fSPeiyuan Song
1828fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
1838fd9d4d5SAntonio Nino Diaz	TF_CFLAGS_aarch32	+=	-marm
1848fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
1858fd9d4d5SAntonio Nino Diaz	TF_CFLAGS_aarch32	+=	-mthumb
1868fd9d4d5SAntonio Nino Diazelse
1878fd9d4d5SAntonio Nino Diaz        $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
188c5e1da83SJayanth Dodderi Chidanandendif #(AARCH32_INSTRUCTION_SET)
1898fd9d4d5SAntonio Nino Diaz
190a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
191d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
1929d29c227SSoby Mathew
193c5e1da83SJayanth Dodderi Chidanand##############################################################################
194c5e1da83SJayanth Dodderi Chidanand# WARNINGS Configuration
195c5e1da83SJayanth Dodderi Chidanand###############################################################################
1969ab81b5eSJustin Chadwell# General warnings
1979ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
198b7f6525dSJustin Chadwell				-Wdisabled-optimization -Wvla -Wshadow	\
199d75a9ecdSBoyan Karatotev				-Wredundant-decls
200d75a9ecdSBoyan Karatotev# stricter warnings
201d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wextra -Wno-trigraphs
202d75a9ecdSBoyan Karatotev# too verbose for generic build
203d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-missing-field-initializers \
204d75a9ecdSBoyan Karatotev				-Wno-type-limits -Wno-sign-compare \
205d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
206d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-unused-parameter
2079ab81b5eSJustin Chadwell
2089ab81b5eSJustin Chadwell# Additional warnings
209d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of
210d75a9ecdSBoyan Karatotev# full -Wextra
211d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare
212d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits
213d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers
214e7c645b5SYann Gautier
215d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want
216d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
217d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build
218d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition
219d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes
220d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute
221d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present
222d75a9ecdSBoyan KaratotevWARNING2 += -Wundef
223d141e638SBoyan Karatotev# currently very involved and many platforms set this off
224d141e638SBoyan KaratotevWARNING2 += -Wunused-const-variable=2
225e7c645b5SYann Gautier
226d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored
227e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
228d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return
229d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs
230d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align
231e7c645b5SYann GautierWARNING3 += -Wcast-qual
232e7c645b5SYann GautierWARNING3 += -Wconversion
233e7c645b5SYann GautierWARNING3 += -Wpacked
234e7c645b5SYann GautierWARNING3 += -Wpointer-arith
235e7c645b5SYann GautierWARNING3 += -Wswitch-default
236e7c645b5SYann Gautier
237d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues
238d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings
239d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed
240d75a9ecdSBoyan Karatotevifdef W
241d75a9ecdSBoyan Karatotev	ifneq (${W},0)
242d75a9ecdSBoyan Karatotev		E	 ?= 0
243d75a9ecdSBoyan Karatotev	endif
244d75a9ecdSBoyan Karatotevendif
245d75a9ecdSBoyan Karatotev
246e7c645b5SYann Gautierifeq (${W},1)
2479ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1)
248e7c645b5SYann Gautierelse ifeq (${W},2)
2499ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1) $(WARNING2)
250e7c645b5SYann Gautierelse ifeq (${W},3)
2519ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
252c5e1da83SJayanth Dodderi Chidanandendif #(W)
253e7c645b5SYann Gautier
2549ab81b5eSJustin Chadwell# Compiler specific warnings
2558620bd0bSChris Kayifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
25693c690ebSJustin Chadwell# not using clang
257d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
258d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
259d7b4cd41SJustin Chadwell				-Wlogical-op
260dea23e24SGovindraj Raja
261dea23e24SGovindraj Raja# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
262316f5c97SBoyan KaratotevTF_CFLAGS_MIN_PAGE_SIZE	:=	$(call cc_option, --param=min-pagesize=0)
263316f5c97SBoyan KaratotevTF_CFLAGS		+=	$(TF_CFLAGS_MIN_PAGE_SIZE)
264dea23e24SGovindraj Raja
265538516f5SBipin Raviifeq ($(HARDEN_SLS), 1)
266316f5c97SBoyan Karatotev        TF_CFLAGS_MHARDEN_SLS	:=      $(call cc_option, -mharden-sls=all)
267316f5c97SBoyan Karatotev        TF_CFLAGS_aarch64	+=      $(TF_CFLAGS_MHARDEN_SLS)
268538516f5SBipin Raviendif
269538516f5SBipin Ravi
27093c690ebSJustin Chadwellelse
27193c690ebSJustin Chadwell# using clang
272d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
273d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
274c5e1da83SJayanth Dodderi Chidanandendif #(Clang Warning)
27500296576SAmbroise Vincent
2766336b07aSYann Gautierifneq (${E},0)
2776336b07aSYann Gautier	ERRORS := -Werror
278c5e1da83SJayanth Dodderi Chidanandendif #(E)
2796336b07aSYann Gautier
280c5e1da83SJayanth Dodderi Chidanand################################################################################
281c5e1da83SJayanth Dodderi Chidanand# Compiler and Linker Directives
282c5e1da83SJayanth Dodderi Chidanand################################################################################
283ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
2849ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
285d4089fb8SGovindraj RajaASFLAGS			+=	$(CPPFLAGS)                 			\
286d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
28759de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
288ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
289ee0c5b8cSBoyan Karatotev				-ffreestanding -fno-common			\
290ebd6efaeSSamuel Holland				-Os -std=gnu99
29173c99d4eSJuan Castillo
2921f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
2931f461979SJustin Chadwell	TF_CFLAGS	+=	-fsanitize=undefined -fno-sanitize-recover
294c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},on)
295c5e1da83SJayanth Dodderi Chidanand
2961f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
2971f461979SJustin Chadwell	TF_CFLAGS	+=	-fsanitize=undefined -fno-sanitize-recover	\
2981f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
299c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},trap)
3001f461979SJustin Chadwell
301291e7182SChris KayGCC_V_OUTPUT		:=	$(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
302f7ec31dbSdavid cunado
3031f49db5fSMarco FelschTF_LDFLAGS		+=	-z noexecstack
3041f49db5fSMarco Felsch
305641f16e7SAmbroise Vincent# LD = armlink
3068620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link)
307c2ad38ceSVarun Wadekar	TF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
308c2ad38ceSVarun Wadekar	TF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
309edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
310641f16e7SAmbroise Vincent
311641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
3128620bd0bSChris Kayelse ifeq ($($(ARCH)-ld-id),gnu-gcc)
313edbce9aaSzelalem-aweke	# Pass ld options with Wl or Xlinker switches
31486e489c1SChris Kay	TF_LDFLAGS		+=	$(call ld_option,-Xlinker --no-warn-rwx-segments)
315edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
316edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	-Wl,--gc-sections
317ac98b82aSChris Kay
318ac98b82aSChris Kay	TF_LDFLAGS		+=	-Wl,-z,common-page-size=4096 #Configure page size constants
319ac98b82aSChris Kay	TF_LDFLAGS		+=	-Wl,-z,max-page-size=4096
320304ad94bSAndrey Skvortsov	TF_LDFLAGS		+=	-Wl,--build-id=none
321ac98b82aSChris Kay
322edbce9aaSzelalem-aweke	ifeq ($(ENABLE_LTO),1)
323edbce9aaSzelalem-aweke		ifeq (${ARCH},aarch64)
324edbce9aaSzelalem-aweke			TF_LDFLAGS	+=	-flto -fuse-linker-plugin
32531f80efeSAndrey Skvortsov			TF_LDFLAGS      +=	-flto-partition=one
326edbce9aaSzelalem-aweke		endif
327c5e1da83SJayanth Dodderi Chidanand	endif #(ENABLE_LTO)
328c5e1da83SJayanth Dodderi Chidanand
329edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
330edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
331cfe6767fSYann Gautier	ifeq (${ARCH},aarch64)
332edbce9aaSzelalem-aweke		ifneq (${ERRATA_A53_843419},1)
333edbce9aaSzelalem-aweke			TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
334edbce9aaSzelalem-aweke		endif
335cfe6767fSYann Gautier	endif
336edbce9aaSzelalem-aweke	TF_LDFLAGS		+= 	-nostdlib
337edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
338641f16e7SAmbroise Vincent
339641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
340c2ad38ceSVarun Wadekarelse
3411f49db5fSMarco Felsch# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
3421f49db5fSMarco Felsch# are not loaded by a elf loader.
3431f49db5fSMarco Felsch	TF_LDFLAGS		+=	$(call ld_option, --no-warn-rwx-segments)
344ebac6922SYabin Cui	TF_LDFLAGS		+=	-O1
345c2b8806fSDouglas Raillard	TF_LDFLAGS		+=	--gc-sections
346ac98b82aSChris Kay
347ac98b82aSChris Kay	TF_LDFLAGS		+=	-z common-page-size=4096 # Configure page size constants
348ac98b82aSChris Kay	TF_LDFLAGS		+=	-z max-page-size=4096
349304ad94bSAndrey Skvortsov	TF_LDFLAGS		+=	--build-id=none
350ac98b82aSChris Kay
351641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
352ebac6922SYabin Cui# therefore don't add those in that case.
353ebac6922SYabin Cui# ld.lld reports section type mismatch warnings,
354ebac6922SYabin Cui# therefore don't add --fatal-warnings to it.
3558620bd0bSChris Kay	ifneq ($($(ARCH)-ld-id),llvm-lld)
356ebac6922SYabin Cui		TF_LDFLAGS	+=	$(TF_LDFLAGS_$(ARCH)) --fatal-warnings
357edbce9aaSzelalem-aweke	endif
358c5e1da83SJayanth Dodderi Chidanand
359c5e1da83SJayanth Dodderi Chidanandendif #(LD = armlink)
36073c99d4eSJuan Castillo
36173c99d4eSJuan Castillo################################################################################
362f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features.
363f5211420SGovindraj Raja################################################################################
364f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
3657d5fc98fSAlexeiFedorov	ARM_ARCH_MAJOR := 9
3667d5fc98fSAlexeiFedorov	ARM_ARCH_MINOR := 2
367f5211420SGovindraj Rajaendif
368f5211420SGovindraj Raja
369f5211420SGovindraj Raja################################################################################
37073c99d4eSJuan Castillo# Common sources and include directories
37173c99d4eSJuan Castillo################################################################################
372d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
37373c99d4eSJuan Castillo
374758ccb80SChris Kay# Allow overriding the timestamp, for example for reproducible builds, or to
375758ccb80SChris Kay# synchronize timestamps across multiple projects.
376758ccb80SChris Kay# This must be set to a C string (including quotes where applicable).
377758ccb80SChris KayBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
378758ccb80SChris Kay
379758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
380758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
381758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
382758ccb80SChris Kay
38373c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
3847f56e9a3SSoby Mathew				common/tf_log.c				\
3859d29c227SSoby Mathew				common/${ARCH}/debug.S			\
38691b48c9fSJulius Werner				drivers/console/multi_console.c		\
3879d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
3889d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
389c73686a1SBoyan Karatotev				lib/extensions/pmuv3/${ARCH}/pmuv3.c	\
390566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
3917f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
39275311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
3939d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
39461f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
395d7a6b0f8SRyan Harkin
3968620bd0bSChris Kayifeq ($($(ARCH)-cc-id),arm-clang)
3978422a840SAntonio Nino Diaz	BL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
3988422a840SAntonio Nino Diazendif
3998422a840SAntonio Nino Diaz
4001f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4011f461979SJustin Chadwell	BL_COMMON_SOURCES	+=	plat/common/ubsan.c
4021f461979SJustin Chadwellendif
4031f461979SJustin Chadwell
40401d237cbSYann GautierINCLUDES		+=	-Iinclude				\
405f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
40609d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
40709d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
40809d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
40909d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
41009d40e0eSAntonio Nino Diaz
411e03dcc8fSNishant SharmaDTC_FLAGS		+=	-I dts -O dtb
412e03dcc8fSNishant SharmaDTC_CPPFLAGS		+=	-P -nostdinc $(INCLUDES) -Ifdts -undef \
413e03dcc8fSNishant Sharma				-x assembler-with-cpp $(DEFINES)
414e03dcc8fSNishant Sharma
4159c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4169c6d1c50SAntonio Nino Diaz
41773c99d4eSJuan Castillo################################################################################
4183547270fSGovindraj Raja# Generic definitions
4193547270fSGovindraj Raja################################################################################
4203547270fSGovindraj Raja
4213547270fSGovindraj Rajaifeq (${BUILD_BASE},)
4223547270fSGovindraj Raja     BUILD_BASE		:=	./build
4233547270fSGovindraj Rajaendif
4243547270fSGovindraj RajaBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
4253547270fSGovindraj Raja
4263547270fSGovindraj RajaSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
4273547270fSGovindraj Raja
4283547270fSGovindraj Raja# Platforms providing their own TBB makefile may override this value
4293547270fSGovindraj RajaINCLUDE_TBBR_MK		:=	1
4303547270fSGovindraj Raja
4313547270fSGovindraj Raja################################################################################
4323547270fSGovindraj Raja# Include SPD Makefile if one has been specified
4333547270fSGovindraj Raja################################################################################
4343547270fSGovindraj Raja
4353547270fSGovindraj Rajaifneq (${SPD},none)
4363547270fSGovindraj Raja	ifeq (${SPD},spmd)
4373547270fSGovindraj Raja	# SPMD is located in std_svc directory
4383547270fSGovindraj Raja		SPD_DIR := std_svc
4393547270fSGovindraj Raja
4403547270fSGovindraj Raja		ifeq ($(SPMD_SPM_AT_SEL2),1)
4413547270fSGovindraj Raja			CTX_INCLUDE_EL2_REGS := 1
4423547270fSGovindraj Raja		endif
4433547270fSGovindraj Raja
4443547270fSGovindraj Raja		ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
4453547270fSGovindraj Raja			DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
4463547270fSGovindraj Raja		endif
4473547270fSGovindraj Raja
4480686a01bSArunachalam Ganapathy		ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
4490686a01bSArunachalam Ganapathy			DTC_CPPFLAGS	+=	-DTRUSTY_SP_FW_CONFIG
4500686a01bSArunachalam Ganapathy		endif
4510686a01bSArunachalam Ganapathy
4523547270fSGovindraj Raja		ifeq ($(TS_SP_FW_CONFIG),1)
4533547270fSGovindraj Raja			DTC_CPPFLAGS	+=	-DTS_SP_FW_CONFIG
4543547270fSGovindraj Raja		endif
4553547270fSGovindraj Raja
4563547270fSGovindraj Raja		ifneq ($(ARM_BL2_SP_LIST_DTS),)
4573547270fSGovindraj Raja		DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
4583547270fSGovindraj Raja		endif
4593547270fSGovindraj Raja
4603547270fSGovindraj Raja		ifneq ($(SP_LAYOUT_FILE),)
4613547270fSGovindraj Raja		BL2_ENABLE_SP_LOAD := 1
4623547270fSGovindraj Raja		endif
4633547270fSGovindraj Raja	else
4643547270fSGovindraj Raja		# All other SPDs in spd directory
4653547270fSGovindraj Raja		SPD_DIR := spd
4663547270fSGovindraj Raja	endif #(SPD)
4673547270fSGovindraj Raja
4683547270fSGovindraj Raja	# We expect to locate an spd.mk under the specified SPD directory
4693547270fSGovindraj Raja	SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
4703547270fSGovindraj Raja
4713547270fSGovindraj Raja	ifeq (${SPD_MAKE},)
4723547270fSGovindraj Raja                $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
4733547270fSGovindraj Raja	endif
4743547270fSGovindraj Raja        $(info Including ${SPD_MAKE})
4753547270fSGovindraj Raja        include ${SPD_MAKE}
4763547270fSGovindraj Raja
4773547270fSGovindraj Raja	# If there's BL32 companion for the chosen SPD, we expect that the SPD's
4783547270fSGovindraj Raja	# Makefile would set NEED_BL32 to "yes". In this case, the build system
4793547270fSGovindraj Raja	# supports two mutually exclusive options:
4803547270fSGovindraj Raja	# * BL32 is built from source: then BL32_SOURCES must contain the list
4813547270fSGovindraj Raja	#   of source files to build BL32
4823547270fSGovindraj Raja	# * BL32 is a prebuilt binary: then BL32 must point to the image file
4833547270fSGovindraj Raja	#   that will be included in the FIP
4843547270fSGovindraj Raja	# If both BL32_SOURCES and BL32 are defined, the binary takes precedence
4853547270fSGovindraj Raja	# over the sources.
4863547270fSGovindraj Rajaendif #(SPD=none)
4873547270fSGovindraj Raja
4883547270fSGovindraj Raja################################################################################
489696ed168SOlivier Deprez# Include the platform specific Makefile after the SPD Makefile (the platform
490696ed168SOlivier Deprez# makefile may use all previous definitions in this file)
491696ed168SOlivier Deprez################################################################################
492696ed168SOlivier Deprezinclude ${PLAT_MAKEFILE_FULL}
493696ed168SOlivier Deprez
494696ed168SOlivier Deprez################################################################################
4958d9f5f25SBoyan Karatotev# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
4968d9f5f25SBoyan Karatotev# platform.
4978d9f5f25SBoyan Karatotev################################################################################
4988d9f5f25SBoyan Karatotev
4998d9f5f25SBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
5008d9f5f25SBoyan Karatotev################################################################################
501f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set
502f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags
503f5211420SGovindraj Raja################################################################################
504f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0)
505f5211420SGovindraj Raja	# Default value turns off all types of branch protection
506f5211420SGovindraj Raja	BP_OPTION := none
507f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64)
508f5211420SGovindraj Raja        $(error BRANCH_PROTECTION requires AArch64)
509f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1)
510f5211420SGovindraj Raja	# Enables all types of branch protection features
511f5211420SGovindraj Raja	BP_OPTION := standard
512f5211420SGovindraj Raja	ENABLE_BTI := 1
513f5211420SGovindraj Raja	ENABLE_PAUTH := 1
514f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2)
515f5211420SGovindraj Raja	# Return address signing to its standard level
516f5211420SGovindraj Raja	BP_OPTION := pac-ret
517f5211420SGovindraj Raja	ENABLE_PAUTH := 1
518f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3)
519f5211420SGovindraj Raja	# Extend the signing to include leaf functions
520f5211420SGovindraj Raja	BP_OPTION := pac-ret+leaf
521f5211420SGovindraj Raja	ENABLE_PAUTH := 1
522f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4)
523f5211420SGovindraj Raja	# Turn on branch target identification mechanism
524f5211420SGovindraj Raja	BP_OPTION := bti
525f5211420SGovindraj Raja	ENABLE_BTI := 1
5268d9f5f25SBoyan Karatotevelse ifeq (${BRANCH_PROTECTION},5)
5278d9f5f25SBoyan Karatotev	# Turn on branch target identification mechanism
5288d9f5f25SBoyan Karatotev	BP_OPTION := standard
5298d9f5f25SBoyan Karatotev	ENABLE_BTI := 2
5308d9f5f25SBoyan Karatotev	ENABLE_PAUTH := 2
531f5211420SGovindraj Rajaelse
532f5211420SGovindraj Raja        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
533f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION)
534f5211420SGovindraj Raja
5358d9f5f25SBoyan Karatotevifneq ($(ENABLE_PAUTH),0)
5368d9f5f25SBoyan Karatotev	CTX_INCLUDE_PAUTH_REGS	:= ${ENABLE_PAUTH}
537f5211420SGovindraj Rajaendif
538f5211420SGovindraj Rajaifneq (${BP_OPTION},none)
539f5211420SGovindraj Raja	TF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
540f5211420SGovindraj Rajaendif #(BP_OPTION)
541f5211420SGovindraj Raja
542f5211420SGovindraj Raja# Pointer Authentication sources
5438d9f5f25SBoyan Karatotevifneq (${ENABLE_PAUTH},0)
544f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
545f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms
5468d9f5f25SBoyan Karatotev	BL_COMMON_SOURCES	+=	lib/extensions/pauth/pauth.c
547f5211420SGovindraj Rajaendif
548f5211420SGovindraj Raja
549f5211420SGovindraj Raja####################################################
550f5211420SGovindraj Raja# Enable required options for Memory Stack Tagging.
551f5211420SGovindraj Raja####################################################
552f5211420SGovindraj Raja
553f5211420SGovindraj Raja# Currently, these options are enabled only for clang and armclang compiler.
554f5211420SGovindraj Rajaifeq (${SUPPORT_STACK_MEMTAG},yes)
555f5211420SGovindraj Raja    ifdef mem_tag_arch_support
556f5211420SGovindraj Raja        # Check for armclang and clang compilers
5578620bd0bSChris Kay        ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
558f5211420SGovindraj Raja        # Add "memtag" architecture feature modifier if not specified
559f5211420SGovindraj Raja            ifeq ( ,$(findstring memtag,$(arch-features)))
560f5211420SGovindraj Raja                arch-features	:=	$(arch-features)+memtag
561f5211420SGovindraj Raja            endif	# memtag
5628620bd0bSChris Kay            ifeq ($($(ARCH)-cc-id),arm-clang)
563f5211420SGovindraj Raja                TF_CFLAGS	+=	-mmemtag-stack
5648620bd0bSChris Kay            else ifeq ($($(ARCH)-cc-id),llvm-clang)
565f5211420SGovindraj Raja                TF_CFLAGS	+=	-fsanitize=memtag
566f5211420SGovindraj Raja            endif	# armclang
567f5211420SGovindraj Raja        endif
568f5211420SGovindraj Raja    else
569f5211420SGovindraj Raja        $(error "Error: stack memory tagging is not supported for  \
570f5211420SGovindraj Raja        architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
571f5211420SGovindraj Raja	endif #(mem_tag_arch_support)
572f5211420SGovindraj Rajaendif #(SUPPORT_STACK_MEMTAG)
573f5211420SGovindraj Raja
574f5211420SGovindraj Raja################################################################################
575f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME.
576f5211420SGovindraj Raja################################################################################
577f5211420SGovindraj Raja# FEAT_RME
578f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
579f5211420SGovindraj Raja	# RME requires AARCH64
580f5211420SGovindraj Raja	ifneq (${ARCH},aarch64)
581f5211420SGovindraj Raja                $(error ENABLE_RME requires AArch64)
582f5211420SGovindraj Raja	endif
583f5211420SGovindraj Raja
584f5211420SGovindraj Raja	# RME requires el2 context to be saved for now.
585f5211420SGovindraj Raja	CTX_INCLUDE_EL2_REGS := 1
586f5211420SGovindraj Raja	CTX_INCLUDE_AARCH32_REGS := 0
587f5211420SGovindraj Raja	CTX_INCLUDE_PAUTH_REGS := 1
588f5211420SGovindraj Raja
589d048af0dSJavier Almansa Sobrino	ifneq ($(ENABLE_FEAT_MPAM), 0)
590d048af0dSJavier Almansa Sobrino		CTX_INCLUDE_MPAM_REGS := 1
591d048af0dSJavier Almansa Sobrino	endif
592d048af0dSJavier Almansa Sobrino
593f5211420SGovindraj Raja	# RME enables CSV2_2 extension by default.
594f5211420SGovindraj Raja	ENABLE_FEAT_CSV2_2 = 1
595f5211420SGovindraj Rajaendif #(FEAT_RME)
596f5211420SGovindraj Raja
597f5211420SGovindraj Raja################################################################################
5985b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled
5995b18de09SZelalem Aweke################################################################################
6005b18de09SZelalem Awekeifneq (${ENABLE_RME},0)
6015b18de09SZelalem Aweke	ifneq (${ARCH},aarch64)
6025b18de09SZelalem Aweke                $(error ENABLE_RME requires AArch64)
6035b18de09SZelalem Aweke	endif
6041d63ae4dSMarc Bonnici	ifeq ($(SPMC_AT_EL3),1)
6051d63ae4dSMarc Bonnici                $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
6061d63ae4dSMarc Bonnici	endif
607c5e1da83SJayanth Dodderi Chidanand
6084fba2e1fSBoyan Karatotev	ifneq (${SPD}, none)
6094fba2e1fSBoyan Karatotev		ifneq (${SPD}, spmd)
6104fba2e1fSBoyan Karatotev                        $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
6114fba2e1fSBoyan Karatotev		endif
6124fba2e1fSBoyan Karatotev	endif
6135b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk
6145b18de09SZelalem Aweke$(warning "RME is an experimental feature")
6155b18de09SZelalem Awekeendif
6165b18de09SZelalem Aweke
6173547270fSGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1)
6183547270fSGovindraj Raja	ifeq (${SPD},none)
6193547270fSGovindraj Raja		ifeq (${ENABLE_RME},0)
6203547270fSGovindraj Raja                        $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
6213547270fSGovindraj Raja                        or RME is enabled)
6223547270fSGovindraj Raja		endif
6233547270fSGovindraj Raja	endif
6243547270fSGovindraj Rajaendif
6250f21c547SJuan Castillo
6267794d6c8SGovindraj Raja################################################################################
6277e84f3cfSTushar Khandelwal# Verify FEAT_RME, FEAT_SCTLR2 and FEAT_TCR2 are enabled if FEAT_MEC is enabled.
6287e84f3cfSTushar Khandelwal################################################################################
6297e84f3cfSTushar Khandelwal
6307e84f3cfSTushar Khandelwalifneq (${ENABLE_FEAT_MEC},0)
6317e84f3cfSTushar Khandelwal    ifeq (${ENABLE_RME},0)
6327e84f3cfSTushar Khandelwal        $(error FEAT_RME must be enabled when FEAT_MEC is enabled.)
6337e84f3cfSTushar Khandelwal    endif
6347e84f3cfSTushar Khandelwal    ifeq (${ENABLE_FEAT_TCR2},0)
6357e84f3cfSTushar Khandelwal        $(error FEAT_TCR2 must be enabled when FEAT_MEC is enabled.)
6367e84f3cfSTushar Khandelwal    endif
6377e84f3cfSTushar Khandelwal    ifeq (${ENABLE_FEAT_SCTLR2},0)
6387e84f3cfSTushar Khandelwal        $(error FEAT_SCTLR2 must be enabled when FEAT_MEC is enabled.)
6397e84f3cfSTushar Khandelwal    endif
6407e84f3cfSTushar Khandelwalendif
6417e84f3cfSTushar Khandelwal
6427e84f3cfSTushar Khandelwal################################################################################
64330655136SGovindraj Raja# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
64430655136SGovindraj Raja################################################################################
64530655136SGovindraj Rajaifneq (${ENABLE_FEAT_D128}, 0)
64630655136SGovindraj Raja        BL_COMMON_SOURCES       +=      lib/extensions/sysreg128/sysreg128.S
64730655136SGovindraj Rajaendif
64830655136SGovindraj Raja
64930655136SGovindraj Raja################################################################################
6507794d6c8SGovindraj Raja# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
6517794d6c8SGovindraj Raja# up with appropriate march values for compiler.
6527794d6c8SGovindraj Raja################################################################################
6537794d6c8SGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}march.mk
6547794d6c8SGovindraj Raja
6557794d6c8SGovindraj RajaTF_CFLAGS   +=	$(march-directive)
6567275ac2aSGovindraj RajaASFLAGS		+=	$(march-directive)
6577794d6c8SGovindraj Raja
65842d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios
65942d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios -
66042d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running
66142d4d3baSArvind Ram Prakash# BL2 in EL3
66242d4d3baSArvind Ram Prakash
66342d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1)
66442d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
66542d4d3baSArvind Ram Prakash	ifeq (${ENABLE_RME},1)
666c5e1da83SJayanth Dodderi Chidanand                $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
667c5e1da83SJayanth Dodderi Chidanand                supported at the moment.)
66842d4d3baSArvind Ram Prakash	endif
66942d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1)
67042d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
67142d4d3baSArvind Ram Prakashelse
67242d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	0
67342d4d3baSArvind Ram Prakashendif
67442d4d3baSArvind Ram Prakash
675f87e54f7SManish Pandey# This internal flag is set to 1 when Firmware First handling of External aborts
676f87e54f7SManish Pandey# is required by lowe ELs. Currently only NS requires this support.
677f87e54f7SManish Pandeyifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
678f87e54f7SManish Pandey	FFH_SUPPORT := 1
679f87e54f7SManish Pandeyelse
680f87e54f7SManish Pandey	FFH_SUPPORT := 0
681f87e54f7SManish Pandeyendif
682f87e54f7SManish Pandey
68326e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
68426e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
68526e63c44SEtienne Carriereendif
68626e63c44SEtienne Carriere
6873bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
6883bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
6893bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
6908620bd0bSChris Kayifeq ($($(ARCH)-ld-id),gnu-gcc)
6917b592418SSamuel Holland	TF_LDFLAGS	+=	-no-pie
6927b592418SSamuel Hollandendif
693c5e1da83SJayanth Dodderi Chidanandendif #(PIE_FOUND)
694320920c1SMasahiro Yamada
6958620bd0bSChris Kayifeq ($($(ARCH)-ld-id),gnu-gcc)
696320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
697320920c1SMasahiro Yamadaelse
698320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
699320920c1SMasahiro Yamadaendif
700320920c1SMasahiro Yamada
701320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
70242d4d3baSArvind Ram Prakash	ifeq ($(RESET_TO_BL2),1)
70369af7fcfSMasahiro Yamada		ifneq ($(BL2_IN_XIP_MEM),1)
704966660ecSChris Kay			BL2_CPPFLAGS	+=	-fpie
70569af7fcfSMasahiro Yamada			BL2_CFLAGS	+=	-fpie
70669af7fcfSMasahiro Yamada			BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
707c5e1da83SJayanth Dodderi Chidanand		endif #(BL2_IN_XIP_MEM)
708c5e1da83SJayanth Dodderi Chidanand	endif #(RESET_TO_BL2)
709966660ecSChris Kay	BL31_CPPFLAGS	+=	-fpie
710320920c1SMasahiro Yamada	BL31_CFLAGS 	+=	-fpie
711320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
712966660ecSChris Kay
713966660ecSChris Kay	BL32_CPPFLAGS	+=	-fpie
714d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
715d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
716c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PIE)
7173bd17c0fSSoby Mathew
718007433d8SBoyan KaratotevBL1_CPPFLAGS  += -DREPORT_ERRATA=${DEBUG}
719007433d8SBoyan KaratotevBL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
720007433d8SBoyan KaratotevBL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
721007433d8SBoyan Karatotev
7229cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
72342d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2),1)
7249cefb4b1SMasahiro Yamada	BL2_CPPFLAGS += -DIMAGE_AT_EL3
725d5e97a1dSMasahiro Yamadaelse
7269cefb4b1SMasahiro Yamada	BL2_CPPFLAGS += -DIMAGE_AT_EL1
727c5e1da83SJayanth Dodderi Chidanandendif #(RESET_TO_BL2)
728007433d8SBoyan Karatotev
729007433d8SBoyan Karatotevifeq (${ARCH},aarch64)
7309cefb4b1SMasahiro Yamada	BL2U_CPPFLAGS += -DIMAGE_AT_EL1
7319cefb4b1SMasahiro Yamada	BL31_CPPFLAGS += -DIMAGE_AT_EL3
7329cefb4b1SMasahiro Yamada	BL32_CPPFLAGS += -DIMAGE_AT_EL1
733007433d8SBoyan Karatotevelse
734007433d8SBoyan Karatotev	BL32_CPPFLAGS += -DIMAGE_AT_EL3
735d5e97a1dSMasahiro Yamadaendif
736d5e97a1dSMasahiro Yamada
73754035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
73854035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
73954035fc4SSandrine Bailleux# This can be overridden by the platform.
74073c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
7414f6ad66aSAchin Gupta
742a4409008Sdp-arm################################################################################
743a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
744a4409008Sdp-arm################################################################################
745c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32)
746c5e1da83SJayanth Dodderi Chidanand        NEED_BL32 := yes
747c5e1da83SJayanth Dodderi Chidanand
748a4409008Sdp-arm        ifneq (${AARCH32_SP},none)
749a4409008Sdp-arm        # We expect to locate an sp.mk under the specified AARCH32_SP directory
750a4409008Sdp-arm		AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
751a4409008Sdp-arm
752a4409008Sdp-arm                ifeq (${AARCH32_SP_MAKE},)
753a4409008Sdp-arm                        $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
754a4409008Sdp-arm                endif
755a4409008Sdp-arm                $(info Including ${AARCH32_SP_MAKE})
756a4409008Sdp-arm                include ${AARCH32_SP_MAKE}
757a4409008Sdp-arm        endif
758c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
7594f6ad66aSAchin Gupta
76073c99d4eSJuan Castillo################################################################################
76177f1f7a1SVarun Wadekar# Include libc if not overridden
76277f1f7a1SVarun Wadekar################################################################################
76377f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
76477f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
76577f1f7a1SVarun Wadekarendif
76677f1f7a1SVarun Wadekar
767*5d893410SBoyan Karatotevifneq (${USE_GIC_DRIVER},0)
768*5d893410SBoyan Karatotevinclude drivers/arm/gic/gic.mk
769*5d893410SBoyan Karatotevendif
770*5d893410SBoyan Karatotev
77177f1f7a1SVarun Wadekar################################################################################
772c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies
773cf2c8a33SAntonio Nino Diaz################################################################################
774cf2c8a33SAntonio Nino Diaz
775a0effb91SGovindraj Raja# Handle all invalid build configurations with SPMD usage.
776a0effb91SGovindraj Rajaifeq (${ENABLE_SPMD_LP}, 1)
777a0effb91SGovindraj Rajaifneq (${SPD},spmd)
778a0effb91SGovindraj Raja	$(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
779a0effb91SGovindraj Rajaendif
780a0effb91SGovindraj Rajaifeq ($(SPMC_AT_EL3),1)
781a0effb91SGovindraj Raja	$(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
782a0effb91SGovindraj Rajaendif
783a0effb91SGovindraj Rajaendif
784a0effb91SGovindraj Raja
785a0effb91SGovindraj Rajaifneq (${SPD},none)
786a0effb91SGovindraj Rajaifeq (${ARCH},aarch32)
787a0effb91SGovindraj Raja	$(error "Error: SPD is incompatible with AArch32.")
788a0effb91SGovindraj Rajaendif
789a0effb91SGovindraj Rajaifdef EL3_PAYLOAD_BASE
790a0effb91SGovindraj Raja	$(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
791a0effb91SGovindraj Raja	$(warning "The SPD and its BL32 companion will be present but ignored.")
792a0effb91SGovindraj Rajaendif
793a0effb91SGovindraj Rajaifeq (${SPD},spmd)
794a0effb91SGovindraj Rajaifeq ($(SPMD_SPM_AT_SEL2),1)
795a0effb91SGovindraj Raja	ifeq ($(SPMC_AT_EL3),1)
796a0effb91SGovindraj Raja		$(error SPM cannot be enabled in both S-EL2 and EL3.)
797a0effb91SGovindraj Raja	endif
798a0effb91SGovindraj Raja	ifeq ($(CTX_INCLUDE_SVE_REGS),1)
799a0effb91SGovindraj Raja		$(error SVE context management not needed with Hafnium SPMC.)
800a0effb91SGovindraj Raja	endif
801a0effb91SGovindraj Rajaendif
802a0effb91SGovindraj Raja
803a0effb91SGovindraj Rajaifeq ($(SPMC_AT_EL3_SEL0_SP),1)
804a0effb91SGovindraj Raja	ifneq ($(SPMC_AT_EL3),1)
805a0effb91SGovindraj Raja		$(error SEL0 SP cannot be enabled without SPMC at EL3)
806a0effb91SGovindraj Raja	endif
807a0effb91SGovindraj Rajaendif
808a0effb91SGovindraj Rajaendif #(SPD=spmd)
809a0effb91SGovindraj Rajaendif #(SPD!=none)
810a0effb91SGovindraj Raja
811c5e1da83SJayanth Dodderi Chidanand# USE_DEBUGFS experimental feature recommended only in debug builds
812c5e1da83SJayanth Dodderi Chidanandifeq (${USE_DEBUGFS},1)
813c5e1da83SJayanth Dodderi Chidanand        ifeq (${DEBUG},1)
814c5e1da83SJayanth Dodderi Chidanand                $(warning DEBUGFS experimental feature is enabled.)
815c5e1da83SJayanth Dodderi Chidanand        else
816c5e1da83SJayanth Dodderi Chidanand                $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
817c5e1da83SJayanth Dodderi Chidanand        endif
818c5e1da83SJayanth Dodderi Chidanandendif #(USE_DEBUGFS)
819c5e1da83SJayanth Dodderi Chidanand
820c5e1da83SJayanth Dodderi Chidanand# USE_SPINLOCK_CAS requires AArch64 build
821c5e1da83SJayanth Dodderi Chidanandifeq (${USE_SPINLOCK_CAS},1)
822c5e1da83SJayanth Dodderi Chidanand        ifneq (${ARCH},aarch64)
823c5e1da83SJayanth Dodderi Chidanand               $(error USE_SPINLOCK_CAS requires AArch64)
824c5e1da83SJayanth Dodderi Chidanand        endif
825c5e1da83SJayanth Dodderi Chidanandendif #(USE_SPINLOCK_CAS)
826c5e1da83SJayanth Dodderi Chidanand
827c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the
828c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all
829c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0)
830c5e1da83SJayanth Dodderi Chidanand        FIP_DEPS += certificates
831c5e1da83SJayanth Dodderi Chidanand        FWU_FIP_DEPS += fwu_certificates
832c5e1da83SJayanth Dodderi Chidanandendif
833c5e1da83SJayanth Dodderi Chidanand
834c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none)
835c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -f ${FW_ENC_STATUS}
836c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -k ${ENC_KEY}
837c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -n ${ENC_NONCE}
838c5e1da83SJayanth Dodderi Chidanand	FIP_DEPS += enctool
839c5e1da83SJayanth Dodderi Chidanand	FWU_FIP_DEPS += enctool
840c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
841c5e1da83SJayanth Dodderi Chidanand
842cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
84368450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
84468450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
84568450a6dSAntonio Nino Diaz		incompatible build options. EL3_PAYLOAD_BASE has priority.")
846cf2c8a33SAntonio Nino Diaz	endif
84776580f3dSQixiang Xu	ifneq (${GENERATE_COT},0)
848c5e1da83SJayanth Dodderi Chidanand                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
849c5e1da83SJayanth Dodderi Chidanand                build options.")
85076580f3dSQixiang Xu	endif
85176580f3dSQixiang Xu	ifneq (${TRUSTED_BOARD_BOOT},0)
852c5e1da83SJayanth Dodderi Chidanand                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
853c5e1da83SJayanth Dodderi Chidanand                incompatible \ build options.")
85476580f3dSQixiang Xu	endif
855c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
856cf2c8a33SAntonio Nino Diaz
857cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
858cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
859cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
860cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
861cf2c8a33SAntonio Nino Diaz	endif
86268450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
86368450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
864c5e1da83SJayanth Dodderi Chidanand                PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
865cf2c8a33SAntonio Nino Diaz	endif
866c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
867cf2c8a33SAntonio Nino Diaz
868d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
869d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
870d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
871d4593e47SJeenu Viswambharan        $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
872d4593e47SJeenu Viswambharanendif
8731a0a3f06SYatharth Kochar
87442d4d3baSArvind Ram Prakash#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
87542d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
87642d4d3baSArvind Ram Prakash        $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
8777d173fc5SJiafei Panendif
8787d173fc5SJiafei Pan
8799202d519SManish Pandey# RAS_EXTENSION is deprecated, provide alternate build options
88014c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
881c5e1da83SJayanth Dodderi Chidanand        $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
882f87e54f7SManish Pandey        and HANDLE_EA_EL3_FIRST_NS instead")
8839202d519SManish Pandeyendif
884c5e1da83SJayanth Dodderi Chidanand
885c5e1da83SJayanth Dodderi Chidanand
8869202d519SManish Pandey# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
8871a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
8886503ff29SAndre Przywara	ifeq ($(ENABLE_FEAT_RAS),0)
8896503ff29SAndre Przywara                $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
8901a7c1cfeSJeenu Viswambharan	endif
891c5e1da83SJayanth Dodderi Chidanandendif #(FAULT_INJECTION_SUPPORT)
8921a7c1cfeSJeenu Viswambharan
893ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
894209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
895209a60ccSSoby Mathew	ifeq (${TRUSTED_BOARD_BOOT}, 0)
896c5e1da83SJayanth Dodderi Chidanand                $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
897c5e1da83SJayanth Dodderi Chidanand                to be set.")
898209a60ccSSoby Mathew	endif
899c5e1da83SJayanth Dodderi Chidanandendif #(DYN_DISABLE_AUTH)
900209a60ccSSoby Mathew
9012bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
9022bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
9032bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
9042bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
9052bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
9062bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
9072bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
9082bf4f27fSManish V Badarkhe# Support hash calculation only
9092bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 2
9102bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1)
9112bf4f27fSManish V Badarkhe# Support authentication verification only
912c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 1
913c9c56f6eSManish V Badarkheelse
914c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 0
915c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
916c9c56f6eSManish V Badarkhe
917e4a070e3SManish V Badarkheifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),)
918e4a070e3SManish V BadarkheCRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a
919e4a070e3SManish V Badarkheendif
920e4a070e3SManish V Badarkhe
921cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
922cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
923700e7685SManish Pandey        $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
92484ef9cd8SManish V Badarkheendif
92584ef9cd8SManish V Badarkhe
926b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
9279fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
9289fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
9298d9f5f25SBoyan Karatotevifneq ($(ENABLE_PAUTH),0)
9309fc59639SAlexei Fedorov	ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
9318d9f5f25SBoyan Karatotev                $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS to be enabled)
93206715f85SAlexei Fedorov	endif
933c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PAUTH)
9349fc59639SAlexei Fedorov
9358d9f5f25SBoyan Karatotevifneq ($(CTX_INCLUDE_PAUTH_REGS),0)
9369fc59639SAlexei Fedorov	ifneq (${ARCH},aarch64)
9379fc59639SAlexei Fedorov                $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
938b86048c4SAntonio Nino Diaz	endif
939c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_PAUTH_REGS)
9409fc59639SAlexei Fedorov
9416a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1)
9426a0da736SJayanth Dodderi Chidanand        $(info FEATURE_DETECTION is an experimental feature)
943c5e1da83SJayanth Dodderi Chidanandendif #(FEATURE_DETECTION)
9446a0da736SJayanth Dodderi Chidanand
94503d3c0d7SJayanth Dodderi Chidanandifneq ($(ENABLE_SME2_FOR_NS), 0)
94603d3c0d7SJayanth Dodderi Chidanand	ifeq (${ENABLE_SME_FOR_NS}, 0)
947c5e1da83SJayanth Dodderi Chidanand                $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
948c5e1da83SJayanth Dodderi Chidanand                to be set")
94903d3c0d7SJayanth Dodderi Chidanand                $(warning "Forced ENABLE_SME_FOR_NS=1")
95003d3c0d7SJayanth Dodderi Chidanand		override ENABLE_SME_FOR_NS	:= 1
95103d3c0d7SJayanth Dodderi Chidanand	endif
952c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME2_FOR_NS)
95345007acdSJayanth Dodderi Chidanand
95460e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
95560e8f3cfSPetre-Ionut Tudor	ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
956c5e1da83SJayanth Dodderi Chidanand                $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
957c5e1da83SJayanth Dodderi Chidanand                library v2")
95860e8f3cfSPetre-Ionut Tudor	endif
959c5e1da83SJayanth Dodderi Chidanandendif #(ARM_XLAT_TABLES_LIB_V1)
96060e8f3cfSPetre-Ionut Tudor
9617cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
9627cda17bbSSumit Garg	ifeq (${TRUSTED_BOARD_BOOT}, 0)
963c5e1da83SJayanth Dodderi Chidanand                $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
964c5e1da83SJayanth Dodderi Chidanand                to be set)
9657cda17bbSSumit Garg	endif
966c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
9677cda17bbSSumit Garg
968744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build
969dc78e62dSjohpow01ifeq (${ARCH},aarch32)
970744ad974Sjohpow01
971744ad974Sjohpow01	# SME/SVE only supported on AArch64
97245007acdSJayanth Dodderi Chidanand	ifneq (${ENABLE_SME_FOR_NS},0)
973dc78e62dSjohpow01                $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
974dc78e62dSjohpow01	endif
97503d3c0d7SJayanth Dodderi Chidanand
976dc78e62dSjohpow01	ifeq (${ENABLE_SVE_FOR_NS},1)
977dc78e62dSjohpow01		# Warning instead of error due to CI dependency on this
97824ab2c0aSYann Gautier                $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
979dc78e62dSjohpow01	endif
980744ad974Sjohpow01
981ff86e0b4SJuan Pablo Conde	# BRBE is not supported in AArch32
982744ad974Sjohpow01	ifeq (${ENABLE_BRBE_FOR_NS},1)
983744ad974Sjohpow01                $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
984744ad974Sjohpow01	endif
985744ad974Sjohpow01
986ff86e0b4SJuan Pablo Conde	# FEAT_RNG_TRAP is not supported in AArch32
987ff86e0b4SJuan Pablo Conde	ifeq (${ENABLE_FEAT_RNG_TRAP},1)
988ff86e0b4SJuan Pablo Conde                $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
989ff86e0b4SJuan Pablo Conde	endif
990a57e18e4SArvind Ram Prakash
991a57e18e4SArvind Ram Prakash	ifneq (${ENABLE_FEAT_FPMR},0)
992a57e18e4SArvind Ram Prakash                $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
993a57e18e4SArvind Ram Prakash	endif
9948db17052SBoyan Karatotev
9958db17052SBoyan Karatotev	ifeq (${ARCH_FEATURE_AVAILABILITY},1)
9968db17052SBoyan Karatotev                $(error "ARCH_FEATURE_AVAILABILITY cannot be used with ARCH=aarch32")
9978db17052SBoyan Karatotev	endif
9986b8df7b9SArvind Ram Prakash	# FEAT_MOPS is only supported on AArch64
9996b8df7b9SArvind Ram Prakash	ifneq (${ENABLE_FEAT_MOPS},0)
10006b8df7b9SArvind Ram Prakash		$(error "ENABLE_FEAT_MOPS cannot be used with ARCH=aarch32")
10016b8df7b9SArvind Ram Prakash	endif
1002c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
1003dc78e62dSjohpow01
1004a57e18e4SArvind Ram Prakashifneq (${ENABLE_FEAT_FPMR},0)
1005a57e18e4SArvind Ram Prakash	ifeq (${ENABLE_FEAT_FGT},0)
1006a57e18e4SArvind Ram Prakash                $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
1007a57e18e4SArvind Ram Prakash	endif
1008a57e18e4SArvind Ram Prakash	ifeq (${ENABLE_FEAT_HCX},0)
1009a57e18e4SArvind Ram Prakash                $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
1010a57e18e4SArvind Ram Prakash	endif
1011a57e18e4SArvind Ram Prakashendif #(ENABLE_FEAT_FPMR)
1012a57e18e4SArvind Ram Prakash
10130d122947SBoyan Karatotevifneq (${ENABLE_SME_FOR_NS},0)
10140d122947SBoyan Karatotev	ifeq (${ENABLE_SVE_FOR_NS},0)
10150d122947SBoyan Karatotev                $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
10160d122947SBoyan Karatotev	endif
1017c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_NS)
10180d122947SBoyan Karatotev
1019dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well
1020dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1)
1021dc78e62dSjohpow01	ifeq (${ENABLE_SME_FOR_NS},0)
1022dc78e62dSjohpow01                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
1023dc78e62dSjohpow01	endif
10240d122947SBoyan Karatotev	ifeq (${ENABLE_SVE_FOR_SWD},0)
10250d122947SBoyan Karatotev                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
10260d122947SBoyan Karatotev	endif
1027c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_SWD)
1028c5e1da83SJayanth Dodderi Chidanand
10293524d074SMadhukar Pappireddy# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
10303524d074SMadhukar Pappireddy# mechanism.
1031dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1)
1032dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},0)
1033dc78e62dSjohpow01        $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1034dc78e62dSjohpow01    endif
10353524d074SMadhukar Pappireddyendif
1036dc78e62dSjohpow01
1037484befbfSArvind Ram Prakash# Enabling FEAT_MOPS requires access to hcrx_el2 registers which is
1038484befbfSArvind Ram Prakash# available only when FEAT_HCX is enabled.
1039484befbfSArvind Ram Prakashifneq (${ENABLE_FEAT_MOPS},0)
1040484befbfSArvind Ram Prakash	ifeq (${ENABLE_FEAT_HCX},0)
1041484befbfSArvind Ram Prakash		$(error "ENABLE_FEAT_MOPS requires ENABLE_FEAT_HCX")
1042484befbfSArvind Ram Prakash	endif
1043484befbfSArvind Ram Prakashendif
1044484befbfSArvind Ram Prakash
10453524d074SMadhukar Pappireddy# Enabling SVE for both the worlds typically requires the context
10463524d074SMadhukar Pappireddy# management of SVE registers. The only exception being SPMC at S-EL2.
10473524d074SMadhukar Pappireddyifeq (${ENABLE_SVE_FOR_SWD}, 1)
10483524d074SMadhukar Pappireddy    ifneq (${ENABLE_SVE_FOR_NS}, 0)
10493524d074SMadhukar Pappireddy        ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
10503524d074SMadhukar Pappireddy            $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
10513524d074SMadhukar Pappireddy        endif
10523524d074SMadhukar Pappireddy    endif
10533524d074SMadhukar Pappireddyendif
10543524d074SMadhukar Pappireddy
10553524d074SMadhukar Pappireddy# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
10563524d074SMadhukar Pappireddy# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
10573524d074SMadhukar Pappireddy# and SVE registers.
10583524d074SMadhukar Pappireddyifeq (${CTX_INCLUDE_FPREGS}, 1)
10593524d074SMadhukar Pappireddy    ifneq (${ENABLE_SVE_FOR_NS},0)
10603524d074SMadhukar Pappireddy        ifeq (${CTX_INCLUDE_SVE_REGS},0)
10613524d074SMadhukar Pappireddy	    # Warning instead of error due to CI dependency on this
10623524d074SMadhukar Pappireddy            $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
10633524d074SMadhukar Pappireddy            $(warning "Forced ENABLE_SVE_FOR_NS=0")
10643524d074SMadhukar Pappireddy	    override ENABLE_SVE_FOR_NS	:= 0
10653524d074SMadhukar Pappireddy        endif
10663524d074SMadhukar Pappireddy    endif
10673524d074SMadhukar Pappireddyendif #(CTX_INCLUDE_FPREGS)
10683524d074SMadhukar Pappireddy
10693524d074SMadhukar Pappireddy# SVE context management is only required if secure world has access to SVE/FP
10703524d074SMadhukar Pappireddy# functionality.
10713524d074SMadhukar Pappireddyifeq (${CTX_INCLUDE_SVE_REGS},1)
10723524d074SMadhukar Pappireddy    ifeq (${ENABLE_SVE_FOR_SWD},0)
10733524d074SMadhukar Pappireddy        $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
10743524d074SMadhukar Pappireddy    endif
10753524d074SMadhukar Pappireddyendif
10763524d074SMadhukar Pappireddy
10773524d074SMadhukar Pappireddy# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
10783524d074SMadhukar Pappireddy# management including FPU registers.
1079dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1)
108045007acdSJayanth Dodderi Chidanand    ifneq (${ENABLE_SME_FOR_NS},0)
1081dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1082dc78e62dSjohpow01    endif
1083c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_FPREGS)
1084dc78e62dSjohpow01
108500e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1)
108600e28874SManish V Badarkhe        $(info DRTM_SUPPORT is an experimental feature)
108700e28874SManish V Badarkheendif
108800e28874SManish V Badarkhe
10898953568aSLevi Yunifeq (${HOB_LIST},1)
10908953568aSLevi Yun        $(warning HOB_LIST is an experimental feature)
10918953568aSLevi Yunendif
10928953568aSLevi Yun
10933ba2c151SRaymond Maoifeq (${TRANSFER_LIST},1)
10943ba2c151SRaymond Mao        $(info TRANSFER_LIST is an experimental feature)
10953ba2c151SRaymond Maoendif
10963ba2c151SRaymond Mao
1097274a69e7SChris Kayifeq (${ENABLE_RME},1)
1098274a69e7SChris Kay	ifneq (${SEPARATE_CODE_AND_RODATA},1)
1099274a69e7SChris Kay                $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1100274a69e7SChris Kay	endif
1101274a69e7SChris Kayendif
1102274a69e7SChris Kay
11035782b890SManish V Badarkheifeq ($(PSA_CRYPTO),1)
11045782b890SManish V Badarkhe        $(info PSA_CRYPTO is an experimental feature)
11055782b890SManish V Badarkheendif
11065782b890SManish V Badarkhe
110782222db8SManish V Badarkheifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
110882222db8SManish V Badarkhe        $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
110982222db8SManish V Badarkheendif
111082222db8SManish V Badarkhe
1111cf2c8a33SAntonio Nino Diaz################################################################################
111273c99d4eSJuan Castillo# Process platform overrideable behaviour
111373c99d4eSJuan Castillo################################################################################
11144f6ad66aSAchin Gupta
11155f24ce96SManish Pandeyifdef BL1_SOURCES
11165f24ce96SManish Pandey	NEED_BL1 := yes
1117c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES)
11185f24ce96SManish Pandey
11195f24ce96SManish Pandeyifdef BL2_SOURCES
11205f24ce96SManish Pandey	NEED_BL2 := yes
11215f24ce96SManish Pandey
1122bd97f83aSJohn Tsichritzis	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1123bd97f83aSJohn Tsichritzis	# Certificate generation tools. This flag can be overridden by the platform.
1124cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
1125cf2c8a33SAntonio Nino Diaz		# If booting an EL3 payload there is no need for a BL33 image
1126cf2c8a33SAntonio Nino Diaz		# in the FIP file.
11274c117f6cSSandrine Bailleux		NEED_BL33		:=	no
1128cf2c8a33SAntonio Nino Diaz	else
112968450a6dSAntonio Nino Diaz		ifdef PRELOADED_BL33_BASE
1130cf2c8a33SAntonio Nino Diaz			# If booting a BL33 preloaded image there is no need of
1131cf2c8a33SAntonio Nino Diaz			# another one in the FIP file.
1132cf2c8a33SAntonio Nino Diaz			NEED_BL33		:=	no
1133cf2c8a33SAntonio Nino Diaz		else
1134cf2c8a33SAntonio Nino Diaz			NEED_BL33		?=	yes
1135cf2c8a33SAntonio Nino Diaz		endif
11364c117f6cSSandrine Bailleux	endif
1137c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES)
11386f971622SJuan Castillo
11395f24ce96SManish Pandeyifdef BL2U_SOURCES
11405f24ce96SManish Pandey	NEED_BL2U := yes
1141c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES)
11425f24ce96SManish Pandey
11434d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
11444d045d0eSMasahiro Yamadaifdef SCP_BL2
11454d045d0eSMasahiro Yamada	NEED_SCP_BL2		:=	yes
1146c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2)
11474d045d0eSMasahiro Yamada
11485744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
11495744e874SSoby Mathewifneq (${ARCH},aarch32)
11505744e874SSoby Mathew	ifdef BL31_SOURCES
1151c5e1da83SJayanth Dodderi Chidanand	# When booting an EL3 payload, there is no need to compile the BL31
1152c5e1da83SJayanth Dodderi Chidanand	# image nor put it in the FIP.
11535744e874SSoby Mathew		ifndef EL3_PAYLOAD_BASE
11545744e874SSoby Mathew			NEED_BL31 := yes
11555744e874SSoby Mathew		endif
11565744e874SSoby Mathew	endif
1157c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64)
11585744e874SSoby Mathew
115973c99d4eSJuan Castillo# Process TBB related flags
11606f971622SJuan Castilloifneq (${GENERATE_COT},0)
116173c99d4eSJuan Castillo	# Common cert_create options
11626f971622SJuan Castillo	ifneq (${CREATE_KEYS},0)
11636f971622SJuan Castillo                $(eval CRT_ARGS += -n)
11640191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
1165fd34e7baSJuan Castillo		ifneq (${SAVE_KEYS},0)
1166fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
11670191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
1168fd34e7baSJuan Castillo		endif
11696f971622SJuan Castillo	endif
117073c99d4eSJuan Castillo	# Include TBBR makefile (unless the platform indicates otherwise)
117173c99d4eSJuan Castillo	ifeq (${INCLUDE_TBBR_MK},1)
117273c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
117373c99d4eSJuan Castillo	endif
1174c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
11756f971622SJuan Castillo
11761c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
11771c75d5dfSMasahiro Yamada	FIP_ARGS += --align ${FIP_ALIGN}
1178c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN)
11791c75d5dfSMasahiro Yamada
11805f24ce96SManish Pandeyifdef FDT_SOURCES
11815f24ce96SManish Pandey	NEED_FDT := yes
1182c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES)
11835f24ce96SManish Pandey
118473c99d4eSJuan Castillo################################################################################
118546e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
118646e5e035SMichalis Pappas################################################################################
118746e5e035SMichalis Pappas
118846e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
118946e5e035SMichalis Pappas
119046e5e035SMichalis Pappas################################################################################
11918a86052dSSoby Mathew# Include BL specific makefiles
11928a86052dSSoby Mathew################################################################################
11935f24ce96SManish Pandey
11945f24ce96SManish Pandeyifeq (${NEED_BL1},yes)
11958a86052dSSoby Mathewinclude bl1/bl1.mk
11968a86052dSSoby Mathewendif
11978a86052dSSoby Mathew
11985f24ce96SManish Pandeyifeq (${NEED_BL2},yes)
11998a86052dSSoby Mathewinclude bl2/bl2.mk
12008a86052dSSoby Mathewendif
12018a86052dSSoby Mathew
12025f24ce96SManish Pandeyifeq (${NEED_BL2U},yes)
12038a86052dSSoby Mathewinclude bl2u/bl2u.mk
12048a86052dSSoby Mathewendif
12058a86052dSSoby Mathew
12065744e874SSoby Mathewifeq (${NEED_BL31},yes)
12078a86052dSSoby Mathewinclude bl31/bl31.mk
12088a86052dSSoby Mathewendif
120903b397a8SNishanth Menon
121073c99d4eSJuan Castillo################################################################################
121173c99d4eSJuan Castillo# Build options checks
121273c99d4eSJuan Castillo################################################################################
121373c99d4eSJuan Castillo
1214c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags
1215327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
1216327131c4SLeonardo Sandoval    $(sort \
1217327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
121846789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
1219327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
1220327131c4SLeonardo Sandoval	CREATE_KEYS \
1221327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
1222327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
122342422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
1224327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
12259acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
1226327131c4SLeonardo Sandoval	DEBUG \
1227327131c4SLeonardo Sandoval	DYN_DISABLE_AUTH \
1228327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
12291fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
1230873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
1231327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
1232327131c4SLeonardo Sandoval	ENABLE_PIE \
1233327131c4SLeonardo Sandoval	ENABLE_PMF \
1234327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
1235327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
1236dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
12370c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
1238970a4a8dSManish Pandey	ENABLE_FEAT_RAS	\
1239f87e54f7SManish Pandey	FFH_SUPPORT	\
1240327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
1241327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
1242327131c4SLeonardo Sandoval	GENERATE_COT \
1243327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
124446cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
1245538516f5SBipin Ravi	HARDEN_SLS \
1246327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
1247327131c4SLeonardo Sandoval	MEASURED_BOOT \
124836e3d877SAbhi.Singh	DISCRETE_TPM \
1249e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
12506a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
12512132c707SSona Mathew	RMMD_ENABLE_IDE_KEY_PROG \
125200e28874SManish V Badarkhe	DRTM_SUPPORT \
1253327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
1254327131c4SLeonardo Sandoval	OVERRIDE_LIBC \
1255327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
1256327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
1257327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
125864b4710bSWing Li	PSCI_OS_INIT_MODE \
12598db17052SBoyan Karatotev	ARCH_FEATURE_AVAILABILITY \
1260327131c4SLeonardo Sandoval	RESET_TO_BL31 \
1261327131c4SLeonardo Sandoval	SAVE_KEYS \
1262327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
126396a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
1264327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
126586acbbe2SYe Li	SEPARATE_RWDATA_REGION \
1266308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
1267327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
1268327131c4SLeonardo Sandoval	SPM_MM \
12691d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
1270801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
1271327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
1272890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
12733ba2c151SRaymond Mao	TRANSFER_LIST \
1274327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
1275327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
1276327131c4SLeonardo Sandoval	USE_DEBUGFS \
1277327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
1278327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
1279327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
1280327131c4SLeonardo Sandoval	USE_ROMLIB \
1281327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
1282327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
128342d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
1284327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
1285327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
1286327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
1287327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
1288327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
1289327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
129045c7328cSBoyan Karatotev	ERRATA_SME_POWER_DOWN \
129100e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
1292327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
1293327131c4SLeonardo Sandoval	USE_SP804_TIMER \
1294396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
129511d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
129668120783SChris Kay	ENABLE_MPMM \
12972b5e00d4SBoyan Karatotev	FEAT_PABANDON \
12986a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
12990b22e591SJayanth Dodderi Chidanand	TRNG_SUPPORT \
1300593ae354SBoyan Karatotev	ENABLE_ERRATA_ALL \
1301ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
1302ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
130304c7303bSOkash Khawaja	CONDITIONAL_CMO \
13045782b890SManish V Badarkhe	PSA_CRYPTO	\
130585bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
1306183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
1307bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
1308ae770fedSYann Gautier	EARLY_CONSOLE \
1309f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
13108953568aSLevi Yun	HOB_LIST \
1311327131c4SLeonardo Sandoval)))
131273c99d4eSJuan Castillo
1313c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags
1314327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
1315327131c4SLeonardo Sandoval    $(sort \
1316327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
1317327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
1318327131c4SLeonardo Sandoval	BRANCH_PROTECTION \
13196a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_PAUTH_REGS \
13206a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_NEVE_REGS \
13212bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT \
132283a4dae1SBoyan Karatotev	DISABLE_MTPMU \
13231298f2f1SJayanth Dodderi Chidanand	ENABLE_BRBE_FOR_NS \
132447c681b7SJayanth Dodderi Chidanand	ENABLE_TRBE_FOR_NS \
13256a0da736SJayanth Dodderi Chidanand	ENABLE_BTI \
13266a0da736SJayanth Dodderi Chidanand	ENABLE_PAUTH \
1327d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
13286a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
13296a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
133030019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
133183271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
13326a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_DIT \
13336a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
13346a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
133533e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
1336a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
13376a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_HCX \
133819d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
13397e84f3cfSTushar Khandelwal	ENABLE_FEAT_MEC \
13406b8df7b9SArvind Ram Prakash	ENABLE_FEAT_MOPS \
13418e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
13426a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
13436a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_RNG \
1344ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
13456a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
1346d3331603SMark Brown	ENABLE_FEAT_TCR2 \
13476d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
13480e4daed2SGovindraj Raja	ENABLE_FEAT_SB \
1349062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
1350062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
1351062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
1352062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
13534ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
135430655136SGovindraj Raja	ENABLE_FEAT_D128 \
1355688ab57bSMark Brown	ENABLE_FEAT_GCS \
13566a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
1357edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
13586a0da736SJayanth Dodderi Chidanand	ENABLE_RME \
13596437a09aSAndre Przywara	ENABLE_SPE_FOR_NS \
1360603a0c6fSAndre Przywara	ENABLE_SYS_REG_TRACE_FOR_NS \
136145007acdSJayanth Dodderi Chidanand	ENABLE_SME_FOR_NS \
136203d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
13632b0bc4e0SJayanth Dodderi Chidanand	ENABLE_SVE_FOR_NS \
13646a0da736SJayanth Dodderi Chidanand	ENABLE_TRF_FOR_NS \
1365327131c4SLeonardo Sandoval	FW_ENC_STATUS \
13665357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
13675357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
1368781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
1369781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
1370bebcf27fSMark Brown	SVE_VECTOR_LEN \
13710ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
1372327131c4SLeonardo Sandoval)))
1373c877b414SJeenu Viswambharan
1374aacff749SJustin Chadwellifdef KEY_SIZE
1375aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
1376aacff749SJustin Chadwellendif
1377aacff749SJustin Chadwell
13781f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
13791f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
13801f461979SJustin Chadwellendif
13811f461979SJustin Chadwell
138273c99d4eSJuan Castillo################################################################################
138373c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
138473c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
138573c99d4eSJuan Castillo# platform to overwrite the default options
138673c99d4eSJuan Castillo################################################################################
138773c99d4eSJuan Castillo
1388327131c4SLeonardo Sandoval$(eval $(call add_defines,\
1389327131c4SLeonardo Sandoval    $(sort \
1390327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
1391327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
1392327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
139346789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
1394327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
1395327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
1396327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
139742422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
1398327131c4SLeonardo Sandoval	CTX_INCLUDE_PAUTH_REGS \
13999acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
1400327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
1401327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
1402062f8aafSArunachalam Ganapathy	CTX_INCLUDE_NEVE_REGS \
1403327131c4SLeonardo Sandoval	DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
14040063dd17SJavier Almansa Sobrino	DISABLE_MTPMU \
1405d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
14061fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
1407873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
1408327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
1409327131c4SLeonardo Sandoval	ENABLE_BTI \
141083271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
1411edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
1412327131c4SLeonardo Sandoval	ENABLE_PAUTH \
1413327131c4SLeonardo Sandoval	ENABLE_PIE \
1414327131c4SLeonardo Sandoval	ENABLE_PMF \
1415327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
14165b18de09SZelalem Aweke	ENABLE_RME \
14176a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
14182132c707SSona Mathew	RMMD_ENABLE_IDE_KEY_PROG \
1419327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
1420dc78e62dSjohpow01	ENABLE_SME_FOR_NS \
142103d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
1422dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
142390118bb5SAndre Przywara	ENABLE_SPE_FOR_NS \
1424327131c4SLeonardo Sandoval	ENABLE_SVE_FOR_NS \
14250c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
1426970a4a8dSManish Pandey	ENABLE_FEAT_RAS \
1427f87e54f7SManish Pandey	FFH_SUPPORT \
1428327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
1429327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
1430327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
1431327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
1432327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
143346cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
1434327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
1435327131c4SLeonardo Sandoval	LOG_LEVEL \
1436327131c4SLeonardo Sandoval	MEASURED_BOOT \
143736e3d877SAbhi.Singh	DISCRETE_TPM \
1438e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
143900e28874SManish V Badarkhe	DRTM_SUPPORT \
1440327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
1441327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
1442327131c4SLeonardo Sandoval	PLAT_${PLAT} \
1443327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
1444327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
144564b4710bSWing Li	PSCI_OS_INIT_MODE \
14468db17052SBoyan Karatotev	ARCH_FEATURE_AVAILABILITY \
1447327131c4SLeonardo Sandoval	RESET_TO_BL31 \
1448d766084fSAlexeiFedorov	RME_GPT_BITLOCK_BLOCK \
1449ec0088bbSAlexeiFedorov	RME_GPT_MAX_BLOCK \
1450327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
145196a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
1452327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
145386acbbe2SYe Li	SEPARATE_RWDATA_REGION \
1454308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
1455327131c4SLeonardo Sandoval	RECLAIM_INIT_CODE \
1456327131c4SLeonardo Sandoval	SPD_${SPD} \
1457327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
1458327131c4SLeonardo Sandoval	SPM_MM \
14591d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
1460801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
1461327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
14623ba2c151SRaymond Mao	TRANSFER_LIST \
1463327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
1464c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT \
14657dfb9911SJimmy Brisson	TRNG_SUPPORT \
1466ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
1467ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
1468327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
1469327131c4SLeonardo Sandoval	USE_DEBUGFS \
1470327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
1471327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
1472327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
1473327131c4SLeonardo Sandoval	USE_ROMLIB \
1474327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
1475327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
147642d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
147742d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	\
1478327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
1479327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
1480327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
1481327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
148245c7328cSBoyan Karatotev	ERRATA_SME_POWER_DOWN \
148300e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
1484327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
1485327131c4SLeonardo Sandoval	USE_SP804_TIMER \
148612cd65e0STomas Pilar	ENABLE_FEAT_RNG \
1487ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
14884e04478aSChris Kay	ENABLE_FEAT_SB \
14897d33ffe4SDaniel Boulby	ENABLE_FEAT_DIT \
14905357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
14915357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
1492396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
149311d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
1494744ad974Sjohpow01	ENABLE_BRBE_FOR_NS \
1495813524eaSManish V Badarkhe	ENABLE_TRBE_FOR_NS \
1496d4582d30SManish V Badarkhe	ENABLE_SYS_REG_TRACE_FOR_NS \
14978fcd3d96SManish V Badarkhe	ENABLE_TRF_FOR_NS \
1498cb4ec47bSjohpow01	ENABLE_FEAT_HCX \
149968120783SChris Kay	ENABLE_MPMM \
15002b5e00d4SBoyan Karatotev	FEAT_PABANDON \
1501f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
150233e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
1503a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
1504f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
15056a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
15066a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
15076a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
15086a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
150930019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
151019d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
15117e84f3cfSTushar Khandelwal	ENABLE_FEAT_MEC \
15126a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
1513d3331603SMark Brown	ENABLE_FEAT_TCR2 \
15146d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
1515062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
1516062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
1517062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
1518062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
15194ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
152030655136SGovindraj Raja	ENABLE_FEAT_D128 \
1521688ab57bSMark Brown	ENABLE_FEAT_GCS \
15226b8df7b9SArvind Ram Prakash	ENABLE_FEAT_MOPS \
15238e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
15246a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
1525781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
1526781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
152704c7303bSOkash Khawaja	CONDITIONAL_CMO \
15280ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
1529a8cf6faeSJayanth Dodderi Chidanand	SVE_VECTOR_LEN \
1530890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
15315782b890SManish V Badarkhe	PSA_CRYPTO	\
153285bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
1533183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
1534bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
1535ae770fedSYann Gautier	EARLY_CONSOLE \
1536f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
15378953568aSLevi Yun	HOB_LIST \
1538327131c4SLeonardo Sandoval)))
15392fae4b1eSJeenu Viswambharan
1540bfef8b90SJuan Pablo Condeifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1541bfef8b90SJuan Pablo Condeifeq (${DEBUG}, 0)
1542bfef8b90SJuan Pablo Conde        $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1543bfef8b90SJuan Pablo Conde        override PLATFORM_REPORT_CTX_MEM_USE := 0
1544bfef8b90SJuan Pablo Condeendif
1545bfef8b90SJuan Pablo Condeendif
1546bfef8b90SJuan Pablo Conde
15471f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
15481f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
1549c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB)
15501f461979SJustin Chadwell
15514c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
15524c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
15534c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1554cf2c8a33SAntonio Nino Diazelse
155568450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and
155668450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority.
155768450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
155868450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
15594c117f6cSSandrine Bailleux	endif
1560c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
156173c99d4eSJuan Castillo
1562209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1563209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1564209a60ccSSoby Mathew        $(eval $(call add_define,DYN_DISABLE_AUTH))
1565209a60ccSSoby Mathewendif
1566209a60ccSSoby Mathew
15678620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link)
1568c2ad38ceSVarun Wadekar        $(eval $(call add_define,USE_ARM_LINK))
1569c2ad38ceSVarun Wadekarendif
1570c2ad38ceSVarun Wadekar
1571ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1572ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1573c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1574ce2b1ec6SManish Pandey	-include $(BUILD_PLAT)/sp_gen.mk
1575ce2b1ec6SManish Pandey	FIP_DEPS += sp
157607c44475SManish Pandey	CRT_DEPS += sp
1577ce2b1ec6SManish Pandey	NEED_SP_PKG := yes
1578ce2b1ec6SManish Pandeyelse
1579c33ff198SOlivier Deprez	ifeq (${SPMD_SPM_AT_SEL2},1)
1580c33ff198SOlivier Deprez                $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1581c33ff198SOlivier Deprez	endif
1582c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE)
1583c5e1da83SJayanth Dodderi Chidanandendif #(SPD)
1584ce2b1ec6SManish Pandey
158573c99d4eSJuan Castillo################################################################################
158673c99d4eSJuan Castillo# Build targets
158773c99d4eSJuan Castillo################################################################################
158873c99d4eSJuan Castillo
15892329e22bSHarrison 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
159073c99d4eSJuan Castillo
159173c99d4eSJuan Castilloall: msg_start
159273c99d4eSJuan Castillo
159373c99d4eSJuan Castillomsg_start:
15947c4e1eeaSChris Kay	$(s)echo "Building ${PLAT}"
159573c99d4eSJuan Castillo
15967a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1597d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
15988620bd0bSChris Kayifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
1599c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1600c2ad38ceSVarun Wadekarelse
1601bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
16027a24cba5SSoby Mathewendif
1603c5e1da83SJayanth Dodderi Chidanandendif #(!ERROR_DEPRECATED)
16047a24cba5SSoby Mathew
160561f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
16065fee0287SRoberto Vargas
160773c99d4eSJuan Castillo# Expand build macros for the different images
160873c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
1609b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES})
1610434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1))
1611c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1)
161273c99d4eSJuan Castillo
161373c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1614c5e1da83SJayanth Dodderi Chidanand
161542d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0)
1616c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1617c9b31ae8SRoberto Vargasendif
1618c9b31ae8SRoberto Vargas
1619eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES})
1620eb1acfb6SChris Kay
162133950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1622434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1623c5e1da83SJayanth Dodderi Chidanand
1624c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2)
162573c99d4eSJuan Castillo
16264d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
162733950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1628c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2)
16294d045d0eSMasahiro Yamada
163073c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
163173c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
163226d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
163326d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1634c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1635c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1636434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1637c6ba9b45SSumit Gargelse
163833950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1639434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw)))
1640c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1641c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31)
164273c99d4eSJuan Castillo
164370d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1644c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
164570d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
164673c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
164726d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
164826d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
16499cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
16509cd15239SMasahiro Yamada
1651c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1652434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1653c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1654c6ba9b45SSumit Gargelse
1655434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
165633950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1657c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1658c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32)
165973c99d4eSJuan Castillo
16605b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
16615b18de09SZelalem Aweke# needs to be built from RMM_SOURCES.
16625b18de09SZelalem Awekeifeq (${NEED_RMM},yes)
16635b18de09SZelalem Aweke# Sort RMM source files to remove duplicates
16645b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES})
16655b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
16665b18de09SZelalem Aweke
16675b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
16685b18de09SZelalem Aweke	 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1669c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM)
16705b18de09SZelalem Aweke
167173c99d4eSJuan Castillo# Add the BL33 image if required by the platform
167273c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
167333950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1674c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
1675db6071c9SJuan Castillo
16769003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
167733950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1678434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1679c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U)
16809003fa0bSYatharth Kochar
168103b397a8SNishanth Menon# Expand build macros for the different images
168203b397a8SNishanth Menonifeq (${NEED_FDT},yes)
168303b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
16841c08ff32SSalman Nabi
16851c08ff32SSalman Nabi    ifneq (${INITRD_SIZE}${INITRD_PATH},)
16861c08ff32SSalman Nabi        ifndef INITRD_BASE
16871c08ff32SSalman Nabi            $(error INITRD_BASE must be set when inserting initrd properties to the DTB.)
16881c08ff32SSalman Nabi        endif
16891c08ff32SSalman Nabi
16901c08ff32SSalman Nabi        INITRD_SIZE ?= $(shell printf "0x%x\n" $$(stat -Lc %s $(INITRD_PATH)))
16911c08ff32SSalman Nabi        initrd_end = $(shell printf "0x%x\n" $$(expr $$(($(INITRD_BASE) + $(INITRD_SIZE)))))
16921c08ff32SSalman Nabi
16931c08ff32SSalman Nabi        define $(HW_CONFIG)-after +=
16941c08ff32SSalman Nabi            $(s)echo "  INITRD  $(HW_CONFIG)"
16951c08ff32SSalman Nabi            $(q)fdtput -t x $@ /chosen linux,initrd-start $(INITRD_BASE)
16961c08ff32SSalman Nabi            $(q)fdtput -t x $@ /chosen linux,initrd-end $(initrd_end)
16971c08ff32SSalman Nabi        endef
16981c08ff32SSalman Nabi    endif
1699c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT)
170003b397a8SNishanth Menon
1701ce2b1ec6SManish Pandey# Add Secure Partition packages
1702ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1703fd74ca0dSChris Kay$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
1704679e27ceSChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
1705dd816235SKathleen Capella	$(q)$(if $(host-poetry),poetry run )${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
1706822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
17077c4e1eeaSChris Kay	$(s)echo
17087c4e1eeaSChris Kay	$(s)echo "Built SP Images successfully"
17097c4e1eeaSChris Kay	$(s)echo
1710c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG)
1711ce2b1ec6SManish Pandey
171236eaaf37SIan Spraylocate-checkpatch:
171336eaaf37SIan Sprayifndef CHECKPATCH
171466079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
171536eaaf37SIan Sprayelse
171636eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
171766079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
171836eaaf37SIan Sprayendif
1719c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH)
172036eaaf37SIan Spray
17214f6ad66aSAchin Guptaclean:
17227c4e1eeaSChris Kay	$(s)echo "  CLEAN"
1723c3273703SChris Kay	$(q)rm -rf $(BUILD_PLAT)
17247c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
17257c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
17267c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
17277c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
17284f6ad66aSAchin Gupta
1729eaaeece2SJames Morrisseyrealclean distclean:
17307c4e1eeaSChris Kay	$(s)echo "  REALCLEAN"
1731c3273703SChris Kay	$(q)rm -rf $(BUILD_BASE)
1732c3273703SChris Kay	$(q)rm -rf $(CURDIR)/cscope.*
17337c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
17347c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
17357c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
17367c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
17374f6ad66aSAchin Gupta
173836eaaf37SIan Spraycheckcodebase:		locate-checkpatch
17397c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
17407c4e1eeaSChris Kay	$(q)if test -d .git ; then						\
17411ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
17421a41e8c1SDan Handley		while read GIT_FILE ;					\
17431a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
17441a41e8c1SDan Handley		done ;							\
174536eaaf37SIan Spray	else								\
17461a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
17471a41e8c1SDan Handley		 -not -iwholename "*build*"				\
17481a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
174961f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
17501a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
17511ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
17521a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
175336eaaf37SIan Spray	fi
175436eaaf37SIan Spray
175536eaaf37SIan Spraycheckpatch:		locate-checkpatch
17567c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
17577c4e1eeaSChris Kay	$(q)if test -n "${CHECKPATCH_OPTS}"; then				\
175802a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
175902a76d5fSYann Gautier	fi
17607c4e1eeaSChris Kay	$(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
176177a0a7f1SYann Gautier	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
176277a0a7f1SYann Gautier	do								\
176351d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
17641a721748SYann Gautier		( git log --format=email "$$commit~..$$commit"		\
17651a721748SYann Gautier			-- ${CHECK_PATHS} ;				\
176651d28937SAntonio Nino Diaz		  git diff --format=email "$$commit~..$$commit"		\
17671a721748SYann Gautier			-- ${CHECK_PATHS}; ) |				\
176802a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
176951d28937SAntonio Nino Diaz	done
177036eaaf37SIan Spray
177173c99d4eSJuan Castillocerttool: ${CRTTOOL}
177273c99d4eSJuan Castillo
1773a9812206SPali Rohár${CRTTOOL}: FORCE
17747c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all
17757c4e1eeaSChris Kay	$(s)echo
17767c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17777c4e1eeaSChris Kay	$(s)echo
17786f971622SJuan Castillo
17796f971622SJuan Castilloifneq (${GENERATE_COT},0)
178073c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
17817c4e1eeaSChris Kay	$(q)${CRTTOOL} ${CRT_ARGS}
17827c4e1eeaSChris Kay	$(s)echo
17837c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17847c4e1eeaSChris Kay	$(s)echo "Certificates can be found in ${BUILD_PLAT}"
17857c4e1eeaSChris Kay	$(s)echo
1786c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
178727713fb4SSoby Mathew
178873c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
17894727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
17907c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FIP_ARGS} $@
17917c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
17927c4e1eeaSChris Kay	$(s)echo
17937c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17947c4e1eeaSChris Kay	$(s)echo
1795f58ad36fSHarry Liebel
17960191262dSYatharth Kocharifneq (${GENERATE_COT},0)
17970191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
17987c4e1eeaSChris Kay	$(q)${CRTTOOL} ${FWU_CRT_ARGS}
17997c4e1eeaSChris Kay	$(s)echo
18007c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
18017c4e1eeaSChris Kay	$(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
18027c4e1eeaSChris Kay	$(s)echo
1803c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
18040191262dSYatharth Kochar
18050191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
18064727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
18077c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
18087c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
18097c4e1eeaSChris Kay	$(s)echo
18107c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
18117c4e1eeaSChris Kay	$(s)echo
18120191262dSYatharth Kochar
181373c99d4eSJuan Castillofiptool: ${FIPTOOL}
181473c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
18150191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
181673c99d4eSJuan Castillo
1817a9812206SPali Rohár${FIPTOOL}: FORCE
181840469bf9SManish V Badarkhe	$(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
1819f58ad36fSHarry Liebel
1820e4a070e3SManish V Badarkhe$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB)
1821e4a070e3SManish V Badarkhe	$(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_SUPPORT=${CRYPTO_SUPPORT} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
18225accce5bSRoberto Vargas
1823cfe83910SLouis Mayencourtmemmap: all
1824c25405d6SChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
1825ed0c801fSChris Kay	$(q)$(if $(host-poetry),poetry run )memory -sr ${BUILD_PLAT}
1826cfe83910SLouis Mayencourt
18272329e22bSHarrison Mutaitl: ${BUILD_PLAT}/tl.bin
18282329e22bSHarrison Mutai${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
1829c25405d6SChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
1830d2867397SChris Kay	$(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
18312329e22bSHarrison Mutai
18326de32378SMadhukar Pappireddydoc:
18337c4e1eeaSChris Kay	$(s)echo "  BUILD DOCUMENTATION"
18347c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
18356de32378SMadhukar Pappireddy
183690aa901fSSumit Gargenctool: ${ENCTOOL}
183790aa901fSSumit Garg
1838a9812206SPali Rohár${ENCTOOL}: FORCE
18397c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
18407c4e1eeaSChris Kay	$(s)echo
18417c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
18427c4e1eeaSChris Kay	$(s)echo
184390aa901fSSumit Garg
184435fab8c9SJoakim Bechcscope:
18457c4e1eeaSChris Kay	$(s)echo "  CSCOPE"
18467c4e1eeaSChris Kay	$(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
18477c4e1eeaSChris Kay	$(q)cscope -b -q -k
184835fab8c9SJoakim Bech
184972ee3314SRyan Harkinhelp:
18507c4e1eeaSChris Kay	$(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
18517c4e1eeaSChris Kay	$(s)echo ""
18527c4e1eeaSChris Kay	$(s)echo "PLAT is used to specify which platform you wish to build."
18537c4e1eeaSChris Kay	$(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
18547c4e1eeaSChris Kay	$(s)echo ""
18557c4e1eeaSChris Kay	$(s)echo "platform = ${PLATFORM_LIST}"
18567c4e1eeaSChris Kay	$(s)echo ""
18577c4e1eeaSChris Kay	$(s)echo "Please refer to the User Guide for a list of all supported options."
18587c4e1eeaSChris Kay	$(s)echo "Note that the build system doesn't track dependencies for build "
18597c4e1eeaSChris Kay	$(s)echo "options. Therefore, if any of the build options are changed "
18607c4e1eeaSChris Kay	$(s)echo "from a previous build, a clean build must be performed."
18617c4e1eeaSChris Kay	$(s)echo ""
18627c4e1eeaSChris Kay	$(s)echo "Supported Targets:"
18637c4e1eeaSChris Kay	$(s)echo "  all            Build all individual bootloader binaries"
18647c4e1eeaSChris Kay	$(s)echo "  bl1            Build the BL1 binary"
18657c4e1eeaSChris Kay	$(s)echo "  bl2            Build the BL2 binary"
18667c4e1eeaSChris Kay	$(s)echo "  bl2u           Build the BL2U binary"
18677c4e1eeaSChris Kay	$(s)echo "  bl31           Build the BL31 binary"
18687c4e1eeaSChris Kay	$(s)echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
18697c4e1eeaSChris Kay	$(s)echo "                 this builds secure payload specified by AARCH32_SP"
18707c4e1eeaSChris Kay	$(s)echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
18717c4e1eeaSChris Kay	$(s)echo "  fip            Build the Firmware Image Package (FIP)"
18727c4e1eeaSChris Kay	$(s)echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
18737c4e1eeaSChris Kay	$(s)echo "  checkcodebase  Check the coding style of the entire source tree"
18747c4e1eeaSChris Kay	$(s)echo "  checkpatch     Check the coding style on changes in the current"
18757c4e1eeaSChris Kay	$(s)echo "                 branch against BASE_COMMIT (default origin/master)"
18767c4e1eeaSChris Kay	$(s)echo "  clean          Clean the build for the selected platform"
18777c4e1eeaSChris Kay	$(s)echo "  cscope         Generate cscope index"
18787c4e1eeaSChris Kay	$(s)echo "  distclean      Remove all build artifacts for all platforms"
18797c4e1eeaSChris Kay	$(s)echo "  certtool       Build the Certificate generation tool"
18807c4e1eeaSChris Kay	$(s)echo "  enctool        Build the Firmware encryption tool"
18817c4e1eeaSChris Kay	$(s)echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
18827c4e1eeaSChris Kay	$(s)echo "  sp             Build the Secure Partition Packages"
18837c4e1eeaSChris Kay	$(s)echo "  sptool         Build the Secure Partition Package creation tool"
18847c4e1eeaSChris Kay	$(s)echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
18857c4e1eeaSChris Kay	$(s)echo "  memmap         Print the memory map of the built binaries"
18867c4e1eeaSChris Kay	$(s)echo "  doc            Build html based documentation using Sphinx tool"
18877c4e1eeaSChris Kay	$(s)echo ""
18887c4e1eeaSChris Kay	$(s)echo "Note: most build targets require PLAT to be set to a specific platform."
18897c4e1eeaSChris Kay	$(s)echo ""
18907c4e1eeaSChris Kay	$(s)echo "example: build all targets for the FVP platform:"
18917c4e1eeaSChris Kay	$(s)echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1892a9812206SPali Rohár
1893a9812206SPali Rohár.PHONY: FORCE
1894a9812206SPali RohárFORCE:;
1895