xref: /rk3399_ARM-atf/Makefile (revision 4e04478aace24232d9acb9ca7c71af8ae845811f)
14f6ad66aSAchin Gupta#
27dfb9911SJimmy Brisson# Copyright (c) 2013-2021, ARM Limited and Contributors. All rights reserved.
34f6ad66aSAchin Gupta#
482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
54f6ad66aSAchin Gupta#
64f6ad66aSAchin Gupta
7e35c4045SJeenu Viswambharan#
8aaa3e722SJuan Castillo# Trusted Firmware Version
9aaa3e722SJuan Castillo#
101a0f1121SSoby MathewVERSION_MAJOR			:= 2
115edddf3aSManish V BadarkheVERSION_MINOR			:= 4
12aaa3e722SJuan Castillo
1388154678SJuan Castillo# Default goal is build all images
1488154678SJuan Castillo.DEFAULT_GOAL			:= all
1588154678SJuan Castillo
1672fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to
1772fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
1872fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual.
1972fc70edSDouglas RaillardMAKEOVERRIDES =
2072fc70edSDouglas Raillard
21231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/
22231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
23e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk
2473c99d4eSJuan Castillo
2573c99d4eSJuan Castillo################################################################################
262fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies
2773c99d4eSJuan Castillo################################################################################
28e35c4045SJeenu Viswambharan
292fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
30872be88aSdp-arm
31cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default
32cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS		:= ${DEBUG}
332fae4b1eSJeenu ViswambharanENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
342fae4b1eSJeenu ViswambharanPLAT				:= ${DEFAULT_PLAT}
3573c99d4eSJuan Castillo
3673c99d4eSJuan Castillo################################################################################
3773c99d4eSJuan Castillo# Checkpatch script options
3873c99d4eSJuan Castillo################################################################################
3973c99d4eSJuan Castillo
40f607739cSSandrine BailleuxCHECKCODE_ARGS		:=	--no-patch
41f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files
424501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	:=	$(sort $(filter-out                     \
434501843fSGilad Ben-Yossef					include/drivers/arm/cryptocell,	\
444501843fSGilad Ben-Yossef					$(wildcard include/drivers/arm/*)))
454501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK	+=	include/drivers/arm/cryptocell/*.h
464501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
474501843fSGilad Ben-Yossef					include/drivers/arm,		\
484501843fSGilad Ben-Yossef					$(wildcard include/drivers/*)))
49f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
501a41e8c1SDan Handley					include/lib/libfdt		\
5161f72a34SRoberto Vargas					include/lib/libc,		\
52f0b489c1SDan Handley					$(wildcard include/lib/*)))
53f0b489c1SDan HandleyINC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
544501843fSGilad Ben-Yossef					include/lib			\
554501843fSGilad Ben-Yossef					include/drivers,		\
56f0b489c1SDan Handley					$(wildcard include/*)))
57f0b489c1SDan HandleyLIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
58d801fbb0Sdp-arm					lib/compiler-rt			\
5955cdcf75SAntonio Nino Diaz					lib/libfdt%			\
6061f72a34SRoberto Vargas					lib/libc,			\
61f0b489c1SDan Handley					$(wildcard lib/*)))
62f0b489c1SDan HandleyROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
63f0b489c1SDan Handley					lib				\
64f0b489c1SDan Handley					include				\
65f0b489c1SDan Handley					docs				\
661ef35512SPaul Beesley					%.rst,				\
67f0b489c1SDan Handley					$(wildcard *)))
68f0b489c1SDan HandleyCHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
69f0b489c1SDan Handley				${INC_DIRS_TO_CHECK}			\
70f0b489c1SDan Handley				${INC_LIB_DIRS_TO_CHECK}		\
714501843fSGilad Ben-Yossef				${LIB_DIRS_TO_CHECK}			\
724501843fSGilad Ben-Yossef				${INC_DRV_DIRS_TO_CHECK}		\
734501843fSGilad Ben-Yossef				${INC_ARM_DIRS_TO_CHECK}
7436eaaf37SIan Spray
7573c99d4eSJuan Castillo
7673c99d4eSJuan Castillo################################################################################
7773c99d4eSJuan Castillo# Process build options
7873c99d4eSJuan Castillo################################################################################
7973c99d4eSJuan Castillo
8073c99d4eSJuan Castillo# Verbose flag
81e35c4045SJeenu Viswambharanifeq (${V},0)
82b169f6a9SEvan Lloyd        Q:=@
83ee1ba6d4SAndre Przywara        ECHO:=@echo
8436eaaf37SIan Spray        CHECKCODE_ARGS	+=	--no-summary --terse
854f6ad66aSAchin Guptaelse
86b169f6a9SEvan Lloyd        Q:=
87b5a0f4bdSAntonio Nino Diaz        ECHO:=$(ECHO_QUIET)
884f6ad66aSAchin Guptaendif
89ee1ba6d4SAndre Przywara
90ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
91ee1ba6d4SAndre Przywara        Q:=@
92b5a0f4bdSAntonio Nino Diaz        ECHO:=$(ECHO_QUIET)
93ee1ba6d4SAndre Przywaraendif
94ee1ba6d4SAndre Przywara
95ee1ba6d4SAndre Przywaraexport Q ECHO
962f2cef46SJeenu Viswambharan
9773c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the
9873c99d4eSJuan Castillo# target 'certificates' to create them all
9973c99d4eSJuan Castilloifneq (${GENERATE_COT},0)
10073c99d4eSJuan Castillo        FIP_DEPS += certificates
1010191262dSYatharth Kochar        FWU_FIP_DEPS += fwu_certificates
10273c99d4eSJuan Castilloendif
10373c99d4eSJuan Castillo
1049fc59639SAlexei Fedorov# Process BRANCH_PROTECTION value and set
1059fc59639SAlexei Fedorov# Pointer Authentication and Branch Target Identification flags
1069fc59639SAlexei Fedorovifeq (${BRANCH_PROTECTION},0)
1079fc59639SAlexei Fedorov	# Default value turns off all types of branch protection
1089fc59639SAlexei Fedorov	BP_OPTION := none
1099fc59639SAlexei Fedorovelse ifneq (${ARCH},aarch64)
1109fc59639SAlexei Fedorov        $(error BRANCH_PROTECTION requires AArch64)
1119fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},1)
1129fc59639SAlexei Fedorov	# Enables all types of branch protection features
1139fc59639SAlexei Fedorov	BP_OPTION := standard
1149fc59639SAlexei Fedorov	ENABLE_BTI := 1
1159fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1169fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},2)
1179fc59639SAlexei Fedorov	# Return address signing to its standard level
1189fc59639SAlexei Fedorov	BP_OPTION := pac-ret
1199fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1209fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},3)
1219fc59639SAlexei Fedorov	# Extend the signing to include leaf functions
1229fc59639SAlexei Fedorov	BP_OPTION := pac-ret+leaf
1239fc59639SAlexei Fedorov	ENABLE_PAUTH := 1
1243768fecfSAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},4)
1253768fecfSAlexei Fedorov	# Turn on branch target identification mechanism
1263768fecfSAlexei Fedorov	BP_OPTION := bti
1273768fecfSAlexei Fedorov	ENABLE_BTI := 1
1289fc59639SAlexei Fedorovelse
1299fc59639SAlexei Fedorov        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
1309fc59639SAlexei Fedorovendif
13173c99d4eSJuan Castillo
132c97cba4eSSoby Mathew# USE_SPINLOCK_CAS requires AArch64 build
133c97cba4eSSoby Mathewifeq (${USE_SPINLOCK_CAS},1)
134c97cba4eSSoby Mathewifneq (${ARCH},aarch64)
135c97cba4eSSoby Mathew        $(error USE_SPINLOCK_CAS requires AArch64)
136c97cba4eSSoby Mathewelse
137c97cba4eSSoby Mathew        $(info USE_SPINLOCK_CAS is an experimental feature)
138c97cba4eSSoby Mathewendif
139c97cba4eSSoby Mathewendif
140c97cba4eSSoby Mathew
1410ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds
1420ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1)
1430ca3913dSOlivier Deprezifeq (${DEBUG},1)
1440ca3913dSOlivier Deprez        $(warning DEBUGFS experimental feature is enabled.)
1450ca3913dSOlivier Deprezelse
1460ca3913dSOlivier Deprez        $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
1470ca3913dSOlivier Deprezendif
1480ca3913dSOlivier Deprezendif
1490ca3913dSOlivier Deprez
150c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
151c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS}
152c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY}
153c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE}
154c6ba9b45SSumit GargFIP_DEPS += enctool
155c6ba9b45SSumit GargFWU_FIP_DEPS += enctool
156c6ba9b45SSumit Gargendif
157c6ba9b45SSumit Garg
15873c99d4eSJuan Castillo################################################################################
15973c99d4eSJuan Castillo# Toolchain
16073c99d4eSJuan Castillo################################################################################
16173c99d4eSJuan Castillo
16272610c41Sdp-armHOSTCC			:=	gcc
16372610c41Sdp-armexport HOSTCC
16472610c41Sdp-arm
16573c99d4eSJuan CastilloCC			:=	${CROSS_COMPILE}gcc
16673c99d4eSJuan CastilloCPP			:=	${CROSS_COMPILE}cpp
16773c99d4eSJuan CastilloAS			:=	${CROSS_COMPILE}gcc
16873c99d4eSJuan CastilloAR			:=	${CROSS_COMPILE}ar
1692adee763SRoberto VargasLINKER			:=	${CROSS_COMPILE}ld
17073c99d4eSJuan CastilloOC			:=	${CROSS_COMPILE}objcopy
17173c99d4eSJuan CastilloOD			:=	${CROSS_COMPILE}objdump
17273c99d4eSJuan CastilloNM			:=	${CROSS_COMPILE}nm
17373c99d4eSJuan CastilloPP			:=	${CROSS_COMPILE}gcc -E
17438c14d88SSoby MathewDTC			:=	dtc
17573c99d4eSJuan Castillo
176b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
177b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \
1782adee763SRoberto Vargas	$(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
1792adee763SRoberto VargasLINKER			:=	${LINKER}.bfd
180b25a577fSJulius Wernerendif
181b25a577fSJulius Werner
18226e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
18326e63c44SEtienne Carrieretarget32-directive	= 	-target arm-none-eabi
18426e63c44SEtienne Carriere# Will set march32-directive from platform configuration
18526e63c44SEtienne Carriereelse
18626e63c44SEtienne Carrieretarget32-directive	= 	-target armv8a-none-eabi
187fa6f774bSAlexei Fedorov
188f1821790SAlexei Fedorov# Set the compiler's target architecture profile based on
189f1821790SAlexei Fedorov# ARM_ARCH_MAJOR ARM_ARCH_MINOR options
190fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0)
191f1821790SAlexei Fedorovmarch32-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
192f1821790SAlexei Fedorovmarch64-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
193fa6f774bSAlexei Fedorovelse
194f1821790SAlexei Fedorovmarch32-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
195f1821790SAlexei Fedorovmarch64-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
196fa6f774bSAlexei Fedorovendif
19726e63c44SEtienne Carriereendif
19826e63c44SEtienne Carriere
1997ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
2007ff088d1SManish V Badarkheifeq ($(ARCH), aarch64)
2014a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5
2024a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
2037ff088d1SManish V Badarkhemem_tag_arch_support	= 	yes
2047ff088d1SManish V Badarkheendif
2057ff088d1SManish V Badarkheendif
2067ff088d1SManish V Badarkhe
207f1821790SAlexei Fedorov# Get architecture feature modifiers
208f1821790SAlexei Fedorovarch-features		=	${ARM_ARCH_FEATURE}
209f1821790SAlexei Fedorov
210f1821790SAlexei Fedorov# Enable required options for memory stack tagging.
211f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler.
2127ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes)
2137ff088d1SManish V Badarkheifdef mem_tag_arch_support
214f1821790SAlexei Fedorov# Check for armclang and clang compilers
2157ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang))
216f1821790SAlexei Fedorov# Add "memtag" architecture feature modifier if not specified
217f1821790SAlexei Fedorovifeq ( ,$(findstring memtag,$(arch-features)))
218f1821790SAlexei Fedorovarch-features       	:=       $(arch-features)+memtag
219f1821790SAlexei Fedorovendif	# memtag
2207ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang)
2217ff088d1SManish V BadarkheTF_CFLAGS		+=	-mmemtag-stack
2227ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang)
2237ff088d1SManish V BadarkheTF_CFLAGS		+=	-fsanitize=memtag
224f1821790SAlexei Fedorovendif	# armclang
225f1821790SAlexei Fedorovendif	# armclang clang
2267ff088d1SManish V Badarkheelse
2277ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \
2287ff088d1SManish V Badarkhe	${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
229f1821790SAlexei Fedorovendif	# mem_tag_arch_support
230f1821790SAlexei Fedorovendif	# SUPPORT_STACK_MEMTAG
231f1821790SAlexei Fedorov
232f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers
233f1821790SAlexei Fedorovifneq ($(arch-features), none)
234f1821790SAlexei Fedorov# Strip "none+" from arch-features
235f1821790SAlexei Fedorovarch-features		:=	$(subst none+,,$(arch-features))
236f1821790SAlexei Fedorovifeq ($(ARCH), aarch32)
237f1821790SAlexei Fedorovmarch32-directive	:=	$(march32-directive)+$(arch-features)
238f1821790SAlexei Fedorovelse
239f1821790SAlexei Fedorovmarch64-directive	:=	$(march64-directive)+$(arch-features)
2407ff088d1SManish V Badarkheendif
241f1821790SAlexei Fedorov# Print features
242f1821790SAlexei Fedorov$(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
243f1821790SAlexei Fedorovendif	# arch-features
2447ff088d1SManish V Badarkhe
24512cd65e0STomas Pilar# Determine if FEAT_RNG is supported
24612cd65e0STomas PilarENABLE_FEAT_RNG		=	$(if $(findstring rng,${arch-features}),1,0)
24712cd65e0STomas Pilar
248*4e04478aSChris Kay# Determine if FEAT_SB is supported
249*4e04478aSChris KayENABLE_FEAT_SB		=	$(if $(findstring sb,${arch-features}),1,0)
250*4e04478aSChris Kay
251*4e04478aSChris Kayifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
252*4e04478aSChris KayENABLE_FEAT_SB		= 	1
253*4e04478aSChris Kayendif
254*4e04478aSChris Kay
255fd18a8fcSVarun Wadekarifneq ($(findstring armclang,$(notdir $(CC))),)
25626e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	-target arm-arm-none-eabi $(march32-directive)
257fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-arm-none-eabi $(march64-directive)
2582adee763SRoberto VargasLD			=	$(LINKER)
2591684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2607040155eSRoberto VargasCPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2617040155eSRoberto VargasPP			=	$(CC) -E $(TF_CFLAGS_$(ARCH))
2627559633bSdp-armelse ifneq ($(findstring clang,$(notdir $(CC))),)
263eff737c1SArve HjønnevågCLANG_CCDIR		=	$(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),)
264e2bfec0bSYann GautierTF_CFLAGS_aarch32	=	$(target32-directive) $(march32-directive)
265fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	-target aarch64-elf $(march64-directive)
266eff737c1SArve HjønnevågLD			=	$(CLANG_CCDIR)ld.lld
267641f16e7SAmbroise Vincentifeq (, $(shell which $(LD)))
268641f16e7SAmbroise Vincent$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker")
269641f16e7SAmbroise Vincentendif
2701684b873SRoberto VargasAS			=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
2717040155eSRoberto VargasCPP			=	$(CC) -E
2727040155eSRoberto VargasPP			=	$(CC) -E
273edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),)
274edbce9aaSzelalem-awekeTF_CFLAGS_aarch32	=	$(march32-directive)
275edbce9aaSzelalem-awekeTF_CFLAGS_aarch64	=	$(march64-directive)
276edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
277edbce9aaSzelalem-aweke	# Enable LTO only for aarch64
278edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
279edbce9aaSzelalem-aweke		LTO_CFLAGS	=	-flto
280edbce9aaSzelalem-aweke		# Use gcc as a wrapper for the ld, recommended for LTO
281edbce9aaSzelalem-aweke		LINKER		:=	${CROSS_COMPILE}gcc
282edbce9aaSzelalem-aweke	endif
283edbce9aaSzelalem-awekeendif
284edbce9aaSzelalem-awekeLD			=	$(LINKER)
285d5461857Sdp-armelse
28626e63c44SEtienne CarriereTF_CFLAGS_aarch32	=	$(march32-directive)
287fa6f774bSAlexei FedorovTF_CFLAGS_aarch64	=	$(march64-directive)
2882adee763SRoberto VargasLD			=	$(LINKER)
289d5461857Sdp-armendif
290d5461857Sdp-arm
29132b209bfSAhmad Fatoum# Process Debug flag
29232b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG))
29332b209bfSAhmad Fatoumifneq (${DEBUG}, 0)
29432b209bfSAhmad Fatoum        BUILD_TYPE	:=	debug
29532b209bfSAhmad Fatoum        TF_CFLAGS	+= 	-g
29632b209bfSAhmad Fatoum
29732b209bfSAhmad Fatoum        ifneq ($(findstring clang,$(notdir $(CC))),)
29832b209bfSAhmad Fatoum             ASFLAGS		+= 	-g
29932b209bfSAhmad Fatoum        else
30032b209bfSAhmad Fatoum             ASFLAGS		+= 	-g -Wa,--gdwarf-2
30132b209bfSAhmad Fatoum        endif
30232b209bfSAhmad Fatoum
30332b209bfSAhmad Fatoum        # Use LOG_LEVEL_INFO by default for debug builds
30432b209bfSAhmad Fatoum        LOG_LEVEL	:=	40
30532b209bfSAhmad Fatoumelse
30632b209bfSAhmad Fatoum        BUILD_TYPE	:=	release
30732b209bfSAhmad Fatoum        # Use LOG_LEVEL_NOTICE by default for release builds
30832b209bfSAhmad Fatoum        LOG_LEVEL	:=	20
30932b209bfSAhmad Fatoumendif
31032b209bfSAhmad Fatoum
311f1de4c8fSPeiyuan Song# Default build string (git branch and commit)
312f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},)
313f1de4c8fSPeiyuan Song        BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
314f1de4c8fSPeiyuan Songendif
315f1de4c8fSPeiyuan SongVERSION_STRING    :=  v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
316f1de4c8fSPeiyuan Song
3178fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32)
3188fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-marm
3198fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32)
3208fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32	+=	-mthumb
3218fd9d4d5SAntonio Nino Diazelse
3228fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
3238fd9d4d5SAntonio Nino Diazendif
3248fd9d4d5SAntonio Nino Diaz
325a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32	+=	-mno-unaligned-access
326d5461857Sdp-armTF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
3279d29c227SSoby Mathew
3289fc59639SAlexei Fedorovifneq (${BP_OPTION},none)
3299fc59639SAlexei FedorovTF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
3309fc59639SAlexei Fedorovendif
3319fc59639SAlexei Fedorov
33226e63c44SEtienne CarriereASFLAGS_aarch32		=	$(march32-directive)
333fa6f774bSAlexei FedorovASFLAGS_aarch64		=	$(march64-directive)
334b86048c4SAntonio Nino Diaz
3359ab81b5eSJustin Chadwell# General warnings
3369ab81b5eSJustin ChadwellWARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
337b7f6525dSJustin Chadwell				-Wdisabled-optimization	-Wvla -Wshadow	\
338ca661a00SMadhukar Pappireddy				-Wno-unused-parameter -Wredundant-decls
3399ab81b5eSJustin Chadwell
3409ab81b5eSJustin Chadwell# Additional warnings
3419ab81b5eSJustin Chadwell# Level 1
342e7c645b5SYann GautierWARNING1 := -Wextra
343e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute
344e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes
345e7c645b5SYann GautierWARNING1 += -Wold-style-definition
346e7c645b5SYann Gautier
347b7f6525dSJustin Chadwell# Level 2
348e7c645b5SYann GautierWARNING2 := -Waggregate-return
349e7c645b5SYann GautierWARNING2 += -Wcast-align
350e7c645b5SYann GautierWARNING2 += -Wnested-externs
351e7c645b5SYann Gautier
352e7c645b5SYann GautierWARNING3 := -Wbad-function-cast
353e7c645b5SYann GautierWARNING3 += -Wcast-qual
354e7c645b5SYann GautierWARNING3 += -Wconversion
355e7c645b5SYann GautierWARNING3 += -Wpacked
356e7c645b5SYann GautierWARNING3 += -Wpointer-arith
357e7c645b5SYann GautierWARNING3 += -Wswitch-default
358e7c645b5SYann Gautier
359e7c645b5SYann Gautierifeq (${W},1)
3609ab81b5eSJustin ChadwellWARNINGS += $(WARNING1)
361e7c645b5SYann Gautierelse ifeq (${W},2)
3629ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2)
363e7c645b5SYann Gautierelse ifeq (${W},3)
3649ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
365e7c645b5SYann Gautierendif
366e7c645b5SYann Gautier
3679ab81b5eSJustin Chadwell# Compiler specific warnings
36800296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),)
36993c690ebSJustin Chadwell# not using clang
370d7b4cd41SJustin ChadwellWARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
371d7b4cd41SJustin Chadwell				-Wpacked-bitfield-compat -Wshift-overflow=2 \
372d7b4cd41SJustin Chadwell				-Wlogical-op
37393c690ebSJustin Chadwellelse
37493c690ebSJustin Chadwell# using clang
375d7b4cd41SJustin ChadwellWARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
376d7b4cd41SJustin Chadwell				-Wlogical-op-parentheses
37700296576SAmbroise Vincentendif
37800296576SAmbroise Vincent
3796336b07aSYann Gautierifneq (${E},0)
3806336b07aSYann GautierERRORS := -Werror
3816336b07aSYann Gautierendif
3826336b07aSYann Gautier
383ea7a57a3SRoberto VargasCPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
3849ab81b5eSJustin Chadwell				$(ERRORS) $(WARNINGS)
38559de5096SMasahiro YamadaASFLAGS			+=	$(CPPFLAGS) $(ASFLAGS_$(ARCH))			\
386d5dfdeb6SJulius Werner				-ffreestanding -Wa,--fatal-warnings
38759de5096SMasahiro YamadaTF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
388ebd6efaeSSamuel Holland				-ffunction-sections -fdata-sections		\
389ebd6efaeSSamuel Holland				-ffreestanding -fno-builtin -fno-common		\
390ebd6efaeSSamuel Holland				-Os -std=gnu99
39173c99d4eSJuan Castillo
3921f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
3931f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover
3941f461979SJustin Chadwellendif
3951f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
3961f461979SJustin ChadwellTF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover	\
3971f461979SJustin Chadwell				-fsanitize-undefined-trap-on-error
3981f461979SJustin Chadwellendif
3991f461979SJustin Chadwell
400f7ec31dbSdavid cunadoGCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
401f7ec31dbSdavid cunado
402641f16e7SAmbroise Vincent# LD = armlink
403c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
404c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
405c2ad38ceSVarun WadekarTF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
406edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
407641f16e7SAmbroise Vincent
408641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled)
409edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),)
410edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches
411edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
412edbce9aaSzelalem-awekeTF_LDFLAGS		+=	-Wl,--gc-sections
413edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1)
414edbce9aaSzelalem-aweke	ifeq (${ARCH},aarch64)
415edbce9aaSzelalem-aweke		TF_LDFLAGS	+=	-flto -fuse-linker-plugin
416edbce9aaSzelalem-aweke	endif
417edbce9aaSzelalem-awekeendif
418edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link
419edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled
420edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1)
421edbce9aaSzelalem-aweke	TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
422edbce9aaSzelalem-awekeendif
423edbce9aaSzelalem-awekeTF_LDFLAGS		+= 	-nostdlib
424edbce9aaSzelalem-awekeTF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
425641f16e7SAmbroise Vincent
426641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
427c2ad38ceSVarun Wadekarelse
428c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--fatal-warnings -O1
429c2b8806fSDouglas RaillardTF_LDFLAGS		+=	--gc-sections
430641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags,
431641f16e7SAmbroise Vincent# therefore don't add those in that case
432641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),)
433c2b8806fSDouglas RaillardTF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
434edbce9aaSzelalem-awekeendif
435641f16e7SAmbroise Vincentendif
43673c99d4eSJuan Castillo
43703b397a8SNishanth MenonDTC_FLAGS		+=	-I dts -O dtb
438a6de824fSLouis MayencourtDTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
439a6de824fSLouis Mayencourt				-x assembler-with-cpp $(DEFINES)
44003b397a8SNishanth Menon
4410ab49645SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
4420ab49645SAlexei FedorovDTC_CPPFLAGS		+=	-DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE}
4430ab49645SAlexei Fedorovendif
4440ab49645SAlexei Fedorov
44573c99d4eSJuan Castillo################################################################################
44673c99d4eSJuan Castillo# Common sources and include directories
44773c99d4eSJuan Castillo################################################################################
448d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk
44973c99d4eSJuan Castillo
45073c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
4517f56e9a3SSoby Mathew				common/tf_log.c				\
4529d29c227SSoby Mathew				common/${ARCH}/debug.S			\
45391b48c9fSJulius Werner				drivers/console/multi_console.c		\
4549d29c227SSoby Mathew				lib/${ARCH}/cache_helpers.S		\
4559d29c227SSoby Mathew				lib/${ARCH}/misc_helpers.S		\
456566034fcSSoby Mathew				plat/common/plat_bl_common.c		\
4577f56e9a3SSoby Mathew				plat/common/plat_log_common.c		\
45875311203Sdp-arm				plat/common/${ARCH}/plat_common.c	\
4599d29c227SSoby Mathew				plat/common/${ARCH}/platform_helpers.S	\
46061f72a34SRoberto Vargas				${COMPILER_RT_SRCS}
461d7a6b0f8SRyan Harkin
4628422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang)
4638422a840SAntonio Nino DiazBL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
4648422a840SAntonio Nino Diazendif
4658422a840SAntonio Nino Diaz
4661f461979SJustin Chadwellifeq (${SANITIZE_UB},on)
4671f461979SJustin ChadwellBL_COMMON_SOURCES	+=	plat/common/ubsan.c
4681f461979SJustin Chadwellendif
4691f461979SJustin Chadwell
47001d237cbSYann GautierINCLUDES		+=	-Iinclude				\
471f5478dedSAntonio Nino Diaz				-Iinclude/arch/${ARCH}			\
47209d40e0eSAntonio Nino Diaz				-Iinclude/lib/cpus/${ARCH}		\
47309d40e0eSAntonio Nino Diaz				-Iinclude/lib/el3_runtime/${ARCH}	\
47409d40e0eSAntonio Nino Diaz				${PLAT_INCLUDES}			\
47509d40e0eSAntonio Nino Diaz				${SPD_INCLUDES}
47609d40e0eSAntonio Nino Diaz
4779c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk
4789c6d1c50SAntonio Nino Diaz
47973c99d4eSJuan Castillo################################################################################
48073c99d4eSJuan Castillo# Generic definitions
48173c99d4eSJuan Castillo################################################################################
48273c99d4eSJuan Castillo
483231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
484231c1470SEvan Lloyd
48529214e95SGrant Likelyifeq (${BUILD_BASE},)
48673c99d4eSJuan Castillo     BUILD_BASE		:=	./build
48729214e95SGrant Likelyendif
48829214e95SGrant LikelyBUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
48973c99d4eSJuan Castillo
490231c1470SEvan LloydSPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
49173c99d4eSJuan Castillo
49273c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
49373c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
49473c99d4eSJuan Castillo
49573c99d4eSJuan Castillo
49673c99d4eSJuan Castillo################################################################################
49773c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
49873c99d4eSJuan Castillo################################################################################
49973c99d4eSJuan Castillo
50073c99d4eSJuan Castilloifneq (${SPD},none)
5019d29c227SSoby Mathew    ifeq (${ARCH},aarch32)
5029d29c227SSoby Mathew        $(error "Error: SPD is incompatible with AArch32.")
5039d29c227SSoby Mathew    endif
50428f39f02SMax Shvetsov
5054c117f6cSSandrine Bailleux    ifdef EL3_PAYLOAD_BASE
5064c117f6cSSandrine Bailleux        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
5074c117f6cSSandrine Bailleux        $(warning "The SPD and its BL32 companion will be present but ignored.")
5084c117f6cSSandrine Bailleux    endif
50928f39f02SMax Shvetsov
510c3fb00d9SAchin Gupta    ifeq (${SPD},spmd)
511033039f8SMax Shvetsov        $(warning "SPMD is an experimental feature")
512c3fb00d9SAchin Gupta        # SPMD is located in std_svc directory
513c3fb00d9SAchin Gupta        SPD_DIR := std_svc
51428f39f02SMax Shvetsov
515033039f8SMax Shvetsov        ifeq ($(SPMD_SPM_AT_SEL2),1)
51628f39f02SMax Shvetsov            ifeq ($(CTX_INCLUDE_EL2_REGS),0)
517033039f8SMax Shvetsov                $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
518033039f8SMax Shvetsov            endif
51928f39f02SMax Shvetsov        endif
520db1ef41aSOlivier Deprez
521db1ef41aSOlivier Deprez        ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
522db1ef41aSOlivier Deprez            DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
523db1ef41aSOlivier Deprez        endif
524c3fb00d9SAchin Gupta    else
525c3fb00d9SAchin Gupta        # All other SPDs in spd directory
526c3fb00d9SAchin Gupta        SPD_DIR := spd
527c3fb00d9SAchin Gupta    endif
528c3fb00d9SAchin Gupta
52973c99d4eSJuan Castillo    # We expect to locate an spd.mk under the specified SPD directory
530c3fb00d9SAchin Gupta    SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
531c3fb00d9SAchin Gupta
53273c99d4eSJuan Castillo    ifeq (${SPD_MAKE},)
533c3fb00d9SAchin Gupta        $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
53473c99d4eSJuan Castillo    endif
53573c99d4eSJuan Castillo    $(info Including ${SPD_MAKE})
53673c99d4eSJuan Castillo    include ${SPD_MAKE}
53773c99d4eSJuan Castillo
53870d1fc53SJuan Castillo    # If there's BL32 companion for the chosen SPD, we expect that the SPD's
53970d1fc53SJuan Castillo    # Makefile would set NEED_BL32 to "yes". In this case, the build system
54070d1fc53SJuan Castillo    # supports two mutually exclusive options:
54170d1fc53SJuan Castillo    # * BL32 is built from source: then BL32_SOURCES must contain the list
54270d1fc53SJuan Castillo    #   of source files to build BL32
54370d1fc53SJuan Castillo    # * BL32 is a prebuilt binary: then BL32 must point to the image file
54470d1fc53SJuan Castillo    #   that will be included in the FIP
54570d1fc53SJuan Castillo    # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
54670d1fc53SJuan Castillo    # over the sources.
547e35c4045SJeenu Viswambharanendif
548e35c4045SJeenu Viswambharan
54951faada7SDouglas Raillard################################################################################
55073c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
55173c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
55273c99d4eSJuan Castillo################################################################################
5532da8d8bfSJeenu Viswambharan
55473c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
5550f21c547SJuan Castillo
5568012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
5578012cc5cSMasahiro Yamada
55826e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7)
55926e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk
56026e63c44SEtienne Carriereendif
56126e63c44SEtienne Carriere
5623bd17c0fSSoby MathewPIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
5633bd17c0fSSoby Mathewifneq ($(PIE_FOUND),)
5643bd17c0fSSoby Mathew	TF_CFLAGS	+=	-fno-PIE
5653bd17c0fSSoby Mathewendif
566320920c1SMasahiro Yamada
567320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),)
568320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
569320920c1SMasahiro Yamadaelse
570320920c1SMasahiro Yamada	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
571320920c1SMasahiro Yamadaendif
572320920c1SMasahiro Yamada
573320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1)
57469af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
57569af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1)
57669af7fcfSMasahiro Yamada	BL2_CFLAGS	+=	-fpie
57769af7fcfSMasahiro Yamada	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
57869af7fcfSMasahiro Yamadaendif
57969af7fcfSMasahiro Yamadaendif
580320920c1SMasahiro Yamada	BL31_CFLAGS	+=	-fpie
581320920c1SMasahiro Yamada	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
582d974301dSMasahiro Yamadaifeq ($(ARCH),aarch64)
583d974301dSMasahiro Yamada	BL32_CFLAGS	+=	-fpie
584d974301dSMasahiro Yamada	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
585d974301dSMasahiro Yamadaendif
5863bd17c0fSSoby Mathewendif
5873bd17c0fSSoby Mathew
588d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64)
5899cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3
590d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1)
5919cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3
592d5e97a1dSMasahiro Yamadaelse
5939cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1
594d5e97a1dSMasahiro Yamadaendif
5959cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1
5969cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3
5979cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1
598d5e97a1dSMasahiro Yamadaendif
599d5e97a1dSMasahiro Yamada
60054035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
60154035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
60254035fc4SSandrine Bailleux# This can be overridden by the platform.
60373c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
6044f6ad66aSAchin Gupta
605a4409008Sdp-armifeq (${ARCH},aarch32)
606a4409008Sdp-armNEED_BL32 := yes
607a4409008Sdp-arm
608a4409008Sdp-arm################################################################################
609a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32
610a4409008Sdp-arm################################################################################
611a4409008Sdp-armifneq (${AARCH32_SP},none)
612a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory
613a4409008Sdp-armAARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
614a4409008Sdp-arm
615a4409008Sdp-armifeq (${AARCH32_SP_MAKE},)
616a4409008Sdp-arm  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
617a4409008Sdp-armendif
618a4409008Sdp-arm
619a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE})
620a4409008Sdp-arminclude ${AARCH32_SP_MAKE}
621a4409008Sdp-armendif
622a4409008Sdp-arm
623a4409008Sdp-armendif
6244f6ad66aSAchin Gupta
62573c99d4eSJuan Castillo################################################################################
62677f1f7a1SVarun Wadekar# Include libc if not overridden
62777f1f7a1SVarun Wadekar################################################################################
62877f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0)
62977f1f7a1SVarun Wadekarinclude lib/libc/libc.mk
63077f1f7a1SVarun Wadekarendif
63177f1f7a1SVarun Wadekar
63277f1f7a1SVarun Wadekar################################################################################
633cf2c8a33SAntonio Nino Diaz# Check incompatible options
634cf2c8a33SAntonio Nino Diaz################################################################################
635cf2c8a33SAntonio Nino Diaz
636cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE
63768450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
63868450a6dSAntonio Nino Diaz                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
63968450a6dSAntonio Nino Diaz                incompatible build options. EL3_PAYLOAD_BASE has priority.")
640cf2c8a33SAntonio Nino Diaz        endif
64176580f3dSQixiang Xu        ifneq (${GENERATE_COT},0)
64276580f3dSQixiang Xu                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
64376580f3dSQixiang Xu        endif
64476580f3dSQixiang Xu        ifneq (${TRUSTED_BOARD_BOOT},0)
64576580f3dSQixiang Xu                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
64676580f3dSQixiang Xu        endif
647cf2c8a33SAntonio Nino Diazendif
648cf2c8a33SAntonio Nino Diaz
649cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes)
650cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
651cf2c8a33SAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
652cf2c8a33SAntonio Nino Diaz                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
653cf2c8a33SAntonio Nino Diaz        endif
65468450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
65568450a6dSAntonio Nino Diaz                $(warning "BL33 image is not needed when option \
65668450a6dSAntonio Nino Diaz                PRELOADED_BL33_BASE is used and won't be added to the FIP \
65768450a6dSAntonio Nino Diaz                file.")
658cf2c8a33SAntonio Nino Diaz        endif
659cf2c8a33SAntonio Nino Diazendif
660cf2c8a33SAntonio Nino Diaz
661d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to
662d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
663d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
664d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
665d4593e47SJeenu Viswambharanendif
6661a0a3f06SYatharth Kochar
6677d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
6687d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
6697d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
6707d173fc5SJiafei Panendif
6717d173fc5SJiafei Pan
67214c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first
67314c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1)
67414c6016aSJeenu Viswambharan    ifneq ($(HANDLE_EA_EL3_FIRST),1)
67514c6016aSJeenu Viswambharan        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1)
67614c6016aSJeenu Viswambharan    endif
67714c6016aSJeenu Viswambharanendif
67814c6016aSJeenu Viswambharan
6791a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
6801a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1)
6811a7c1cfeSJeenu Viswambharan    ifneq ($(RAS_EXTENSION),1)
6821a7c1cfeSJeenu Viswambharan        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
6831a7c1cfeSJeenu Viswambharan    endif
6841a7c1cfeSJeenu Viswambharanendif
6851a7c1cfeSJeenu Viswambharan
686ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
687209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1)
688209a60ccSSoby Mathew    ifeq (${TRUSTED_BOARD_BOOT}, 0)
689209a60ccSSoby Mathew        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
690209a60ccSSoby Mathew    endif
691209a60ccSSoby Mathewendif
692209a60ccSSoby Mathew
693cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
694cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
695cbf9e84aSBalint Dobszay$(error "SDEI_IN_FCONF is an experimental feature and is only supported when \
696cbf9e84aSBalint Dobszay	SDEI_SUPPORT is enabled")
697cbf9e84aSBalint Dobszayendif
698cbf9e84aSBalint Dobszay
69984ef9cd8SManish V Badarkheifeq ($(COT_DESC_IN_DTB),1)
70084ef9cd8SManish V Badarkhe    $(info CoT in device tree is an experimental feature)
70184ef9cd8SManish V Badarkheendif
70284ef9cd8SManish V Badarkhe
703b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the
7049fc59639SAlexei Fedorov# registers associated to it are also saved and restored.
7059fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
706b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1)
7079fc59639SAlexei Fedorov    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
7089fc59639SAlexei Fedorov        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
70906715f85SAlexei Fedorov    endif
7109fc59639SAlexei Fedorovendif
7119fc59639SAlexei Fedorov
71206715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
7139fc59639SAlexei Fedorov    ifneq (${ARCH},aarch64)
7149fc59639SAlexei Fedorov        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
715dfc66a17SJohn Tsichritzis    else
71606715f85SAlexei Fedorov        $(info CTX_INCLUDE_PAUTH_REGS is an experimental feature)
717b86048c4SAntonio Nino Diaz    endif
718b86048c4SAntonio Nino Diazendif
7199fc59639SAlexei Fedorov
7209fc59639SAlexei Fedorovifeq ($(ENABLE_PAUTH),1)
7219fc59639SAlexei Fedorov    $(info Pointer Authentication is an experimental feature)
7229fc59639SAlexei Fedorovendif
7239fc59639SAlexei Fedorov
7249fc59639SAlexei Fedorovifeq ($(ENABLE_BTI),1)
7259fc59639SAlexei Fedorov    $(info Branch Protection is an experimental feature)
726dfc66a17SJohn Tsichritzisendif
727b86048c4SAntonio Nino Diaz
7289dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1)
7299dd94382SJustin Chadwell    ifneq (${ARCH},aarch64)
7309dd94382SJustin Chadwell        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
7319dd94382SJustin Chadwell    else
7329dd94382SJustin Chadwell        $(info CTX_INCLUDE_MTE_REGS is an experimental feature)
7339dd94382SJustin Chadwell    endif
7349dd94382SJustin Chadwellendif
7359dd94382SJustin Chadwell
7368c105290SAlexei Fedorovifeq ($(MEASURED_BOOT),1)
7378c105290SAlexei Fedorov    ifneq (${TRUSTED_BOARD_BOOT},1)
7387cda17bbSSumit Garg        $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1)
7398c105290SAlexei Fedorov    else
7408c105290SAlexei Fedorov        $(info MEASURED_BOOT is an experimental feature)
7418c105290SAlexei Fedorov    endif
7428c105290SAlexei Fedorovendif
7438c105290SAlexei Fedorov
74460e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
74560e8f3cfSPetre-Ionut Tudor    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
74660e8f3cfSPetre-Ionut Tudor        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
74760e8f3cfSPetre-Ionut Tudor    endif
74860e8f3cfSPetre-Ionut Tudorendif
74960e8f3cfSPetre-Ionut Tudor
7507cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none)
7517cda17bbSSumit Garg    ifeq (${TRUSTED_BOARD_BOOT}, 0)
7527cda17bbSSumit Garg        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
7537cda17bbSSumit Garg    else
7547cda17bbSSumit Garg        $(info DECRYPTION_SUPPORT is an experimental feature)
7557cda17bbSSumit Garg    endif
7567cda17bbSSumit Gargendif
7577cda17bbSSumit Garg
758cf2c8a33SAntonio Nino Diaz################################################################################
75973c99d4eSJuan Castillo# Process platform overrideable behaviour
76073c99d4eSJuan Castillo################################################################################
7614f6ad66aSAchin Gupta
762bd97f83aSJohn Tsichritzis# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
763bd97f83aSJohn Tsichritzis# Certificate generation tools. This flag can be overridden by the platform.
76473c99d4eSJuan Castilloifdef BL2_SOURCES
765cf2c8a33SAntonio Nino Diaz        ifdef EL3_PAYLOAD_BASE
766cf2c8a33SAntonio Nino Diaz                # If booting an EL3 payload there is no need for a BL33 image
767cf2c8a33SAntonio Nino Diaz                # in the FIP file.
7684c117f6cSSandrine Bailleux                NEED_BL33		:=	no
769cf2c8a33SAntonio Nino Diaz        else
77068450a6dSAntonio Nino Diaz                ifdef PRELOADED_BL33_BASE
771cf2c8a33SAntonio Nino Diaz                        # If booting a BL33 preloaded image there is no need of
772cf2c8a33SAntonio Nino Diaz                        # another one in the FIP file.
773cf2c8a33SAntonio Nino Diaz                        NEED_BL33		:=	no
774cf2c8a33SAntonio Nino Diaz                else
775cf2c8a33SAntonio Nino Diaz                        NEED_BL33		?=	yes
776cf2c8a33SAntonio Nino Diaz                endif
7774c117f6cSSandrine Bailleux        endif
77873c99d4eSJuan Castilloendif
7796f971622SJuan Castillo
7804d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it.
7814d045d0eSMasahiro Yamadaifdef SCP_BL2
7824d045d0eSMasahiro Yamada        NEED_SCP_BL2		:=	yes
7834d045d0eSMasahiro Yamadaendif
7844d045d0eSMasahiro Yamada
7855744e874SSoby Mathew# For AArch32, BL31 is not currently supported.
7865744e874SSoby Mathewifneq (${ARCH},aarch32)
7875744e874SSoby Mathew    ifdef BL31_SOURCES
7885744e874SSoby Mathew        # When booting an EL3 payload, there is no need to compile the BL31 image nor
7895744e874SSoby Mathew        # put it in the FIP.
7905744e874SSoby Mathew        ifndef EL3_PAYLOAD_BASE
7915744e874SSoby Mathew            NEED_BL31 := yes
7925744e874SSoby Mathew        endif
7935744e874SSoby Mathew    endif
7945744e874SSoby Mathewendif
7955744e874SSoby Mathew
79673c99d4eSJuan Castillo# Process TBB related flags
7976f971622SJuan Castilloifneq (${GENERATE_COT},0)
79873c99d4eSJuan Castillo        # Common cert_create options
7996f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
8006f971622SJuan Castillo                $(eval CRT_ARGS += -n)
8010191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
802fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
803fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
8040191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
805fd34e7baSJuan Castillo                endif
8066f971622SJuan Castillo        endif
80773c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
80873c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
80973c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
81073c99d4eSJuan Castillo        endif
8116f971622SJuan Castilloendif
8126f971622SJuan Castillo
8131c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0)
8141c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN}
8151c75d5dfSMasahiro Yamadaendif
8161c75d5dfSMasahiro Yamada
81773c99d4eSJuan Castillo################################################################################
81846e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL
81946e5e035SMichalis Pappas################################################################################
82046e5e035SMichalis Pappas
82146e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk
82246e5e035SMichalis Pappas
82346e5e035SMichalis Pappas################################################################################
824819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc)
82573c99d4eSJuan Castillo################################################################################
82673c99d4eSJuan Castillo
82773c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
82873c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
82942a45b51SEvan LloydCRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
83073c99d4eSJuan Castillo
83190aa901fSSumit Garg# Variables for use with Firmware Encryption Tool
83290aa901fSSumit GargENCTOOLPATH		?=	tools/encrypt_fw
83390aa901fSSumit GargENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
83490aa901fSSumit Garg
83573c99d4eSJuan Castillo# Variables for use with Firmware Image Package
836819281eeSdp-armFIPTOOLPATH		?=	tools/fiptool
837819281eeSdp-armFIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
83873c99d4eSJuan Castillo
83926010da1SAntonio Nino Diaz# Variables for use with sptool
84026010da1SAntonio Nino DiazSPTOOLPATH		?=	tools/sptool
84126010da1SAntonio Nino DiazSPTOOL			?=	${SPTOOLPATH}/sptool${BIN_EXT}
842ce2b1ec6SManish PandeySP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
84326010da1SAntonio Nino Diaz
8445accce5bSRoberto Vargas# Variables for use with ROMLIB
8455accce5bSRoberto VargasROMLIBPATH		?=	lib/romlib
8465accce5bSRoberto Vargas
847cfe83910SLouis Mayencourt# Variable for use with Python
848cfe83910SLouis MayencourtPYTHON			?=	python3
849cfe83910SLouis Mayencourt
850cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP
851cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH		?=	tools/memory
852cfe83910SLouis MayencourtPRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
853cfe83910SLouis Mayencourt
8546de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool
8556de32378SMadhukar PappireddyDOCS_PATH		?=	docs
8566de32378SMadhukar Pappireddy
8578a86052dSSoby Mathew################################################################################
8588a86052dSSoby Mathew# Include BL specific makefiles
8598a86052dSSoby Mathew################################################################################
8608a86052dSSoby Mathewifdef BL1_SOURCES
8618a86052dSSoby MathewNEED_BL1 := yes
8628a86052dSSoby Mathewinclude bl1/bl1.mk
8638a86052dSSoby Mathewendif
8648a86052dSSoby Mathew
8658a86052dSSoby Mathewifdef BL2_SOURCES
8668a86052dSSoby MathewNEED_BL2 := yes
8678a86052dSSoby Mathewinclude bl2/bl2.mk
8688a86052dSSoby Mathewendif
8698a86052dSSoby Mathew
8708a86052dSSoby Mathewifdef BL2U_SOURCES
8718a86052dSSoby MathewNEED_BL2U := yes
8728a86052dSSoby Mathewinclude bl2u/bl2u.mk
8738a86052dSSoby Mathewendif
8748a86052dSSoby Mathew
8755744e874SSoby Mathewifeq (${NEED_BL31},yes)
8768a86052dSSoby Mathewifdef BL31_SOURCES
8778a86052dSSoby Mathewinclude bl31/bl31.mk
8788a86052dSSoby Mathewendif
8798a86052dSSoby Mathewendif
8808a86052dSSoby Mathew
88103b397a8SNishanth Menonifdef FDT_SOURCES
88203b397a8SNishanth MenonNEED_FDT := yes
88303b397a8SNishanth Menonendif
88403b397a8SNishanth Menon
88573c99d4eSJuan Castillo################################################################################
88673c99d4eSJuan Castillo# Build options checks
88773c99d4eSJuan Castillo################################################################################
88873c99d4eSJuan Castillo
889327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\
890327131c4SLeonardo Sandoval    $(sort \
891327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
892327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
893327131c4SLeonardo Sandoval        CREATE_KEYS \
894327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
895327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
896327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
897327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
898327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
899062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
900327131c4SLeonardo Sandoval        DEBUG \
9010063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
902327131c4SLeonardo Sandoval        DYN_DISABLE_AUTH \
903327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
904327131c4SLeonardo Sandoval        ENABLE_AMU \
905873d4241Sjohpow01        AMU_RESTRICT_COUNTERS \
906327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
907327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
908327131c4SLeonardo Sandoval        ENABLE_PIE \
909327131c4SLeonardo Sandoval        ENABLE_PMF \
910327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
911327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
912327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
913327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
914327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
915327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
916327131c4SLeonardo Sandoval        GENERATE_COT \
917327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
918327131c4SLeonardo Sandoval        HANDLE_EA_EL3_FIRST \
919327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
920327131c4SLeonardo Sandoval        INVERTED_MEMMAP \
921327131c4SLeonardo Sandoval        MEASURED_BOOT \
922327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
923327131c4SLeonardo Sandoval        OVERRIDE_LIBC \
924327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
925327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
926327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
927327131c4SLeonardo Sandoval        RAS_EXTENSION \
928327131c4SLeonardo Sandoval        RESET_TO_BL31 \
929327131c4SLeonardo Sandoval        SAVE_KEYS \
930327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
931327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
932327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
933327131c4SLeonardo Sandoval        SPM_MM \
934327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
935327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
936327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
937327131c4SLeonardo Sandoval        USE_DEBUGFS \
938327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
939327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
940327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
941327131c4SLeonardo Sandoval        USE_ROMLIB \
942327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
943327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
944327131c4SLeonardo Sandoval        BL2_AT_EL3 \
945327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
946327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
947327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
948327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
949327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
950327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
951327131c4SLeonardo Sandoval        RAS_TRAP_LOWER_EL_ERR_ACCESS \
952327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
953327131c4SLeonardo Sandoval        USE_SP804_TIMER \
95412cd65e0STomas Pilar        ENABLE_FEAT_RNG \
955*4e04478aSChris Kay        ENABLE_FEAT_SB \
956327131c4SLeonardo Sandoval)))
95773c99d4eSJuan Castillo
958327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\
959327131c4SLeonardo Sandoval    $(sort \
960327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
961327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
962327131c4SLeonardo Sandoval        BRANCH_PROTECTION \
963327131c4SLeonardo Sandoval        FW_ENC_STATUS \
964327131c4SLeonardo Sandoval)))
965c877b414SJeenu Viswambharan
966aacff749SJustin Chadwellifdef KEY_SIZE
967aacff749SJustin Chadwell        $(eval $(call assert_numeric,KEY_SIZE))
968aacff749SJustin Chadwellendif
969aacff749SJustin Chadwell
9701f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),)
9711f461979SJustin Chadwell        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
9721f461979SJustin Chadwellendif
9731f461979SJustin Chadwell
97473c99d4eSJuan Castillo################################################################################
97573c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
97673c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
97773c99d4eSJuan Castillo# platform to overwrite the default options
97873c99d4eSJuan Castillo################################################################################
97973c99d4eSJuan Castillo
980327131c4SLeonardo Sandoval$(eval $(call add_defines,\
981327131c4SLeonardo Sandoval    $(sort \
982327131c4SLeonardo Sandoval        ALLOW_RO_XLAT_TABLES \
983327131c4SLeonardo Sandoval        ARM_ARCH_MAJOR \
984327131c4SLeonardo Sandoval        ARM_ARCH_MINOR \
985327131c4SLeonardo Sandoval        COLD_BOOT_SINGLE_CPU \
986327131c4SLeonardo Sandoval        CTX_INCLUDE_AARCH32_REGS \
987327131c4SLeonardo Sandoval        CTX_INCLUDE_FPREGS \
988327131c4SLeonardo Sandoval        CTX_INCLUDE_PAUTH_REGS \
989327131c4SLeonardo Sandoval        EL3_EXCEPTION_HANDLING \
990327131c4SLeonardo Sandoval        CTX_INCLUDE_MTE_REGS \
991327131c4SLeonardo Sandoval        CTX_INCLUDE_EL2_REGS \
992062f8aafSArunachalam Ganapathy        CTX_INCLUDE_NEVE_REGS \
993327131c4SLeonardo Sandoval        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
9940063dd17SJavier Almansa Sobrino        DISABLE_MTPMU \
995327131c4SLeonardo Sandoval        ENABLE_AMU \
996873d4241Sjohpow01        AMU_RESTRICT_COUNTERS \
997327131c4SLeonardo Sandoval        ENABLE_ASSERTIONS \
998327131c4SLeonardo Sandoval        ENABLE_BTI \
999327131c4SLeonardo Sandoval        ENABLE_MPAM_FOR_LOWER_ELS \
1000327131c4SLeonardo Sandoval        ENABLE_PAUTH \
1001327131c4SLeonardo Sandoval        ENABLE_PIE \
1002327131c4SLeonardo Sandoval        ENABLE_PMF \
1003327131c4SLeonardo Sandoval        ENABLE_PSCI_STAT \
1004327131c4SLeonardo Sandoval        ENABLE_RUNTIME_INSTRUMENTATION \
1005327131c4SLeonardo Sandoval        ENABLE_SPE_FOR_LOWER_ELS \
1006327131c4SLeonardo Sandoval        ENABLE_SVE_FOR_NS \
1007327131c4SLeonardo Sandoval        ENCRYPT_BL31 \
1008327131c4SLeonardo Sandoval        ENCRYPT_BL32 \
1009327131c4SLeonardo Sandoval        ERROR_DEPRECATED \
1010327131c4SLeonardo Sandoval        FAULT_INJECTION_SUPPORT \
1011327131c4SLeonardo Sandoval        GICV2_G0_FOR_EL3 \
1012327131c4SLeonardo Sandoval        HANDLE_EA_EL3_FIRST \
1013327131c4SLeonardo Sandoval        HW_ASSISTED_COHERENCY \
1014327131c4SLeonardo Sandoval        LOG_LEVEL \
1015327131c4SLeonardo Sandoval        MEASURED_BOOT \
1016327131c4SLeonardo Sandoval        NS_TIMER_SWITCH \
1017327131c4SLeonardo Sandoval        PL011_GENERIC_UART \
1018327131c4SLeonardo Sandoval        PLAT_${PLAT} \
1019327131c4SLeonardo Sandoval        PROGRAMMABLE_RESET_ADDRESS \
1020327131c4SLeonardo Sandoval        PSCI_EXTENDED_STATE_ID \
1021327131c4SLeonardo Sandoval        RAS_EXTENSION \
1022327131c4SLeonardo Sandoval        RESET_TO_BL31 \
1023327131c4SLeonardo Sandoval        SEPARATE_CODE_AND_RODATA \
1024327131c4SLeonardo Sandoval        SEPARATE_NOBITS_REGION \
1025327131c4SLeonardo Sandoval        RECLAIM_INIT_CODE \
1026327131c4SLeonardo Sandoval        SPD_${SPD} \
1027327131c4SLeonardo Sandoval        SPIN_ON_BL1_EXIT \
1028327131c4SLeonardo Sandoval        SPM_MM \
1029327131c4SLeonardo Sandoval        SPMD_SPM_AT_SEL2 \
1030327131c4SLeonardo Sandoval        TRUSTED_BOARD_BOOT \
10317dfb9911SJimmy Brisson        TRNG_SUPPORT \
1032327131c4SLeonardo Sandoval        USE_COHERENT_MEM \
1033327131c4SLeonardo Sandoval        USE_DEBUGFS \
1034327131c4SLeonardo Sandoval        ARM_IO_IN_DTB \
1035327131c4SLeonardo Sandoval        SDEI_IN_FCONF \
1036327131c4SLeonardo Sandoval        SEC_INT_DESC_IN_FCONF \
1037327131c4SLeonardo Sandoval        USE_ROMLIB \
1038327131c4SLeonardo Sandoval        USE_TBBR_DEFS \
1039327131c4SLeonardo Sandoval        WARMBOOT_ENABLE_DCACHE_EARLY \
1040327131c4SLeonardo Sandoval        BL2_AT_EL3 \
1041327131c4SLeonardo Sandoval        BL2_IN_XIP_MEM \
1042327131c4SLeonardo Sandoval        BL2_INV_DCACHE \
1043327131c4SLeonardo Sandoval        USE_SPINLOCK_CAS \
1044327131c4SLeonardo Sandoval        ERRATA_SPECULATIVE_AT \
1045327131c4SLeonardo Sandoval        RAS_TRAP_LOWER_EL_ERR_ACCESS \
1046327131c4SLeonardo Sandoval        COT_DESC_IN_DTB \
1047327131c4SLeonardo Sandoval        USE_SP804_TIMER \
104812cd65e0STomas Pilar        ENABLE_FEAT_RNG \
1049*4e04478aSChris Kay        ENABLE_FEAT_SB \
1050327131c4SLeonardo Sandoval)))
10512fae4b1eSJeenu Viswambharan
10521f461979SJustin Chadwellifeq (${SANITIZE_UB},trap)
10531f461979SJustin Chadwell        $(eval $(call add_define,MONITOR_TRAPS))
10541f461979SJustin Chadwellendif
10551f461979SJustin Chadwell
10564c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
10574c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
10584c117f6cSSandrine Bailleux        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1059cf2c8a33SAntonio Nino Diazelse
106068450a6dSAntonio Nino Diaz        # Define the PRELOADED_BL33_BASE flag only if it is provided and
106168450a6dSAntonio Nino Diaz        # EL3_PAYLOAD_BASE is not defined, as it has priority.
106268450a6dSAntonio Nino Diaz        ifdef PRELOADED_BL33_BASE
106368450a6dSAntonio Nino Diaz                $(eval $(call add_define,PRELOADED_BL33_BASE))
10644c117f6cSSandrine Bailleux        endif
1065cf2c8a33SAntonio Nino Diazendif
106673c99d4eSJuan Castillo
1067209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set.
1068209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1)
1069209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH))
1070209a60ccSSoby Mathewendif
1071209a60ccSSoby Mathew
1072c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),)
1073c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK))
1074c2ad38ceSVarun Wadekarendif
1075c2ad38ceSVarun Wadekar
1076ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1077ce2b1ec6SManish Pandeyifeq (${SPD},spmd)
1078c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE
1079c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},0)
1080c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL1 does not require SP_LAYOUT_FILE")
1081c33ff198SOlivier Deprez        endif
1082ce2b1ec6SManish Pandey        -include $(BUILD_PLAT)/sp_gen.mk
1083ce2b1ec6SManish Pandey        FIP_DEPS += sp
108407c44475SManish Pandey        CRT_DEPS += sp
1085ce2b1ec6SManish Pandey        NEED_SP_PKG := yes
1086ce2b1ec6SManish Pandeyelse
1087c33ff198SOlivier Deprez        ifeq (${SPMD_SPM_AT_SEL2},1)
1088c33ff198SOlivier Deprez            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1089c33ff198SOlivier Deprez        endif
1090ce2b1ec6SManish Pandeyendif
1091ce2b1ec6SManish Pandeyendif
1092ce2b1ec6SManish Pandey
109373c99d4eSJuan Castillo################################################################################
109473c99d4eSJuan Castillo# Build targets
109573c99d4eSJuan Castillo################################################################################
109673c99d4eSJuan Castillo
109790aa901fSSumit Garg.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
109873c99d4eSJuan Castillo.SUFFIXES:
109973c99d4eSJuan Castillo
110073c99d4eSJuan Castilloall: msg_start
110173c99d4eSJuan Castillo
110273c99d4eSJuan Castillomsg_start:
110373c99d4eSJuan Castillo	@echo "Building ${PLAT}"
110473c99d4eSJuan Castillo
11057a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
1106d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not.
1107c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),)
1108c2ad38ceSVarun Wadekar    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1109c2ad38ceSVarun Wadekarelse
1110bc1a03c7SDan Handley    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
11117a24cba5SSoby Mathewendif
1112d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED
11137a24cba5SSoby Mathew
11145accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS))
111561f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c))
11165fee0287SRoberto Vargas
111773c99d4eSJuan Castillo# Expand build macros for the different images
111873c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
111973c99d4eSJuan Castillo$(eval $(call MAKE_BL,1))
112073c99d4eSJuan Castilloendif
112173c99d4eSJuan Castillo
112273c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
1123c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0)
1124c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw
1125c9b31ae8SRoberto Vargasendif
1126c9b31ae8SRoberto Vargas
112733950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1128c9b31ae8SRoberto Vargas	$(eval $(call MAKE_BL,2,${FIP_BL2_ARGS})))
112973c99d4eSJuan Castilloendif
113073c99d4eSJuan Castillo
11314d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes)
113233950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
11334d045d0eSMasahiro Yamadaendif
11344d045d0eSMasahiro Yamada
113573c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
113673c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
113726d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates
113826d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES})
1139c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1140c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1141c6ba9b45SSumit Garg	$(eval $(call MAKE_BL,31,soc-fw,,$(ENCRYPT_BL31))))
1142c6ba9b45SSumit Gargelse
114333950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
11448f0617efSJuan Castillo	$(eval $(call MAKE_BL,31,soc-fw)))
114573c99d4eSJuan Castilloendif
1146c6ba9b45SSumit Gargendif
114773c99d4eSJuan Castillo
114870d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1149c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the
115070d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
115173c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
115226d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates
115326d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES})
11549cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
11559cd15239SMasahiro Yamada
1156c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none)
1157c6ba9b45SSumit Garg$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw,,$(ENCRYPT_BL32))),\
1158c6ba9b45SSumit Garg	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1159c6ba9b45SSumit Gargelse
11609cd15239SMasahiro Yamada$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\
116133950dd8SMasahiro Yamada	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
116273c99d4eSJuan Castilloendif
1163c6ba9b45SSumit Gargendif
116473c99d4eSJuan Castillo
116573c99d4eSJuan Castillo# Add the BL33 image if required by the platform
116673c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
116733950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1168db6071c9SJuan Castilloendif
1169db6071c9SJuan Castillo
11709003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
117133950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
11721dc0714fSMasahiro Yamada	$(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_)))
11739003fa0bSYatharth Kocharendif
11749003fa0bSYatharth Kochar
117503b397a8SNishanth Menon# Expand build macros for the different images
117603b397a8SNishanth Menonifeq (${NEED_FDT},yes)
117703b397a8SNishanth Menon    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
117803b397a8SNishanth Menonendif
117903b397a8SNishanth Menon
1180ce2b1ec6SManish Pandey# Add Secure Partition packages
1181ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes)
1182ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
11831e7528ecSRuari Phipps	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1184ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk
1185ce2b1ec6SManish Pandey	${Q}$(SPTOOL) $(SPTOOL_ARGS)
1186ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1187ce2b1ec6SManish Pandey	@echo "Built SP Images successfully"
1188ce2b1ec6SManish Pandey	@${ECHO_BLANK_LINE}
1189ce2b1ec6SManish Pandeyendif
1190ce2b1ec6SManish Pandey
119136eaaf37SIan Spraylocate-checkpatch:
119236eaaf37SIan Sprayifndef CHECKPATCH
119366079b04SEtienne Carriere	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
119436eaaf37SIan Sprayelse
119536eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
119666079b04SEtienne Carriere	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
119736eaaf37SIan Sprayendif
119836eaaf37SIan Sprayendif
119936eaaf37SIan Spray
12004f6ad66aSAchin Guptaclean:
12014f6ad66aSAchin Gupta	@echo "  CLEAN"
1202f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
120388a1cf1eSSami Mujawarifdef UNIX_MK
12042f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
120588a1cf1eSSami Mujawarelse
120688a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
120788a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
120888a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
120988a1cf1eSSami Mujawarendif
12106f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
121190aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
12125accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
12134f6ad66aSAchin Gupta
1214eaaeece2SJames Morrisseyrealclean distclean:
1215eaaeece2SJames Morrissey	@echo "  REALCLEAN"
1216f1477d4aSEvan Lloyd	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1217f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
121888a1cf1eSSami Mujawarifdef UNIX_MK
12192f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
122088a1cf1eSSami Mujawarelse
122188a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
122288a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
122388a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
122488a1cf1eSSami Mujawarendif
122526010da1SAntonio Nino Diaz	${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean
12266f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
122790aa901fSSumit Garg	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
12285accce5bSRoberto Vargas	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
12294f6ad66aSAchin Gupta
123036eaaf37SIan Spraycheckcodebase:		locate-checkpatch
123136eaaf37SIan Spray	@echo "  CHECKING STYLE"
123236eaaf37SIan Spray	@if test -d .git ; then						\
12331ef35512SPaul Beesley		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
12341a41e8c1SDan Handley		while read GIT_FILE ;					\
12351a41e8c1SDan Handley		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
12361a41e8c1SDan Handley		done ;							\
123736eaaf37SIan Spray	else								\
12381a41e8c1SDan Handley		 find . -type f -not -iwholename "*.git*"		\
12391a41e8c1SDan Handley		 -not -iwholename "*build*"				\
12401a41e8c1SDan Handley		 -not -iwholename "*libfdt*"				\
124161f72a34SRoberto Vargas		 -not -iwholename "*libc*"				\
12421a41e8c1SDan Handley		 -not -iwholename "*docs*"				\
12431ef35512SPaul Beesley		 -not -iwholename "*.rst"				\
12441a41e8c1SDan Handley		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
124536eaaf37SIan Spray	fi
124636eaaf37SIan Spray
124736eaaf37SIan Spraycheckpatch:		locate-checkpatch
124836eaaf37SIan Spray	@echo "  CHECKING STYLE"
124902a76d5fSYann Gautier	@if test -n "${CHECKPATCH_OPTS}"; then				\
125002a76d5fSYann Gautier		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
125102a76d5fSYann Gautier	fi
125251d28937SAntonio Nino Diaz	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
125351d28937SAntonio Nino Diaz	for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do		\
125451d28937SAntonio Nino Diaz		printf "\n[*] Checking style of '$$commit'\n\n";	\
125551d28937SAntonio Nino Diaz		git log --format=email "$$commit~..$$commit"		\
125602a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
125702a76d5fSYann Gautier			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
125851d28937SAntonio Nino Diaz		git diff --format=email "$$commit~..$$commit"		\
125902a76d5fSYann Gautier			-- ${CHECK_PATHS} |				\
126002a76d5fSYann Gautier			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
126151d28937SAntonio Nino Diaz	done
126236eaaf37SIan Spray
126373c99d4eSJuan Castillocerttool: ${CRTTOOL}
126473c99d4eSJuan Castillo
1265a9812206SPali Rohár${CRTTOOL}: FORCE
1266fafd3ec9SManish 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}
1267f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12686f971622SJuan Castillo	@echo "Built $@ successfully"
1269f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12706f971622SJuan Castillo
12716f971622SJuan Castilloifneq (${GENERATE_COT},0)
127273c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
12736f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
1274f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12756f971622SJuan Castillo	@echo "Built $@ successfully"
12766f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
1277f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
127873c99d4eSJuan Castilloendif
127927713fb4SSoby Mathew
128073c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
12814727fd13SPali Rohár	$(eval ${CHECK_FIP_CMD})
1282819281eeSdp-arm	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1283819281eeSdp-arm	${Q}${FIPTOOL} info $@
1284f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
12852f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
1286f1477d4aSEvan Lloyd	@${ECHO_BLANK_LINE}
1287f58ad36fSHarry Liebel
12880191262dSYatharth Kocharifneq (${GENERATE_COT},0)
12890191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
12900191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1291052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12920191262dSYatharth Kochar	@echo "Built $@ successfully"
12930191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1294052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
12950191262dSYatharth Kocharendif
12960191262dSYatharth Kochar
12970191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
12984727fd13SPali Rohár	$(eval ${CHECK_FWU_FIP_CMD})
1299819281eeSdp-arm	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1300819281eeSdp-arm	${Q}${FIPTOOL} info $@
1301052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
13020191262dSYatharth Kochar	@echo "Built $@ successfully"
1303052ab529SEvan Lloyd	@${ECHO_BLANK_LINE}
13040191262dSYatharth Kochar
130573c99d4eSJuan Castillofiptool: ${FIPTOOL}
130673c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
13070191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
130873c99d4eSJuan Castillo
1309a9812206SPali Rohár${FIPTOOL}: FORCE
131088a1cf1eSSami Mujawar	@${ECHO_BLANK_LINE}
131188a1cf1eSSami Mujawar	@echo "Building $@"
131288a1cf1eSSami Mujawarifdef UNIX_MK
1313fafd3ec9SManish V Badarkhe	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH}
131488a1cf1eSSami Mujawarelse
131588a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want
131688a1cf1eSSami Mujawar# to pass the gnumake flags to nmake.
131788a1cf1eSSami Mujawar	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
131888a1cf1eSSami Mujawarendif
131988a1cf1eSSami Mujawar	@${ECHO_BLANK_LINE}
1320f58ad36fSHarry Liebel
132126010da1SAntonio Nino Diazsptool: ${SPTOOL}
1322a9812206SPali Rohár${SPTOOL}: FORCE
1323fafd3ec9SManish V Badarkhe	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH}
132426010da1SAntonio Nino Diaz
1325a9812206SPali Rohárromlib.bin: libraries FORCE
1326bbb24f61SJohn 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
13275accce5bSRoberto Vargas
1328cfe83910SLouis Mayencourt# Call print_memory_map tool
1329cfe83910SLouis Mayencourtmemmap: all
1330b890b36dSLouis Mayencourt	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1331cfe83910SLouis Mayencourt
13326de32378SMadhukar Pappireddydoc:
13336de32378SMadhukar Pappireddy	@echo "  BUILD DOCUMENTATION"
13346de32378SMadhukar Pappireddy	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
13356de32378SMadhukar Pappireddy
133690aa901fSSumit Gargenctool: ${ENCTOOL}
133790aa901fSSumit Garg
1338a9812206SPali Rohár${ENCTOOL}: FORCE
1339fafd3ec9SManish V Badarkhe	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH}
134090aa901fSSumit Garg	@${ECHO_BLANK_LINE}
134190aa901fSSumit Garg	@echo "Built $@ successfully"
134290aa901fSSumit Garg	@${ECHO_BLANK_LINE}
134390aa901fSSumit Garg
134435fab8c9SJoakim Bechcscope:
134535fab8c9SJoakim Bech	@echo "  CSCOPE"
134635fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
134735fab8c9SJoakim Bech	${Q}cscope -b -q -k
134835fab8c9SJoakim Bech
134972ee3314SRyan Harkinhelp:
13507c23126cSJohn Tsichritzis	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
135172ee3314SRyan Harkin	@echo ""
135272ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
135308c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
135472ee3314SRyan Harkin	@echo ""
13557c23126cSJohn Tsichritzis	@echo "platform = ${PLATFORM_LIST}"
13567c23126cSJohn Tsichritzis	@echo ""
13571b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
13581b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
13591b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
13601b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
13611b578596SSandrine Bailleux	@echo ""
136272ee3314SRyan Harkin	@echo "Supported Targets:"
13631b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
136436eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
13658aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
13669003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
1367d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
13689d29c227SSoby Mathew	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
13699d29c227SSoby Mathew	@echo "                 this builds secure payload specified by AARCH32_SP"
137073c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
13711b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
13720191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
137336eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
137436eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
137536eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
137672ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
137735fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
137872ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
13796f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
138090aa901fSSumit Garg	@echo "  enctool        Build the Firmware encryption tool"
1381f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1382ce2b1ec6SManish Pandey	@echo "  sp             Build the Secure Partition Packages"
138326010da1SAntonio Nino Diaz	@echo "  sptool         Build the Secure Partition Package creation tool"
138438c14d88SSoby Mathew	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1385cfe83910SLouis Mayencourt	@echo "  memmap         Print the memory map of the built binaries"
13866de32378SMadhukar Pappireddy	@echo "  doc            Build html based documentation using Sphinx tool"
138772ee3314SRyan Harkin	@echo ""
13881b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
138972ee3314SRyan Harkin	@echo ""
139072ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
139172ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1392a9812206SPali Rohár
1393a9812206SPali Rohár.PHONY: FORCE
1394a9812206SPali RohárFORCE:;
1395