xref: /rk3399_ARM-atf/Makefile (revision 7ff088d1f0d17e6afed236f979ffc5adf005d8b0)
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
112ee6b2bcSDeepika BhavnaniVERSION_MINOR			:= 2
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
42f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
431a41e8c1SDan Handley					include/lib/libfdt		\
4461f72a34SRoberto Vargas					include/lib/libc,		\
45f0b489c1SDan Handley					$(wildcard include/lib/*)))
46f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
47f0b489c1SDan Handley					include/lib,			\
48f0b489c1SDan Handley					$(wildcard include/*)))
49f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
50d801fbb0Sdp-arm					lib/compiler-rt			\
5155cdcf75SAntonio Nino Diaz					lib/libfdt%			\
5261f72a34SRoberto Vargas					lib/libc,			\
53f0b489c1SDan Handley					$(wildcard lib/*)))
54f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
55f0b489c1SDan Handley					lib				\
56f0b489c1SDan Handley					include				\
57f0b489c1SDan Handley					docs				\
581ef35512SPaul Beesley					%.rst,				\
59f0b489c1SDan Handley					$(wildcard *)))
60f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
61f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
62f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
63f0b489c1SDan Handley				${LIB_DIRS_TO_CHECK}
6436eaaf37SIan Spray
6573c99d4eSJuan Castillo
6673c99d4eSJuan Castillo################################################################################
6773c99d4eSJuan Castillo# Process build options
6873c99d4eSJuan Castillo################################################################################
6973c99d4eSJuan Castillo
7073c99d4eSJuan Castillo# Verbose flag
71e35c4045SJeenu Viswambharanifeq (${V},0)
72b169f6a9SEvan Lloyd        Q:=@
73ee1ba6d4SAndre Przywara        ECHO:=@echo
7436eaaf37SIan Spray        CHECKCODE_ARGS	+=	--no-summary --terse
754f6ad66aSAchin Guptaelse
76b169f6a9SEvan Lloyd        Q:=
77b5a0f4bdSAntonio Nino Diaz        ECHO:=$(ECHO_QUIET)
784f6ad66aSAchin Guptaendif
79ee1ba6d4SAndre Przywara
80ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
81ee1ba6d4SAndre Przywara        Q:=@
82b5a0f4bdSAntonio Nino Diaz        ECHO:=$(ECHO_QUIET)
83ee1ba6d4SAndre Przywaraendif
84ee1ba6d4SAndre Przywara
85ee1ba6d4SAndre Przywaraexport Q ECHO
862f2cef46SJeenu Viswambharan
87aaa3e722SJuan Castillo# Default build string (git branch and commit)
88aaa3e722SJuan Castilloifeq (${BUILD_STRING},)
89bee71c7aSMasahiro Yamada        BUILD_STRING	:=	$(shell git describe --always --dirty --tags 2> /dev/null)
90aaa3e722SJuan Castilloendif
91aaa3e722SJuan CastilloVERSION_STRING		:=	v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
92aaa3e722SJuan Castillo
9373c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the
9473c99d4eSJuan Castillo# target 'certificates' to create them all
9573c99d4eSJuan Castilloifneq (${GENERATE_COT},0)
9673c99d4eSJuan Castillo        FIP_DEPS += certificates
970191262dSYatharth Kochar        FWU_FIP_DEPS += fwu_certificates
9873c99d4eSJuan Castilloendif
9973c99d4eSJuan Castillo
1009fc59639SAlexei Fedorov# Process BRANCH_PROTECTION value and set
1019fc59639SAlexei Fedorov# Pointer Authentication and Branch Target Identification flags
1029fc59639SAlexei Fedorovifeq (${BRANCH_PROTECTION},0)
1039fc59639SAlexei Fedorov	# Default value turns off all types of branch protection
1049fc59639SAlexei Fedorov	BP_OPTION := none
1059fc59639SAlexei Fedorovelse ifneq (${ARCH},aarch64)
1069fc59639SAlexei Fedorov        $(error BRANCH_PROTECTION requires AArch64)
1079fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},1)
1089fc59639SAlexei Fedorov	# Enables all types of branch protection features
1099fc59639SAlexei Fedorov	BP_OPTION := standard
1109fc59639SAlexei Fedorov	ENABLE_BTI := 1
1119fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1129fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},2)
1139fc59639SAlexei Fedorov	# Return address signing to its standard level
1149fc59639SAlexei Fedorov	BP_OPTION := pac-ret
1159fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1169fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},3)
1179fc59639SAlexei Fedorov	# Extend the signing to include leaf functions
1189fc59639SAlexei Fedorov	BP_OPTION := pac-ret+leaf
1199fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1209fc59639SAlexei Fedorovelse
1219fc59639SAlexei Fedorov        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
1229fc59639SAlexei Fedorovendif
12373c99d4eSJuan Castillo
124c97cba4eSSoby Mathew# USE_SPINLOCK_CAS requires AArch64 build
125c97cba4eSSoby Mathewifeq (${USE_SPINLOCK_CAS},1)
126c97cba4eSSoby Mathewifneq (${ARCH},aarch64)
127c97cba4eSSoby Mathew        $(error USE_SPINLOCK_CAS requires AArch64)
128c97cba4eSSoby Mathewelse
129c97cba4eSSoby Mathew        $(info USE_SPINLOCK_CAS is an experimental feature)
130c97cba4eSSoby Mathewendif
131c97cba4eSSoby Mathewendif
132c97cba4eSSoby Mathew
1330ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds
1340ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1)
1350ca3913dSOlivier Deprezifeq (${DEBUG},1)
1360ca3913dSOlivier Deprez        $(warning DEBUGFS experimental feature is enabled.)
1370ca3913dSOlivier Deprezelse
1380ca3913dSOlivier Deprez        $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
1390ca3913dSOlivier Deprezendif
1400ca3913dSOlivier Deprezendif
1410ca3913dSOlivier Deprez
142c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
143c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS}
144c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY}
145c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE}
146c6ba9b45SSumit GargFIP_DEPS += enctool
147c6ba9b45SSumit GargFWU_FIP_DEPS += enctool
148c6ba9b45SSumit Gargendif
149c6ba9b45SSumit Garg
15073c99d4eSJuan Castillo################################################################################
15173c99d4eSJuan Castillo# Toolchain
15273c99d4eSJuan Castillo################################################################################
15373c99d4eSJuan Castillo
15472610c41Sdp-armHOSTCC			:=	gcc
15572610c41Sdp-armexport HOSTCC
15672610c41Sdp-arm
15773c99d4eSJuan CastilloCC			:=	${CROSS_COMPILE}gcc
15873c99d4eSJuan CastilloCPP			:=	${CROSS_COMPILE}cpp
15973c99d4eSJuan CastilloAS			:=	${CROSS_COMPILE}gcc
16073c99d4eSJuan CastilloAR			:=	${CROSS_COMPILE}ar
1612adee763SRoberto VargasLINKER			:=	${CROSS_COMPILE}ld
16273c99d4eSJuan CastilloOC			:=	${CROSS_COMPILE}objcopy
16373c99d4eSJuan CastilloOD			:=	${CROSS_COMPILE}objdump
16473c99d4eSJuan CastilloNM			:=	${CROSS_COMPILE}nm
16573c99d4eSJuan CastilloPP			:=	${CROSS_COMPILE}gcc -E
16638c14d88SSoby MathewDTC			:=	dtc
16773c99d4eSJuan Castillo
168b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
169b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \
1702adee763SRoberto Vargas	$(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
1712adee763SRoberto VargasLINKER			:=	${LINKER}.bfd
172b25a577fSJulius Wernerendif
173b25a577fSJulius Werner
17426e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
17526e63c44SEtienne Carrieretarget32-directive	= 	-target arm-none-eabi
17626e63c44SEtienne Carriere# Will set march32-directive from platform configuration
17726e63c44SEtienne Carriereelse
17826e63c44SEtienne Carrieretarget32-directive	= 	-target armv8a-none-eabi
179fa6f774bSAlexei Fedorov
180fa6f774bSAlexei Fedorov# Set the compiler's target architecture profile based on ARM_ARCH_MINOR option
181fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0)
182da547d4bSSandrine Bailleuxmarch32-directive	= 	-march=armv8-a
183fa6f774bSAlexei Fedorovmarch64-directive	= 	-march=armv8-a
184fa6f774bSAlexei Fedorovelse
185fa6f774bSAlexei Fedorovmarch32-directive	= 	-march=armv8.${ARM_ARCH_MINOR}-a
186fa6f774bSAlexei Fedorovmarch64-directive	= 	-march=armv8.${ARM_ARCH_MINOR}-a
187fa6f774bSAlexei Fedorovendif
18826e63c44SEtienne Carriereendif
18926e63c44SEtienne Carriere
190*7ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
191*7ff088d1SManish V Badarkheifeq ($(ARCH), aarch64)
192*7ff088d1SManish V Badarkheifeq ($(shell test $(ARM_ARCH_MAJOR) -gt 8; echo $$?),0)
193*7ff088d1SManish V Badarkhemem_tag_arch_support	= 	yes
194*7ff088d1SManish V Badarkheelse ifeq ($(shell test $(ARM_ARCH_MAJOR) -eq 8 -a $(ARM_ARCH_MINOR) -ge 5; \
195*7ff088d1SManish V Badarkhe	   echo $$?),0)
196*7ff088d1SManish V Badarkhemem_tag_arch_support	= 	yes
197*7ff088d1SManish V Badarkheendif
198*7ff088d1SManish V Badarkheendif
199*7ff088d1SManish V Badarkhe
200*7ff088d1SManish V Badarkhe# Enabled required option for memory stack tagging. Currently, these options are
201*7ff088d1SManish V Badarkhe# enabled only for clang and armclang compiler.
202*7ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes)
203*7ff088d1SManish V Badarkheifdef mem_tag_arch_support
204*7ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang))
205*7ff088d1SManish V Badarkhemarch64-directive       =       -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a+memtag
206*7ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang)
207*7ff088d1SManish V BadarkheTF_CFLAGS		+=	-mmemtag-stack
208*7ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang)
209*7ff088d1SManish V BadarkheTF_CFLAGS		+=	-fsanitize=memtag
210*7ff088d1SManish V Badarkheendif
211*7ff088d1SManish V Badarkheendif
212*7ff088d1SManish V Badarkheelse
213*7ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \
214*7ff088d1SManish V Badarkhe	${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
215*7ff088d1SManish V Badarkheendif
216*7ff088d1SManish V Badarkheendif
217*7ff088d1SManish V Badarkhe
218fd18a8fcSVarun Wadekarifneq ($(findstring armclang,$(notdir $(CC))),)
21926e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	-target arm-arm-none-eabi $(march32-directive)
220fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-arm-none-eabi $(march64-directive)
2212adee763SRoberto VargasLD			=	$(LINKER)
2221684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2237040155eSRoberto VargasCPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2247040155eSRoberto VargasPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2257559633bSdp-armelse ifneq ($(findstring clang,$(notdir $(CC))),)
226eff737c1SArve HjønnevågCLANG_CCDIR		=	$(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),)
227e2bfec0bSYann GautierTF_CFLAGS_aarch32	=	$(target32-directive) $(march32-directive)
228fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-elf $(march64-directive)
229eff737c1SArve HjønnevågLD			=	$(CLANG_CCDIR)ld.lld
230641f16e7SAmbroise Vincentifeq (, $(shell which $(LD)))
231641f16e7SAmbroise Vincent$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker")
232641f16e7SAmbroise Vincentendif
2331684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2347040155eSRoberto VargasCPP			=	$(CC) -E
2357040155eSRoberto VargasPP			=	$(CC) -E
236edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),)
237edbce9aaSzelalem-awekeTF_CFLAGS_aarch32	=	$(march32-directive)
238edbce9aaSzelalem-awekeTF_CFLAGS_aarch64	=	$(march64-directive)
239edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
240edbce9aaSzelalem-aweke	# Enable LTO only for aarch64
241edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
242edbce9aaSzelalem-aweke		LTO_CFLAGS	=	-flto
243edbce9aaSzelalem-aweke		# Use gcc as a wrapper for the ld, recommended for LTO
244edbce9aaSzelalem-aweke		LINKER		:=	${CROSS_COMPILE}gcc
245edbce9aaSzelalem-aweke	endif
246edbce9aaSzelalem-awekeendif
247edbce9aaSzelalem-awekeLD			=	$(LINKER)
248d5461857Sdp-armelse
24926e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	$(march32-directive)
250fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	$(march64-directive)
2512adee763SRoberto VargasLD			=	$(LINKER)
252d5461857Sdp-armendif
253d5461857Sdp-arm
25432b209bfSAhmad Fatoum# Process Debug flag
25532b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
25632b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
25732b209bfSAhmad Fatoum        BUILD_TYPE	:=	debug
25832b209bfSAhmad Fatoum        TF_CFLAGS	+= 	-g
25932b209bfSAhmad Fatoum
26032b209bfSAhmad Fatoum        ifneq ($(findstring clang,$(notdir $(CC))),)
26132b209bfSAhmad Fatoum             ASFLAGS		+= 	-g
26232b209bfSAhmad Fatoum        else
26332b209bfSAhmad Fatoum             ASFLAGS		+= 	-g -Wa,--gdwarf-2
26432b209bfSAhmad Fatoum        endif
26532b209bfSAhmad Fatoum
26632b209bfSAhmad Fatoum        # Use LOG_LEVEL_INFO by default for debug builds
26732b209bfSAhmad Fatoum        LOG_LEVEL	:=	40
26832b209bfSAhmad Fatoumelse
26932b209bfSAhmad Fatoum        BUILD_TYPE	:=	release
27032b209bfSAhmad Fatoum        # Use LOG_LEVEL_NOTICE by default for release builds
27132b209bfSAhmad Fatoum        LOG_LEVEL	:=	20
27232b209bfSAhmad Fatoumendif
27332b209bfSAhmad Fatoum
2748fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
2758fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-marm
2768fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
2778fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-mthumb
2788fd9d4d5SAntonio Nino Diazelse
2798fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
2808fd9d4d5SAntonio Nino Diazendif
2818fd9d4d5SAntonio Nino Diaz
282a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
283d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
2849d29c227SSoby Mathew
2859fc59639SAlexei Fedorovifneq (${BP_OPTION},none)
2869fc59639SAlexei FedorovTF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
2879fc59639SAlexei Fedorovendif
2889fc59639SAlexei Fedorov
28926e63c44SEtienne CarriereASFLAGS_aarch32		=	$(march32-directive)
290fa6f774bSAlexei FedorovASFLAGS_aarch64		=	$(march64-directive)
291b86048c4SAntonio Nino Diaz
2929ab81b5eSJustin Chadwell# General warnings
2939ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
294b7f6525dSJustin Chadwell				-Wdisabled-optimization	-Wvla -Wshadow	\
295ca661a00SMadhukar Pappireddy				-Wno-unused-parameter -Wredundant-decls
2969ab81b5eSJustin Chadwell
2979ab81b5eSJustin Chadwell# Additional warnings
2989ab81b5eSJustin Chadwell# Level 1
299e7c645b5SYann GautierWARNING1 := -Wextra
300e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute
301e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes
302e7c645b5SYann GautierWARNING1 += -Wold-style-definition
303e7c645b5SYann Gautier
304b7f6525dSJustin Chadwell# Level 2
305e7c645b5SYann GautierWARNING2 := -Waggregate-return
306e7c645b5SYann GautierWARNING2 += -Wcast-align
307e7c645b5SYann GautierWARNING2 += -Wnested-externs
308e7c645b5SYann Gautier
309e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
310e7c645b5SYann GautierWARNING3 += -Wcast-qual
311e7c645b5SYann GautierWARNING3 += -Wconversion
312e7c645b5SYann GautierWARNING3 += -Wpacked
313e7c645b5SYann GautierWARNING3 += -Wpointer-arith
314e7c645b5SYann GautierWARNING3 += -Wswitch-default
315e7c645b5SYann Gautier
316e7c645b5SYann Gautierifeq (${W},1)
3179ab81b5eSJustin ChadwellWARNINGS += $(WARNING1)
318e7c645b5SYann Gautierelse ifeq (${W},2)
3199ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2)
320e7c645b5SYann Gautierelse ifeq (${W},3)
3219ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
322e7c645b5SYann Gautierendif
323e7c645b5SYann Gautier
3249ab81b5eSJustin Chadwell# Compiler specific warnings
32500296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),)
32693c690ebSJustin Chadwell# not using clang
327d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
328d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
329d7b4cd41SJustin Chadwell				-Wlogical-op
33093c690ebSJustin Chadwellelse
33193c690ebSJustin Chadwell# using clang
332d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
333d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
33400296576SAmbroise Vincentendif
33500296576SAmbroise Vincent
3366336b07aSYann Gautierifneq (${E},0)
3376336b07aSYann GautierERRORS := -Werror
3386336b07aSYann Gautierendif
3396336b07aSYann Gautier
340ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
3419ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
34259de5096SMasahiro YamadaASFLAGS			+=	$(CPPFLAGS) $(ASFLAGS_$(ARCH))			\
343d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
34459de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
345ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
346ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
347ebd6efaeSSamuel Holland				-Os -std=gnu99
34873c99d4eSJuan Castillo
3491f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
3501f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover
3511f461979SJustin Chadwellendif
3521f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
3531f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover	\
3541f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
3551f461979SJustin Chadwellendif
3561f461979SJustin Chadwell
357f7ec31dbSdavid cunadoGCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
358f7ec31dbSdavid cunado
359641f16e7SAmbroise Vincent# LD = armlink
360c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
361c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
362c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
363edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
364641f16e7SAmbroise Vincent
365641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
366edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),)
367edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches
368edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
369edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--gc-sections
370edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
371edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
372edbce9aaSzelalem-aweke		TF_LDFLAGS	+=	-flto -fuse-linker-plugin
373edbce9aaSzelalem-aweke	endif
374edbce9aaSzelalem-awekeendif
375edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
376edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
377edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1)
378edbce9aaSzelalem-aweke	TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
379edbce9aaSzelalem-awekeendif
380edbce9aaSzelalem-awekeTF_LDFLAGS		+= 	-nostdlib
381edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
382641f16e7SAmbroise Vincent
383641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
384c2ad38ceSVarun Wadekarelse
385c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--fatal-warnings -O1
386c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--gc-sections
387641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
388641f16e7SAmbroise Vincent# therefore don't add those in that case
389641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),)
390c2b8806fSDouglas RaillardTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
391edbce9aaSzelalem-awekeendif
392641f16e7SAmbroise Vincentendif
39373c99d4eSJuan Castillo
39403b397a8SNishanth MenonDTC_FLAGS		+=	-I dts -O dtb
395a6de824fSLouis MayencourtDTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
396a6de824fSLouis Mayencourt				-x assembler-with-cpp $(DEFINES)
39703b397a8SNishanth Menon
3980ab49645SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
3990ab49645SAlexei FedorovDTC_CPPFLAGS		+=	-DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE}
4000ab49645SAlexei Fedorovendif
4010ab49645SAlexei Fedorov
40273c99d4eSJuan Castillo################################################################################
40373c99d4eSJuan Castillo# Common sources and include directories
40473c99d4eSJuan Castillo################################################################################
405d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
40673c99d4eSJuan Castillo
40773c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
4087f56e9a3SSoby Mathew				common/tf_log.c				\
4099d29c227SSoby Mathew				common/${ARCH}/debug.S			\
41091b48c9fSJulius Werner				drivers/console/multi_console.c		\
4119d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
4129d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
413566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
4147f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
41575311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
4169d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
41761f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
418d7a6b0f8SRyan Harkin
4198422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang)
4208422a840SAntonio Nino DiazBL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
4218422a840SAntonio Nino Diazendif
4228422a840SAntonio Nino Diaz
4231f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4241f461979SJustin ChadwellBL_COMMON_SOURCES	+=	plat/common/ubsan.c
4251f461979SJustin Chadwellendif
4261f461979SJustin Chadwell
42701d237cbSYann GautierINCLUDES		+=	-Iinclude				\
428f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
42909d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
43009d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
43109d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
43209d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
43309d40e0eSAntonio Nino Diaz
4349c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4359c6d1c50SAntonio Nino Diaz
43673c99d4eSJuan Castillo################################################################################
43773c99d4eSJuan Castillo# Generic definitions
43873c99d4eSJuan Castillo################################################################################
43973c99d4eSJuan Castillo
440231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
441231c1470SEvan Lloyd
44273c99d4eSJuan CastilloBUILD_BASE		:=	./build
44373c99d4eSJuan CastilloBUILD_PLAT		:=	${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
44473c99d4eSJuan Castillo
445231c1470SEvan LloydSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
44673c99d4eSJuan Castillo
44773c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
44873c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
44973c99d4eSJuan Castillo
45073c99d4eSJuan Castillo
45173c99d4eSJuan Castillo################################################################################
45273c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
45373c99d4eSJuan Castillo################################################################################
45473c99d4eSJuan Castillo
45573c99d4eSJuan Castilloifneq (${SPD},none)
4569d29c227SSoby Mathew    ifeq (${ARCH},aarch32)
4579d29c227SSoby Mathew        $(error "Error: SPD is incompatible with AArch32.")
4589d29c227SSoby Mathew    endif
45928f39f02SMax Shvetsov
4604c117f6cSSandrine Bailleux    ifdef EL3_PAYLOAD_BASE
4614c117f6cSSandrine Bailleux        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
4624c117f6cSSandrine Bailleux        $(warning "The SPD and its BL32 companion will be present but ignored.")
4634c117f6cSSandrine Bailleux    endif
46428f39f02SMax Shvetsov
465c3fb00d9SAchin Gupta    ifeq (${SPD},spmd)
466033039f8SMax Shvetsov        $(warning "SPMD is an experimental feature")
467c3fb00d9SAchin Gupta        # SPMD is located in std_svc directory
468c3fb00d9SAchin Gupta        SPD_DIR := std_svc
46928f39f02SMax Shvetsov
470033039f8SMax Shvetsov        ifeq ($(SPMD_SPM_AT_SEL2),1)
47128f39f02SMax Shvetsov            ifeq ($(CTX_INCLUDE_EL2_REGS),0)
472033039f8SMax Shvetsov                $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
473033039f8SMax Shvetsov            endif
47428f39f02SMax Shvetsov        endif
475c3fb00d9SAchin Gupta    else
476c3fb00d9SAchin Gupta        # All other SPDs in spd directory
477c3fb00d9SAchin Gupta        SPD_DIR := spd
478c3fb00d9SAchin Gupta    endif
479c3fb00d9SAchin Gupta
48073c99d4eSJuan Castillo    # We expect to locate an spd.mk under the specified SPD directory
481c3fb00d9SAchin Gupta    SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
482c3fb00d9SAchin Gupta
48373c99d4eSJuan Castillo    ifeq (${SPD_MAKE},)
484c3fb00d9SAchin Gupta        $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
48573c99d4eSJuan Castillo    endif
48673c99d4eSJuan Castillo    $(info Including ${SPD_MAKE})
48773c99d4eSJuan Castillo    include ${SPD_MAKE}
48873c99d4eSJuan Castillo
48970d1fc53SJuan Castillo    # If there's BL32 companion for the chosen SPD, we expect that the SPD's
49070d1fc53SJuan Castillo    # Makefile would set NEED_BL32 to "yes". In this case, the build system
49170d1fc53SJuan Castillo    # supports two mutually exclusive options:
49270d1fc53SJuan Castillo    # * BL32 is built from source: then BL32_SOURCES must contain the list
49370d1fc53SJuan Castillo    #   of source files to build BL32
49470d1fc53SJuan Castillo    # * BL32 is a prebuilt binary: then BL32 must point to the image file
49570d1fc53SJuan Castillo    #   that will be included in the FIP
49670d1fc53SJuan Castillo    # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
49770d1fc53SJuan Castillo    # over the sources.
498e35c4045SJeenu Viswambharanendif
499e35c4045SJeenu Viswambharan
50051faada7SDouglas Raillard################################################################################
50173c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
50273c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
50373c99d4eSJuan Castillo################################################################################
5042da8d8bfSJeenu Viswambharan
50573c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
5060f21c547SJuan Castillo
5078012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
5088012cc5cSMasahiro Yamada
50926e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
51026e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
51126e63c44SEtienne Carriereendif
51226e63c44SEtienne Carriere
5133bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
5143bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
5153bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
5163bd17c0fSSoby Mathewendif
517320920c1SMasahiro Yamada
518320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),)
519320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
520320920c1SMasahiro Yamadaelse
521320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
522320920c1SMasahiro Yamadaendif
523320920c1SMasahiro Yamada
524320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
52569af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
52669af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1)
52769af7fcfSMasahiro Yamada	BL2_CFLAGS	+=	-fpie
52869af7fcfSMasahiro Yamada	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
52969af7fcfSMasahiro Yamadaendif
53069af7fcfSMasahiro Yamadaendif
531320920c1SMasahiro Yamada	BL31_CFLAGS	+=	-fpie
532320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
533d974301dSMasahiro Yamadaifeq ($(ARCH),aarch64)
534d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
535d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
536d974301dSMasahiro Yamadaendif
5373bd17c0fSSoby Mathewendif
5383bd17c0fSSoby Mathew
539d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64)
540d5e97a1dSMasahiro YamadaBL1_CFLAGS += -DIMAGE_AT_EL3
541d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
542d5e97a1dSMasahiro YamadaBL2_CFLAGS += -DIMAGE_AT_EL3
543d5e97a1dSMasahiro Yamadaelse
544d5e97a1dSMasahiro YamadaBL2_CFLAGS += -DIMAGE_AT_EL1
545d5e97a1dSMasahiro Yamadaendif
546d5e97a1dSMasahiro YamadaBL2U_CFLAGS += -DIMAGE_AT_EL1
547d5e97a1dSMasahiro YamadaBL31_CFLAGS += -DIMAGE_AT_EL3
548d5e97a1dSMasahiro YamadaBL32_CFLAGS += -DIMAGE_AT_EL1
549d5e97a1dSMasahiro Yamadaendif
550d5e97a1dSMasahiro Yamada
55154035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
55254035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
55354035fc4SSandrine Bailleux# This can be overridden by the platform.
55473c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
5554f6ad66aSAchin Gupta
556a4409008Sdp-armifeq (${ARCH},aarch32)
557a4409008Sdp-armNEED_BL32 := yes
558a4409008Sdp-arm
559a4409008Sdp-arm################################################################################
560a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
561a4409008Sdp-arm################################################################################
562a4409008Sdp-armifneq (${AARCH32_SP},none)
563a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory
564a4409008Sdp-armAARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
565a4409008Sdp-arm
566a4409008Sdp-armifeq (${AARCH32_SP_MAKE},)
567a4409008Sdp-arm  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
568a4409008Sdp-armendif
569a4409008Sdp-arm
570a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE})
571a4409008Sdp-arminclude ${AARCH32_SP_MAKE}
572a4409008Sdp-armendif
573a4409008Sdp-arm
574a4409008Sdp-armendif
5754f6ad66aSAchin Gupta
57673c99d4eSJuan Castillo################################################################################
57777f1f7a1SVarun Wadekar# Include libc if not overridden
57877f1f7a1SVarun Wadekar################################################################################
57977f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
58077f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
58177f1f7a1SVarun Wadekarendif
58277f1f7a1SVarun Wadekar
58377f1f7a1SVarun Wadekar################################################################################
584cf2c8a33SAntonio Nino Diaz# Check incompatible options
585cf2c8a33SAntonio Nino Diaz################################################################################
586cf2c8a33SAntonio Nino Diaz
587cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
58868450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
58968450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
59068450a6dSAntonio Nino Diaz                incompatible build options. EL3_PAYLOAD_BASE has priority.")
591cf2c8a33SAntonio Nino Diaz        endif
59276580f3dSQixiang Xu        ifneq (${GENERATE_COT},0)
59376580f3dSQixiang Xu                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
59476580f3dSQixiang Xu        endif
59576580f3dSQixiang Xu        ifneq (${TRUSTED_BOARD_BOOT},0)
59676580f3dSQixiang Xu                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
59776580f3dSQixiang Xu        endif
598cf2c8a33SAntonio Nino Diazendif
599cf2c8a33SAntonio Nino Diaz
600cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
601cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
602cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
603cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
604cf2c8a33SAntonio Nino Diaz        endif
60568450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
60668450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
60768450a6dSAntonio Nino Diaz                PRELOADED_BL33_BASE is used and won't be added to the FIP \
60868450a6dSAntonio Nino Diaz                file.")
609cf2c8a33SAntonio Nino Diaz        endif
610cf2c8a33SAntonio Nino Diazendif
611cf2c8a33SAntonio Nino Diaz
612d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
613d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
614d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
615d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
616d4593e47SJeenu Viswambharanendif
6171a0a3f06SYatharth Kochar
6187d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
6197d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
6207d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
6217d173fc5SJiafei Panendif
6227d173fc5SJiafei Pan
62314c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first
62414c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
62514c6016aSJeenu Viswambharan    ifneq ($(HANDLE_EA_EL3_FIRST),1)
62614c6016aSJeenu Viswambharan        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1)
62714c6016aSJeenu Viswambharan    endif
62814c6016aSJeenu Viswambharanendif
62914c6016aSJeenu Viswambharan
6301a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
6311a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
6321a7c1cfeSJeenu Viswambharan    ifneq ($(RAS_EXTENSION),1)
6331a7c1cfeSJeenu Viswambharan        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
6341a7c1cfeSJeenu Viswambharan    endif
6351a7c1cfeSJeenu Viswambharanendif
6361a7c1cfeSJeenu Viswambharan
637ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
638209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
639209a60ccSSoby Mathew    ifeq (${TRUSTED_BOARD_BOOT}, 0)
640209a60ccSSoby Mathew        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
641209a60ccSSoby Mathew    endif
642209a60ccSSoby Mathewendif
643209a60ccSSoby Mathew
644b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
6459fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
6469fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
647b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
6489fc59639SAlexei Fedorov    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
6499fc59639SAlexei Fedorov        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
65006715f85SAlexei Fedorov    endif
6519fc59639SAlexei Fedorovendif
6529fc59639SAlexei Fedorov
65306715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
6549fc59639SAlexei Fedorov    ifneq (${ARCH},aarch64)
6559fc59639SAlexei Fedorov        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
656dfc66a17SJohn Tsichritzis    else
65706715f85SAlexei Fedorov        $(info CTX_INCLUDE_PAUTH_REGS is an experimental feature)
658b86048c4SAntonio Nino Diaz    endif
659b86048c4SAntonio Nino Diazendif
6609fc59639SAlexei Fedorov
6619fc59639SAlexei Fedorovifeq ($(ENABLE_PAUTH),1)
6629fc59639SAlexei Fedorov    $(info Pointer Authentication is an experimental feature)
6639fc59639SAlexei Fedorovendif
6649fc59639SAlexei Fedorov
6659fc59639SAlexei Fedorovifeq ($(ENABLE_BTI),1)
6669fc59639SAlexei Fedorov    $(info Branch Protection is an experimental feature)
667dfc66a17SJohn Tsichritzisendif
668b86048c4SAntonio Nino Diaz
6699dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1)
6709dd94382SJustin Chadwell    ifneq (${ARCH},aarch64)
6719dd94382SJustin Chadwell        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
6729dd94382SJustin Chadwell    else
6739dd94382SJustin Chadwell        $(info CTX_INCLUDE_MTE_REGS is an experimental feature)
6749dd94382SJustin Chadwell    endif
6759dd94382SJustin Chadwellendif
6769dd94382SJustin Chadwell
6778c105290SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
6788c105290SAlexei Fedorov    ifneq (${TRUSTED_BOARD_BOOT},1)
6797cda17bbSSumit Garg        $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1)
6808c105290SAlexei Fedorov    else
6818c105290SAlexei Fedorov        $(info MEASURED_BOOT is an experimental feature)
6828c105290SAlexei Fedorov    endif
6838c105290SAlexei Fedorovendif
6848c105290SAlexei Fedorov
68560e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
68660e8f3cfSPetre-Ionut Tudor    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
68760e8f3cfSPetre-Ionut Tudor        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
68860e8f3cfSPetre-Ionut Tudor    endif
68960e8f3cfSPetre-Ionut Tudorendif
69060e8f3cfSPetre-Ionut Tudor
6917cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
6927cda17bbSSumit Garg    ifeq (${TRUSTED_BOARD_BOOT}, 0)
6937cda17bbSSumit Garg        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
6947cda17bbSSumit Garg    else
6957cda17bbSSumit Garg        $(info DECRYPTION_SUPPORT is an experimental feature)
6967cda17bbSSumit Garg    endif
6977cda17bbSSumit Gargendif
6987cda17bbSSumit Garg
699cf2c8a33SAntonio Nino Diaz################################################################################
70073c99d4eSJuan Castillo# Process platform overrideable behaviour
70173c99d4eSJuan Castillo################################################################################
7024f6ad66aSAchin Gupta
703bd97f83aSJohn Tsichritzis# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
704bd97f83aSJohn Tsichritzis# Certificate generation tools. This flag can be overridden by the platform.
70573c99d4eSJuan Castilloifdef BL2_SOURCES
706cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
707cf2c8a33SAntonio Nino Diaz                # If booting an EL3 payload there is no need for a BL33 image
708cf2c8a33SAntonio Nino Diaz                # in the FIP file.
7094c117f6cSSandrine Bailleux                NEED_BL33		:=	no
710cf2c8a33SAntonio Nino Diaz        else
71168450a6dSAntonio Nino Diaz                ifdef PRELOADED_BL33_BASE
712cf2c8a33SAntonio Nino Diaz                        # If booting a BL33 preloaded image there is no need of
713cf2c8a33SAntonio Nino Diaz                        # another one in the FIP file.
714cf2c8a33SAntonio Nino Diaz                        NEED_BL33		:=	no
715cf2c8a33SAntonio Nino Diaz                else
716cf2c8a33SAntonio Nino Diaz                        NEED_BL33		?=	yes
717cf2c8a33SAntonio Nino Diaz                endif
7184c117f6cSSandrine Bailleux        endif
71973c99d4eSJuan Castilloendif
7206f971622SJuan Castillo
7214d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
7224d045d0eSMasahiro Yamadaifdef SCP_BL2
7234d045d0eSMasahiro Yamada        NEED_SCP_BL2		:=	yes
7244d045d0eSMasahiro Yamadaendif
7254d045d0eSMasahiro Yamada
7265744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
7275744e874SSoby Mathewifneq (${ARCH},aarch32)
7285744e874SSoby Mathew    ifdef BL31_SOURCES
7295744e874SSoby Mathew        # When booting an EL3 payload, there is no need to compile the BL31 image nor
7305744e874SSoby Mathew        # put it in the FIP.
7315744e874SSoby Mathew        ifndef EL3_PAYLOAD_BASE
7325744e874SSoby Mathew            NEED_BL31 := yes
7335744e874SSoby Mathew        endif
7345744e874SSoby Mathew    endif
7355744e874SSoby Mathewendif
7365744e874SSoby Mathew
73773c99d4eSJuan Castillo# Process TBB related flags
7386f971622SJuan Castilloifneq (${GENERATE_COT},0)
73973c99d4eSJuan Castillo        # Common cert_create options
7406f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
7416f971622SJuan Castillo                $(eval CRT_ARGS += -n)
7420191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
743fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
744fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
7450191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
746fd34e7baSJuan Castillo                endif
7476f971622SJuan Castillo        endif
74873c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
74973c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
75073c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
75173c99d4eSJuan Castillo        endif
7526f971622SJuan Castilloendif
7536f971622SJuan Castillo
7541c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
7551c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN}
7561c75d5dfSMasahiro Yamadaendif
7571c75d5dfSMasahiro Yamada
75873c99d4eSJuan Castillo################################################################################
75946e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
76046e5e035SMichalis Pappas################################################################################
76146e5e035SMichalis Pappas
76246e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
76346e5e035SMichalis Pappas
76446e5e035SMichalis Pappas################################################################################
765819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc)
76673c99d4eSJuan Castillo################################################################################
76773c99d4eSJuan Castillo
76873c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
76973c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
77042a45b51SEvan LloydCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
77173c99d4eSJuan Castillo
77290aa901fSSumit Garg# Variables for use with Firmware Encryption Tool
77390aa901fSSumit GargENCTOOLPATH		?=	tools/encrypt_fw
77490aa901fSSumit GargENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
77590aa901fSSumit Garg
77673c99d4eSJuan Castillo# Variables for use with Firmware Image Package
777819281eeSdp-armFIPTOOLPATH		?=	tools/fiptool
778819281eeSdp-armFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
77973c99d4eSJuan Castillo
78026010da1SAntonio Nino Diaz# Variables for use with sptool
78126010da1SAntonio Nino DiazSPTOOLPATH		?=	tools/sptool
78226010da1SAntonio Nino DiazSPTOOL			?=	${SPTOOLPATH}/sptool${BIN_EXT}
783ce2b1ec6SManish PandeySP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
78426010da1SAntonio Nino Diaz
7855accce5bSRoberto Vargas# Variables for use with ROMLIB
7865accce5bSRoberto VargasROMLIBPATH		?=	lib/romlib
7875accce5bSRoberto Vargas
788cfe83910SLouis Mayencourt# Variable for use with Python
789cfe83910SLouis MayencourtPYTHON			?=	python3
790cfe83910SLouis Mayencourt
791cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP
792cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH		?=	tools/memory
793cfe83910SLouis MayencourtPRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
794cfe83910SLouis Mayencourt
7956de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool
7966de32378SMadhukar PappireddyDOCS_PATH		?=	docs
7976de32378SMadhukar Pappireddy
7988a86052dSSoby Mathew################################################################################
7998a86052dSSoby Mathew# Include BL specific makefiles
8008a86052dSSoby Mathew################################################################################
8018a86052dSSoby Mathewifdef BL1_SOURCES
8028a86052dSSoby MathewNEED_BL1 := yes
8038a86052dSSoby Mathewinclude bl1/bl1.mk
8048a86052dSSoby Mathewendif
8058a86052dSSoby Mathew
8068a86052dSSoby Mathewifdef BL2_SOURCES
8078a86052dSSoby MathewNEED_BL2 := yes
8088a86052dSSoby Mathewinclude bl2/bl2.mk
8098a86052dSSoby Mathewendif
8108a86052dSSoby Mathew
8118a86052dSSoby Mathewifdef BL2U_SOURCES
8128a86052dSSoby MathewNEED_BL2U := yes
8138a86052dSSoby Mathewinclude bl2u/bl2u.mk
8148a86052dSSoby Mathewendif
8158a86052dSSoby Mathew
8165744e874SSoby Mathewifeq (${NEED_BL31},yes)
8178a86052dSSoby Mathewifdef BL31_SOURCES
8188a86052dSSoby Mathewinclude bl31/bl31.mk
8198a86052dSSoby Mathewendif
8208a86052dSSoby Mathewendif
8218a86052dSSoby Mathew
82203b397a8SNishanth Menonifdef FDT_SOURCES
82303b397a8SNishanth MenonNEED_FDT := yes
82403b397a8SNishanth Menonendif
82503b397a8SNishanth Menon
82673c99d4eSJuan Castillo################################################################################
82773c99d4eSJuan Castillo# Build options checks
82873c99d4eSJuan Castillo################################################################################
82973c99d4eSJuan Castillo
83060e8f3cfSPetre-Ionut Tudor$(eval $(call assert_boolean,ALLOW_RO_XLAT_TABLES))
831a9bec67dSSandrine Bailleux$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU))
8322fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,CREATE_KEYS))
8332fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS))
8342fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
8355283962eSAntonio Nino Diaz$(eval $(call assert_boolean,CTX_INCLUDE_PAUTH_REGS))
8369dd94382SJustin Chadwell$(eval $(call assert_boolean,CTX_INCLUDE_MTE_REGS))
83728f39f02SMax Shvetsov$(eval $(call assert_boolean,CTX_INCLUDE_EL2_REGS))
8382fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,DEBUG))
839209a60ccSSoby Mathew$(eval $(call assert_boolean,DYN_DISABLE_AUTH))
840c8b55b8fSJeenu Viswambharan$(eval $(call assert_boolean,EL3_EXCEPTION_HANDLING))
8410319a977SDimitris Papastamos$(eval $(call assert_boolean,ENABLE_AMU))
842cc8b5632SAntonio Nino Diaz$(eval $(call assert_boolean,ENABLE_ASSERTIONS))
8435f835918SJeenu Viswambharan$(eval $(call assert_boolean,ENABLE_MPAM_FOR_LOWER_ELS))
8443bd17c0fSSoby Mathew$(eval $(call assert_boolean,ENABLE_PIE))
845a31d8983SYatharth Kochar$(eval $(call assert_boolean,ENABLE_PMF))
846170fb93dSYatharth Kochar$(eval $(call assert_boolean,ENABLE_PSCI_STAT))
847872be88aSdp-arm$(eval $(call assert_boolean,ENABLE_RUNTIME_INSTRUMENTATION))
848c1232c31SJeenu Viswambharan$(eval $(call assert_boolean,ENABLE_SPE_FOR_LOWER_ELS))
8491a853370SDavid Cunado$(eval $(call assert_boolean,ENABLE_SVE_FOR_NS))
8502fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,ERROR_DEPRECATED))
8511a7c1cfeSJeenu Viswambharan$(eval $(call assert_boolean,FAULT_INJECTION_SUPPORT))
8522fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,GENERATE_COT))
85374dce7faSJeenu Viswambharan$(eval $(call assert_boolean,GICV2_G0_FOR_EL3))
85476454abfSJeenu Viswambharan$(eval $(call assert_boolean,HANDLE_EA_EL3_FIRST))
8553c251af3SJeenu Viswambharan$(eval $(call assert_boolean,HW_ASSISTED_COHERENCY))
856b890b36dSLouis Mayencourt$(eval $(call assert_boolean,INVERTED_MEMMAP))
8578c105290SAlexei Fedorov$(eval $(call assert_boolean,MEASURED_BOOT))
8582fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,NS_TIMER_SWITCH))
85977f1f7a1SVarun Wadekar$(eval $(call assert_boolean,OVERRIDE_LIBC))
8602fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,PL011_GENERIC_UART))
8612fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS))
8622fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID))
86314c6016aSJeenu Viswambharan$(eval $(call assert_boolean,RAS_EXTENSION))
8642fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,RESET_TO_BL31))
8652fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,SAVE_KEYS))
8662fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,SEPARATE_CODE_AND_RODATA))
867f8578e64SSamuel Holland$(eval $(call assert_boolean,SEPARATE_NOBITS_REGION))
8682fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT))
8698855e52eSAntonio Nino Diaz$(eval $(call assert_boolean,SPM_MM))
870033039f8SMax Shvetsov$(eval $(call assert_boolean,SPMD_SPM_AT_SEL2))
8712fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
8722fae4b1eSJeenu Viswambharan$(eval $(call assert_boolean,USE_COHERENT_MEM))
8730ca3913dSOlivier Deprez$(eval $(call assert_boolean,USE_DEBUGFS))
874a6de824fSLouis Mayencourt$(eval $(call assert_boolean,ARM_IO_IN_DTB))
8755accce5bSRoberto Vargas$(eval $(call assert_boolean,USE_ROMLIB))
876bb41eb7aSMasahiro Yamada$(eval $(call assert_boolean,USE_TBBR_DEFS))
877bcc3c49cSSoby Mathew$(eval $(call assert_boolean,WARMBOOT_ENABLE_DCACHE_EARLY))
878b1d27b48SRoberto Vargas$(eval $(call assert_boolean,BL2_AT_EL3))
8797d173fc5SJiafei Pan$(eval $(call assert_boolean,BL2_IN_XIP_MEM))
880b90f207aSHadi Asyrafi$(eval $(call assert_boolean,BL2_INV_DCACHE))
881c97cba4eSSoby Mathew$(eval $(call assert_boolean,USE_SPINLOCK_CAS))
882c6ba9b45SSumit Garg$(eval $(call assert_boolean,ENCRYPT_BL31))
883c6ba9b45SSumit Garg$(eval $(call assert_boolean,ENCRYPT_BL32))
88473c99d4eSJuan Castillo
885c877b414SJeenu Viswambharan$(eval $(call assert_numeric,ARM_ARCH_MAJOR))
886c877b414SJeenu Viswambharan$(eval $(call assert_numeric,ARM_ARCH_MINOR))
8879fc59639SAlexei Fedorov$(eval $(call assert_numeric,BRANCH_PROTECTION))
888c6ba9b45SSumit Garg$(eval $(call assert_numeric,FW_ENC_STATUS))
889c877b414SJeenu Viswambharan
890aacff749SJustin Chadwellifdef KEY_SIZE
891aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
892aacff749SJustin Chadwellendif
893aacff749SJustin Chadwell
8941f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
8951f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
8961f461979SJustin Chadwellendif
8971f461979SJustin Chadwell
89873c99d4eSJuan Castillo################################################################################
89973c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
90073c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
90173c99d4eSJuan Castillo# platform to overwrite the default options
90273c99d4eSJuan Castillo################################################################################
90373c99d4eSJuan Castillo
90460e8f3cfSPetre-Ionut Tudor$(eval $(call add_define,ALLOW_RO_XLAT_TABLES))
905c877b414SJeenu Viswambharan$(eval $(call add_define,ARM_ARCH_MAJOR))
906c877b414SJeenu Viswambharan$(eval $(call add_define,ARM_ARCH_MINOR))
907a9bec67dSSandrine Bailleux$(eval $(call add_define,COLD_BOOT_SINGLE_CPU))
9082fae4b1eSJeenu Viswambharan$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS))
9092fae4b1eSJeenu Viswambharan$(eval $(call add_define,CTX_INCLUDE_FPREGS))
9105283962eSAntonio Nino Diaz$(eval $(call add_define,CTX_INCLUDE_PAUTH_REGS))
911c8b55b8fSJeenu Viswambharan$(eval $(call add_define,EL3_EXCEPTION_HANDLING))
9129dd94382SJustin Chadwell$(eval $(call add_define,CTX_INCLUDE_MTE_REGS))
91328f39f02SMax Shvetsov$(eval $(call add_define,CTX_INCLUDE_EL2_REGS))
9147cda17bbSSumit Garg$(eval $(call add_define,DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT}))
9150319a977SDimitris Papastamos$(eval $(call add_define,ENABLE_AMU))
916cc8b5632SAntonio Nino Diaz$(eval $(call add_define,ENABLE_ASSERTIONS))
9179fc59639SAlexei Fedorov$(eval $(call add_define,ENABLE_BTI))
9185f835918SJeenu Viswambharan$(eval $(call add_define,ENABLE_MPAM_FOR_LOWER_ELS))
919b86048c4SAntonio Nino Diaz$(eval $(call add_define,ENABLE_PAUTH))
9203bd17c0fSSoby Mathew$(eval $(call add_define,ENABLE_PIE))
921a31d8983SYatharth Kochar$(eval $(call add_define,ENABLE_PMF))
922170fb93dSYatharth Kochar$(eval $(call add_define,ENABLE_PSCI_STAT))
923872be88aSdp-arm$(eval $(call add_define,ENABLE_RUNTIME_INSTRUMENTATION))
924c1232c31SJeenu Viswambharan$(eval $(call add_define,ENABLE_SPE_FOR_LOWER_ELS))
9251a853370SDavid Cunado$(eval $(call add_define,ENABLE_SVE_FOR_NS))
926c6ba9b45SSumit Garg$(eval $(call add_define,ENCRYPT_BL31))
927c6ba9b45SSumit Garg$(eval $(call add_define,ENCRYPT_BL32))
9282fae4b1eSJeenu Viswambharan$(eval $(call add_define,ERROR_DEPRECATED))
9291a7c1cfeSJeenu Viswambharan$(eval $(call add_define,FAULT_INJECTION_SUPPORT))
93074dce7faSJeenu Viswambharan$(eval $(call add_define,GICV2_G0_FOR_EL3))
93176454abfSJeenu Viswambharan$(eval $(call add_define,HANDLE_EA_EL3_FIRST))
9323c251af3SJeenu Viswambharan$(eval $(call add_define,HW_ASSISTED_COHERENCY))
9332fae4b1eSJeenu Viswambharan$(eval $(call add_define,LOG_LEVEL))
9348c105290SAlexei Fedorov$(eval $(call add_define,MEASURED_BOOT))
9352fae4b1eSJeenu Viswambharan$(eval $(call add_define,NS_TIMER_SWITCH))
9362fae4b1eSJeenu Viswambharan$(eval $(call add_define,PL011_GENERIC_UART))
9372fae4b1eSJeenu Viswambharan$(eval $(call add_define,PLAT_${PLAT}))
9382fae4b1eSJeenu Viswambharan$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS))
9392fae4b1eSJeenu Viswambharan$(eval $(call add_define,PSCI_EXTENDED_STATE_ID))
94014c6016aSJeenu Viswambharan$(eval $(call add_define,RAS_EXTENSION))
9412fae4b1eSJeenu Viswambharan$(eval $(call add_define,RESET_TO_BL31))
9422fae4b1eSJeenu Viswambharan$(eval $(call add_define,SEPARATE_CODE_AND_RODATA))
943f8578e64SSamuel Holland$(eval $(call add_define,SEPARATE_NOBITS_REGION))
9441dcc28cfSDaniel Boulby$(eval $(call add_define,RECLAIM_INIT_CODE))
9452fae4b1eSJeenu Viswambharan$(eval $(call add_define,SPD_${SPD}))
9462fae4b1eSJeenu Viswambharan$(eval $(call add_define,SPIN_ON_BL1_EXIT))
9478855e52eSAntonio Nino Diaz$(eval $(call add_define,SPM_MM))
948033039f8SMax Shvetsov$(eval $(call add_define,SPMD_SPM_AT_SEL2))
9492fae4b1eSJeenu Viswambharan$(eval $(call add_define,TRUSTED_BOARD_BOOT))
9502fae4b1eSJeenu Viswambharan$(eval $(call add_define,USE_COHERENT_MEM))
9510ca3913dSOlivier Deprez$(eval $(call add_define,USE_DEBUGFS))
952a6de824fSLouis Mayencourt$(eval $(call add_define,ARM_IO_IN_DTB))
9535accce5bSRoberto Vargas$(eval $(call add_define,USE_ROMLIB))
954bb41eb7aSMasahiro Yamada$(eval $(call add_define,USE_TBBR_DEFS))
955bcc3c49cSSoby Mathew$(eval $(call add_define,WARMBOOT_ENABLE_DCACHE_EARLY))
956b1d27b48SRoberto Vargas$(eval $(call add_define,BL2_AT_EL3))
9577d173fc5SJiafei Pan$(eval $(call add_define,BL2_IN_XIP_MEM))
958b90f207aSHadi Asyrafi$(eval $(call add_define,BL2_INV_DCACHE))
959c97cba4eSSoby Mathew$(eval $(call add_define,USE_SPINLOCK_CAS))
9602fae4b1eSJeenu Viswambharan
9611f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
9621f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
9631f461979SJustin Chadwellendif
9641f461979SJustin Chadwell
9654c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
9664c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
9674c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
968cf2c8a33SAntonio Nino Diazelse
96968450a6dSAntonio Nino Diaz        # Define the PRELOADED_BL33_BASE flag only if it is provided and
97068450a6dSAntonio Nino Diaz        # EL3_PAYLOAD_BASE is not defined, as it has priority.
97168450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
97268450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
9734c117f6cSSandrine Bailleux        endif
974cf2c8a33SAntonio Nino Diazendif
97573c99d4eSJuan Castillo
976209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
977209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
978209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH))
979209a60ccSSoby Mathewendif
980209a60ccSSoby Mathew
981c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
982c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK))
983c2ad38ceSVarun Wadekarendif
984c2ad38ceSVarun Wadekar
985ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
986ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
987c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
988c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},0)
989c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL1 does not require SP_LAYOUT_FILE")
990c33ff198SOlivier Deprez        endif
991ce2b1ec6SManish Pandey        -include $(BUILD_PLAT)/sp_gen.mk
992ce2b1ec6SManish Pandey        FIP_DEPS += sp
993ce2b1ec6SManish Pandey        NEED_SP_PKG := yes
994ce2b1ec6SManish Pandeyelse
995c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},1)
996c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
997c33ff198SOlivier Deprez        endif
998ce2b1ec6SManish Pandeyendif
999ce2b1ec6SManish Pandeyendif
1000ce2b1ec6SManish Pandey
100173c99d4eSJuan Castillo################################################################################
100273c99d4eSJuan Castillo# Build targets
100373c99d4eSJuan Castillo################################################################################
100473c99d4eSJuan Castillo
100590aa901fSSumit Garg.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
100673c99d4eSJuan Castillo.SUFFIXES:
100773c99d4eSJuan Castillo
100873c99d4eSJuan Castilloall: msg_start
100973c99d4eSJuan Castillo
101073c99d4eSJuan Castillomsg_start:
101173c99d4eSJuan Castillo	@echo "Building ${PLAT}"
101273c99d4eSJuan Castillo
10137a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1014d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
1015c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),)
1016c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1017c2ad38ceSVarun Wadekarelse
1018bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
10197a24cba5SSoby Mathewendif
1020d5dfdeb6SJulius Werner# __ASSEMBLY__ is deprecated in favor of the compiler-builtin __ASSEMBLER__.
1021d5dfdeb6SJulius WernerASFLAGS	+= -D__ASSEMBLY__
1022402b3cf8SJulius Werner# AARCH32/AARCH64 macros are deprecated in favor of the compiler-builtin __aarch64__.
1023402b3cf8SJulius Wernerifeq (${ARCH},aarch32)
1024402b3cf8SJulius Werner        $(eval $(call add_define,AARCH32))
1025402b3cf8SJulius Wernerelse
1026402b3cf8SJulius Werner        $(eval $(call add_define,AARCH64))
1027402b3cf8SJulius Wernerendif
1028d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED
10297a24cba5SSoby Mathew
10305accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS))
103161f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
10325fee0287SRoberto Vargas
103373c99d4eSJuan Castillo# Expand build macros for the different images
103473c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
103573c99d4eSJuan Castillo$(eval $(call MAKE_BL,1))
103673c99d4eSJuan Castilloendif
103773c99d4eSJuan Castillo
103873c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1039c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0)
1040c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1041c9b31ae8SRoberto Vargasendif
1042c9b31ae8SRoberto Vargas
104333950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1044c9b31ae8SRoberto Vargas	$(eval $(call MAKE_BL,2,${FIP_BL2_ARGS})))
104573c99d4eSJuan Castilloendif
104673c99d4eSJuan Castillo
10474d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
104833950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
10494d045d0eSMasahiro Yamadaendif
10504d045d0eSMasahiro Yamada
105173c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
105273c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
105326d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
105426d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1055c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1056c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1057c6ba9b45SSumit Garg	$(eval $(call MAKE_BL,31,soc-fw,,$(ENCRYPT_BL31))))
1058c6ba9b45SSumit Gargelse
105933950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
10608f0617efSJuan Castillo	$(eval $(call MAKE_BL,31,soc-fw)))
106173c99d4eSJuan Castilloendif
1062c6ba9b45SSumit Gargendif
106373c99d4eSJuan Castillo
106470d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1065c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
106670d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
106773c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
106826d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
106926d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
10709cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
10719cd15239SMasahiro Yamada
1072c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1073c6ba9b45SSumit Garg$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw,,$(ENCRYPT_BL32))),\
1074c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1075c6ba9b45SSumit Gargelse
10769cd15239SMasahiro Yamada$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\
107733950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
107873c99d4eSJuan Castilloendif
1079c6ba9b45SSumit Gargendif
108073c99d4eSJuan Castillo
108173c99d4eSJuan Castillo# Add the BL33 image if required by the platform
108273c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
108333950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1084db6071c9SJuan Castilloendif
1085db6071c9SJuan Castillo
10869003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
108733950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
10881dc0714fSMasahiro Yamada	$(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_)))
10899003fa0bSYatharth Kocharendif
10909003fa0bSYatharth Kochar
109103b397a8SNishanth Menon# Expand build macros for the different images
109203b397a8SNishanth Menonifeq (${NEED_FDT},yes)
109303b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
109403b397a8SNishanth Menonendif
109503b397a8SNishanth Menon
1096ce2b1ec6SManish Pandey# Add Secure Partition packages
1097ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1098ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1099ce2b1ec6SManish Pandey	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT)
1100ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk
1101ce2b1ec6SManish Pandey	${Q}$(SPTOOL) $(SPTOOL_ARGS)
1102ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1103ce2b1ec6SManish Pandey	@echo "Built SP Images successfully"
1104ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1105ce2b1ec6SManish Pandeyendif
1106ce2b1ec6SManish Pandey
110736eaaf37SIan Spraylocate-checkpatch:
110836eaaf37SIan Sprayifndef CHECKPATCH
110966079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
111036eaaf37SIan Sprayelse
111136eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
111266079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
111336eaaf37SIan Sprayendif
111436eaaf37SIan Sprayendif
111536eaaf37SIan Spray
11164f6ad66aSAchin Guptaclean:
11174f6ad66aSAchin Gupta	@echo "  CLEAN"
1118f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
11192f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
11206f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
112190aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
11225accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11234f6ad66aSAchin Gupta
1124eaaeece2SJames Morrisseyrealclean distclean:
1125eaaeece2SJames Morrissey	@echo "  REALCLEAN"
1126f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1127f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
11282f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
112926010da1SAntonio Nino Diaz	${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean
11306f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
113190aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
11325accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11334f6ad66aSAchin Gupta
113436eaaf37SIan Spraycheckcodebase:		locate-checkpatch
113536eaaf37SIan Spray	@echo "  CHECKING STYLE"
113636eaaf37SIan Spray	@if test -d .git ; then						\
11371ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
11381a41e8c1SDan Handley		while read GIT_FILE ;					\
11391a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
11401a41e8c1SDan Handley		done ;							\
114136eaaf37SIan Spray	else								\
11421a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
11431a41e8c1SDan Handley		 -not -iwholename "*build*"				\
11441a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
114561f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
11461a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
11471ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
11481a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
114936eaaf37SIan Spray	fi
115036eaaf37SIan Spray
115136eaaf37SIan Spraycheckpatch:		locate-checkpatch
115236eaaf37SIan Spray	@echo "  CHECKING STYLE"
115302a76d5fSYann Gautier	@if test -n "${CHECKPATCH_OPTS}"; then				\
115402a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
115502a76d5fSYann Gautier	fi
115651d28937SAntonio Nino Diaz	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
115751d28937SAntonio Nino Diaz	for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do		\
115851d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
115951d28937SAntonio Nino Diaz		git log --format=email "$$commit~..$$commit"		\
116002a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
116102a76d5fSYann Gautier			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
116251d28937SAntonio Nino Diaz		git diff --format=email "$$commit~..$$commit"		\
116302a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
116402a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
116551d28937SAntonio Nino Diaz	done
116636eaaf37SIan Spray
116773c99d4eSJuan Castillocerttool: ${CRTTOOL}
116873c99d4eSJuan Castillo
11696f971622SJuan Castillo.PHONY: ${CRTTOOL}
11706f971622SJuan Castillo${CRTTOOL}:
11713bff910dSSandrine Bailleux	${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} --no-print-directory -C ${CRTTOOLPATH}
1172f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
11736f971622SJuan Castillo	@echo "Built $@ successfully"
1174f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
11756f971622SJuan Castillo
11766f971622SJuan Castilloifneq (${GENERATE_COT},0)
117773c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
11786f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
1179f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
11806f971622SJuan Castillo	@echo "Built $@ successfully"
11816f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
1182f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
118373c99d4eSJuan Castilloendif
118427713fb4SSoby Mathew
118573c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
1186819281eeSdp-arm	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1187819281eeSdp-arm	${Q}${FIPTOOL} info $@
1188f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
11892f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
1190f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1191f58ad36fSHarry Liebel
11920191262dSYatharth Kocharifneq (${GENERATE_COT},0)
11930191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
11940191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1195052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
11960191262dSYatharth Kochar	@echo "Built $@ successfully"
11970191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1198052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
11990191262dSYatharth Kocharendif
12000191262dSYatharth Kochar
12010191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
1202819281eeSdp-arm	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1203819281eeSdp-arm	${Q}${FIPTOOL} info $@
1204052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12050191262dSYatharth Kochar	@echo "Built $@ successfully"
1206052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12070191262dSYatharth Kochar
120873c99d4eSJuan Castillofiptool: ${FIPTOOL}
120973c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
12100191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
121173c99d4eSJuan Castillo
121273c99d4eSJuan Castillo.PHONY: ${FIPTOOL}
121373c99d4eSJuan Castillo${FIPTOOL}:
1214819281eeSdp-arm	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${FIPTOOLPATH}
1215f58ad36fSHarry Liebel
121626010da1SAntonio Nino Diazsptool: ${SPTOOL}
121726010da1SAntonio Nino Diaz.PHONY: ${SPTOOL}
121826010da1SAntonio Nino Diaz${SPTOOL}:
121926010da1SAntonio Nino Diaz	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${SPTOOLPATH}
122026010da1SAntonio Nino Diaz
12215accce5bSRoberto Vargas.PHONY: libraries
12225accce5bSRoberto Vargasromlib.bin: libraries
1223bbb24f61SJohn 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
12245accce5bSRoberto Vargas
1225cfe83910SLouis Mayencourt# Call print_memory_map tool
1226cfe83910SLouis Mayencourtmemmap: all
1227b890b36dSLouis Mayencourt	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1228cfe83910SLouis Mayencourt
12296de32378SMadhukar Pappireddydoc:
12306de32378SMadhukar Pappireddy	@echo "  BUILD DOCUMENTATION"
12316de32378SMadhukar Pappireddy	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
12326de32378SMadhukar Pappireddy
123390aa901fSSumit Gargenctool: ${ENCTOOL}
123490aa901fSSumit Garg
123590aa901fSSumit Garg.PHONY: ${ENCTOOL}
123690aa901fSSumit Garg${ENCTOOL}:
123790aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 --no-print-directory -C ${ENCTOOLPATH}
123890aa901fSSumit Garg	@${ECHO_BLANK_LINE}
123990aa901fSSumit Garg	@echo "Built $@ successfully"
124090aa901fSSumit Garg	@${ECHO_BLANK_LINE}
124190aa901fSSumit Garg
124235fab8c9SJoakim Bechcscope:
124335fab8c9SJoakim Bech	@echo "  CSCOPE"
124435fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
124535fab8c9SJoakim Bech	${Q}cscope -b -q -k
124635fab8c9SJoakim Bech
124772ee3314SRyan Harkinhelp:
12487c23126cSJohn Tsichritzis	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
124972ee3314SRyan Harkin	@echo ""
125072ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
125108c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
125272ee3314SRyan Harkin	@echo ""
12537c23126cSJohn Tsichritzis	@echo "platform = ${PLATFORM_LIST}"
12547c23126cSJohn Tsichritzis	@echo ""
12551b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
12561b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
12571b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
12581b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
12591b578596SSandrine Bailleux	@echo ""
126072ee3314SRyan Harkin	@echo "Supported Targets:"
12611b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
126236eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
12638aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
12649003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
1265d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
12669d29c227SSoby Mathew	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
12679d29c227SSoby Mathew	@echo "                 this builds secure payload specified by AARCH32_SP"
126873c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
12691b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
12700191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
127136eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
127236eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
127336eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
127472ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
127535fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
127672ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
12776f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
127890aa901fSSumit Garg	@echo "  enctool        Build the Firmware encryption tool"
1279f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1280ce2b1ec6SManish Pandey	@echo "  sp             Build the Secure Partition Packages"
128126010da1SAntonio Nino Diaz	@echo "  sptool         Build the Secure Partition Package creation tool"
128238c14d88SSoby Mathew	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1283cfe83910SLouis Mayencourt	@echo "  memmap         Print the memory map of the built binaries"
12846de32378SMadhukar Pappireddy	@echo "  doc            Build html based documentation using Sphinx tool"
128572ee3314SRyan Harkin	@echo ""
12861b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
128772ee3314SRyan Harkin	@echo ""
128872ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
128972ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1290