xref: /rk3399_ARM-atf/Makefile (revision 3547270f59a3e27eab316a99cdaab6a835c10e85)
14f6ad66aSAchin Gupta#
201cf14ddSMaksims Svecovs# Copyright (c) 2013-2023, 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
11b78ad00eSJuan Pablo CondeVERSION_MINOR			:= 9
12055ebecaSYann GautierVERSION_PATCH			:= 0
13055ebecaSYann GautierVERSION				:= ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
14aaa3e722SJuan Castillo
1588154678SJuan Castillo# Default goal is build all images
1688154678SJuan Castillo.DEFAULT_GOAL			:= all
1788154678SJuan Castillo
1872fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to
1972fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
2072fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual.
2172fc70edSDouglas RaillardMAKEOVERRIDES =
2272fc70edSDouglas Raillard
23231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/
24231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
25e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk
2673c99d4eSJuan Castillo
2773c99d4eSJuan Castillo################################################################################
282fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies
2973c99d4eSJuan Castillo################################################################################
30e35c4045SJeenu Viswambharan
312fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
32872be88aSdp-arm
33cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default
34cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS		:= ${DEBUG}
352fae4b1eSJeenu ViswambharanENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
362fae4b1eSJeenu ViswambharanPLAT				:= ${DEFAULT_PLAT}
3773c99d4eSJuan Castillo
3873c99d4eSJuan Castillo################################################################################
3973c99d4eSJuan Castillo# Checkpatch script options
4073c99d4eSJuan Castillo################################################################################
4173c99d4eSJuan Castillo
42f607739cSSandrine BailleuxCHECKCODE_ARGS		:=	--no-patch
43f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files
444501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	:=	$(sort $(filter-out                     \
454501843fSGilad Ben-Yossef					include/drivers/arm/cryptocell,	\
464501843fSGilad Ben-Yossef					$(wildcard include/drivers/arm/*)))
474501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	+=	include/drivers/arm/cryptocell/*.h
484501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
494501843fSGilad Ben-Yossef					include/drivers/arm,		\
504501843fSGilad Ben-Yossef					$(wildcard include/drivers/*)))
51f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
521a41e8c1SDan Handley					include/lib/libfdt		\
5361f72a34SRoberto Vargas					include/lib/libc,		\
54f0b489c1SDan Handley					$(wildcard include/lib/*)))
55f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
564501843fSGilad Ben-Yossef					include/lib			\
574501843fSGilad Ben-Yossef					include/drivers,		\
58f0b489c1SDan Handley					$(wildcard include/*)))
59f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
60d801fbb0Sdp-arm					lib/compiler-rt			\
6155cdcf75SAntonio Nino Diaz					lib/libfdt%			\
6261f72a34SRoberto Vargas					lib/libc,			\
63a194255dSDaniel Boulby					lib/zlib			\
64f0b489c1SDan Handley					$(wildcard lib/*)))
65f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
66f0b489c1SDan Handley					lib				\
67f0b489c1SDan Handley					include				\
68f0b489c1SDan Handley					docs				\
691ef35512SPaul Beesley					%.rst,				\
70f0b489c1SDan Handley					$(wildcard *)))
71f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
72f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
73f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
744501843fSGilad Ben-Yossef				${LIB_DIRS_TO_CHECK}			\
754501843fSGilad Ben-Yossef				${INC_DRV_DIRS_TO_CHECK}		\
764501843fSGilad Ben-Yossef				${INC_ARM_DIRS_TO_CHECK}
7736eaaf37SIan Spray
7873c99d4eSJuan Castillo################################################################################
7973c99d4eSJuan Castillo# Process build options
8073c99d4eSJuan Castillo################################################################################
8173c99d4eSJuan Castillo
8273c99d4eSJuan Castillo# Verbose flag
83e35c4045SJeenu Viswambharanifeq (${V},0)
84b169f6a9SEvan Lloyd	Q:=@
85ee1ba6d4SAndre Przywara	ECHO:=@echo
8636eaaf37SIan Spray	CHECKCODE_ARGS	+=	--no-summary --terse
874f6ad66aSAchin Guptaelse
88b169f6a9SEvan Lloyd	Q:=
89b5a0f4bdSAntonio Nino Diaz	ECHO:=$(ECHO_QUIET)
904f6ad66aSAchin Guptaendif
91ee1ba6d4SAndre Przywara
92ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
93ee1ba6d4SAndre Przywara	Q:=@
94b5a0f4bdSAntonio Nino Diaz	ECHO:=$(ECHO_QUIET)
95ee1ba6d4SAndre Przywaraendif
96ee1ba6d4SAndre Przywara
97ee1ba6d4SAndre Przywaraexport Q ECHO
982f2cef46SJeenu Viswambharan
9973c99d4eSJuan Castillo################################################################################
10073c99d4eSJuan Castillo# Toolchain
10173c99d4eSJuan Castillo################################################################################
10273c99d4eSJuan Castillo
10372610c41Sdp-armHOSTCC			:=	gcc
10472610c41Sdp-armexport HOSTCC
10572610c41Sdp-arm
10673c99d4eSJuan CastilloCC			:=	${CROSS_COMPILE}gcc
10773c99d4eSJuan CastilloCPP			:=	${CROSS_COMPILE}cpp
10873c99d4eSJuan CastilloAS			:=	${CROSS_COMPILE}gcc
10973c99d4eSJuan CastilloAR			:=	${CROSS_COMPILE}ar
1102adee763SRoberto VargasLINKER			:=	${CROSS_COMPILE}ld
11173c99d4eSJuan CastilloOC			:=	${CROSS_COMPILE}objcopy
11273c99d4eSJuan CastilloOD			:=	${CROSS_COMPILE}objdump
11373c99d4eSJuan CastilloNM			:=	${CROSS_COMPILE}nm
11473c99d4eSJuan CastilloPP			:=	${CROSS_COMPILE}gcc -E
11538c14d88SSoby MathewDTC			:=	dtc
11673c99d4eSJuan Castillo
117b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
118b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \
1192adee763SRoberto Vargas	$(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
1202adee763SRoberto VargasLINKER			:=	${LINKER}.bfd
121b25a577fSJulius Wernerendif
122b25a577fSJulius Werner
123c5e1da83SJayanth Dodderi Chidanand################################################################################
124c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc)
125c5e1da83SJayanth Dodderi Chidanand################################################################################
126c5e1da83SJayanth Dodderi Chidanand
127c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool
128c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH		?=	tools/cert_create
129c5e1da83SJayanth Dodderi ChidanandCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
130c5e1da83SJayanth Dodderi Chidanand
131c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool
132c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH		?=	tools/encrypt_fw
133c5e1da83SJayanth Dodderi ChidanandENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
134c5e1da83SJayanth Dodderi Chidanand
135c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package
136c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH		?=	tools/fiptool
137c5e1da83SJayanth Dodderi ChidanandFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
138c5e1da83SJayanth Dodderi Chidanand
139c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool
140c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH		?=	tools/sptool
141c5e1da83SJayanth Dodderi ChidanandSPTOOL			?=	${SPTOOLPATH}/sptool.py
142c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
14320629b31SKarl MeakinSP_DTS_LIST_FRAGMENT	?=	${BUILD_PLAT}/sp_list_fragment.dts
144c5e1da83SJayanth Dodderi Chidanand
145c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB
146c5e1da83SJayanth Dodderi ChidanandROMLIBPATH		?=	lib/romlib
147c5e1da83SJayanth Dodderi Chidanand
148c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python
149c5e1da83SJayanth Dodderi ChidanandPYTHON			?=	python3
150c5e1da83SJayanth Dodderi Chidanand
151c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool
152c5e1da83SJayanth Dodderi ChidanandDOCS_PATH		?=	docs
153c5e1da83SJayanth Dodderi Chidanand
154c5e1da83SJayanth Dodderi Chidanand################################################################################
155c5e1da83SJayanth Dodderi Chidanand# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
156c5e1da83SJayanth Dodderi Chidanand################################################################################
15726e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
15826e63c44SEtienne Carriere	target32-directive	= 	-target arm-none-eabi
159d4089fb8SGovindraj Raja# Will set march-directive from platform configuration
16026e63c44SEtienne Carriereelse
16126e63c44SEtienne Carriere	target32-directive	= 	-target armv8a-none-eabi
162c5e1da83SJayanth Dodderi Chidanandendif #(ARM_ARCH_MAJOR)
163c5e1da83SJayanth Dodderi Chidanand
164c5e1da83SJayanth Dodderi Chidanand################################################################################
165c5e1da83SJayanth Dodderi Chidanand# Get Architecture Feature Modifiers
166c5e1da83SJayanth Dodderi Chidanand################################################################################
167c5e1da83SJayanth Dodderi Chidanandarch-features		=	${ARM_ARCH_FEATURE}
168c5e1da83SJayanth Dodderi Chidanand
169f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers
170f1821790SAlexei Fedorovifneq ($(arch-features), none)
171f1821790SAlexei Fedorov	# Strip "none+" from arch-features
172f1821790SAlexei Fedorov	arch-features	:=	$(subst none+,,$(arch-features))
173d4089fb8SGovindraj Raja	march-directive	:=	$(march-directive)+$(arch-features)
174f1821790SAlexei Fedorov# Print features
175f1821790SAlexei Fedorov        $(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
176c5e1da83SJayanth Dodderi Chidanandendif #(arch-features)
1774e04478aSChris Kay
178c8a992fdSoriginifneq ($(findstring clang,$(notdir $(CC))),)
179fd18a8fcSVarun Wadekar	ifneq ($(findstring armclang,$(notdir $(CC))),)
1807794d6c8SGovindraj Raja		TF_CFLAGS_aarch32	:=	-target arm-arm-none-eabi
1817794d6c8SGovindraj Raja		TF_CFLAGS_aarch64	:=	-target aarch64-arm-none-eabi
182c8a992fdSorigin		LD			:=	$(LINKER)
183c8a992fdSorigin	else
1847794d6c8SGovindraj Raja		TF_CFLAGS_aarch32	=	$(target32-directive)
1857794d6c8SGovindraj Raja		TF_CFLAGS_aarch64	:=	-target aarch64-elf
186c8a992fdSorigin		LD			:=	$(shell $(CC) --print-prog-name ld.lld)
187c8a992fdSorigin
188c8a992fdSorigin		AR			:=	$(shell $(CC) --print-prog-name llvm-ar)
189c8a992fdSorigin		OD			:=	$(shell $(CC) --print-prog-name llvm-objdump)
190c8a992fdSorigin		OC			:=	$(shell $(CC) --print-prog-name llvm-objcopy)
191641f16e7SAmbroise Vincent	endif
192c8a992fdSorigin
193c8a992fdSorigin	CPP		:=	$(CC) -E $(TF_CFLAGS_$(ARCH))
194c8a992fdSorigin	PP		:=	$(CC) -E $(TF_CFLAGS_$(ARCH))
195c8a992fdSorigin	AS		:=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
196edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),)
197edbce9aaSzelalem-aweke	ifeq ($(ENABLE_LTO),1)
198edbce9aaSzelalem-aweke		# Enable LTO only for aarch64
199edbce9aaSzelalem-aweke		ifeq (${ARCH},aarch64)
200edbce9aaSzelalem-aweke			LTO_CFLAGS	=	-flto
201edbce9aaSzelalem-aweke			# Use gcc as a wrapper for the ld, recommended for LTO
202edbce9aaSzelalem-aweke			LINKER		:=	${CROSS_COMPILE}gcc
203edbce9aaSzelalem-aweke		endif
204edbce9aaSzelalem-aweke	endif
205edbce9aaSzelalem-aweke	LD			=	$(LINKER)
206d5461857Sdp-armelse
2072adee763SRoberto Vargas	LD			=	$(LINKER)
208c5e1da83SJayanth Dodderi Chidanandendif #(clang)
209d5461857Sdp-arm
21032b209bfSAhmad Fatoum# Process Debug flag
21132b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
21232b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
21332b209bfSAhmad Fatoum	BUILD_TYPE	:=	debug
2144466cf82SDaniel Boulby	TF_CFLAGS	+=	-g -gdwarf-4
2154466cf82SDaniel Boulby	ASFLAGS		+=	-g -Wa,-gdwarf-4
21632b209bfSAhmad Fatoum
21732b209bfSAhmad Fatoum	# Use LOG_LEVEL_INFO by default for debug builds
21832b209bfSAhmad Fatoum	LOG_LEVEL	:=	40
21932b209bfSAhmad Fatoumelse
22032b209bfSAhmad Fatoum	BUILD_TYPE	:=	release
22132b209bfSAhmad Fatoum	# Use LOG_LEVEL_NOTICE by default for release builds
22232b209bfSAhmad Fatoum	LOG_LEVEL	:=	20
223c5e1da83SJayanth Dodderi Chidanandendif #(Debug)
22432b209bfSAhmad Fatoum
225f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
226f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
227f1de4c8fSPeiyuan Song	BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
228f1de4c8fSPeiyuan Songendif
229dddf4283Slaurenw-armVERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
230f1de4c8fSPeiyuan Song
2318fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
2328fd9d4d5SAntonio Nino Diaz	TF_CFLAGS_aarch32	+=	-marm
2338fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
2348fd9d4d5SAntonio Nino Diaz	TF_CFLAGS_aarch32	+=	-mthumb
2358fd9d4d5SAntonio Nino Diazelse
2368fd9d4d5SAntonio Nino Diaz        $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
237c5e1da83SJayanth Dodderi Chidanandendif #(AARCH32_INSTRUCTION_SET)
2388fd9d4d5SAntonio Nino Diaz
239a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
240d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
2419d29c227SSoby Mathew
242d4089fb8SGovindraj RajaASFLAGS		+=	$(march-directive)
243b86048c4SAntonio Nino Diaz
244c5e1da83SJayanth Dodderi Chidanand##############################################################################
245c5e1da83SJayanth Dodderi Chidanand# WARNINGS Configuration
246c5e1da83SJayanth Dodderi Chidanand###############################################################################
2479ab81b5eSJustin Chadwell# General warnings
2489ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
249b7f6525dSJustin Chadwell				-Wdisabled-optimization -Wvla -Wshadow	\
250d75a9ecdSBoyan Karatotev				-Wredundant-decls
251d75a9ecdSBoyan Karatotev# stricter warnings
252d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wextra -Wno-trigraphs
253d75a9ecdSBoyan Karatotev# too verbose for generic build
254d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-missing-field-initializers \
255d75a9ecdSBoyan Karatotev				-Wno-type-limits -Wno-sign-compare \
256d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
257d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-unused-parameter
2589ab81b5eSJustin Chadwell
2599ab81b5eSJustin Chadwell# Additional warnings
260d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of
261d75a9ecdSBoyan Karatotev# full -Wextra
262d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare
263d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits
264d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers
265e7c645b5SYann Gautier
266d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want
267d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
268d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build
269d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition
270d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes
271d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute
272d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present
273d75a9ecdSBoyan KaratotevWARNING2 += -Wundef
274d141e638SBoyan Karatotev# currently very involved and many platforms set this off
275d141e638SBoyan KaratotevWARNING2 += -Wunused-const-variable=2
276e7c645b5SYann Gautier
277d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored
278e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
279d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return
280d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs
281d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align
282e7c645b5SYann GautierWARNING3 += -Wcast-qual
283e7c645b5SYann GautierWARNING3 += -Wconversion
284e7c645b5SYann GautierWARNING3 += -Wpacked
285e7c645b5SYann GautierWARNING3 += -Wpointer-arith
286e7c645b5SYann GautierWARNING3 += -Wswitch-default
287e7c645b5SYann Gautier
288d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues
289d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings
290d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed
291d75a9ecdSBoyan Karatotevifdef W
292d75a9ecdSBoyan Karatotev	ifneq (${W},0)
293d75a9ecdSBoyan Karatotev		E	 ?= 0
294d75a9ecdSBoyan Karatotev	endif
295d75a9ecdSBoyan Karatotevendif
296d75a9ecdSBoyan Karatotev
297e7c645b5SYann Gautierifeq (${W},1)
2989ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1)
299e7c645b5SYann Gautierelse ifeq (${W},2)
3009ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1) $(WARNING2)
301e7c645b5SYann Gautierelse ifeq (${W},3)
3029ab81b5eSJustin Chadwell	WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
303c5e1da83SJayanth Dodderi Chidanandendif #(W)
304e7c645b5SYann Gautier
3059ab81b5eSJustin Chadwell# Compiler specific warnings
30600296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),)
30793c690ebSJustin Chadwell# not using clang
308d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
309d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
310d7b4cd41SJustin Chadwell				-Wlogical-op
311dea23e24SGovindraj Raja
312dea23e24SGovindraj Raja# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
313dea23e24SGovindraj RajaTF_CFLAGS		+= 	$(call cc_option, --param=min-pagesize=0)
314dea23e24SGovindraj Raja
31593c690ebSJustin Chadwellelse
31693c690ebSJustin Chadwell# using clang
317d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
318d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
319c5e1da83SJayanth Dodderi Chidanandendif #(Clang Warning)
32000296576SAmbroise Vincent
3216336b07aSYann Gautierifneq (${E},0)
3226336b07aSYann Gautier	ERRORS := -Werror
323c5e1da83SJayanth Dodderi Chidanandendif #(E)
3246336b07aSYann Gautier
325c5e1da83SJayanth Dodderi Chidanand################################################################################
326c5e1da83SJayanth Dodderi Chidanand# Compiler and Linker Directives
327c5e1da83SJayanth Dodderi Chidanand################################################################################
328ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
3299ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
330d4089fb8SGovindraj RajaASFLAGS			+=	$(CPPFLAGS)                 			\
331d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
33259de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
333ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
334ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
335ebd6efaeSSamuel Holland				-Os -std=gnu99
33673c99d4eSJuan Castillo
3371f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
3381f461979SJustin Chadwell	TF_CFLAGS	+=	-fsanitize=undefined -fno-sanitize-recover
339c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},on)
340c5e1da83SJayanth Dodderi Chidanand
3411f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
3421f461979SJustin Chadwell	TF_CFLAGS	+=	-fsanitize=undefined -fno-sanitize-recover	\
3431f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
344c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},trap)
3451f461979SJustin Chadwell
346f7ec31dbSdavid cunadoGCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
347f7ec31dbSdavid cunado
3481f49db5fSMarco FelschTF_LDFLAGS		+=	-z noexecstack
3491f49db5fSMarco Felsch
350641f16e7SAmbroise Vincent# LD = armlink
351c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
352c2ad38ceSVarun Wadekar	TF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
353c2ad38ceSVarun Wadekar	TF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
354edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
355641f16e7SAmbroise Vincent
356641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
357edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),)
358edbce9aaSzelalem-aweke	# Pass ld options with Wl or Xlinker switches
359edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
360edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	-Wl,--gc-sections
361ac98b82aSChris Kay
362ac98b82aSChris Kay	TF_LDFLAGS		+=	-Wl,-z,common-page-size=4096 #Configure page size constants
363ac98b82aSChris Kay	TF_LDFLAGS		+=	-Wl,-z,max-page-size=4096
364ac98b82aSChris Kay
365edbce9aaSzelalem-aweke	ifeq ($(ENABLE_LTO),1)
366edbce9aaSzelalem-aweke		ifeq (${ARCH},aarch64)
367edbce9aaSzelalem-aweke			TF_LDFLAGS	+=	-flto -fuse-linker-plugin
368edbce9aaSzelalem-aweke		endif
369c5e1da83SJayanth Dodderi Chidanand	endif #(ENABLE_LTO)
370c5e1da83SJayanth Dodderi Chidanand
371edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
372edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
373cfe6767fSYann Gautier	ifeq (${ARCH},aarch64)
374edbce9aaSzelalem-aweke		ifneq (${ERRATA_A53_843419},1)
375edbce9aaSzelalem-aweke			TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
376edbce9aaSzelalem-aweke		endif
377cfe6767fSYann Gautier	endif
378edbce9aaSzelalem-aweke	TF_LDFLAGS		+= 	-nostdlib
379edbce9aaSzelalem-aweke	TF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
380641f16e7SAmbroise Vincent
381641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
382c2ad38ceSVarun Wadekarelse
3831f49db5fSMarco Felsch# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
3841f49db5fSMarco Felsch# are not loaded by a elf loader.
3851f49db5fSMarco Felsch	TF_LDFLAGS		+=	$(call ld_option, --no-warn-rwx-segments)
386ebac6922SYabin Cui	TF_LDFLAGS		+=	-O1
387c2b8806fSDouglas Raillard	TF_LDFLAGS		+=	--gc-sections
388ac98b82aSChris Kay
389ac98b82aSChris Kay	TF_LDFLAGS		+=	-z common-page-size=4096 # Configure page size constants
390ac98b82aSChris Kay	TF_LDFLAGS		+=	-z max-page-size=4096
391ac98b82aSChris Kay
392641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
393ebac6922SYabin Cui# therefore don't add those in that case.
394ebac6922SYabin Cui# ld.lld reports section type mismatch warnings,
395ebac6922SYabin Cui# therefore don't add --fatal-warnings to it.
396641f16e7SAmbroise Vincent	ifeq ($(findstring ld.lld,$(notdir $(LD))),)
397ebac6922SYabin Cui		TF_LDFLAGS	+=	$(TF_LDFLAGS_$(ARCH)) --fatal-warnings
398edbce9aaSzelalem-aweke	endif
399c5e1da83SJayanth Dodderi Chidanand
400c5e1da83SJayanth Dodderi Chidanandendif #(LD = armlink)
40173c99d4eSJuan Castillo
40203b397a8SNishanth MenonDTC_FLAGS		+=	-I dts -O dtb
403a6de824fSLouis MayencourtDTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
404a6de824fSLouis Mayencourt				-x assembler-with-cpp $(DEFINES)
40503b397a8SNishanth Menon
40673c99d4eSJuan Castillo################################################################################
407f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features.
408f5211420SGovindraj Raja################################################################################
409f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
410f5211420SGovindraj Raja	ARM_ARCH_MAJOR := 8
411f5211420SGovindraj Raja	ARM_ARCH_MINOR := 6
412f5211420SGovindraj Rajaendif
413f5211420SGovindraj Raja
414f5211420SGovindraj Raja################################################################################
41573c99d4eSJuan Castillo# Common sources and include directories
41673c99d4eSJuan Castillo################################################################################
4176a0da736SJayanth Dodderi Chidanandinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
418d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
41973c99d4eSJuan Castillo
42073c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
4217f56e9a3SSoby Mathew				common/tf_log.c				\
4229d29c227SSoby Mathew				common/${ARCH}/debug.S			\
42391b48c9fSJulius Werner				drivers/console/multi_console.c		\
4249d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
4259d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
426c73686a1SBoyan Karatotev				lib/extensions/pmuv3/${ARCH}/pmuv3.c	\
427566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
4287f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
42975311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
4309d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
43161f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
432d7a6b0f8SRyan Harkin
4338422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang)
4348422a840SAntonio Nino Diaz	BL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
4358422a840SAntonio Nino Diazendif
4368422a840SAntonio Nino Diaz
4371f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4381f461979SJustin Chadwell	BL_COMMON_SOURCES	+=	plat/common/ubsan.c
4391f461979SJustin Chadwellendif
4401f461979SJustin Chadwell
44101d237cbSYann GautierINCLUDES		+=	-Iinclude				\
442f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
44309d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
44409d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
44509d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
44609d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
44709d40e0eSAntonio Nino Diaz
4489c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4499c6d1c50SAntonio Nino Diaz
45073c99d4eSJuan Castillo################################################################################
451*3547270fSGovindraj Raja# Generic definitions
452*3547270fSGovindraj Raja################################################################################
453*3547270fSGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
454*3547270fSGovindraj Raja
455*3547270fSGovindraj Rajaifeq (${BUILD_BASE},)
456*3547270fSGovindraj Raja     BUILD_BASE		:=	./build
457*3547270fSGovindraj Rajaendif
458*3547270fSGovindraj RajaBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
459*3547270fSGovindraj Raja
460*3547270fSGovindraj RajaSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
461*3547270fSGovindraj Raja
462*3547270fSGovindraj Raja# Platforms providing their own TBB makefile may override this value
463*3547270fSGovindraj RajaINCLUDE_TBBR_MK		:=	1
464*3547270fSGovindraj Raja
465*3547270fSGovindraj Raja################################################################################
466*3547270fSGovindraj Raja# Include SPD Makefile if one has been specified
467*3547270fSGovindraj Raja################################################################################
468*3547270fSGovindraj Raja
469*3547270fSGovindraj Rajaifneq (${SPD},none)
470*3547270fSGovindraj Raja	ifeq (${ARCH},aarch32)
471*3547270fSGovindraj Raja                $(error "Error: SPD is incompatible with AArch32.")
472*3547270fSGovindraj Raja	endif
473*3547270fSGovindraj Raja
474*3547270fSGovindraj Raja	ifdef EL3_PAYLOAD_BASE
475*3547270fSGovindraj Raja                $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
476*3547270fSGovindraj Raja                $(warning "The SPD and its BL32 companion will be present but \
477*3547270fSGovindraj Raja                ignored.")
478*3547270fSGovindraj Raja	endif
479*3547270fSGovindraj Raja
480*3547270fSGovindraj Raja	ifeq (${SPD},spmd)
481*3547270fSGovindraj Raja	# SPMD is located in std_svc directory
482*3547270fSGovindraj Raja		SPD_DIR := std_svc
483*3547270fSGovindraj Raja
484*3547270fSGovindraj Raja		ifeq ($(SPMD_SPM_AT_SEL2),1)
485*3547270fSGovindraj Raja			CTX_INCLUDE_EL2_REGS := 1
486*3547270fSGovindraj Raja			ifeq ($(SPMC_AT_EL3),1)
487*3547270fSGovindraj Raja                                $(error SPM cannot be enabled in both S-EL2 and EL3.)
488*3547270fSGovindraj Raja			endif
489*3547270fSGovindraj Raja		endif
490*3547270fSGovindraj Raja
491*3547270fSGovindraj Raja		ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
492*3547270fSGovindraj Raja			DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
493*3547270fSGovindraj Raja		endif
494*3547270fSGovindraj Raja
495*3547270fSGovindraj Raja		ifeq ($(TS_SP_FW_CONFIG),1)
496*3547270fSGovindraj Raja		DTC_CPPFLAGS	+=	-DTS_SP_FW_CONFIG
497*3547270fSGovindraj Raja		endif
498*3547270fSGovindraj Raja
499*3547270fSGovindraj Raja		ifneq ($(ARM_BL2_SP_LIST_DTS),)
500*3547270fSGovindraj Raja		DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
501*3547270fSGovindraj Raja		endif
502*3547270fSGovindraj Raja
503*3547270fSGovindraj Raja		ifneq ($(SP_LAYOUT_FILE),)
504*3547270fSGovindraj Raja		BL2_ENABLE_SP_LOAD := 1
505*3547270fSGovindraj Raja		endif
506*3547270fSGovindraj Raja	else
507*3547270fSGovindraj Raja		# All other SPDs in spd directory
508*3547270fSGovindraj Raja		SPD_DIR := spd
509*3547270fSGovindraj Raja	endif #(SPD)
510*3547270fSGovindraj Raja
511*3547270fSGovindraj Raja	# We expect to locate an spd.mk under the specified SPD directory
512*3547270fSGovindraj Raja	SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
513*3547270fSGovindraj Raja
514*3547270fSGovindraj Raja	ifeq (${SPD_MAKE},)
515*3547270fSGovindraj Raja                $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
516*3547270fSGovindraj Raja	endif
517*3547270fSGovindraj Raja        $(info Including ${SPD_MAKE})
518*3547270fSGovindraj Raja        include ${SPD_MAKE}
519*3547270fSGovindraj Raja
520*3547270fSGovindraj Raja	# If there's BL32 companion for the chosen SPD, we expect that the SPD's
521*3547270fSGovindraj Raja	# Makefile would set NEED_BL32 to "yes". In this case, the build system
522*3547270fSGovindraj Raja	# supports two mutually exclusive options:
523*3547270fSGovindraj Raja	# * BL32 is built from source: then BL32_SOURCES must contain the list
524*3547270fSGovindraj Raja	#   of source files to build BL32
525*3547270fSGovindraj Raja	# * BL32 is a prebuilt binary: then BL32 must point to the image file
526*3547270fSGovindraj Raja	#   that will be included in the FIP
527*3547270fSGovindraj Raja	# If both BL32_SOURCES and BL32 are defined, the binary takes precedence
528*3547270fSGovindraj Raja	# over the sources.
529*3547270fSGovindraj Rajaendif #(SPD=none)
530*3547270fSGovindraj Raja
531*3547270fSGovindraj Rajaifeq (${ENABLE_SPMD_LP}, 1)
532*3547270fSGovindraj Rajaifneq (${SPD},spmd)
533*3547270fSGovindraj Raja        $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
534*3547270fSGovindraj Rajaendif
535*3547270fSGovindraj Rajaifeq ($(SPMC_AT_EL3),1)
536*3547270fSGovindraj Raja        $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
537*3547270fSGovindraj Rajaendif
538*3547270fSGovindraj Rajaendif
539*3547270fSGovindraj Raja
540*3547270fSGovindraj Raja################################################################################
541f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set
542f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags
543f5211420SGovindraj Raja################################################################################
544f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0)
545f5211420SGovindraj Raja	# Default value turns off all types of branch protection
546f5211420SGovindraj Raja	BP_OPTION := none
547f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64)
548f5211420SGovindraj Raja        $(error BRANCH_PROTECTION requires AArch64)
549f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1)
550f5211420SGovindraj Raja	# Enables all types of branch protection features
551f5211420SGovindraj Raja	BP_OPTION := standard
552f5211420SGovindraj Raja	ENABLE_BTI := 1
553f5211420SGovindraj Raja	ENABLE_PAUTH := 1
554f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2)
555f5211420SGovindraj Raja	# Return address signing to its standard level
556f5211420SGovindraj Raja	BP_OPTION := pac-ret
557f5211420SGovindraj Raja	ENABLE_PAUTH := 1
558f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3)
559f5211420SGovindraj Raja	# Extend the signing to include leaf functions
560f5211420SGovindraj Raja	BP_OPTION := pac-ret+leaf
561f5211420SGovindraj Raja	ENABLE_PAUTH := 1
562f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4)
563f5211420SGovindraj Raja	# Turn on branch target identification mechanism
564f5211420SGovindraj Raja	BP_OPTION := bti
565f5211420SGovindraj Raja	ENABLE_BTI := 1
566f5211420SGovindraj Rajaelse
567f5211420SGovindraj Raja        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
568f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION)
569f5211420SGovindraj Raja
570f5211420SGovindraj Rajaifeq ($(ENABLE_PAUTH),1)
571f5211420SGovindraj Raja	CTX_INCLUDE_PAUTH_REGS := 1
572f5211420SGovindraj Rajaendif
573f5211420SGovindraj Rajaifneq (${BP_OPTION},none)
574f5211420SGovindraj Raja	TF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
575f5211420SGovindraj Rajaendif #(BP_OPTION)
576f5211420SGovindraj Raja
577f5211420SGovindraj Raja# Pointer Authentication sources
578f5211420SGovindraj Rajaifeq (${ENABLE_PAUTH}, 1)
579f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
580f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms
581f5211420SGovindraj Raja	BL_COMMON_SOURCES	+=	lib/extensions/pauth/pauth_helpers.S
582f5211420SGovindraj Rajaendif
583f5211420SGovindraj Raja
584*3547270fSGovindraj Raja################################################################################
585*3547270fSGovindraj Raja# Include the platform specific Makefile after the SPD Makefile (the platform
586*3547270fSGovindraj Raja# makefile may use all previous definitions in this file)
587*3547270fSGovindraj Raja################################################################################
588*3547270fSGovindraj Rajainclude ${PLAT_MAKEFILE_FULL}
589*3547270fSGovindraj Raja
590*3547270fSGovindraj Raja################################################################################
591*3547270fSGovindraj Raja# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
592*3547270fSGovindraj Raja# platform.
593*3547270fSGovindraj Raja################################################################################
594*3547270fSGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
595*3547270fSGovindraj Raja
596f5211420SGovindraj Raja####################################################
597f5211420SGovindraj Raja# Enable required options for Memory Stack Tagging.
598f5211420SGovindraj Raja####################################################
599f5211420SGovindraj Raja
600f5211420SGovindraj Raja# Currently, these options are enabled only for clang and armclang compiler.
601f5211420SGovindraj Rajaifeq (${SUPPORT_STACK_MEMTAG},yes)
602f5211420SGovindraj Raja    ifdef mem_tag_arch_support
603f5211420SGovindraj Raja        # Check for armclang and clang compilers
604f5211420SGovindraj Raja        ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
605f5211420SGovindraj Raja        # Add "memtag" architecture feature modifier if not specified
606f5211420SGovindraj Raja            ifeq ( ,$(findstring memtag,$(arch-features)))
607f5211420SGovindraj Raja                arch-features	:=	$(arch-features)+memtag
608f5211420SGovindraj Raja            endif	# memtag
609f5211420SGovindraj Raja            ifeq ($(notdir $(CC)),armclang)
610f5211420SGovindraj Raja                TF_CFLAGS	+=	-mmemtag-stack
611f5211420SGovindraj Raja            else ifeq ($(notdir $(CC)),clang)
612f5211420SGovindraj Raja                TF_CFLAGS	+=	-fsanitize=memtag
613f5211420SGovindraj Raja            endif	# armclang
614f5211420SGovindraj Raja        endif
615f5211420SGovindraj Raja    else
616f5211420SGovindraj Raja        $(error "Error: stack memory tagging is not supported for  \
617f5211420SGovindraj Raja        architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
618f5211420SGovindraj Raja	endif #(mem_tag_arch_support)
619f5211420SGovindraj Rajaendif #(SUPPORT_STACK_MEMTAG)
620f5211420SGovindraj Raja
621f5211420SGovindraj Raja################################################################################
622f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME.
623f5211420SGovindraj Raja################################################################################
624f5211420SGovindraj Raja# FEAT_RME
625f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
626f5211420SGovindraj Raja	# RME doesn't support PIE
627f5211420SGovindraj Raja	ifneq (${ENABLE_PIE},0)
628f5211420SGovindraj Raja                $(error ENABLE_RME does not support PIE)
629f5211420SGovindraj Raja	endif
630f5211420SGovindraj Raja
631f5211420SGovindraj Raja	# RME doesn't support BRBE
632f5211420SGovindraj Raja	ifneq (${ENABLE_BRBE_FOR_NS},0)
633f5211420SGovindraj Raja                $(error ENABLE_RME does not support BRBE.)
634f5211420SGovindraj Raja	endif
635f5211420SGovindraj Raja
636f5211420SGovindraj Raja	# RME requires AARCH64
637f5211420SGovindraj Raja	ifneq (${ARCH},aarch64)
638f5211420SGovindraj Raja                $(error ENABLE_RME requires AArch64)
639f5211420SGovindraj Raja	endif
640f5211420SGovindraj Raja
641f5211420SGovindraj Raja	# RME requires el2 context to be saved for now.
642f5211420SGovindraj Raja	CTX_INCLUDE_EL2_REGS := 1
643f5211420SGovindraj Raja	CTX_INCLUDE_AARCH32_REGS := 0
644f5211420SGovindraj Raja	CTX_INCLUDE_PAUTH_REGS := 1
645f5211420SGovindraj Raja
646f5211420SGovindraj Raja	# RME enables CSV2_2 extension by default.
647f5211420SGovindraj Raja	ENABLE_FEAT_CSV2_2 = 1
648f5211420SGovindraj Rajaendif #(FEAT_RME)
649f5211420SGovindraj Raja
650f5211420SGovindraj Raja################################################################################
65173c99d4eSJuan Castillo# Generic definitions
65273c99d4eSJuan Castillo################################################################################
653231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
654231c1470SEvan Lloyd
65529214e95SGrant Likelyifeq (${BUILD_BASE},)
65673c99d4eSJuan Castillo     BUILD_BASE		:=	./build
65729214e95SGrant Likelyendif
65829214e95SGrant LikelyBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
65973c99d4eSJuan Castillo
660231c1470SEvan LloydSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
66173c99d4eSJuan Castillo
66273c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
66373c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
66473c99d4eSJuan Castillo
66573c99d4eSJuan Castillo################################################################################
66673c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
66773c99d4eSJuan Castillo################################################################################
66873c99d4eSJuan Castillo
66973c99d4eSJuan Castilloifneq (${SPD},none)
6709d29c227SSoby Mathew	ifeq (${ARCH},aarch32)
6719d29c227SSoby Mathew                $(error "Error: SPD is incompatible with AArch32.")
6729d29c227SSoby Mathew	endif
67328f39f02SMax Shvetsov
6744c117f6cSSandrine Bailleux	ifdef EL3_PAYLOAD_BASE
6754c117f6cSSandrine Bailleux                $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
676c5e1da83SJayanth Dodderi Chidanand                $(warning "The SPD and its BL32 companion will be present but \
677c5e1da83SJayanth Dodderi Chidanand                ignored.")
6784c117f6cSSandrine Bailleux	endif
67928f39f02SMax Shvetsov
680c3fb00d9SAchin Gupta	ifeq (${SPD},spmd)
681c3fb00d9SAchin Gupta	# SPMD is located in std_svc directory
682c3fb00d9SAchin Gupta		SPD_DIR := std_svc
68328f39f02SMax Shvetsov
684033039f8SMax Shvetsov		ifeq ($(SPMD_SPM_AT_SEL2),1)
685f1910cc1SGovindraj Raja			CTX_INCLUDE_EL2_REGS := 1
6861d63ae4dSMarc Bonnici			ifeq ($(SPMC_AT_EL3),1)
6871d63ae4dSMarc Bonnici                                $(error SPM cannot be enabled in both S-EL2 and EL3.)
6881d63ae4dSMarc Bonnici			endif
68928f39f02SMax Shvetsov		endif
690db1ef41aSOlivier Deprez
691db1ef41aSOlivier Deprez		ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
692db1ef41aSOlivier Deprez			DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
693db1ef41aSOlivier Deprez		endif
694ca932481SDavidson K
695ca932481SDavidson K		ifeq ($(TS_SP_FW_CONFIG),1)
696ca932481SDavidson K		DTC_CPPFLAGS	+=	-DTS_SP_FW_CONFIG
697ca932481SDavidson K		endif
69833993a37SBalint Dobszay
69933993a37SBalint Dobszay		ifneq ($(ARM_BL2_SP_LIST_DTS),)
70033993a37SBalint Dobszay		DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
70133993a37SBalint Dobszay		endif
70246789a7cSBalint Dobszay
70346789a7cSBalint Dobszay		ifneq ($(SP_LAYOUT_FILE),)
70446789a7cSBalint Dobszay		BL2_ENABLE_SP_LOAD := 1
70546789a7cSBalint Dobszay		endif
706801cd3c8SNishant Sharma
707801cd3c8SNishant Sharma		ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
708801cd3c8SNishant Sharma			ifneq ($(SPMC_AT_EL3),1)
709801cd3c8SNishant Sharma			$(error SEL0 SP cannot be enabled without SPMC at EL3)
710801cd3c8SNishant Sharma			endif
711801cd3c8SNishant Sharma		endif
712c3fb00d9SAchin Gupta	else
713c3fb00d9SAchin Gupta		# All other SPDs in spd directory
714c3fb00d9SAchin Gupta		SPD_DIR := spd
715c5e1da83SJayanth Dodderi Chidanand	endif #(SPD)
716c3fb00d9SAchin Gupta
71773c99d4eSJuan Castillo	# We expect to locate an spd.mk under the specified SPD directory
718c3fb00d9SAchin Gupta	SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
719c3fb00d9SAchin Gupta
72073c99d4eSJuan Castillo	ifeq (${SPD_MAKE},)
721c3fb00d9SAchin Gupta                $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
72273c99d4eSJuan Castillo	endif
72373c99d4eSJuan Castillo        $(info Including ${SPD_MAKE})
72473c99d4eSJuan Castillo        include ${SPD_MAKE}
72573c99d4eSJuan Castillo
72670d1fc53SJuan Castillo	# If there's BL32 companion for the chosen SPD, we expect that the SPD's
72770d1fc53SJuan Castillo	# Makefile would set NEED_BL32 to "yes". In this case, the build system
72870d1fc53SJuan Castillo	# supports two mutually exclusive options:
72970d1fc53SJuan Castillo	# * BL32 is built from source: then BL32_SOURCES must contain the list
73070d1fc53SJuan Castillo	#   of source files to build BL32
73170d1fc53SJuan Castillo	# * BL32 is a prebuilt binary: then BL32 must point to the image file
73270d1fc53SJuan Castillo	#   that will be included in the FIP
73370d1fc53SJuan Castillo	# If both BL32_SOURCES and BL32 are defined, the binary takes precedence
73470d1fc53SJuan Castillo	# over the sources.
735c5e1da83SJayanth Dodderi Chidanandendif #(SPD=none)
736e35c4045SJeenu Viswambharan
737890b5088SRaghu Krishnamurthyifeq (${ENABLE_SPMD_LP}, 1)
738890b5088SRaghu Krishnamurthyifneq (${SPD},spmd)
739890b5088SRaghu Krishnamurthy        $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
740890b5088SRaghu Krishnamurthyendif
741890b5088SRaghu Krishnamurthyifeq ($(SPMC_AT_EL3),1)
742890b5088SRaghu Krishnamurthy        $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
743890b5088SRaghu Krishnamurthyendif
744890b5088SRaghu Krishnamurthyendif
745890b5088SRaghu Krishnamurthy
746f1910cc1SGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1)
747f1910cc1SGovindraj Raja	ifeq (${SPD},none)
748f1910cc1SGovindraj Raja		ifeq (${ENABLE_RME},0)
749c5e1da83SJayanth Dodderi Chidanand                        $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
750c5e1da83SJayanth Dodderi Chidanand                        or RME is enabled)
751f1910cc1SGovindraj Raja		endif
752f1910cc1SGovindraj Raja	endif
753f1910cc1SGovindraj Rajaendif
754f1910cc1SGovindraj Raja
75551faada7SDouglas Raillard################################################################################
7565b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled
7575b18de09SZelalem Aweke################################################################################
7585b18de09SZelalem Awekeifneq (${ENABLE_RME},0)
7595b18de09SZelalem Aweke	ifneq (${ARCH},aarch64)
7605b18de09SZelalem Aweke                $(error ENABLE_RME requires AArch64)
7615b18de09SZelalem Aweke	endif
7621d63ae4dSMarc Bonnici	ifeq ($(SPMC_AT_EL3),1)
7631d63ae4dSMarc Bonnici                $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
7641d63ae4dSMarc Bonnici	endif
765c5e1da83SJayanth Dodderi Chidanand
7664fba2e1fSBoyan Karatotev	ifneq (${SPD}, none)
7674fba2e1fSBoyan Karatotev		ifneq (${SPD}, spmd)
7684fba2e1fSBoyan Karatotev                        $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
7694fba2e1fSBoyan Karatotev		endif
7704fba2e1fSBoyan Karatotev	endif
7715b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk
7725b18de09SZelalem Aweke$(warning "RME is an experimental feature")
7735b18de09SZelalem Awekeendif
7745b18de09SZelalem Aweke
775*3547270fSGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1)
776*3547270fSGovindraj Raja	ifeq (${SPD},none)
777*3547270fSGovindraj Raja		ifeq (${ENABLE_RME},0)
778*3547270fSGovindraj Raja                        $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
779*3547270fSGovindraj Raja                        or RME is enabled)
780*3547270fSGovindraj Raja		endif
781*3547270fSGovindraj Raja	endif
782*3547270fSGovindraj Rajaendif
7830f21c547SJuan Castillo
7847794d6c8SGovindraj Raja################################################################################
7857794d6c8SGovindraj Raja# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
7867794d6c8SGovindraj Raja# up with appropriate march values for compiler.
7877794d6c8SGovindraj Raja################################################################################
7887794d6c8SGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}march.mk
7897794d6c8SGovindraj Raja
7907794d6c8SGovindraj RajaTF_CFLAGS   +=	$(march-directive)
7917794d6c8SGovindraj Raja
79242d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios
79342d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios -
79442d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running
79542d4d3baSArvind Ram Prakash# BL2 in EL3
79642d4d3baSArvind Ram Prakash
79742d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1)
79842d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
79942d4d3baSArvind Ram Prakash	ifeq (${ENABLE_RME},1)
800c5e1da83SJayanth Dodderi Chidanand                $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
801c5e1da83SJayanth Dodderi Chidanand                supported at the moment.)
80242d4d3baSArvind Ram Prakash	endif
80342d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1)
80442d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
80542d4d3baSArvind Ram Prakashelse
80642d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	0
80742d4d3baSArvind Ram Prakashendif
80842d4d3baSArvind Ram Prakash
8098012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
8108012cc5cSMasahiro Yamada
81126e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
81226e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
81326e63c44SEtienne Carriereendif
81426e63c44SEtienne Carriere
8153bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
8163bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
8173bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
8187b592418SSamuel Hollandifneq ($(findstring gcc,$(notdir $(LD))),)
8197b592418SSamuel Holland	TF_LDFLAGS	+=	-no-pie
8207b592418SSamuel Hollandendif
821c5e1da83SJayanth Dodderi Chidanandendif #(PIE_FOUND)
822320920c1SMasahiro Yamada
823320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),)
824320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
825320920c1SMasahiro Yamadaelse
826320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
827320920c1SMasahiro Yamadaendif
828320920c1SMasahiro Yamada
829320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
83042d4d3baSArvind Ram Prakash	ifeq ($(RESET_TO_BL2),1)
83169af7fcfSMasahiro Yamada		ifneq ($(BL2_IN_XIP_MEM),1)
832966660ecSChris Kay			BL2_CPPFLAGS	+=	-fpie
83369af7fcfSMasahiro Yamada			BL2_CFLAGS	+=	-fpie
83469af7fcfSMasahiro Yamada			BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
835c5e1da83SJayanth Dodderi Chidanand		endif #(BL2_IN_XIP_MEM)
836c5e1da83SJayanth Dodderi Chidanand	endif #(RESET_TO_BL2)
837966660ecSChris Kay	BL31_CPPFLAGS	+=	-fpie
838320920c1SMasahiro Yamada	BL31_CFLAGS 	+=	-fpie
839320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
840966660ecSChris Kay
841966660ecSChris Kay	BL32_CPPFLAGS	+=	-fpie
842d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
843d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
844c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PIE)
8453bd17c0fSSoby Mathew
846007433d8SBoyan KaratotevBL1_CPPFLAGS  += -DREPORT_ERRATA=${DEBUG}
847007433d8SBoyan KaratotevBL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
848007433d8SBoyan KaratotevBL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
849007433d8SBoyan Karatotev
8509cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
85142d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2),1)
8529cefb4b1SMasahiro Yamada	BL2_CPPFLAGS += -DIMAGE_AT_EL3
853d5e97a1dSMasahiro Yamadaelse
8549cefb4b1SMasahiro Yamada	BL2_CPPFLAGS += -DIMAGE_AT_EL1
855c5e1da83SJayanth Dodderi Chidanandendif #(RESET_TO_BL2)
856007433d8SBoyan Karatotev
857007433d8SBoyan Karatotevifeq (${ARCH},aarch64)
8589cefb4b1SMasahiro Yamada	BL2U_CPPFLAGS += -DIMAGE_AT_EL1
8599cefb4b1SMasahiro Yamada	BL31_CPPFLAGS += -DIMAGE_AT_EL3
8609cefb4b1SMasahiro Yamada	BL32_CPPFLAGS += -DIMAGE_AT_EL1
861007433d8SBoyan Karatotevelse
862007433d8SBoyan Karatotev	BL32_CPPFLAGS += -DIMAGE_AT_EL3
863d5e97a1dSMasahiro Yamadaendif
864d5e97a1dSMasahiro Yamada
86554035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
86654035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
86754035fc4SSandrine Bailleux# This can be overridden by the platform.
86873c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
8694f6ad66aSAchin Gupta
870a4409008Sdp-arm################################################################################
871a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
872a4409008Sdp-arm################################################################################
873c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32)
874c5e1da83SJayanth Dodderi Chidanand        NEED_BL32 := yes
875c5e1da83SJayanth Dodderi Chidanand
876a4409008Sdp-arm        ifneq (${AARCH32_SP},none)
877a4409008Sdp-arm        # We expect to locate an sp.mk under the specified AARCH32_SP directory
878a4409008Sdp-arm		AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
879a4409008Sdp-arm
880a4409008Sdp-arm                ifeq (${AARCH32_SP_MAKE},)
881a4409008Sdp-arm                        $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
882a4409008Sdp-arm                endif
883a4409008Sdp-arm                $(info Including ${AARCH32_SP_MAKE})
884a4409008Sdp-arm                include ${AARCH32_SP_MAKE}
885a4409008Sdp-arm        endif
886c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
8874f6ad66aSAchin Gupta
88873c99d4eSJuan Castillo################################################################################
88977f1f7a1SVarun Wadekar# Include libc if not overridden
89077f1f7a1SVarun Wadekar################################################################################
89177f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
89277f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
89377f1f7a1SVarun Wadekarendif
89477f1f7a1SVarun Wadekar
89577f1f7a1SVarun Wadekar################################################################################
896c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies
897cf2c8a33SAntonio Nino Diaz################################################################################
898cf2c8a33SAntonio Nino Diaz
899c5e1da83SJayanth Dodderi Chidanand# USE_DEBUGFS experimental feature recommended only in debug builds
900c5e1da83SJayanth Dodderi Chidanandifeq (${USE_DEBUGFS},1)
901c5e1da83SJayanth Dodderi Chidanand        ifeq (${DEBUG},1)
902c5e1da83SJayanth Dodderi Chidanand                $(warning DEBUGFS experimental feature is enabled.)
903c5e1da83SJayanth Dodderi Chidanand        else
904c5e1da83SJayanth Dodderi Chidanand                $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
905c5e1da83SJayanth Dodderi Chidanand        endif
906c5e1da83SJayanth Dodderi Chidanandendif #(USE_DEBUGFS)
907c5e1da83SJayanth Dodderi Chidanand
908c5e1da83SJayanth Dodderi Chidanand# USE_SPINLOCK_CAS requires AArch64 build
909c5e1da83SJayanth Dodderi Chidanandifeq (${USE_SPINLOCK_CAS},1)
910c5e1da83SJayanth Dodderi Chidanand        ifneq (${ARCH},aarch64)
911c5e1da83SJayanth Dodderi Chidanand               $(error USE_SPINLOCK_CAS requires AArch64)
912c5e1da83SJayanth Dodderi Chidanand        endif
913c5e1da83SJayanth Dodderi Chidanandendif #(USE_SPINLOCK_CAS)
914c5e1da83SJayanth Dodderi Chidanand
915c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the
916c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all
917c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0)
918c5e1da83SJayanth Dodderi Chidanand        FIP_DEPS += certificates
919c5e1da83SJayanth Dodderi Chidanand        FWU_FIP_DEPS += fwu_certificates
920c5e1da83SJayanth Dodderi Chidanandendif
921c5e1da83SJayanth Dodderi Chidanand
922c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none)
923c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -f ${FW_ENC_STATUS}
924c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -k ${ENC_KEY}
925c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -n ${ENC_NONCE}
926c5e1da83SJayanth Dodderi Chidanand	FIP_DEPS += enctool
927c5e1da83SJayanth Dodderi Chidanand	FWU_FIP_DEPS += enctool
928c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
929c5e1da83SJayanth Dodderi Chidanand
930cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
93168450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
93268450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
93368450a6dSAntonio Nino Diaz		incompatible build options. EL3_PAYLOAD_BASE has priority.")
934cf2c8a33SAntonio Nino Diaz	endif
93576580f3dSQixiang Xu	ifneq (${GENERATE_COT},0)
936c5e1da83SJayanth Dodderi Chidanand                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
937c5e1da83SJayanth Dodderi Chidanand                build options.")
93876580f3dSQixiang Xu	endif
93976580f3dSQixiang Xu	ifneq (${TRUSTED_BOARD_BOOT},0)
940c5e1da83SJayanth Dodderi Chidanand                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
941c5e1da83SJayanth Dodderi Chidanand                incompatible \ build options.")
94276580f3dSQixiang Xu	endif
943c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
944cf2c8a33SAntonio Nino Diaz
945cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
946cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
947cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
948cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
949cf2c8a33SAntonio Nino Diaz	endif
95068450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
95168450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
952c5e1da83SJayanth Dodderi Chidanand                PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
953cf2c8a33SAntonio Nino Diaz	endif
954c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
955cf2c8a33SAntonio Nino Diaz
956d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
957d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
958d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
959d4593e47SJeenu Viswambharan        $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
960d4593e47SJeenu Viswambharanendif
9611a0a3f06SYatharth Kochar
96242d4d3baSArvind Ram Prakash#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
96342d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
96442d4d3baSArvind Ram Prakash        $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
9657d173fc5SJiafei Panendif
9667d173fc5SJiafei Pan
9679202d519SManish Pandey# RAS_EXTENSION is deprecated, provide alternate build options
96814c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
969c5e1da83SJayanth Dodderi Chidanand        $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
970c5e1da83SJayanth Dodderi Chidanand        and RAS_FFH_SUPPORT instead")
9719202d519SManish Pandeyendif
972c5e1da83SJayanth Dodderi Chidanand
9739202d519SManish Pandey# RAS firmware first handling requires that EAs are handled in EL3 first
9749202d519SManish Pandeyifeq ($(RAS_FFH_SUPPORT),1)
9759202d519SManish Pandey	ifneq ($(ENABLE_FEAT_RAS),1)
9769202d519SManish Pandey                $(error For RAS_FFH_SUPPORT, ENABLE_FEAT_RAS must also be 1)
9779202d519SManish Pandey	endif
97846cc41d5SManish Pandey	ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
9799202d519SManish Pandey                $(error For RAS_FFH_SUPPORT, HANDLE_EA_EL3_FIRST_NS must also be 1)
98014c6016aSJeenu Viswambharan	endif
981c5e1da83SJayanth Dodderi Chidanandendif #(RAS_FFH_SUPPORT)
982c5e1da83SJayanth Dodderi Chidanand
9839202d519SManish Pandey# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
9841a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
9856503ff29SAndre Przywara	ifeq ($(ENABLE_FEAT_RAS),0)
9866503ff29SAndre Przywara                $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
9871a7c1cfeSJeenu Viswambharan	endif
988c5e1da83SJayanth Dodderi Chidanandendif #(FAULT_INJECTION_SUPPORT)
9891a7c1cfeSJeenu Viswambharan
990ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
991209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
992209a60ccSSoby Mathew	ifeq (${TRUSTED_BOARD_BOOT}, 0)
993c5e1da83SJayanth Dodderi Chidanand                $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
994c5e1da83SJayanth Dodderi Chidanand                to be set.")
995209a60ccSSoby Mathew	endif
996c5e1da83SJayanth Dodderi Chidanandendif #(DYN_DISABLE_AUTH)
997209a60ccSSoby Mathew
9982bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
9992bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
10002bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
10012bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
10022bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
10032bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
10042bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
10052bf4f27fSManish V Badarkhe# Support hash calculation only
10062bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 2
10072bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1)
10082bf4f27fSManish V Badarkhe# Support authentication verification only
1009c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 1
1010c9c56f6eSManish V Badarkheelse
1011c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 0
1012c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
1013c9c56f6eSManish V Badarkhe
1014cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
1015cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
1016700e7685SManish Pandey        $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
101784ef9cd8SManish V Badarkheendif
101884ef9cd8SManish V Badarkhe
1019b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
10209fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
10219fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
1022b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
10239fc59639SAlexei Fedorov	ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
10249fc59639SAlexei Fedorov                $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
102506715f85SAlexei Fedorov	endif
1026c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PAUTH)
10279fc59639SAlexei Fedorov
102806715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
10299fc59639SAlexei Fedorov	ifneq (${ARCH},aarch64)
10309fc59639SAlexei Fedorov                $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
1031b86048c4SAntonio Nino Diaz	endif
1032c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_PAUTH_REGS)
10339fc59639SAlexei Fedorov
10349dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1)
10359dd94382SJustin Chadwell	ifneq (${ARCH},aarch64)
10369dd94382SJustin Chadwell                $(error CTX_INCLUDE_MTE_REGS requires AArch64)
10379dd94382SJustin Chadwell	endif
1038c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_MTE_REGS)
10399dd94382SJustin Chadwell
1040396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1)
1041396b339dSManish V Badarkhe        $(info PSA_FWU_SUPPORT is an experimental feature)
1042c5e1da83SJayanth Dodderi Chidanandendif #(PSA_FWU_SUPPORT)
1043396b339dSManish V Badarkhe
10446a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1)
10456a0da736SJayanth Dodderi Chidanand        $(info FEATURE_DETECTION is an experimental feature)
1046c5e1da83SJayanth Dodderi Chidanandendif #(FEATURE_DETECTION)
10476a0da736SJayanth Dodderi Chidanand
104803d3c0d7SJayanth Dodderi Chidanandifneq ($(ENABLE_SME2_FOR_NS), 0)
104903d3c0d7SJayanth Dodderi Chidanand	ifeq (${ENABLE_SME_FOR_NS}, 0)
1050c5e1da83SJayanth Dodderi Chidanand                $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
1051c5e1da83SJayanth Dodderi Chidanand                to be set")
105203d3c0d7SJayanth Dodderi Chidanand                $(warning "Forced ENABLE_SME_FOR_NS=1")
105303d3c0d7SJayanth Dodderi Chidanand		override ENABLE_SME_FOR_NS	:= 1
105403d3c0d7SJayanth Dodderi Chidanand	endif
1055c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME2_FOR_NS)
105645007acdSJayanth Dodderi Chidanand
105760e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
105860e8f3cfSPetre-Ionut Tudor	ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
1059c5e1da83SJayanth Dodderi Chidanand                $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
1060c5e1da83SJayanth Dodderi Chidanand                library v2")
106160e8f3cfSPetre-Ionut Tudor	endif
1062c5e1da83SJayanth Dodderi Chidanandendif #(ARM_XLAT_TABLES_LIB_V1)
106360e8f3cfSPetre-Ionut Tudor
10647cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
10657cda17bbSSumit Garg	ifeq (${TRUSTED_BOARD_BOOT}, 0)
1066c5e1da83SJayanth Dodderi Chidanand                $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
1067c5e1da83SJayanth Dodderi Chidanand                to be set)
10687cda17bbSSumit Garg	endif
1069c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
10707cda17bbSSumit Garg
1071744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build
1072dc78e62dSjohpow01ifeq (${ARCH},aarch32)
1073744ad974Sjohpow01
1074744ad974Sjohpow01	# SME/SVE only supported on AArch64
107545007acdSJayanth Dodderi Chidanand	ifneq (${ENABLE_SME_FOR_NS},0)
1076dc78e62dSjohpow01                $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
1077dc78e62dSjohpow01	endif
107803d3c0d7SJayanth Dodderi Chidanand
1079dc78e62dSjohpow01	ifeq (${ENABLE_SVE_FOR_NS},1)
1080dc78e62dSjohpow01		# Warning instead of error due to CI dependency on this
108124ab2c0aSYann Gautier                $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
1082dc78e62dSjohpow01	endif
1083744ad974Sjohpow01
1084ff86e0b4SJuan Pablo Conde	# BRBE is not supported in AArch32
1085744ad974Sjohpow01	ifeq (${ENABLE_BRBE_FOR_NS},1)
1086744ad974Sjohpow01                $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
1087744ad974Sjohpow01	endif
1088744ad974Sjohpow01
1089ff86e0b4SJuan Pablo Conde	# FEAT_RNG_TRAP is not supported in AArch32
1090ff86e0b4SJuan Pablo Conde	ifeq (${ENABLE_FEAT_RNG_TRAP},1)
1091ff86e0b4SJuan Pablo Conde                $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
1092ff86e0b4SJuan Pablo Conde	endif
1093c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
1094dc78e62dSjohpow01
10950d122947SBoyan Karatotevifneq (${ENABLE_SME_FOR_NS},0)
10960d122947SBoyan Karatotev	ifeq (${ENABLE_SVE_FOR_NS},0)
10970d122947SBoyan Karatotev                $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
10980d122947SBoyan Karatotev	endif
1099c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_NS)
11000d122947SBoyan Karatotev
1101dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well
1102dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1)
1103dc78e62dSjohpow01	ifeq (${ENABLE_SME_FOR_NS},0)
1104dc78e62dSjohpow01                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
1105dc78e62dSjohpow01	endif
11060d122947SBoyan Karatotev	ifeq (${ENABLE_SVE_FOR_SWD},0)
11070d122947SBoyan Karatotev                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
11080d122947SBoyan Karatotev	endif
1109c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_SWD)
1110c5e1da83SJayanth Dodderi Chidanand
1111dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1)
1112dc78e62dSjohpow01	ifeq (${ENABLE_SVE_FOR_NS},0)
1113dc78e62dSjohpow01                $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1114dc78e62dSjohpow01	endif
1115c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SVE_FOR_SWD)
1116dc78e62dSjohpow01
1117dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
1118dc78e62dSjohpow01# its own context management including FPU registers.
1119dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1)
112045007acdSJayanth Dodderi Chidanand	ifneq (${ENABLE_SME_FOR_NS},0)
1121dc78e62dSjohpow01                $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1122dc78e62dSjohpow01	endif
112303d3c0d7SJayanth Dodderi Chidanand
1124dc78e62dSjohpow01	ifeq (${ENABLE_SVE_FOR_NS},1)
1125dc78e62dSjohpow01		# Warning instead of error due to CI dependency on this
1126dc78e62dSjohpow01                $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1127dc78e62dSjohpow01                $(warning "Forced ENABLE_SVE_FOR_NS=0")
1128dc78e62dSjohpow01		override ENABLE_SVE_FOR_NS	:= 0
1129dc78e62dSjohpow01	endif
1130c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_FPREGS)
1131dc78e62dSjohpow01
113200e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1)
113300e28874SManish V Badarkhe        $(info DRTM_SUPPORT is an experimental feature)
113400e28874SManish V Badarkheendif
113500e28874SManish V Badarkhe
11363ba2c151SRaymond Maoifeq (${TRANSFER_LIST},1)
11373ba2c151SRaymond Mao        $(info TRANSFER_LIST is an experimental feature)
11383ba2c151SRaymond Maoendif
11393ba2c151SRaymond Mao
1140274a69e7SChris Kayifeq (${ENABLE_RME},1)
1141274a69e7SChris Kay	ifneq (${SEPARATE_CODE_AND_RODATA},1)
1142274a69e7SChris Kay                $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1143274a69e7SChris Kay	endif
1144274a69e7SChris Kayendif
1145274a69e7SChris Kay
1146c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_RNG is supported
1147c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_RNG		=	$(if $(findstring rng,${arch-features}),1,0)
1148c5e1da83SJayanth Dodderi Chidanand
1149c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_SB is supported
1150c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_SB		=	$(if $(findstring sb,${arch-features}),1,0)
1151c5e1da83SJayanth Dodderi Chidanand
11525782b890SManish V Badarkheifeq ($(PSA_CRYPTO),1)
11535782b890SManish V Badarkhe        $(info PSA_CRYPTO is an experimental feature)
11545782b890SManish V Badarkheendif
11555782b890SManish V Badarkhe
1156cf2c8a33SAntonio Nino Diaz################################################################################
115773c99d4eSJuan Castillo# Process platform overrideable behaviour
115873c99d4eSJuan Castillo################################################################################
11594f6ad66aSAchin Gupta
11605f24ce96SManish Pandeyifdef BL1_SOURCES
11615f24ce96SManish Pandey	NEED_BL1 := yes
1162c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES)
11635f24ce96SManish Pandey
11645f24ce96SManish Pandeyifdef BL2_SOURCES
11655f24ce96SManish Pandey	NEED_BL2 := yes
11665f24ce96SManish Pandey
1167bd97f83aSJohn Tsichritzis	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1168bd97f83aSJohn Tsichritzis	# Certificate generation tools. This flag can be overridden by the platform.
1169cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
1170cf2c8a33SAntonio Nino Diaz		# If booting an EL3 payload there is no need for a BL33 image
1171cf2c8a33SAntonio Nino Diaz		# in the FIP file.
11724c117f6cSSandrine Bailleux		NEED_BL33		:=	no
1173cf2c8a33SAntonio Nino Diaz	else
117468450a6dSAntonio Nino Diaz		ifdef PRELOADED_BL33_BASE
1175cf2c8a33SAntonio Nino Diaz			# If booting a BL33 preloaded image there is no need of
1176cf2c8a33SAntonio Nino Diaz			# another one in the FIP file.
1177cf2c8a33SAntonio Nino Diaz			NEED_BL33		:=	no
1178cf2c8a33SAntonio Nino Diaz		else
1179cf2c8a33SAntonio Nino Diaz			NEED_BL33		?=	yes
1180cf2c8a33SAntonio Nino Diaz		endif
11814c117f6cSSandrine Bailleux	endif
1182c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES)
11836f971622SJuan Castillo
11845f24ce96SManish Pandeyifdef BL2U_SOURCES
11855f24ce96SManish Pandey	NEED_BL2U := yes
1186c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES)
11875f24ce96SManish Pandey
11884d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
11894d045d0eSMasahiro Yamadaifdef SCP_BL2
11904d045d0eSMasahiro Yamada	NEED_SCP_BL2		:=	yes
1191c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2)
11924d045d0eSMasahiro Yamada
11935744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
11945744e874SSoby Mathewifneq (${ARCH},aarch32)
11955744e874SSoby Mathew	ifdef BL31_SOURCES
1196c5e1da83SJayanth Dodderi Chidanand	# When booting an EL3 payload, there is no need to compile the BL31
1197c5e1da83SJayanth Dodderi Chidanand	# image nor put it in the FIP.
11985744e874SSoby Mathew		ifndef EL3_PAYLOAD_BASE
11995744e874SSoby Mathew			NEED_BL31 := yes
12005744e874SSoby Mathew		endif
12015744e874SSoby Mathew	endif
1202c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64)
12035744e874SSoby Mathew
120473c99d4eSJuan Castillo# Process TBB related flags
12056f971622SJuan Castilloifneq (${GENERATE_COT},0)
120673c99d4eSJuan Castillo	# Common cert_create options
12076f971622SJuan Castillo	ifneq (${CREATE_KEYS},0)
12086f971622SJuan Castillo                $(eval CRT_ARGS += -n)
12090191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
1210fd34e7baSJuan Castillo		ifneq (${SAVE_KEYS},0)
1211fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
12120191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
1213fd34e7baSJuan Castillo		endif
12146f971622SJuan Castillo	endif
121573c99d4eSJuan Castillo	# Include TBBR makefile (unless the platform indicates otherwise)
121673c99d4eSJuan Castillo	ifeq (${INCLUDE_TBBR_MK},1)
121773c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
121873c99d4eSJuan Castillo	endif
1219c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
12206f971622SJuan Castillo
12211c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
12221c75d5dfSMasahiro Yamada	FIP_ARGS += --align ${FIP_ALIGN}
1223c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN)
12241c75d5dfSMasahiro Yamada
12255f24ce96SManish Pandeyifdef FDT_SOURCES
12265f24ce96SManish Pandey	NEED_FDT := yes
1227c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES)
12285f24ce96SManish Pandey
122973c99d4eSJuan Castillo################################################################################
123046e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
123146e5e035SMichalis Pappas################################################################################
123246e5e035SMichalis Pappas
123346e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
123446e5e035SMichalis Pappas
123546e5e035SMichalis Pappas################################################################################
12368a86052dSSoby Mathew# Include BL specific makefiles
12378a86052dSSoby Mathew################################################################################
12385f24ce96SManish Pandey
12395f24ce96SManish Pandeyifeq (${NEED_BL1},yes)
12408a86052dSSoby Mathewinclude bl1/bl1.mk
12418a86052dSSoby Mathewendif
12428a86052dSSoby Mathew
12435f24ce96SManish Pandeyifeq (${NEED_BL2},yes)
12448a86052dSSoby Mathewinclude bl2/bl2.mk
12458a86052dSSoby Mathewendif
12468a86052dSSoby Mathew
12475f24ce96SManish Pandeyifeq (${NEED_BL2U},yes)
12488a86052dSSoby Mathewinclude bl2u/bl2u.mk
12498a86052dSSoby Mathewendif
12508a86052dSSoby Mathew
12515744e874SSoby Mathewifeq (${NEED_BL31},yes)
12528a86052dSSoby Mathewinclude bl31/bl31.mk
12538a86052dSSoby Mathewendif
125403b397a8SNishanth Menon
125573c99d4eSJuan Castillo################################################################################
125673c99d4eSJuan Castillo# Build options checks
125773c99d4eSJuan Castillo################################################################################
125873c99d4eSJuan Castillo
1259c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags
1260327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
1261327131c4SLeonardo Sandoval    $(sort \
1262327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
126346789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
1264327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
1265327131c4SLeonardo Sandoval	CREATE_KEYS \
1266327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
1267327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
1268327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
1269327131c4SLeonardo Sandoval	DEBUG \
1270327131c4SLeonardo Sandoval	DYN_DISABLE_AUTH \
1271327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
12721fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
1273742ca230SChris Kay	ENABLE_AMU_FCONF \
1274873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
1275327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
127624077098SAndre Przywara	ENABLE_FEAT_SB \
1277327131c4SLeonardo Sandoval	ENABLE_PIE \
1278327131c4SLeonardo Sandoval	ENABLE_PMF \
1279327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
1280327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
1281dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
12820c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
1283327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
1284327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
1285327131c4SLeonardo Sandoval	GENERATE_COT \
1286327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
128746cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
1288327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
1289327131c4SLeonardo Sandoval	MEASURED_BOOT \
129000e28874SManish V Badarkhe	DRTM_SUPPORT \
1291327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
1292327131c4SLeonardo Sandoval	OVERRIDE_LIBC \
1293327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
12940ce2072dSTamas Ban	PLAT_RSS_NOT_SUPPORTED \
1295327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
1296327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
129764b4710bSWing Li	PSCI_OS_INIT_MODE \
1298327131c4SLeonardo Sandoval	RESET_TO_BL31 \
1299327131c4SLeonardo Sandoval	SAVE_KEYS \
1300327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
130196a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
1302327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
1303327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
1304327131c4SLeonardo Sandoval	SPM_MM \
13051d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
1306801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
1307327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
1308890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
13093ba2c151SRaymond Mao	TRANSFER_LIST \
1310327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
1311327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
1312327131c4SLeonardo Sandoval	USE_DEBUGFS \
1313327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
1314327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
1315327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
1316327131c4SLeonardo Sandoval	USE_ROMLIB \
1317327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
1318327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
131942d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
1320327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
1321327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
1322327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
1323327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
1324327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
1325327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
132600e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
1327327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
1328327131c4SLeonardo Sandoval	USE_SP804_TIMER \
1329396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
133068120783SChris Kay	ENABLE_MPMM \
133168120783SChris Kay	ENABLE_MPMM_FCONF \
13326a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
13330b22e591SJayanth Dodderi Chidanand	TRNG_SUPPORT \
1334ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
1335ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
133604c7303bSOkash Khawaja	CONDITIONAL_CMO \
13379202d519SManish Pandey	RAS_FFH_SUPPORT \
13385782b890SManish V Badarkhe	PSA_CRYPTO	\
133985bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
1340327131c4SLeonardo Sandoval)))
134173c99d4eSJuan Castillo
1342c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags
1343327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
1344327131c4SLeonardo Sandoval    $(sort \
1345327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
1346327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
1347327131c4SLeonardo Sandoval	BRANCH_PROTECTION \
13486a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_PAUTH_REGS \
13496a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_MTE_REGS \
13506a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_NEVE_REGS \
13512bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT \
135283a4dae1SBoyan Karatotev	DISABLE_MTPMU \
13531298f2f1SJayanth Dodderi Chidanand	ENABLE_BRBE_FOR_NS \
135447c681b7SJayanth Dodderi Chidanand	ENABLE_TRBE_FOR_NS \
13556a0da736SJayanth Dodderi Chidanand	ENABLE_BTI \
13566a0da736SJayanth Dodderi Chidanand	ENABLE_PAUTH \
1357d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
13586a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
13596a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
13609202d519SManish Pandey	ENABLE_FEAT_RAS	\
13616a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_DIT \
13626a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
13636a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
13646a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_HCX \
13656a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
13666a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_RNG \
1367ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
13686a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
1369d3331603SMark Brown	ENABLE_FEAT_TCR2 \
1370062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
1371062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
1372062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
1373062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
1374688ab57bSMark Brown	ENABLE_FEAT_GCS \
13756a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
13764d0b6632SMaksims Svecovs	ENABLE_FEAT_MTE_PERM \
1377edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
13786a0da736SJayanth Dodderi Chidanand	ENABLE_RME \
13796437a09aSAndre Przywara	ENABLE_SPE_FOR_NS \
1380603a0c6fSAndre Przywara	ENABLE_SYS_REG_TRACE_FOR_NS \
138145007acdSJayanth Dodderi Chidanand	ENABLE_SME_FOR_NS \
138203d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
13832b0bc4e0SJayanth Dodderi Chidanand	ENABLE_SVE_FOR_NS \
13846a0da736SJayanth Dodderi Chidanand	ENABLE_TRF_FOR_NS \
1385327131c4SLeonardo Sandoval	FW_ENC_STATUS \
13865357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
13875357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
1388781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
1389781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
1390bebcf27fSMark Brown	SVE_VECTOR_LEN \
13910ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
1392327131c4SLeonardo Sandoval)))
1393c877b414SJeenu Viswambharan
1394aacff749SJustin Chadwellifdef KEY_SIZE
1395aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
1396aacff749SJustin Chadwellendif
1397aacff749SJustin Chadwell
13981f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
13991f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
14001f461979SJustin Chadwellendif
14011f461979SJustin Chadwell
140273c99d4eSJuan Castillo################################################################################
140373c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
140473c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
140573c99d4eSJuan Castillo# platform to overwrite the default options
140673c99d4eSJuan Castillo################################################################################
140773c99d4eSJuan Castillo
1408327131c4SLeonardo Sandoval$(eval $(call add_defines,\
1409327131c4SLeonardo Sandoval    $(sort \
1410327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
1411327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
1412327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
141346789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
1414327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
1415327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
1416327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
1417327131c4SLeonardo Sandoval	CTX_INCLUDE_PAUTH_REGS \
1418327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
1419327131c4SLeonardo Sandoval	CTX_INCLUDE_MTE_REGS \
1420327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
1421062f8aafSArunachalam Ganapathy	CTX_INCLUDE_NEVE_REGS \
1422327131c4SLeonardo Sandoval	DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
14230063dd17SJavier Almansa Sobrino	DISABLE_MTPMU \
1424d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
14251fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
1426742ca230SChris Kay	ENABLE_AMU_FCONF \
1427873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
1428327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
1429327131c4SLeonardo Sandoval	ENABLE_BTI \
1430edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
1431327131c4SLeonardo Sandoval	ENABLE_PAUTH \
1432327131c4SLeonardo Sandoval	ENABLE_PIE \
1433327131c4SLeonardo Sandoval	ENABLE_PMF \
1434327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
14355b18de09SZelalem Aweke	ENABLE_RME \
1436327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
1437dc78e62dSjohpow01	ENABLE_SME_FOR_NS \
143803d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
1439dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
144090118bb5SAndre Przywara	ENABLE_SPE_FOR_NS \
1441327131c4SLeonardo Sandoval	ENABLE_SVE_FOR_NS \
14420c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
1443327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
1444327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
1445327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
1446327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
1447327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
144846cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
1449327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
1450327131c4SLeonardo Sandoval	LOG_LEVEL \
1451327131c4SLeonardo Sandoval	MEASURED_BOOT \
145200e28874SManish V Badarkhe	DRTM_SUPPORT \
1453327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
1454327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
1455327131c4SLeonardo Sandoval	PLAT_${PLAT} \
14560ce2072dSTamas Ban	PLAT_RSS_NOT_SUPPORTED \
1457327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
1458327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
145964b4710bSWing Li	PSCI_OS_INIT_MODE \
14609202d519SManish Pandey	ENABLE_FEAT_RAS \
14619202d519SManish Pandey	RAS_FFH_SUPPORT \
1462327131c4SLeonardo Sandoval	RESET_TO_BL31 \
1463327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
146496a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
1465327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
1466327131c4SLeonardo Sandoval	RECLAIM_INIT_CODE \
1467327131c4SLeonardo Sandoval	SPD_${SPD} \
1468327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
1469327131c4SLeonardo Sandoval	SPM_MM \
14701d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
1471801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
1472327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
14733ba2c151SRaymond Mao	TRANSFER_LIST \
1474327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
1475c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT \
14767dfb9911SJimmy Brisson	TRNG_SUPPORT \
1477ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
1478ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
1479327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
1480327131c4SLeonardo Sandoval	USE_DEBUGFS \
1481327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
1482327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
1483327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
1484327131c4SLeonardo Sandoval	USE_ROMLIB \
1485327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
1486327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
148742d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
148842d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	\
1489327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
1490327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
1491327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
1492327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
149300e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
1494327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
1495327131c4SLeonardo Sandoval	USE_SP804_TIMER \
149612cd65e0STomas Pilar	ENABLE_FEAT_RNG \
1497ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
14984e04478aSChris Kay	ENABLE_FEAT_SB \
14997d33ffe4SDaniel Boulby	ENABLE_FEAT_DIT \
15005357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
15015357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
1502396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
1503744ad974Sjohpow01	ENABLE_BRBE_FOR_NS \
1504813524eaSManish V Badarkhe	ENABLE_TRBE_FOR_NS \
1505d4582d30SManish V Badarkhe	ENABLE_SYS_REG_TRACE_FOR_NS \
15068fcd3d96SManish V Badarkhe	ENABLE_TRF_FOR_NS \
1507cb4ec47bSjohpow01	ENABLE_FEAT_HCX \
150868120783SChris Kay	ENABLE_MPMM \
150968120783SChris Kay	ENABLE_MPMM_FCONF \
1510f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
1511f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
15126a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
15136a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
15146a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
15156a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
15166a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
1517d3331603SMark Brown	ENABLE_FEAT_TCR2 \
1518062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
1519062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
1520062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
1521062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
1522688ab57bSMark Brown	ENABLE_FEAT_GCS \
15234d0b6632SMaksims Svecovs	ENABLE_FEAT_MTE_PERM \
15246a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
1525781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
1526781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
152704c7303bSOkash Khawaja	CONDITIONAL_CMO \
15280ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
1529a8cf6faeSJayanth Dodderi Chidanand	SVE_VECTOR_LEN \
1530890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
15315782b890SManish V Badarkhe	PSA_CRYPTO	\
153285bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
1533327131c4SLeonardo Sandoval)))
15342fae4b1eSJeenu Viswambharan
15351f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
15361f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
1537c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB)
15381f461979SJustin Chadwell
15394c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
15404c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
15414c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1542cf2c8a33SAntonio Nino Diazelse
154368450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and
154468450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority.
154568450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
154668450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
15474c117f6cSSandrine Bailleux	endif
1548c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
154973c99d4eSJuan Castillo
1550209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1551209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1552209a60ccSSoby Mathew        $(eval $(call add_define,DYN_DISABLE_AUTH))
1553209a60ccSSoby Mathewendif
1554209a60ccSSoby Mathew
1555c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
1556c2ad38ceSVarun Wadekar        $(eval $(call add_define,USE_ARM_LINK))
1557c2ad38ceSVarun Wadekarendif
1558c2ad38ceSVarun Wadekar
1559ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1560ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1561c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1562ce2b1ec6SManish Pandey	-include $(BUILD_PLAT)/sp_gen.mk
1563ce2b1ec6SManish Pandey	FIP_DEPS += sp
156407c44475SManish Pandey	CRT_DEPS += sp
1565ce2b1ec6SManish Pandey	NEED_SP_PKG := yes
1566ce2b1ec6SManish Pandeyelse
1567c33ff198SOlivier Deprez	ifeq (${SPMD_SPM_AT_SEL2},1)
1568c33ff198SOlivier Deprez                $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1569c33ff198SOlivier Deprez	endif
1570c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE)
1571c5e1da83SJayanth Dodderi Chidanandendif #(SPD)
1572ce2b1ec6SManish Pandey
157373c99d4eSJuan Castillo################################################################################
157473c99d4eSJuan Castillo# Build targets
157573c99d4eSJuan Castillo################################################################################
157673c99d4eSJuan Castillo
157790aa901fSSumit Garg.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
157873c99d4eSJuan Castillo.SUFFIXES:
157973c99d4eSJuan Castillo
158073c99d4eSJuan Castilloall: msg_start
158173c99d4eSJuan Castillo
158273c99d4eSJuan Castillomsg_start:
158373c99d4eSJuan Castillo	@echo "Building ${PLAT}"
158473c99d4eSJuan Castillo
15857a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1586d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
1587c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),)
1588c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1589c2ad38ceSVarun Wadekarelse
1590bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
15917a24cba5SSoby Mathewendif
1592c5e1da83SJayanth Dodderi Chidanandendif #(!ERROR_DEPRECATED)
15937a24cba5SSoby Mathew
15945accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS))
159561f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
15965fee0287SRoberto Vargas
159773c99d4eSJuan Castillo# Expand build macros for the different images
159873c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
1599b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES})
1600434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1))
1601c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1)
160273c99d4eSJuan Castillo
160373c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1604c5e1da83SJayanth Dodderi Chidanand
160542d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0)
1606c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1607c9b31ae8SRoberto Vargasendif
1608c9b31ae8SRoberto Vargas
1609eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES})
1610eb1acfb6SChris Kay
161133950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1612434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1613c5e1da83SJayanth Dodderi Chidanand
1614c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2)
161573c99d4eSJuan Castillo
16164d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
161733950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1618c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2)
16194d045d0eSMasahiro Yamada
162073c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
162173c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
162226d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
162326d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1624c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1625c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1626434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1627c6ba9b45SSumit Gargelse
162833950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1629434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw)))
1630c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1631c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31)
163273c99d4eSJuan Castillo
163370d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1634c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
163570d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
163673c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
163726d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
163826d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
16399cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
16409cd15239SMasahiro Yamada
1641c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1642434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1643c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1644c6ba9b45SSumit Gargelse
1645434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
164633950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1647c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1648c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32)
164973c99d4eSJuan Castillo
16505b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
16515b18de09SZelalem Aweke# needs to be built from RMM_SOURCES.
16525b18de09SZelalem Awekeifeq (${NEED_RMM},yes)
16535b18de09SZelalem Aweke# Sort RMM source files to remove duplicates
16545b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES})
16555b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
16565b18de09SZelalem Aweke
16575b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
16585b18de09SZelalem Aweke	 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1659c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM)
16605b18de09SZelalem Aweke
166173c99d4eSJuan Castillo# Add the BL33 image if required by the platform
166273c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
166333950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1664c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
1665db6071c9SJuan Castillo
16669003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
166733950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1668434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1669c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U)
16709003fa0bSYatharth Kochar
167103b397a8SNishanth Menon# Expand build macros for the different images
167203b397a8SNishanth Menonifeq (${NEED_FDT},yes)
167303b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
1674c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT)
167503b397a8SNishanth Menon
1676ce2b1ec6SManish Pandey# Add Secure Partition packages
1677ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1678ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk : ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
167920629b31SKarl Meakin	${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
1680822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1681ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1682ce2b1ec6SManish Pandey	@echo "Built SP Images successfully"
1683ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1684c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG)
1685ce2b1ec6SManish Pandey
168636eaaf37SIan Spraylocate-checkpatch:
168736eaaf37SIan Sprayifndef CHECKPATCH
168866079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
168936eaaf37SIan Sprayelse
169036eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
169166079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
169236eaaf37SIan Sprayendif
1693c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH)
169436eaaf37SIan Spray
16954f6ad66aSAchin Guptaclean:
16964f6ad66aSAchin Gupta	@echo "  CLEAN"
1697f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
169888a1cf1eSSami Mujawarifdef UNIX_MK
16992f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
170088a1cf1eSSami Mujawarelse
170188a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
170288a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
170388a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1704c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK)
17056f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
170690aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
17075accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
17084f6ad66aSAchin Gupta
1709eaaeece2SJames Morrisseyrealclean distclean:
1710eaaeece2SJames Morrissey	@echo "  REALCLEAN"
1711f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1712f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
171388a1cf1eSSami Mujawarifdef UNIX_MK
17142f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
171588a1cf1eSSami Mujawarelse
171688a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
171788a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
171888a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1719c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK)
1720e15591aaSNicolas Boulenguez	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
172190aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
17225accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
17234f6ad66aSAchin Gupta
172436eaaf37SIan Spraycheckcodebase:		locate-checkpatch
172536eaaf37SIan Spray	@echo "  CHECKING STYLE"
172636eaaf37SIan Spray	@if test -d .git ; then						\
17271ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
17281a41e8c1SDan Handley		while read GIT_FILE ;					\
17291a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
17301a41e8c1SDan Handley		done ;							\
173136eaaf37SIan Spray	else								\
17321a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
17331a41e8c1SDan Handley		 -not -iwholename "*build*"				\
17341a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
173561f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
17361a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
17371ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
17381a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
173936eaaf37SIan Spray	fi
174036eaaf37SIan Spray
174136eaaf37SIan Spraycheckpatch:		locate-checkpatch
174236eaaf37SIan Spray	@echo "  CHECKING STYLE"
174302a76d5fSYann Gautier	@if test -n "${CHECKPATCH_OPTS}"; then				\
174402a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
174502a76d5fSYann Gautier	fi
174651d28937SAntonio Nino Diaz	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
174777a0a7f1SYann Gautier	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
174877a0a7f1SYann Gautier	do								\
174951d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
175051d28937SAntonio Nino Diaz		git log --format=email "$$commit~..$$commit"		\
175102a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
175202a76d5fSYann Gautier			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
175351d28937SAntonio Nino Diaz		git diff --format=email "$$commit~..$$commit"		\
175402a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
175502a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
175651d28937SAntonio Nino Diaz	done
175736eaaf37SIan Spray
175873c99d4eSJuan Castillocerttool: ${CRTTOOL}
175973c99d4eSJuan Castillo
1760a9812206SPali Rohár${CRTTOOL}: FORCE
1761598b166bSLionel Debieve	${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${CRTTOOLPATH} all
1762f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
17636f971622SJuan Castillo	@echo "Built $@ successfully"
1764f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
17656f971622SJuan Castillo
17666f971622SJuan Castilloifneq (${GENERATE_COT},0)
176773c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
17686f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
1769f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
17706f971622SJuan Castillo	@echo "Built $@ successfully"
17716f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
1772f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1773c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
177427713fb4SSoby Mathew
177573c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
17764727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
1777819281eeSdp-arm	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1778819281eeSdp-arm	${Q}${FIPTOOL} info $@
1779f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
17802f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
1781f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1782f58ad36fSHarry Liebel
17830191262dSYatharth Kocharifneq (${GENERATE_COT},0)
17840191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
17850191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1786052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
17870191262dSYatharth Kochar	@echo "Built $@ successfully"
17880191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1789052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
1790c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
17910191262dSYatharth Kochar
17920191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
17934727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
1794819281eeSdp-arm	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1795819281eeSdp-arm	${Q}${FIPTOOL} info $@
1796052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
17970191262dSYatharth Kochar	@echo "Built $@ successfully"
1798052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
17990191262dSYatharth Kochar
180073c99d4eSJuan Castillofiptool: ${FIPTOOL}
180173c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
18020191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
180373c99d4eSJuan Castillo
1804a9812206SPali Rohár${FIPTOOL}: FORCE
180588a1cf1eSSami Mujawarifdef UNIX_MK
1806598b166bSLionel Debieve	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
180788a1cf1eSSami Mujawarelse
180888a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
180988a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
181088a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1811c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK)
1812f58ad36fSHarry Liebel
1813a9812206SPali Rohárromlib.bin: libraries FORCE
1814bbb24f61SJohn Tsichritzis	${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all
18155accce5bSRoberto Vargas
1816cfe83910SLouis Mayencourtmemmap: all
1817af5b49e9SHarrison Mutaiifdef UNIX_MK
1818af5b49e9SHarrison Mutai	${Q}PYTHONPATH=${CURDIR}/tools/memory \
1819af5b49e9SHarrison Mutai		${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1820af5b49e9SHarrison Mutaielse
1821af5b49e9SHarrison Mutai	${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
1822af5b49e9SHarrison Mutai		${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1823af5b49e9SHarrison Mutaiendif
1824cfe83910SLouis Mayencourt
18256de32378SMadhukar Pappireddydoc:
18266de32378SMadhukar Pappireddy	@echo "  BUILD DOCUMENTATION"
18276de32378SMadhukar Pappireddy	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
18286de32378SMadhukar Pappireddy
182990aa901fSSumit Gargenctool: ${ENCTOOL}
183090aa901fSSumit Garg
1831a9812206SPali Rohár${ENCTOOL}: FORCE
1832598b166bSLionel Debieve	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
183390aa901fSSumit Garg	@${ECHO_BLANK_LINE}
183490aa901fSSumit Garg	@echo "Built $@ successfully"
183590aa901fSSumit Garg	@${ECHO_BLANK_LINE}
183690aa901fSSumit Garg
183735fab8c9SJoakim Bechcscope:
183835fab8c9SJoakim Bech	@echo "  CSCOPE"
183935fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
184035fab8c9SJoakim Bech	${Q}cscope -b -q -k
184135fab8c9SJoakim Bech
184272ee3314SRyan Harkinhelp:
18437c23126cSJohn Tsichritzis	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
184472ee3314SRyan Harkin	@echo ""
184572ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
184608c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
184772ee3314SRyan Harkin	@echo ""
18487c23126cSJohn Tsichritzis	@echo "platform = ${PLATFORM_LIST}"
18497c23126cSJohn Tsichritzis	@echo ""
18501b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
18511b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
18521b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
18531b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
18541b578596SSandrine Bailleux	@echo ""
185572ee3314SRyan Harkin	@echo "Supported Targets:"
18561b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
185736eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
18588aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
18599003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
1860d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
18619d29c227SSoby Mathew	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
18629d29c227SSoby Mathew	@echo "                 this builds secure payload specified by AARCH32_SP"
186373c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
18641b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
18650191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
186636eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
186736eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
186836eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
186972ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
187035fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
187172ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
18726f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
187390aa901fSSumit Garg	@echo "  enctool        Build the Firmware encryption tool"
1874f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1875ce2b1ec6SManish Pandey	@echo "  sp             Build the Secure Partition Packages"
187626010da1SAntonio Nino Diaz	@echo "  sptool         Build the Secure Partition Package creation tool"
187738c14d88SSoby Mathew	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1878cfe83910SLouis Mayencourt	@echo "  memmap         Print the memory map of the built binaries"
18796de32378SMadhukar Pappireddy	@echo "  doc            Build html based documentation using Sphinx tool"
188072ee3314SRyan Harkin	@echo ""
18811b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
188272ee3314SRyan Harkin	@echo ""
188372ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
188472ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1885a9812206SPali Rohár
1886a9812206SPali Rohár.PHONY: FORCE
1887a9812206SPali RohárFORCE:;
1888