xref: /rk3399_ARM-atf/Makefile (revision d75a9ecdaa8caa7f845297958a3f606b66bc2264)
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	\
353*d75a9ecdSBoyan Karatotev				-Wredundant-decls
354*d75a9ecdSBoyan Karatotev# stricter warnings
355*d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wextra -Wno-trigraphs
356*d75a9ecdSBoyan Karatotev# too verbose for generic build
357*d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-missing-field-initializers \
358*d75a9ecdSBoyan Karatotev				-Wno-type-limits -Wno-sign-compare \
359*d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
360*d75a9ecdSBoyan KaratotevWARNINGS		+=	-Wno-unused-parameter
3619ab81b5eSJustin Chadwell
3629ab81b5eSJustin Chadwell# Additional warnings
363*d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of
364*d75a9ecdSBoyan Karatotev# full -Wextra
365*d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare
366*d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits
367*d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers
368e7c645b5SYann Gautier
369*d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want
370*d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
371*d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build
372*d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition
373*d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes
374*d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute
375*d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present
376*d75a9ecdSBoyan KaratotevWARNING2 += -Wundef
377e7c645b5SYann Gautier
378*d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored
379e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
380*d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return
381*d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs
382*d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align
383e7c645b5SYann GautierWARNING3 += -Wcast-qual
384e7c645b5SYann GautierWARNING3 += -Wconversion
385e7c645b5SYann GautierWARNING3 += -Wpacked
386e7c645b5SYann GautierWARNING3 += -Wpointer-arith
387e7c645b5SYann GautierWARNING3 += -Wswitch-default
388e7c645b5SYann Gautier
389*d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues
390*d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings
391*d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed
392*d75a9ecdSBoyan Karatotevifdef W
393*d75a9ecdSBoyan Karatotevifneq (${W},0)
394*d75a9ecdSBoyan KaratotevE	 ?= 0
395*d75a9ecdSBoyan Karatotevendif
396*d75a9ecdSBoyan Karatotevendif
397*d75a9ecdSBoyan Karatotev
398e7c645b5SYann Gautierifeq (${W},1)
3999ab81b5eSJustin ChadwellWARNINGS += $(WARNING1)
400e7c645b5SYann Gautierelse ifeq (${W},2)
4019ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2)
402e7c645b5SYann Gautierelse ifeq (${W},3)
4039ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
404e7c645b5SYann Gautierendif
405e7c645b5SYann Gautier
4069ab81b5eSJustin Chadwell# Compiler specific warnings
40700296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),)
40893c690ebSJustin Chadwell# not using clang
409d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
410d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
411d7b4cd41SJustin Chadwell				-Wlogical-op
41293c690ebSJustin Chadwellelse
41393c690ebSJustin Chadwell# using clang
414d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
415d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
41600296576SAmbroise Vincentendif
41700296576SAmbroise Vincent
4186336b07aSYann Gautierifneq (${E},0)
4196336b07aSYann GautierERRORS := -Werror
4206336b07aSYann Gautierendif
4216336b07aSYann Gautier
422ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
4239ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
42459de5096SMasahiro YamadaASFLAGS			+=	$(CPPFLAGS) $(ASFLAGS_$(ARCH))			\
425d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
42659de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
427ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
428ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
429ebd6efaeSSamuel Holland				-Os -std=gnu99
43073c99d4eSJuan Castillo
431bebcf27fSMark Brown$(eval $(call add_define,SVE_VECTOR_LEN))
432bebcf27fSMark Brown
4331f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4341f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover
4351f461979SJustin Chadwellendif
4361f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
4371f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover	\
4381f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
4391f461979SJustin Chadwellendif
4401f461979SJustin Chadwell
441f7ec31dbSdavid cunadoGCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
442f7ec31dbSdavid cunado
443641f16e7SAmbroise Vincent# LD = armlink
444c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
445c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
446c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
447edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
448641f16e7SAmbroise Vincent
449641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
450edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),)
451edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches
452edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
453edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--gc-sections
454edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
455edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
456edbce9aaSzelalem-aweke		TF_LDFLAGS	+=	-flto -fuse-linker-plugin
457edbce9aaSzelalem-aweke	endif
458edbce9aaSzelalem-awekeendif
459edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
460edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
461edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1)
462edbce9aaSzelalem-aweke	TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
463edbce9aaSzelalem-awekeendif
464edbce9aaSzelalem-awekeTF_LDFLAGS		+= 	-nostdlib
465edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
466641f16e7SAmbroise Vincent
467641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
468c2ad38ceSVarun Wadekarelse
469c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--fatal-warnings -O1
470c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--gc-sections
471641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
472641f16e7SAmbroise Vincent# therefore don't add those in that case
473641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),)
474c2b8806fSDouglas RaillardTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
475edbce9aaSzelalem-awekeendif
476641f16e7SAmbroise Vincentendif
47773c99d4eSJuan Castillo
47803b397a8SNishanth MenonDTC_FLAGS		+=	-I dts -O dtb
479a6de824fSLouis MayencourtDTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
480a6de824fSLouis Mayencourt				-x assembler-with-cpp $(DEFINES)
48103b397a8SNishanth Menon
48273c99d4eSJuan Castillo################################################################################
48373c99d4eSJuan Castillo# Common sources and include directories
48473c99d4eSJuan Castillo################################################################################
4856a0da736SJayanth Dodderi Chidanandinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk
486d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
48773c99d4eSJuan Castillo
48873c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
4897f56e9a3SSoby Mathew				common/tf_log.c				\
4909d29c227SSoby Mathew				common/${ARCH}/debug.S			\
49191b48c9fSJulius Werner				drivers/console/multi_console.c		\
4929d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
4939d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
494566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
4957f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
49675311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
4979d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
49861f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
499d7a6b0f8SRyan Harkin
5008422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang)
5018422a840SAntonio Nino DiazBL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
5028422a840SAntonio Nino Diazendif
5038422a840SAntonio Nino Diaz
5041f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
5051f461979SJustin ChadwellBL_COMMON_SOURCES	+=	plat/common/ubsan.c
5061f461979SJustin Chadwellendif
5071f461979SJustin Chadwell
50801d237cbSYann GautierINCLUDES		+=	-Iinclude				\
509f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
51009d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
51109d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
51209d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
51309d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
51409d40e0eSAntonio Nino Diaz
5159c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
5169c6d1c50SAntonio Nino Diaz
51773c99d4eSJuan Castillo################################################################################
51873c99d4eSJuan Castillo# Generic definitions
51973c99d4eSJuan Castillo################################################################################
52073c99d4eSJuan Castillo
521231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
522231c1470SEvan Lloyd
52329214e95SGrant Likelyifeq (${BUILD_BASE},)
52473c99d4eSJuan Castillo     BUILD_BASE		:=	./build
52529214e95SGrant Likelyendif
52629214e95SGrant LikelyBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
52773c99d4eSJuan Castillo
528231c1470SEvan LloydSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
52973c99d4eSJuan Castillo
53073c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
53173c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
53273c99d4eSJuan Castillo
53373c99d4eSJuan Castillo
53473c99d4eSJuan Castillo################################################################################
53573c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
53673c99d4eSJuan Castillo################################################################################
53773c99d4eSJuan Castillo
53873c99d4eSJuan Castilloifneq (${SPD},none)
5399d29c227SSoby Mathew    ifeq (${ARCH},aarch32)
5409d29c227SSoby Mathew        $(error "Error: SPD is incompatible with AArch32.")
5419d29c227SSoby Mathew    endif
54228f39f02SMax Shvetsov
5434c117f6cSSandrine Bailleux    ifdef EL3_PAYLOAD_BASE
5444c117f6cSSandrine Bailleux        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
5454c117f6cSSandrine Bailleux        $(warning "The SPD and its BL32 companion will be present but ignored.")
5464c117f6cSSandrine Bailleux    endif
54728f39f02SMax Shvetsov
548c3fb00d9SAchin Gupta    ifeq (${SPD},spmd)
549c3fb00d9SAchin Gupta        # SPMD is located in std_svc directory
550c3fb00d9SAchin Gupta        SPD_DIR := std_svc
55128f39f02SMax Shvetsov
552033039f8SMax Shvetsov        ifeq ($(SPMD_SPM_AT_SEL2),1)
55328f39f02SMax Shvetsov            ifeq ($(CTX_INCLUDE_EL2_REGS),0)
554033039f8SMax Shvetsov                $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
555033039f8SMax Shvetsov            endif
5561d63ae4dSMarc Bonnici	    ifeq ($(SPMC_AT_EL3),1)
5571d63ae4dSMarc Bonnici                $(error SPM cannot be enabled in both S-EL2 and EL3.)
5581d63ae4dSMarc Bonnici            endif
55928f39f02SMax Shvetsov        endif
560db1ef41aSOlivier Deprez
561db1ef41aSOlivier Deprez        ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
562db1ef41aSOlivier Deprez            DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
563db1ef41aSOlivier Deprez        endif
564ca932481SDavidson K
565ca932481SDavidson K        ifeq ($(TS_SP_FW_CONFIG),1)
566ca932481SDavidson K            DTC_CPPFLAGS	+=	-DTS_SP_FW_CONFIG
567ca932481SDavidson K        endif
56833993a37SBalint Dobszay
56933993a37SBalint Dobszay        ifneq ($(ARM_BL2_SP_LIST_DTS),)
57033993a37SBalint Dobszay            DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
57133993a37SBalint Dobszay        endif
57246789a7cSBalint Dobszay
57346789a7cSBalint Dobszay        ifneq ($(SP_LAYOUT_FILE),)
57446789a7cSBalint Dobszay            BL2_ENABLE_SP_LOAD := 1
57546789a7cSBalint Dobszay        endif
576c3fb00d9SAchin Gupta    else
577c3fb00d9SAchin Gupta        # All other SPDs in spd directory
578c3fb00d9SAchin Gupta        SPD_DIR := spd
579c3fb00d9SAchin Gupta    endif
580c3fb00d9SAchin Gupta
58173c99d4eSJuan Castillo    # We expect to locate an spd.mk under the specified SPD directory
582c3fb00d9SAchin Gupta    SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
583c3fb00d9SAchin Gupta
58473c99d4eSJuan Castillo    ifeq (${SPD_MAKE},)
585c3fb00d9SAchin Gupta        $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
58673c99d4eSJuan Castillo    endif
58773c99d4eSJuan Castillo    $(info Including ${SPD_MAKE})
58873c99d4eSJuan Castillo    include ${SPD_MAKE}
58973c99d4eSJuan Castillo
59070d1fc53SJuan Castillo    # If there's BL32 companion for the chosen SPD, we expect that the SPD's
59170d1fc53SJuan Castillo    # Makefile would set NEED_BL32 to "yes". In this case, the build system
59270d1fc53SJuan Castillo    # supports two mutually exclusive options:
59370d1fc53SJuan Castillo    # * BL32 is built from source: then BL32_SOURCES must contain the list
59470d1fc53SJuan Castillo    #   of source files to build BL32
59570d1fc53SJuan Castillo    # * BL32 is a prebuilt binary: then BL32 must point to the image file
59670d1fc53SJuan Castillo    #   that will be included in the FIP
59770d1fc53SJuan Castillo    # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
59870d1fc53SJuan Castillo    # over the sources.
599e35c4045SJeenu Viswambharanendif
600e35c4045SJeenu Viswambharan
60151faada7SDouglas Raillard################################################################################
6025b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled
6035b18de09SZelalem Aweke################################################################################
6045b18de09SZelalem Aweke
6055b18de09SZelalem Awekeifneq (${ENABLE_RME},0)
6065b18de09SZelalem Awekeifneq (${ARCH},aarch64)
6075b18de09SZelalem Aweke	$(error ENABLE_RME requires AArch64)
6085b18de09SZelalem Awekeendif
6091d63ae4dSMarc Bonniciifeq ($(SPMC_AT_EL3),1)
6101d63ae4dSMarc Bonnici	$(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
6111d63ae4dSMarc Bonniciendif
6125b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk
6135b18de09SZelalem Aweke$(warning "RME is an experimental feature")
6145b18de09SZelalem Awekeendif
6155b18de09SZelalem Aweke
6165b18de09SZelalem Aweke################################################################################
61773c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
61873c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
61973c99d4eSJuan Castillo################################################################################
6202da8d8bfSJeenu Viswambharan
62173c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
6220f21c547SJuan Castillo
6238012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
6248012cc5cSMasahiro Yamada
62526e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
62626e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
62726e63c44SEtienne Carriereendif
62826e63c44SEtienne Carriere
6293bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
6303bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
6313bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
6327b592418SSamuel Hollandifneq ($(findstring gcc,$(notdir $(LD))),)
6337b592418SSamuel Holland	TF_LDFLAGS	+=	-no-pie
6347b592418SSamuel Hollandendif
6353bd17c0fSSoby Mathewendif
636320920c1SMasahiro Yamada
637320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),)
638320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
639320920c1SMasahiro Yamadaelse
640320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
641320920c1SMasahiro Yamadaendif
642320920c1SMasahiro Yamada
643320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
64469af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
64569af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1)
64669af7fcfSMasahiro Yamada	BL2_CFLAGS	+=	-fpie
64769af7fcfSMasahiro Yamada	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
64869af7fcfSMasahiro Yamadaendif
64969af7fcfSMasahiro Yamadaendif
650320920c1SMasahiro Yamada	BL31_CFLAGS	+=	-fpie
651320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
652d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
653d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
654d974301dSMasahiro Yamadaendif
6553bd17c0fSSoby Mathew
656d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64)
6579cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
658d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
6599cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3
660d5e97a1dSMasahiro Yamadaelse
6619cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1
662d5e97a1dSMasahiro Yamadaendif
6639cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1
6649cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3
6659cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1
666d5e97a1dSMasahiro Yamadaendif
667d5e97a1dSMasahiro Yamada
66854035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
66954035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
67054035fc4SSandrine Bailleux# This can be overridden by the platform.
67173c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
6724f6ad66aSAchin Gupta
673a4409008Sdp-armifeq (${ARCH},aarch32)
674a4409008Sdp-armNEED_BL32 := yes
675a4409008Sdp-arm
676a4409008Sdp-arm################################################################################
677a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
678a4409008Sdp-arm################################################################################
679a4409008Sdp-armifneq (${AARCH32_SP},none)
680a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory
681a4409008Sdp-armAARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
682a4409008Sdp-arm
683a4409008Sdp-armifeq (${AARCH32_SP_MAKE},)
684a4409008Sdp-arm  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
685a4409008Sdp-armendif
686a4409008Sdp-arm
687a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE})
688a4409008Sdp-arminclude ${AARCH32_SP_MAKE}
689a4409008Sdp-armendif
690a4409008Sdp-arm
691a4409008Sdp-armendif
6924f6ad66aSAchin Gupta
69373c99d4eSJuan Castillo################################################################################
69477f1f7a1SVarun Wadekar# Include libc if not overridden
69577f1f7a1SVarun Wadekar################################################################################
69677f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
69777f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
69877f1f7a1SVarun Wadekarendif
69977f1f7a1SVarun Wadekar
70077f1f7a1SVarun Wadekar################################################################################
701cf2c8a33SAntonio Nino Diaz# Check incompatible options
702cf2c8a33SAntonio Nino Diaz################################################################################
703cf2c8a33SAntonio Nino Diaz
704cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
70568450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
70668450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
70768450a6dSAntonio Nino Diaz                incompatible build options. EL3_PAYLOAD_BASE has priority.")
708cf2c8a33SAntonio Nino Diaz        endif
70976580f3dSQixiang Xu        ifneq (${GENERATE_COT},0)
71076580f3dSQixiang Xu                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
71176580f3dSQixiang Xu        endif
71276580f3dSQixiang Xu        ifneq (${TRUSTED_BOARD_BOOT},0)
71376580f3dSQixiang Xu                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
71476580f3dSQixiang Xu        endif
715cf2c8a33SAntonio Nino Diazendif
716cf2c8a33SAntonio Nino Diaz
717cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
718cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
719cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
720cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
721cf2c8a33SAntonio Nino Diaz        endif
72268450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
72368450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
72468450a6dSAntonio Nino Diaz                PRELOADED_BL33_BASE is used and won't be added to the FIP \
72568450a6dSAntonio Nino Diaz                file.")
726cf2c8a33SAntonio Nino Diaz        endif
727cf2c8a33SAntonio Nino Diazendif
728cf2c8a33SAntonio Nino Diaz
729d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
730d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
731d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
732d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
733d4593e47SJeenu Viswambharanendif
7341a0a3f06SYatharth Kochar
7357d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
7367d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
7377d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
7387d173fc5SJiafei Panendif
7397d173fc5SJiafei Pan
74014c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first
74114c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
74246cc41d5SManish Pandey    ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
74346cc41d5SManish Pandey        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1)
74414c6016aSJeenu Viswambharan    endif
74514c6016aSJeenu Viswambharanendif
74614c6016aSJeenu Viswambharan
7471a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
7481a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
7491a7c1cfeSJeenu Viswambharan    ifneq ($(RAS_EXTENSION),1)
7501a7c1cfeSJeenu Viswambharan        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
7511a7c1cfeSJeenu Viswambharan    endif
7521a7c1cfeSJeenu Viswambharanendif
7531a7c1cfeSJeenu Viswambharan
754ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
755209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
756209a60ccSSoby Mathew    ifeq (${TRUSTED_BOARD_BOOT}, 0)
757209a60ccSSoby Mathew        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
758209a60ccSSoby Mathew    endif
759209a60ccSSoby Mathewendif
760209a60ccSSoby Mathew
7612bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
7622bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
7632bf4f27fSManish V Badarkhe    CRYPTO_SUPPORT := 3
7642bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
7652bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation
7662bf4f27fSManish V Badarkhe    CRYPTO_SUPPORT := 3
7672bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
7682bf4f27fSManish V Badarkhe# Support hash calculation only
7692bf4f27fSManish V Badarkhe    CRYPTO_SUPPORT := 2
7702bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1)
7712bf4f27fSManish V Badarkhe# Support authentication verification only
772c9c56f6eSManish V Badarkhe    CRYPTO_SUPPORT := 1
773c9c56f6eSManish V Badarkheelse
774c9c56f6eSManish V Badarkhe    CRYPTO_SUPPORT := 0
775c9c56f6eSManish V Badarkheendif
776c9c56f6eSManish V Badarkhe
777cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
778cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
779700e7685SManish Pandey$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
78084ef9cd8SManish V Badarkheendif
78184ef9cd8SManish V Badarkhe
782b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
7839fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
7849fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
785b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
7869fc59639SAlexei Fedorov    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
7879fc59639SAlexei Fedorov        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
78806715f85SAlexei Fedorov    endif
7899fc59639SAlexei Fedorovendif
7909fc59639SAlexei Fedorov
79106715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
7929fc59639SAlexei Fedorov    ifneq (${ARCH},aarch64)
7939fc59639SAlexei Fedorov        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
794b86048c4SAntonio Nino Diaz    endif
795b86048c4SAntonio Nino Diazendif
7969fc59639SAlexei Fedorov
7979dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1)
7989dd94382SJustin Chadwell    ifneq (${ARCH},aarch64)
7999dd94382SJustin Chadwell        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
8009dd94382SJustin Chadwell    endif
8019dd94382SJustin Chadwellendif
8029dd94382SJustin Chadwell
803396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1)
804396b339dSManish V Badarkhe    $(info PSA_FWU_SUPPORT is an experimental feature)
805396b339dSManish V Badarkheendif
806396b339dSManish V Badarkhe
8076a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1)
8086a0da736SJayanth Dodderi Chidanand    $(info FEATURE_DETECTION is an experimental feature)
8096a0da736SJayanth Dodderi Chidanandendif
8106a0da736SJayanth Dodderi Chidanand
81160e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
81260e8f3cfSPetre-Ionut Tudor    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
81360e8f3cfSPetre-Ionut Tudor        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
81460e8f3cfSPetre-Ionut Tudor    endif
81560e8f3cfSPetre-Ionut Tudorendif
81660e8f3cfSPetre-Ionut Tudor
8177cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
8187cda17bbSSumit Garg    ifeq (${TRUSTED_BOARD_BOOT}, 0)
8197cda17bbSSumit Garg        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
8207cda17bbSSumit Garg    endif
8217cda17bbSSumit Gargendif
8227cda17bbSSumit Garg
823744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build
824dc78e62dSjohpow01ifeq (${ARCH},aarch32)
825744ad974Sjohpow01
826744ad974Sjohpow01    # SME/SVE only supported on AArch64
827dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},1)
828dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
829dc78e62dSjohpow01    endif
830dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},1)
831dc78e62dSjohpow01        # Warning instead of error due to CI dependency on this
83224ab2c0aSYann Gautier        $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
833dc78e62dSjohpow01    endif
834744ad974Sjohpow01
835ff86e0b4SJuan Pablo Conde    # BRBE is not supported in AArch32
836744ad974Sjohpow01    ifeq (${ENABLE_BRBE_FOR_NS},1)
837744ad974Sjohpow01        $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
838744ad974Sjohpow01    endif
839744ad974Sjohpow01
840ff86e0b4SJuan Pablo Conde    # FEAT_RNG_TRAP is not supported in AArch32
841ff86e0b4SJuan Pablo Conde    ifeq (${ENABLE_FEAT_RNG_TRAP},1)
842ff86e0b4SJuan Pablo Conde        $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
843ff86e0b4SJuan Pablo Conde    endif
844dc78e62dSjohpow01endif
845dc78e62dSjohpow01
846dc78e62dSjohpow01# Ensure ENABLE_RME is not used with SME
847dc78e62dSjohpow01ifeq (${ENABLE_RME},1)
848dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},1)
849dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
850dc78e62dSjohpow01    endif
851dc78e62dSjohpow01endif
852dc78e62dSjohpow01
853dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well
854dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1)
855dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},0)
856dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
857dc78e62dSjohpow01    endif
858dc78e62dSjohpow01endif
859dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1)
860dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},0)
861dc78e62dSjohpow01        $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
862dc78e62dSjohpow01    endif
863dc78e62dSjohpow01endif
864dc78e62dSjohpow01
865dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
866dc78e62dSjohpow01# its own context management including FPU registers.
867dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1)
868dc78e62dSjohpow01    ifeq (${ENABLE_SME_FOR_NS},1)
869dc78e62dSjohpow01        $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
870dc78e62dSjohpow01    endif
871dc78e62dSjohpow01    ifeq (${ENABLE_SVE_FOR_NS},1)
872dc78e62dSjohpow01        # Warning instead of error due to CI dependency on this
873dc78e62dSjohpow01        $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
874dc78e62dSjohpow01        $(warning "Forced ENABLE_SVE_FOR_NS=0")
875dc78e62dSjohpow01        override ENABLE_SVE_FOR_NS	:= 0
876dc78e62dSjohpow01    endif
877dc78e62dSjohpow01endif
878dc78e62dSjohpow01
87900e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1)
88000e28874SManish V Badarkhe    $(info DRTM_SUPPORT is an experimental feature)
88100e28874SManish V Badarkheendif
88200e28874SManish V Badarkhe
883274a69e7SChris Kayifeq (${ENABLE_RME},1)
884274a69e7SChris Kay    ifneq (${SEPARATE_CODE_AND_RODATA},1)
885274a69e7SChris Kay        $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
886274a69e7SChris Kay    endif
887274a69e7SChris Kayendif
888274a69e7SChris Kay
889cf2c8a33SAntonio Nino Diaz################################################################################
89073c99d4eSJuan Castillo# Process platform overrideable behaviour
89173c99d4eSJuan Castillo################################################################################
8924f6ad66aSAchin Gupta
8935f24ce96SManish Pandeyifdef BL1_SOURCES
8945f24ce96SManish PandeyNEED_BL1 := yes
8955f24ce96SManish Pandeyendif
8965f24ce96SManish Pandey
8975f24ce96SManish Pandeyifdef BL2_SOURCES
8985f24ce96SManish Pandey	NEED_BL2 := yes
8995f24ce96SManish Pandey
900bd97f83aSJohn Tsichritzis	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
901bd97f83aSJohn Tsichritzis	# Certificate generation tools. This flag can be overridden by the platform.
902cf2c8a33SAntonio Nino Diaz	ifdef EL3_PAYLOAD_BASE
903cf2c8a33SAntonio Nino Diaz                # If booting an EL3 payload there is no need for a BL33 image
904cf2c8a33SAntonio Nino Diaz                # in the FIP file.
9054c117f6cSSandrine Bailleux                NEED_BL33		:=	no
906cf2c8a33SAntonio Nino Diaz        else
90768450a6dSAntonio Nino Diaz                ifdef PRELOADED_BL33_BASE
908cf2c8a33SAntonio Nino Diaz                        # If booting a BL33 preloaded image there is no need of
909cf2c8a33SAntonio Nino Diaz                        # another one in the FIP file.
910cf2c8a33SAntonio Nino Diaz                        NEED_BL33		:=	no
911cf2c8a33SAntonio Nino Diaz                else
912cf2c8a33SAntonio Nino Diaz                        NEED_BL33		?=	yes
913cf2c8a33SAntonio Nino Diaz                endif
9144c117f6cSSandrine Bailleux        endif
91573c99d4eSJuan Castilloendif
9166f971622SJuan Castillo
9175f24ce96SManish Pandeyifdef BL2U_SOURCES
9185f24ce96SManish PandeyNEED_BL2U := yes
9195f24ce96SManish Pandeyendif
9205f24ce96SManish Pandey
9214d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
9224d045d0eSMasahiro Yamadaifdef SCP_BL2
9234d045d0eSMasahiro Yamada        NEED_SCP_BL2		:=	yes
9244d045d0eSMasahiro Yamadaendif
9254d045d0eSMasahiro Yamada
9265744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
9275744e874SSoby Mathewifneq (${ARCH},aarch32)
9285744e874SSoby Mathew    ifdef BL31_SOURCES
9295744e874SSoby Mathew        # When booting an EL3 payload, there is no need to compile the BL31 image nor
9305744e874SSoby Mathew        # put it in the FIP.
9315744e874SSoby Mathew        ifndef EL3_PAYLOAD_BASE
9325744e874SSoby Mathew            NEED_BL31 := yes
9335744e874SSoby Mathew        endif
9345744e874SSoby Mathew    endif
9355744e874SSoby Mathewendif
9365744e874SSoby Mathew
93773c99d4eSJuan Castillo# Process TBB related flags
9386f971622SJuan Castilloifneq (${GENERATE_COT},0)
93973c99d4eSJuan Castillo        # Common cert_create options
9406f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
9416f971622SJuan Castillo                $(eval CRT_ARGS += -n)
9420191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
943fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
944fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
9450191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
946fd34e7baSJuan Castillo                endif
9476f971622SJuan Castillo        endif
94873c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
94973c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
95073c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
95173c99d4eSJuan Castillo        endif
9526f971622SJuan Castilloendif
9536f971622SJuan Castillo
9541c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
9551c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN}
9561c75d5dfSMasahiro Yamadaendif
9571c75d5dfSMasahiro Yamada
9585f24ce96SManish Pandeyifdef FDT_SOURCES
9595f24ce96SManish PandeyNEED_FDT := yes
9605f24ce96SManish Pandeyendif
9615f24ce96SManish Pandey
96273c99d4eSJuan Castillo################################################################################
96346e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
96446e5e035SMichalis Pappas################################################################################
96546e5e035SMichalis Pappas
96646e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
96746e5e035SMichalis Pappas
96846e5e035SMichalis Pappas################################################################################
969819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc)
97073c99d4eSJuan Castillo################################################################################
97173c99d4eSJuan Castillo
97273c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
97373c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
97442a45b51SEvan LloydCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
97573c99d4eSJuan Castillo
97690aa901fSSumit Garg# Variables for use with Firmware Encryption Tool
97790aa901fSSumit GargENCTOOLPATH		?=	tools/encrypt_fw
97890aa901fSSumit GargENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
97990aa901fSSumit Garg
98073c99d4eSJuan Castillo# Variables for use with Firmware Image Package
981819281eeSdp-armFIPTOOLPATH		?=	tools/fiptool
982819281eeSdp-armFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
98373c99d4eSJuan Castillo
98426010da1SAntonio Nino Diaz# Variables for use with sptool
98526010da1SAntonio Nino DiazSPTOOLPATH		?=	tools/sptool
986822c7279SJ-AlvesSPTOOL			?=	${SPTOOLPATH}/sptool.py
987ce2b1ec6SManish PandeySP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
98826010da1SAntonio Nino Diaz
9895accce5bSRoberto Vargas# Variables for use with ROMLIB
9905accce5bSRoberto VargasROMLIBPATH		?=	lib/romlib
9915accce5bSRoberto Vargas
992cfe83910SLouis Mayencourt# Variable for use with Python
993cfe83910SLouis MayencourtPYTHON			?=	python3
994cfe83910SLouis Mayencourt
995cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP
996cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH		?=	tools/memory
997cfe83910SLouis MayencourtPRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
998cfe83910SLouis Mayencourt
9996de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool
10006de32378SMadhukar PappireddyDOCS_PATH		?=	docs
10016de32378SMadhukar Pappireddy
10021f1c0206SAbdul Halim, Muhammad Hadi Asyrafi# Defination of SIMICS flag
10031f1c0206SAbdul Halim, Muhammad Hadi AsyrafiSIMICS_BUILD	?=	0
10041f1c0206SAbdul Halim, Muhammad Hadi Asyrafi
10058a86052dSSoby Mathew################################################################################
10068a86052dSSoby Mathew# Include BL specific makefiles
10078a86052dSSoby Mathew################################################################################
10085f24ce96SManish Pandey
10095f24ce96SManish Pandeyifeq (${NEED_BL1},yes)
10108a86052dSSoby Mathewinclude bl1/bl1.mk
10118a86052dSSoby Mathewendif
10128a86052dSSoby Mathew
10135f24ce96SManish Pandeyifeq (${NEED_BL2},yes)
10148a86052dSSoby Mathewinclude bl2/bl2.mk
10158a86052dSSoby Mathewendif
10168a86052dSSoby Mathew
10175f24ce96SManish Pandeyifeq (${NEED_BL2U},yes)
10188a86052dSSoby Mathewinclude bl2u/bl2u.mk
10198a86052dSSoby Mathewendif
10208a86052dSSoby Mathew
10215744e874SSoby Mathewifeq (${NEED_BL31},yes)
10228a86052dSSoby Mathewinclude bl31/bl31.mk
10238a86052dSSoby Mathewendif
102403b397a8SNishanth Menon
102573c99d4eSJuan Castillo################################################################################
102673c99d4eSJuan Castillo# Build options checks
102773c99d4eSJuan Castillo################################################################################
102873c99d4eSJuan Castillo
1029327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
1030327131c4SLeonardo Sandoval    $(sort \
1031327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
103246789a7cSBalint Dobszay        BL2_ENABLE_SP_LOAD \
1033327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
1034327131c4SLeonardo Sandoval        CREATE_KEYS \
1035327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
1036327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
1037327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
1038327131c4SLeonardo Sandoval        DEBUG \
10390063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
1040327131c4SLeonardo Sandoval        DYN_DISABLE_AUTH \
1041327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
1042327131c4SLeonardo Sandoval        ENABLE_AMU \
10431fd685a7SChris Kay        ENABLE_AMU_AUXILIARY_COUNTERS \
1044742ca230SChris Kay        ENABLE_AMU_FCONF \
1045873d4241Sjohpow01        AMU_RESTRICT_COUNTERS \
1046327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
1047327131c4SLeonardo Sandoval        ENABLE_PIE \
1048327131c4SLeonardo Sandoval        ENABLE_PMF \
1049327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
1050327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
1051dc78e62dSjohpow01        ENABLE_SME_FOR_NS \
1052dc78e62dSjohpow01        ENABLE_SME_FOR_SWD \
1053327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
1054327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
10550c5e7d1cSMax Shvetsov        ENABLE_SVE_FOR_SWD \
1056327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
1057327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
1058327131c4SLeonardo Sandoval        GENERATE_COT \
1059327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
106046cc41d5SManish Pandey        HANDLE_EA_EL3_FIRST_NS \
1061327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
1062327131c4SLeonardo Sandoval        INVERTED_MEMMAP \
1063327131c4SLeonardo Sandoval        MEASURED_BOOT \
106400e28874SManish V Badarkhe        DRTM_SUPPORT \
1065327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
1066327131c4SLeonardo Sandoval        OVERRIDE_LIBC \
1067327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
10680ce2072dSTamas Ban        PLAT_RSS_NOT_SUPPORTED \
1069327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
1070327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
1071327131c4SLeonardo Sandoval        RESET_TO_BL31 \
107225844ff7SJorge Ramirez-Ortiz        RESET_TO_BL31_WITH_PARAMS \
1073327131c4SLeonardo Sandoval        SAVE_KEYS \
1074327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
107596a8ed14SJiafei Pan        SEPARATE_BL2_NOLOAD_REGION \
1076327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
1077327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
1078327131c4SLeonardo Sandoval        SPM_MM \
10791d63ae4dSMarc Bonnici        SPMC_AT_EL3 \
1080327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
1081327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
1082327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
1083327131c4SLeonardo Sandoval        USE_DEBUGFS \
1084327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
1085327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
1086327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
1087327131c4SLeonardo Sandoval        USE_ROMLIB \
1088327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
1089327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
1090327131c4SLeonardo Sandoval        BL2_AT_EL3 \
1091327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
1092327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
1093327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
1094327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
1095327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
1096327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
109700e8f79cSManish Pandey        RAS_TRAP_NS_ERR_REC_ACCESS \
1098327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
1099327131c4SLeonardo Sandoval        USE_SP804_TIMER \
1100396b339dSManish V Badarkhe        PSA_FWU_SUPPORT \
1101d4582d30SManish V Badarkhe        ENABLE_SYS_REG_TRACE_FOR_NS \
110268120783SChris Kay        ENABLE_MPMM \
110368120783SChris Kay        ENABLE_MPMM_FCONF \
11041f1c0206SAbdul Halim, Muhammad Hadi Asyrafi        SIMICS_BUILD \
11056a0da736SJayanth Dodderi Chidanand        FEATURE_DETECTION \
11060b22e591SJayanth Dodderi Chidanand	TRNG_SUPPORT \
110704c7303bSOkash Khawaja	CONDITIONAL_CMO \
1108327131c4SLeonardo Sandoval)))
110973c99d4eSJuan Castillo
1110327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
1111327131c4SLeonardo Sandoval    $(sort \
1112327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
1113327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
1114327131c4SLeonardo Sandoval        BRANCH_PROTECTION \
11156a0da736SJayanth Dodderi Chidanand        CTX_INCLUDE_PAUTH_REGS \
11166a0da736SJayanth Dodderi Chidanand        CTX_INCLUDE_MTE_REGS \
11176a0da736SJayanth Dodderi Chidanand        CTX_INCLUDE_NEVE_REGS \
11182bf4f27fSManish V Badarkhe        CRYPTO_SUPPORT \
11191298f2f1SJayanth Dodderi Chidanand        ENABLE_BRBE_FOR_NS \
112047c681b7SJayanth Dodderi Chidanand        ENABLE_TRBE_FOR_NS \
11216a0da736SJayanth Dodderi Chidanand        ENABLE_BTI \
11226a0da736SJayanth Dodderi Chidanand        ENABLE_PAUTH \
11236a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1 \
11246a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1p1 \
11256a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_CSV2_2 \
11266a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_DIT \
11276a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_ECV \
11286a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_FGT \
11296a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_HCX \
11306a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_PAN \
11316a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_RNG \
1132ff86e0b4SJuan Pablo Conde        ENABLE_FEAT_RNG_TRAP \
11336a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_SB \
11346a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_SEL2 \
11356a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_VHE \
11366a0da736SJayanth Dodderi Chidanand        ENABLE_MPAM_FOR_LOWER_ELS \
11376a0da736SJayanth Dodderi Chidanand        ENABLE_RME \
11386a0da736SJayanth Dodderi Chidanand        ENABLE_TRF_FOR_NS \
1139327131c4SLeonardo Sandoval        FW_ENC_STATUS \
11405357f83dSManish V Badarkhe        NR_OF_FW_BANKS \
11415357f83dSManish V Badarkhe        NR_OF_IMAGES_IN_FW_BANK \
11426a0da736SJayanth Dodderi Chidanand        RAS_EXTENSION \
1143781d07a4SJayanth Dodderi Chidanand        TWED_DELAY \
1144781d07a4SJayanth Dodderi Chidanand        ENABLE_FEAT_TWED \
1145bebcf27fSMark Brown        SVE_VECTOR_LEN \
1146327131c4SLeonardo Sandoval)))
1147c877b414SJeenu Viswambharan
1148aacff749SJustin Chadwellifdef KEY_SIZE
1149aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
1150aacff749SJustin Chadwellendif
1151aacff749SJustin Chadwell
11521f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
11531f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
11541f461979SJustin Chadwellendif
11551f461979SJustin Chadwell
115673c99d4eSJuan Castillo################################################################################
115773c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
115873c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
115973c99d4eSJuan Castillo# platform to overwrite the default options
116073c99d4eSJuan Castillo################################################################################
116173c99d4eSJuan Castillo
1162327131c4SLeonardo Sandoval$(eval $(call add_defines,\
1163327131c4SLeonardo Sandoval    $(sort \
1164327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
1165327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
1166327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
116746789a7cSBalint Dobszay        BL2_ENABLE_SP_LOAD \
1168327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
1169327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
1170327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
1171327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
1172327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
1173327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
1174327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
1175062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
1176327131c4SLeonardo Sandoval        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
11770063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
1178327131c4SLeonardo Sandoval        ENABLE_AMU \
11791fd685a7SChris Kay        ENABLE_AMU_AUXILIARY_COUNTERS \
1180742ca230SChris Kay        ENABLE_AMU_FCONF \
1181873d4241Sjohpow01        AMU_RESTRICT_COUNTERS \
1182327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
1183327131c4SLeonardo Sandoval        ENABLE_BTI \
1184327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
1185327131c4SLeonardo Sandoval        ENABLE_PAUTH \
1186327131c4SLeonardo Sandoval        ENABLE_PIE \
1187327131c4SLeonardo Sandoval        ENABLE_PMF \
1188327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
11895b18de09SZelalem Aweke        ENABLE_RME \
1190327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
1191dc78e62dSjohpow01        ENABLE_SME_FOR_NS \
1192dc78e62dSjohpow01        ENABLE_SME_FOR_SWD \
1193327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
1194327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
11950c5e7d1cSMax Shvetsov        ENABLE_SVE_FOR_SWD \
1196327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
1197327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
1198327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
1199327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
1200327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
120146cc41d5SManish Pandey        HANDLE_EA_EL3_FIRST_NS \
1202327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
1203327131c4SLeonardo Sandoval        LOG_LEVEL \
1204327131c4SLeonardo Sandoval        MEASURED_BOOT \
120500e28874SManish V Badarkhe        DRTM_SUPPORT \
1206327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
1207327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
1208327131c4SLeonardo Sandoval        PLAT_${PLAT} \
12090ce2072dSTamas Ban        PLAT_RSS_NOT_SUPPORTED \
1210327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
1211327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
1212327131c4SLeonardo Sandoval        RAS_EXTENSION \
1213327131c4SLeonardo Sandoval        RESET_TO_BL31 \
121425844ff7SJorge Ramirez-Ortiz        RESET_TO_BL31_WITH_PARAMS \
1215327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
121696a8ed14SJiafei Pan        SEPARATE_BL2_NOLOAD_REGION \
1217327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
1218327131c4SLeonardo Sandoval        RECLAIM_INIT_CODE \
1219327131c4SLeonardo Sandoval        SPD_${SPD} \
1220327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
1221327131c4SLeonardo Sandoval        SPM_MM \
12221d63ae4dSMarc Bonnici        SPMC_AT_EL3 \
1223327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
1224327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
1225c9c56f6eSManish V Badarkhe        CRYPTO_SUPPORT \
12267dfb9911SJimmy Brisson        TRNG_SUPPORT \
1227327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
1228327131c4SLeonardo Sandoval        USE_DEBUGFS \
1229327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
1230327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
1231327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
1232327131c4SLeonardo Sandoval        USE_ROMLIB \
1233327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
1234327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
1235327131c4SLeonardo Sandoval        BL2_AT_EL3 \
1236327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
1237327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
1238327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
1239327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
124000e8f79cSManish Pandey        RAS_TRAP_NS_ERR_REC_ACCESS \
1241327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
1242327131c4SLeonardo Sandoval        USE_SP804_TIMER \
124312cd65e0STomas Pilar        ENABLE_FEAT_RNG \
1244ff86e0b4SJuan Pablo Conde        ENABLE_FEAT_RNG_TRAP \
12454e04478aSChris Kay        ENABLE_FEAT_SB \
12467d33ffe4SDaniel Boulby        ENABLE_FEAT_DIT \
12475357f83dSManish V Badarkhe        NR_OF_FW_BANKS \
12485357f83dSManish V Badarkhe        NR_OF_IMAGES_IN_FW_BANK \
1249396b339dSManish V Badarkhe        PSA_FWU_SUPPORT \
1250744ad974Sjohpow01        ENABLE_BRBE_FOR_NS \
1251813524eaSManish V Badarkhe        ENABLE_TRBE_FOR_NS \
1252d4582d30SManish V Badarkhe        ENABLE_SYS_REG_TRACE_FOR_NS \
12538fcd3d96SManish V Badarkhe        ENABLE_TRF_FOR_NS \
1254cb4ec47bSjohpow01        ENABLE_FEAT_HCX \
125568120783SChris Kay        ENABLE_MPMM \
125668120783SChris Kay        ENABLE_MPMM_FCONF \
1257f74cb0beSJayanth Dodderi Chidanand        ENABLE_FEAT_FGT \
1258f74cb0beSJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1 \
1259f74cb0beSJayanth Dodderi Chidanand        ENABLE_FEAT_ECV \
12601f1c0206SAbdul Halim, Muhammad Hadi Asyrafi        SIMICS_BUILD \
12616a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_AMUv1p1 \
12626a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_SEL2 \
12636a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_VHE \
12646a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_CSV2_2 \
12656a0da736SJayanth Dodderi Chidanand        ENABLE_FEAT_PAN \
12666a0da736SJayanth Dodderi Chidanand        FEATURE_DETECTION \
1267781d07a4SJayanth Dodderi Chidanand        TWED_DELAY \
1268781d07a4SJayanth Dodderi Chidanand        ENABLE_FEAT_TWED \
126904c7303bSOkash Khawaja	CONDITIONAL_CMO \
1270327131c4SLeonardo Sandoval)))
12712fae4b1eSJeenu Viswambharan
12721f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
12731f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
12741f461979SJustin Chadwellendif
12751f461979SJustin Chadwell
12764c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
12774c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
12784c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1279cf2c8a33SAntonio Nino Diazelse
128068450a6dSAntonio Nino Diaz        # Define the PRELOADED_BL33_BASE flag only if it is provided and
128168450a6dSAntonio Nino Diaz        # EL3_PAYLOAD_BASE is not defined, as it has priority.
128268450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
128368450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
12844c117f6cSSandrine Bailleux        endif
1285cf2c8a33SAntonio Nino Diazendif
128673c99d4eSJuan Castillo
1287209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1288209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1289209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH))
1290209a60ccSSoby Mathewendif
1291209a60ccSSoby Mathew
1292c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
1293c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK))
1294c2ad38ceSVarun Wadekarendif
1295c2ad38ceSVarun Wadekar
1296ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1297ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1298c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1299ce2b1ec6SManish Pandey        -include $(BUILD_PLAT)/sp_gen.mk
1300ce2b1ec6SManish Pandey        FIP_DEPS += sp
130107c44475SManish Pandey        CRT_DEPS += sp
1302ce2b1ec6SManish Pandey        NEED_SP_PKG := yes
1303ce2b1ec6SManish Pandeyelse
1304c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},1)
1305c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1306c33ff198SOlivier Deprez        endif
1307ce2b1ec6SManish Pandeyendif
1308ce2b1ec6SManish Pandeyendif
1309ce2b1ec6SManish Pandey
131073c99d4eSJuan Castillo################################################################################
131173c99d4eSJuan Castillo# Build targets
131273c99d4eSJuan Castillo################################################################################
131373c99d4eSJuan Castillo
131490aa901fSSumit Garg.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
131573c99d4eSJuan Castillo.SUFFIXES:
131673c99d4eSJuan Castillo
131773c99d4eSJuan Castilloall: msg_start
131873c99d4eSJuan Castillo
131973c99d4eSJuan Castillomsg_start:
132073c99d4eSJuan Castillo	@echo "Building ${PLAT}"
132173c99d4eSJuan Castillo
13227a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1323d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
1324c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),)
1325c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1326c2ad38ceSVarun Wadekarelse
1327bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
13287a24cba5SSoby Mathewendif
1329d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED
13307a24cba5SSoby Mathew
13315accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS))
133261f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
13335fee0287SRoberto Vargas
133473c99d4eSJuan Castillo# Expand build macros for the different images
133573c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
1336b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES})
1337b34635a0SChris Kay
1338434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1))
133973c99d4eSJuan Castilloendif
134073c99d4eSJuan Castillo
134173c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1342c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0)
1343c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1344c9b31ae8SRoberto Vargasendif
1345c9b31ae8SRoberto Vargas
1346eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES})
1347eb1acfb6SChris Kay
134833950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1349434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
135073c99d4eSJuan Castilloendif
135173c99d4eSJuan Castillo
13524d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
135333950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
13544d045d0eSMasahiro Yamadaendif
13554d045d0eSMasahiro Yamada
135673c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
135773c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
135826d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
135926d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1360c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1361c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1362434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1363c6ba9b45SSumit Gargelse
136433950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1365434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl31,soc-fw)))
136673c99d4eSJuan Castilloendif
1367c6ba9b45SSumit Gargendif
136873c99d4eSJuan Castillo
136970d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1370c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
137170d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
137273c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
137326d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
137426d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
13759cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
13769cd15239SMasahiro Yamada
1377c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1378434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1379c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1380c6ba9b45SSumit Gargelse
1381434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
138233950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
138373c99d4eSJuan Castilloendif
1384c6ba9b45SSumit Gargendif
138573c99d4eSJuan Castillo
13865b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
13875b18de09SZelalem Aweke# needs to be built from RMM_SOURCES.
13885b18de09SZelalem Awekeifeq (${NEED_RMM},yes)
13895b18de09SZelalem Aweke# Sort RMM source files to remove duplicates
13905b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES})
13915b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
13925b18de09SZelalem Aweke
13935b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
13945b18de09SZelalem Aweke         $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
13955b18de09SZelalem Awekeendif
13965b18de09SZelalem Aweke
139773c99d4eSJuan Castillo# Add the BL33 image if required by the platform
139873c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
139933950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1400db6071c9SJuan Castilloendif
1401db6071c9SJuan Castillo
14029003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
140333950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1404434d0491SZelalem Aweke	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
14059003fa0bSYatharth Kocharendif
14069003fa0bSYatharth Kochar
140703b397a8SNishanth Menon# Expand build macros for the different images
140803b397a8SNishanth Menonifeq (${NEED_FDT},yes)
140903b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
141003b397a8SNishanth Menonendif
141103b397a8SNishanth Menon
1412ce2b1ec6SManish Pandey# Add Secure Partition packages
1413ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1414ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
14151e7528ecSRuari Phipps	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1416822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1417ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1418ce2b1ec6SManish Pandey	@echo "Built SP Images successfully"
1419ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1420ce2b1ec6SManish Pandeyendif
1421ce2b1ec6SManish Pandey
142236eaaf37SIan Spraylocate-checkpatch:
142336eaaf37SIan Sprayifndef CHECKPATCH
142466079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
142536eaaf37SIan Sprayelse
142636eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
142766079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
142836eaaf37SIan Sprayendif
142936eaaf37SIan Sprayendif
143036eaaf37SIan Spray
14314f6ad66aSAchin Guptaclean:
14324f6ad66aSAchin Gupta	@echo "  CLEAN"
1433f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
143488a1cf1eSSami Mujawarifdef UNIX_MK
14352f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
143688a1cf1eSSami Mujawarelse
143788a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
143888a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
143988a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
144088a1cf1eSSami Mujawarendif
14416f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
144290aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
14435accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
14444f6ad66aSAchin Gupta
1445eaaeece2SJames Morrisseyrealclean distclean:
1446eaaeece2SJames Morrissey	@echo "  REALCLEAN"
1447f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1448f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
144988a1cf1eSSami Mujawarifdef UNIX_MK
14502f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
145188a1cf1eSSami Mujawarelse
145288a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
145388a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
145488a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
145588a1cf1eSSami Mujawarendif
1456e15591aaSNicolas Boulenguez	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
145790aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
14585accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
14594f6ad66aSAchin Gupta
146036eaaf37SIan Spraycheckcodebase:		locate-checkpatch
146136eaaf37SIan Spray	@echo "  CHECKING STYLE"
146236eaaf37SIan Spray	@if test -d .git ; then						\
14631ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
14641a41e8c1SDan Handley		while read GIT_FILE ;					\
14651a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
14661a41e8c1SDan Handley		done ;							\
146736eaaf37SIan Spray	else								\
14681a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
14691a41e8c1SDan Handley		 -not -iwholename "*build*"				\
14701a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
147161f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
14721a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
14731ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
14741a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
147536eaaf37SIan Spray	fi
147636eaaf37SIan Spray
147736eaaf37SIan Spraycheckpatch:		locate-checkpatch
147836eaaf37SIan Spray	@echo "  CHECKING STYLE"
147902a76d5fSYann Gautier	@if test -n "${CHECKPATCH_OPTS}"; then				\
148002a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
148102a76d5fSYann Gautier	fi
148251d28937SAntonio Nino Diaz	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
148377a0a7f1SYann Gautier	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
148477a0a7f1SYann Gautier	do								\
148551d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
148651d28937SAntonio Nino Diaz		git log --format=email "$$commit~..$$commit"		\
148702a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
148802a76d5fSYann Gautier			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
148951d28937SAntonio Nino Diaz		git diff --format=email "$$commit~..$$commit"		\
149002a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
149102a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
149251d28937SAntonio Nino Diaz	done
149336eaaf37SIan Spray
149473c99d4eSJuan Castillocerttool: ${CRTTOOL}
149573c99d4eSJuan Castillo
1496a9812206SPali Rohár${CRTTOOL}: FORCE
1497598b166bSLionel 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
1498f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
14996f971622SJuan Castillo	@echo "Built $@ successfully"
1500f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
15016f971622SJuan Castillo
15026f971622SJuan Castilloifneq (${GENERATE_COT},0)
150373c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
15046f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
1505f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
15066f971622SJuan Castillo	@echo "Built $@ successfully"
15076f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
1508f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
150973c99d4eSJuan Castilloendif
151027713fb4SSoby Mathew
151173c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
15124727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
1513819281eeSdp-arm	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1514819281eeSdp-arm	${Q}${FIPTOOL} info $@
1515f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
15162f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
1517f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1518f58ad36fSHarry Liebel
15190191262dSYatharth Kocharifneq (${GENERATE_COT},0)
15200191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
15210191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1522052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15230191262dSYatharth Kochar	@echo "Built $@ successfully"
15240191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1525052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15260191262dSYatharth Kocharendif
15270191262dSYatharth Kochar
15280191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
15294727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
1530819281eeSdp-arm	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1531819281eeSdp-arm	${Q}${FIPTOOL} info $@
1532052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15330191262dSYatharth Kochar	@echo "Built $@ successfully"
1534052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
15350191262dSYatharth Kochar
153673c99d4eSJuan Castillofiptool: ${FIPTOOL}
153773c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
15380191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
153973c99d4eSJuan Castillo
1540a9812206SPali Rohár${FIPTOOL}: FORCE
154188a1cf1eSSami Mujawarifdef UNIX_MK
1542598b166bSLionel Debieve	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
154388a1cf1eSSami Mujawarelse
154488a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
154588a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
154688a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
154788a1cf1eSSami Mujawarendif
1548f58ad36fSHarry Liebel
1549a9812206SPali Rohárromlib.bin: libraries FORCE
1550bbb24f61SJohn 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
15515accce5bSRoberto Vargas
1552cfe83910SLouis Mayencourt# Call print_memory_map tool
1553cfe83910SLouis Mayencourtmemmap: all
1554b890b36dSLouis Mayencourt	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1555cfe83910SLouis Mayencourt
15566de32378SMadhukar Pappireddydoc:
15576de32378SMadhukar Pappireddy	@echo "  BUILD DOCUMENTATION"
15586de32378SMadhukar Pappireddy	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
15596de32378SMadhukar Pappireddy
156090aa901fSSumit Gargenctool: ${ENCTOOL}
156190aa901fSSumit Garg
1562a9812206SPali Rohár${ENCTOOL}: FORCE
1563598b166bSLionel Debieve	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
156490aa901fSSumit Garg	@${ECHO_BLANK_LINE}
156590aa901fSSumit Garg	@echo "Built $@ successfully"
156690aa901fSSumit Garg	@${ECHO_BLANK_LINE}
156790aa901fSSumit Garg
156835fab8c9SJoakim Bechcscope:
156935fab8c9SJoakim Bech	@echo "  CSCOPE"
157035fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
157135fab8c9SJoakim Bech	${Q}cscope -b -q -k
157235fab8c9SJoakim Bech
157372ee3314SRyan Harkinhelp:
15747c23126cSJohn Tsichritzis	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
157572ee3314SRyan Harkin	@echo ""
157672ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
157708c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
157872ee3314SRyan Harkin	@echo ""
15797c23126cSJohn Tsichritzis	@echo "platform = ${PLATFORM_LIST}"
15807c23126cSJohn Tsichritzis	@echo ""
15811b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
15821b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
15831b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
15841b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
15851b578596SSandrine Bailleux	@echo ""
158672ee3314SRyan Harkin	@echo "Supported Targets:"
15871b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
158836eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
15898aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
15909003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
1591d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
15929d29c227SSoby Mathew	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
15939d29c227SSoby Mathew	@echo "                 this builds secure payload specified by AARCH32_SP"
159473c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
15951b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
15960191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
159736eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
159836eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
159936eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
160072ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
160135fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
160272ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
16036f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
160490aa901fSSumit Garg	@echo "  enctool        Build the Firmware encryption tool"
1605f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1606ce2b1ec6SManish Pandey	@echo "  sp             Build the Secure Partition Packages"
160726010da1SAntonio Nino Diaz	@echo "  sptool         Build the Secure Partition Package creation tool"
160838c14d88SSoby Mathew	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1609cfe83910SLouis Mayencourt	@echo "  memmap         Print the memory map of the built binaries"
16106de32378SMadhukar Pappireddy	@echo "  doc            Build html based documentation using Sphinx tool"
161172ee3314SRyan Harkin	@echo ""
16121b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
161372ee3314SRyan Harkin	@echo ""
161472ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
161572ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1616a9812206SPali Rohár
1617a9812206SPali Rohár.PHONY: FORCE
1618a9812206SPali RohárFORCE:;
1619