xref: /rk3399_ARM-atf/Makefile (revision 5edddf3a0fd8d5d1775552081bcf18b311e5f4d3)
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
11*5edddf3aSManish 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
188fa6f774bSAlexei Fedorov# Set the compiler's target architecture profile based on ARM_ARCH_MINOR option
189fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0)
190da547d4bSSandrine Bailleuxmarch32-directive	= 	-march=armv8-a
191fa6f774bSAlexei Fedorovmarch64-directive	= 	-march=armv8-a
192fa6f774bSAlexei Fedorovelse
193fa6f774bSAlexei Fedorovmarch32-directive	= 	-march=armv8.${ARM_ARCH_MINOR}-a
194fa6f774bSAlexei Fedorovmarch64-directive	= 	-march=armv8.${ARM_ARCH_MINOR}-a
195fa6f774bSAlexei Fedorovendif
19626e63c44SEtienne Carriereendif
19726e63c44SEtienne Carriere
1987ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
1997ff088d1SManish V Badarkheifeq ($(ARCH), aarch64)
2004a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5
2014a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
2027ff088d1SManish V Badarkhemem_tag_arch_support	= 	yes
2037ff088d1SManish V Badarkheendif
2047ff088d1SManish V Badarkheendif
2057ff088d1SManish V Badarkhe
2067ff088d1SManish V Badarkhe# Enabled required option for memory stack tagging. Currently, these options are
2077ff088d1SManish V Badarkhe# enabled only for clang and armclang compiler.
2087ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes)
2097ff088d1SManish V Badarkheifdef mem_tag_arch_support
2107ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang))
2117ff088d1SManish V Badarkhemarch64-directive       =       -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a+memtag
2127ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang)
2137ff088d1SManish V BadarkheTF_CFLAGS		+=	-mmemtag-stack
2147ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang)
2157ff088d1SManish V BadarkheTF_CFLAGS		+=	-fsanitize=memtag
2167ff088d1SManish V Badarkheendif
2177ff088d1SManish V Badarkheendif
2187ff088d1SManish V Badarkheelse
2197ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \
2207ff088d1SManish V Badarkhe	${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
2217ff088d1SManish V Badarkheendif
2227ff088d1SManish V Badarkheendif
2237ff088d1SManish V Badarkhe
224fd18a8fcSVarun Wadekarifneq ($(findstring armclang,$(notdir $(CC))),)
22526e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	-target arm-arm-none-eabi $(march32-directive)
226fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-arm-none-eabi $(march64-directive)
2272adee763SRoberto VargasLD			=	$(LINKER)
2281684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2297040155eSRoberto VargasCPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2307040155eSRoberto VargasPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2317559633bSdp-armelse ifneq ($(findstring clang,$(notdir $(CC))),)
232eff737c1SArve HjønnevågCLANG_CCDIR		=	$(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),)
233e2bfec0bSYann GautierTF_CFLAGS_aarch32	=	$(target32-directive) $(march32-directive)
234fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-elf $(march64-directive)
235eff737c1SArve HjønnevågLD			=	$(CLANG_CCDIR)ld.lld
236641f16e7SAmbroise Vincentifeq (, $(shell which $(LD)))
237641f16e7SAmbroise Vincent$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker")
238641f16e7SAmbroise Vincentendif
2391684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2407040155eSRoberto VargasCPP			=	$(CC) -E
2417040155eSRoberto VargasPP			=	$(CC) -E
242edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),)
243edbce9aaSzelalem-awekeTF_CFLAGS_aarch32	=	$(march32-directive)
244edbce9aaSzelalem-awekeTF_CFLAGS_aarch64	=	$(march64-directive)
245edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
246edbce9aaSzelalem-aweke	# Enable LTO only for aarch64
247edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
248edbce9aaSzelalem-aweke		LTO_CFLAGS	=	-flto
249edbce9aaSzelalem-aweke		# Use gcc as a wrapper for the ld, recommended for LTO
250edbce9aaSzelalem-aweke		LINKER		:=	${CROSS_COMPILE}gcc
251edbce9aaSzelalem-aweke	endif
252edbce9aaSzelalem-awekeendif
253edbce9aaSzelalem-awekeLD			=	$(LINKER)
254d5461857Sdp-armelse
25526e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	$(march32-directive)
256fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	$(march64-directive)
2572adee763SRoberto VargasLD			=	$(LINKER)
258d5461857Sdp-armendif
259d5461857Sdp-arm
26032b209bfSAhmad Fatoum# Process Debug flag
26132b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
26232b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
26332b209bfSAhmad Fatoum        BUILD_TYPE	:=	debug
26432b209bfSAhmad Fatoum        TF_CFLAGS	+= 	-g
26532b209bfSAhmad Fatoum
26632b209bfSAhmad Fatoum        ifneq ($(findstring clang,$(notdir $(CC))),)
26732b209bfSAhmad Fatoum             ASFLAGS		+= 	-g
26832b209bfSAhmad Fatoum        else
26932b209bfSAhmad Fatoum             ASFLAGS		+= 	-g -Wa,--gdwarf-2
27032b209bfSAhmad Fatoum        endif
27132b209bfSAhmad Fatoum
27232b209bfSAhmad Fatoum        # Use LOG_LEVEL_INFO by default for debug builds
27332b209bfSAhmad Fatoum        LOG_LEVEL	:=	40
27432b209bfSAhmad Fatoumelse
27532b209bfSAhmad Fatoum        BUILD_TYPE	:=	release
27632b209bfSAhmad Fatoum        # Use LOG_LEVEL_NOTICE by default for release builds
27732b209bfSAhmad Fatoum        LOG_LEVEL	:=	20
27832b209bfSAhmad Fatoumendif
27932b209bfSAhmad Fatoum
280f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
281f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
282f1de4c8fSPeiyuan Song        BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
283f1de4c8fSPeiyuan Songendif
284f1de4c8fSPeiyuan SongVERSION_STRING    :=  v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
285f1de4c8fSPeiyuan Song
2868fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
2878fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-marm
2888fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
2898fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-mthumb
2908fd9d4d5SAntonio Nino Diazelse
2918fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
2928fd9d4d5SAntonio Nino Diazendif
2938fd9d4d5SAntonio Nino Diaz
294a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
295d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
2969d29c227SSoby Mathew
2979fc59639SAlexei Fedorovifneq (${BP_OPTION},none)
2989fc59639SAlexei FedorovTF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
2999fc59639SAlexei Fedorovendif
3009fc59639SAlexei Fedorov
30126e63c44SEtienne CarriereASFLAGS_aarch32		=	$(march32-directive)
302fa6f774bSAlexei FedorovASFLAGS_aarch64		=	$(march64-directive)
303b86048c4SAntonio Nino Diaz
3049ab81b5eSJustin Chadwell# General warnings
3059ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
306b7f6525dSJustin Chadwell				-Wdisabled-optimization	-Wvla -Wshadow	\
307ca661a00SMadhukar Pappireddy				-Wno-unused-parameter -Wredundant-decls
3089ab81b5eSJustin Chadwell
3099ab81b5eSJustin Chadwell# Additional warnings
3109ab81b5eSJustin Chadwell# Level 1
311e7c645b5SYann GautierWARNING1 := -Wextra
312e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute
313e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes
314e7c645b5SYann GautierWARNING1 += -Wold-style-definition
315e7c645b5SYann Gautier
316b7f6525dSJustin Chadwell# Level 2
317e7c645b5SYann GautierWARNING2 := -Waggregate-return
318e7c645b5SYann GautierWARNING2 += -Wcast-align
319e7c645b5SYann GautierWARNING2 += -Wnested-externs
320e7c645b5SYann Gautier
321e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
322e7c645b5SYann GautierWARNING3 += -Wcast-qual
323e7c645b5SYann GautierWARNING3 += -Wconversion
324e7c645b5SYann GautierWARNING3 += -Wpacked
325e7c645b5SYann GautierWARNING3 += -Wpointer-arith
326e7c645b5SYann GautierWARNING3 += -Wswitch-default
327e7c645b5SYann Gautier
328e7c645b5SYann Gautierifeq (${W},1)
3299ab81b5eSJustin ChadwellWARNINGS += $(WARNING1)
330e7c645b5SYann Gautierelse ifeq (${W},2)
3319ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2)
332e7c645b5SYann Gautierelse ifeq (${W},3)
3339ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
334e7c645b5SYann Gautierendif
335e7c645b5SYann Gautier
3369ab81b5eSJustin Chadwell# Compiler specific warnings
33700296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),)
33893c690ebSJustin Chadwell# not using clang
339d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
340d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
341d7b4cd41SJustin Chadwell				-Wlogical-op
34293c690ebSJustin Chadwellelse
34393c690ebSJustin Chadwell# using clang
344d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
345d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
34600296576SAmbroise Vincentendif
34700296576SAmbroise Vincent
3486336b07aSYann Gautierifneq (${E},0)
3496336b07aSYann GautierERRORS := -Werror
3506336b07aSYann Gautierendif
3516336b07aSYann Gautier
352ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
3539ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
35459de5096SMasahiro YamadaASFLAGS			+=	$(CPPFLAGS) $(ASFLAGS_$(ARCH))			\
355d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
35659de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
357ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
358ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
359ebd6efaeSSamuel Holland				-Os -std=gnu99
36073c99d4eSJuan Castillo
3611f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
3621f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover
3631f461979SJustin Chadwellendif
3641f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
3651f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover	\
3661f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
3671f461979SJustin Chadwellendif
3681f461979SJustin Chadwell
369f7ec31dbSdavid cunadoGCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
370f7ec31dbSdavid cunado
371641f16e7SAmbroise Vincent# LD = armlink
372c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
373c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
374c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
375edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
376641f16e7SAmbroise Vincent
377641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
378edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),)
379edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches
380edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
381edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--gc-sections
382edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
383edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
384edbce9aaSzelalem-aweke		TF_LDFLAGS	+=	-flto -fuse-linker-plugin
385edbce9aaSzelalem-aweke	endif
386edbce9aaSzelalem-awekeendif
387edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
388edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
389edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1)
390edbce9aaSzelalem-aweke	TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
391edbce9aaSzelalem-awekeendif
392edbce9aaSzelalem-awekeTF_LDFLAGS		+= 	-nostdlib
393edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
394641f16e7SAmbroise Vincent
395641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
396c2ad38ceSVarun Wadekarelse
397c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--fatal-warnings -O1
398c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--gc-sections
399641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
400641f16e7SAmbroise Vincent# therefore don't add those in that case
401641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),)
402c2b8806fSDouglas RaillardTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
403edbce9aaSzelalem-awekeendif
404641f16e7SAmbroise Vincentendif
40573c99d4eSJuan Castillo
40603b397a8SNishanth MenonDTC_FLAGS		+=	-I dts -O dtb
407a6de824fSLouis MayencourtDTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
408a6de824fSLouis Mayencourt				-x assembler-with-cpp $(DEFINES)
40903b397a8SNishanth Menon
4100ab49645SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
4110ab49645SAlexei FedorovDTC_CPPFLAGS		+=	-DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE}
4120ab49645SAlexei Fedorovendif
4130ab49645SAlexei Fedorov
41473c99d4eSJuan Castillo################################################################################
41573c99d4eSJuan Castillo# Common sources and include directories
41673c99d4eSJuan Castillo################################################################################
417d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
41873c99d4eSJuan Castillo
41973c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
4207f56e9a3SSoby Mathew				common/tf_log.c				\
4219d29c227SSoby Mathew				common/${ARCH}/debug.S			\
42291b48c9fSJulius Werner				drivers/console/multi_console.c		\
4239d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
4249d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
425566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
4267f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
42775311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
4289d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
42961f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
430d7a6b0f8SRyan Harkin
4318422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang)
4328422a840SAntonio Nino DiazBL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
4338422a840SAntonio Nino Diazendif
4348422a840SAntonio Nino Diaz
4351f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4361f461979SJustin ChadwellBL_COMMON_SOURCES	+=	plat/common/ubsan.c
4371f461979SJustin Chadwellendif
4381f461979SJustin Chadwell
43901d237cbSYann GautierINCLUDES		+=	-Iinclude				\
440f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
44109d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
44209d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
44309d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
44409d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
44509d40e0eSAntonio Nino Diaz
4469c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4479c6d1c50SAntonio Nino Diaz
44873c99d4eSJuan Castillo################################################################################
44973c99d4eSJuan Castillo# Generic definitions
45073c99d4eSJuan Castillo################################################################################
45173c99d4eSJuan Castillo
452231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
453231c1470SEvan Lloyd
45429214e95SGrant Likelyifeq (${BUILD_BASE},)
45573c99d4eSJuan Castillo     BUILD_BASE		:=	./build
45629214e95SGrant Likelyendif
45729214e95SGrant LikelyBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
45873c99d4eSJuan Castillo
459231c1470SEvan LloydSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
46073c99d4eSJuan Castillo
46173c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
46273c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
46373c99d4eSJuan Castillo
46473c99d4eSJuan Castillo
46573c99d4eSJuan Castillo################################################################################
46673c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
46773c99d4eSJuan Castillo################################################################################
46873c99d4eSJuan Castillo
46973c99d4eSJuan Castilloifneq (${SPD},none)
4709d29c227SSoby Mathew    ifeq (${ARCH},aarch32)
4719d29c227SSoby Mathew        $(error "Error: SPD is incompatible with AArch32.")
4729d29c227SSoby Mathew    endif
47328f39f02SMax Shvetsov
4744c117f6cSSandrine Bailleux    ifdef EL3_PAYLOAD_BASE
4754c117f6cSSandrine Bailleux        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
4764c117f6cSSandrine Bailleux        $(warning "The SPD and its BL32 companion will be present but ignored.")
4774c117f6cSSandrine Bailleux    endif
47828f39f02SMax Shvetsov
479c3fb00d9SAchin Gupta    ifeq (${SPD},spmd)
480033039f8SMax Shvetsov        $(warning "SPMD is an experimental feature")
481c3fb00d9SAchin Gupta        # SPMD is located in std_svc directory
482c3fb00d9SAchin Gupta        SPD_DIR := std_svc
48328f39f02SMax Shvetsov
484033039f8SMax Shvetsov        ifeq ($(SPMD_SPM_AT_SEL2),1)
48528f39f02SMax Shvetsov            ifeq ($(CTX_INCLUDE_EL2_REGS),0)
486033039f8SMax Shvetsov                $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
487033039f8SMax Shvetsov            endif
48828f39f02SMax Shvetsov        endif
489db1ef41aSOlivier Deprez
490db1ef41aSOlivier Deprez        ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
491db1ef41aSOlivier Deprez            DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
492db1ef41aSOlivier Deprez        endif
493c3fb00d9SAchin Gupta    else
494c3fb00d9SAchin Gupta        # All other SPDs in spd directory
495c3fb00d9SAchin Gupta        SPD_DIR := spd
496c3fb00d9SAchin Gupta    endif
497c3fb00d9SAchin Gupta
49873c99d4eSJuan Castillo    # We expect to locate an spd.mk under the specified SPD directory
499c3fb00d9SAchin Gupta    SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
500c3fb00d9SAchin Gupta
50173c99d4eSJuan Castillo    ifeq (${SPD_MAKE},)
502c3fb00d9SAchin Gupta        $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
50373c99d4eSJuan Castillo    endif
50473c99d4eSJuan Castillo    $(info Including ${SPD_MAKE})
50573c99d4eSJuan Castillo    include ${SPD_MAKE}
50673c99d4eSJuan Castillo
50770d1fc53SJuan Castillo    # If there's BL32 companion for the chosen SPD, we expect that the SPD's
50870d1fc53SJuan Castillo    # Makefile would set NEED_BL32 to "yes". In this case, the build system
50970d1fc53SJuan Castillo    # supports two mutually exclusive options:
51070d1fc53SJuan Castillo    # * BL32 is built from source: then BL32_SOURCES must contain the list
51170d1fc53SJuan Castillo    #   of source files to build BL32
51270d1fc53SJuan Castillo    # * BL32 is a prebuilt binary: then BL32 must point to the image file
51370d1fc53SJuan Castillo    #   that will be included in the FIP
51470d1fc53SJuan Castillo    # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
51570d1fc53SJuan Castillo    # over the sources.
516e35c4045SJeenu Viswambharanendif
517e35c4045SJeenu Viswambharan
51851faada7SDouglas Raillard################################################################################
51973c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
52073c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
52173c99d4eSJuan Castillo################################################################################
5222da8d8bfSJeenu Viswambharan
52373c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
5240f21c547SJuan Castillo
5258012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
5268012cc5cSMasahiro Yamada
52726e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
52826e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
52926e63c44SEtienne Carriereendif
53026e63c44SEtienne Carriere
5313bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
5323bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
5333bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
5343bd17c0fSSoby Mathewendif
535320920c1SMasahiro Yamada
536320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),)
537320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
538320920c1SMasahiro Yamadaelse
539320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
540320920c1SMasahiro Yamadaendif
541320920c1SMasahiro Yamada
542320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
54369af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
54469af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1)
54569af7fcfSMasahiro Yamada	BL2_CFLAGS	+=	-fpie
54669af7fcfSMasahiro Yamada	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
54769af7fcfSMasahiro Yamadaendif
54869af7fcfSMasahiro Yamadaendif
549320920c1SMasahiro Yamada	BL31_CFLAGS	+=	-fpie
550320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
551d974301dSMasahiro Yamadaifeq ($(ARCH),aarch64)
552d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
553d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
554d974301dSMasahiro Yamadaendif
5553bd17c0fSSoby Mathewendif
5563bd17c0fSSoby Mathew
557d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64)
5589cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
559d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
5609cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3
561d5e97a1dSMasahiro Yamadaelse
5629cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1
563d5e97a1dSMasahiro Yamadaendif
5649cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1
5659cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3
5669cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1
567d5e97a1dSMasahiro Yamadaendif
568d5e97a1dSMasahiro Yamada
56954035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
57054035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
57154035fc4SSandrine Bailleux# This can be overridden by the platform.
57273c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
5734f6ad66aSAchin Gupta
574a4409008Sdp-armifeq (${ARCH},aarch32)
575a4409008Sdp-armNEED_BL32 := yes
576a4409008Sdp-arm
577a4409008Sdp-arm################################################################################
578a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
579a4409008Sdp-arm################################################################################
580a4409008Sdp-armifneq (${AARCH32_SP},none)
581a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory
582a4409008Sdp-armAARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
583a4409008Sdp-arm
584a4409008Sdp-armifeq (${AARCH32_SP_MAKE},)
585a4409008Sdp-arm  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
586a4409008Sdp-armendif
587a4409008Sdp-arm
588a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE})
589a4409008Sdp-arminclude ${AARCH32_SP_MAKE}
590a4409008Sdp-armendif
591a4409008Sdp-arm
592a4409008Sdp-armendif
5934f6ad66aSAchin Gupta
59473c99d4eSJuan Castillo################################################################################
59577f1f7a1SVarun Wadekar# Include libc if not overridden
59677f1f7a1SVarun Wadekar################################################################################
59777f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
59877f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
59977f1f7a1SVarun Wadekarendif
60077f1f7a1SVarun Wadekar
60177f1f7a1SVarun Wadekar################################################################################
602cf2c8a33SAntonio Nino Diaz# Check incompatible options
603cf2c8a33SAntonio Nino Diaz################################################################################
604cf2c8a33SAntonio Nino Diaz
605cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
60668450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
60768450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
60868450a6dSAntonio Nino Diaz                incompatible build options. EL3_PAYLOAD_BASE has priority.")
609cf2c8a33SAntonio Nino Diaz        endif
61076580f3dSQixiang Xu        ifneq (${GENERATE_COT},0)
61176580f3dSQixiang Xu                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
61276580f3dSQixiang Xu        endif
61376580f3dSQixiang Xu        ifneq (${TRUSTED_BOARD_BOOT},0)
61476580f3dSQixiang Xu                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
61576580f3dSQixiang Xu        endif
616cf2c8a33SAntonio Nino Diazendif
617cf2c8a33SAntonio Nino Diaz
618cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
619cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
620cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
621cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
622cf2c8a33SAntonio Nino Diaz        endif
62368450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
62468450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
62568450a6dSAntonio Nino Diaz                PRELOADED_BL33_BASE is used and won't be added to the FIP \
62668450a6dSAntonio Nino Diaz                file.")
627cf2c8a33SAntonio Nino Diaz        endif
628cf2c8a33SAntonio Nino Diazendif
629cf2c8a33SAntonio Nino Diaz
630d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
631d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
632d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
633d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
634d4593e47SJeenu Viswambharanendif
6351a0a3f06SYatharth Kochar
6367d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
6377d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
6387d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
6397d173fc5SJiafei Panendif
6407d173fc5SJiafei Pan
64114c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first
64214c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
64314c6016aSJeenu Viswambharan    ifneq ($(HANDLE_EA_EL3_FIRST),1)
64414c6016aSJeenu Viswambharan        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1)
64514c6016aSJeenu Viswambharan    endif
64614c6016aSJeenu Viswambharanendif
64714c6016aSJeenu Viswambharan
6481a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
6491a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
6501a7c1cfeSJeenu Viswambharan    ifneq ($(RAS_EXTENSION),1)
6511a7c1cfeSJeenu Viswambharan        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
6521a7c1cfeSJeenu Viswambharan    endif
6531a7c1cfeSJeenu Viswambharanendif
6541a7c1cfeSJeenu Viswambharan
655ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
656209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
657209a60ccSSoby Mathew    ifeq (${TRUSTED_BOARD_BOOT}, 0)
658209a60ccSSoby Mathew        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
659209a60ccSSoby Mathew    endif
660209a60ccSSoby Mathewendif
661209a60ccSSoby Mathew
662cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
663cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
664cbf9e84aSBalint Dobszay$(error "SDEI_IN_FCONF is an experimental feature and is only supported when \
665cbf9e84aSBalint Dobszay	SDEI_SUPPORT is enabled")
666cbf9e84aSBalint Dobszayendif
667cbf9e84aSBalint Dobszay
66884ef9cd8SManish V Badarkheifeq ($(COT_DESC_IN_DTB),1)
66984ef9cd8SManish V Badarkhe    $(info CoT in device tree is an experimental feature)
67084ef9cd8SManish V Badarkheendif
67184ef9cd8SManish V Badarkhe
672b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
6739fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
6749fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
675b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
6769fc59639SAlexei Fedorov    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
6779fc59639SAlexei Fedorov        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
67806715f85SAlexei Fedorov    endif
6799fc59639SAlexei Fedorovendif
6809fc59639SAlexei Fedorov
68106715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
6829fc59639SAlexei Fedorov    ifneq (${ARCH},aarch64)
6839fc59639SAlexei Fedorov        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
684dfc66a17SJohn Tsichritzis    else
68506715f85SAlexei Fedorov        $(info CTX_INCLUDE_PAUTH_REGS is an experimental feature)
686b86048c4SAntonio Nino Diaz    endif
687b86048c4SAntonio Nino Diazendif
6889fc59639SAlexei Fedorov
6899fc59639SAlexei Fedorovifeq ($(ENABLE_PAUTH),1)
6909fc59639SAlexei Fedorov    $(info Pointer Authentication is an experimental feature)
6919fc59639SAlexei Fedorovendif
6929fc59639SAlexei Fedorov
6939fc59639SAlexei Fedorovifeq ($(ENABLE_BTI),1)
6949fc59639SAlexei Fedorov    $(info Branch Protection is an experimental feature)
695dfc66a17SJohn Tsichritzisendif
696b86048c4SAntonio Nino Diaz
6979dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1)
6989dd94382SJustin Chadwell    ifneq (${ARCH},aarch64)
6999dd94382SJustin Chadwell        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
7009dd94382SJustin Chadwell    else
7019dd94382SJustin Chadwell        $(info CTX_INCLUDE_MTE_REGS is an experimental feature)
7029dd94382SJustin Chadwell    endif
7039dd94382SJustin Chadwellendif
7049dd94382SJustin Chadwell
7058c105290SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
7068c105290SAlexei Fedorov    ifneq (${TRUSTED_BOARD_BOOT},1)
7077cda17bbSSumit Garg        $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1)
7088c105290SAlexei Fedorov    else
7098c105290SAlexei Fedorov        $(info MEASURED_BOOT is an experimental feature)
7108c105290SAlexei Fedorov    endif
7118c105290SAlexei Fedorovendif
7128c105290SAlexei Fedorov
71360e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
71460e8f3cfSPetre-Ionut Tudor    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
71560e8f3cfSPetre-Ionut Tudor        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
71660e8f3cfSPetre-Ionut Tudor    endif
71760e8f3cfSPetre-Ionut Tudorendif
71860e8f3cfSPetre-Ionut Tudor
7197cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
7207cda17bbSSumit Garg    ifeq (${TRUSTED_BOARD_BOOT}, 0)
7217cda17bbSSumit Garg        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
7227cda17bbSSumit Garg    else
7237cda17bbSSumit Garg        $(info DECRYPTION_SUPPORT is an experimental feature)
7247cda17bbSSumit Garg    endif
7257cda17bbSSumit Gargendif
7267cda17bbSSumit Garg
727cf2c8a33SAntonio Nino Diaz################################################################################
72873c99d4eSJuan Castillo# Process platform overrideable behaviour
72973c99d4eSJuan Castillo################################################################################
7304f6ad66aSAchin Gupta
731bd97f83aSJohn Tsichritzis# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
732bd97f83aSJohn Tsichritzis# Certificate generation tools. This flag can be overridden by the platform.
73373c99d4eSJuan Castilloifdef BL2_SOURCES
734cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
735cf2c8a33SAntonio Nino Diaz                # If booting an EL3 payload there is no need for a BL33 image
736cf2c8a33SAntonio Nino Diaz                # in the FIP file.
7374c117f6cSSandrine Bailleux                NEED_BL33		:=	no
738cf2c8a33SAntonio Nino Diaz        else
73968450a6dSAntonio Nino Diaz                ifdef PRELOADED_BL33_BASE
740cf2c8a33SAntonio Nino Diaz                        # If booting a BL33 preloaded image there is no need of
741cf2c8a33SAntonio Nino Diaz                        # another one in the FIP file.
742cf2c8a33SAntonio Nino Diaz                        NEED_BL33		:=	no
743cf2c8a33SAntonio Nino Diaz                else
744cf2c8a33SAntonio Nino Diaz                        NEED_BL33		?=	yes
745cf2c8a33SAntonio Nino Diaz                endif
7464c117f6cSSandrine Bailleux        endif
74773c99d4eSJuan Castilloendif
7486f971622SJuan Castillo
7494d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
7504d045d0eSMasahiro Yamadaifdef SCP_BL2
7514d045d0eSMasahiro Yamada        NEED_SCP_BL2		:=	yes
7524d045d0eSMasahiro Yamadaendif
7534d045d0eSMasahiro Yamada
7545744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
7555744e874SSoby Mathewifneq (${ARCH},aarch32)
7565744e874SSoby Mathew    ifdef BL31_SOURCES
7575744e874SSoby Mathew        # When booting an EL3 payload, there is no need to compile the BL31 image nor
7585744e874SSoby Mathew        # put it in the FIP.
7595744e874SSoby Mathew        ifndef EL3_PAYLOAD_BASE
7605744e874SSoby Mathew            NEED_BL31 := yes
7615744e874SSoby Mathew        endif
7625744e874SSoby Mathew    endif
7635744e874SSoby Mathewendif
7645744e874SSoby Mathew
76573c99d4eSJuan Castillo# Process TBB related flags
7666f971622SJuan Castilloifneq (${GENERATE_COT},0)
76773c99d4eSJuan Castillo        # Common cert_create options
7686f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
7696f971622SJuan Castillo                $(eval CRT_ARGS += -n)
7700191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
771fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
772fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
7730191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
774fd34e7baSJuan Castillo                endif
7756f971622SJuan Castillo        endif
77673c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
77773c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
77873c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
77973c99d4eSJuan Castillo        endif
7806f971622SJuan Castilloendif
7816f971622SJuan Castillo
7821c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
7831c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN}
7841c75d5dfSMasahiro Yamadaendif
7851c75d5dfSMasahiro Yamada
78673c99d4eSJuan Castillo################################################################################
78746e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
78846e5e035SMichalis Pappas################################################################################
78946e5e035SMichalis Pappas
79046e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
79146e5e035SMichalis Pappas
79246e5e035SMichalis Pappas################################################################################
793819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc)
79473c99d4eSJuan Castillo################################################################################
79573c99d4eSJuan Castillo
79673c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
79773c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
79842a45b51SEvan LloydCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
79973c99d4eSJuan Castillo
80090aa901fSSumit Garg# Variables for use with Firmware Encryption Tool
80190aa901fSSumit GargENCTOOLPATH		?=	tools/encrypt_fw
80290aa901fSSumit GargENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
80390aa901fSSumit Garg
80473c99d4eSJuan Castillo# Variables for use with Firmware Image Package
805819281eeSdp-armFIPTOOLPATH		?=	tools/fiptool
806819281eeSdp-armFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
80773c99d4eSJuan Castillo
80826010da1SAntonio Nino Diaz# Variables for use with sptool
80926010da1SAntonio Nino DiazSPTOOLPATH		?=	tools/sptool
81026010da1SAntonio Nino DiazSPTOOL			?=	${SPTOOLPATH}/sptool${BIN_EXT}
811ce2b1ec6SManish PandeySP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
81226010da1SAntonio Nino Diaz
8135accce5bSRoberto Vargas# Variables for use with ROMLIB
8145accce5bSRoberto VargasROMLIBPATH		?=	lib/romlib
8155accce5bSRoberto Vargas
816cfe83910SLouis Mayencourt# Variable for use with Python
817cfe83910SLouis MayencourtPYTHON			?=	python3
818cfe83910SLouis Mayencourt
819cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP
820cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH		?=	tools/memory
821cfe83910SLouis MayencourtPRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
822cfe83910SLouis Mayencourt
8236de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool
8246de32378SMadhukar PappireddyDOCS_PATH		?=	docs
8256de32378SMadhukar Pappireddy
8268a86052dSSoby Mathew################################################################################
8278a86052dSSoby Mathew# Include BL specific makefiles
8288a86052dSSoby Mathew################################################################################
8298a86052dSSoby Mathewifdef BL1_SOURCES
8308a86052dSSoby MathewNEED_BL1 := yes
8318a86052dSSoby Mathewinclude bl1/bl1.mk
8328a86052dSSoby Mathewendif
8338a86052dSSoby Mathew
8348a86052dSSoby Mathewifdef BL2_SOURCES
8358a86052dSSoby MathewNEED_BL2 := yes
8368a86052dSSoby Mathewinclude bl2/bl2.mk
8378a86052dSSoby Mathewendif
8388a86052dSSoby Mathew
8398a86052dSSoby Mathewifdef BL2U_SOURCES
8408a86052dSSoby MathewNEED_BL2U := yes
8418a86052dSSoby Mathewinclude bl2u/bl2u.mk
8428a86052dSSoby Mathewendif
8438a86052dSSoby Mathew
8445744e874SSoby Mathewifeq (${NEED_BL31},yes)
8458a86052dSSoby Mathewifdef BL31_SOURCES
8468a86052dSSoby Mathewinclude bl31/bl31.mk
8478a86052dSSoby Mathewendif
8488a86052dSSoby Mathewendif
8498a86052dSSoby Mathew
85003b397a8SNishanth Menonifdef FDT_SOURCES
85103b397a8SNishanth MenonNEED_FDT := yes
85203b397a8SNishanth Menonendif
85303b397a8SNishanth Menon
85473c99d4eSJuan Castillo################################################################################
85573c99d4eSJuan Castillo# Build options checks
85673c99d4eSJuan Castillo################################################################################
85773c99d4eSJuan Castillo
858327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
859327131c4SLeonardo Sandoval    $(sort \
860327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
861327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
862327131c4SLeonardo Sandoval        CREATE_KEYS \
863327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
864327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
865327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
866327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
867327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
868062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
869327131c4SLeonardo Sandoval        DEBUG \
870327131c4SLeonardo Sandoval        DYN_DISABLE_AUTH \
871327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
872327131c4SLeonardo Sandoval        ENABLE_AMU \
873327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
874327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
875327131c4SLeonardo Sandoval        ENABLE_PIE \
876327131c4SLeonardo Sandoval        ENABLE_PMF \
877327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
878327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
879327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
880327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
881327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
882327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
883327131c4SLeonardo Sandoval        GENERATE_COT \
884327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
885327131c4SLeonardo Sandoval        HANDLE_EA_EL3_FIRST \
886327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
887327131c4SLeonardo Sandoval        INVERTED_MEMMAP \
888327131c4SLeonardo Sandoval        MEASURED_BOOT \
889327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
890327131c4SLeonardo Sandoval        OVERRIDE_LIBC \
891327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
892327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
893327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
894327131c4SLeonardo Sandoval        RAS_EXTENSION \
895327131c4SLeonardo Sandoval        RESET_TO_BL31 \
896327131c4SLeonardo Sandoval        SAVE_KEYS \
897327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
898327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
899327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
900327131c4SLeonardo Sandoval        SPM_MM \
901327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
902327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
903327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
904327131c4SLeonardo Sandoval        USE_DEBUGFS \
905327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
906327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
907327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
908327131c4SLeonardo Sandoval        USE_ROMLIB \
909327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
910327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
911327131c4SLeonardo Sandoval        BL2_AT_EL3 \
912327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
913327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
914327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
915327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
916327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
917327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
918327131c4SLeonardo Sandoval        RAS_TRAP_LOWER_EL_ERR_ACCESS \
919327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
920327131c4SLeonardo Sandoval        USE_SP804_TIMER \
921327131c4SLeonardo Sandoval)))
92273c99d4eSJuan Castillo
923327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
924327131c4SLeonardo Sandoval    $(sort \
925327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
926327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
927327131c4SLeonardo Sandoval        BRANCH_PROTECTION \
928327131c4SLeonardo Sandoval        FW_ENC_STATUS \
929327131c4SLeonardo Sandoval)))
930c877b414SJeenu Viswambharan
931aacff749SJustin Chadwellifdef KEY_SIZE
932aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
933aacff749SJustin Chadwellendif
934aacff749SJustin Chadwell
9351f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
9361f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
9371f461979SJustin Chadwellendif
9381f461979SJustin Chadwell
93973c99d4eSJuan Castillo################################################################################
94073c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
94173c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
94273c99d4eSJuan Castillo# platform to overwrite the default options
94373c99d4eSJuan Castillo################################################################################
94473c99d4eSJuan Castillo
945327131c4SLeonardo Sandoval$(eval $(call add_defines,\
946327131c4SLeonardo Sandoval    $(sort \
947327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
948327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
949327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
950327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
951327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
952327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
953327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
954327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
955327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
956327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
957062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
958327131c4SLeonardo Sandoval        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
959327131c4SLeonardo Sandoval        ENABLE_AMU \
960327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
961327131c4SLeonardo Sandoval        ENABLE_BTI \
962327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
963327131c4SLeonardo Sandoval        ENABLE_PAUTH \
964327131c4SLeonardo Sandoval        ENABLE_PIE \
965327131c4SLeonardo Sandoval        ENABLE_PMF \
966327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
967327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
968327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
969327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
970327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
971327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
972327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
973327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
974327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
975327131c4SLeonardo Sandoval        HANDLE_EA_EL3_FIRST \
976327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
977327131c4SLeonardo Sandoval        LOG_LEVEL \
978327131c4SLeonardo Sandoval        MEASURED_BOOT \
979327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
980327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
981327131c4SLeonardo Sandoval        PLAT_${PLAT} \
982327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
983327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
984327131c4SLeonardo Sandoval        RAS_EXTENSION \
985327131c4SLeonardo Sandoval        RESET_TO_BL31 \
986327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
987327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
988327131c4SLeonardo Sandoval        RECLAIM_INIT_CODE \
989327131c4SLeonardo Sandoval        SPD_${SPD} \
990327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
991327131c4SLeonardo Sandoval        SPM_MM \
992327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
993327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
994327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
995327131c4SLeonardo Sandoval        USE_DEBUGFS \
996327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
997327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
998327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
999327131c4SLeonardo Sandoval        USE_ROMLIB \
1000327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
1001327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
1002327131c4SLeonardo Sandoval        BL2_AT_EL3 \
1003327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
1004327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
1005327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
1006327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
1007327131c4SLeonardo Sandoval        RAS_TRAP_LOWER_EL_ERR_ACCESS \
1008327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
1009327131c4SLeonardo Sandoval        USE_SP804_TIMER \
1010327131c4SLeonardo Sandoval)))
10112fae4b1eSJeenu Viswambharan
10121f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
10131f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
10141f461979SJustin Chadwellendif
10151f461979SJustin Chadwell
10164c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
10174c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
10184c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1019cf2c8a33SAntonio Nino Diazelse
102068450a6dSAntonio Nino Diaz        # Define the PRELOADED_BL33_BASE flag only if it is provided and
102168450a6dSAntonio Nino Diaz        # EL3_PAYLOAD_BASE is not defined, as it has priority.
102268450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
102368450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
10244c117f6cSSandrine Bailleux        endif
1025cf2c8a33SAntonio Nino Diazendif
102673c99d4eSJuan Castillo
1027209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1028209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1029209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH))
1030209a60ccSSoby Mathewendif
1031209a60ccSSoby Mathew
1032c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
1033c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK))
1034c2ad38ceSVarun Wadekarendif
1035c2ad38ceSVarun Wadekar
1036ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1037ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1038c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1039c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},0)
1040c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL1 does not require SP_LAYOUT_FILE")
1041c33ff198SOlivier Deprez        endif
1042ce2b1ec6SManish Pandey        -include $(BUILD_PLAT)/sp_gen.mk
1043ce2b1ec6SManish Pandey        FIP_DEPS += sp
104407c44475SManish Pandey        CRT_DEPS += sp
1045ce2b1ec6SManish Pandey        NEED_SP_PKG := yes
1046ce2b1ec6SManish Pandeyelse
1047c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},1)
1048c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1049c33ff198SOlivier Deprez        endif
1050ce2b1ec6SManish Pandeyendif
1051ce2b1ec6SManish Pandeyendif
1052ce2b1ec6SManish Pandey
105373c99d4eSJuan Castillo################################################################################
105473c99d4eSJuan Castillo# Build targets
105573c99d4eSJuan Castillo################################################################################
105673c99d4eSJuan Castillo
105790aa901fSSumit Garg.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
105873c99d4eSJuan Castillo.SUFFIXES:
105973c99d4eSJuan Castillo
106073c99d4eSJuan Castilloall: msg_start
106173c99d4eSJuan Castillo
106273c99d4eSJuan Castillomsg_start:
106373c99d4eSJuan Castillo	@echo "Building ${PLAT}"
106473c99d4eSJuan Castillo
10657a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1066d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
1067c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),)
1068c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1069c2ad38ceSVarun Wadekarelse
1070bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
10717a24cba5SSoby Mathewendif
1072d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED
10737a24cba5SSoby Mathew
10745accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS))
107561f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
10765fee0287SRoberto Vargas
107773c99d4eSJuan Castillo# Expand build macros for the different images
107873c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
107973c99d4eSJuan Castillo$(eval $(call MAKE_BL,1))
108073c99d4eSJuan Castilloendif
108173c99d4eSJuan Castillo
108273c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1083c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0)
1084c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1085c9b31ae8SRoberto Vargasendif
1086c9b31ae8SRoberto Vargas
108733950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1088c9b31ae8SRoberto Vargas	$(eval $(call MAKE_BL,2,${FIP_BL2_ARGS})))
108973c99d4eSJuan Castilloendif
109073c99d4eSJuan Castillo
10914d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
109233950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
10934d045d0eSMasahiro Yamadaendif
10944d045d0eSMasahiro Yamada
109573c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
109673c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
109726d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
109826d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1099c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1100c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1101c6ba9b45SSumit Garg	$(eval $(call MAKE_BL,31,soc-fw,,$(ENCRYPT_BL31))))
1102c6ba9b45SSumit Gargelse
110333950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
11048f0617efSJuan Castillo	$(eval $(call MAKE_BL,31,soc-fw)))
110573c99d4eSJuan Castilloendif
1106c6ba9b45SSumit Gargendif
110773c99d4eSJuan Castillo
110870d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1109c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
111070d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
111173c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
111226d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
111326d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
11149cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
11159cd15239SMasahiro Yamada
1116c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1117c6ba9b45SSumit Garg$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw,,$(ENCRYPT_BL32))),\
1118c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1119c6ba9b45SSumit Gargelse
11209cd15239SMasahiro Yamada$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\
112133950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
112273c99d4eSJuan Castilloendif
1123c6ba9b45SSumit Gargendif
112473c99d4eSJuan Castillo
112573c99d4eSJuan Castillo# Add the BL33 image if required by the platform
112673c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
112733950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1128db6071c9SJuan Castilloendif
1129db6071c9SJuan Castillo
11309003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
113133950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
11321dc0714fSMasahiro Yamada	$(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_)))
11339003fa0bSYatharth Kocharendif
11349003fa0bSYatharth Kochar
113503b397a8SNishanth Menon# Expand build macros for the different images
113603b397a8SNishanth Menonifeq (${NEED_FDT},yes)
113703b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
113803b397a8SNishanth Menonendif
113903b397a8SNishanth Menon
1140ce2b1ec6SManish Pandey# Add Secure Partition packages
1141ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1142ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
11431e7528ecSRuari Phipps	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1144ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk
1145ce2b1ec6SManish Pandey	${Q}$(SPTOOL) $(SPTOOL_ARGS)
1146ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1147ce2b1ec6SManish Pandey	@echo "Built SP Images successfully"
1148ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1149ce2b1ec6SManish Pandeyendif
1150ce2b1ec6SManish Pandey
115136eaaf37SIan Spraylocate-checkpatch:
115236eaaf37SIan Sprayifndef CHECKPATCH
115366079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
115436eaaf37SIan Sprayelse
115536eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
115666079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
115736eaaf37SIan Sprayendif
115836eaaf37SIan Sprayendif
115936eaaf37SIan Spray
11604f6ad66aSAchin Guptaclean:
11614f6ad66aSAchin Gupta	@echo "  CLEAN"
1162f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
116388a1cf1eSSami Mujawarifdef UNIX_MK
11642f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
116588a1cf1eSSami Mujawarelse
116688a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
116788a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
116888a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
116988a1cf1eSSami Mujawarendif
11706f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
117190aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
11725accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11734f6ad66aSAchin Gupta
1174eaaeece2SJames Morrisseyrealclean distclean:
1175eaaeece2SJames Morrissey	@echo "  REALCLEAN"
1176f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1177f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
117888a1cf1eSSami Mujawarifdef UNIX_MK
11792f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
118088a1cf1eSSami Mujawarelse
118188a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
118288a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
118388a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
118488a1cf1eSSami Mujawarendif
118526010da1SAntonio Nino Diaz	${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean
11866f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
118790aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
11885accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
11894f6ad66aSAchin Gupta
119036eaaf37SIan Spraycheckcodebase:		locate-checkpatch
119136eaaf37SIan Spray	@echo "  CHECKING STYLE"
119236eaaf37SIan Spray	@if test -d .git ; then						\
11931ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
11941a41e8c1SDan Handley		while read GIT_FILE ;					\
11951a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
11961a41e8c1SDan Handley		done ;							\
119736eaaf37SIan Spray	else								\
11981a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
11991a41e8c1SDan Handley		 -not -iwholename "*build*"				\
12001a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
120161f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
12021a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
12031ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
12041a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
120536eaaf37SIan Spray	fi
120636eaaf37SIan Spray
120736eaaf37SIan Spraycheckpatch:		locate-checkpatch
120836eaaf37SIan Spray	@echo "  CHECKING STYLE"
120902a76d5fSYann Gautier	@if test -n "${CHECKPATCH_OPTS}"; then				\
121002a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
121102a76d5fSYann Gautier	fi
121251d28937SAntonio Nino Diaz	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
121351d28937SAntonio Nino Diaz	for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do		\
121451d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
121551d28937SAntonio Nino Diaz		git log --format=email "$$commit~..$$commit"		\
121602a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
121702a76d5fSYann Gautier			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
121851d28937SAntonio Nino Diaz		git diff --format=email "$$commit~..$$commit"		\
121902a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
122002a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
122151d28937SAntonio Nino Diaz	done
122236eaaf37SIan Spray
122373c99d4eSJuan Castillocerttool: ${CRTTOOL}
122473c99d4eSJuan Castillo
12256f971622SJuan Castillo.PHONY: ${CRTTOOL}
12266f971622SJuan Castillo${CRTTOOL}:
1227fafd3ec9SManish 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}
1228f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12296f971622SJuan Castillo	@echo "Built $@ successfully"
1230f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12316f971622SJuan Castillo
12326f971622SJuan Castilloifneq (${GENERATE_COT},0)
123373c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
12346f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
1235f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12366f971622SJuan Castillo	@echo "Built $@ successfully"
12376f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
1238f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
123973c99d4eSJuan Castilloendif
124027713fb4SSoby Mathew
124173c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
1242819281eeSdp-arm	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1243819281eeSdp-arm	${Q}${FIPTOOL} info $@
1244f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12452f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
1246f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1247f58ad36fSHarry Liebel
12480191262dSYatharth Kocharifneq (${GENERATE_COT},0)
12490191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
12500191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1251052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12520191262dSYatharth Kochar	@echo "Built $@ successfully"
12530191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1254052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12550191262dSYatharth Kocharendif
12560191262dSYatharth Kochar
12570191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
1258819281eeSdp-arm	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1259819281eeSdp-arm	${Q}${FIPTOOL} info $@
1260052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12610191262dSYatharth Kochar	@echo "Built $@ successfully"
1262052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12630191262dSYatharth Kochar
126473c99d4eSJuan Castillofiptool: ${FIPTOOL}
126573c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
12660191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
126773c99d4eSJuan Castillo
126873c99d4eSJuan Castillo.PHONY: ${FIPTOOL}
126973c99d4eSJuan Castillo${FIPTOOL}:
127088a1cf1eSSami Mujawar	@${ECHO_BLANK_LINE}
127188a1cf1eSSami Mujawar	@echo "Building $@"
127288a1cf1eSSami Mujawarifdef UNIX_MK
1273fafd3ec9SManish V Badarkhe	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH}
127488a1cf1eSSami Mujawarelse
127588a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
127688a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
127788a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
127888a1cf1eSSami Mujawarendif
127988a1cf1eSSami Mujawar	@${ECHO_BLANK_LINE}
1280f58ad36fSHarry Liebel
128126010da1SAntonio Nino Diazsptool: ${SPTOOL}
128226010da1SAntonio Nino Diaz.PHONY: ${SPTOOL}
128326010da1SAntonio Nino Diaz${SPTOOL}:
1284fafd3ec9SManish V Badarkhe	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH}
128526010da1SAntonio Nino Diaz
12865accce5bSRoberto Vargas.PHONY: libraries
12875accce5bSRoberto Vargasromlib.bin: libraries
1288bbb24f61SJohn 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
12895accce5bSRoberto Vargas
1290cfe83910SLouis Mayencourt# Call print_memory_map tool
1291cfe83910SLouis Mayencourtmemmap: all
1292b890b36dSLouis Mayencourt	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1293cfe83910SLouis Mayencourt
12946de32378SMadhukar Pappireddydoc:
12956de32378SMadhukar Pappireddy	@echo "  BUILD DOCUMENTATION"
12966de32378SMadhukar Pappireddy	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
12976de32378SMadhukar Pappireddy
129890aa901fSSumit Gargenctool: ${ENCTOOL}
129990aa901fSSumit Garg
130090aa901fSSumit Garg.PHONY: ${ENCTOOL}
130190aa901fSSumit Garg${ENCTOOL}:
1302fafd3ec9SManish V Badarkhe	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH}
130390aa901fSSumit Garg	@${ECHO_BLANK_LINE}
130490aa901fSSumit Garg	@echo "Built $@ successfully"
130590aa901fSSumit Garg	@${ECHO_BLANK_LINE}
130690aa901fSSumit Garg
130735fab8c9SJoakim Bechcscope:
130835fab8c9SJoakim Bech	@echo "  CSCOPE"
130935fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
131035fab8c9SJoakim Bech	${Q}cscope -b -q -k
131135fab8c9SJoakim Bech
131272ee3314SRyan Harkinhelp:
13137c23126cSJohn Tsichritzis	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
131472ee3314SRyan Harkin	@echo ""
131572ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
131608c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
131772ee3314SRyan Harkin	@echo ""
13187c23126cSJohn Tsichritzis	@echo "platform = ${PLATFORM_LIST}"
13197c23126cSJohn Tsichritzis	@echo ""
13201b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
13211b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
13221b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
13231b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
13241b578596SSandrine Bailleux	@echo ""
132572ee3314SRyan Harkin	@echo "Supported Targets:"
13261b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
132736eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
13288aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
13299003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
1330d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
13319d29c227SSoby Mathew	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
13329d29c227SSoby Mathew	@echo "                 this builds secure payload specified by AARCH32_SP"
133373c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
13341b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
13350191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
133636eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
133736eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
133836eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
133972ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
134035fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
134172ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
13426f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
134390aa901fSSumit Garg	@echo "  enctool        Build the Firmware encryption tool"
1344f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1345ce2b1ec6SManish Pandey	@echo "  sp             Build the Secure Partition Packages"
134626010da1SAntonio Nino Diaz	@echo "  sptool         Build the Secure Partition Package creation tool"
134738c14d88SSoby Mathew	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1348cfe83910SLouis Mayencourt	@echo "  memmap         Print the memory map of the built binaries"
13496de32378SMadhukar Pappireddy	@echo "  doc            Build html based documentation using Sphinx tool"
135072ee3314SRyan Harkin	@echo ""
13511b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
135272ee3314SRyan Harkin	@echo ""
135372ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
135472ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1355