xref: /rk3399_ARM-atf/Makefile (revision b3bcfd12c8469df79b212647b9eb2743d7dbb070)
14f6ad66aSAchin Gupta#
2c3273703SChris Kay# Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
34f6ad66aSAchin Gupta#
482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
54f6ad66aSAchin Gupta#
64f6ad66aSAchin Gupta
7e35c4045SJeenu Viswambharan#
8aaa3e722SJuan Castillo# Trusted Firmware Version
9aaa3e722SJuan Castillo#
101a0f1121SSoby MathewVERSION_MAJOR			:= 2
1197a6de9eSGovindraj RajaVERSION_MINOR			:= 13
12c25d1ccfSYann Gautier# VERSION_PATCH is only used for LTS releases
13c25d1ccfSYann GautierVERSION_PATCH			:= 0
14055ebecaSYann GautierVERSION				:= ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
15aaa3e722SJuan Castillo
1688154678SJuan Castillo# Default goal is build all images
1788154678SJuan Castillo.DEFAULT_GOAL			:= all
1888154678SJuan Castillo
1972fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to
2072fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
2172fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual.
2272fc70edSDouglas RaillardMAKEOVERRIDES =
2372fc70edSDouglas Raillard
24231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/
25231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
26f4dd18c2SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}build-rules.mk
277c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk
2873c99d4eSJuan Castillo
2973c99d4eSJuan Castillo################################################################################
302fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies
3173c99d4eSJuan Castillo################################################################################
32e35c4045SJeenu Viswambharan
332fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
34422b181fSYann GautierPLAT				:= ${DEFAULT_PLAT}
351b2fb6adSAndrey Skvortsovinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
361b2fb6adSAndrey Skvortsov
371b2fb6adSAndrey Skvortsov# To be able to set platform specific defaults
381b2fb6adSAndrey Skvortsovifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
391b2fb6adSAndrey Skvortsovinclude ${PLAT_DEFAULTS_MAKEFILE_FULL}
401b2fb6adSAndrey Skvortsovendif
41872be88aSdp-arm
42cc277de8SChris Kay################################################################################
43cc277de8SChris Kay# Configure the toolchains used to build TF-A and its tools
44cc277de8SChris Kay################################################################################
45cc277de8SChris Kay
46cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk
47cc277de8SChris Kay
48cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default
49cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS		:= ${DEBUG}
502fae4b1eSJeenu ViswambharanENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
5173c99d4eSJuan Castillo
5273c99d4eSJuan Castillo################################################################################
5373c99d4eSJuan Castillo# Checkpatch script options
5473c99d4eSJuan Castillo################################################################################
5573c99d4eSJuan Castillo
56f607739cSSandrine BailleuxCHECKCODE_ARGS		:=	--no-patch
57f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files
584501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
594501843fSGilad Ben-Yossef					include/drivers/arm,		\
604501843fSGilad Ben-Yossef					$(wildcard include/drivers/*)))
61f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
621a41e8c1SDan Handley					include/lib/libfdt		\
6361f72a34SRoberto Vargas					include/lib/libc,		\
64f0b489c1SDan Handley					$(wildcard include/lib/*)))
65f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
664501843fSGilad Ben-Yossef					include/lib			\
674501843fSGilad Ben-Yossef					include/drivers,		\
68f0b489c1SDan Handley					$(wildcard include/*)))
69f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
70d801fbb0Sdp-arm					lib/compiler-rt			\
7155cdcf75SAntonio Nino Diaz					lib/libfdt%			\
7261f72a34SRoberto Vargas					lib/libc,			\
73a194255dSDaniel Boulby					lib/zlib			\
74f0b489c1SDan Handley					$(wildcard lib/*)))
75f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
76f0b489c1SDan Handley					lib				\
77f0b489c1SDan Handley					include				\
78f0b489c1SDan Handley					docs				\
791ef35512SPaul Beesley					%.rst,				\
80f0b489c1SDan Handley					$(wildcard *)))
81f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
82f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
83f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
844501843fSGilad Ben-Yossef				${LIB_DIRS_TO_CHECK}			\
854501843fSGilad Ben-Yossef				${INC_DRV_DIRS_TO_CHECK}		\
864501843fSGilad Ben-Yossef				${INC_ARM_DIRS_TO_CHECK}
8736eaaf37SIan Spray
8873c99d4eSJuan Castillo################################################################################
8973c99d4eSJuan Castillo# Process build options
9073c99d4eSJuan Castillo################################################################################
9173c99d4eSJuan Castillo
927c4e1eeaSChris Kayifeq ($(verbose),)
9336eaaf37SIan Spray	CHECKCODE_ARGS	+=	--no-summary --terse
944f6ad66aSAchin Guptaendif
95ee1ba6d4SAndre Przywara
9673c99d4eSJuan Castillo################################################################################
97c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc)
98c5e1da83SJayanth Dodderi Chidanand################################################################################
99c5e1da83SJayanth Dodderi Chidanand
100c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool
101c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH		?=	tools/cert_create
102f4595e6eSBoyan KaratotevCRTTOOL			?=	${BUILD_PLAT}/${CRTTOOLPATH}/cert_create$(.exe)
103c5e1da83SJayanth Dodderi Chidanand
104c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool
105c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH		?=	tools/encrypt_fw
10696fbe884SBoyan KaratotevENCTOOL			?=	${BUILD_PLAT}/${ENCTOOLPATH}/encrypt_fw$(.exe)
107c5e1da83SJayanth Dodderi Chidanand
108c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package
109c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH		?=	tools/fiptool
110cbd6cec3SBoyan KaratotevFIPTOOL			?=	${BUILD_PLAT}/${FIPTOOLPATH}/fiptool$(.exe)
111c5e1da83SJayanth Dodderi Chidanand
112c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool
113c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH		?=	tools/sptool
114c5e1da83SJayanth Dodderi ChidanandSPTOOL			?=	${SPTOOLPATH}/sptool.py
115c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
11620629b31SKarl MeakinSP_DTS_LIST_FRAGMENT	?=	${BUILD_PLAT}/sp_list_fragment.dts
117c5e1da83SJayanth Dodderi Chidanand
1180fe374efSJ-Alves# Variables for use with sptool
1190fe374efSJ-AlvesTLCTOOL 		?=	poetry run tlc
1200fe374efSJ-Alves
121c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB
122c5e1da83SJayanth Dodderi ChidanandROMLIBPATH		?=	lib/romlib
123c5e1da83SJayanth Dodderi Chidanand
124c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python
125c5e1da83SJayanth Dodderi ChidanandPYTHON			?=	python3
126c5e1da83SJayanth Dodderi Chidanand
127c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool
128c5e1da83SJayanth Dodderi ChidanandDOCS_PATH		?=	docs
129c5e1da83SJayanth Dodderi Chidanand
13032b209bfSAhmad Fatoum# Process Debug flag
13132b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
13232b209bfSAhmad Fatoum	BUILD_TYPE	:=	debug
13332b209bfSAhmad Fatoum	# Use LOG_LEVEL_INFO by default for debug builds
13432b209bfSAhmad Fatoum	LOG_LEVEL	:=	40
13532b209bfSAhmad Fatoumelse
13632b209bfSAhmad Fatoum	BUILD_TYPE	:=	release
13732b209bfSAhmad Fatoum	# Use LOG_LEVEL_NOTICE by default for release builds
13832b209bfSAhmad Fatoum	LOG_LEVEL	:=	20
139c5e1da83SJayanth Dodderi Chidanandendif #(Debug)
14032b209bfSAhmad Fatoum
141f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
142f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
143f1de4c8fSPeiyuan Song	BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
144f1de4c8fSPeiyuan Songendif
145dddf4283Slaurenw-armVERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
146f1de4c8fSPeiyuan Song
147d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues
148d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings
149d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed
150d75a9ecdSBoyan Karatotevifdef W
151d75a9ecdSBoyan Karatotev	ifneq (${W},0)
152d75a9ecdSBoyan Karatotev		E	 ?= 0
153d75a9ecdSBoyan Karatotev	endif
154d75a9ecdSBoyan Karatotevendif
155d75a9ecdSBoyan Karatotev
15673c99d4eSJuan Castillo################################################################################
157f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features.
158f5211420SGovindraj Raja################################################################################
159f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
1607d5fc98fSAlexeiFedorov	ARM_ARCH_MAJOR := 9
1617d5fc98fSAlexeiFedorov	ARM_ARCH_MINOR := 2
162f5211420SGovindraj Rajaendif
163f5211420SGovindraj Raja
164f5211420SGovindraj Raja################################################################################
16573c99d4eSJuan Castillo# Common sources and include directories
16673c99d4eSJuan Castillo################################################################################
167d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
16873c99d4eSJuan Castillo
169758ccb80SChris Kay# Allow overriding the timestamp, for example for reproducible builds, or to
170758ccb80SChris Kay# synchronize timestamps across multiple projects.
171758ccb80SChris Kay# This must be set to a C string (including quotes where applicable).
172758ccb80SChris KayBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
173758ccb80SChris Kay
174758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
175758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
176758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
177758ccb80SChris Kay
17873c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
1797f56e9a3SSoby Mathew				common/tf_log.c				\
1809d29c227SSoby Mathew				common/${ARCH}/debug.S			\
18191b48c9fSJulius Werner				drivers/console/multi_console.c		\
1829d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
1839d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
184c73686a1SBoyan Karatotev				lib/extensions/pmuv3/${ARCH}/pmuv3.c	\
185566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
1867f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
18775311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
1889d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
18961f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
190d7a6b0f8SRyan Harkin
1918620bd0bSChris Kayifeq ($($(ARCH)-cc-id),arm-clang)
1928422a840SAntonio Nino Diaz	BL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
1938422a840SAntonio Nino Diazendif
1948422a840SAntonio Nino Diaz
1951f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
1961f461979SJustin Chadwell	BL_COMMON_SOURCES	+=	plat/common/ubsan.c
1971f461979SJustin Chadwellendif
1981f461979SJustin Chadwell
19901d237cbSYann GautierINCLUDES		+=	-Iinclude				\
200f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
20109d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
20209d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
20309d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
20409d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
20509d40e0eSAntonio Nino Diaz
2069c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
2079c6d1c50SAntonio Nino Diaz
20873c99d4eSJuan Castillo################################################################################
2093547270fSGovindraj Raja# Generic definitions
2103547270fSGovindraj Raja################################################################################
2113547270fSGovindraj Raja
2123547270fSGovindraj Rajaifeq (${BUILD_BASE},)
2133547270fSGovindraj Raja     BUILD_BASE		:=	./build
2143547270fSGovindraj Rajaendif
2153547270fSGovindraj RajaBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
2163547270fSGovindraj Raja
2173547270fSGovindraj RajaSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
2183547270fSGovindraj Raja
2193547270fSGovindraj Raja# Platforms providing their own TBB makefile may override this value
2203547270fSGovindraj RajaINCLUDE_TBBR_MK		:=	1
2213547270fSGovindraj Raja
2223547270fSGovindraj Raja################################################################################
2233547270fSGovindraj Raja# Include SPD Makefile if one has been specified
2243547270fSGovindraj Raja################################################################################
2253547270fSGovindraj Raja
2263547270fSGovindraj Rajaifneq (${SPD},none)
2273547270fSGovindraj Raja	ifeq (${SPD},spmd)
2283547270fSGovindraj Raja	# SPMD is located in std_svc directory
2293547270fSGovindraj Raja		SPD_DIR := std_svc
2303547270fSGovindraj Raja
2313547270fSGovindraj Raja		ifeq ($(SPMD_SPM_AT_SEL2),1)
2323547270fSGovindraj Raja			CTX_INCLUDE_EL2_REGS := 1
2333547270fSGovindraj Raja		endif
2343547270fSGovindraj Raja
2353547270fSGovindraj Raja		ifneq ($(SP_LAYOUT_FILE),)
2363547270fSGovindraj Raja		BL2_ENABLE_SP_LOAD := 1
2373547270fSGovindraj Raja		endif
2383547270fSGovindraj Raja	else
2393547270fSGovindraj Raja		# All other SPDs in spd directory
2403547270fSGovindraj Raja		SPD_DIR := spd
2413547270fSGovindraj Raja	endif #(SPD)
2423547270fSGovindraj Raja
2433547270fSGovindraj Raja	# We expect to locate an spd.mk under the specified SPD directory
2443547270fSGovindraj Raja	SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
2453547270fSGovindraj Raja
2463547270fSGovindraj Raja	ifeq (${SPD_MAKE},)
2473547270fSGovindraj Raja                $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
2483547270fSGovindraj Raja	endif
2493547270fSGovindraj Raja        $(info Including ${SPD_MAKE})
2503547270fSGovindraj Raja        include ${SPD_MAKE}
2513547270fSGovindraj Raja
2523547270fSGovindraj Raja	# If there's BL32 companion for the chosen SPD, we expect that the SPD's
2533547270fSGovindraj Raja	# Makefile would set NEED_BL32 to "yes". In this case, the build system
2543547270fSGovindraj Raja	# supports two mutually exclusive options:
2553547270fSGovindraj Raja	# * BL32 is built from source: then BL32_SOURCES must contain the list
2563547270fSGovindraj Raja	#   of source files to build BL32
2573547270fSGovindraj Raja	# * BL32 is a prebuilt binary: then BL32 must point to the image file
2583547270fSGovindraj Raja	#   that will be included in the FIP
2593547270fSGovindraj Raja	# If both BL32_SOURCES and BL32 are defined, the binary takes precedence
2603547270fSGovindraj Raja	# over the sources.
2613547270fSGovindraj Rajaendif #(SPD=none)
2623547270fSGovindraj Raja
2633547270fSGovindraj Raja################################################################################
264696ed168SOlivier Deprez# Include the platform specific Makefile after the SPD Makefile (the platform
265696ed168SOlivier Deprez# makefile may use all previous definitions in this file)
266696ed168SOlivier Deprez################################################################################
267696ed168SOlivier Deprezinclude ${PLAT_MAKEFILE_FULL}
268696ed168SOlivier Deprez
269696ed168SOlivier Deprez################################################################################
2708d9f5f25SBoyan Karatotev# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
2718d9f5f25SBoyan Karatotev# platform.
2728d9f5f25SBoyan Karatotev################################################################################
2738d9f5f25SBoyan Karatotev
2748d9f5f25SBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
2758d9f5f25SBoyan Karatotev################################################################################
276f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set
277f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags
278f5211420SGovindraj Raja################################################################################
279f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0)
280f5211420SGovindraj Raja	# Default value turns off all types of branch protection
281f5211420SGovindraj Raja	BP_OPTION := none
282f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64)
283f5211420SGovindraj Raja        $(error BRANCH_PROTECTION requires AArch64)
284f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1)
285f5211420SGovindraj Raja	# Enables all types of branch protection features
286f5211420SGovindraj Raja	BP_OPTION := standard
287f5211420SGovindraj Raja	ENABLE_BTI := 1
288f5211420SGovindraj Raja	ENABLE_PAUTH := 1
289f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2)
290f5211420SGovindraj Raja	# Return address signing to its standard level
291f5211420SGovindraj Raja	BP_OPTION := pac-ret
292f5211420SGovindraj Raja	ENABLE_PAUTH := 1
293f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3)
294f5211420SGovindraj Raja	# Extend the signing to include leaf functions
295f5211420SGovindraj Raja	BP_OPTION := pac-ret+leaf
296f5211420SGovindraj Raja	ENABLE_PAUTH := 1
297f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4)
298f5211420SGovindraj Raja	# Turn on branch target identification mechanism
299f5211420SGovindraj Raja	BP_OPTION := bti
300f5211420SGovindraj Raja	ENABLE_BTI := 1
3018d9f5f25SBoyan Karatotevelse ifeq (${BRANCH_PROTECTION},5)
3028d9f5f25SBoyan Karatotev	# Turn on branch target identification mechanism
3038d9f5f25SBoyan Karatotev	BP_OPTION := standard
3048d9f5f25SBoyan Karatotev	ENABLE_BTI := 2
3058d9f5f25SBoyan Karatotev	ENABLE_PAUTH := 2
306f5211420SGovindraj Rajaelse
307f5211420SGovindraj Raja        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
308f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION)
309f5211420SGovindraj Raja
3108d9f5f25SBoyan Karatotevifneq ($(ENABLE_PAUTH),0)
3118d9f5f25SBoyan Karatotev	CTX_INCLUDE_PAUTH_REGS	:= ${ENABLE_PAUTH}
312f5211420SGovindraj Rajaendif
313f5211420SGovindraj Raja
314f5211420SGovindraj Raja# Pointer Authentication sources
3158d9f5f25SBoyan Karatotevifneq (${ENABLE_PAUTH},0)
316f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
317f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms
3188d9f5f25SBoyan Karatotev	BL_COMMON_SOURCES	+=	lib/extensions/pauth/pauth.c
319f5211420SGovindraj Rajaendif
320b14987cfSBoyan Karatotev#
321b14987cfSBoyan Karatotevifneq (${ENABLE_FEAT_PAUTH_LR},0)
322b14987cfSBoyan Karatotev# Currently, FEAT_PAUTH_LR is only supported by arm/clang compilers
323b14987cfSBoyan Karatotev# TODO implement for GCC when support is added
324b14987cfSBoyan Karatotevifeq ($($(ARCH)-cc-id),arm-clang)
325b14987cfSBoyan Karatotev	arch-features	:= $(arch-features)+pauth-lr
326b14987cfSBoyan Karatotevelse
327b14987cfSBoyan Karatotev	$(error Error: ENABLE_FEAT_PAUTH_LR not supported for GCC compiler)
328b14987cfSBoyan Karatotevendif
329b14987cfSBoyan Karatotevendif
330f5211420SGovindraj Raja
331f5211420SGovindraj Raja################################################################################
332f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME.
333f5211420SGovindraj Raja################################################################################
334f5211420SGovindraj Raja# FEAT_RME
335f5211420SGovindraj Rajaifeq (${ENABLE_RME},1)
336f5211420SGovindraj Raja	# RME requires el2 context to be saved for now.
337f5211420SGovindraj Raja	CTX_INCLUDE_EL2_REGS := 1
338f5211420SGovindraj Raja	CTX_INCLUDE_AARCH32_REGS := 0
339f5211420SGovindraj Raja	CTX_INCLUDE_PAUTH_REGS := 1
340f5211420SGovindraj Raja
341d048af0dSJavier Almansa Sobrino	ifneq ($(ENABLE_FEAT_MPAM), 0)
342d048af0dSJavier Almansa Sobrino		CTX_INCLUDE_MPAM_REGS := 1
343d048af0dSJavier Almansa Sobrino	endif
344d048af0dSJavier Almansa Sobrino
345f5211420SGovindraj Raja	# RME enables CSV2_2 extension by default.
346f5211420SGovindraj Raja	ENABLE_FEAT_CSV2_2 = 1
347f5211420SGovindraj Rajaendif #(FEAT_RME)
348f5211420SGovindraj Raja
349f5211420SGovindraj Raja################################################################################
3505b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled
3515b18de09SZelalem Aweke################################################################################
3525b18de09SZelalem Awekeifneq (${ENABLE_RME},0)
3535b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk
3545b18de09SZelalem Aweke$(warning "RME is an experimental feature")
3555b18de09SZelalem Awekeendif
3565b18de09SZelalem Aweke
3577e84f3cfSTushar Khandelwal################################################################################
35830655136SGovindraj Raja# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
35930655136SGovindraj Raja################################################################################
36030655136SGovindraj Rajaifneq (${ENABLE_FEAT_D128}, 0)
36130655136SGovindraj Raja        BL_COMMON_SOURCES       +=      lib/extensions/sysreg128/sysreg128.S
36230655136SGovindraj Rajaendif
36330655136SGovindraj Raja
36442d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios
36542d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios -
36642d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running
36742d4d3baSArvind Ram Prakash# BL2 in EL3
36842d4d3baSArvind Ram Prakash
36942d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1)
37042d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
37142d4d3baSArvind Ram Prakash	ifeq (${ENABLE_RME},1)
372c5e1da83SJayanth Dodderi Chidanand                $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
373c5e1da83SJayanth Dodderi Chidanand                supported at the moment.)
37442d4d3baSArvind Ram Prakash	endif
37542d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1)
37642d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	1
37742d4d3baSArvind Ram Prakashelse
37842d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	:=	0
37942d4d3baSArvind Ram Prakashendif
38042d4d3baSArvind Ram Prakash
381f87e54f7SManish Pandey# This internal flag is set to 1 when Firmware First handling of External aborts
382f87e54f7SManish Pandey# is required by lowe ELs. Currently only NS requires this support.
383f87e54f7SManish Pandeyifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
384f87e54f7SManish Pandey	FFH_SUPPORT := 1
385f87e54f7SManish Pandeyelse
386f87e54f7SManish Pandey	FFH_SUPPORT := 0
387f87e54f7SManish Pandeyendif
388f87e54f7SManish Pandey
38954035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
39054035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
39154035fc4SSandrine Bailleux# This can be overridden by the platform.
39273c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
3934f6ad66aSAchin Gupta
394a4409008Sdp-arm################################################################################
395a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
396a4409008Sdp-arm################################################################################
397c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32)
398c5e1da83SJayanth Dodderi Chidanand        NEED_BL32 := yes
399c5e1da83SJayanth Dodderi Chidanand
400a4409008Sdp-arm        ifneq (${AARCH32_SP},none)
401a4409008Sdp-arm        # We expect to locate an sp.mk under the specified AARCH32_SP directory
402a4409008Sdp-arm		AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
403a4409008Sdp-arm
404a4409008Sdp-arm                ifeq (${AARCH32_SP_MAKE},)
405a4409008Sdp-arm                        $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
406a4409008Sdp-arm                endif
407a4409008Sdp-arm                $(info Including ${AARCH32_SP_MAKE})
408a4409008Sdp-arm                include ${AARCH32_SP_MAKE}
409a4409008Sdp-arm        endif
410c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32)
4114f6ad66aSAchin Gupta
41273c99d4eSJuan Castillo################################################################################
41377f1f7a1SVarun Wadekar# Include libc if not overridden
41477f1f7a1SVarun Wadekar################################################################################
41577f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
41677f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
41777f1f7a1SVarun Wadekarendif
41877f1f7a1SVarun Wadekar
4195d893410SBoyan Karatotevifneq (${USE_GIC_DRIVER},0)
4205d893410SBoyan Karatotevinclude drivers/arm/gic/gic.mk
4215d893410SBoyan Karatotevendif
4225d893410SBoyan Karatotev
42377f1f7a1SVarun Wadekar################################################################################
424c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies
425cf2c8a33SAntonio Nino Diaz################################################################################
426b14987cfSBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}constraints.mk
427c5e1da83SJayanth Dodderi Chidanand
428c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the
429c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all
430c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0)
431c5e1da83SJayanth Dodderi Chidanand    FIP_DEPS += certificates
432c5e1da83SJayanth Dodderi Chidanand    FWU_FIP_DEPS += fwu_certificates
433d57362bdSXialin Liu    BL2_FIP_DEPS += bl2_certificates
434c5e1da83SJayanth Dodderi Chidanandendif
435c5e1da83SJayanth Dodderi Chidanand
436c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none)
437c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -f ${FW_ENC_STATUS}
438c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -k ${ENC_KEY}
439c5e1da83SJayanth Dodderi Chidanand	ENC_ARGS += -n ${ENC_NONCE}
440c5e1da83SJayanth Dodderi Chidanand	FIP_DEPS += enctool
441c5e1da83SJayanth Dodderi Chidanand	FWU_FIP_DEPS += enctool
442d57362bdSXialin Liu	BL2_FIP_DEPS += enctool
443c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
444c5e1da83SJayanth Dodderi Chidanand
4452bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
4462bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
4472bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
4482bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
4492bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
4502bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 3
4512bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
4522bf4f27fSManish V Badarkhe# Support hash calculation only
4532bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT := 2
4542bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1)
4552bf4f27fSManish V Badarkhe# Support authentication verification only
456c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 1
457c9c56f6eSManish V Badarkheelse
458c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT := 0
459c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
460c9c56f6eSManish V Badarkhe
461e4a070e3SManish V Badarkheifneq ($(filter 1 2 3,$(CRYPTO_SUPPORT)),)
462e4a070e3SManish V BadarkheCRYPTO_LIB := $(BUILD_PLAT)/lib/libmbedtls.a
463e4a070e3SManish V Badarkheendif
464e4a070e3SManish V Badarkhe
465cf2c8a33SAntonio Nino Diaz################################################################################
46673c99d4eSJuan Castillo# Process platform overrideable behaviour
46773c99d4eSJuan Castillo################################################################################
4684f6ad66aSAchin Gupta
4695f24ce96SManish Pandeyifdef BL1_SOURCES
4705f24ce96SManish Pandey	NEED_BL1 := yes
471c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES)
4725f24ce96SManish Pandey
4735f24ce96SManish Pandeyifdef BL2_SOURCES
4745f24ce96SManish Pandey	NEED_BL2 := yes
4755f24ce96SManish Pandey
476bd97f83aSJohn Tsichritzis	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
477bd97f83aSJohn Tsichritzis	# Certificate generation tools. This flag can be overridden by the platform.
478cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
479cf2c8a33SAntonio Nino Diaz		# If booting an EL3 payload there is no need for a BL33 image
480cf2c8a33SAntonio Nino Diaz		# in the FIP file.
4814c117f6cSSandrine Bailleux		NEED_BL33		:=	no
482cf2c8a33SAntonio Nino Diaz	else
48368450a6dSAntonio Nino Diaz		ifdef PRELOADED_BL33_BASE
484cf2c8a33SAntonio Nino Diaz			# If booting a BL33 preloaded image there is no need of
485cf2c8a33SAntonio Nino Diaz			# another one in the FIP file.
486cf2c8a33SAntonio Nino Diaz			NEED_BL33		:=	no
487cf2c8a33SAntonio Nino Diaz		else
488cf2c8a33SAntonio Nino Diaz			NEED_BL33		?=	yes
489cf2c8a33SAntonio Nino Diaz		endif
4904c117f6cSSandrine Bailleux	endif
491c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES)
4926f971622SJuan Castillo
4935f24ce96SManish Pandeyifdef BL2U_SOURCES
4945f24ce96SManish Pandey	NEED_BL2U := yes
495c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES)
4965f24ce96SManish Pandey
4974d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
4984d045d0eSMasahiro Yamadaifdef SCP_BL2
4994d045d0eSMasahiro Yamada	NEED_SCP_BL2		:=	yes
500c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2)
5014d045d0eSMasahiro Yamada
5025744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
5035744e874SSoby Mathewifneq (${ARCH},aarch32)
5045744e874SSoby Mathew	ifdef BL31_SOURCES
505c5e1da83SJayanth Dodderi Chidanand	# When booting an EL3 payload, there is no need to compile the BL31
506c5e1da83SJayanth Dodderi Chidanand	# image nor put it in the FIP.
5075744e874SSoby Mathew		ifndef EL3_PAYLOAD_BASE
5085744e874SSoby Mathew			NEED_BL31 := yes
5095744e874SSoby Mathew		endif
5105744e874SSoby Mathew	endif
511c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64)
5125744e874SSoby Mathew
51373c99d4eSJuan Castillo# Process TBB related flags
5146f971622SJuan Castilloifneq (${GENERATE_COT},0)
51573c99d4eSJuan Castillo    # Common cert_create options
5166f971622SJuan Castillo    ifneq (${CREATE_KEYS},0)
5176f971622SJuan Castillo        $(eval CRT_ARGS += -n)
5180191262dSYatharth Kochar        $(eval FWU_CRT_ARGS += -n)
519d57362bdSXialin Liu        $(eval BL2_CRT_ARGS += -n)
520fd34e7baSJuan Castillo        ifneq (${SAVE_KEYS},0)
521fd34e7baSJuan Castillo            $(eval CRT_ARGS += -k)
5220191262dSYatharth Kochar            $(eval FWU_CRT_ARGS += -k)
523d57362bdSXialin Liu            $(eval BL2_CRT_ARGS += -k)
524fd34e7baSJuan Castillo        endif
5256f971622SJuan Castillo    endif
52673c99d4eSJuan Castillo    # Include TBBR makefile (unless the platform indicates otherwise)
52773c99d4eSJuan Castillo    ifeq (${INCLUDE_TBBR_MK},1)
52873c99d4eSJuan Castillo        include make_helpers/tbbr/tbbr_tools.mk
52973c99d4eSJuan Castillo    endif
530c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
5316f971622SJuan Castillo
5321c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
5331c75d5dfSMasahiro Yamada	FIP_ARGS += --align ${FIP_ALIGN}
534c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN)
5351c75d5dfSMasahiro Yamada
5365f24ce96SManish Pandeyifdef FDT_SOURCES
5375f24ce96SManish Pandey	NEED_FDT := yes
538c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES)
5395f24ce96SManish Pandey
54073c99d4eSJuan Castillo################################################################################
54146e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
54246e5e035SMichalis Pappas################################################################################
54346e5e035SMichalis Pappas
54446e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
54546e5e035SMichalis Pappas
54646e5e035SMichalis Pappas################################################################################
5478a86052dSSoby Mathew# Include BL specific makefiles
5488a86052dSSoby Mathew################################################################################
5495f24ce96SManish Pandey
5505f24ce96SManish Pandeyifeq (${NEED_BL1},yes)
5518a86052dSSoby Mathewinclude bl1/bl1.mk
5528a86052dSSoby Mathewendif
5538a86052dSSoby Mathew
5545f24ce96SManish Pandeyifeq (${NEED_BL2},yes)
5558a86052dSSoby Mathewinclude bl2/bl2.mk
5568a86052dSSoby Mathewendif
5578a86052dSSoby Mathew
5585f24ce96SManish Pandeyifeq (${NEED_BL2U},yes)
5598a86052dSSoby Mathewinclude bl2u/bl2u.mk
5608a86052dSSoby Mathewendif
5618a86052dSSoby Mathew
5625744e874SSoby Mathewifeq (${NEED_BL31},yes)
5638a86052dSSoby Mathewinclude bl31/bl31.mk
5648a86052dSSoby Mathewendif
56503b397a8SNishanth Menon
56673c99d4eSJuan Castillo################################################################################
56773c99d4eSJuan Castillo# Build options checks
56873c99d4eSJuan Castillo################################################################################
56973c99d4eSJuan Castillo
570c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags
571327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
572327131c4SLeonardo Sandoval    $(sort \
573327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
57446789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
575327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
576327131c4SLeonardo Sandoval	CREATE_KEYS \
577327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
578327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
57942422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
580327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
5819acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
582327131c4SLeonardo Sandoval	DEBUG \
583327131c4SLeonardo Sandoval	DYN_DISABLE_AUTH \
584327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
5851fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
586873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
587327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
588327131c4SLeonardo Sandoval	ENABLE_PIE \
589327131c4SLeonardo Sandoval	ENABLE_PMF \
590327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
591327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
592dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
5930c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
5948cef63d6SBoyan Karatotev	ENABLE_FEAT_GCIE \
595970a4a8dSManish Pandey	ENABLE_FEAT_RAS	\
596f87e54f7SManish Pandey	FFH_SUPPORT	\
597327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
598327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
599327131c4SLeonardo Sandoval	GENERATE_COT \
600327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
60146cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
602538516f5SBipin Ravi	HARDEN_SLS \
603327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
604327131c4SLeonardo Sandoval	MEASURED_BOOT \
60536e3d877SAbhi.Singh	DISCRETE_TPM \
606e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
6076a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
6082132c707SSona Mathew	RMMD_ENABLE_IDE_KEY_PROG \
60900e28874SManish V Badarkhe	DRTM_SUPPORT \
610327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
611327131c4SLeonardo Sandoval	OVERRIDE_LIBC \
612327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
6135be66449SBoyan Karatotev	PLAT_EXTRA_LD_SCRIPT \
614327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
615327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
61664b4710bSWing Li	PSCI_OS_INIT_MODE \
6178db17052SBoyan Karatotev	ARCH_FEATURE_AVAILABILITY \
618327131c4SLeonardo Sandoval	RESET_TO_BL31 \
619327131c4SLeonardo Sandoval	SAVE_KEYS \
620327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
62196a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
622327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
62386acbbe2SYe Li	SEPARATE_RWDATA_REGION \
624308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
625327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
626327131c4SLeonardo Sandoval	SPM_MM \
6271d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
628801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
629327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
630890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
6313ba2c151SRaymond Mao	TRANSFER_LIST \
632327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
633327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
634327131c4SLeonardo Sandoval	USE_DEBUGFS \
635291e493dSHarrison Mutai	USE_KERNEL_DT_CONVENTION \
636327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
637327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
638327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
639327131c4SLeonardo Sandoval	USE_ROMLIB \
640327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
641327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
64242d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
643327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
644327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
645327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
646327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
647327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
648327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
64945c7328cSBoyan Karatotev	ERRATA_SME_POWER_DOWN \
65000e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
651327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
652327131c4SLeonardo Sandoval	USE_SP804_TIMER \
653396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
65411d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
65568120783SChris Kay	ENABLE_MPMM \
6566a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
6570b22e591SJayanth Dodderi Chidanand	TRNG_SUPPORT \
658593ae354SBoyan Karatotev	ENABLE_ERRATA_ALL \
659ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
660ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
66104c7303bSOkash Khawaja	CONDITIONAL_CMO \
6625782b890SManish V Badarkhe	PSA_CRYPTO	\
66385bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
664183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
665bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
666ae770fedSYann Gautier	EARLY_CONSOLE \
667f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
6688953568aSLevi Yun	HOB_LIST \
669cf48f49fSManish V Badarkhe	LFA_SUPPORT \
670327131c4SLeonardo Sandoval)))
67173c99d4eSJuan Castillo
672c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags
673327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
674327131c4SLeonardo Sandoval    $(sort \
675327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
676327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
677327131c4SLeonardo Sandoval	BRANCH_PROTECTION \
6786a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_PAUTH_REGS \
6796a0da736SJayanth Dodderi Chidanand	CTX_INCLUDE_NEVE_REGS \
6802bf4f27fSManish V Badarkhe	CRYPTO_SUPPORT \
68183a4dae1SBoyan Karatotev	DISABLE_MTPMU \
6821298f2f1SJayanth Dodderi Chidanand	ENABLE_BRBE_FOR_NS \
68347c681b7SJayanth Dodderi Chidanand	ENABLE_TRBE_FOR_NS \
6846a0da736SJayanth Dodderi Chidanand	ENABLE_BTI \
6856a0da736SJayanth Dodderi Chidanand	ENABLE_PAUTH \
686025b1b81SJohn Powell	ENABLE_FEAT_PAUTH_LR \
687cc2523bbSAndre Przywara	ENABLE_FEAT_AIE \
688d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
6896a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
690a1032bebSJohn Powell	ENABLE_FEAT_CPA2 \
6916a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
69230019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
69383271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
6946a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_DIT \
6956a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
6966a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
69733e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
6984274b526SArvind Ram Prakash	ENABLE_FEAT_FGWTE3 \
699a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
7006a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_HCX \
70119d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
7027e84f3cfSTushar Khandelwal	ENABLE_FEAT_MEC \
7036b8df7b9SArvind Ram Prakash	ENABLE_FEAT_MOPS \
7048e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
7056a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
706*b3bcfd12SAndre Przywara	ENABLE_FEAT_PFAR \
7076a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_RNG \
708ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
7096a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
710d3331603SMark Brown	ENABLE_FEAT_TCR2 \
7116d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
7120e4daed2SGovindraj Raja	ENABLE_FEAT_SB \
713062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
714062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
715062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
716062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
7174ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
71830655136SGovindraj Raja	ENABLE_FEAT_D128 \
719688ab57bSMark Brown	ENABLE_FEAT_GCS \
7206a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
721edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
722c42aefd3SArvind Ram Prakash	ENABLE_FEAT_MPAM_PE_BW_CTRL \
7236a0da736SJayanth Dodderi Chidanand	ENABLE_RME \
7246437a09aSAndre Przywara	ENABLE_SPE_FOR_NS \
725603a0c6fSAndre Przywara	ENABLE_SYS_REG_TRACE_FOR_NS \
72645007acdSJayanth Dodderi Chidanand	ENABLE_SME_FOR_NS \
72703d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
7282b0bc4e0SJayanth Dodderi Chidanand	ENABLE_SVE_FOR_NS \
7296a0da736SJayanth Dodderi Chidanand	ENABLE_TRF_FOR_NS \
730327131c4SLeonardo Sandoval	FW_ENC_STATUS \
7315357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
7325357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
733781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
734781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
735bebcf27fSMark Brown	SVE_VECTOR_LEN \
7360ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
737ee580c2dSBoyan Karatotev	W \
738327131c4SLeonardo Sandoval)))
739c877b414SJeenu Viswambharan
740aacff749SJustin Chadwellifdef KEY_SIZE
741aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
742aacff749SJustin Chadwellendif
743aacff749SJustin Chadwell
7441f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
7451f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
7461f461979SJustin Chadwellendif
7471f461979SJustin Chadwell
74873c99d4eSJuan Castillo################################################################################
74973c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
75073c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
75173c99d4eSJuan Castillo# platform to overwrite the default options
75273c99d4eSJuan Castillo################################################################################
75373c99d4eSJuan Castillo
754327131c4SLeonardo Sandoval$(eval $(call add_defines,\
755327131c4SLeonardo Sandoval    $(sort \
756327131c4SLeonardo Sandoval	ALLOW_RO_XLAT_TABLES \
757327131c4SLeonardo Sandoval	ARM_ARCH_MAJOR \
758327131c4SLeonardo Sandoval	ARM_ARCH_MINOR \
75946789a7cSBalint Dobszay	BL2_ENABLE_SP_LOAD \
760327131c4SLeonardo Sandoval	COLD_BOOT_SINGLE_CPU \
761327131c4SLeonardo Sandoval	CTX_INCLUDE_AARCH32_REGS \
762327131c4SLeonardo Sandoval	CTX_INCLUDE_FPREGS \
76342422622SMadhukar Pappireddy	CTX_INCLUDE_SVE_REGS \
764327131c4SLeonardo Sandoval	CTX_INCLUDE_PAUTH_REGS \
7659acff28aSArvind Ram Prakash	CTX_INCLUDE_MPAM_REGS \
766327131c4SLeonardo Sandoval	EL3_EXCEPTION_HANDLING \
767327131c4SLeonardo Sandoval	CTX_INCLUDE_EL2_REGS \
768062f8aafSArunachalam Ganapathy	CTX_INCLUDE_NEVE_REGS \
769ee580c2dSBoyan Karatotev	DEBUG \
770327131c4SLeonardo Sandoval	DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
7710063dd17SJavier Almansa Sobrino	DISABLE_MTPMU \
772d23acc9eSAndre Przywara	ENABLE_FEAT_AMU \
7731fd685a7SChris Kay	ENABLE_AMU_AUXILIARY_COUNTERS \
774873d4241Sjohpow01	AMU_RESTRICT_COUNTERS \
775327131c4SLeonardo Sandoval	ENABLE_ASSERTIONS \
776327131c4SLeonardo Sandoval	ENABLE_BTI \
77783271d5aSArvind Ram Prakash	ENABLE_FEAT_DEBUGV8P9 \
778edebefbcSArvind Ram Prakash	ENABLE_FEAT_MPAM \
779c42aefd3SArvind Ram Prakash	ENABLE_FEAT_MPAM_PE_BW_CTRL \
780327131c4SLeonardo Sandoval	ENABLE_PAUTH \
781025b1b81SJohn Powell	ENABLE_FEAT_PAUTH_LR \
782327131c4SLeonardo Sandoval	ENABLE_PIE \
783327131c4SLeonardo Sandoval	ENABLE_PMF \
784327131c4SLeonardo Sandoval	ENABLE_PSCI_STAT \
7855b18de09SZelalem Aweke	ENABLE_RME \
7866a88ec8bSRaghu Krishnamurthy	RMMD_ENABLE_EL3_TOKEN_SIGN \
7872132c707SSona Mathew	RMMD_ENABLE_IDE_KEY_PROG \
788327131c4SLeonardo Sandoval	ENABLE_RUNTIME_INSTRUMENTATION \
789dc78e62dSjohpow01	ENABLE_SME_FOR_NS \
79003d3c0d7SJayanth Dodderi Chidanand	ENABLE_SME2_FOR_NS \
791dc78e62dSjohpow01	ENABLE_SME_FOR_SWD \
79290118bb5SAndre Przywara	ENABLE_SPE_FOR_NS \
793327131c4SLeonardo Sandoval	ENABLE_SVE_FOR_NS \
7940c5e7d1cSMax Shvetsov	ENABLE_SVE_FOR_SWD \
795970a4a8dSManish Pandey	ENABLE_FEAT_RAS \
796f87e54f7SManish Pandey	FFH_SUPPORT \
797327131c4SLeonardo Sandoval	ENCRYPT_BL31 \
798327131c4SLeonardo Sandoval	ENCRYPT_BL32 \
799327131c4SLeonardo Sandoval	ERROR_DEPRECATED \
800327131c4SLeonardo Sandoval	FAULT_INJECTION_SUPPORT \
801327131c4SLeonardo Sandoval	GICV2_G0_FOR_EL3 \
80246cc41d5SManish Pandey	HANDLE_EA_EL3_FIRST_NS \
803327131c4SLeonardo Sandoval	HW_ASSISTED_COHERENCY \
804327131c4SLeonardo Sandoval	LOG_LEVEL \
805327131c4SLeonardo Sandoval	MEASURED_BOOT \
80636e3d877SAbhi.Singh	DISCRETE_TPM \
807e7f1181fSTamas Ban	DICE_PROTECTION_ENVIRONMENT \
80800e28874SManish V Badarkhe	DRTM_SUPPORT \
809327131c4SLeonardo Sandoval	NS_TIMER_SWITCH \
810327131c4SLeonardo Sandoval	PL011_GENERIC_UART \
8115be66449SBoyan Karatotev	PLAT_EXTRA_LD_SCRIPT \
812327131c4SLeonardo Sandoval	PLAT_${PLAT} \
813327131c4SLeonardo Sandoval	PROGRAMMABLE_RESET_ADDRESS \
814327131c4SLeonardo Sandoval	PSCI_EXTENDED_STATE_ID \
81564b4710bSWing Li	PSCI_OS_INIT_MODE \
8168db17052SBoyan Karatotev	ARCH_FEATURE_AVAILABILITY \
817327131c4SLeonardo Sandoval	RESET_TO_BL31 \
818d766084fSAlexeiFedorov	RME_GPT_BITLOCK_BLOCK \
819ec0088bbSAlexeiFedorov	RME_GPT_MAX_BLOCK \
820327131c4SLeonardo Sandoval	SEPARATE_CODE_AND_RODATA \
8215ce4ee1aSXialin Liu	SEPARATE_BL2_FIP \
82296a8ed14SJiafei Pan	SEPARATE_BL2_NOLOAD_REGION \
823327131c4SLeonardo Sandoval	SEPARATE_NOBITS_REGION \
82486acbbe2SYe Li	SEPARATE_RWDATA_REGION \
825308ebfa1SMadhukar Pappireddy	SEPARATE_SIMD_SECTION \
826327131c4SLeonardo Sandoval	RECLAIM_INIT_CODE \
827327131c4SLeonardo Sandoval	SPD_${SPD} \
828327131c4SLeonardo Sandoval	SPIN_ON_BL1_EXIT \
829327131c4SLeonardo Sandoval	SPM_MM \
8301d63ae4dSMarc Bonnici	SPMC_AT_EL3 \
831801cd3c8SNishant Sharma	SPMC_AT_EL3_SEL0_SP \
832327131c4SLeonardo Sandoval	SPMD_SPM_AT_SEL2 \
8333ba2c151SRaymond Mao	TRANSFER_LIST \
834327131c4SLeonardo Sandoval	TRUSTED_BOARD_BOOT \
835c9c56f6eSManish V Badarkhe	CRYPTO_SUPPORT \
8367dfb9911SJimmy Brisson	TRNG_SUPPORT \
837ffea3844SSona Mathew	ERRATA_ABI_SUPPORT \
838ef63f5beSSona Mathew	ERRATA_NON_ARM_INTERCONNECT \
839327131c4SLeonardo Sandoval	USE_COHERENT_MEM \
840327131c4SLeonardo Sandoval	USE_DEBUGFS \
841327131c4SLeonardo Sandoval	ARM_IO_IN_DTB \
842327131c4SLeonardo Sandoval	SDEI_IN_FCONF \
843327131c4SLeonardo Sandoval	SEC_INT_DESC_IN_FCONF \
844327131c4SLeonardo Sandoval	USE_ROMLIB \
845327131c4SLeonardo Sandoval	USE_TBBR_DEFS \
846291e493dSHarrison Mutai	USE_KERNEL_DT_CONVENTION \
847327131c4SLeonardo Sandoval	WARMBOOT_ENABLE_DCACHE_EARLY \
84842d4d3baSArvind Ram Prakash	RESET_TO_BL2 \
84942d4d3baSArvind Ram Prakash	BL2_RUNS_AT_EL3	\
850327131c4SLeonardo Sandoval	BL2_IN_XIP_MEM \
851327131c4SLeonardo Sandoval	BL2_INV_DCACHE \
852327131c4SLeonardo Sandoval	USE_SPINLOCK_CAS \
853327131c4SLeonardo Sandoval	ERRATA_SPECULATIVE_AT \
85445c7328cSBoyan Karatotev	ERRATA_SME_POWER_DOWN \
85500e8f79cSManish Pandey	RAS_TRAP_NS_ERR_REC_ACCESS \
856327131c4SLeonardo Sandoval	COT_DESC_IN_DTB \
857327131c4SLeonardo Sandoval	USE_SP804_TIMER \
85812cd65e0STomas Pilar	ENABLE_FEAT_RNG \
859ff86e0b4SJuan Pablo Conde	ENABLE_FEAT_RNG_TRAP \
8604e04478aSChris Kay	ENABLE_FEAT_SB \
8617d33ffe4SDaniel Boulby	ENABLE_FEAT_DIT \
8625357f83dSManish V Badarkhe	NR_OF_FW_BANKS \
8635357f83dSManish V Badarkhe	NR_OF_IMAGES_IN_FW_BANK \
864396b339dSManish V Badarkhe	PSA_FWU_SUPPORT \
86511d05a77SSughosh Ganu	PSA_FWU_METADATA_FW_STORE_DESC \
866744ad974Sjohpow01	ENABLE_BRBE_FOR_NS \
867813524eaSManish V Badarkhe	ENABLE_TRBE_FOR_NS \
868d4582d30SManish V Badarkhe	ENABLE_SYS_REG_TRACE_FOR_NS \
8698fcd3d96SManish V Badarkhe	ENABLE_TRF_FOR_NS \
870cc2523bbSAndre Przywara	ENABLE_FEAT_AIE \
871cb4ec47bSjohpow01	ENABLE_FEAT_HCX \
87268120783SChris Kay	ENABLE_MPMM \
873f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_FGT \
87433e6aaacSArvind Ram Prakash	ENABLE_FEAT_FGT2 \
8754274b526SArvind Ram Prakash	ENABLE_FEAT_FGWTE3 \
876a57e18e4SArvind Ram Prakash	ENABLE_FEAT_FPMR \
877f74cb0beSJayanth Dodderi Chidanand	ENABLE_FEAT_ECV \
8786a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_AMUv1p1 \
8796a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_SEL2 \
8806a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_VHE \
881a1032bebSJohn Powell	ENABLE_FEAT_CPA2 \
8826a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_CSV2_2 \
88330019d86SSona Mathew	ENABLE_FEAT_CSV2_3 \
88419d52a83SAndre Przywara	ENABLE_FEAT_LS64_ACCDATA \
8857e84f3cfSTushar Khandelwal	ENABLE_FEAT_MEC \
8866a0da736SJayanth Dodderi Chidanand	ENABLE_FEAT_PAN \
887d3331603SMark Brown	ENABLE_FEAT_TCR2 \
8886d0433f0SJayanth Dodderi Chidanand	ENABLE_FEAT_THE \
889062b6c6bSMark Brown	ENABLE_FEAT_S2PIE \
890062b6c6bSMark Brown	ENABLE_FEAT_S1PIE \
891062b6c6bSMark Brown	ENABLE_FEAT_S2POE \
892062b6c6bSMark Brown	ENABLE_FEAT_S1POE \
8934ec4e545SJayanth Dodderi Chidanand	ENABLE_FEAT_SCTLR2 \
89430655136SGovindraj Raja	ENABLE_FEAT_D128 \
895688ab57bSMark Brown	ENABLE_FEAT_GCS \
8966b8df7b9SArvind Ram Prakash	ENABLE_FEAT_MOPS \
8978cef63d6SBoyan Karatotev	ENABLE_FEAT_GCIE \
8988e397889SGovindraj Raja	ENABLE_FEAT_MTE2 \
899*b3bcfd12SAndre Przywara	ENABLE_FEAT_PFAR \
9006a0da736SJayanth Dodderi Chidanand	FEATURE_DETECTION \
901781d07a4SJayanth Dodderi Chidanand	TWED_DELAY \
902781d07a4SJayanth Dodderi Chidanand	ENABLE_FEAT_TWED \
90304c7303bSOkash Khawaja	CONDITIONAL_CMO \
9040ed3be6fSVarun Wadekar	IMPDEF_SYSREG_TRAP \
905a8cf6faeSJayanth Dodderi Chidanand	SVE_VECTOR_LEN \
906890b5088SRaghu Krishnamurthy	ENABLE_SPMD_LP \
9075782b890SManish V Badarkhe	PSA_CRYPTO	\
90885bebe18SSandrine Bailleux	ENABLE_CONSOLE_GETC \
909183329a5SArvind Ram Prakash	INIT_UNUSED_NS_EL2	\
910bfef8b90SJuan Pablo Conde	PLATFORM_REPORT_CTX_MEM_USE \
911ae770fedSYann Gautier	EARLY_CONSOLE \
912f99a69c3SArvind Ram Prakash	PRESERVE_DSU_PMU_REGS \
9138953568aSLevi Yun	HOB_LIST \
9142f5fd826SHarrison Mutai	HW_CONFIG_BASE \
915cf48f49fSManish V Badarkhe	LFA_SUPPORT \
916327131c4SLeonardo Sandoval)))
9172fae4b1eSJeenu Viswambharan
918bfef8b90SJuan Pablo Condeifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
919bfef8b90SJuan Pablo Condeifeq (${DEBUG}, 0)
920bfef8b90SJuan Pablo Conde        $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
921bfef8b90SJuan Pablo Conde        override PLATFORM_REPORT_CTX_MEM_USE := 0
922bfef8b90SJuan Pablo Condeendif
923bfef8b90SJuan Pablo Condeendif
924bfef8b90SJuan Pablo Conde
9251f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
9261f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
927c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB)
9281f461979SJustin Chadwell
9294c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
9304c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
9314c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
932cf2c8a33SAntonio Nino Diazelse
93368450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and
93468450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority.
93568450a6dSAntonio Nino Diaz	ifdef PRELOADED_BL33_BASE
93668450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
9374c117f6cSSandrine Bailleux	endif
938c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE)
93973c99d4eSJuan Castillo
940209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
941209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
942209a60ccSSoby Mathew        $(eval $(call add_define,DYN_DISABLE_AUTH))
943209a60ccSSoby Mathewendif
944209a60ccSSoby Mathew
9458620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link)
946c2ad38ceSVarun Wadekar        $(eval $(call add_define,USE_ARM_LINK))
947c2ad38ceSVarun Wadekarendif
948c2ad38ceSVarun Wadekar
949ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
950ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
951c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
952ce2b1ec6SManish Pandey	-include $(BUILD_PLAT)/sp_gen.mk
953ce2b1ec6SManish Pandey	FIP_DEPS += sp
95407c44475SManish Pandey	CRT_DEPS += sp
955ce2b1ec6SManish Pandey	NEED_SP_PKG := yes
956ce2b1ec6SManish Pandeyelse
957c33ff198SOlivier Deprez	ifeq (${SPMD_SPM_AT_SEL2},1)
958c33ff198SOlivier Deprez                $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
959c33ff198SOlivier Deprez	endif
960c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE)
961c5e1da83SJayanth Dodderi Chidanandendif #(SPD)
962ce2b1ec6SManish Pandey
96373c99d4eSJuan Castillo################################################################################
9643df79ae7SBoyan Karatotev# Configure the flags for the specified compiler and linker
9653df79ae7SBoyan Karatotev################################################################################
9663df79ae7SBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}cflags.mk
9673df79ae7SBoyan Karatotev
9683df79ae7SBoyan Karatotev################################################################################
96973c99d4eSJuan Castillo# Build targets
97073c99d4eSJuan Castillo################################################################################
97173c99d4eSJuan Castillo
9722329e22bSHarrison Mutai.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
97373c99d4eSJuan Castillo
97473c99d4eSJuan Castilloall: msg_start
97573c99d4eSJuan Castillo
97673c99d4eSJuan Castillomsg_start:
9777c4e1eeaSChris Kay	$(s)echo "Building ${PLAT}"
97873c99d4eSJuan Castillo
97961f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
9805fee0287SRoberto Vargas
98173c99d4eSJuan Castillo# Expand build macros for the different images
98273c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
983b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES})
984434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1))
985c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1)
98673c99d4eSJuan Castillo
98773c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
988c5e1da83SJayanth Dodderi Chidanand
98942d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0)
990c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
991c9b31ae8SRoberto Vargasendif
992c9b31ae8SRoberto Vargas
993eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES})
994eb1acfb6SChris Kay
995d57362bdSXialin Liuifeq (${SEPARATE_BL2_FIP},1)
996d57362bdSXialin Liu$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS},BL2_)), \
997d57362bdSXialin Liu	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS},BL2_)))
998d57362bdSXialin Liuelse
99933950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})), \
1000434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1001d57362bdSXialin Liuendif #(SEPARATE_BL2_FIP)
1002c5e1da83SJayanth Dodderi Chidanand
1003c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2)
100473c99d4eSJuan Castillo
10054d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
100633950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1007c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2)
10084d045d0eSMasahiro Yamada
100973c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
101073c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
101126d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
101226d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1013c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1014c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1015434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1016c6ba9b45SSumit Gargelse
101733950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1018434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw)))
1019c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1020c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31)
102173c99d4eSJuan Castillo
102270d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1023c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
102470d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
102573c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
102626d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
102726d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
10289cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
10299cd15239SMasahiro Yamada
1030c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1031434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1032c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1033c6ba9b45SSumit Gargelse
1034434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
103533950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1036c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT)
1037c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32)
103873c99d4eSJuan Castillo
10395b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
10405b18de09SZelalem Aweke# needs to be built from RMM_SOURCES.
10415b18de09SZelalem Awekeifeq (${NEED_RMM},yes)
10425b18de09SZelalem Aweke# Sort RMM source files to remove duplicates
10435b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES})
10445b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
10455b18de09SZelalem Aweke
10465b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
10475b18de09SZelalem Aweke	 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1048c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM)
10495b18de09SZelalem Aweke
105073c99d4eSJuan Castillo# Add the BL33 image if required by the platform
105173c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
105233950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1053c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33)
1054db6071c9SJuan Castillo
10559003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
105633950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1057434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1058c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U)
10599003fa0bSYatharth Kochar
106003b397a8SNishanth Menon# Expand build macros for the different images
106103b397a8SNishanth Menonifeq (${NEED_FDT},yes)
106203b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
10631c08ff32SSalman Nabi
10641c08ff32SSalman Nabi    ifneq (${INITRD_SIZE}${INITRD_PATH},)
10651c08ff32SSalman Nabi        ifndef INITRD_BASE
10661c08ff32SSalman Nabi            $(error INITRD_BASE must be set when inserting initrd properties to the DTB.)
10671c08ff32SSalman Nabi        endif
10681c08ff32SSalman Nabi
10691c08ff32SSalman Nabi        INITRD_SIZE ?= $(shell printf "0x%x\n" $$(stat -Lc %s $(INITRD_PATH)))
10701c08ff32SSalman Nabi        initrd_end = $(shell printf "0x%x\n" $$(expr $$(($(INITRD_BASE) + $(INITRD_SIZE)))))
10711c08ff32SSalman Nabi
10721c08ff32SSalman Nabi        define $(HW_CONFIG)-after +=
10731c08ff32SSalman Nabi            $(s)echo "  INITRD  $(HW_CONFIG)"
10741c08ff32SSalman Nabi            $(q)fdtput -t x $@ /chosen linux,initrd-start $(INITRD_BASE)
10751c08ff32SSalman Nabi            $(q)fdtput -t x $@ /chosen linux,initrd-end $(initrd_end)
10761c08ff32SSalman Nabi        endef
10771c08ff32SSalman Nabi    endif
1078c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT)
107903b397a8SNishanth Menon
1080ce2b1ec6SManish Pandey# Add Secure Partition packages
1081ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1082fd74ca0dSChris Kay$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
1083679e27ceSChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
1084dd816235SKathleen Capella	$(q)$(if $(host-poetry),poetry run )${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
1085822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
10867c4e1eeaSChris Kay	$(s)echo
10877c4e1eeaSChris Kay	$(s)echo "Built SP Images successfully"
10887c4e1eeaSChris Kay	$(s)echo
1089c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG)
1090ce2b1ec6SManish Pandey
109136eaaf37SIan Spraylocate-checkpatch:
109236eaaf37SIan Sprayifndef CHECKPATCH
109366079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
109436eaaf37SIan Sprayelse
109536eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
109666079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
109736eaaf37SIan Sprayendif
1098c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH)
109936eaaf37SIan Spray
11004f6ad66aSAchin Guptaclean:
11017c4e1eeaSChris Kay	$(s)echo "  CLEAN"
1102c3273703SChris Kay	$(q)rm -rf $(BUILD_PLAT)
1103cbd6cec3SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean
1104cbd6cec3SBoyan Karatotev	$(q)rm -rf ${FIPTOOLPATH}/fiptool
1105f4595e6eSBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1106f4595e6eSBoyan Karatotev	$(q)rm -rf ${CRTTOOLPATH}/cert_create
110796fbe884SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
11087c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11094f6ad66aSAchin Gupta
1110eaaeece2SJames Morrisseyrealclean distclean:
11117c4e1eeaSChris Kay	$(s)echo "  REALCLEAN"
1112c3273703SChris Kay	$(q)rm -rf $(BUILD_BASE)
1113c3273703SChris Kay	$(q)rm -rf $(CURDIR)/cscope.*
1114cbd6cec3SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean
1115cbd6cec3SBoyan Karatotev	$(q)rm -rf ${FIPTOOLPATH}/fiptool
1116f4595e6eSBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1117f4595e6eSBoyan Karatotev	$(q)rm -rf ${CRTTOOLPATH}/cert_create
111896fbe884SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
11197c4e1eeaSChris Kay	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11204f6ad66aSAchin Gupta
112136eaaf37SIan Spraycheckcodebase:		locate-checkpatch
11227c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
11237c4e1eeaSChris Kay	$(q)if test -d .git ; then						\
11241ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
11251a41e8c1SDan Handley		while read GIT_FILE ;					\
11261a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
11271a41e8c1SDan Handley		done ;							\
112836eaaf37SIan Spray	else								\
11291a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
11301a41e8c1SDan Handley		 -not -iwholename "*build*"				\
11311a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
113261f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
11331a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
11341ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
11351a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
113636eaaf37SIan Spray	fi
113736eaaf37SIan Spray
113836eaaf37SIan Spraycheckpatch:		locate-checkpatch
11397c4e1eeaSChris Kay	$(s)echo "  CHECKING STYLE"
11407c4e1eeaSChris Kay	$(q)if test -n "${CHECKPATCH_OPTS}"; then				\
114102a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
114202a76d5fSYann Gautier	fi
11437c4e1eeaSChris Kay	$(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
114477a0a7f1SYann Gautier	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
114577a0a7f1SYann Gautier	do								\
114651d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
11471a721748SYann Gautier		( git log --format=email "$$commit~..$$commit"		\
11481a721748SYann Gautier			-- ${CHECK_PATHS} ;				\
114951d28937SAntonio Nino Diaz		  git diff --format=email "$$commit~..$$commit"		\
11501a721748SYann Gautier			-- ${CHECK_PATHS}; ) |				\
115102a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
115251d28937SAntonio Nino Diaz	done
115336eaaf37SIan Spray
115473c99d4eSJuan Castillocerttool: ${CRTTOOL}
115573c99d4eSJuan Castillo
1156774fb379SBoyan Karatotev${CRTTOOL}: FORCE | $$(@D)/
1157f4595e6eSBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all
1158f4595e6eSBoyan Karatotev	$(q)ln -sf ${CRTTOOL} ${CRTTOOLPATH}/cert_create
11597c4e1eeaSChris Kay	$(s)echo
11607c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
11617c4e1eeaSChris Kay	$(s)echo
11626f971622SJuan Castillo
11636f971622SJuan Castilloifneq (${GENERATE_COT},0)
1164f02135a3SFabien Lehousselcertificates: ${CRT_DEPS} ${CRTTOOL} ${DTBS}
11657c4e1eeaSChris Kay	$(q)${CRTTOOL} ${CRT_ARGS}
11667c4e1eeaSChris Kay	$(s)echo
11677c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
11687c4e1eeaSChris Kay	$(s)echo "Certificates can be found in ${BUILD_PLAT}"
11697c4e1eeaSChris Kay	$(s)echo
1170c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
117127713fb4SSoby Mathew
1172d57362bdSXialin Liuifeq (${SEPARATE_BL2_FIP},1)
1173774fb379SBoyan Karatotev${BUILD_PLAT}/${BL2_FIP_NAME}: ${BL2_FIP_DEPS} ${FIPTOOL} | $$(@D)/
1174d57362bdSXialin Liu	$(eval ${CHECK_BL2_FIP_CMD})
1175d57362bdSXialin Liu	$(q)${FIPTOOL} create ${BL2_FIP_ARGS} $@
1176d57362bdSXialin Liu	$(q)${FIPTOOL} info $@
1177d57362bdSXialin Liu	$(s)echo
1178d57362bdSXialin Liu	$(s)echo "Built $@ successfully"
1179d57362bdSXialin Liu	$(s)echo
1180d57362bdSXialin Liuendif #(SEPARATE_BL2_FIP)
1181d57362bdSXialin Liu
1182774fb379SBoyan Karatotev${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} | $$(@D)/
11834727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
11847c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FIP_ARGS} $@
11857c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
11867c4e1eeaSChris Kay	$(s)echo
11877c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
11887c4e1eeaSChris Kay	$(s)echo
1189f58ad36fSHarry Liebel
11900191262dSYatharth Kocharifneq (${GENERATE_COT},0)
11910191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
11927c4e1eeaSChris Kay	$(q)${CRTTOOL} ${FWU_CRT_ARGS}
11937c4e1eeaSChris Kay	$(s)echo
11947c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
11957c4e1eeaSChris Kay	$(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
11967c4e1eeaSChris Kay	$(s)echo
1197c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT)
11980191262dSYatharth Kochar
1199d57362bdSXialin Liuifneq (${GENERATE_COT},0)
1200774fb379SBoyan Karatotevbl2_certificates: ${BUILD_PLAT}/${FIP_NAME} ${BL2_CRT_DEPS} ${CRTTOOL} | ${BUILD_PLAT}/
1201d57362bdSXialin Liu	$(q)${CRTTOOL} ${BL2_CRT_ARGS}
1202d57362bdSXialin Liu	$(s)echo
1203d57362bdSXialin Liu	$(s)echo "Built $@ successfully"
1204d57362bdSXialin Liu	$(s)echo "BL2 certificates can be found in ${BUILD_PLAT}"
1205d57362bdSXialin Liu	$(s)echo
1206d57362bdSXialin Liuendif #(GENERATE_COT)
1207d57362bdSXialin Liu
1208774fb379SBoyan Karatotev${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} | $$(@D)/
12094727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
12107c4e1eeaSChris Kay	$(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
12117c4e1eeaSChris Kay	$(q)${FIPTOOL} info $@
12127c4e1eeaSChris Kay	$(s)echo
12137c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
12147c4e1eeaSChris Kay	$(s)echo
12150191262dSYatharth Kochar
121673c99d4eSJuan Castillofiptool: ${FIPTOOL}
1217d57362bdSXialin Liuifeq (${SEPARATE_BL2_FIP},1)
1218d57362bdSXialin Liubl2_fip: ${BUILD_PLAT}/${BL2_FIP_NAME}
1219d57362bdSXialin Liufip: bl2_fip
1220d57362bdSXialin Liuelse
122173c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
1222d57362bdSXialin Liuendif #(SEPARATE_BL2_FIP)
12230191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
122473c99d4eSJuan Castillo
1225cbd6cec3SBoyan Karatotev# symlink for compatibility before tools were in the build directory
1226774fb379SBoyan Karatotev${FIPTOOL}: FORCE | $$(@D)/
1227cbd6cec3SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
1228cbd6cec3SBoyan Karatotev	$(q)ln -sf ${FIPTOOL} ${FIPTOOLPATH}/fiptool
1229f58ad36fSHarry Liebel
1230774fb379SBoyan Karatotev$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB) | $$(@D)/
1231e4a070e3SManish V Badarkhe	$(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_SUPPORT=${CRYPTO_SUPPORT} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
12325accce5bSRoberto Vargas
1233cfe83910SLouis Mayencourtmemmap: all
1234c25405d6SChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
12354aa3f18dSChris Kay	$(q)$(if $(host-poetry),poetry run )memory --root ${BUILD_PLAT} symbols
1236cfe83910SLouis Mayencourt
12372329e22bSHarrison Mutaitl: ${BUILD_PLAT}/tl.bin
1238774fb379SBoyan Karatotev${BUILD_PLAT}/tl.bin: ${HW_CONFIG} | $$(@D)/
1239c25405d6SChris Kay	$(if $(host-poetry),$(q)poetry -q install --no-root)
1240d2867397SChris Kay	$(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
12412329e22bSHarrison Mutai
12426de32378SMadhukar Pappireddydoc:
12437c4e1eeaSChris Kay	$(s)echo "  BUILD DOCUMENTATION"
1244c61c9a31SHarrison Mutai	$(if $(host-poetry),$(q)poetry -q install --with docs --no-root)
1245725a80d7SBoyan Karatotev	$(q)$(if $(host-poetry),poetry run )${MAKE} --no-print-directory -C ${DOCS_PATH} BUILDDIR=$(abspath ${BUILD_BASE}/docs) html
12466de32378SMadhukar Pappireddy
124790aa901fSSumit Gargenctool: ${ENCTOOL}
124890aa901fSSumit Garg
1249774fb379SBoyan Karatotev${ENCTOOL}: FORCE | $$(@D)/
125096fbe884SBoyan Karatotev	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
12517c4e1eeaSChris Kay	$(s)echo
12527c4e1eeaSChris Kay	$(s)echo "Built $@ successfully"
12537c4e1eeaSChris Kay	$(s)echo
125490aa901fSSumit Garg
125535fab8c9SJoakim Bechcscope:
12567c4e1eeaSChris Kay	$(s)echo "  CSCOPE"
12577c4e1eeaSChris Kay	$(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
12587c4e1eeaSChris Kay	$(q)cscope -b -q -k
125935fab8c9SJoakim Bech
126072ee3314SRyan Harkinhelp:
12617c4e1eeaSChris Kay	$(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
12627c4e1eeaSChris Kay	$(s)echo ""
12637c4e1eeaSChris Kay	$(s)echo "PLAT is used to specify which platform you wish to build."
12647c4e1eeaSChris Kay	$(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
12657c4e1eeaSChris Kay	$(s)echo ""
12667c4e1eeaSChris Kay	$(s)echo "platform = ${PLATFORM_LIST}"
12677c4e1eeaSChris Kay	$(s)echo ""
12687c4e1eeaSChris Kay	$(s)echo "Please refer to the User Guide for a list of all supported options."
12697c4e1eeaSChris Kay	$(s)echo "Note that the build system doesn't track dependencies for build "
12707c4e1eeaSChris Kay	$(s)echo "options. Therefore, if any of the build options are changed "
12717c4e1eeaSChris Kay	$(s)echo "from a previous build, a clean build must be performed."
12727c4e1eeaSChris Kay	$(s)echo ""
12737c4e1eeaSChris Kay	$(s)echo "Supported Targets:"
12747c4e1eeaSChris Kay	$(s)echo "  all            Build all individual bootloader binaries"
12757c4e1eeaSChris Kay	$(s)echo "  bl1            Build the BL1 binary"
12767c4e1eeaSChris Kay	$(s)echo "  bl2            Build the BL2 binary"
12777c4e1eeaSChris Kay	$(s)echo "  bl2u           Build the BL2U binary"
12787c4e1eeaSChris Kay	$(s)echo "  bl31           Build the BL31 binary"
12797c4e1eeaSChris Kay	$(s)echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
12807c4e1eeaSChris Kay	$(s)echo "                 this builds secure payload specified by AARCH32_SP"
12817c4e1eeaSChris Kay	$(s)echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
12827c4e1eeaSChris Kay	$(s)echo "  fip            Build the Firmware Image Package (FIP)"
12837c4e1eeaSChris Kay	$(s)echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
12847c4e1eeaSChris Kay	$(s)echo "  checkcodebase  Check the coding style of the entire source tree"
12857c4e1eeaSChris Kay	$(s)echo "  checkpatch     Check the coding style on changes in the current"
12867c4e1eeaSChris Kay	$(s)echo "                 branch against BASE_COMMIT (default origin/master)"
12877c4e1eeaSChris Kay	$(s)echo "  clean          Clean the build for the selected platform"
12887c4e1eeaSChris Kay	$(s)echo "  cscope         Generate cscope index"
12897c4e1eeaSChris Kay	$(s)echo "  distclean      Remove all build artifacts for all platforms"
12907c4e1eeaSChris Kay	$(s)echo "  certtool       Build the Certificate generation tool"
12917c4e1eeaSChris Kay	$(s)echo "  enctool        Build the Firmware encryption tool"
12927c4e1eeaSChris Kay	$(s)echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
12937c4e1eeaSChris Kay	$(s)echo "  sp             Build the Secure Partition Packages"
12947c4e1eeaSChris Kay	$(s)echo "  sptool         Build the Secure Partition Package creation tool"
12957c4e1eeaSChris Kay	$(s)echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
12967c4e1eeaSChris Kay	$(s)echo "  memmap         Print the memory map of the built binaries"
12977c4e1eeaSChris Kay	$(s)echo "  doc            Build html based documentation using Sphinx tool"
12987c4e1eeaSChris Kay	$(s)echo ""
12997c4e1eeaSChris Kay	$(s)echo "Note: most build targets require PLAT to be set to a specific platform."
13007c4e1eeaSChris Kay	$(s)echo ""
13017c4e1eeaSChris Kay	$(s)echo "example: build all targets for the FVP platform:"
13027c4e1eeaSChris Kay	$(s)echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1303a9812206SPali Rohár
1304a9812206SPali Rohár.PHONY: FORCE
1305a9812206SPali RohárFORCE:;
1306