xref: /rk3399_ARM-atf/Makefile (revision 12cd65e091c229c1bc12d6ca58417391ec62d37f)
14f6ad66aSAchin Gupta#
22d51b55eSBalint Dobszay# Copyright (c) 2013-2020, 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
115edddf3aSManish V BadarkheVERSION_MINOR			:= 4
12aaa3e722SJuan Castillo
1388154678SJuan Castillo# Default goal is build all images
1488154678SJuan Castillo.DEFAULT_GOAL			:= all
1588154678SJuan Castillo
1672fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to
1772fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
1872fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual.
1972fc70edSDouglas RaillardMAKEOVERRIDES =
2072fc70edSDouglas Raillard
21231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/
22231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
23e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk
2473c99d4eSJuan Castillo
2573c99d4eSJuan Castillo################################################################################
262fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies
2773c99d4eSJuan Castillo################################################################################
28e35c4045SJeenu Viswambharan
292fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
30872be88aSdp-arm
31cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default
32cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS		:= ${DEBUG}
332fae4b1eSJeenu ViswambharanENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
342fae4b1eSJeenu ViswambharanPLAT				:= ${DEFAULT_PLAT}
3573c99d4eSJuan Castillo
3673c99d4eSJuan Castillo################################################################################
3773c99d4eSJuan Castillo# Checkpatch script options
3873c99d4eSJuan Castillo################################################################################
3973c99d4eSJuan Castillo
40f607739cSSandrine BailleuxCHECKCODE_ARGS		:=	--no-patch
41f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files
424501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	:=	$(sort $(filter-out                     \
434501843fSGilad Ben-Yossef					include/drivers/arm/cryptocell,	\
444501843fSGilad Ben-Yossef					$(wildcard include/drivers/arm/*)))
454501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	+=	include/drivers/arm/cryptocell/*.h
464501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
474501843fSGilad Ben-Yossef					include/drivers/arm,		\
484501843fSGilad Ben-Yossef					$(wildcard include/drivers/*)))
49f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
501a41e8c1SDan Handley					include/lib/libfdt		\
5161f72a34SRoberto Vargas					include/lib/libc,		\
52f0b489c1SDan Handley					$(wildcard include/lib/*)))
53f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
544501843fSGilad Ben-Yossef					include/lib			\
554501843fSGilad Ben-Yossef					include/drivers,		\
56f0b489c1SDan Handley					$(wildcard include/*)))
57f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
58d801fbb0Sdp-arm					lib/compiler-rt			\
5955cdcf75SAntonio Nino Diaz					lib/libfdt%			\
6061f72a34SRoberto Vargas					lib/libc,			\
61f0b489c1SDan Handley					$(wildcard lib/*)))
62f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
63f0b489c1SDan Handley					lib				\
64f0b489c1SDan Handley					include				\
65f0b489c1SDan Handley					docs				\
661ef35512SPaul Beesley					%.rst,				\
67f0b489c1SDan Handley					$(wildcard *)))
68f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
69f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
70f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
714501843fSGilad Ben-Yossef				${LIB_DIRS_TO_CHECK}			\
724501843fSGilad Ben-Yossef				${INC_DRV_DIRS_TO_CHECK}		\
734501843fSGilad Ben-Yossef				${INC_ARM_DIRS_TO_CHECK}
7436eaaf37SIan Spray
7573c99d4eSJuan Castillo
7673c99d4eSJuan Castillo################################################################################
7773c99d4eSJuan Castillo# Process build options
7873c99d4eSJuan Castillo################################################################################
7973c99d4eSJuan Castillo
8073c99d4eSJuan Castillo# Verbose flag
81e35c4045SJeenu Viswambharanifeq (${V},0)
82b169f6a9SEvan Lloyd        Q:=@
83ee1ba6d4SAndre Przywara        ECHO:=@echo
8436eaaf37SIan Spray        CHECKCODE_ARGS	+=	--no-summary --terse
854f6ad66aSAchin Guptaelse
86b169f6a9SEvan Lloyd        Q:=
87b5a0f4bdSAntonio Nino Diaz        ECHO:=$(ECHO_QUIET)
884f6ad66aSAchin Guptaendif
89ee1ba6d4SAndre Przywara
90ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
91ee1ba6d4SAndre Przywara        Q:=@
92b5a0f4bdSAntonio Nino Diaz        ECHO:=$(ECHO_QUIET)
93ee1ba6d4SAndre Przywaraendif
94ee1ba6d4SAndre Przywara
95ee1ba6d4SAndre Przywaraexport Q ECHO
962f2cef46SJeenu Viswambharan
9773c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the
9873c99d4eSJuan Castillo# target 'certificates' to create them all
9973c99d4eSJuan Castilloifneq (${GENERATE_COT},0)
10073c99d4eSJuan Castillo        FIP_DEPS += certificates
1010191262dSYatharth Kochar        FWU_FIP_DEPS += fwu_certificates
10273c99d4eSJuan Castilloendif
10373c99d4eSJuan Castillo
1049fc59639SAlexei Fedorov# Process BRANCH_PROTECTION value and set
1059fc59639SAlexei Fedorov# Pointer Authentication and Branch Target Identification flags
1069fc59639SAlexei Fedorovifeq (${BRANCH_PROTECTION},0)
1079fc59639SAlexei Fedorov	# Default value turns off all types of branch protection
1089fc59639SAlexei Fedorov	BP_OPTION := none
1099fc59639SAlexei Fedorovelse ifneq (${ARCH},aarch64)
1109fc59639SAlexei Fedorov        $(error BRANCH_PROTECTION requires AArch64)
1119fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},1)
1129fc59639SAlexei Fedorov	# Enables all types of branch protection features
1139fc59639SAlexei Fedorov	BP_OPTION := standard
1149fc59639SAlexei Fedorov	ENABLE_BTI := 1
1159fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1169fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},2)
1179fc59639SAlexei Fedorov	# Return address signing to its standard level
1189fc59639SAlexei Fedorov	BP_OPTION := pac-ret
1199fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1209fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},3)
1219fc59639SAlexei Fedorov	# Extend the signing to include leaf functions
1229fc59639SAlexei Fedorov	BP_OPTION := pac-ret+leaf
1239fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1243768fecfSAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},4)
1253768fecfSAlexei Fedorov	# Turn on branch target identification mechanism
1263768fecfSAlexei Fedorov	BP_OPTION := bti
1273768fecfSAlexei Fedorov	ENABLE_BTI := 1
1289fc59639SAlexei Fedorovelse
1299fc59639SAlexei Fedorov        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
1309fc59639SAlexei Fedorovendif
13173c99d4eSJuan Castillo
132c97cba4eSSoby Mathew# USE_SPINLOCK_CAS requires AArch64 build
133c97cba4eSSoby Mathewifeq (${USE_SPINLOCK_CAS},1)
134c97cba4eSSoby Mathewifneq (${ARCH},aarch64)
135c97cba4eSSoby Mathew        $(error USE_SPINLOCK_CAS requires AArch64)
136c97cba4eSSoby Mathewelse
137c97cba4eSSoby Mathew        $(info USE_SPINLOCK_CAS is an experimental feature)
138c97cba4eSSoby Mathewendif
139c97cba4eSSoby Mathewendif
140c97cba4eSSoby Mathew
1410ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds
1420ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1)
1430ca3913dSOlivier Deprezifeq (${DEBUG},1)
1440ca3913dSOlivier Deprez        $(warning DEBUGFS experimental feature is enabled.)
1450ca3913dSOlivier Deprezelse
1460ca3913dSOlivier Deprez        $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
1470ca3913dSOlivier Deprezendif
1480ca3913dSOlivier Deprezendif
1490ca3913dSOlivier Deprez
150c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
151c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS}
152c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY}
153c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE}
154c6ba9b45SSumit GargFIP_DEPS += enctool
155c6ba9b45SSumit GargFWU_FIP_DEPS += enctool
156c6ba9b45SSumit Gargendif
157c6ba9b45SSumit Garg
15873c99d4eSJuan Castillo################################################################################
15973c99d4eSJuan Castillo# Toolchain
16073c99d4eSJuan Castillo################################################################################
16173c99d4eSJuan Castillo
16272610c41Sdp-armHOSTCC			:=	gcc
16372610c41Sdp-armexport HOSTCC
16472610c41Sdp-arm
16573c99d4eSJuan CastilloCC			:=	${CROSS_COMPILE}gcc
16673c99d4eSJuan CastilloCPP			:=	${CROSS_COMPILE}cpp
16773c99d4eSJuan CastilloAS			:=	${CROSS_COMPILE}gcc
16873c99d4eSJuan CastilloAR			:=	${CROSS_COMPILE}ar
1692adee763SRoberto VargasLINKER			:=	${CROSS_COMPILE}ld
17073c99d4eSJuan CastilloOC			:=	${CROSS_COMPILE}objcopy
17173c99d4eSJuan CastilloOD			:=	${CROSS_COMPILE}objdump
17273c99d4eSJuan CastilloNM			:=	${CROSS_COMPILE}nm
17373c99d4eSJuan CastilloPP			:=	${CROSS_COMPILE}gcc -E
17438c14d88SSoby MathewDTC			:=	dtc
17573c99d4eSJuan Castillo
176b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
177b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \
1782adee763SRoberto Vargas	$(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
1792adee763SRoberto VargasLINKER			:=	${LINKER}.bfd
180b25a577fSJulius Wernerendif
181b25a577fSJulius Werner
18226e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
18326e63c44SEtienne Carrieretarget32-directive	= 	-target arm-none-eabi
18426e63c44SEtienne Carriere# Will set march32-directive from platform configuration
18526e63c44SEtienne Carriereelse
18626e63c44SEtienne Carrieretarget32-directive	= 	-target armv8a-none-eabi
187fa6f774bSAlexei Fedorov
188f1821790SAlexei Fedorov# Set the compiler's target architecture profile based on
189f1821790SAlexei Fedorov# ARM_ARCH_MAJOR ARM_ARCH_MINOR options
190fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0)
191f1821790SAlexei Fedorovmarch32-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
192f1821790SAlexei Fedorovmarch64-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
193fa6f774bSAlexei Fedorovelse
194f1821790SAlexei Fedorovmarch32-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
195f1821790SAlexei Fedorovmarch64-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
196fa6f774bSAlexei Fedorovendif
19726e63c44SEtienne Carriereendif
19826e63c44SEtienne Carriere
1997ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
2007ff088d1SManish V Badarkheifeq ($(ARCH), aarch64)
2014a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5
2024a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
2037ff088d1SManish V Badarkhemem_tag_arch_support	= 	yes
2047ff088d1SManish V Badarkheendif
2057ff088d1SManish V Badarkheendif
2067ff088d1SManish V Badarkhe
207f1821790SAlexei Fedorov# Get architecture feature modifiers
208f1821790SAlexei Fedorovarch-features		=	${ARM_ARCH_FEATURE}
209f1821790SAlexei Fedorov
210f1821790SAlexei Fedorov# Enable required options for memory stack tagging.
211f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler.
2127ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes)
2137ff088d1SManish V Badarkheifdef mem_tag_arch_support
214f1821790SAlexei Fedorov# Check for armclang and clang compilers
2157ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang))
216f1821790SAlexei Fedorov# Add "memtag" architecture feature modifier if not specified
217f1821790SAlexei Fedorovifeq ( ,$(findstring memtag,$(arch-features)))
218f1821790SAlexei Fedorovarch-features       	:=       $(arch-features)+memtag
219f1821790SAlexei Fedorovendif	# memtag
2207ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang)
2217ff088d1SManish V BadarkheTF_CFLAGS		+=	-mmemtag-stack
2227ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang)
2237ff088d1SManish V BadarkheTF_CFLAGS		+=	-fsanitize=memtag
224f1821790SAlexei Fedorovendif	# armclang
225f1821790SAlexei Fedorovendif	# armclang clang
2267ff088d1SManish V Badarkheelse
2277ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \
2287ff088d1SManish V Badarkhe	${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
229f1821790SAlexei Fedorovendif	# mem_tag_arch_support
230f1821790SAlexei Fedorovendif	# SUPPORT_STACK_MEMTAG
231f1821790SAlexei Fedorov
232f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers
233f1821790SAlexei Fedorovifneq ($(arch-features), none)
234f1821790SAlexei Fedorov# Strip "none+" from arch-features
235f1821790SAlexei Fedorovarch-features		:=	$(subst none+,,$(arch-features))
236f1821790SAlexei Fedorovifeq ($(ARCH), aarch32)
237f1821790SAlexei Fedorovmarch32-directive	:=	$(march32-directive)+$(arch-features)
238f1821790SAlexei Fedorovelse
239f1821790SAlexei Fedorovmarch64-directive	:=	$(march64-directive)+$(arch-features)
2407ff088d1SManish V Badarkheendif
241f1821790SAlexei Fedorov# Print features
242f1821790SAlexei Fedorov$(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
243f1821790SAlexei Fedorovendif	# arch-features
2447ff088d1SManish V Badarkhe
245*12cd65e0STomas Pilar# Determine if FEAT_RNG is supported
246*12cd65e0STomas PilarENABLE_FEAT_RNG		=	$(if $(findstring rng,${arch-features}),1,0)
247*12cd65e0STomas Pilar
248fd18a8fcSVarun Wadekarifneq ($(findstring armclang,$(notdir $(CC))),)
24926e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	-target arm-arm-none-eabi $(march32-directive)
250fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-arm-none-eabi $(march64-directive)
2512adee763SRoberto VargasLD			=	$(LINKER)
2521684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2537040155eSRoberto VargasCPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2547040155eSRoberto VargasPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2557559633bSdp-armelse ifneq ($(findstring clang,$(notdir $(CC))),)
256eff737c1SArve HjønnevågCLANG_CCDIR		=	$(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),)
257e2bfec0bSYann GautierTF_CFLAGS_aarch32	=	$(target32-directive) $(march32-directive)
258fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-elf $(march64-directive)
259eff737c1SArve HjønnevågLD			=	$(CLANG_CCDIR)ld.lld
260641f16e7SAmbroise Vincentifeq (, $(shell which $(LD)))
261641f16e7SAmbroise Vincent$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker")
262641f16e7SAmbroise Vincentendif
2631684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2647040155eSRoberto VargasCPP			=	$(CC) -E
2657040155eSRoberto VargasPP			=	$(CC) -E
266edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),)
267edbce9aaSzelalem-awekeTF_CFLAGS_aarch32	=	$(march32-directive)
268edbce9aaSzelalem-awekeTF_CFLAGS_aarch64	=	$(march64-directive)
269edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
270edbce9aaSzelalem-aweke	# Enable LTO only for aarch64
271edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
272edbce9aaSzelalem-aweke		LTO_CFLAGS	=	-flto
273edbce9aaSzelalem-aweke		# Use gcc as a wrapper for the ld, recommended for LTO
274edbce9aaSzelalem-aweke		LINKER		:=	${CROSS_COMPILE}gcc
275edbce9aaSzelalem-aweke	endif
276edbce9aaSzelalem-awekeendif
277edbce9aaSzelalem-awekeLD			=	$(LINKER)
278d5461857Sdp-armelse
27926e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	$(march32-directive)
280fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	$(march64-directive)
2812adee763SRoberto VargasLD			=	$(LINKER)
282d5461857Sdp-armendif
283d5461857Sdp-arm
28432b209bfSAhmad Fatoum# Process Debug flag
28532b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
28632b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
28732b209bfSAhmad Fatoum        BUILD_TYPE	:=	debug
28832b209bfSAhmad Fatoum        TF_CFLAGS	+= 	-g
28932b209bfSAhmad Fatoum
29032b209bfSAhmad Fatoum        ifneq ($(findstring clang,$(notdir $(CC))),)
29132b209bfSAhmad Fatoum             ASFLAGS		+= 	-g
29232b209bfSAhmad Fatoum        else
29332b209bfSAhmad Fatoum             ASFLAGS		+= 	-g -Wa,--gdwarf-2
29432b209bfSAhmad Fatoum        endif
29532b209bfSAhmad Fatoum
29632b209bfSAhmad Fatoum        # Use LOG_LEVEL_INFO by default for debug builds
29732b209bfSAhmad Fatoum        LOG_LEVEL	:=	40
29832b209bfSAhmad Fatoumelse
29932b209bfSAhmad Fatoum        BUILD_TYPE	:=	release
30032b209bfSAhmad Fatoum        # Use LOG_LEVEL_NOTICE by default for release builds
30132b209bfSAhmad Fatoum        LOG_LEVEL	:=	20
30232b209bfSAhmad Fatoumendif
30332b209bfSAhmad Fatoum
304f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
305f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
306f1de4c8fSPeiyuan Song        BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
307f1de4c8fSPeiyuan Songendif
308f1de4c8fSPeiyuan SongVERSION_STRING    :=  v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
309f1de4c8fSPeiyuan Song
3108fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
3118fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-marm
3128fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
3138fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-mthumb
3148fd9d4d5SAntonio Nino Diazelse
3158fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
3168fd9d4d5SAntonio Nino Diazendif
3178fd9d4d5SAntonio Nino Diaz
318a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
319d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
3209d29c227SSoby Mathew
3219fc59639SAlexei Fedorovifneq (${BP_OPTION},none)
3229fc59639SAlexei FedorovTF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
3239fc59639SAlexei Fedorovendif
3249fc59639SAlexei Fedorov
32526e63c44SEtienne CarriereASFLAGS_aarch32		=	$(march32-directive)
326fa6f774bSAlexei FedorovASFLAGS_aarch64		=	$(march64-directive)
327b86048c4SAntonio Nino Diaz
3289ab81b5eSJustin Chadwell# General warnings
3299ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
330b7f6525dSJustin Chadwell				-Wdisabled-optimization	-Wvla -Wshadow	\
331ca661a00SMadhukar Pappireddy				-Wno-unused-parameter -Wredundant-decls
3329ab81b5eSJustin Chadwell
3339ab81b5eSJustin Chadwell# Additional warnings
3349ab81b5eSJustin Chadwell# Level 1
335e7c645b5SYann GautierWARNING1 := -Wextra
336e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute
337e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes
338e7c645b5SYann GautierWARNING1 += -Wold-style-definition
339e7c645b5SYann Gautier
340b7f6525dSJustin Chadwell# Level 2
341e7c645b5SYann GautierWARNING2 := -Waggregate-return
342e7c645b5SYann GautierWARNING2 += -Wcast-align
343e7c645b5SYann GautierWARNING2 += -Wnested-externs
344e7c645b5SYann Gautier
345e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
346e7c645b5SYann GautierWARNING3 += -Wcast-qual
347e7c645b5SYann GautierWARNING3 += -Wconversion
348e7c645b5SYann GautierWARNING3 += -Wpacked
349e7c645b5SYann GautierWARNING3 += -Wpointer-arith
350e7c645b5SYann GautierWARNING3 += -Wswitch-default
351e7c645b5SYann Gautier
352e7c645b5SYann Gautierifeq (${W},1)
3539ab81b5eSJustin ChadwellWARNINGS += $(WARNING1)
354e7c645b5SYann Gautierelse ifeq (${W},2)
3559ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2)
356e7c645b5SYann Gautierelse ifeq (${W},3)
3579ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
358e7c645b5SYann Gautierendif
359e7c645b5SYann Gautier
3609ab81b5eSJustin Chadwell# Compiler specific warnings
36100296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),)
36293c690ebSJustin Chadwell# not using clang
363d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
364d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
365d7b4cd41SJustin Chadwell				-Wlogical-op
36693c690ebSJustin Chadwellelse
36793c690ebSJustin Chadwell# using clang
368d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
369d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
37000296576SAmbroise Vincentendif
37100296576SAmbroise Vincent
3726336b07aSYann Gautierifneq (${E},0)
3736336b07aSYann GautierERRORS := -Werror
3746336b07aSYann Gautierendif
3756336b07aSYann Gautier
376ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
3779ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
37859de5096SMasahiro YamadaASFLAGS			+=	$(CPPFLAGS) $(ASFLAGS_$(ARCH))			\
379d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
38059de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
381ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
382ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
383ebd6efaeSSamuel Holland				-Os -std=gnu99
38473c99d4eSJuan Castillo
3851f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
3861f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover
3871f461979SJustin Chadwellendif
3881f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
3891f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover	\
3901f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
3911f461979SJustin Chadwellendif
3921f461979SJustin Chadwell
393f7ec31dbSdavid cunadoGCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
394f7ec31dbSdavid cunado
395641f16e7SAmbroise Vincent# LD = armlink
396c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
397c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
398c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
399edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
400641f16e7SAmbroise Vincent
401641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
402edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),)
403edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches
404edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
405edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--gc-sections
406edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
407edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
408edbce9aaSzelalem-aweke		TF_LDFLAGS	+=	-flto -fuse-linker-plugin
409edbce9aaSzelalem-aweke	endif
410edbce9aaSzelalem-awekeendif
411edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
412edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
413edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1)
414edbce9aaSzelalem-aweke	TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
415edbce9aaSzelalem-awekeendif
416edbce9aaSzelalem-awekeTF_LDFLAGS		+= 	-nostdlib
417edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
418641f16e7SAmbroise Vincent
419641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
420c2ad38ceSVarun Wadekarelse
421c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--fatal-warnings -O1
422c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--gc-sections
423641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
424641f16e7SAmbroise Vincent# therefore don't add those in that case
425641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),)
426c2b8806fSDouglas RaillardTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
427edbce9aaSzelalem-awekeendif
428641f16e7SAmbroise Vincentendif
42973c99d4eSJuan Castillo
43003b397a8SNishanth MenonDTC_FLAGS		+=	-I dts -O dtb
431a6de824fSLouis MayencourtDTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
432a6de824fSLouis Mayencourt				-x assembler-with-cpp $(DEFINES)
43303b397a8SNishanth Menon
4340ab49645SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
4350ab49645SAlexei FedorovDTC_CPPFLAGS		+=	-DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE}
4360ab49645SAlexei Fedorovendif
4370ab49645SAlexei Fedorov
43873c99d4eSJuan Castillo################################################################################
43973c99d4eSJuan Castillo# Common sources and include directories
44073c99d4eSJuan Castillo################################################################################
441d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
44273c99d4eSJuan Castillo
44373c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
4447f56e9a3SSoby Mathew				common/tf_log.c				\
4459d29c227SSoby Mathew				common/${ARCH}/debug.S			\
44691b48c9fSJulius Werner				drivers/console/multi_console.c		\
4479d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
4489d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
449566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
4507f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
45175311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
4529d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
45361f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
454d7a6b0f8SRyan Harkin
4558422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang)
4568422a840SAntonio Nino DiazBL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
4578422a840SAntonio Nino Diazendif
4588422a840SAntonio Nino Diaz
4591f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4601f461979SJustin ChadwellBL_COMMON_SOURCES	+=	plat/common/ubsan.c
4611f461979SJustin Chadwellendif
4621f461979SJustin Chadwell
46301d237cbSYann GautierINCLUDES		+=	-Iinclude				\
464f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
46509d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
46609d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
46709d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
46809d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
46909d40e0eSAntonio Nino Diaz
4709c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4719c6d1c50SAntonio Nino Diaz
47273c99d4eSJuan Castillo################################################################################
47373c99d4eSJuan Castillo# Generic definitions
47473c99d4eSJuan Castillo################################################################################
47573c99d4eSJuan Castillo
476231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
477231c1470SEvan Lloyd
47829214e95SGrant Likelyifeq (${BUILD_BASE},)
47973c99d4eSJuan Castillo     BUILD_BASE		:=	./build
48029214e95SGrant Likelyendif
48129214e95SGrant LikelyBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
48273c99d4eSJuan Castillo
483231c1470SEvan LloydSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
48473c99d4eSJuan Castillo
48573c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
48673c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
48773c99d4eSJuan Castillo
48873c99d4eSJuan Castillo
48973c99d4eSJuan Castillo################################################################################
49073c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
49173c99d4eSJuan Castillo################################################################################
49273c99d4eSJuan Castillo
49373c99d4eSJuan Castilloifneq (${SPD},none)
4949d29c227SSoby Mathew    ifeq (${ARCH},aarch32)
4959d29c227SSoby Mathew        $(error "Error: SPD is incompatible with AArch32.")
4969d29c227SSoby Mathew    endif
49728f39f02SMax Shvetsov
4984c117f6cSSandrine Bailleux    ifdef EL3_PAYLOAD_BASE
4994c117f6cSSandrine Bailleux        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
5004c117f6cSSandrine Bailleux        $(warning "The SPD and its BL32 companion will be present but ignored.")
5014c117f6cSSandrine Bailleux    endif
50228f39f02SMax Shvetsov
503c3fb00d9SAchin Gupta    ifeq (${SPD},spmd)
504033039f8SMax Shvetsov        $(warning "SPMD is an experimental feature")
505c3fb00d9SAchin Gupta        # SPMD is located in std_svc directory
506c3fb00d9SAchin Gupta        SPD_DIR := std_svc
50728f39f02SMax Shvetsov
508033039f8SMax Shvetsov        ifeq ($(SPMD_SPM_AT_SEL2),1)
50928f39f02SMax Shvetsov            ifeq ($(CTX_INCLUDE_EL2_REGS),0)
510033039f8SMax Shvetsov                $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
511033039f8SMax Shvetsov            endif
51228f39f02SMax Shvetsov        endif
513db1ef41aSOlivier Deprez
514db1ef41aSOlivier Deprez        ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
515db1ef41aSOlivier Deprez            DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
516db1ef41aSOlivier Deprez        endif
517c3fb00d9SAchin Gupta    else
518c3fb00d9SAchin Gupta        # All other SPDs in spd directory
519c3fb00d9SAchin Gupta        SPD_DIR := spd
520c3fb00d9SAchin Gupta    endif
521c3fb00d9SAchin Gupta
52273c99d4eSJuan Castillo    # We expect to locate an spd.mk under the specified SPD directory
523c3fb00d9SAchin Gupta    SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
524c3fb00d9SAchin Gupta
52573c99d4eSJuan Castillo    ifeq (${SPD_MAKE},)
526c3fb00d9SAchin Gupta        $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
52773c99d4eSJuan Castillo    endif
52873c99d4eSJuan Castillo    $(info Including ${SPD_MAKE})
52973c99d4eSJuan Castillo    include ${SPD_MAKE}
53073c99d4eSJuan Castillo
53170d1fc53SJuan Castillo    # If there's BL32 companion for the chosen SPD, we expect that the SPD's
53270d1fc53SJuan Castillo    # Makefile would set NEED_BL32 to "yes". In this case, the build system
53370d1fc53SJuan Castillo    # supports two mutually exclusive options:
53470d1fc53SJuan Castillo    # * BL32 is built from source: then BL32_SOURCES must contain the list
53570d1fc53SJuan Castillo    #   of source files to build BL32
53670d1fc53SJuan Castillo    # * BL32 is a prebuilt binary: then BL32 must point to the image file
53770d1fc53SJuan Castillo    #   that will be included in the FIP
53870d1fc53SJuan Castillo    # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
53970d1fc53SJuan Castillo    # over the sources.
540e35c4045SJeenu Viswambharanendif
541e35c4045SJeenu Viswambharan
54251faada7SDouglas Raillard################################################################################
54373c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
54473c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
54573c99d4eSJuan Castillo################################################################################
5462da8d8bfSJeenu Viswambharan
54773c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
5480f21c547SJuan Castillo
5498012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
5508012cc5cSMasahiro Yamada
55126e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
55226e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
55326e63c44SEtienne Carriereendif
55426e63c44SEtienne Carriere
5553bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
5563bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
5573bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
5583bd17c0fSSoby Mathewendif
559320920c1SMasahiro Yamada
560320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),)
561320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
562320920c1SMasahiro Yamadaelse
563320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
564320920c1SMasahiro Yamadaendif
565320920c1SMasahiro Yamada
566320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
56769af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
56869af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1)
56969af7fcfSMasahiro Yamada	BL2_CFLAGS	+=	-fpie
57069af7fcfSMasahiro Yamada	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
57169af7fcfSMasahiro Yamadaendif
57269af7fcfSMasahiro Yamadaendif
573320920c1SMasahiro Yamada	BL31_CFLAGS	+=	-fpie
574320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
575d974301dSMasahiro Yamadaifeq ($(ARCH),aarch64)
576d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
577d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
578d974301dSMasahiro Yamadaendif
5793bd17c0fSSoby Mathewendif
5803bd17c0fSSoby Mathew
581d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64)
5829cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
583d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
5849cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3
585d5e97a1dSMasahiro Yamadaelse
5869cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1
587d5e97a1dSMasahiro Yamadaendif
5889cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1
5899cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3
5909cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1
591d5e97a1dSMasahiro Yamadaendif
592d5e97a1dSMasahiro Yamada
59354035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
59454035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
59554035fc4SSandrine Bailleux# This can be overridden by the platform.
59673c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
5974f6ad66aSAchin Gupta
598a4409008Sdp-armifeq (${ARCH},aarch32)
599a4409008Sdp-armNEED_BL32 := yes
600a4409008Sdp-arm
601a4409008Sdp-arm################################################################################
602a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
603a4409008Sdp-arm################################################################################
604a4409008Sdp-armifneq (${AARCH32_SP},none)
605a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory
606a4409008Sdp-armAARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
607a4409008Sdp-arm
608a4409008Sdp-armifeq (${AARCH32_SP_MAKE},)
609a4409008Sdp-arm  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
610a4409008Sdp-armendif
611a4409008Sdp-arm
612a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE})
613a4409008Sdp-arminclude ${AARCH32_SP_MAKE}
614a4409008Sdp-armendif
615a4409008Sdp-arm
616a4409008Sdp-armendif
6174f6ad66aSAchin Gupta
61873c99d4eSJuan Castillo################################################################################
61977f1f7a1SVarun Wadekar# Include libc if not overridden
62077f1f7a1SVarun Wadekar################################################################################
62177f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
62277f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
62377f1f7a1SVarun Wadekarendif
62477f1f7a1SVarun Wadekar
62577f1f7a1SVarun Wadekar################################################################################
626cf2c8a33SAntonio Nino Diaz# Check incompatible options
627cf2c8a33SAntonio Nino Diaz################################################################################
628cf2c8a33SAntonio Nino Diaz
629cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
63068450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
63168450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
63268450a6dSAntonio Nino Diaz                incompatible build options. EL3_PAYLOAD_BASE has priority.")
633cf2c8a33SAntonio Nino Diaz        endif
63476580f3dSQixiang Xu        ifneq (${GENERATE_COT},0)
63576580f3dSQixiang Xu                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
63676580f3dSQixiang Xu        endif
63776580f3dSQixiang Xu        ifneq (${TRUSTED_BOARD_BOOT},0)
63876580f3dSQixiang Xu                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
63976580f3dSQixiang Xu        endif
640cf2c8a33SAntonio Nino Diazendif
641cf2c8a33SAntonio Nino Diaz
642cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
643cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
644cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
645cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
646cf2c8a33SAntonio Nino Diaz        endif
64768450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
64868450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
64968450a6dSAntonio Nino Diaz                PRELOADED_BL33_BASE is used and won't be added to the FIP \
65068450a6dSAntonio Nino Diaz                file.")
651cf2c8a33SAntonio Nino Diaz        endif
652cf2c8a33SAntonio Nino Diazendif
653cf2c8a33SAntonio Nino Diaz
654d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
655d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
656d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
657d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
658d4593e47SJeenu Viswambharanendif
6591a0a3f06SYatharth Kochar
6607d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
6617d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
6627d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
6637d173fc5SJiafei Panendif
6647d173fc5SJiafei Pan
66514c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first
66614c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
66714c6016aSJeenu Viswambharan    ifneq ($(HANDLE_EA_EL3_FIRST),1)
66814c6016aSJeenu Viswambharan        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1)
66914c6016aSJeenu Viswambharan    endif
67014c6016aSJeenu Viswambharanendif
67114c6016aSJeenu Viswambharan
6721a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
6731a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
6741a7c1cfeSJeenu Viswambharan    ifneq ($(RAS_EXTENSION),1)
6751a7c1cfeSJeenu Viswambharan        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
6761a7c1cfeSJeenu Viswambharan    endif
6771a7c1cfeSJeenu Viswambharanendif
6781a7c1cfeSJeenu Viswambharan
679ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
680209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
681209a60ccSSoby Mathew    ifeq (${TRUSTED_BOARD_BOOT}, 0)
682209a60ccSSoby Mathew        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
683209a60ccSSoby Mathew    endif
684209a60ccSSoby Mathewendif
685209a60ccSSoby Mathew
686cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
687cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
688cbf9e84aSBalint Dobszay$(error "SDEI_IN_FCONF is an experimental feature and is only supported when \
689cbf9e84aSBalint Dobszay	SDEI_SUPPORT is enabled")
690cbf9e84aSBalint Dobszayendif
691cbf9e84aSBalint Dobszay
69284ef9cd8SManish V Badarkheifeq ($(COT_DESC_IN_DTB),1)
69384ef9cd8SManish V Badarkhe    $(info CoT in device tree is an experimental feature)
69484ef9cd8SManish V Badarkheendif
69584ef9cd8SManish V Badarkhe
696b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
6979fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
6989fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
699b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
7009fc59639SAlexei Fedorov    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
7019fc59639SAlexei Fedorov        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
70206715f85SAlexei Fedorov    endif
7039fc59639SAlexei Fedorovendif
7049fc59639SAlexei Fedorov
70506715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
7069fc59639SAlexei Fedorov    ifneq (${ARCH},aarch64)
7079fc59639SAlexei Fedorov        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
708dfc66a17SJohn Tsichritzis    else
70906715f85SAlexei Fedorov        $(info CTX_INCLUDE_PAUTH_REGS is an experimental feature)
710b86048c4SAntonio Nino Diaz    endif
711b86048c4SAntonio Nino Diazendif
7129fc59639SAlexei Fedorov
7139fc59639SAlexei Fedorovifeq ($(ENABLE_PAUTH),1)
7149fc59639SAlexei Fedorov    $(info Pointer Authentication is an experimental feature)
7159fc59639SAlexei Fedorovendif
7169fc59639SAlexei Fedorov
7179fc59639SAlexei Fedorovifeq ($(ENABLE_BTI),1)
7189fc59639SAlexei Fedorov    $(info Branch Protection is an experimental feature)
719dfc66a17SJohn Tsichritzisendif
720b86048c4SAntonio Nino Diaz
7219dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1)
7229dd94382SJustin Chadwell    ifneq (${ARCH},aarch64)
7239dd94382SJustin Chadwell        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
7249dd94382SJustin Chadwell    else
7259dd94382SJustin Chadwell        $(info CTX_INCLUDE_MTE_REGS is an experimental feature)
7269dd94382SJustin Chadwell    endif
7279dd94382SJustin Chadwellendif
7289dd94382SJustin Chadwell
7298c105290SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
7308c105290SAlexei Fedorov    ifneq (${TRUSTED_BOARD_BOOT},1)
7317cda17bbSSumit Garg        $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1)
7328c105290SAlexei Fedorov    else
7338c105290SAlexei Fedorov        $(info MEASURED_BOOT is an experimental feature)
7348c105290SAlexei Fedorov    endif
7358c105290SAlexei Fedorovendif
7368c105290SAlexei Fedorov
73760e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
73860e8f3cfSPetre-Ionut Tudor    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
73960e8f3cfSPetre-Ionut Tudor        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
74060e8f3cfSPetre-Ionut Tudor    endif
74160e8f3cfSPetre-Ionut Tudorendif
74260e8f3cfSPetre-Ionut Tudor
7437cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
7447cda17bbSSumit Garg    ifeq (${TRUSTED_BOARD_BOOT}, 0)
7457cda17bbSSumit Garg        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
7467cda17bbSSumit Garg    else
7477cda17bbSSumit Garg        $(info DECRYPTION_SUPPORT is an experimental feature)
7487cda17bbSSumit Garg    endif
7497cda17bbSSumit Gargendif
7507cda17bbSSumit Garg
751cf2c8a33SAntonio Nino Diaz################################################################################
75273c99d4eSJuan Castillo# Process platform overrideable behaviour
75373c99d4eSJuan Castillo################################################################################
7544f6ad66aSAchin Gupta
755bd97f83aSJohn Tsichritzis# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
756bd97f83aSJohn Tsichritzis# Certificate generation tools. This flag can be overridden by the platform.
75773c99d4eSJuan Castilloifdef BL2_SOURCES
758cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
759cf2c8a33SAntonio Nino Diaz                # If booting an EL3 payload there is no need for a BL33 image
760cf2c8a33SAntonio Nino Diaz                # in the FIP file.
7614c117f6cSSandrine Bailleux                NEED_BL33		:=	no
762cf2c8a33SAntonio Nino Diaz        else
76368450a6dSAntonio Nino Diaz                ifdef PRELOADED_BL33_BASE
764cf2c8a33SAntonio Nino Diaz                        # If booting a BL33 preloaded image there is no need of
765cf2c8a33SAntonio Nino Diaz                        # another one in the FIP file.
766cf2c8a33SAntonio Nino Diaz                        NEED_BL33		:=	no
767cf2c8a33SAntonio Nino Diaz                else
768cf2c8a33SAntonio Nino Diaz                        NEED_BL33		?=	yes
769cf2c8a33SAntonio Nino Diaz                endif
7704c117f6cSSandrine Bailleux        endif
77173c99d4eSJuan Castilloendif
7726f971622SJuan Castillo
7734d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
7744d045d0eSMasahiro Yamadaifdef SCP_BL2
7754d045d0eSMasahiro Yamada        NEED_SCP_BL2		:=	yes
7764d045d0eSMasahiro Yamadaendif
7774d045d0eSMasahiro Yamada
7785744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
7795744e874SSoby Mathewifneq (${ARCH},aarch32)
7805744e874SSoby Mathew    ifdef BL31_SOURCES
7815744e874SSoby Mathew        # When booting an EL3 payload, there is no need to compile the BL31 image nor
7825744e874SSoby Mathew        # put it in the FIP.
7835744e874SSoby Mathew        ifndef EL3_PAYLOAD_BASE
7845744e874SSoby Mathew            NEED_BL31 := yes
7855744e874SSoby Mathew        endif
7865744e874SSoby Mathew    endif
7875744e874SSoby Mathewendif
7885744e874SSoby Mathew
78973c99d4eSJuan Castillo# Process TBB related flags
7906f971622SJuan Castilloifneq (${GENERATE_COT},0)
79173c99d4eSJuan Castillo        # Common cert_create options
7926f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
7936f971622SJuan Castillo                $(eval CRT_ARGS += -n)
7940191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
795fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
796fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
7970191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
798fd34e7baSJuan Castillo                endif
7996f971622SJuan Castillo        endif
80073c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
80173c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
80273c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
80373c99d4eSJuan Castillo        endif
8046f971622SJuan Castilloendif
8056f971622SJuan Castillo
8061c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
8071c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN}
8081c75d5dfSMasahiro Yamadaendif
8091c75d5dfSMasahiro Yamada
81073c99d4eSJuan Castillo################################################################################
81146e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
81246e5e035SMichalis Pappas################################################################################
81346e5e035SMichalis Pappas
81446e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
81546e5e035SMichalis Pappas
81646e5e035SMichalis Pappas################################################################################
817819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc)
81873c99d4eSJuan Castillo################################################################################
81973c99d4eSJuan Castillo
82073c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
82173c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
82242a45b51SEvan LloydCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
82373c99d4eSJuan Castillo
82490aa901fSSumit Garg# Variables for use with Firmware Encryption Tool
82590aa901fSSumit GargENCTOOLPATH		?=	tools/encrypt_fw
82690aa901fSSumit GargENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
82790aa901fSSumit Garg
82873c99d4eSJuan Castillo# Variables for use with Firmware Image Package
829819281eeSdp-armFIPTOOLPATH		?=	tools/fiptool
830819281eeSdp-armFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
83173c99d4eSJuan Castillo
83226010da1SAntonio Nino Diaz# Variables for use with sptool
83326010da1SAntonio Nino DiazSPTOOLPATH		?=	tools/sptool
83426010da1SAntonio Nino DiazSPTOOL			?=	${SPTOOLPATH}/sptool${BIN_EXT}
835ce2b1ec6SManish PandeySP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
83626010da1SAntonio Nino Diaz
8375accce5bSRoberto Vargas# Variables for use with ROMLIB
8385accce5bSRoberto VargasROMLIBPATH		?=	lib/romlib
8395accce5bSRoberto Vargas
840cfe83910SLouis Mayencourt# Variable for use with Python
841cfe83910SLouis MayencourtPYTHON			?=	python3
842cfe83910SLouis Mayencourt
843cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP
844cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH		?=	tools/memory
845cfe83910SLouis MayencourtPRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
846cfe83910SLouis Mayencourt
8476de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool
8486de32378SMadhukar PappireddyDOCS_PATH		?=	docs
8496de32378SMadhukar Pappireddy
8508a86052dSSoby Mathew################################################################################
8518a86052dSSoby Mathew# Include BL specific makefiles
8528a86052dSSoby Mathew################################################################################
8538a86052dSSoby Mathewifdef BL1_SOURCES
8548a86052dSSoby MathewNEED_BL1 := yes
8558a86052dSSoby Mathewinclude bl1/bl1.mk
8568a86052dSSoby Mathewendif
8578a86052dSSoby Mathew
8588a86052dSSoby Mathewifdef BL2_SOURCES
8598a86052dSSoby MathewNEED_BL2 := yes
8608a86052dSSoby Mathewinclude bl2/bl2.mk
8618a86052dSSoby Mathewendif
8628a86052dSSoby Mathew
8638a86052dSSoby Mathewifdef BL2U_SOURCES
8648a86052dSSoby MathewNEED_BL2U := yes
8658a86052dSSoby Mathewinclude bl2u/bl2u.mk
8668a86052dSSoby Mathewendif
8678a86052dSSoby Mathew
8685744e874SSoby Mathewifeq (${NEED_BL31},yes)
8698a86052dSSoby Mathewifdef BL31_SOURCES
8708a86052dSSoby Mathewinclude bl31/bl31.mk
8718a86052dSSoby Mathewendif
8728a86052dSSoby Mathewendif
8738a86052dSSoby Mathew
87403b397a8SNishanth Menonifdef FDT_SOURCES
87503b397a8SNishanth MenonNEED_FDT := yes
87603b397a8SNishanth Menonendif
87703b397a8SNishanth Menon
87873c99d4eSJuan Castillo################################################################################
87973c99d4eSJuan Castillo# Build options checks
88073c99d4eSJuan Castillo################################################################################
88173c99d4eSJuan Castillo
882327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
883327131c4SLeonardo Sandoval    $(sort \
884327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
885327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
886327131c4SLeonardo Sandoval        CREATE_KEYS \
887327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
888327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
889327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
890327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
891327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
892062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
893327131c4SLeonardo Sandoval        DEBUG \
8940063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
895327131c4SLeonardo Sandoval        DYN_DISABLE_AUTH \
896327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
897327131c4SLeonardo Sandoval        ENABLE_AMU \
898327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
899327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
900327131c4SLeonardo Sandoval        ENABLE_PIE \
901327131c4SLeonardo Sandoval        ENABLE_PMF \
902327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
903327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
904327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
905327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
906327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
907327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
908327131c4SLeonardo Sandoval        GENERATE_COT \
909327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
910327131c4SLeonardo Sandoval        HANDLE_EA_EL3_FIRST \
911327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
912327131c4SLeonardo Sandoval        INVERTED_MEMMAP \
913327131c4SLeonardo Sandoval        MEASURED_BOOT \
914327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
915327131c4SLeonardo Sandoval        OVERRIDE_LIBC \
916327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
917327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
918327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
919327131c4SLeonardo Sandoval        RAS_EXTENSION \
920327131c4SLeonardo Sandoval        RESET_TO_BL31 \
921327131c4SLeonardo Sandoval        SAVE_KEYS \
922327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
923327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
924327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
925327131c4SLeonardo Sandoval        SPM_MM \
926327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
927327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
928327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
929327131c4SLeonardo Sandoval        USE_DEBUGFS \
930327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
931327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
932327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
933327131c4SLeonardo Sandoval        USE_ROMLIB \
934327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
935327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
936327131c4SLeonardo Sandoval        BL2_AT_EL3 \
937327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
938327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
939327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
940327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
941327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
942327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
943327131c4SLeonardo Sandoval        RAS_TRAP_LOWER_EL_ERR_ACCESS \
944327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
945327131c4SLeonardo Sandoval        USE_SP804_TIMER \
946*12cd65e0STomas Pilar        ENABLE_FEAT_RNG \
947327131c4SLeonardo Sandoval)))
94873c99d4eSJuan Castillo
949327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
950327131c4SLeonardo Sandoval    $(sort \
951327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
952327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
953327131c4SLeonardo Sandoval        BRANCH_PROTECTION \
954327131c4SLeonardo Sandoval        FW_ENC_STATUS \
955327131c4SLeonardo Sandoval)))
956c877b414SJeenu Viswambharan
957aacff749SJustin Chadwellifdef KEY_SIZE
958aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
959aacff749SJustin Chadwellendif
960aacff749SJustin Chadwell
9611f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
9621f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
9631f461979SJustin Chadwellendif
9641f461979SJustin Chadwell
96573c99d4eSJuan Castillo################################################################################
96673c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
96773c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
96873c99d4eSJuan Castillo# platform to overwrite the default options
96973c99d4eSJuan Castillo################################################################################
97073c99d4eSJuan Castillo
971327131c4SLeonardo Sandoval$(eval $(call add_defines,\
972327131c4SLeonardo Sandoval    $(sort \
973327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
974327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
975327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
976327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
977327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
978327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
979327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
980327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
981327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
982327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
983062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
984327131c4SLeonardo Sandoval        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
9850063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
986327131c4SLeonardo Sandoval        ENABLE_AMU \
987327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
988327131c4SLeonardo Sandoval        ENABLE_BTI \
989327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
990327131c4SLeonardo Sandoval        ENABLE_PAUTH \
991327131c4SLeonardo Sandoval        ENABLE_PIE \
992327131c4SLeonardo Sandoval        ENABLE_PMF \
993327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
994327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
995327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
996327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
997327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
998327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
999327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
1000327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
1001327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
1002327131c4SLeonardo Sandoval        HANDLE_EA_EL3_FIRST \
1003327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
1004327131c4SLeonardo Sandoval        LOG_LEVEL \
1005327131c4SLeonardo Sandoval        MEASURED_BOOT \
1006327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
1007327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
1008327131c4SLeonardo Sandoval        PLAT_${PLAT} \
1009327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
1010327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
1011327131c4SLeonardo Sandoval        RAS_EXTENSION \
1012327131c4SLeonardo Sandoval        RESET_TO_BL31 \
1013327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
1014327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
1015327131c4SLeonardo Sandoval        RECLAIM_INIT_CODE \
1016327131c4SLeonardo Sandoval        SPD_${SPD} \
1017327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
1018327131c4SLeonardo Sandoval        SPM_MM \
1019327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
1020327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
1021327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
1022327131c4SLeonardo Sandoval        USE_DEBUGFS \
1023327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
1024327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
1025327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
1026327131c4SLeonardo Sandoval        USE_ROMLIB \
1027327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
1028327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
1029327131c4SLeonardo Sandoval        BL2_AT_EL3 \
1030327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
1031327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
1032327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
1033327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
1034327131c4SLeonardo Sandoval        RAS_TRAP_LOWER_EL_ERR_ACCESS \
1035327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
1036327131c4SLeonardo Sandoval        USE_SP804_TIMER \
1037*12cd65e0STomas Pilar        ENABLE_FEAT_RNG \
1038327131c4SLeonardo Sandoval)))
10392fae4b1eSJeenu Viswambharan
10401f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
10411f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
10421f461979SJustin Chadwellendif
10431f461979SJustin Chadwell
10444c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
10454c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
10464c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1047cf2c8a33SAntonio Nino Diazelse
104868450a6dSAntonio Nino Diaz        # Define the PRELOADED_BL33_BASE flag only if it is provided and
104968450a6dSAntonio Nino Diaz        # EL3_PAYLOAD_BASE is not defined, as it has priority.
105068450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
105168450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
10524c117f6cSSandrine Bailleux        endif
1053cf2c8a33SAntonio Nino Diazendif
105473c99d4eSJuan Castillo
1055209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1056209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1057209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH))
1058209a60ccSSoby Mathewendif
1059209a60ccSSoby Mathew
1060c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
1061c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK))
1062c2ad38ceSVarun Wadekarendif
1063c2ad38ceSVarun Wadekar
1064ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1065ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1066c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1067c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},0)
1068c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL1 does not require SP_LAYOUT_FILE")
1069c33ff198SOlivier Deprez        endif
1070ce2b1ec6SManish Pandey        -include $(BUILD_PLAT)/sp_gen.mk
1071ce2b1ec6SManish Pandey        FIP_DEPS += sp
107207c44475SManish Pandey        CRT_DEPS += sp
1073ce2b1ec6SManish Pandey        NEED_SP_PKG := yes
1074ce2b1ec6SManish Pandeyelse
1075c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},1)
1076c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1077c33ff198SOlivier Deprez        endif
1078ce2b1ec6SManish Pandeyendif
1079ce2b1ec6SManish Pandeyendif
1080ce2b1ec6SManish Pandey
108173c99d4eSJuan Castillo################################################################################
108273c99d4eSJuan Castillo# Build targets
108373c99d4eSJuan Castillo################################################################################
108473c99d4eSJuan Castillo
108590aa901fSSumit Garg.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
108673c99d4eSJuan Castillo.SUFFIXES:
108773c99d4eSJuan Castillo
108873c99d4eSJuan Castilloall: msg_start
108973c99d4eSJuan Castillo
109073c99d4eSJuan Castillomsg_start:
109173c99d4eSJuan Castillo	@echo "Building ${PLAT}"
109273c99d4eSJuan Castillo
10937a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1094d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
1095c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),)
1096c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1097c2ad38ceSVarun Wadekarelse
1098bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
10997a24cba5SSoby Mathewendif
1100d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED
11017a24cba5SSoby Mathew
11025accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS))
110361f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
11045fee0287SRoberto Vargas
110573c99d4eSJuan Castillo# Expand build macros for the different images
110673c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
110773c99d4eSJuan Castillo$(eval $(call MAKE_BL,1))
110873c99d4eSJuan Castilloendif
110973c99d4eSJuan Castillo
111073c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1111c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0)
1112c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1113c9b31ae8SRoberto Vargasendif
1114c9b31ae8SRoberto Vargas
111533950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1116c9b31ae8SRoberto Vargas	$(eval $(call MAKE_BL,2,${FIP_BL2_ARGS})))
111773c99d4eSJuan Castilloendif
111873c99d4eSJuan Castillo
11194d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
112033950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
11214d045d0eSMasahiro Yamadaendif
11224d045d0eSMasahiro Yamada
112373c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
112473c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
112526d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
112626d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1127c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1128c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1129c6ba9b45SSumit Garg	$(eval $(call MAKE_BL,31,soc-fw,,$(ENCRYPT_BL31))))
1130c6ba9b45SSumit Gargelse
113133950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
11328f0617efSJuan Castillo	$(eval $(call MAKE_BL,31,soc-fw)))
113373c99d4eSJuan Castilloendif
1134c6ba9b45SSumit Gargendif
113573c99d4eSJuan Castillo
113670d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1137c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
113870d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
113973c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
114026d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
114126d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
11429cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
11439cd15239SMasahiro Yamada
1144c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1145c6ba9b45SSumit Garg$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw,,$(ENCRYPT_BL32))),\
1146c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1147c6ba9b45SSumit Gargelse
11489cd15239SMasahiro Yamada$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\
114933950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
115073c99d4eSJuan Castilloendif
1151c6ba9b45SSumit Gargendif
115273c99d4eSJuan Castillo
115373c99d4eSJuan Castillo# Add the BL33 image if required by the platform
115473c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
115533950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1156db6071c9SJuan Castilloendif
1157db6071c9SJuan Castillo
11589003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
115933950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
11601dc0714fSMasahiro Yamada	$(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_)))
11619003fa0bSYatharth Kocharendif
11629003fa0bSYatharth Kochar
116303b397a8SNishanth Menon# Expand build macros for the different images
116403b397a8SNishanth Menonifeq (${NEED_FDT},yes)
116503b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
116603b397a8SNishanth Menonendif
116703b397a8SNishanth Menon
1168ce2b1ec6SManish Pandey# Add Secure Partition packages
1169ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1170ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
11711e7528ecSRuari Phipps	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1172ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk
1173ce2b1ec6SManish Pandey	${Q}$(SPTOOL) $(SPTOOL_ARGS)
1174ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1175ce2b1ec6SManish Pandey	@echo "Built SP Images successfully"
1176ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1177ce2b1ec6SManish Pandeyendif
1178ce2b1ec6SManish Pandey
117936eaaf37SIan Spraylocate-checkpatch:
118036eaaf37SIan Sprayifndef CHECKPATCH
118166079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
118236eaaf37SIan Sprayelse
118336eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
118466079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
118536eaaf37SIan Sprayendif
118636eaaf37SIan Sprayendif
118736eaaf37SIan Spray
11884f6ad66aSAchin Guptaclean:
11894f6ad66aSAchin Gupta	@echo "  CLEAN"
1190f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
119188a1cf1eSSami Mujawarifdef UNIX_MK
11922f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
119388a1cf1eSSami Mujawarelse
119488a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
119588a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
119688a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
119788a1cf1eSSami Mujawarendif
11986f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
119990aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
12005accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
12014f6ad66aSAchin Gupta
1202eaaeece2SJames Morrisseyrealclean distclean:
1203eaaeece2SJames Morrissey	@echo "  REALCLEAN"
1204f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1205f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
120688a1cf1eSSami Mujawarifdef UNIX_MK
12072f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
120888a1cf1eSSami Mujawarelse
120988a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
121088a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
121188a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
121288a1cf1eSSami Mujawarendif
121326010da1SAntonio Nino Diaz	${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean
12146f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
121590aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
12165accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
12174f6ad66aSAchin Gupta
121836eaaf37SIan Spraycheckcodebase:		locate-checkpatch
121936eaaf37SIan Spray	@echo "  CHECKING STYLE"
122036eaaf37SIan Spray	@if test -d .git ; then						\
12211ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
12221a41e8c1SDan Handley		while read GIT_FILE ;					\
12231a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
12241a41e8c1SDan Handley		done ;							\
122536eaaf37SIan Spray	else								\
12261a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
12271a41e8c1SDan Handley		 -not -iwholename "*build*"				\
12281a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
122961f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
12301a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
12311ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
12321a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
123336eaaf37SIan Spray	fi
123436eaaf37SIan Spray
123536eaaf37SIan Spraycheckpatch:		locate-checkpatch
123636eaaf37SIan Spray	@echo "  CHECKING STYLE"
123702a76d5fSYann Gautier	@if test -n "${CHECKPATCH_OPTS}"; then				\
123802a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
123902a76d5fSYann Gautier	fi
124051d28937SAntonio Nino Diaz	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
124151d28937SAntonio Nino Diaz	for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do		\
124251d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
124351d28937SAntonio Nino Diaz		git log --format=email "$$commit~..$$commit"		\
124402a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
124502a76d5fSYann Gautier			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
124651d28937SAntonio Nino Diaz		git diff --format=email "$$commit~..$$commit"		\
124702a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
124802a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
124951d28937SAntonio Nino Diaz	done
125036eaaf37SIan Spray
125173c99d4eSJuan Castillocerttool: ${CRTTOOL}
125273c99d4eSJuan Castillo
12536f971622SJuan Castillo.PHONY: ${CRTTOOL}
12546f971622SJuan Castillo${CRTTOOL}:
1255fafd3ec9SManish V Badarkhe	${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} --no-print-directory -C ${CRTTOOLPATH}
1256f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12576f971622SJuan Castillo	@echo "Built $@ successfully"
1258f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12596f971622SJuan Castillo
12606f971622SJuan Castilloifneq (${GENERATE_COT},0)
126173c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
12626f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
1263f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12646f971622SJuan Castillo	@echo "Built $@ successfully"
12656f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
1266f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
126773c99d4eSJuan Castilloendif
126827713fb4SSoby Mathew
126973c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
1270819281eeSdp-arm	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1271819281eeSdp-arm	${Q}${FIPTOOL} info $@
1272f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12732f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
1274f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1275f58ad36fSHarry Liebel
12760191262dSYatharth Kocharifneq (${GENERATE_COT},0)
12770191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
12780191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1279052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12800191262dSYatharth Kochar	@echo "Built $@ successfully"
12810191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1282052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12830191262dSYatharth Kocharendif
12840191262dSYatharth Kochar
12850191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
1286819281eeSdp-arm	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1287819281eeSdp-arm	${Q}${FIPTOOL} info $@
1288052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12890191262dSYatharth Kochar	@echo "Built $@ successfully"
1290052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12910191262dSYatharth Kochar
129273c99d4eSJuan Castillofiptool: ${FIPTOOL}
129373c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
12940191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
129573c99d4eSJuan Castillo
129673c99d4eSJuan Castillo.PHONY: ${FIPTOOL}
129773c99d4eSJuan Castillo${FIPTOOL}:
129888a1cf1eSSami Mujawar	@${ECHO_BLANK_LINE}
129988a1cf1eSSami Mujawar	@echo "Building $@"
130088a1cf1eSSami Mujawarifdef UNIX_MK
1301fafd3ec9SManish V Badarkhe	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH}
130288a1cf1eSSami Mujawarelse
130388a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
130488a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
130588a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
130688a1cf1eSSami Mujawarendif
130788a1cf1eSSami Mujawar	@${ECHO_BLANK_LINE}
1308f58ad36fSHarry Liebel
130926010da1SAntonio Nino Diazsptool: ${SPTOOL}
131026010da1SAntonio Nino Diaz.PHONY: ${SPTOOL}
131126010da1SAntonio Nino Diaz${SPTOOL}:
1312fafd3ec9SManish V Badarkhe	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH}
131326010da1SAntonio Nino Diaz
13145accce5bSRoberto Vargas.PHONY: libraries
13155accce5bSRoberto Vargasromlib.bin: libraries
1316bbb24f61SJohn 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
13175accce5bSRoberto Vargas
1318cfe83910SLouis Mayencourt# Call print_memory_map tool
1319cfe83910SLouis Mayencourtmemmap: all
1320b890b36dSLouis Mayencourt	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1321cfe83910SLouis Mayencourt
13226de32378SMadhukar Pappireddydoc:
13236de32378SMadhukar Pappireddy	@echo "  BUILD DOCUMENTATION"
13246de32378SMadhukar Pappireddy	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
13256de32378SMadhukar Pappireddy
132690aa901fSSumit Gargenctool: ${ENCTOOL}
132790aa901fSSumit Garg
132890aa901fSSumit Garg.PHONY: ${ENCTOOL}
132990aa901fSSumit Garg${ENCTOOL}:
1330fafd3ec9SManish V Badarkhe	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH}
133190aa901fSSumit Garg	@${ECHO_BLANK_LINE}
133290aa901fSSumit Garg	@echo "Built $@ successfully"
133390aa901fSSumit Garg	@${ECHO_BLANK_LINE}
133490aa901fSSumit Garg
133535fab8c9SJoakim Bechcscope:
133635fab8c9SJoakim Bech	@echo "  CSCOPE"
133735fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
133835fab8c9SJoakim Bech	${Q}cscope -b -q -k
133935fab8c9SJoakim Bech
134072ee3314SRyan Harkinhelp:
13417c23126cSJohn Tsichritzis	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
134272ee3314SRyan Harkin	@echo ""
134372ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
134408c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
134572ee3314SRyan Harkin	@echo ""
13467c23126cSJohn Tsichritzis	@echo "platform = ${PLATFORM_LIST}"
13477c23126cSJohn Tsichritzis	@echo ""
13481b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
13491b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
13501b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
13511b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
13521b578596SSandrine Bailleux	@echo ""
135372ee3314SRyan Harkin	@echo "Supported Targets:"
13541b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
135536eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
13568aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
13579003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
1358d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
13599d29c227SSoby Mathew	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
13609d29c227SSoby Mathew	@echo "                 this builds secure payload specified by AARCH32_SP"
136173c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
13621b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
13630191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
136436eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
136536eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
136636eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
136772ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
136835fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
136972ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
13706f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
137190aa901fSSumit Garg	@echo "  enctool        Build the Firmware encryption tool"
1372f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1373ce2b1ec6SManish Pandey	@echo "  sp             Build the Secure Partition Packages"
137426010da1SAntonio Nino Diaz	@echo "  sptool         Build the Secure Partition Package creation tool"
137538c14d88SSoby Mathew	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1376cfe83910SLouis Mayencourt	@echo "  memmap         Print the memory map of the built binaries"
13776de32378SMadhukar Pappireddy	@echo "  doc            Build html based documentation using Sphinx tool"
137872ee3314SRyan Harkin	@echo ""
13791b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
138072ee3314SRyan Harkin	@echo ""
138172ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
138272ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1383