xref: /rk3399_ARM-atf/Makefile (revision f1910cc178fe1488e30f66aa9a4f9e450b955eb1)
14f6ad66aSAchin Gupta#
2c9c56f6eSManish V Badarkhe# Copyright (c) 2013-2022, 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
110fa7fe59Slaurenw-armVERSION_MINOR			:= 8
12dddf4283Slaurenw-armVERSION				:= ${VERSION_MAJOR}.${VERSION_MINOR}
13aaa3e722SJuan Castillo
1488154678SJuan Castillo# Default goal is build all images
1588154678SJuan Castillo.DEFAULT_GOAL			:= all
1688154678SJuan Castillo
1772fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to
1872fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
1972fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual.
2072fc70edSDouglas RaillardMAKEOVERRIDES =
2172fc70edSDouglas Raillard
22231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/
23231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
24e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk
2573c99d4eSJuan Castillo
2673c99d4eSJuan Castillo################################################################################
272fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies
2873c99d4eSJuan Castillo################################################################################
29e35c4045SJeenu Viswambharan
302fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
31872be88aSdp-arm
32cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default
33cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS		:= ${DEBUG}
342fae4b1eSJeenu ViswambharanENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
352fae4b1eSJeenu ViswambharanPLAT				:= ${DEFAULT_PLAT}
3673c99d4eSJuan Castillo
3773c99d4eSJuan Castillo################################################################################
3873c99d4eSJuan Castillo# Checkpatch script options
3973c99d4eSJuan Castillo################################################################################
4073c99d4eSJuan Castillo
41f607739cSSandrine BailleuxCHECKCODE_ARGS		:=	--no-patch
42f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files
434501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	:=	$(sort $(filter-out                     \
444501843fSGilad Ben-Yossef					include/drivers/arm/cryptocell,	\
454501843fSGilad Ben-Yossef					$(wildcard include/drivers/arm/*)))
464501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	+=	include/drivers/arm/cryptocell/*.h
474501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
484501843fSGilad Ben-Yossef					include/drivers/arm,		\
494501843fSGilad Ben-Yossef					$(wildcard include/drivers/*)))
50f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
511a41e8c1SDan Handley					include/lib/libfdt		\
5261f72a34SRoberto Vargas					include/lib/libc,		\
53f0b489c1SDan Handley					$(wildcard include/lib/*)))
54f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
554501843fSGilad Ben-Yossef					include/lib			\
564501843fSGilad Ben-Yossef					include/drivers,		\
57f0b489c1SDan Handley					$(wildcard include/*)))
58f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
59d801fbb0Sdp-arm					lib/compiler-rt			\
6055cdcf75SAntonio Nino Diaz					lib/libfdt%			\
6161f72a34SRoberto Vargas					lib/libc,			\
62a194255dSDaniel Boulby					lib/zlib			\
63f0b489c1SDan Handley					$(wildcard lib/*)))
64f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
65f0b489c1SDan Handley					lib				\
66f0b489c1SDan Handley					include				\
67f0b489c1SDan Handley					docs				\
681ef35512SPaul Beesley					%.rst,				\
69f0b489c1SDan Handley					$(wildcard *)))
70f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
71f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
72f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
734501843fSGilad Ben-Yossef				${LIB_DIRS_TO_CHECK}			\
744501843fSGilad Ben-Yossef				${INC_DRV_DIRS_TO_CHECK}		\
754501843fSGilad Ben-Yossef				${INC_ARM_DIRS_TO_CHECK}
7636eaaf37SIan Spray
7773c99d4eSJuan Castillo
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# The cert_create tool cannot generate certificates individually, so we use the
10073c99d4eSJuan Castillo# target 'certificates' to create them all
10173c99d4eSJuan Castilloifneq (${GENERATE_COT},0)
10273c99d4eSJuan Castillo        FIP_DEPS += certificates
1030191262dSYatharth Kochar        FWU_FIP_DEPS += fwu_certificates
10473c99d4eSJuan Castilloendif
10573c99d4eSJuan Castillo
1069fc59639SAlexei Fedorov# Process BRANCH_PROTECTION value and set
1079fc59639SAlexei Fedorov# Pointer Authentication and Branch Target Identification flags
1089fc59639SAlexei Fedorovifeq (${BRANCH_PROTECTION},0)
1099fc59639SAlexei Fedorov	# Default value turns off all types of branch protection
1109fc59639SAlexei Fedorov	BP_OPTION := none
1119fc59639SAlexei Fedorovelse ifneq (${ARCH},aarch64)
1129fc59639SAlexei Fedorov        $(error BRANCH_PROTECTION requires AArch64)
1139fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},1)
1149fc59639SAlexei Fedorov	# Enables all types of branch protection features
1159fc59639SAlexei Fedorov	BP_OPTION := standard
1169fc59639SAlexei Fedorov	ENABLE_BTI := 1
1179fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1189fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},2)
1199fc59639SAlexei Fedorov	# Return address signing to its standard level
1209fc59639SAlexei Fedorov	BP_OPTION := pac-ret
1219fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1229fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},3)
1239fc59639SAlexei Fedorov	# Extend the signing to include leaf functions
1249fc59639SAlexei Fedorov	BP_OPTION := pac-ret+leaf
1259fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1263768fecfSAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},4)
1273768fecfSAlexei Fedorov	# Turn on branch target identification mechanism
1283768fecfSAlexei Fedorov	BP_OPTION := bti
1293768fecfSAlexei Fedorov	ENABLE_BTI := 1
1309fc59639SAlexei Fedorovelse
1319fc59639SAlexei Fedorov        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
1329fc59639SAlexei Fedorovendif
13373c99d4eSJuan Castillo
1345b18de09SZelalem Aweke# FEAT_RME
1355b18de09SZelalem Awekeifeq (${ENABLE_RME},1)
1365b18de09SZelalem Aweke# RME doesn't support PIE
1375b18de09SZelalem Awekeifneq (${ENABLE_PIE},0)
1385b18de09SZelalem Aweke        $(error ENABLE_RME does not support PIE)
1395b18de09SZelalem Awekeendif
140744ad974Sjohpow01# RME doesn't support BRBE
141744ad974Sjohpow01ifneq (${ENABLE_BRBE_FOR_NS},0)
142744ad974Sjohpow01        $(error ENABLE_RME does not support BRBE.)
143744ad974Sjohpow01endif
1445b18de09SZelalem Aweke# RME requires AARCH64
1455b18de09SZelalem Awekeifneq (${ARCH},aarch64)
1465b18de09SZelalem Aweke        $(error ENABLE_RME requires AArch64)
1475b18de09SZelalem Awekeendif
1485b18de09SZelalem Aweke# RME requires el2 context to be saved for now.
1495b18de09SZelalem AwekeCTX_INCLUDE_EL2_REGS := 1
1505b18de09SZelalem AwekeCTX_INCLUDE_AARCH32_REGS := 0
1515b18de09SZelalem AwekeARM_ARCH_MAJOR := 8
1527670ddb1SAndre PrzywaraARM_ARCH_MINOR := 5
1537670ddb1SAndre PrzywaraENABLE_FEAT_ECV = 1
1547670ddb1SAndre PrzywaraENABLE_FEAT_FGT = 1
1557670ddb1SAndre Przywara
1565b18de09SZelalem Awekeendif
1575b18de09SZelalem Aweke
158c97cba4eSSoby Mathew# USE_SPINLOCK_CAS requires AArch64 build
159c97cba4eSSoby Mathewifeq (${USE_SPINLOCK_CAS},1)
160c97cba4eSSoby Mathewifneq (${ARCH},aarch64)
161c97cba4eSSoby Mathew        $(error USE_SPINLOCK_CAS requires AArch64)
162c97cba4eSSoby Mathewendif
163c97cba4eSSoby Mathewendif
164c97cba4eSSoby Mathew
1650ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds
1660ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1)
1670ca3913dSOlivier Deprezifeq (${DEBUG},1)
1680ca3913dSOlivier Deprez        $(warning DEBUGFS experimental feature is enabled.)
1690ca3913dSOlivier Deprezelse
1700ca3913dSOlivier Deprez        $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
1710ca3913dSOlivier Deprezendif
1720ca3913dSOlivier Deprezendif
1730ca3913dSOlivier Deprez
174c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
175c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS}
176c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY}
177c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE}
178c6ba9b45SSumit GargFIP_DEPS += enctool
179c6ba9b45SSumit GargFWU_FIP_DEPS += enctool
180c6ba9b45SSumit Gargendif
181c6ba9b45SSumit Garg
18273c99d4eSJuan Castillo################################################################################
18373c99d4eSJuan Castillo# Toolchain
18473c99d4eSJuan Castillo################################################################################
18573c99d4eSJuan Castillo
18672610c41Sdp-armHOSTCC			:=	gcc
18772610c41Sdp-armexport HOSTCC
18872610c41Sdp-arm
18973c99d4eSJuan CastilloCC			:=	${CROSS_COMPILE}gcc
19073c99d4eSJuan CastilloCPP			:=	${CROSS_COMPILE}cpp
19173c99d4eSJuan CastilloAS			:=	${CROSS_COMPILE}gcc
19273c99d4eSJuan CastilloAR			:=	${CROSS_COMPILE}ar
1932adee763SRoberto VargasLINKER			:=	${CROSS_COMPILE}ld
19473c99d4eSJuan CastilloOC			:=	${CROSS_COMPILE}objcopy
19573c99d4eSJuan CastilloOD			:=	${CROSS_COMPILE}objdump
19673c99d4eSJuan CastilloNM			:=	${CROSS_COMPILE}nm
19773c99d4eSJuan CastilloPP			:=	${CROSS_COMPILE}gcc -E
19838c14d88SSoby MathewDTC			:=	dtc
19973c99d4eSJuan Castillo
200b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
201b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \
2022adee763SRoberto Vargas	$(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
2032adee763SRoberto VargasLINKER			:=	${LINKER}.bfd
204b25a577fSJulius Wernerendif
205b25a577fSJulius Werner
20626e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
20726e63c44SEtienne Carrieretarget32-directive	= 	-target arm-none-eabi
20826e63c44SEtienne Carriere# Will set march32-directive from platform configuration
20926e63c44SEtienne Carriereelse
21026e63c44SEtienne Carrieretarget32-directive	= 	-target armv8a-none-eabi
211fa6f774bSAlexei Fedorov
212f1821790SAlexei Fedorov# Set the compiler's target architecture profile based on
213f1821790SAlexei Fedorov# ARM_ARCH_MAJOR ARM_ARCH_MINOR options
214fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0)
215f1821790SAlexei Fedorovmarch32-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
216f1821790SAlexei Fedorovmarch64-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
217fa6f774bSAlexei Fedorovelse
218f1821790SAlexei Fedorovmarch32-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
219f1821790SAlexei Fedorovmarch64-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
220fa6f774bSAlexei Fedorovendif
22126e63c44SEtienne Carriereendif
22226e63c44SEtienne Carriere
2237ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
2247ff088d1SManish V Badarkheifeq ($(ARCH), aarch64)
2254a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5
2264a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
2277ff088d1SManish V Badarkhemem_tag_arch_support	= 	yes
2287ff088d1SManish V Badarkheendif
2297ff088d1SManish V Badarkheendif
2307ff088d1SManish V Badarkhe
231f1821790SAlexei Fedorov# Get architecture feature modifiers
232f1821790SAlexei Fedorovarch-features		=	${ARM_ARCH_FEATURE}
233f1821790SAlexei Fedorov
234f1821790SAlexei Fedorov# Enable required options for memory stack tagging.
235f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler.
2367ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes)
2377ff088d1SManish V Badarkheifdef mem_tag_arch_support
238f1821790SAlexei Fedorov# Check for armclang and clang compilers
2397ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang))
240f1821790SAlexei Fedorov# Add "memtag" architecture feature modifier if not specified
241f1821790SAlexei Fedorovifeq ( ,$(findstring memtag,$(arch-features)))
242f1821790SAlexei Fedorovarch-features       	:=       $(arch-features)+memtag
243f1821790SAlexei Fedorovendif	# memtag
2447ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang)
2457ff088d1SManish V BadarkheTF_CFLAGS		+=	-mmemtag-stack
2467ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang)
2477ff088d1SManish V BadarkheTF_CFLAGS		+=	-fsanitize=memtag
248f1821790SAlexei Fedorovendif	# armclang
249f1821790SAlexei Fedorovendif	# armclang clang
2507ff088d1SManish V Badarkheelse
2517ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \
2527ff088d1SManish V Badarkhe	${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
253f1821790SAlexei Fedorovendif	# mem_tag_arch_support
254f1821790SAlexei Fedorovendif	# SUPPORT_STACK_MEMTAG
255f1821790SAlexei Fedorov
256f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers
257f1821790SAlexei Fedorovifneq ($(arch-features), none)
258f1821790SAlexei Fedorov# Strip "none+" from arch-features
259f1821790SAlexei Fedorovarch-features		:=	$(subst none+,,$(arch-features))
260f1821790SAlexei Fedorovifeq ($(ARCH), aarch32)
261f1821790SAlexei Fedorovmarch32-directive	:=	$(march32-directive)+$(arch-features)
262f1821790SAlexei Fedorovelse
263f1821790SAlexei Fedorovmarch64-directive	:=	$(march64-directive)+$(arch-features)
2647ff088d1SManish V Badarkheendif
265f1821790SAlexei Fedorov# Print features
266f1821790SAlexei Fedorov$(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
267f1821790SAlexei Fedorovendif	# arch-features
2687ff088d1SManish V Badarkhe
26912cd65e0STomas Pilar# Determine if FEAT_RNG is supported
27012cd65e0STomas PilarENABLE_FEAT_RNG		=	$(if $(findstring rng,${arch-features}),1,0)
27112cd65e0STomas Pilar
2724e04478aSChris Kay# Determine if FEAT_SB is supported
2734e04478aSChris KayENABLE_FEAT_SB		=	$(if $(findstring sb,${arch-features}),1,0)
2744e04478aSChris Kay
275c8a992fdSoriginifneq ($(findstring clang,$(notdir $(CC))),)
276fd18a8fcSVarun Wadekar	ifneq ($(findstring armclang,$(notdir $(CC))),)
277c8a992fdSorigin		TF_CFLAGS_aarch32	:=	-target arm-arm-none-eabi $(march32-directive)
278c8a992fdSorigin		TF_CFLAGS_aarch64	:=	-target aarch64-arm-none-eabi $(march64-directive)
279c8a992fdSorigin		LD			:=	$(LINKER)
280c8a992fdSorigin	else
28194eb1277SArvind Ram Prakash		TF_CFLAGS_aarch32	=	$(target32-directive) $(march32-directive)
282c8a992fdSorigin		TF_CFLAGS_aarch64	:=	-target aarch64-elf $(march64-directive)
283c8a992fdSorigin		LD			:=	$(shell $(CC) --print-prog-name ld.lld)
284c8a992fdSorigin
285c8a992fdSorigin		AR			:=	$(shell $(CC) --print-prog-name llvm-ar)
286c8a992fdSorigin		OD			:=	$(shell $(CC) --print-prog-name llvm-objdump)
287c8a992fdSorigin		OC			:=	$(shell $(CC) --print-prog-name llvm-objcopy)
288641f16e7SAmbroise Vincent	endif
289c8a992fdSorigin
290c8a992fdSorigin	CPP		:=	$(CC) -E $(TF_CFLAGS_$(ARCH))
291c8a992fdSorigin	PP		:=	$(CC) -E $(TF_CFLAGS_$(ARCH))
292c8a992fdSorigin	AS		:=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
293edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),)
294edbce9aaSzelalem-awekeTF_CFLAGS_aarch32	=	$(march32-directive)
295edbce9aaSzelalem-awekeTF_CFLAGS_aarch64	=	$(march64-directive)
296edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
297edbce9aaSzelalem-aweke	# Enable LTO only for aarch64
298edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
299edbce9aaSzelalem-aweke		LTO_CFLAGS	=	-flto
300edbce9aaSzelalem-aweke		# Use gcc as a wrapper for the ld, recommended for LTO
301edbce9aaSzelalem-aweke		LINKER		:=	${CROSS_COMPILE}gcc
302edbce9aaSzelalem-aweke	endif
303edbce9aaSzelalem-awekeendif
304edbce9aaSzelalem-awekeLD			=	$(LINKER)
305d5461857Sdp-armelse
30626e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	$(march32-directive)
307fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	$(march64-directive)
3082adee763SRoberto VargasLD			=	$(LINKER)
309d5461857Sdp-armendif
310d5461857Sdp-arm
31132b209bfSAhmad Fatoum# Process Debug flag
31232b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
31332b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
31432b209bfSAhmad Fatoum        BUILD_TYPE	:=	debug
3154466cf82SDaniel Boulby        TF_CFLAGS	+=	-g -gdwarf-4
3164466cf82SDaniel Boulby        ASFLAGS		+=	-g -Wa,-gdwarf-4
31732b209bfSAhmad Fatoum
31832b209bfSAhmad Fatoum        # Use LOG_LEVEL_INFO by default for debug builds
31932b209bfSAhmad Fatoum        LOG_LEVEL	:=	40
32032b209bfSAhmad Fatoumelse
32132b209bfSAhmad Fatoum        BUILD_TYPE	:=	release
32232b209bfSAhmad Fatoum        # Use LOG_LEVEL_NOTICE by default for release builds
32332b209bfSAhmad Fatoum        LOG_LEVEL	:=	20
32432b209bfSAhmad Fatoumendif
32532b209bfSAhmad Fatoum
326f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
327f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
328f1de4c8fSPeiyuan Song        BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
329f1de4c8fSPeiyuan Songendif
330dddf4283Slaurenw-armVERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
331f1de4c8fSPeiyuan Song
3328fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
3338fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-marm
3348fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
3358fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-mthumb
3368fd9d4d5SAntonio Nino Diazelse
3378fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
3388fd9d4d5SAntonio Nino Diazendif
3398fd9d4d5SAntonio Nino Diaz
340a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
341d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
3429d29c227SSoby Mathew
3439fc59639SAlexei Fedorovifneq (${BP_OPTION},none)
3449fc59639SAlexei FedorovTF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
3459fc59639SAlexei Fedorovendif
3469fc59639SAlexei Fedorov
34726e63c44SEtienne CarriereASFLAGS_aarch32		=	$(march32-directive)
348fa6f774bSAlexei FedorovASFLAGS_aarch64		=	$(march64-directive)
349b86048c4SAntonio Nino Diaz
3509ab81b5eSJustin Chadwell# General warnings
3519ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
352b7f6525dSJustin Chadwell				-Wdisabled-optimization -Wvla -Wshadow	\
353ca661a00SMadhukar Pappireddy				-Wno-unused-parameter -Wredundant-decls
3549ab81b5eSJustin Chadwell
3559ab81b5eSJustin Chadwell# Additional warnings
3569ab81b5eSJustin Chadwell# Level 1
357e7c645b5SYann GautierWARNING1 := -Wextra
358e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute
359e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes
360e7c645b5SYann GautierWARNING1 += -Wold-style-definition
361e7c645b5SYann Gautier
362b7f6525dSJustin Chadwell# Level 2
363e7c645b5SYann GautierWARNING2 := -Waggregate-return
364e7c645b5SYann GautierWARNING2 += -Wcast-align
365e7c645b5SYann GautierWARNING2 += -Wnested-externs
366e7c645b5SYann Gautier
367e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
368e7c645b5SYann GautierWARNING3 += -Wcast-qual
369e7c645b5SYann GautierWARNING3 += -Wconversion
370e7c645b5SYann GautierWARNING3 += -Wpacked
371e7c645b5SYann GautierWARNING3 += -Wpointer-arith
372e7c645b5SYann GautierWARNING3 += -Wswitch-default
373e7c645b5SYann Gautier
374e7c645b5SYann Gautierifeq (${W},1)
3759ab81b5eSJustin ChadwellWARNINGS += $(WARNING1)
376e7c645b5SYann Gautierelse ifeq (${W},2)
3779ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2)
378e7c645b5SYann Gautierelse ifeq (${W},3)
3799ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
380e7c645b5SYann Gautierendif
381e7c645b5SYann Gautier
3829ab81b5eSJustin Chadwell# Compiler specific warnings
38300296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),)
38493c690ebSJustin Chadwell# not using clang
385d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
386d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
387d7b4cd41SJustin Chadwell				-Wlogical-op
38893c690ebSJustin Chadwellelse
38993c690ebSJustin Chadwell# using clang
390d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
391d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
39200296576SAmbroise Vincentendif
39300296576SAmbroise Vincent
3946336b07aSYann Gautierifneq (${E},0)
3956336b07aSYann GautierERRORS := -Werror
3966336b07aSYann Gautierendif
3976336b07aSYann Gautier
398ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
3999ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
40059de5096SMasahiro YamadaASFLAGS			+=	$(CPPFLAGS) $(ASFLAGS_$(ARCH))			\
401d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
40259de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
403ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
404ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
405ebd6efaeSSamuel Holland				-Os -std=gnu99
40673c99d4eSJuan Castillo
407bebcf27fSMark Brown$(eval $(call add_define,SVE_VECTOR_LEN))
408bebcf27fSMark Brown
4091f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4101f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover
4111f461979SJustin Chadwellendif
4121f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
4131f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover	\
4141f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
4151f461979SJustin Chadwellendif
4161f461979SJustin Chadwell
417f7ec31dbSdavid cunadoGCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
418f7ec31dbSdavid cunado
419641f16e7SAmbroise Vincent# LD = armlink
420c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
421c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
422c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
423edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
424641f16e7SAmbroise Vincent
425641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
426edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),)
427edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches
428edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
429edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--gc-sections
430edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
431edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
432edbce9aaSzelalem-aweke		TF_LDFLAGS	+=	-flto -fuse-linker-plugin
433edbce9aaSzelalem-aweke	endif
434edbce9aaSzelalem-awekeendif
435edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
436edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
437edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1)
438edbce9aaSzelalem-aweke	TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
439edbce9aaSzelalem-awekeendif
440edbce9aaSzelalem-awekeTF_LDFLAGS		+= 	-nostdlib
441edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
442641f16e7SAmbroise Vincent
443641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
444c2ad38ceSVarun Wadekarelse
445c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--fatal-warnings -O1
446c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--gc-sections
447641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
448641f16e7SAmbroise Vincent# therefore don't add those in that case
449641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),)
450c2b8806fSDouglas RaillardTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
451edbce9aaSzelalem-awekeendif
452641f16e7SAmbroise Vincentendif
45373c99d4eSJuan Castillo
45403b397a8SNishanth MenonDTC_FLAGS		+=	-I dts -O dtb
455a6de824fSLouis MayencourtDTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
456a6de824fSLouis Mayencourt				-x assembler-with-cpp $(DEFINES)
45703b397a8SNishanth Menon
45873c99d4eSJuan Castillo################################################################################
45973c99d4eSJuan Castillo# Common sources and include directories
46073c99d4eSJuan Castillo################################################################################
4616a0da736SJayanth Dodderi Chidanandinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
462d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
46373c99d4eSJuan Castillo
46473c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
4657f56e9a3SSoby Mathew				common/tf_log.c				\
4669d29c227SSoby Mathew				common/${ARCH}/debug.S			\
46791b48c9fSJulius Werner				drivers/console/multi_console.c		\
4689d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
4699d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
470566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
4717f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
47275311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
4739d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
47461f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
475d7a6b0f8SRyan Harkin
4768422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang)
4778422a840SAntonio Nino DiazBL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
4788422a840SAntonio Nino Diazendif
4798422a840SAntonio Nino Diaz
4801f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4811f461979SJustin ChadwellBL_COMMON_SOURCES	+=	plat/common/ubsan.c
4821f461979SJustin Chadwellendif
4831f461979SJustin Chadwell
48401d237cbSYann GautierINCLUDES		+=	-Iinclude				\
485f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
48609d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
48709d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
48809d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
48909d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
49009d40e0eSAntonio Nino Diaz
4919c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4929c6d1c50SAntonio Nino Diaz
49373c99d4eSJuan Castillo################################################################################
49473c99d4eSJuan Castillo# Generic definitions
49573c99d4eSJuan Castillo################################################################################
49673c99d4eSJuan Castillo
497231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
498231c1470SEvan Lloyd
49929214e95SGrant Likelyifeq (${BUILD_BASE},)
50073c99d4eSJuan Castillo     BUILD_BASE		:=	./build
50129214e95SGrant Likelyendif
50229214e95SGrant LikelyBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
50373c99d4eSJuan Castillo
504231c1470SEvan LloydSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
50573c99d4eSJuan Castillo
50673c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
50773c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
50873c99d4eSJuan Castillo
50973c99d4eSJuan Castillo
51073c99d4eSJuan Castillo################################################################################
51173c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
51273c99d4eSJuan Castillo################################################################################
51373c99d4eSJuan Castillo
51473c99d4eSJuan Castilloifneq (${SPD},none)
5159d29c227SSoby Mathew    ifeq (${ARCH},aarch32)
5169d29c227SSoby Mathew        $(error "Error: SPD is incompatible with AArch32.")
5179d29c227SSoby Mathew    endif
51828f39f02SMax Shvetsov
5194c117f6cSSandrine Bailleux    ifdef EL3_PAYLOAD_BASE
5204c117f6cSSandrine Bailleux        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
5214c117f6cSSandrine Bailleux        $(warning "The SPD and its BL32 companion will be present but ignored.")
5224c117f6cSSandrine Bailleux    endif
52328f39f02SMax Shvetsov
524c3fb00d9SAchin Gupta    ifeq (${SPD},spmd)
525c3fb00d9SAchin Gupta        # SPMD is located in std_svc directory
526c3fb00d9SAchin Gupta        SPD_DIR := std_svc
52728f39f02SMax Shvetsov
528033039f8SMax Shvetsov        ifeq ($(SPMD_SPM_AT_SEL2),1)
529*f1910cc1SGovindraj Raja            CTX_INCLUDE_EL2_REGS := 1
5301d63ae4dSMarc Bonnici	    ifeq ($(SPMC_AT_EL3),1)
5311d63ae4dSMarc Bonnici                $(error SPM cannot be enabled in both S-EL2 and EL3.)
5321d63ae4dSMarc Bonnici            endif
53328f39f02SMax Shvetsov        endif
534db1ef41aSOlivier Deprez
535db1ef41aSOlivier Deprez        ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
536db1ef41aSOlivier Deprez            DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
537db1ef41aSOlivier Deprez        endif
538ca932481SDavidson K
539ca932481SDavidson K        ifeq ($(TS_SP_FW_CONFIG),1)
540ca932481SDavidson K            DTC_CPPFLAGS	+=	-DTS_SP_FW_CONFIG
541ca932481SDavidson K        endif
54233993a37SBalint Dobszay
54333993a37SBalint Dobszay        ifneq ($(ARM_BL2_SP_LIST_DTS),)
54433993a37SBalint Dobszay            DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
54533993a37SBalint Dobszay        endif
54646789a7cSBalint Dobszay
54746789a7cSBalint Dobszay        ifneq ($(SP_LAYOUT_FILE),)
54846789a7cSBalint Dobszay            BL2_ENABLE_SP_LOAD := 1
54946789a7cSBalint Dobszay        endif
550c3fb00d9SAchin Gupta    else
551c3fb00d9SAchin Gupta        # All other SPDs in spd directory
552c3fb00d9SAchin Gupta        SPD_DIR := spd
553c3fb00d9SAchin Gupta    endif
554c3fb00d9SAchin Gupta
55573c99d4eSJuan Castillo    # We expect to locate an spd.mk under the specified SPD directory
556c3fb00d9SAchin Gupta    SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
557c3fb00d9SAchin Gupta
55873c99d4eSJuan Castillo    ifeq (${SPD_MAKE},)
559c3fb00d9SAchin Gupta        $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
56073c99d4eSJuan Castillo    endif
56173c99d4eSJuan Castillo    $(info Including ${SPD_MAKE})
56273c99d4eSJuan Castillo    include ${SPD_MAKE}
56373c99d4eSJuan Castillo
56470d1fc53SJuan Castillo    # If there's BL32 companion for the chosen SPD, we expect that the SPD's
56570d1fc53SJuan Castillo    # Makefile would set NEED_BL32 to "yes". In this case, the build system
56670d1fc53SJuan Castillo    # supports two mutually exclusive options:
56770d1fc53SJuan Castillo    # * BL32 is built from source: then BL32_SOURCES must contain the list
56870d1fc53SJuan Castillo    #   of source files to build BL32
56970d1fc53SJuan Castillo    # * BL32 is a prebuilt binary: then BL32 must point to the image file
57070d1fc53SJuan Castillo    #   that will be included in the FIP
57170d1fc53SJuan Castillo    # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
57270d1fc53SJuan Castillo    # over the sources.
573e35c4045SJeenu Viswambharanendif
574e35c4045SJeenu Viswambharan
575*f1910cc1SGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1)
576*f1910cc1SGovindraj Rajaifeq (${SPD},none)
577*f1910cc1SGovindraj Rajaifeq (${ENABLE_RME},0)
578*f1910cc1SGovindraj Raja    $(error CTX_INCLUDE_EL2_REGS is available only when SPD or RME is enabled)
579*f1910cc1SGovindraj Rajaendif
580*f1910cc1SGovindraj Rajaendif
581*f1910cc1SGovindraj Rajaendif
582*f1910cc1SGovindraj Raja
58351faada7SDouglas Raillard################################################################################
5845b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled
5855b18de09SZelalem Aweke################################################################################
5865b18de09SZelalem Aweke
5875b18de09SZelalem Awekeifneq (${ENABLE_RME},0)
5885b18de09SZelalem Awekeifneq (${ARCH},aarch64)
5895b18de09SZelalem Aweke	$(error ENABLE_RME requires AArch64)
5905b18de09SZelalem Awekeendif
5911d63ae4dSMarc Bonniciifeq ($(SPMC_AT_EL3),1)
5921d63ae4dSMarc Bonnici	$(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
5931d63ae4dSMarc Bonniciendif
5945b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk
5955b18de09SZelalem Aweke$(warning "RME is an experimental feature")
5965b18de09SZelalem Awekeendif
5975b18de09SZelalem Aweke
5985b18de09SZelalem Aweke################################################################################
59973c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
60073c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
60173c99d4eSJuan Castillo################################################################################
6022da8d8bfSJeenu Viswambharan
60373c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
6040f21c547SJuan Castillo
6058012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
6068012cc5cSMasahiro Yamada
60726e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
60826e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
60926e63c44SEtienne Carriereendif
61026e63c44SEtienne Carriere
6113bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
6123bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
6133bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
6147b592418SSamuel Hollandifneq ($(findstring gcc,$(notdir $(LD))),)
6157b592418SSamuel Holland	TF_LDFLAGS	+=	-no-pie
6167b592418SSamuel Hollandendif
6173bd17c0fSSoby Mathewendif
618320920c1SMasahiro Yamada
619320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),)
620320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
621320920c1SMasahiro Yamadaelse
622320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
623320920c1SMasahiro Yamadaendif
624320920c1SMasahiro Yamada
625320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
62669af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
62769af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1)
62869af7fcfSMasahiro Yamada	BL2_CFLAGS	+=	-fpie
62969af7fcfSMasahiro Yamada	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
63069af7fcfSMasahiro Yamadaendif
63169af7fcfSMasahiro Yamadaendif
632320920c1SMasahiro Yamada	BL31_CFLAGS	+=	-fpie
633320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
634d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
635d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
636d974301dSMasahiro Yamadaendif
6373bd17c0fSSoby Mathew
638d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64)
6399cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
640d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
6419cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3
642d5e97a1dSMasahiro Yamadaelse
6439cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1
644d5e97a1dSMasahiro Yamadaendif
6459cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1
6469cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3
6479cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1
648d5e97a1dSMasahiro Yamadaendif
649d5e97a1dSMasahiro Yamada
65054035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
65154035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
65254035fc4SSandrine Bailleux# This can be overridden by the platform.
65373c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
6544f6ad66aSAchin Gupta
655a4409008Sdp-armifeq (${ARCH},aarch32)
656a4409008Sdp-armNEED_BL32 := yes
657a4409008Sdp-arm
658a4409008Sdp-arm################################################################################
659a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
660a4409008Sdp-arm################################################################################
661a4409008Sdp-armifneq (${AARCH32_SP},none)
662a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory
663a4409008Sdp-armAARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
664a4409008Sdp-arm
665a4409008Sdp-armifeq (${AARCH32_SP_MAKE},)
666a4409008Sdp-arm  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
667a4409008Sdp-armendif
668a4409008Sdp-arm
669a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE})
670a4409008Sdp-arminclude ${AARCH32_SP_MAKE}
671a4409008Sdp-armendif
672a4409008Sdp-arm
673a4409008Sdp-armendif
6744f6ad66aSAchin Gupta
67573c99d4eSJuan Castillo################################################################################
67677f1f7a1SVarun Wadekar# Include libc if not overridden
67777f1f7a1SVarun Wadekar################################################################################
67877f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
67977f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
68077f1f7a1SVarun Wadekarendif
68177f1f7a1SVarun Wadekar
68277f1f7a1SVarun Wadekar################################################################################
683cf2c8a33SAntonio Nino Diaz# Check incompatible options
684cf2c8a33SAntonio Nino Diaz################################################################################
685cf2c8a33SAntonio Nino Diaz
686cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
68768450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
68868450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
68968450a6dSAntonio Nino Diaz                incompatible build options. EL3_PAYLOAD_BASE has priority.")
690cf2c8a33SAntonio Nino Diaz        endif
69176580f3dSQixiang Xu        ifneq (${GENERATE_COT},0)
69276580f3dSQixiang Xu                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
69376580f3dSQixiang Xu        endif
69476580f3dSQixiang Xu        ifneq (${TRUSTED_BOARD_BOOT},0)
69576580f3dSQixiang Xu                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
69676580f3dSQixiang Xu        endif
697cf2c8a33SAntonio Nino Diazendif
698cf2c8a33SAntonio Nino Diaz
699cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
700cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
701cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
702cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
703cf2c8a33SAntonio Nino Diaz        endif
70468450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
70568450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
70668450a6dSAntonio Nino Diaz                PRELOADED_BL33_BASE is used and won't be added to the FIP \
70768450a6dSAntonio Nino Diaz                file.")
708cf2c8a33SAntonio Nino Diaz        endif
709cf2c8a33SAntonio Nino Diazendif
710cf2c8a33SAntonio Nino Diaz
711d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
712d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
713d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
714d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
715d4593e47SJeenu Viswambharanendif
7161a0a3f06SYatharth Kochar
7177d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
7187d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
7197d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
7207d173fc5SJiafei Panendif
7217d173fc5SJiafei Pan
72214c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first
72314c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
72446cc41d5SManish Pandey    ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
72546cc41d5SManish Pandey        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1)
72614c6016aSJeenu Viswambharan    endif
72714c6016aSJeenu Viswambharanendif
72814c6016aSJeenu Viswambharan
7291a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
7301a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
7311a7c1cfeSJeenu Viswambharan    ifneq ($(RAS_EXTENSION),1)
7321a7c1cfeSJeenu Viswambharan        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
7331a7c1cfeSJeenu Viswambharan    endif
7341a7c1cfeSJeenu Viswambharanendif
7351a7c1cfeSJeenu Viswambharan
736ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
737209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
738209a60ccSSoby Mathew    ifeq (${TRUSTED_BOARD_BOOT}, 0)
739209a60ccSSoby Mathew        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
740209a60ccSSoby Mathew    endif
741209a60ccSSoby Mathewendif
742209a60ccSSoby Mathew
7432bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
7442bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
7452bf4f27fSManish V Badarkhe    CRYPTO_SUPPORT := 3
7462bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
7472bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
7482bf4f27fSManish V Badarkhe    CRYPTO_SUPPORT := 3
7492bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
7502bf4f27fSManish V Badarkhe# Support hash calculation only
7512bf4f27fSManish V Badarkhe    CRYPTO_SUPPORT := 2
7522bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1)
7532bf4f27fSManish V Badarkhe# Support authentication verification only
754c9c56f6eSManish V Badarkhe    CRYPTO_SUPPORT := 1
755c9c56f6eSManish V Badarkheelse
756c9c56f6eSManish V Badarkhe    CRYPTO_SUPPORT := 0
757c9c56f6eSManish V Badarkheendif
758c9c56f6eSManish V Badarkhe
759cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
760cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
761700e7685SManish Pandey$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
76284ef9cd8SManish V Badarkheendif
76384ef9cd8SManish V Badarkhe
764b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
7659fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
7669fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
767b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
7689fc59639SAlexei Fedorov    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
7699fc59639SAlexei Fedorov        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
77006715f85SAlexei Fedorov    endif
7719fc59639SAlexei Fedorovendif
7729fc59639SAlexei Fedorov
77306715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
7749fc59639SAlexei Fedorov    ifneq (${ARCH},aarch64)
7759fc59639SAlexei Fedorov        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
776b86048c4SAntonio Nino Diaz    endif
777b86048c4SAntonio Nino Diazendif
7789fc59639SAlexei Fedorov
7799dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1)
7809dd94382SJustin Chadwell    ifneq (${ARCH},aarch64)
7819dd94382SJustin Chadwell        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
7829dd94382SJustin Chadwell    endif
7839dd94382SJustin Chadwellendif
7849dd94382SJustin Chadwell
785396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1)
786396b339dSManish V Badarkhe    $(info PSA_FWU_SUPPORT is an experimental feature)
787396b339dSManish V Badarkheendif
788396b339dSManish V Badarkhe
7896a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1)
7906a0da736SJayanth Dodderi Chidanand    $(info FEATURE_DETECTION is an experimental feature)
7916a0da736SJayanth Dodderi Chidanandendif
7926a0da736SJayanth Dodderi Chidanand
79360e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
79460e8f3cfSPetre-Ionut Tudor    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
79560e8f3cfSPetre-Ionut Tudor        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
79660e8f3cfSPetre-Ionut Tudor    endif
79760e8f3cfSPetre-Ionut Tudorendif
79860e8f3cfSPetre-Ionut Tudor
7997cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
8007cda17bbSSumit Garg    ifeq (${TRUSTED_BOARD_BOOT}, 0)
8017cda17bbSSumit Garg        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
8027cda17bbSSumit Garg    endif
8037cda17bbSSumit Gargendif
8047cda17bbSSumit Garg
805744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build
806dc78e62dSjohpow01ifeq (${ARCH},aarch32)
807744ad974Sjohpow01
808744ad974Sjohpow01    # SME/SVE only supported on AArch64
809dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},1)
810dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
811dc78e62dSjohpow01    endif
812dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},1)
813dc78e62dSjohpow01        # Warning instead of error due to CI dependency on this
81424ab2c0aSYann Gautier        $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
815dc78e62dSjohpow01    endif
816744ad974Sjohpow01
817ff86e0b4SJuan Pablo Conde    # BRBE is not supported in AArch32
818744ad974Sjohpow01    ifeq (${ENABLE_BRBE_FOR_NS},1)
819744ad974Sjohpow01        $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
820744ad974Sjohpow01    endif
821744ad974Sjohpow01
822ff86e0b4SJuan Pablo Conde    # FEAT_RNG_TRAP is not supported in AArch32
823ff86e0b4SJuan Pablo Conde    ifeq (${ENABLE_FEAT_RNG_TRAP},1)
824ff86e0b4SJuan Pablo Conde        $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
825ff86e0b4SJuan Pablo Conde    endif
826dc78e62dSjohpow01endif
827dc78e62dSjohpow01
828dc78e62dSjohpow01# Ensure ENABLE_RME is not used with SME
829dc78e62dSjohpow01ifeq (${ENABLE_RME},1)
830dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},1)
831dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
832dc78e62dSjohpow01    endif
833dc78e62dSjohpow01endif
834dc78e62dSjohpow01
835dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well
836dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1)
837dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},0)
838dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
839dc78e62dSjohpow01    endif
840dc78e62dSjohpow01endif
841dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1)
842dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},0)
843dc78e62dSjohpow01        $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
844dc78e62dSjohpow01    endif
845dc78e62dSjohpow01endif
846dc78e62dSjohpow01
847dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
848dc78e62dSjohpow01# its own context management including FPU registers.
849dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1)
850dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},1)
851dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
852dc78e62dSjohpow01    endif
853dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},1)
854dc78e62dSjohpow01        # Warning instead of error due to CI dependency on this
855dc78e62dSjohpow01        $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
856dc78e62dSjohpow01        $(warning "Forced ENABLE_SVE_FOR_NS=0")
857dc78e62dSjohpow01        override ENABLE_SVE_FOR_NS	:= 0
858dc78e62dSjohpow01    endif
859dc78e62dSjohpow01endif
860dc78e62dSjohpow01
86100e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1)
86200e28874SManish V Badarkhe    $(info DRTM_SUPPORT is an experimental feature)
86300e28874SManish V Badarkheendif
86400e28874SManish V Badarkhe
865274a69e7SChris Kayifeq (${ENABLE_RME},1)
866274a69e7SChris Kay    ifneq (${SEPARATE_CODE_AND_RODATA},1)
867274a69e7SChris Kay        $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
868274a69e7SChris Kay    endif
869274a69e7SChris Kayendif
870274a69e7SChris Kay
871cf2c8a33SAntonio Nino Diaz################################################################################
87273c99d4eSJuan Castillo# Process platform overrideable behaviour
87373c99d4eSJuan Castillo################################################################################
8744f6ad66aSAchin Gupta
8755f24ce96SManish Pandeyifdef BL1_SOURCES
8765f24ce96SManish PandeyNEED_BL1 := yes
8775f24ce96SManish Pandeyendif
8785f24ce96SManish Pandey
8795f24ce96SManish Pandeyifdef BL2_SOURCES
8805f24ce96SManish Pandey	NEED_BL2 := yes
8815f24ce96SManish Pandey
882bd97f83aSJohn Tsichritzis	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
883bd97f83aSJohn Tsichritzis	# Certificate generation tools. This flag can be overridden by the platform.
884cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
885cf2c8a33SAntonio Nino Diaz                # If booting an EL3 payload there is no need for a BL33 image
886cf2c8a33SAntonio Nino Diaz                # in the FIP file.
8874c117f6cSSandrine Bailleux                NEED_BL33		:=	no
888cf2c8a33SAntonio Nino Diaz        else
88968450a6dSAntonio Nino Diaz                ifdef PRELOADED_BL33_BASE
890cf2c8a33SAntonio Nino Diaz                        # If booting a BL33 preloaded image there is no need of
891cf2c8a33SAntonio Nino Diaz                        # another one in the FIP file.
892cf2c8a33SAntonio Nino Diaz                        NEED_BL33		:=	no
893cf2c8a33SAntonio Nino Diaz                else
894cf2c8a33SAntonio Nino Diaz                        NEED_BL33		?=	yes
895cf2c8a33SAntonio Nino Diaz                endif
8964c117f6cSSandrine Bailleux        endif
89773c99d4eSJuan Castilloendif
8986f971622SJuan Castillo
8995f24ce96SManish Pandeyifdef BL2U_SOURCES
9005f24ce96SManish PandeyNEED_BL2U := yes
9015f24ce96SManish Pandeyendif
9025f24ce96SManish Pandey
9034d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
9044d045d0eSMasahiro Yamadaifdef SCP_BL2
9054d045d0eSMasahiro Yamada        NEED_SCP_BL2		:=	yes
9064d045d0eSMasahiro Yamadaendif
9074d045d0eSMasahiro Yamada
9085744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
9095744e874SSoby Mathewifneq (${ARCH},aarch32)
9105744e874SSoby Mathew    ifdef BL31_SOURCES
9115744e874SSoby Mathew        # When booting an EL3 payload, there is no need to compile the BL31 image nor
9125744e874SSoby Mathew        # put it in the FIP.
9135744e874SSoby Mathew        ifndef EL3_PAYLOAD_BASE
9145744e874SSoby Mathew            NEED_BL31 := yes
9155744e874SSoby Mathew        endif
9165744e874SSoby Mathew    endif
9175744e874SSoby Mathewendif
9185744e874SSoby Mathew
91973c99d4eSJuan Castillo# Process TBB related flags
9206f971622SJuan Castilloifneq (${GENERATE_COT},0)
92173c99d4eSJuan Castillo        # Common cert_create options
9226f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
9236f971622SJuan Castillo                $(eval CRT_ARGS += -n)
9240191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
925fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
926fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
9270191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
928fd34e7baSJuan Castillo                endif
9296f971622SJuan Castillo        endif
93073c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
93173c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
93273c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
93373c99d4eSJuan Castillo        endif
9346f971622SJuan Castilloendif
9356f971622SJuan Castillo
9361c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
9371c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN}
9381c75d5dfSMasahiro Yamadaendif
9391c75d5dfSMasahiro Yamada
9405f24ce96SManish Pandeyifdef FDT_SOURCES
9415f24ce96SManish PandeyNEED_FDT := yes
9425f24ce96SManish Pandeyendif
9435f24ce96SManish Pandey
94473c99d4eSJuan Castillo################################################################################
94546e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
94646e5e035SMichalis Pappas################################################################################
94746e5e035SMichalis Pappas
94846e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
94946e5e035SMichalis Pappas
95046e5e035SMichalis Pappas################################################################################
951819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc)
95273c99d4eSJuan Castillo################################################################################
95373c99d4eSJuan Castillo
95473c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
95573c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
95642a45b51SEvan LloydCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
95773c99d4eSJuan Castillo
95890aa901fSSumit Garg# Variables for use with Firmware Encryption Tool
95990aa901fSSumit GargENCTOOLPATH		?=	tools/encrypt_fw
96090aa901fSSumit GargENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
96190aa901fSSumit Garg
96273c99d4eSJuan Castillo# Variables for use with Firmware Image Package
963819281eeSdp-armFIPTOOLPATH		?=	tools/fiptool
964819281eeSdp-armFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
96573c99d4eSJuan Castillo
96626010da1SAntonio Nino Diaz# Variables for use with sptool
96726010da1SAntonio Nino DiazSPTOOLPATH		?=	tools/sptool
968822c7279SJ-AlvesSPTOOL			?=	${SPTOOLPATH}/sptool.py
969ce2b1ec6SManish PandeySP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
97026010da1SAntonio Nino Diaz
9715accce5bSRoberto Vargas# Variables for use with ROMLIB
9725accce5bSRoberto VargasROMLIBPATH		?=	lib/romlib
9735accce5bSRoberto Vargas
974cfe83910SLouis Mayencourt# Variable for use with Python
975cfe83910SLouis MayencourtPYTHON			?=	python3
976cfe83910SLouis Mayencourt
977cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP
978cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH		?=	tools/memory
979cfe83910SLouis MayencourtPRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
980cfe83910SLouis Mayencourt
9816de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool
9826de32378SMadhukar PappireddyDOCS_PATH		?=	docs
9836de32378SMadhukar Pappireddy
9841f1c0206SAbdul Halim, Muhammad Hadi Asyrafi# Defination of SIMICS flag
9851f1c0206SAbdul Halim, Muhammad Hadi AsyrafiSIMICS_BUILD	?=	0
9861f1c0206SAbdul Halim, Muhammad Hadi Asyrafi
9878a86052dSSoby Mathew################################################################################
9888a86052dSSoby Mathew# Include BL specific makefiles
9898a86052dSSoby Mathew################################################################################
9905f24ce96SManish Pandey
9915f24ce96SManish Pandeyifeq (${NEED_BL1},yes)
9928a86052dSSoby Mathewinclude bl1/bl1.mk
9938a86052dSSoby Mathewendif
9948a86052dSSoby Mathew
9955f24ce96SManish Pandeyifeq (${NEED_BL2},yes)
9968a86052dSSoby Mathewinclude bl2/bl2.mk
9978a86052dSSoby Mathewendif
9988a86052dSSoby Mathew
9995f24ce96SManish Pandeyifeq (${NEED_BL2U},yes)
10008a86052dSSoby Mathewinclude bl2u/bl2u.mk
10018a86052dSSoby Mathewendif
10028a86052dSSoby Mathew
10035744e874SSoby Mathewifeq (${NEED_BL31},yes)
10048a86052dSSoby Mathewinclude bl31/bl31.mk
10058a86052dSSoby Mathewendif
100603b397a8SNishanth Menon
100773c99d4eSJuan Castillo################################################################################
100873c99d4eSJuan Castillo# Build options checks
100973c99d4eSJuan Castillo################################################################################
101073c99d4eSJuan Castillo
1011327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
1012327131c4SLeonardo Sandoval    $(sort \
1013327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
101446789a7cSBalint Dobszay        BL2_ENABLE_SP_LOAD \
1015327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
1016327131c4SLeonardo Sandoval        CREATE_KEYS \
1017327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
1018327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
1019327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
1020327131c4SLeonardo Sandoval        DEBUG \
10210063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
1022327131c4SLeonardo Sandoval        DYN_DISABLE_AUTH \
1023327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
1024327131c4SLeonardo Sandoval        ENABLE_AMU \
10251fd685a7SChris Kay        ENABLE_AMU_AUXILIARY_COUNTERS \
1026742ca230SChris Kay        ENABLE_AMU_FCONF \
1027873d4241Sjohpow01        AMU_RESTRICT_COUNTERS \
1028327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
1029327131c4SLeonardo Sandoval        ENABLE_PIE \
1030327131c4SLeonardo Sandoval        ENABLE_PMF \
1031327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
1032327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
1033dc78e62dSjohpow01        ENABLE_SME_FOR_NS \
1034dc78e62dSjohpow01        ENABLE_SME_FOR_SWD \
1035327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
1036327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
10370c5e7d1cSMax Shvetsov        ENABLE_SVE_FOR_SWD \
1038327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
1039327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
1040327131c4SLeonardo Sandoval        GENERATE_COT \
1041327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
104246cc41d5SManish Pandey        HANDLE_EA_EL3_FIRST_NS \
1043327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
1044327131c4SLeonardo Sandoval        INVERTED_MEMMAP \
1045327131c4SLeonardo Sandoval        MEASURED_BOOT \
104600e28874SManish V Badarkhe        DRTM_SUPPORT \
1047327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
1048327131c4SLeonardo Sandoval        OVERRIDE_LIBC \
1049327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
10500ce2072dSTamas Ban        PLAT_RSS_NOT_SUPPORTED \
1051327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
1052327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
1053327131c4SLeonardo Sandoval        RESET_TO_BL31 \
105425844ff7SJorge Ramirez-Ortiz        RESET_TO_BL31_WITH_PARAMS \
1055327131c4SLeonardo Sandoval        SAVE_KEYS \
1056327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
105796a8ed14SJiafei Pan        SEPARATE_BL2_NOLOAD_REGION \
1058327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
1059327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
1060327131c4SLeonardo Sandoval        SPM_MM \
10611d63ae4dSMarc Bonnici        SPMC_AT_EL3 \
1062327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
1063327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
1064327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
1065327131c4SLeonardo Sandoval        USE_DEBUGFS \
1066327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
1067327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
1068327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
1069327131c4SLeonardo Sandoval        USE_ROMLIB \
1070327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
1071327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
1072327131c4SLeonardo Sandoval        BL2_AT_EL3 \
1073327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
1074327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
1075327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
1076327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
1077327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
1078327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
107900e8f79cSManish Pandey        RAS_TRAP_NS_ERR_REC_ACCESS \
1080327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
1081327131c4SLeonardo Sandoval        USE_SP804_TIMER \
1082396b339dSManish V Badarkhe        PSA_FWU_SUPPORT \
1083d4582d30SManish V Badarkhe        ENABLE_SYS_REG_TRACE_FOR_NS \
108468120783SChris Kay        ENABLE_MPMM \
108568120783SChris Kay        ENABLE_MPMM_FCONF \
10861f1c0206SAbdul Halim, Muhammad Hadi Asyrafi        SIMICS_BUILD \
10876a0da736SJayanth Dodderi Chidanand        FEATURE_DETECTION \
10880b22e591SJayanth Dodderi Chidanand	TRNG_SUPPORT \
108904c7303bSOkash Khawaja	CONDITIONAL_CMO \
1090327131c4SLeonardo Sandoval)))
109173c99d4eSJuan Castillo
1092327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
1093327131c4SLeonardo Sandoval    $(sort \
1094327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
1095327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
1096327131c4SLeonardo Sandoval        BRANCH_PROTECTION \
10976a0da736SJayanth Dodderi Chidanand        CTX_INCLUDE_PAUTH_REGS \
10986a0da736SJayanth Dodderi Chidanand        CTX_INCLUDE_MTE_REGS \
10996a0da736SJayanth Dodderi Chidanand        CTX_INCLUDE_NEVE_REGS \
11002bf4f27fSManish V Badarkhe        CRYPTO_SUPPORT \
11011298f2f1SJayanth Dodderi Chidanand        ENABLE_BRBE_FOR_NS \
110247c681b7SJayanth Dodderi Chidanand        ENABLE_TRBE_FOR_NS \
11036a0da736SJayanth Dodderi Chidanand        ENABLE_BTI \
11046a0da736SJayanth Dodderi Chidanand        ENABLE_PAUTH \
11056a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1 \
11066a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1p1 \
11076a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_CSV2_2 \
11086a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_DIT \
11096a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_ECV \
11106a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_FGT \
11116a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_HCX \
11126a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_PAN \
11136a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_RNG \
1114ff86e0b4SJuan Pablo Conde        ENABLE_FEAT_RNG_TRAP \
11156a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_SB \
11166a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_SEL2 \
11176a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_VHE \
11186a0da736SJayanth Dodderi Chidanand        ENABLE_MPAM_FOR_LOWER_ELS \
11196a0da736SJayanth Dodderi Chidanand        ENABLE_RME \
11206a0da736SJayanth Dodderi Chidanand        ENABLE_TRF_FOR_NS \
1121327131c4SLeonardo Sandoval        FW_ENC_STATUS \
11225357f83dSManish V Badarkhe        NR_OF_FW_BANKS \
11235357f83dSManish V Badarkhe        NR_OF_IMAGES_IN_FW_BANK \
11246a0da736SJayanth Dodderi Chidanand        RAS_EXTENSION \
1125781d07a4SJayanth Dodderi Chidanand        TWED_DELAY \
1126781d07a4SJayanth Dodderi Chidanand        ENABLE_FEAT_TWED \
1127bebcf27fSMark Brown        SVE_VECTOR_LEN \
1128327131c4SLeonardo Sandoval)))
1129c877b414SJeenu Viswambharan
1130aacff749SJustin Chadwellifdef KEY_SIZE
1131aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
1132aacff749SJustin Chadwellendif
1133aacff749SJustin Chadwell
11341f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
11351f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
11361f461979SJustin Chadwellendif
11371f461979SJustin Chadwell
113873c99d4eSJuan Castillo################################################################################
113973c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
114073c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
114173c99d4eSJuan Castillo# platform to overwrite the default options
114273c99d4eSJuan Castillo################################################################################
114373c99d4eSJuan Castillo
1144327131c4SLeonardo Sandoval$(eval $(call add_defines,\
1145327131c4SLeonardo Sandoval    $(sort \
1146327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
1147327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
1148327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
114946789a7cSBalint Dobszay        BL2_ENABLE_SP_LOAD \
1150327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
1151327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
1152327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
1153327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
1154327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
1155327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
1156327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
1157062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
1158327131c4SLeonardo Sandoval        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
11590063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
1160327131c4SLeonardo Sandoval        ENABLE_AMU \
11611fd685a7SChris Kay        ENABLE_AMU_AUXILIARY_COUNTERS \
1162742ca230SChris Kay        ENABLE_AMU_FCONF \
1163873d4241Sjohpow01        AMU_RESTRICT_COUNTERS \
1164327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
1165327131c4SLeonardo Sandoval        ENABLE_BTI \
1166327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
1167327131c4SLeonardo Sandoval        ENABLE_PAUTH \
1168327131c4SLeonardo Sandoval        ENABLE_PIE \
1169327131c4SLeonardo Sandoval        ENABLE_PMF \
1170327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
11715b18de09SZelalem Aweke        ENABLE_RME \
1172327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
1173dc78e62dSjohpow01        ENABLE_SME_FOR_NS \
1174dc78e62dSjohpow01        ENABLE_SME_FOR_SWD \
1175327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
1176327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
11770c5e7d1cSMax Shvetsov        ENABLE_SVE_FOR_SWD \
1178327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
1179327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
1180327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
1181327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
1182327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
118346cc41d5SManish Pandey        HANDLE_EA_EL3_FIRST_NS \
1184327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
1185327131c4SLeonardo Sandoval        LOG_LEVEL \
1186327131c4SLeonardo Sandoval        MEASURED_BOOT \
118700e28874SManish V Badarkhe        DRTM_SUPPORT \
1188327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
1189327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
1190327131c4SLeonardo Sandoval        PLAT_${PLAT} \
11910ce2072dSTamas Ban        PLAT_RSS_NOT_SUPPORTED \
1192327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
1193327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
1194327131c4SLeonardo Sandoval        RAS_EXTENSION \
1195327131c4SLeonardo Sandoval        RESET_TO_BL31 \
119625844ff7SJorge Ramirez-Ortiz        RESET_TO_BL31_WITH_PARAMS \
1197327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
119896a8ed14SJiafei Pan        SEPARATE_BL2_NOLOAD_REGION \
1199327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
1200327131c4SLeonardo Sandoval        RECLAIM_INIT_CODE \
1201327131c4SLeonardo Sandoval        SPD_${SPD} \
1202327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
1203327131c4SLeonardo Sandoval        SPM_MM \
12041d63ae4dSMarc Bonnici        SPMC_AT_EL3 \
1205327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
1206327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
1207c9c56f6eSManish V Badarkhe        CRYPTO_SUPPORT \
12087dfb9911SJimmy Brisson        TRNG_SUPPORT \
1209327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
1210327131c4SLeonardo Sandoval        USE_DEBUGFS \
1211327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
1212327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
1213327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
1214327131c4SLeonardo Sandoval        USE_ROMLIB \
1215327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
1216327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
1217327131c4SLeonardo Sandoval        BL2_AT_EL3 \
1218327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
1219327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
1220327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
1221327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
122200e8f79cSManish Pandey        RAS_TRAP_NS_ERR_REC_ACCESS \
1223327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
1224327131c4SLeonardo Sandoval        USE_SP804_TIMER \
122512cd65e0STomas Pilar        ENABLE_FEAT_RNG \
1226ff86e0b4SJuan Pablo Conde        ENABLE_FEAT_RNG_TRAP \
12274e04478aSChris Kay        ENABLE_FEAT_SB \
12287d33ffe4SDaniel Boulby        ENABLE_FEAT_DIT \
12295357f83dSManish V Badarkhe        NR_OF_FW_BANKS \
12305357f83dSManish V Badarkhe        NR_OF_IMAGES_IN_FW_BANK \
1231396b339dSManish V Badarkhe        PSA_FWU_SUPPORT \
1232744ad974Sjohpow01        ENABLE_BRBE_FOR_NS \
1233813524eaSManish V Badarkhe        ENABLE_TRBE_FOR_NS \
1234d4582d30SManish V Badarkhe        ENABLE_SYS_REG_TRACE_FOR_NS \
12358fcd3d96SManish V Badarkhe        ENABLE_TRF_FOR_NS \
1236cb4ec47bSjohpow01        ENABLE_FEAT_HCX \
123768120783SChris Kay        ENABLE_MPMM \
123868120783SChris Kay        ENABLE_MPMM_FCONF \
1239f74cb0beSJayanth Dodderi Chidanand        ENABLE_FEAT_FGT \
1240f74cb0beSJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1 \
1241f74cb0beSJayanth Dodderi Chidanand        ENABLE_FEAT_ECV \
12421f1c0206SAbdul Halim, Muhammad Hadi Asyrafi        SIMICS_BUILD \
12436a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1p1 \
12446a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_SEL2 \
12456a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_VHE \
12466a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_CSV2_2 \
12476a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_PAN \
12486a0da736SJayanth Dodderi Chidanand        FEATURE_DETECTION \
1249781d07a4SJayanth Dodderi Chidanand        TWED_DELAY \
1250781d07a4SJayanth Dodderi Chidanand        ENABLE_FEAT_TWED \
125104c7303bSOkash Khawaja	CONDITIONAL_CMO \
1252327131c4SLeonardo Sandoval)))
12532fae4b1eSJeenu Viswambharan
12541f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
12551f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
12561f461979SJustin Chadwellendif
12571f461979SJustin Chadwell
12584c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
12594c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
12604c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1261cf2c8a33SAntonio Nino Diazelse
126268450a6dSAntonio Nino Diaz        # Define the PRELOADED_BL33_BASE flag only if it is provided and
126368450a6dSAntonio Nino Diaz        # EL3_PAYLOAD_BASE is not defined, as it has priority.
126468450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
126568450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
12664c117f6cSSandrine Bailleux        endif
1267cf2c8a33SAntonio Nino Diazendif
126873c99d4eSJuan Castillo
1269209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1270209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1271209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH))
1272209a60ccSSoby Mathewendif
1273209a60ccSSoby Mathew
1274c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
1275c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK))
1276c2ad38ceSVarun Wadekarendif
1277c2ad38ceSVarun Wadekar
1278ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1279ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1280c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1281ce2b1ec6SManish Pandey        -include $(BUILD_PLAT)/sp_gen.mk
1282ce2b1ec6SManish Pandey        FIP_DEPS += sp
128307c44475SManish Pandey        CRT_DEPS += sp
1284ce2b1ec6SManish Pandey        NEED_SP_PKG := yes
1285ce2b1ec6SManish Pandeyelse
1286c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},1)
1287c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1288c33ff198SOlivier Deprez        endif
1289ce2b1ec6SManish Pandeyendif
1290ce2b1ec6SManish Pandeyendif
1291ce2b1ec6SManish Pandey
129273c99d4eSJuan Castillo################################################################################
129373c99d4eSJuan Castillo# Build targets
129473c99d4eSJuan Castillo################################################################################
129573c99d4eSJuan Castillo
129690aa901fSSumit Garg.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
129773c99d4eSJuan Castillo.SUFFIXES:
129873c99d4eSJuan Castillo
129973c99d4eSJuan Castilloall: msg_start
130073c99d4eSJuan Castillo
130173c99d4eSJuan Castillomsg_start:
130273c99d4eSJuan Castillo	@echo "Building ${PLAT}"
130373c99d4eSJuan Castillo
13047a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1305d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
1306c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),)
1307c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1308c2ad38ceSVarun Wadekarelse
1309bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
13107a24cba5SSoby Mathewendif
1311d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED
13127a24cba5SSoby Mathew
13135accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS))
131461f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
13155fee0287SRoberto Vargas
131673c99d4eSJuan Castillo# Expand build macros for the different images
131773c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
1318b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES})
1319b34635a0SChris Kay
1320434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1))
132173c99d4eSJuan Castilloendif
132273c99d4eSJuan Castillo
132373c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1324c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0)
1325c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1326c9b31ae8SRoberto Vargasendif
1327c9b31ae8SRoberto Vargas
1328eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES})
1329eb1acfb6SChris Kay
133033950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1331434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
133273c99d4eSJuan Castilloendif
133373c99d4eSJuan Castillo
13344d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
133533950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
13364d045d0eSMasahiro Yamadaendif
13374d045d0eSMasahiro Yamada
133873c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
133973c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
134026d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
134126d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1342c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1343c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1344434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1345c6ba9b45SSumit Gargelse
134633950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1347434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw)))
134873c99d4eSJuan Castilloendif
1349c6ba9b45SSumit Gargendif
135073c99d4eSJuan Castillo
135170d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1352c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
135370d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
135473c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
135526d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
135626d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
13579cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
13589cd15239SMasahiro Yamada
1359c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1360434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1361c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1362c6ba9b45SSumit Gargelse
1363434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
136433950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
136573c99d4eSJuan Castilloendif
1366c6ba9b45SSumit Gargendif
136773c99d4eSJuan Castillo
13685b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
13695b18de09SZelalem Aweke# needs to be built from RMM_SOURCES.
13705b18de09SZelalem Awekeifeq (${NEED_RMM},yes)
13715b18de09SZelalem Aweke# Sort RMM source files to remove duplicates
13725b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES})
13735b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
13745b18de09SZelalem Aweke
13755b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
13765b18de09SZelalem Aweke         $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
13775b18de09SZelalem Awekeendif
13785b18de09SZelalem Aweke
137973c99d4eSJuan Castillo# Add the BL33 image if required by the platform
138073c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
138133950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1382db6071c9SJuan Castilloendif
1383db6071c9SJuan Castillo
13849003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
138533950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1386434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
13879003fa0bSYatharth Kocharendif
13889003fa0bSYatharth Kochar
138903b397a8SNishanth Menon# Expand build macros for the different images
139003b397a8SNishanth Menonifeq (${NEED_FDT},yes)
139103b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
139203b397a8SNishanth Menonendif
139303b397a8SNishanth Menon
1394ce2b1ec6SManish Pandey# Add Secure Partition packages
1395ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1396ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
13971e7528ecSRuari Phipps	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1398822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1399ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1400ce2b1ec6SManish Pandey	@echo "Built SP Images successfully"
1401ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1402ce2b1ec6SManish Pandeyendif
1403ce2b1ec6SManish Pandey
140436eaaf37SIan Spraylocate-checkpatch:
140536eaaf37SIan Sprayifndef CHECKPATCH
140666079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
140736eaaf37SIan Sprayelse
140836eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
140966079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
141036eaaf37SIan Sprayendif
141136eaaf37SIan Sprayendif
141236eaaf37SIan Spray
14134f6ad66aSAchin Guptaclean:
14144f6ad66aSAchin Gupta	@echo "  CLEAN"
1415f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
141688a1cf1eSSami Mujawarifdef UNIX_MK
14172f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
141888a1cf1eSSami Mujawarelse
141988a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
142088a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
142188a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
142288a1cf1eSSami Mujawarendif
14236f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
142490aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
14255accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
14264f6ad66aSAchin Gupta
1427eaaeece2SJames Morrisseyrealclean distclean:
1428eaaeece2SJames Morrissey	@echo "  REALCLEAN"
1429f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1430f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
143188a1cf1eSSami Mujawarifdef UNIX_MK
14322f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
143388a1cf1eSSami Mujawarelse
143488a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
143588a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
143688a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
143788a1cf1eSSami Mujawarendif
1438e15591aaSNicolas Boulenguez	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
143990aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
14405accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
14414f6ad66aSAchin Gupta
144236eaaf37SIan Spraycheckcodebase:		locate-checkpatch
144336eaaf37SIan Spray	@echo "  CHECKING STYLE"
144436eaaf37SIan Spray	@if test -d .git ; then						\
14451ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
14461a41e8c1SDan Handley		while read GIT_FILE ;					\
14471a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
14481a41e8c1SDan Handley		done ;							\
144936eaaf37SIan Spray	else								\
14501a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
14511a41e8c1SDan Handley		 -not -iwholename "*build*"				\
14521a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
145361f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
14541a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
14551ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
14561a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
145736eaaf37SIan Spray	fi
145836eaaf37SIan Spray
145936eaaf37SIan Spraycheckpatch:		locate-checkpatch
146036eaaf37SIan Spray	@echo "  CHECKING STYLE"
146102a76d5fSYann Gautier	@if test -n "${CHECKPATCH_OPTS}"; then				\
146202a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
146302a76d5fSYann Gautier	fi
146451d28937SAntonio Nino Diaz	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
146577a0a7f1SYann Gautier	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
146677a0a7f1SYann Gautier	do								\
146751d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
146851d28937SAntonio Nino Diaz		git log --format=email "$$commit~..$$commit"		\
146902a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
147002a76d5fSYann Gautier			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
147151d28937SAntonio Nino Diaz		git diff --format=email "$$commit~..$$commit"		\
147202a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
147302a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
147451d28937SAntonio Nino Diaz	done
147536eaaf37SIan Spray
147673c99d4eSJuan Castillocerttool: ${CRTTOOL}
147773c99d4eSJuan Castillo
1478a9812206SPali Rohár${CRTTOOL}: FORCE
1479598b166bSLionel 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
1480f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
14816f971622SJuan Castillo	@echo "Built $@ successfully"
1482f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
14836f971622SJuan Castillo
14846f971622SJuan Castilloifneq (${GENERATE_COT},0)
148573c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
14866f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
1487f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
14886f971622SJuan Castillo	@echo "Built $@ successfully"
14896f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
1490f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
149173c99d4eSJuan Castilloendif
149227713fb4SSoby Mathew
149373c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
14944727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
1495819281eeSdp-arm	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1496819281eeSdp-arm	${Q}${FIPTOOL} info $@
1497f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
14982f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
1499f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1500f58ad36fSHarry Liebel
15010191262dSYatharth Kocharifneq (${GENERATE_COT},0)
15020191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
15030191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1504052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15050191262dSYatharth Kochar	@echo "Built $@ successfully"
15060191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1507052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15080191262dSYatharth Kocharendif
15090191262dSYatharth Kochar
15100191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
15114727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
1512819281eeSdp-arm	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1513819281eeSdp-arm	${Q}${FIPTOOL} info $@
1514052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15150191262dSYatharth Kochar	@echo "Built $@ successfully"
1516052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15170191262dSYatharth Kochar
151873c99d4eSJuan Castillofiptool: ${FIPTOOL}
151973c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
15200191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
152173c99d4eSJuan Castillo
1522a9812206SPali Rohár${FIPTOOL}: FORCE
152388a1cf1eSSami Mujawarifdef UNIX_MK
1524598b166bSLionel Debieve	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
152588a1cf1eSSami Mujawarelse
152688a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
152788a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
152888a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
152988a1cf1eSSami Mujawarendif
1530f58ad36fSHarry Liebel
1531a9812206SPali Rohárromlib.bin: libraries FORCE
1532bbb24f61SJohn 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
15335accce5bSRoberto Vargas
1534cfe83910SLouis Mayencourt# Call print_memory_map tool
1535cfe83910SLouis Mayencourtmemmap: all
1536b890b36dSLouis Mayencourt	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1537cfe83910SLouis Mayencourt
15386de32378SMadhukar Pappireddydoc:
15396de32378SMadhukar Pappireddy	@echo "  BUILD DOCUMENTATION"
15406de32378SMadhukar Pappireddy	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
15416de32378SMadhukar Pappireddy
154290aa901fSSumit Gargenctool: ${ENCTOOL}
154390aa901fSSumit Garg
1544a9812206SPali Rohár${ENCTOOL}: FORCE
1545598b166bSLionel Debieve	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
154690aa901fSSumit Garg	@${ECHO_BLANK_LINE}
154790aa901fSSumit Garg	@echo "Built $@ successfully"
154890aa901fSSumit Garg	@${ECHO_BLANK_LINE}
154990aa901fSSumit Garg
155035fab8c9SJoakim Bechcscope:
155135fab8c9SJoakim Bech	@echo "  CSCOPE"
155235fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
155335fab8c9SJoakim Bech	${Q}cscope -b -q -k
155435fab8c9SJoakim Bech
155572ee3314SRyan Harkinhelp:
15567c23126cSJohn Tsichritzis	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
155772ee3314SRyan Harkin	@echo ""
155872ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
155908c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
156072ee3314SRyan Harkin	@echo ""
15617c23126cSJohn Tsichritzis	@echo "platform = ${PLATFORM_LIST}"
15627c23126cSJohn Tsichritzis	@echo ""
15631b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
15641b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
15651b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
15661b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
15671b578596SSandrine Bailleux	@echo ""
156872ee3314SRyan Harkin	@echo "Supported Targets:"
15691b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
157036eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
15718aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
15729003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
1573d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
15749d29c227SSoby Mathew	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
15759d29c227SSoby Mathew	@echo "                 this builds secure payload specified by AARCH32_SP"
157673c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
15771b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
15780191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
157936eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
158036eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
158136eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
158272ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
158335fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
158472ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
15856f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
158690aa901fSSumit Garg	@echo "  enctool        Build the Firmware encryption tool"
1587f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1588ce2b1ec6SManish Pandey	@echo "  sp             Build the Secure Partition Packages"
158926010da1SAntonio Nino Diaz	@echo "  sptool         Build the Secure Partition Package creation tool"
159038c14d88SSoby Mathew	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1591cfe83910SLouis Mayencourt	@echo "  memmap         Print the memory map of the built binaries"
15926de32378SMadhukar Pappireddy	@echo "  doc            Build html based documentation using Sphinx tool"
159372ee3314SRyan Harkin	@echo ""
15941b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
159572ee3314SRyan Harkin	@echo ""
159672ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
159772ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1598a9812206SPali Rohár
1599a9812206SPali Rohár.PHONY: FORCE
1600a9812206SPali RohárFORCE:;
1601