xref: /rk3399_ARM-atf/Makefile (revision a57e18e4337b74ce3d133a18f07fa891f0fd5fa9)
14f6ad66aSAchin Gupta#
20a33adc0SGovindraj Raja# Copyright (c) 2013-2024, 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
26e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk
27f4dd18c2SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}build-rules.mk
287c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk
2973c99d4eSJuan Castillo
3073c99d4eSJuan Castillo################################################################################
312fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies
3273c99d4eSJuan Castillo################################################################################
33e35c4045SJeenu Viswambharan
342fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
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
102c5e1da83SJayanth Dodderi ChidanandCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
103c5e1da83SJayanth Dodderi Chidanand
104c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool
105c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH		?=	tools/encrypt_fw
106c5e1da83SJayanth Dodderi ChidanandENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
107c5e1da83SJayanth Dodderi Chidanand
108c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package
109c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH		?=	tools/fiptool
110c5e1da83SJayanth Dodderi ChidanandFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
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
118c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB
119c5e1da83SJayanth Dodderi ChidanandROMLIBPATH		?=	lib/romlib
120c5e1da83SJayanth Dodderi Chidanand
121c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python
122c5e1da83SJayanth Dodderi ChidanandPYTHON			?=	python3
123c5e1da83SJayanth Dodderi Chidanand
124c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool
125c5e1da83SJayanth Dodderi ChidanandDOCS_PATH		?=	docs
126c5e1da83SJayanth Dodderi Chidanand
127c5e1da83SJayanth Dodderi Chidanand################################################################################
128c5e1da83SJayanth Dodderi Chidanand# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
129c5e1da83SJayanth Dodderi Chidanand################################################################################
13026e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
13126e63c44SEtienne Carriere	target32-directive	= 	-target arm-none-eabi
132d4089fb8SGovindraj Raja# Will set march-directive from platform configuration
13326e63c44SEtienne Carriereelse
13426e63c44SEtienne Carriere	target32-directive	= 	-target armv8a-none-eabi
135c5e1da83SJayanth Dodderi Chidanandendif #(ARM_ARCH_MAJOR)
136c5e1da83SJayanth Dodderi Chidanand
137c5e1da83SJayanth Dodderi Chidanand################################################################################
138c5e1da83SJayanth Dodderi Chidanand# Get Architecture Feature Modifiers
139c5e1da83SJayanth Dodderi Chidanand################################################################################
140c5e1da83SJayanth Dodderi Chidanandarch-features		=	${ARM_ARCH_FEATURE}
141c5e1da83SJayanth Dodderi Chidanand
1428620bd0bSChris Kayifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
1438620bd0bSChris Kay	ifeq ($($(ARCH)-cc-id),arm-clang)
1447794d6c8SGovindraj Raja		TF_CFLAGS_aarch32	:=	-target arm-arm-none-eabi
1457794d6c8SGovindraj Raja		TF_CFLAGS_aarch64	:=	-target aarch64-arm-none-eabi
146c8a992fdSorigin	else
1477794d6c8SGovindraj Raja		TF_CFLAGS_aarch32	=	$(target32-directive)
1487794d6c8SGovindraj Raja		TF_CFLAGS_aarch64	:=	-target aarch64-elf
149641f16e7SAmbroise Vincent	endif
150c8a992fdSorigin
1518620bd0bSChris Kayelse ifeq ($($(ARCH)-cc-id),gnu-gcc)
152edbce9aaSzelalem-aweke	# Enable LTO only for aarch64
153edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
154fa402f38SChris Kay		LTO_CFLAGS	=	$(if $(filter-out 0,$(ENABLE_LTO)),-flto)
155edbce9aaSzelalem-aweke	endif
156c5e1da83SJayanth Dodderi Chidanandendif #(clang)
157d5461857Sdp-arm
15832b209bfSAhmad Fatoum# Process Debug flag
15932b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
16032b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
16132b209bfSAhmad Fatoum	BUILD_TYPE	:=	debug
1624466cf82SDaniel Boulby	TF_CFLAGS	+=	-g -gdwarf-4
1634466cf82SDaniel Boulby	ASFLAGS		+=	-g -Wa,-gdwarf-4
16432b209bfSAhmad Fatoum
16532b209bfSAhmad Fatoum	# Use LOG_LEVEL_INFO by default for debug builds
16632b209bfSAhmad Fatoum	LOG_LEVEL	:=	40
16732b209bfSAhmad Fatoumelse
16832b209bfSAhmad Fatoum	BUILD_TYPE	:=	release
16932b209bfSAhmad Fatoum	# Use LOG_LEVEL_NOTICE by default for release builds
17032b209bfSAhmad Fatoum	LOG_LEVEL	:=	20
171c5e1da83SJayanth Dodderi Chidanandendif #(Debug)
17232b209bfSAhmad Fatoum
173f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
174f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
175f1de4c8fSPeiyuan Song	BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
176f1de4c8fSPeiyuan Songendif
177dddf4283Slaurenw-armVERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
178f1de4c8fSPeiyuan Song
1798fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
1808fd9d4d5SAntonio Nino Diaz	TF_CFLAGS_aarch32	+=	-marm
1818fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
1828fd9d4d5SAntonio Nino Diaz	TF_CFLAGS_aarch32	+=	-mthumb
1838fd9d4d5SAntonio Nino Diazelse
1848fd9d4d5SAntonio Nino Diaz        $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
185c5e1da83SJayanth Dodderi Chidanandendif #(AARCH32_INSTRUCTION_SET)
1868fd9d4d5SAntonio Nino Diaz
187a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
188d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
1899d29c227SSoby Mathew
190c5e1da83SJayanth Dodderi Chidanand##############################################################################
191c5e1da83SJayanth Dodderi Chidanand# WARNINGS Configuration
192c5e1da83SJayanth Dodderi Chidanand###############################################################################
1939ab81b5eSJustin Chadwell# General warnings
1949ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
195b7f6525dSJustin Chadwell				-Wdisabled-optimization -Wvla -Wshadow	\
196d75a9ecdSBoyan Karatotev				-Wredundant-decls
197d75a9ecdSBoyan Karatotev# stricter warnings
198d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wextra -Wno-trigraphs
199d75a9ecdSBoyan Karatotev# too verbose for generic build
200d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-missing-field-initializers \
201d75a9ecdSBoyan Karatotev				-Wno-type-limits -Wno-sign-compare \
202d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
203d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-unused-parameter
2049ab81b5eSJustin Chadwell
2059ab81b5eSJustin Chadwell# Additional warnings
206d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of
207d75a9ecdSBoyan Karatotev# full -Wextra
208d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare
209d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits
210d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers
211e7c645b5SYann Gautier
212d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want
213d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
214d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build
215d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition
216d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes
217d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute
218d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present
219d75a9ecdSBoyan KaratotevWARNING2 += -Wundef
220d141e638SBoyan Karatotev# currently very involved and many platforms set this off
221d141e638SBoyan KaratotevWARNING2 += -Wunused-const-variable=2
222e7c645b5SYann Gautier
223d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored
224e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
225d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return
226d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs
227d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align
228e7c645b5SYann GautierWARNING3 += -Wcast-qual
229e7c645b5SYann GautierWARNING3 += -Wconversion
230e7c645b5SYann GautierWARNING3 += -Wpacked
231e7c645b5SYann GautierWARNING3 += -Wpointer-arith
232e7c645b5SYann GautierWARNING3 += -Wswitch-default
233e7c645b5SYann Gautier
234d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues
235d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings
236d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed
237d75a9ecdSBoyan Karatotevifdef W
238d75a9ecdSBoyan Karatotev	ifneq (${W},0)
239d75a9ecdSBoyan Karatotev		E	 ?= 0
240d75a9ecdSBoyan Karatotev	endif
241d75a9ecdSBoyan Karatotevendif
242d75a9ecdSBoyan Karatotev
243e7c645b5SYann Gautierifeq (${W},1)
2449ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1)
245e7c645b5SYann Gautierelse ifeq (${W},2)
2469ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1) $(WARNING2)
247e7c645b5SYann Gautierelse ifeq (${W},3)
2489ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
249c5e1da83SJayanth Dodderi Chidanandendif #(W)
250e7c645b5SYann Gautier
2519ab81b5eSJustin Chadwell# Compiler specific warnings
2528620bd0bSChris Kayifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
25393c690ebSJustin Chadwell# not using clang
254d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
255d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
256d7b4cd41SJustin Chadwell				-Wlogical-op
257dea23e24SGovindraj Raja
258dea23e24SGovindraj Raja# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
259316f5c97SBoyan KaratotevTF_CFLAGS_MIN_PAGE_SIZE	:=	$(call cc_option, --param=min-pagesize=0)
260316f5c97SBoyan KaratotevTF_CFLAGS		+=	$(TF_CFLAGS_MIN_PAGE_SIZE)
261dea23e24SGovindraj Raja
262538516f5SBipin Raviifeq ($(HARDEN_SLS), 1)
263316f5c97SBoyan Karatotev        TF_CFLAGS_MHARDEN_SLS	:=      $(call cc_option, -mharden-sls=all)
264316f5c97SBoyan Karatotev        TF_CFLAGS_aarch64	+=      $(TF_CFLAGS_MHARDEN_SLS)
265538516f5SBipin Raviendif
266538516f5SBipin Ravi
26793c690ebSJustin Chadwellelse
26893c690ebSJustin Chadwell# using clang
269d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
270d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
271c5e1da83SJayanth Dodderi Chidanandendif #(Clang Warning)
27200296576SAmbroise Vincent
2736336b07aSYann Gautierifneq (${E},0)
2746336b07aSYann Gautier	ERRORS := -Werror
275c5e1da83SJayanth Dodderi Chidanandendif #(E)
2766336b07aSYann Gautier
277c5e1da83SJayanth Dodderi Chidanand################################################################################
278c5e1da83SJayanth Dodderi Chidanand# Compiler and Linker Directives
279c5e1da83SJayanth Dodderi Chidanand################################################################################
280ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
2819ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
282d4089fb8SGovindraj RajaASFLAGS			+=	$(CPPFLAGS)                 			\
283d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
28459de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
285ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
286ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
287ebd6efaeSSamuel Holland				-Os -std=gnu99
28873c99d4eSJuan Castillo
2891f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
2901f461979SJustin Chadwell	TF_CFLAGS	+=	-fsanitize=undefined -fno-sanitize-recover
291c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},on)
292c5e1da83SJayanth Dodderi Chidanand
2931f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
2941f461979SJustin Chadwell	TF_CFLAGS	+=	-fsanitize=undefined -fno-sanitize-recover	\
2951f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
296c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},trap)
2971f461979SJustin Chadwell
298291e7182SChris KayGCC_V_OUTPUT		:=	$(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
299f7ec31dbSdavid cunado
3001f49db5fSMarco FelschTF_LDFLAGS		+=	-z noexecstack
3011f49db5fSMarco Felsch
302641f16e7SAmbroise Vincent# LD = armlink
3038620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link)
304c2ad38ceSVarun Wadekar	TF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
305c2ad38ceSVarun Wadekar	TF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
306edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
307641f16e7SAmbroise Vincent
308641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
3098620bd0bSChris Kayelse ifeq ($($(ARCH)-ld-id),gnu-gcc)
310edbce9aaSzelalem-aweke	# Pass ld options with Wl or Xlinker switches
31186e489c1SChris Kay	TF_LDFLAGS		+=	$(call ld_option,-Xlinker --no-warn-rwx-segments)
312edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
313edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	-Wl,--gc-sections
314ac98b82aSChris Kay
315ac98b82aSChris Kay	TF_LDFLAGS		+=	-Wl,-z,common-page-size=4096 #Configure page size constants
316ac98b82aSChris Kay	TF_LDFLAGS		+=	-Wl,-z,max-page-size=4096
317304ad94bSAndrey Skvortsov	TF_LDFLAGS		+=	-Wl,--build-id=none
318ac98b82aSChris Kay
319edbce9aaSzelalem-aweke	ifeq ($(ENABLE_LTO),1)
320edbce9aaSzelalem-aweke		ifeq (${ARCH},aarch64)
321edbce9aaSzelalem-aweke			TF_LDFLAGS	+=	-flto -fuse-linker-plugin
32231f80efeSAndrey Skvortsov			TF_LDFLAGS      +=	-flto-partition=one
323edbce9aaSzelalem-aweke		endif
324c5e1da83SJayanth Dodderi Chidanand	endif #(ENABLE_LTO)
325c5e1da83SJayanth Dodderi Chidanand
326edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
327edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
328cfe6767fSYann Gautier	ifeq (${ARCH},aarch64)
329edbce9aaSzelalem-aweke		ifneq (${ERRATA_A53_843419},1)
330edbce9aaSzelalem-aweke			TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
331edbce9aaSzelalem-aweke		endif
332cfe6767fSYann Gautier	endif
333edbce9aaSzelalem-aweke	TF_LDFLAGS		+= 	-nostdlib
334edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
335641f16e7SAmbroise Vincent
336641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
337c2ad38ceSVarun Wadekarelse
3381f49db5fSMarco Felsch# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
3391f49db5fSMarco Felsch# are not loaded by a elf loader.
3401f49db5fSMarco Felsch	TF_LDFLAGS		+=	$(call ld_option, --no-warn-rwx-segments)
341ebac6922SYabin Cui	TF_LDFLAGS		+=	-O1
342c2b8806fSDouglas Raillard	TF_LDFLAGS		+=	--gc-sections
343ac98b82aSChris Kay
344ac98b82aSChris Kay	TF_LDFLAGS		+=	-z common-page-size=4096 # Configure page size constants
345ac98b82aSChris Kay	TF_LDFLAGS		+=	-z max-page-size=4096
346304ad94bSAndrey Skvortsov	TF_LDFLAGS		+=	--build-id=none
347ac98b82aSChris Kay
348641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
349ebac6922SYabin Cui# therefore don't add those in that case.
350ebac6922SYabin Cui# ld.lld reports section type mismatch warnings,
351ebac6922SYabin Cui# therefore don't add --fatal-warnings to it.
3528620bd0bSChris Kay	ifneq ($($(ARCH)-ld-id),llvm-lld)
353ebac6922SYabin Cui		TF_LDFLAGS	+=	$(TF_LDFLAGS_$(ARCH)) --fatal-warnings
354edbce9aaSzelalem-aweke	endif
355c5e1da83SJayanth Dodderi Chidanand
356c5e1da83SJayanth Dodderi Chidanandendif #(LD = armlink)
35773c99d4eSJuan Castillo
35873c99d4eSJuan Castillo################################################################################
359f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features.
360f5211420SGovindraj Raja################################################################################
361f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
3627d5fc98fSAlexeiFedorov	ARM_ARCH_MAJOR := 9
3637d5fc98fSAlexeiFedorov	ARM_ARCH_MINOR := 2
364f5211420SGovindraj Rajaendif
365f5211420SGovindraj Raja
366f5211420SGovindraj Raja################################################################################
36773c99d4eSJuan Castillo# Common sources and include directories
36873c99d4eSJuan Castillo################################################################################
369d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
37073c99d4eSJuan Castillo
371758ccb80SChris Kay# Allow overriding the timestamp, for example for reproducible builds, or to
372758ccb80SChris Kay# synchronize timestamps across multiple projects.
373758ccb80SChris Kay# This must be set to a C string (including quotes where applicable).
374758ccb80SChris KayBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
375758ccb80SChris Kay
376758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
377758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
378758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
379758ccb80SChris Kay
38073c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
3817f56e9a3SSoby Mathew				common/tf_log.c				\
3829d29c227SSoby Mathew				common/${ARCH}/debug.S			\
38391b48c9fSJulius Werner				drivers/console/multi_console.c		\
3849d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
3859d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
386c73686a1SBoyan Karatotev				lib/extensions/pmuv3/${ARCH}/pmuv3.c	\
387566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
3887f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
38975311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
3909d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
39161f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
392d7a6b0f8SRyan Harkin
3938620bd0bSChris Kayifeq ($($(ARCH)-cc-id),arm-clang)
3948422a840SAntonio Nino Diaz	BL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
3958422a840SAntonio Nino Diazendif
3968422a840SAntonio Nino Diaz
3971f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
3981f461979SJustin Chadwell	BL_COMMON_SOURCES	+=	plat/common/ubsan.c
3991f461979SJustin Chadwellendif
4001f461979SJustin Chadwell
40101d237cbSYann GautierINCLUDES		+=	-Iinclude				\
402f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
40309d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
40409d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
40509d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
40609d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
40709d40e0eSAntonio Nino Diaz
408e03dcc8fSNishant SharmaDTC_FLAGS		+=	-I dts -O dtb
409e03dcc8fSNishant SharmaDTC_CPPFLAGS		+=	-P -nostdinc $(INCLUDES) -Ifdts -undef \
410e03dcc8fSNishant Sharma				-x assembler-with-cpp $(DEFINES)
411e03dcc8fSNishant Sharma
4129c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4139c6d1c50SAntonio Nino Diaz
41473c99d4eSJuan Castillo################################################################################
4153547270fSGovindraj Raja# Generic definitions
4163547270fSGovindraj Raja################################################################################
4173547270fSGovindraj Raja
4183547270fSGovindraj Rajaifeq (${BUILD_BASE},)
4193547270fSGovindraj Raja     BUILD_BASE		:=	./build
4203547270fSGovindraj Rajaendif
4213547270fSGovindraj RajaBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
4223547270fSGovindraj Raja
4233547270fSGovindraj RajaSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
4243547270fSGovindraj Raja
4253547270fSGovindraj Raja# Platforms providing their own TBB makefile may override this value
4263547270fSGovindraj RajaINCLUDE_TBBR_MK		:=	1
4273547270fSGovindraj Raja
4283547270fSGovindraj Raja################################################################################
4293547270fSGovindraj Raja# Include SPD Makefile if one has been specified
4303547270fSGovindraj Raja################################################################################
4313547270fSGovindraj Raja
4323547270fSGovindraj Rajaifneq (${SPD},none)
4333547270fSGovindraj Raja	ifeq (${ARCH},aarch32)
4343547270fSGovindraj Raja                $(error "Error: SPD is incompatible with AArch32.")
4353547270fSGovindraj Raja	endif
4363547270fSGovindraj Raja
4373547270fSGovindraj Raja	ifdef EL3_PAYLOAD_BASE
4383547270fSGovindraj Raja                $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
4393547270fSGovindraj Raja                $(warning "The SPD and its BL32 companion will be present but \
4403547270fSGovindraj Raja                ignored.")
4413547270fSGovindraj Raja	endif
4423547270fSGovindraj Raja
4433547270fSGovindraj Raja	ifeq (${SPD},spmd)
4443547270fSGovindraj Raja	# SPMD is located in std_svc directory
4453547270fSGovindraj Raja		SPD_DIR := std_svc
4463547270fSGovindraj Raja
4473547270fSGovindraj Raja		ifeq ($(SPMD_SPM_AT_SEL2),1)
4483547270fSGovindraj Raja			CTX_INCLUDE_EL2_REGS := 1
4493547270fSGovindraj Raja			ifeq ($(SPMC_AT_EL3),1)
4503547270fSGovindraj Raja                                $(error SPM cannot be enabled in both S-EL2 and EL3.)
4513547270fSGovindraj Raja			endif
45259bdcc58SMadhukar Pappireddy			ifeq ($(CTX_INCLUDE_SVE_REGS),1)
45359bdcc58SMadhukar Pappireddy                                $(error SVE context management not needed with Hafnium SPMC.)
45459bdcc58SMadhukar Pappireddy			endif
4553547270fSGovindraj Raja		endif
4563547270fSGovindraj Raja
4573547270fSGovindraj Raja		ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
4583547270fSGovindraj Raja			DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
4593547270fSGovindraj Raja		endif
4603547270fSGovindraj Raja
4610686a01bSArunachalam Ganapathy		ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
4620686a01bSArunachalam Ganapathy			DTC_CPPFLAGS	+=	-DTRUSTY_SP_FW_CONFIG
4630686a01bSArunachalam Ganapathy		endif
4640686a01bSArunachalam Ganapathy
4653547270fSGovindraj Raja		ifeq ($(TS_SP_FW_CONFIG),1)
4663547270fSGovindraj Raja			DTC_CPPFLAGS	+=	-DTS_SP_FW_CONFIG
4673547270fSGovindraj Raja		endif
4683547270fSGovindraj Raja
4693547270fSGovindraj Raja		ifneq ($(ARM_BL2_SP_LIST_DTS),)
4703547270fSGovindraj Raja		DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
4713547270fSGovindraj Raja		endif
4723547270fSGovindraj Raja
4733547270fSGovindraj Raja		ifneq ($(SP_LAYOUT_FILE),)
4743547270fSGovindraj Raja		BL2_ENABLE_SP_LOAD := 1
4753547270fSGovindraj Raja		endif
476c189adbdSGovindraj Raja
477c189adbdSGovindraj Raja		ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
478c189adbdSGovindraj Raja			ifneq ($(SPMC_AT_EL3),1)
479c189adbdSGovindraj Raja			$(error SEL0 SP cannot be enabled without SPMC at EL3)
480c189adbdSGovindraj Raja			endif
481c189adbdSGovindraj Raja		endif
4823547270fSGovindraj Raja	else
4833547270fSGovindraj Raja		# All other SPDs in spd directory
4843547270fSGovindraj Raja		SPD_DIR := spd
4853547270fSGovindraj Raja	endif #(SPD)
4863547270fSGovindraj Raja
4873547270fSGovindraj Raja	# We expect to locate an spd.mk under the specified SPD directory
4883547270fSGovindraj Raja	SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
4893547270fSGovindraj Raja
4903547270fSGovindraj Raja	ifeq (${SPD_MAKE},)
4913547270fSGovindraj Raja                $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
4923547270fSGovindraj Raja	endif
4933547270fSGovindraj Raja        $(info Including ${SPD_MAKE})
4943547270fSGovindraj Raja        include ${SPD_MAKE}
4953547270fSGovindraj Raja
4963547270fSGovindraj Raja	# If there's BL32 companion for the chosen SPD, we expect that the SPD's
4973547270fSGovindraj Raja	# Makefile would set NEED_BL32 to "yes". In this case, the build system
4983547270fSGovindraj Raja	# supports two mutually exclusive options:
4993547270fSGovindraj Raja	# * BL32 is built from source: then BL32_SOURCES must contain the list
5003547270fSGovindraj Raja	#   of source files to build BL32
5013547270fSGovindraj Raja	# * BL32 is a prebuilt binary: then BL32 must point to the image file
5023547270fSGovindraj Raja	#   that will be included in the FIP
5033547270fSGovindraj Raja	# If both BL32_SOURCES and BL32 are defined, the binary takes precedence
5043547270fSGovindraj Raja	# over the sources.
5053547270fSGovindraj Rajaendif #(SPD=none)
5063547270fSGovindraj Raja
5073547270fSGovindraj Rajaifeq (${ENABLE_SPMD_LP}, 1)
5083547270fSGovindraj Rajaifneq (${SPD},spmd)
5093547270fSGovindraj Raja        $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
5103547270fSGovindraj Rajaendif
5113547270fSGovindraj Rajaifeq ($(SPMC_AT_EL3),1)
5123547270fSGovindraj Raja        $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
5133547270fSGovindraj Rajaendif
5143547270fSGovindraj Rajaendif
5153547270fSGovindraj Raja
5163547270fSGovindraj Raja################################################################################
517f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set
518f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags
519f5211420SGovindraj Raja################################################################################
520f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0)
521f5211420SGovindraj Raja	# Default value turns off all types of branch protection
522f5211420SGovindraj Raja	BP_OPTION := none
523f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64)
524f5211420SGovindraj Raja        $(error BRANCH_PROTECTION requires AArch64)
525f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1)
526f5211420SGovindraj Raja	# Enables all types of branch protection features
527f5211420SGovindraj Raja	BP_OPTION := standard
528f5211420SGovindraj Raja	ENABLE_BTI := 1
529f5211420SGovindraj Raja	ENABLE_PAUTH := 1
530f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2)
531f5211420SGovindraj Raja	# Return address signing to its standard level
532f5211420SGovindraj Raja	BP_OPTION := pac-ret
533f5211420SGovindraj Raja	ENABLE_PAUTH := 1
534f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3)
535f5211420SGovindraj Raja	# Extend the signing to include leaf functions
536f5211420SGovindraj Raja	BP_OPTION := pac-ret+leaf
537f5211420SGovindraj Raja	ENABLE_PAUTH := 1
538f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4)
539f5211420SGovindraj Raja	# Turn on branch target identification mechanism
540f5211420SGovindraj Raja	BP_OPTION := bti
541f5211420SGovindraj Raja	ENABLE_BTI := 1
542f5211420SGovindraj Rajaelse
543f5211420SGovindraj Raja        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
544f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION)
545f5211420SGovindraj Raja
546f5211420SGovindraj Rajaifeq ($(ENABLE_PAUTH),1)
547f5211420SGovindraj Raja	CTX_INCLUDE_PAUTH_REGS := 1
548f5211420SGovindraj Rajaendif
549f5211420SGovindraj Rajaifneq (${BP_OPTION},none)
550f5211420SGovindraj Raja	TF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
551f5211420SGovindraj Rajaendif #(BP_OPTION)
552f5211420SGovindraj Raja
553f5211420SGovindraj Raja# Pointer Authentication sources
554f5211420SGovindraj Rajaifeq (${ENABLE_PAUTH}, 1)
555f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
556f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms
557f5211420SGovindraj Raja	BL_COMMON_SOURCES	+=	lib/extensions/pauth/pauth_helpers.S
558f5211420SGovindraj Rajaendif
559f5211420SGovindraj Raja
5603547270fSGovindraj Raja################################################################################
5613547270fSGovindraj Raja# Include the platform specific Makefile after the SPD Makefile (the platform
5623547270fSGovindraj Raja# makefile may use all previous definitions in this file)
5633547270fSGovindraj Raja################################################################################
5643547270fSGovindraj Rajainclude ${PLAT_MAKEFILE_FULL}
5653547270fSGovindraj Raja
5663547270fSGovindraj Raja################################################################################
5673547270fSGovindraj Raja# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
5683547270fSGovindraj Raja# platform.
5693547270fSGovindraj Raja################################################################################
5703547270fSGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
5713547270fSGovindraj Raja
572f5211420SGovindraj Raja####################################################
573f5211420SGovindraj Raja# Enable required options for Memory Stack Tagging.
574f5211420SGovindraj Raja####################################################
575f5211420SGovindraj Raja
576f5211420SGovindraj Raja# Currently, these options are enabled only for clang and armclang compiler.
577f5211420SGovindraj Rajaifeq (${SUPPORT_STACK_MEMTAG},yes)
578f5211420SGovindraj Raja    ifdef mem_tag_arch_support
579f5211420SGovindraj Raja        # Check for armclang and clang compilers
5808620bd0bSChris Kay        ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
581f5211420SGovindraj Raja        # Add "memtag" architecture feature modifier if not specified
582f5211420SGovindraj Raja            ifeq ( ,$(findstring memtag,$(arch-features)))
583f5211420SGovindraj Raja                arch-features	:=	$(arch-features)+memtag
584f5211420SGovindraj Raja            endif	# memtag
5858620bd0bSChris Kay            ifeq ($($(ARCH)-cc-id),arm-clang)
586f5211420SGovindraj Raja                TF_CFLAGS	+=	-mmemtag-stack
5878620bd0bSChris Kay            else ifeq ($($(ARCH)-cc-id),llvm-clang)
588f5211420SGovindraj Raja                TF_CFLAGS	+=	-fsanitize=memtag
589f5211420SGovindraj Raja            endif	# armclang
590f5211420SGovindraj Raja        endif
591f5211420SGovindraj Raja    else
592f5211420SGovindraj Raja        $(error "Error: stack memory tagging is not supported for  \
593f5211420SGovindraj Raja        architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
594f5211420SGovindraj Raja	endif #(mem_tag_arch_support)
595f5211420SGovindraj Rajaendif #(SUPPORT_STACK_MEMTAG)
596f5211420SGovindraj Raja
597f5211420SGovindraj Raja################################################################################
598f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME.
599f5211420SGovindraj Raja################################################################################
600f5211420SGovindraj Raja# FEAT_RME
601f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
602f5211420SGovindraj Raja	# RME doesn't support PIE
603f5211420SGovindraj Raja	ifneq (${ENABLE_PIE},0)
604f5211420SGovindraj Raja                $(error ENABLE_RME does not support PIE)
605f5211420SGovindraj Raja	endif
606f5211420SGovindraj Raja
607f5211420SGovindraj Raja	# RME requires AARCH64
608f5211420SGovindraj Raja	ifneq (${ARCH},aarch64)
609f5211420SGovindraj Raja                $(error ENABLE_RME requires AArch64)
610f5211420SGovindraj Raja	endif
611f5211420SGovindraj Raja
612f5211420SGovindraj Raja	# RME requires el2 context to be saved for now.
613f5211420SGovindraj Raja	CTX_INCLUDE_EL2_REGS := 1
614f5211420SGovindraj Raja	CTX_INCLUDE_AARCH32_REGS := 0
615f5211420SGovindraj Raja	CTX_INCLUDE_PAUTH_REGS := 1
616f5211420SGovindraj Raja
617f5211420SGovindraj Raja	# RME enables CSV2_2 extension by default.
618f5211420SGovindraj Raja	ENABLE_FEAT_CSV2_2 = 1
619f5211420SGovindraj Rajaendif #(FEAT_RME)
620f5211420SGovindraj Raja
621f5211420SGovindraj Raja################################################################################
6225b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled
6235b18de09SZelalem Aweke################################################################################
6245b18de09SZelalem Awekeifneq (${ENABLE_RME},0)
6255b18de09SZelalem Aweke	ifneq (${ARCH},aarch64)
6265b18de09SZelalem Aweke                $(error ENABLE_RME requires AArch64)
6275b18de09SZelalem Aweke	endif
6281d63ae4dSMarc Bonnici	ifeq ($(SPMC_AT_EL3),1)
6291d63ae4dSMarc Bonnici                $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
6301d63ae4dSMarc Bonnici	endif
631c5e1da83SJayanth Dodderi Chidanand
6324fba2e1fSBoyan Karatotev	ifneq (${SPD}, none)
6334fba2e1fSBoyan Karatotev		ifneq (${SPD}, spmd)
6344fba2e1fSBoyan Karatotev                        $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
6354fba2e1fSBoyan Karatotev		endif
6364fba2e1fSBoyan Karatotev	endif
6375b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk
6385b18de09SZelalem Aweke$(warning "RME is an experimental feature")
6395b18de09SZelalem Awekeendif
6405b18de09SZelalem Aweke
6413547270fSGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1)
6423547270fSGovindraj Raja	ifeq (${SPD},none)
6433547270fSGovindraj Raja		ifeq (${ENABLE_RME},0)
6443547270fSGovindraj Raja                        $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
6453547270fSGovindraj Raja                        or RME is enabled)
6463547270fSGovindraj Raja		endif
6473547270fSGovindraj Raja	endif
6483547270fSGovindraj Rajaendif
6490f21c547SJuan Castillo
6507794d6c8SGovindraj Raja################################################################################
65130655136SGovindraj Raja# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
65230655136SGovindraj Raja################################################################################
65330655136SGovindraj Rajaifneq (${ENABLE_FEAT_D128}, 0)
65430655136SGovindraj Raja        BL_COMMON_SOURCES       +=      lib/extensions/sysreg128/sysreg128.S
65530655136SGovindraj Rajaendif
65630655136SGovindraj Raja
65730655136SGovindraj Raja################################################################################
6587794d6c8SGovindraj Raja# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
6597794d6c8SGovindraj Raja# up with appropriate march values for compiler.
6607794d6c8SGovindraj Raja################################################################################
6617794d6c8SGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}march.mk
6627794d6c8SGovindraj Raja
6637794d6c8SGovindraj RajaTF_CFLAGS   +=	$(march-directive)
6647275ac2aSGovindraj RajaASFLAGS		+=	$(march-directive)
6657794d6c8SGovindraj Raja
66642d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios
66742d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios -
66842d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running
66942d4d3baSArvind Ram Prakash# BL2 in EL3
67042d4d3baSArvind Ram Prakash
67142d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1)
67242d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
67342d4d3baSArvind Ram Prakash	ifeq (${ENABLE_RME},1)
674c5e1da83SJayanth Dodderi Chidanand                $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
675c5e1da83SJayanth Dodderi Chidanand                supported at the moment.)
67642d4d3baSArvind Ram Prakash	endif
67742d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1)
67842d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
67942d4d3baSArvind Ram Prakashelse
68042d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	0
68142d4d3baSArvind Ram Prakashendif
68242d4d3baSArvind Ram Prakash
683f87e54f7SManish Pandey# This internal flag is set to 1 when Firmware First handling of External aborts
684f87e54f7SManish Pandey# is required by lowe ELs. Currently only NS requires this support.
685f87e54f7SManish Pandeyifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
686f87e54f7SManish Pandey	FFH_SUPPORT := 1
687f87e54f7SManish Pandeyelse
688f87e54f7SManish Pandey	FFH_SUPPORT := 0
689f87e54f7SManish Pandeyendif
690f87e54f7SManish Pandey
69126e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
69226e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
69326e63c44SEtienne Carriereendif
69426e63c44SEtienne Carriere
6953bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
6963bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
6973bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
6988620bd0bSChris Kayifeq ($($(ARCH)-ld-id),gnu-gcc)
6997b592418SSamuel Holland	TF_LDFLAGS	+=	-no-pie
7007b592418SSamuel Hollandendif
701c5e1da83SJayanth Dodderi Chidanandendif #(PIE_FOUND)
702320920c1SMasahiro Yamada
7038620bd0bSChris Kayifeq ($($(ARCH)-ld-id),gnu-gcc)
704320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
705320920c1SMasahiro Yamadaelse
706320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
707320920c1SMasahiro Yamadaendif
708320920c1SMasahiro Yamada
709320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
71042d4d3baSArvind Ram Prakash	ifeq ($(RESET_TO_BL2),1)
71169af7fcfSMasahiro Yamada		ifneq ($(BL2_IN_XIP_MEM),1)
712966660ecSChris Kay			BL2_CPPFLAGS	+=	-fpie
71369af7fcfSMasahiro Yamada			BL2_CFLAGS	+=	-fpie
71469af7fcfSMasahiro Yamada			BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
715c5e1da83SJayanth Dodderi Chidanand		endif #(BL2_IN_XIP_MEM)
716c5e1da83SJayanth Dodderi Chidanand	endif #(RESET_TO_BL2)
717966660ecSChris Kay	BL31_CPPFLAGS	+=	-fpie
718320920c1SMasahiro Yamada	BL31_CFLAGS 	+=	-fpie
719320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
720966660ecSChris Kay
721966660ecSChris Kay	BL32_CPPFLAGS	+=	-fpie
722d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
723d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
724c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PIE)
7253bd17c0fSSoby Mathew
726007433d8SBoyan KaratotevBL1_CPPFLAGS  += -DREPORT_ERRATA=${DEBUG}
727007433d8SBoyan KaratotevBL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
728007433d8SBoyan KaratotevBL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
729007433d8SBoyan Karatotev
7309cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
73142d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2),1)
7329cefb4b1SMasahiro Yamada	BL2_CPPFLAGS += -DIMAGE_AT_EL3
733d5e97a1dSMasahiro Yamadaelse
7349cefb4b1SMasahiro Yamada	BL2_CPPFLAGS += -DIMAGE_AT_EL1
735c5e1da83SJayanth Dodderi Chidanandendif #(RESET_TO_BL2)
736007433d8SBoyan Karatotev
737007433d8SBoyan Karatotevifeq (${ARCH},aarch64)
7389cefb4b1SMasahiro Yamada	BL2U_CPPFLAGS += -DIMAGE_AT_EL1
7399cefb4b1SMasahiro Yamada	BL31_CPPFLAGS += -DIMAGE_AT_EL3
7409cefb4b1SMasahiro Yamada	BL32_CPPFLAGS += -DIMAGE_AT_EL1
741007433d8SBoyan Karatotevelse
742007433d8SBoyan Karatotev	BL32_CPPFLAGS += -DIMAGE_AT_EL3
743d5e97a1dSMasahiro Yamadaendif
744d5e97a1dSMasahiro Yamada
74554035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
74654035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
74754035fc4SSandrine Bailleux# This can be overridden by the platform.
74873c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
7494f6ad66aSAchin Gupta
750a4409008Sdp-arm################################################################################
751a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
752a4409008Sdp-arm################################################################################
753c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32)
754c5e1da83SJayanth Dodderi Chidanand        NEED_BL32 := yes
755c5e1da83SJayanth Dodderi Chidanand
756a4409008Sdp-arm        ifneq (${AARCH32_SP},none)
757a4409008Sdp-arm        # We expect to locate an sp.mk under the specified AARCH32_SP directory
758a4409008Sdp-arm		AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
759a4409008Sdp-arm
760a4409008Sdp-arm                ifeq (${AARCH32_SP_MAKE},)
761a4409008Sdp-arm                        $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
762a4409008Sdp-arm                endif
763a4409008Sdp-arm                $(info Including ${AARCH32_SP_MAKE})
764a4409008Sdp-arm                include ${AARCH32_SP_MAKE}
765a4409008Sdp-arm        endif
766c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
7674f6ad66aSAchin Gupta
76873c99d4eSJuan Castillo################################################################################
76977f1f7a1SVarun Wadekar# Include libc if not overridden
77077f1f7a1SVarun Wadekar################################################################################
77177f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
77277f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
77377f1f7a1SVarun Wadekarendif
77477f1f7a1SVarun Wadekar
77577f1f7a1SVarun Wadekar################################################################################
776c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies
777cf2c8a33SAntonio Nino Diaz################################################################################
778cf2c8a33SAntonio Nino Diaz
779c5e1da83SJayanth Dodderi Chidanand# USE_DEBUGFS experimental feature recommended only in debug builds
780c5e1da83SJayanth Dodderi Chidanandifeq (${USE_DEBUGFS},1)
781c5e1da83SJayanth Dodderi Chidanand        ifeq (${DEBUG},1)
782c5e1da83SJayanth Dodderi Chidanand                $(warning DEBUGFS experimental feature is enabled.)
783c5e1da83SJayanth Dodderi Chidanand        else
784c5e1da83SJayanth Dodderi Chidanand                $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
785c5e1da83SJayanth Dodderi Chidanand        endif
786c5e1da83SJayanth Dodderi Chidanandendif #(USE_DEBUGFS)
787c5e1da83SJayanth Dodderi Chidanand
788c5e1da83SJayanth Dodderi Chidanand# USE_SPINLOCK_CAS requires AArch64 build
789c5e1da83SJayanth Dodderi Chidanandifeq (${USE_SPINLOCK_CAS},1)
790c5e1da83SJayanth Dodderi Chidanand        ifneq (${ARCH},aarch64)
791c5e1da83SJayanth Dodderi Chidanand               $(error USE_SPINLOCK_CAS requires AArch64)
792c5e1da83SJayanth Dodderi Chidanand        endif
793c5e1da83SJayanth Dodderi Chidanandendif #(USE_SPINLOCK_CAS)
794c5e1da83SJayanth Dodderi Chidanand
795c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the
796c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all
797c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0)
798c5e1da83SJayanth Dodderi Chidanand        FIP_DEPS += certificates
799c5e1da83SJayanth Dodderi Chidanand        FWU_FIP_DEPS += fwu_certificates
800c5e1da83SJayanth Dodderi Chidanandendif
801c5e1da83SJayanth Dodderi Chidanand
802c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none)
803c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -f ${FW_ENC_STATUS}
804c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -k ${ENC_KEY}
805c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -n ${ENC_NONCE}
806c5e1da83SJayanth Dodderi Chidanand	FIP_DEPS += enctool
807c5e1da83SJayanth Dodderi Chidanand	FWU_FIP_DEPS += enctool
808c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
809c5e1da83SJayanth Dodderi Chidanand
810cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
81168450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
81268450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
81368450a6dSAntonio Nino Diaz		incompatible build options. EL3_PAYLOAD_BASE has priority.")
814cf2c8a33SAntonio Nino Diaz	endif
81576580f3dSQixiang Xu	ifneq (${GENERATE_COT},0)
816c5e1da83SJayanth Dodderi Chidanand                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
817c5e1da83SJayanth Dodderi Chidanand                build options.")
81876580f3dSQixiang Xu	endif
81976580f3dSQixiang Xu	ifneq (${TRUSTED_BOARD_BOOT},0)
820c5e1da83SJayanth Dodderi Chidanand                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
821c5e1da83SJayanth Dodderi Chidanand                incompatible \ build options.")
82276580f3dSQixiang Xu	endif
823c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
824cf2c8a33SAntonio Nino Diaz
825cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
826cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
827cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
828cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
829cf2c8a33SAntonio Nino Diaz	endif
83068450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
83168450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
832c5e1da83SJayanth Dodderi Chidanand                PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
833cf2c8a33SAntonio Nino Diaz	endif
834c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
835cf2c8a33SAntonio Nino Diaz
836d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
837d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
838d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
839d4593e47SJeenu Viswambharan        $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
840d4593e47SJeenu Viswambharanendif
8411a0a3f06SYatharth Kochar
84242d4d3baSArvind Ram Prakash#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
84342d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
84442d4d3baSArvind Ram Prakash        $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
8457d173fc5SJiafei Panendif
8467d173fc5SJiafei Pan
8479202d519SManish Pandey# RAS_EXTENSION is deprecated, provide alternate build options
84814c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
849c5e1da83SJayanth Dodderi Chidanand        $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
850f87e54f7SManish Pandey        and HANDLE_EA_EL3_FIRST_NS instead")
8519202d519SManish Pandeyendif
852c5e1da83SJayanth Dodderi Chidanand
853c5e1da83SJayanth Dodderi Chidanand
8549202d519SManish Pandey# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
8551a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
8566503ff29SAndre Przywara	ifeq ($(ENABLE_FEAT_RAS),0)
8576503ff29SAndre Przywara                $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
8581a7c1cfeSJeenu Viswambharan	endif
859c5e1da83SJayanth Dodderi Chidanandendif #(FAULT_INJECTION_SUPPORT)
8601a7c1cfeSJeenu Viswambharan
861ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
862209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
863209a60ccSSoby Mathew	ifeq (${TRUSTED_BOARD_BOOT}, 0)
864c5e1da83SJayanth Dodderi Chidanand                $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
865c5e1da83SJayanth Dodderi Chidanand                to be set.")
866209a60ccSSoby Mathew	endif
867c5e1da83SJayanth Dodderi Chidanandendif #(DYN_DISABLE_AUTH)
868209a60ccSSoby Mathew
8692bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
8702bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
8712bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
8722bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
8732bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
8742bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
8752bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
8762bf4f27fSManish V Badarkhe# Support hash calculation only
8772bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 2
8782bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1)
8792bf4f27fSManish V Badarkhe# Support authentication verification only
880c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 1
881c9c56f6eSManish V Badarkheelse
882c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 0
883c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
884c9c56f6eSManish V Badarkhe
885cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
886cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
887700e7685SManish Pandey        $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
88884ef9cd8SManish V Badarkheendif
88984ef9cd8SManish V Badarkhe
890b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
8919fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
8929fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
893b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
8949fc59639SAlexei Fedorov	ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
8959fc59639SAlexei Fedorov                $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
89606715f85SAlexei Fedorov	endif
897c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PAUTH)
8989fc59639SAlexei Fedorov
89906715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
9009fc59639SAlexei Fedorov	ifneq (${ARCH},aarch64)
9019fc59639SAlexei Fedorov                $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
902b86048c4SAntonio Nino Diaz	endif
903c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_PAUTH_REGS)
9049fc59639SAlexei Fedorov
9056a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1)
9066a0da736SJayanth Dodderi Chidanand        $(info FEATURE_DETECTION is an experimental feature)
907c5e1da83SJayanth Dodderi Chidanandendif #(FEATURE_DETECTION)
9086a0da736SJayanth Dodderi Chidanand
90903d3c0d7SJayanth Dodderi Chidanandifneq ($(ENABLE_SME2_FOR_NS), 0)
91003d3c0d7SJayanth Dodderi Chidanand	ifeq (${ENABLE_SME_FOR_NS}, 0)
911c5e1da83SJayanth Dodderi Chidanand                $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
912c5e1da83SJayanth Dodderi Chidanand                to be set")
91303d3c0d7SJayanth Dodderi Chidanand                $(warning "Forced ENABLE_SME_FOR_NS=1")
91403d3c0d7SJayanth Dodderi Chidanand		override ENABLE_SME_FOR_NS	:= 1
91503d3c0d7SJayanth Dodderi Chidanand	endif
916c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME2_FOR_NS)
91745007acdSJayanth Dodderi Chidanand
91860e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
91960e8f3cfSPetre-Ionut Tudor	ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
920c5e1da83SJayanth Dodderi Chidanand                $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
921c5e1da83SJayanth Dodderi Chidanand                library v2")
92260e8f3cfSPetre-Ionut Tudor	endif
923c5e1da83SJayanth Dodderi Chidanandendif #(ARM_XLAT_TABLES_LIB_V1)
92460e8f3cfSPetre-Ionut Tudor
9257cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
9267cda17bbSSumit Garg	ifeq (${TRUSTED_BOARD_BOOT}, 0)
927c5e1da83SJayanth Dodderi Chidanand                $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
928c5e1da83SJayanth Dodderi Chidanand                to be set)
9297cda17bbSSumit Garg	endif
930c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
9317cda17bbSSumit Garg
932744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build
933dc78e62dSjohpow01ifeq (${ARCH},aarch32)
934744ad974Sjohpow01
935744ad974Sjohpow01	# SME/SVE only supported on AArch64
93645007acdSJayanth Dodderi Chidanand	ifneq (${ENABLE_SME_FOR_NS},0)
937dc78e62dSjohpow01                $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
938dc78e62dSjohpow01	endif
93903d3c0d7SJayanth Dodderi Chidanand
940dc78e62dSjohpow01	ifeq (${ENABLE_SVE_FOR_NS},1)
941dc78e62dSjohpow01		# Warning instead of error due to CI dependency on this
94224ab2c0aSYann Gautier                $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
943dc78e62dSjohpow01	endif
944744ad974Sjohpow01
945ff86e0b4SJuan Pablo Conde	# BRBE is not supported in AArch32
946744ad974Sjohpow01	ifeq (${ENABLE_BRBE_FOR_NS},1)
947744ad974Sjohpow01                $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
948744ad974Sjohpow01	endif
949744ad974Sjohpow01
950ff86e0b4SJuan Pablo Conde	# FEAT_RNG_TRAP is not supported in AArch32
951ff86e0b4SJuan Pablo Conde	ifeq (${ENABLE_FEAT_RNG_TRAP},1)
952ff86e0b4SJuan Pablo Conde                $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
953ff86e0b4SJuan Pablo Conde	endif
954*a57e18e4SArvind Ram Prakash
955*a57e18e4SArvind Ram Prakash	ifneq (${ENABLE_FEAT_FPMR},0)
956*a57e18e4SArvind Ram Prakash                $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
957*a57e18e4SArvind Ram Prakash	endif
958c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
959dc78e62dSjohpow01
960*a57e18e4SArvind Ram Prakashifneq (${ENABLE_FEAT_FPMR},0)
961*a57e18e4SArvind Ram Prakash	ifeq (${ENABLE_FEAT_FGT},0)
962*a57e18e4SArvind Ram Prakash                $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
963*a57e18e4SArvind Ram Prakash	endif
964*a57e18e4SArvind Ram Prakash	ifeq (${ENABLE_FEAT_HCX},0)
965*a57e18e4SArvind Ram Prakash                $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
966*a57e18e4SArvind Ram Prakash	endif
967*a57e18e4SArvind Ram Prakashendif #(ENABLE_FEAT_FPMR)
968*a57e18e4SArvind Ram Prakash
9690d122947SBoyan Karatotevifneq (${ENABLE_SME_FOR_NS},0)
9700d122947SBoyan Karatotev	ifeq (${ENABLE_SVE_FOR_NS},0)
9710d122947SBoyan Karatotev                $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
9720d122947SBoyan Karatotev	endif
973c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_NS)
9740d122947SBoyan Karatotev
975dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well
976dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1)
977dc78e62dSjohpow01	ifeq (${ENABLE_SME_FOR_NS},0)
978dc78e62dSjohpow01                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
979dc78e62dSjohpow01	endif
9800d122947SBoyan Karatotev	ifeq (${ENABLE_SVE_FOR_SWD},0)
9810d122947SBoyan Karatotev                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
9820d122947SBoyan Karatotev	endif
983c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_SWD)
984c5e1da83SJayanth Dodderi Chidanand
9853524d074SMadhukar Pappireddy# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
9863524d074SMadhukar Pappireddy# mechanism.
987dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1)
988dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},0)
989dc78e62dSjohpow01        $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
990dc78e62dSjohpow01    endif
9913524d074SMadhukar Pappireddyendif
992dc78e62dSjohpow01
9933524d074SMadhukar Pappireddy# Enabling SVE for both the worlds typically requires the context
9943524d074SMadhukar Pappireddy# management of SVE registers. The only exception being SPMC at S-EL2.
9953524d074SMadhukar Pappireddyifeq (${ENABLE_SVE_FOR_SWD}, 1)
9963524d074SMadhukar Pappireddy    ifneq (${ENABLE_SVE_FOR_NS}, 0)
9973524d074SMadhukar Pappireddy        ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
9983524d074SMadhukar Pappireddy            $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
9993524d074SMadhukar Pappireddy        endif
10003524d074SMadhukar Pappireddy    endif
10013524d074SMadhukar Pappireddyendif
10023524d074SMadhukar Pappireddy
10033524d074SMadhukar Pappireddy# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
10043524d074SMadhukar Pappireddy# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
10053524d074SMadhukar Pappireddy# and SVE registers.
10063524d074SMadhukar Pappireddyifeq (${CTX_INCLUDE_FPREGS}, 1)
10073524d074SMadhukar Pappireddy    ifneq (${ENABLE_SVE_FOR_NS},0)
10083524d074SMadhukar Pappireddy        ifeq (${CTX_INCLUDE_SVE_REGS},0)
10093524d074SMadhukar Pappireddy	    # Warning instead of error due to CI dependency on this
10103524d074SMadhukar Pappireddy            $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
10113524d074SMadhukar Pappireddy            $(warning "Forced ENABLE_SVE_FOR_NS=0")
10123524d074SMadhukar Pappireddy	    override ENABLE_SVE_FOR_NS	:= 0
10133524d074SMadhukar Pappireddy        endif
10143524d074SMadhukar Pappireddy    endif
10153524d074SMadhukar Pappireddyendif #(CTX_INCLUDE_FPREGS)
10163524d074SMadhukar Pappireddy
10173524d074SMadhukar Pappireddy# SVE context management is only required if secure world has access to SVE/FP
10183524d074SMadhukar Pappireddy# functionality.
10193524d074SMadhukar Pappireddyifeq (${CTX_INCLUDE_SVE_REGS},1)
10203524d074SMadhukar Pappireddy    ifeq (${ENABLE_SVE_FOR_SWD},0)
10213524d074SMadhukar Pappireddy        $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
10223524d074SMadhukar Pappireddy    endif
10233524d074SMadhukar Pappireddyendif
10243524d074SMadhukar Pappireddy
10253524d074SMadhukar Pappireddy# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
10263524d074SMadhukar Pappireddy# management including FPU registers.
1027dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1)
102845007acdSJayanth Dodderi Chidanand    ifneq (${ENABLE_SME_FOR_NS},0)
1029dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1030dc78e62dSjohpow01    endif
1031c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_FPREGS)
1032dc78e62dSjohpow01
103300e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1)
103400e28874SManish V Badarkhe        $(info DRTM_SUPPORT is an experimental feature)
103500e28874SManish V Badarkheendif
103600e28874SManish V Badarkhe
10378953568aSLevi Yunifeq (${HOB_LIST},1)
10388953568aSLevi Yun        $(warning HOB_LIST is an experimental feature)
10398953568aSLevi Yunendif
10408953568aSLevi Yun
10413ba2c151SRaymond Maoifeq (${TRANSFER_LIST},1)
10423ba2c151SRaymond Mao        $(info TRANSFER_LIST is an experimental feature)
10433ba2c151SRaymond Maoendif
10443ba2c151SRaymond Mao
1045274a69e7SChris Kayifeq (${ENABLE_RME},1)
1046274a69e7SChris Kay	ifneq (${SEPARATE_CODE_AND_RODATA},1)
1047274a69e7SChris Kay                $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1048274a69e7SChris Kay	endif
1049274a69e7SChris Kayendif
1050274a69e7SChris Kay
10515782b890SManish V Badarkheifeq ($(PSA_CRYPTO),1)
10525782b890SManish V Badarkhe        $(info PSA_CRYPTO is an experimental feature)
10535782b890SManish V Badarkheendif
10545782b890SManish V Badarkhe
105582222db8SManish V Badarkheifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
105682222db8SManish V Badarkhe        $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
105782222db8SManish V Badarkheendif
105882222db8SManish V Badarkhe
1059cf2c8a33SAntonio Nino Diaz################################################################################
106073c99d4eSJuan Castillo# Process platform overrideable behaviour
106173c99d4eSJuan Castillo################################################################################
10624f6ad66aSAchin Gupta
10635f24ce96SManish Pandeyifdef BL1_SOURCES
10645f24ce96SManish Pandey	NEED_BL1 := yes
1065c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES)
10665f24ce96SManish Pandey
10675f24ce96SManish Pandeyifdef BL2_SOURCES
10685f24ce96SManish Pandey	NEED_BL2 := yes
10695f24ce96SManish Pandey
1070bd97f83aSJohn Tsichritzis	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1071bd97f83aSJohn Tsichritzis	# Certificate generation tools. This flag can be overridden by the platform.
1072cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
1073cf2c8a33SAntonio Nino Diaz		# If booting an EL3 payload there is no need for a BL33 image
1074cf2c8a33SAntonio Nino Diaz		# in the FIP file.
10754c117f6cSSandrine Bailleux		NEED_BL33		:=	no
1076cf2c8a33SAntonio Nino Diaz	else
107768450a6dSAntonio Nino Diaz		ifdef PRELOADED_BL33_BASE
1078cf2c8a33SAntonio Nino Diaz			# If booting a BL33 preloaded image there is no need of
1079cf2c8a33SAntonio Nino Diaz			# another one in the FIP file.
1080cf2c8a33SAntonio Nino Diaz			NEED_BL33		:=	no
1081cf2c8a33SAntonio Nino Diaz		else
1082cf2c8a33SAntonio Nino Diaz			NEED_BL33		?=	yes
1083cf2c8a33SAntonio Nino Diaz		endif
10844c117f6cSSandrine Bailleux	endif
1085c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES)
10866f971622SJuan Castillo
10875f24ce96SManish Pandeyifdef BL2U_SOURCES
10885f24ce96SManish Pandey	NEED_BL2U := yes
1089c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES)
10905f24ce96SManish Pandey
10914d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
10924d045d0eSMasahiro Yamadaifdef SCP_BL2
10934d045d0eSMasahiro Yamada	NEED_SCP_BL2		:=	yes
1094c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2)
10954d045d0eSMasahiro Yamada
10965744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
10975744e874SSoby Mathewifneq (${ARCH},aarch32)
10985744e874SSoby Mathew	ifdef BL31_SOURCES
1099c5e1da83SJayanth Dodderi Chidanand	# When booting an EL3 payload, there is no need to compile the BL31
1100c5e1da83SJayanth Dodderi Chidanand	# image nor put it in the FIP.
11015744e874SSoby Mathew		ifndef EL3_PAYLOAD_BASE
11025744e874SSoby Mathew			NEED_BL31 := yes
11035744e874SSoby Mathew		endif
11045744e874SSoby Mathew	endif
1105c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64)
11065744e874SSoby Mathew
110773c99d4eSJuan Castillo# Process TBB related flags
11086f971622SJuan Castilloifneq (${GENERATE_COT},0)
110973c99d4eSJuan Castillo	# Common cert_create options
11106f971622SJuan Castillo	ifneq (${CREATE_KEYS},0)
11116f971622SJuan Castillo                $(eval CRT_ARGS += -n)
11120191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
1113fd34e7baSJuan Castillo		ifneq (${SAVE_KEYS},0)
1114fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
11150191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
1116fd34e7baSJuan Castillo		endif
11176f971622SJuan Castillo	endif
111873c99d4eSJuan Castillo	# Include TBBR makefile (unless the platform indicates otherwise)
111973c99d4eSJuan Castillo	ifeq (${INCLUDE_TBBR_MK},1)
112073c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
112173c99d4eSJuan Castillo	endif
1122c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
11236f971622SJuan Castillo
11241c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
11251c75d5dfSMasahiro Yamada	FIP_ARGS += --align ${FIP_ALIGN}
1126c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN)
11271c75d5dfSMasahiro Yamada
11285f24ce96SManish Pandeyifdef FDT_SOURCES
11295f24ce96SManish Pandey	NEED_FDT := yes
1130c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES)
11315f24ce96SManish Pandey
113273c99d4eSJuan Castillo################################################################################
113346e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
113446e5e035SMichalis Pappas################################################################################
113546e5e035SMichalis Pappas
113646e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
113746e5e035SMichalis Pappas
113846e5e035SMichalis Pappas################################################################################
11398a86052dSSoby Mathew# Include BL specific makefiles
11408a86052dSSoby Mathew################################################################################
11415f24ce96SManish Pandey
11425f24ce96SManish Pandeyifeq (${NEED_BL1},yes)
11438a86052dSSoby Mathewinclude bl1/bl1.mk
11448a86052dSSoby Mathewendif
11458a86052dSSoby Mathew
11465f24ce96SManish Pandeyifeq (${NEED_BL2},yes)
11478a86052dSSoby Mathewinclude bl2/bl2.mk
11488a86052dSSoby Mathewendif
11498a86052dSSoby Mathew
11505f24ce96SManish Pandeyifeq (${NEED_BL2U},yes)
11518a86052dSSoby Mathewinclude bl2u/bl2u.mk
11528a86052dSSoby Mathewendif
11538a86052dSSoby Mathew
11545744e874SSoby Mathewifeq (${NEED_BL31},yes)
11558a86052dSSoby Mathewinclude bl31/bl31.mk
11568a86052dSSoby Mathewendif
115703b397a8SNishanth Menon
115873c99d4eSJuan Castillo################################################################################
115973c99d4eSJuan Castillo# Build options checks
116073c99d4eSJuan Castillo################################################################################
116173c99d4eSJuan Castillo
1162c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags
1163327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
1164327131c4SLeonardo Sandoval    $(sort \
1165327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
116646789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
1167327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
1168327131c4SLeonardo Sandoval	CREATE_KEYS \
1169327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
1170327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
117142422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
1172327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
11739acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
1174327131c4SLeonardo Sandoval	DEBUG \
1175327131c4SLeonardo Sandoval	DYN_DISABLE_AUTH \
1176327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
11771fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
1178742ca230SChris Kay	ENABLE_AMU_FCONF \
1179873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
1180327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
1181327131c4SLeonardo Sandoval	ENABLE_PIE \
1182327131c4SLeonardo Sandoval	ENABLE_PMF \
1183327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
1184327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
1185dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
11860c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
1187970a4a8dSManish Pandey	ENABLE_FEAT_RAS	\
1188f87e54f7SManish Pandey	FFH_SUPPORT	\
1189327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
1190327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
1191327131c4SLeonardo Sandoval	GENERATE_COT \
1192327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
119346cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
1194538516f5SBipin Ravi	HARDEN_SLS \
1195327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
1196327131c4SLeonardo Sandoval	MEASURED_BOOT \
1197e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
11986a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
119900e28874SManish V Badarkhe	DRTM_SUPPORT \
1200327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
1201327131c4SLeonardo Sandoval	OVERRIDE_LIBC \
1202327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
1203327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
1204327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
120564b4710bSWing Li	PSCI_OS_INIT_MODE \
1206327131c4SLeonardo Sandoval	RESET_TO_BL31 \
1207327131c4SLeonardo Sandoval	SAVE_KEYS \
1208327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
120996a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
1210327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
121186acbbe2SYe Li	SEPARATE_RWDATA_REGION \
1212308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
1213327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
1214327131c4SLeonardo Sandoval	SPM_MM \
12151d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
1216801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
1217327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
1218890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
12193ba2c151SRaymond Mao	TRANSFER_LIST \
1220327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
1221327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
1222327131c4SLeonardo Sandoval	USE_DEBUGFS \
1223327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
1224327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
1225327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
1226327131c4SLeonardo Sandoval	USE_ROMLIB \
1227327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
1228327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
122942d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
1230327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
1231327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
1232327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
1233327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
1234327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
1235327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
123600e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
1237327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
1238327131c4SLeonardo Sandoval	USE_SP804_TIMER \
1239396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
124011d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
124168120783SChris Kay	ENABLE_MPMM \
124268120783SChris Kay	ENABLE_MPMM_FCONF \
12436a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
12440b22e591SJayanth Dodderi Chidanand	TRNG_SUPPORT \
1245ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
1246ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
124704c7303bSOkash Khawaja	CONDITIONAL_CMO \
12485782b890SManish V Badarkhe	PSA_CRYPTO	\
124985bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
1250183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
1251bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
1252ae770fedSYann Gautier	EARLY_CONSOLE \
1253f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
12548953568aSLevi Yun	HOB_LIST \
1255327131c4SLeonardo Sandoval)))
125673c99d4eSJuan Castillo
1257c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags
1258327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
1259327131c4SLeonardo Sandoval    $(sort \
1260327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
1261327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
1262327131c4SLeonardo Sandoval	BRANCH_PROTECTION \
12636a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_PAUTH_REGS \
12646a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_NEVE_REGS \
12652bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT \
126683a4dae1SBoyan Karatotev	DISABLE_MTPMU \
12671298f2f1SJayanth Dodderi Chidanand	ENABLE_BRBE_FOR_NS \
126847c681b7SJayanth Dodderi Chidanand	ENABLE_TRBE_FOR_NS \
12696a0da736SJayanth Dodderi Chidanand	ENABLE_BTI \
12706a0da736SJayanth Dodderi Chidanand	ENABLE_PAUTH \
1271d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
12726a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
12736a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
127430019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
127583271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
12766a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_DIT \
12776a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
12786a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
127933e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
1280*a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
12816a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_HCX \
128219d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
12838e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
12846a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
12856a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_RNG \
1286ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
12876a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
1288d3331603SMark Brown	ENABLE_FEAT_TCR2 \
12896d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
12900e4daed2SGovindraj Raja	ENABLE_FEAT_SB \
1291062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
1292062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
1293062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
1294062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
12954ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
129630655136SGovindraj Raja	ENABLE_FEAT_D128 \
1297688ab57bSMark Brown	ENABLE_FEAT_GCS \
12986a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
1299edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
13006a0da736SJayanth Dodderi Chidanand	ENABLE_RME \
13016437a09aSAndre Przywara	ENABLE_SPE_FOR_NS \
1302603a0c6fSAndre Przywara	ENABLE_SYS_REG_TRACE_FOR_NS \
130345007acdSJayanth Dodderi Chidanand	ENABLE_SME_FOR_NS \
130403d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
13052b0bc4e0SJayanth Dodderi Chidanand	ENABLE_SVE_FOR_NS \
13066a0da736SJayanth Dodderi Chidanand	ENABLE_TRF_FOR_NS \
1307327131c4SLeonardo Sandoval	FW_ENC_STATUS \
13085357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
13095357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
1310781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
1311781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
1312bebcf27fSMark Brown	SVE_VECTOR_LEN \
13130ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
1314327131c4SLeonardo Sandoval)))
1315c877b414SJeenu Viswambharan
1316aacff749SJustin Chadwellifdef KEY_SIZE
1317aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
1318aacff749SJustin Chadwellendif
1319aacff749SJustin Chadwell
13201f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
13211f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
13221f461979SJustin Chadwellendif
13231f461979SJustin Chadwell
132473c99d4eSJuan Castillo################################################################################
132573c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
132673c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
132773c99d4eSJuan Castillo# platform to overwrite the default options
132873c99d4eSJuan Castillo################################################################################
132973c99d4eSJuan Castillo
1330327131c4SLeonardo Sandoval$(eval $(call add_defines,\
1331327131c4SLeonardo Sandoval    $(sort \
1332327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
1333327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
1334327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
133546789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
1336327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
1337327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
1338327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
133942422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
1340327131c4SLeonardo Sandoval	CTX_INCLUDE_PAUTH_REGS \
13419acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
1342327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
1343327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
1344062f8aafSArunachalam Ganapathy	CTX_INCLUDE_NEVE_REGS \
1345327131c4SLeonardo Sandoval	DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
13460063dd17SJavier Almansa Sobrino	DISABLE_MTPMU \
1347d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
13481fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
1349742ca230SChris Kay	ENABLE_AMU_FCONF \
1350873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
1351327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
1352327131c4SLeonardo Sandoval	ENABLE_BTI \
135383271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
1354edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
1355327131c4SLeonardo Sandoval	ENABLE_PAUTH \
1356327131c4SLeonardo Sandoval	ENABLE_PIE \
1357327131c4SLeonardo Sandoval	ENABLE_PMF \
1358327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
13595b18de09SZelalem Aweke	ENABLE_RME \
13606a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
1361327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
1362dc78e62dSjohpow01	ENABLE_SME_FOR_NS \
136303d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
1364dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
136590118bb5SAndre Przywara	ENABLE_SPE_FOR_NS \
1366327131c4SLeonardo Sandoval	ENABLE_SVE_FOR_NS \
13670c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
1368970a4a8dSManish Pandey	ENABLE_FEAT_RAS \
1369f87e54f7SManish Pandey	FFH_SUPPORT \
1370327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
1371327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
1372327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
1373327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
1374327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
137546cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
1376327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
1377327131c4SLeonardo Sandoval	LOG_LEVEL \
1378327131c4SLeonardo Sandoval	MEASURED_BOOT \
1379e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
138000e28874SManish V Badarkhe	DRTM_SUPPORT \
1381327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
1382327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
1383327131c4SLeonardo Sandoval	PLAT_${PLAT} \
1384327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
1385327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
138664b4710bSWing Li	PSCI_OS_INIT_MODE \
1387327131c4SLeonardo Sandoval	RESET_TO_BL31 \
1388d766084fSAlexeiFedorov	RME_GPT_BITLOCK_BLOCK \
1389ec0088bbSAlexeiFedorov	RME_GPT_MAX_BLOCK \
1390327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
139196a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
1392327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
139386acbbe2SYe Li	SEPARATE_RWDATA_REGION \
1394308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
1395327131c4SLeonardo Sandoval	RECLAIM_INIT_CODE \
1396327131c4SLeonardo Sandoval	SPD_${SPD} \
1397327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
1398327131c4SLeonardo Sandoval	SPM_MM \
13991d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
1400801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
1401327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
14023ba2c151SRaymond Mao	TRANSFER_LIST \
1403327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
1404c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT \
14057dfb9911SJimmy Brisson	TRNG_SUPPORT \
1406ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
1407ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
1408327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
1409327131c4SLeonardo Sandoval	USE_DEBUGFS \
1410327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
1411327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
1412327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
1413327131c4SLeonardo Sandoval	USE_ROMLIB \
1414327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
1415327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
141642d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
141742d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	\
1418327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
1419327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
1420327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
1421327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
142200e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
1423327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
1424327131c4SLeonardo Sandoval	USE_SP804_TIMER \
142512cd65e0STomas Pilar	ENABLE_FEAT_RNG \
1426ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
14274e04478aSChris Kay	ENABLE_FEAT_SB \
14287d33ffe4SDaniel Boulby	ENABLE_FEAT_DIT \
14295357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
14305357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
1431396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
143211d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
1433744ad974Sjohpow01	ENABLE_BRBE_FOR_NS \
1434813524eaSManish V Badarkhe	ENABLE_TRBE_FOR_NS \
1435d4582d30SManish V Badarkhe	ENABLE_SYS_REG_TRACE_FOR_NS \
14368fcd3d96SManish V Badarkhe	ENABLE_TRF_FOR_NS \
1437cb4ec47bSjohpow01	ENABLE_FEAT_HCX \
143868120783SChris Kay	ENABLE_MPMM \
143968120783SChris Kay	ENABLE_MPMM_FCONF \
1440f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
144133e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
1442*a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
1443f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
14446a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
14456a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
14466a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
14476a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
144830019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
144919d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
14506a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
1451d3331603SMark Brown	ENABLE_FEAT_TCR2 \
14526d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
1453062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
1454062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
1455062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
1456062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
14574ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
145830655136SGovindraj Raja	ENABLE_FEAT_D128 \
1459688ab57bSMark Brown	ENABLE_FEAT_GCS \
14608e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
14616a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
1462781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
1463781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
146404c7303bSOkash Khawaja	CONDITIONAL_CMO \
14650ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
1466a8cf6faeSJayanth Dodderi Chidanand	SVE_VECTOR_LEN \
1467890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
14685782b890SManish V Badarkhe	PSA_CRYPTO	\
146985bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
1470183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
1471bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
1472ae770fedSYann Gautier	EARLY_CONSOLE \
1473f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
14748953568aSLevi Yun	HOB_LIST \
1475327131c4SLeonardo Sandoval)))
14762fae4b1eSJeenu Viswambharan
1477bfef8b90SJuan Pablo Condeifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1478bfef8b90SJuan Pablo Condeifeq (${DEBUG}, 0)
1479bfef8b90SJuan Pablo Conde        $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1480bfef8b90SJuan Pablo Conde        override PLATFORM_REPORT_CTX_MEM_USE := 0
1481bfef8b90SJuan Pablo Condeendif
1482bfef8b90SJuan Pablo Condeendif
1483bfef8b90SJuan Pablo Conde
14841f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
14851f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
1486c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB)
14871f461979SJustin Chadwell
14884c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
14894c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
14904c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1491cf2c8a33SAntonio Nino Diazelse
149268450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and
149368450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority.
149468450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
149568450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
14964c117f6cSSandrine Bailleux	endif
1497c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
149873c99d4eSJuan Castillo
1499209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1500209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1501209a60ccSSoby Mathew        $(eval $(call add_define,DYN_DISABLE_AUTH))
1502209a60ccSSoby Mathewendif
1503209a60ccSSoby Mathew
15048620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link)
1505c2ad38ceSVarun Wadekar        $(eval $(call add_define,USE_ARM_LINK))
1506c2ad38ceSVarun Wadekarendif
1507c2ad38ceSVarun Wadekar
1508ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1509ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1510c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1511ce2b1ec6SManish Pandey	-include $(BUILD_PLAT)/sp_gen.mk
1512ce2b1ec6SManish Pandey	FIP_DEPS += sp
151307c44475SManish Pandey	CRT_DEPS += sp
1514ce2b1ec6SManish Pandey	NEED_SP_PKG := yes
1515ce2b1ec6SManish Pandeyelse
1516c33ff198SOlivier Deprez	ifeq (${SPMD_SPM_AT_SEL2},1)
1517c33ff198SOlivier Deprez                $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1518c33ff198SOlivier Deprez	endif
1519c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE)
1520c5e1da83SJayanth Dodderi Chidanandendif #(SPD)
1521ce2b1ec6SManish Pandey
152273c99d4eSJuan Castillo################################################################################
152373c99d4eSJuan Castillo# Build targets
152473c99d4eSJuan Castillo################################################################################
152573c99d4eSJuan Castillo
15262329e22bSHarrison 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
152773c99d4eSJuan Castillo
152873c99d4eSJuan Castilloall: msg_start
152973c99d4eSJuan Castillo
153073c99d4eSJuan Castillomsg_start:
15317c4e1eeaSChris Kay	$(s)echo "Building ${PLAT}"
153273c99d4eSJuan Castillo
15337a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1534d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
15358620bd0bSChris Kayifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
1536c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1537c2ad38ceSVarun Wadekarelse
1538bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
15397a24cba5SSoby Mathewendif
1540c5e1da83SJayanth Dodderi Chidanandendif #(!ERROR_DEPRECATED)
15417a24cba5SSoby Mathew
154261f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
15435fee0287SRoberto Vargas
154473c99d4eSJuan Castillo# Expand build macros for the different images
154573c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
1546b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES})
1547434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1))
1548c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1)
154973c99d4eSJuan Castillo
155073c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1551c5e1da83SJayanth Dodderi Chidanand
155242d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0)
1553c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1554c9b31ae8SRoberto Vargasendif
1555c9b31ae8SRoberto Vargas
1556eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES})
1557eb1acfb6SChris Kay
155833950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1559434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1560c5e1da83SJayanth Dodderi Chidanand
1561c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2)
156273c99d4eSJuan Castillo
15634d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
156433950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1565c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2)
15664d045d0eSMasahiro Yamada
156773c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
156873c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
156926d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
157026d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1571c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1572c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1573434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1574c6ba9b45SSumit Gargelse
157533950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1576434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw)))
1577c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1578c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31)
157973c99d4eSJuan Castillo
158070d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1581c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
158270d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
158373c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
158426d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
158526d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
15869cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
15879cd15239SMasahiro Yamada
1588c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1589434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1590c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1591c6ba9b45SSumit Gargelse
1592434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
159333950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1594c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1595c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32)
159673c99d4eSJuan Castillo
15975b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
15985b18de09SZelalem Aweke# needs to be built from RMM_SOURCES.
15995b18de09SZelalem Awekeifeq (${NEED_RMM},yes)
16005b18de09SZelalem Aweke# Sort RMM source files to remove duplicates
16015b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES})
16025b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
16035b18de09SZelalem Aweke
16045b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
16055b18de09SZelalem Aweke	 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1606c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM)
16075b18de09SZelalem Aweke
160873c99d4eSJuan Castillo# Add the BL33 image if required by the platform
160973c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
161033950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1611c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
1612db6071c9SJuan Castillo
16139003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
161433950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1615434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1616c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U)
16179003fa0bSYatharth Kochar
161803b397a8SNishanth Menon# Expand build macros for the different images
161903b397a8SNishanth Menonifeq (${NEED_FDT},yes)
162003b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
1621c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT)
162203b397a8SNishanth Menon
1623ce2b1ec6SManish Pandey# Add Secure Partition packages
1624ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1625fd74ca0dSChris Kay$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
16267c4e1eeaSChris Kay	$(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
1627822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
16287c4e1eeaSChris Kay	$(s)echo
16297c4e1eeaSChris Kay	$(s)echo "Built SP Images successfully"
16307c4e1eeaSChris Kay	$(s)echo
1631c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG)
1632ce2b1ec6SManish Pandey
163336eaaf37SIan Spraylocate-checkpatch:
163436eaaf37SIan Sprayifndef CHECKPATCH
163566079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
163636eaaf37SIan Sprayelse
163736eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
163866079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
163936eaaf37SIan Sprayendif
1640c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH)
164136eaaf37SIan Spray
16424f6ad66aSAchin Guptaclean:
16437c4e1eeaSChris Kay	$(s)echo "  CLEAN"
1644f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
164588a1cf1eSSami Mujawarifdef UNIX_MK
16467c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
164788a1cf1eSSami Mujawarelse
164888a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
164988a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
16507c4e1eeaSChris Kay	$(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1651c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK)
16527c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
16537c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
16547c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
16554f6ad66aSAchin Gupta
1656eaaeece2SJames Morrisseyrealclean distclean:
16577c4e1eeaSChris Kay	$(s)echo "  REALCLEAN"
1658f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1659f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
166088a1cf1eSSami Mujawarifdef UNIX_MK
16617c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
166288a1cf1eSSami Mujawarelse
166388a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
166488a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
16657c4e1eeaSChris Kay	$(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1666c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK)
16677c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
16687c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
16697c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
16704f6ad66aSAchin Gupta
167136eaaf37SIan Spraycheckcodebase:		locate-checkpatch
16727c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
16737c4e1eeaSChris Kay	$(q)if test -d .git ; then						\
16741ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
16751a41e8c1SDan Handley		while read GIT_FILE ;					\
16761a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
16771a41e8c1SDan Handley		done ;							\
167836eaaf37SIan Spray	else								\
16791a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
16801a41e8c1SDan Handley		 -not -iwholename "*build*"				\
16811a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
168261f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
16831a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
16841ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
16851a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
168636eaaf37SIan Spray	fi
168736eaaf37SIan Spray
168836eaaf37SIan Spraycheckpatch:		locate-checkpatch
16897c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
16907c4e1eeaSChris Kay	$(q)if test -n "${CHECKPATCH_OPTS}"; then				\
169102a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
169202a76d5fSYann Gautier	fi
16937c4e1eeaSChris Kay	$(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
169477a0a7f1SYann Gautier	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
169577a0a7f1SYann Gautier	do								\
169651d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
16971a721748SYann Gautier		( git log --format=email "$$commit~..$$commit"		\
16981a721748SYann Gautier			-- ${CHECK_PATHS} ;				\
169951d28937SAntonio Nino Diaz		  git diff --format=email "$$commit~..$$commit"		\
17001a721748SYann Gautier			-- ${CHECK_PATHS}; ) |				\
170102a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
170251d28937SAntonio Nino Diaz	done
170336eaaf37SIan Spray
170473c99d4eSJuan Castillocerttool: ${CRTTOOL}
170573c99d4eSJuan Castillo
1706a9812206SPali Rohár${CRTTOOL}: FORCE
17077c4e1eeaSChris 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
17087c4e1eeaSChris Kay	$(s)echo
17097c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17107c4e1eeaSChris Kay	$(s)echo
17116f971622SJuan Castillo
17126f971622SJuan Castilloifneq (${GENERATE_COT},0)
171373c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
17147c4e1eeaSChris Kay	$(q)${CRTTOOL} ${CRT_ARGS}
17157c4e1eeaSChris Kay	$(s)echo
17167c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17177c4e1eeaSChris Kay	$(s)echo "Certificates can be found in ${BUILD_PLAT}"
17187c4e1eeaSChris Kay	$(s)echo
1719c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
172027713fb4SSoby Mathew
172173c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
17224727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
17237c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FIP_ARGS} $@
17247c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
17257c4e1eeaSChris Kay	$(s)echo
17267c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17277c4e1eeaSChris Kay	$(s)echo
1728f58ad36fSHarry Liebel
17290191262dSYatharth Kocharifneq (${GENERATE_COT},0)
17300191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
17317c4e1eeaSChris Kay	$(q)${CRTTOOL} ${FWU_CRT_ARGS}
17327c4e1eeaSChris Kay	$(s)echo
17337c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17347c4e1eeaSChris Kay	$(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
17357c4e1eeaSChris Kay	$(s)echo
1736c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
17370191262dSYatharth Kochar
17380191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
17394727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
17407c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
17417c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
17427c4e1eeaSChris Kay	$(s)echo
17437c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17447c4e1eeaSChris Kay	$(s)echo
17450191262dSYatharth Kochar
174673c99d4eSJuan Castillofiptool: ${FIPTOOL}
174773c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
17480191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
174973c99d4eSJuan Castillo
1750a9812206SPali Rohár${FIPTOOL}: FORCE
175188a1cf1eSSami Mujawarifdef UNIX_MK
175240469bf9SManish V Badarkhe	$(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
175388a1cf1eSSami Mujawarelse
175488a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
175588a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
17567c4e1eeaSChris Kay	$(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1757c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK)
1758f58ad36fSHarry Liebel
17596e622818SChris Kay$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libmbedtls.a $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a
17607c4e1eeaSChris Kay	$(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
17615accce5bSRoberto Vargas
1762cfe83910SLouis Mayencourtmemmap: all
1763af5b49e9SHarrison Mutaiifdef UNIX_MK
17647c4e1eeaSChris Kay	$(q)PYTHONPATH=${CURDIR}/tools/memory \
1765af5b49e9SHarrison Mutai		${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1766af5b49e9SHarrison Mutaielse
17677c4e1eeaSChris Kay	$(q)set PYTHONPATH=${CURDIR}/tools/memory && \
1768af5b49e9SHarrison Mutai		${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1769af5b49e9SHarrison Mutaiendif
1770cfe83910SLouis Mayencourt
17712329e22bSHarrison Mutaitl: ${BUILD_PLAT}/tl.bin
17722329e22bSHarrison Mutai${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
1773d2867397SChris Kay	$(if $(host-poetry),$(q)poetry -q install)
1774d2867397SChris Kay	$(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
17752329e22bSHarrison Mutai
17766de32378SMadhukar Pappireddydoc:
17777c4e1eeaSChris Kay	$(s)echo "  BUILD DOCUMENTATION"
17787c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
17796de32378SMadhukar Pappireddy
178090aa901fSSumit Gargenctool: ${ENCTOOL}
178190aa901fSSumit Garg
1782a9812206SPali Rohár${ENCTOOL}: FORCE
17837c4e1eeaSChris Kay	$(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
17847c4e1eeaSChris Kay	$(s)echo
17857c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
17867c4e1eeaSChris Kay	$(s)echo
178790aa901fSSumit Garg
178835fab8c9SJoakim Bechcscope:
17897c4e1eeaSChris Kay	$(s)echo "  CSCOPE"
17907c4e1eeaSChris Kay	$(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
17917c4e1eeaSChris Kay	$(q)cscope -b -q -k
179235fab8c9SJoakim Bech
179372ee3314SRyan Harkinhelp:
17947c4e1eeaSChris Kay	$(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
17957c4e1eeaSChris Kay	$(s)echo ""
17967c4e1eeaSChris Kay	$(s)echo "PLAT is used to specify which platform you wish to build."
17977c4e1eeaSChris Kay	$(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
17987c4e1eeaSChris Kay	$(s)echo ""
17997c4e1eeaSChris Kay	$(s)echo "platform = ${PLATFORM_LIST}"
18007c4e1eeaSChris Kay	$(s)echo ""
18017c4e1eeaSChris Kay	$(s)echo "Please refer to the User Guide for a list of all supported options."
18027c4e1eeaSChris Kay	$(s)echo "Note that the build system doesn't track dependencies for build "
18037c4e1eeaSChris Kay	$(s)echo "options. Therefore, if any of the build options are changed "
18047c4e1eeaSChris Kay	$(s)echo "from a previous build, a clean build must be performed."
18057c4e1eeaSChris Kay	$(s)echo ""
18067c4e1eeaSChris Kay	$(s)echo "Supported Targets:"
18077c4e1eeaSChris Kay	$(s)echo "  all            Build all individual bootloader binaries"
18087c4e1eeaSChris Kay	$(s)echo "  bl1            Build the BL1 binary"
18097c4e1eeaSChris Kay	$(s)echo "  bl2            Build the BL2 binary"
18107c4e1eeaSChris Kay	$(s)echo "  bl2u           Build the BL2U binary"
18117c4e1eeaSChris Kay	$(s)echo "  bl31           Build the BL31 binary"
18127c4e1eeaSChris Kay	$(s)echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
18137c4e1eeaSChris Kay	$(s)echo "                 this builds secure payload specified by AARCH32_SP"
18147c4e1eeaSChris Kay	$(s)echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
18157c4e1eeaSChris Kay	$(s)echo "  fip            Build the Firmware Image Package (FIP)"
18167c4e1eeaSChris Kay	$(s)echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
18177c4e1eeaSChris Kay	$(s)echo "  checkcodebase  Check the coding style of the entire source tree"
18187c4e1eeaSChris Kay	$(s)echo "  checkpatch     Check the coding style on changes in the current"
18197c4e1eeaSChris Kay	$(s)echo "                 branch against BASE_COMMIT (default origin/master)"
18207c4e1eeaSChris Kay	$(s)echo "  clean          Clean the build for the selected platform"
18217c4e1eeaSChris Kay	$(s)echo "  cscope         Generate cscope index"
18227c4e1eeaSChris Kay	$(s)echo "  distclean      Remove all build artifacts for all platforms"
18237c4e1eeaSChris Kay	$(s)echo "  certtool       Build the Certificate generation tool"
18247c4e1eeaSChris Kay	$(s)echo "  enctool        Build the Firmware encryption tool"
18257c4e1eeaSChris Kay	$(s)echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
18267c4e1eeaSChris Kay	$(s)echo "  sp             Build the Secure Partition Packages"
18277c4e1eeaSChris Kay	$(s)echo "  sptool         Build the Secure Partition Package creation tool"
18287c4e1eeaSChris Kay	$(s)echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
18297c4e1eeaSChris Kay	$(s)echo "  memmap         Print the memory map of the built binaries"
18307c4e1eeaSChris Kay	$(s)echo "  doc            Build html based documentation using Sphinx tool"
18317c4e1eeaSChris Kay	$(s)echo ""
18327c4e1eeaSChris Kay	$(s)echo "Note: most build targets require PLAT to be set to a specific platform."
18337c4e1eeaSChris Kay	$(s)echo ""
18347c4e1eeaSChris Kay	$(s)echo "example: build all targets for the FVP platform:"
18357c4e1eeaSChris Kay	$(s)echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1836a9812206SPali Rohár
1837a9812206SPali Rohár.PHONY: FORCE
1838a9812206SPali RohárFORCE:;
1839