xref: /rk3399_ARM-atf/Makefile (revision 0f90f374332a408671f4ffe6a5b3092d5edfffab)
1#
2# Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7#
8# Trusted Firmware Version
9#
10VERSION_MAJOR			:= 2
11VERSION_MINOR			:= 13
12# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH			:= 0
14VERSION				:= ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
15
16# Default goal is build all images
17.DEFAULT_GOAL			:= all
18
19# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
24MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
26include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
27include ${MAKE_HELPERS_DIRECTORY}common.mk
28
29################################################################################
30# Default values for build configurations, and their dependencies
31################################################################################
32
33include ${MAKE_HELPERS_DIRECTORY}defaults.mk
34# Include the CPU specific operations makefile, which provides default
35# values for all CPU errata workarounds and CPU specific optimisations.
36# This can be overridden by the platform.
37include lib/cpus/cpu-ops.mk
38
39PLAT				:= ${DEFAULT_PLAT}
40include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
41
42# To be able to set platform specific defaults
43ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
44include ${PLAT_DEFAULTS_MAKEFILE_FULL}
45endif
46
47################################################################################
48# Configure the toolchains used to build TF-A and its tools
49################################################################################
50
51include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
52
53# Assertions enabled for DEBUG builds by default
54ENABLE_ASSERTIONS		:= ${DEBUG}
55ENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
56
57################################################################################
58# Checkpatch script options
59################################################################################
60
61CHECKCODE_ARGS		:=	--no-patch
62# Do not check the coding style on imported library files or documentation files
63INC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
64					include/drivers/arm,		\
65					$(wildcard include/drivers/*)))
66INC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
67					lib/libfdt		\
68					include/lib/libc,		\
69					$(wildcard include/lib/*)))
70INC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
71					include/lib			\
72					include/drivers,		\
73					$(wildcard include/*)))
74LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
75					lib/compiler-rt			\
76					lib/libfdt%			\
77					lib/libc,			\
78					lib/zlib			\
79					$(wildcard lib/*)))
80ROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
81					lib				\
82					include				\
83					docs				\
84					%.rst,				\
85					$(wildcard *)))
86CHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
87				${INC_DIRS_TO_CHECK}			\
88				${INC_LIB_DIRS_TO_CHECK}		\
89				${LIB_DIRS_TO_CHECK}			\
90				${INC_DRV_DIRS_TO_CHECK}		\
91				${INC_ARM_DIRS_TO_CHECK}
92
93################################################################################
94# Process build options
95################################################################################
96
97ifeq ($(verbose),)
98	CHECKCODE_ARGS	+=	--no-summary --terse
99endif
100
101################################################################################
102# Auxiliary tools (fiptool, cert_create, etc)
103################################################################################
104
105# Variables for use with Certificate Generation Tool
106CRTTOOLPATH		?=	tools/cert_create
107CRTTOOL			?=	${BUILD_PLAT}/${CRTTOOLPATH}/cert_create$(.exe)
108
109# Variables for use with Firmware Encryption Tool
110ENCTOOLPATH		?=	tools/encrypt_fw
111ENCTOOL			?=	${BUILD_PLAT}/${ENCTOOLPATH}/encrypt_fw$(.exe)
112
113# Variables for use with Firmware Image Package
114FIPTOOLPATH		?=	tools/fiptool
115FIPTOOL			?=	${BUILD_PLAT}/${FIPTOOLPATH}/fiptool$(.exe)
116
117# Variables for use with sptool
118SPTOOLPATH		?=	tools/sptool
119SPTOOL			?=	${SPTOOLPATH}/sptool.py
120SP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
121SP_DTS_LIST_FRAGMENT	?=	${BUILD_PLAT}/sp_list_fragment.dts
122
123# Variables for use with sptool
124TLCTOOL 		?=	poetry run tlc
125
126# Variables for use with ROMLIB
127ROMLIBPATH		?=	lib/romlib
128
129# Variable for use with Python
130PYTHON			?=	python3
131
132# Variables for use with documentation build using Sphinx tool
133DOCS_PATH		?=	docs
134
135# Process Debug flag
136ifneq (${DEBUG}, 0)
137	BUILD_TYPE	:=	debug
138	# Use LOG_LEVEL_INFO by default for debug builds
139	LOG_LEVEL	:=	40
140else
141	BUILD_TYPE	:=	release
142	# Use LOG_LEVEL_NOTICE by default for release builds
143	LOG_LEVEL	:=	20
144endif #(Debug)
145
146# Default build string (git branch and commit)
147ifeq (${BUILD_STRING},)
148	BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
149endif
150VERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
151
152# Setting W is quite verbose and most warnings will be pre-existing issues
153# outside of the contributor's control. Don't fail the build on them so warnings
154# can be seen and hopefully addressed
155ifdef W
156	ifneq (${W},0)
157		E	 ?= 0
158	endif
159endif
160
161################################################################################
162# Setup ARCH_MAJOR/MINOR before parsing arch_features.
163################################################################################
164ifeq (${ENABLE_RME},1)
165	ARM_ARCH_MAJOR := 9
166	ARM_ARCH_MINOR := 2
167endif
168
169################################################################################
170# Common sources and include directories
171################################################################################
172include lib/compiler-rt/compiler-rt.mk
173
174# Allow overriding the timestamp, for example for reproducible builds, or to
175# synchronize timestamps across multiple projects.
176# This must be set to a C string (including quotes where applicable).
177BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
178
179DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
180DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
181DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
182
183BL_COMMON_SOURCES	+=	common/bl_common.c			\
184				common/tf_log.c				\
185				common/${ARCH}/debug.S			\
186				drivers/console/multi_console.c		\
187				lib/${ARCH}/cache_helpers.S		\
188				lib/${ARCH}/misc_helpers.S		\
189				lib/extensions/pmuv3/${ARCH}/pmuv3.c	\
190				plat/common/plat_bl_common.c		\
191				plat/common/plat_log_common.c		\
192				plat/common/${ARCH}/plat_common.c	\
193				plat/common/${ARCH}/platform_helpers.S	\
194				${COMPILER_RT_SRCS}
195
196ifeq ($($(ARCH)-cc-id),arm-clang)
197	BL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
198endif
199
200ifeq (${SANITIZE_UB},on)
201	BL_COMMON_SOURCES	+=	plat/common/ubsan.c
202endif
203
204INCLUDES		+=	-Iinclude				\
205				-Iinclude/arch/${ARCH}			\
206				-Iinclude/lib/cpus/${ARCH}		\
207				-Iinclude/lib/el3_runtime/${ARCH}	\
208				${PLAT_INCLUDES}			\
209				${SPD_INCLUDES}
210
211include common/backtrace/backtrace.mk
212
213################################################################################
214# Generic definitions
215################################################################################
216
217ifeq (${BUILD_BASE},)
218     BUILD_BASE		:=	./build
219endif
220BUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
221
222SPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
223
224# Platforms providing their own TBB makefile may override this value
225INCLUDE_TBBR_MK		:=	1
226
227################################################################################
228# Include SPD Makefile if one has been specified
229################################################################################
230
231ifneq (${SPD},none)
232	ifeq (${SPD},spmd)
233	# SPMD is located in std_svc directory
234		SPD_DIR := std_svc
235
236		ifeq ($(SPMD_SPM_AT_SEL2),1)
237			CTX_INCLUDE_EL2_REGS := 1
238		endif
239
240		ifneq ($(SP_LAYOUT_FILE),)
241		BL2_ENABLE_SP_LOAD := 1
242		endif
243	else
244		# All other SPDs in spd directory
245		SPD_DIR := spd
246	endif #(SPD)
247
248	# We expect to locate an spd.mk under the specified SPD directory
249	SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
250
251	ifeq (${SPD_MAKE},)
252                $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
253	endif
254        $(info Including ${SPD_MAKE})
255        include ${SPD_MAKE}
256
257	# If there's BL32 companion for the chosen SPD, we expect that the SPD's
258	# Makefile would set NEED_BL32 to "yes". In this case, the build system
259	# supports two mutually exclusive options:
260	# * BL32 is built from source: then BL32_SOURCES must contain the list
261	#   of source files to build BL32
262	# * BL32 is a prebuilt binary: then BL32 must point to the image file
263	#   that will be included in the FIP
264	# If both BL32_SOURCES and BL32 are defined, the binary takes precedence
265	# over the sources.
266endif #(SPD=none)
267
268################################################################################
269# Include the platform specific Makefile after the SPD Makefile (the platform
270# makefile may use all previous definitions in this file)
271################################################################################
272include ${PLAT_MAKEFILE_FULL}
273
274################################################################################
275# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
276# platform.
277################################################################################
278
279include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
280################################################################################
281# Process BRANCH_PROTECTION value and set
282# Pointer Authentication and Branch Target Identification flags
283################################################################################
284ifeq (${BRANCH_PROTECTION},0)
285	# Default value turns off all types of branch protection
286	BP_OPTION := none
287else ifneq (${ARCH},aarch64)
288        $(error BRANCH_PROTECTION requires AArch64)
289else ifeq (${BRANCH_PROTECTION},1)
290	# Enables all types of branch protection features
291	BP_OPTION := standard
292	ENABLE_BTI := 1
293	ENABLE_PAUTH := 1
294else ifeq (${BRANCH_PROTECTION},2)
295	# Return address signing to its standard level
296	BP_OPTION := pac-ret
297	ENABLE_PAUTH := 1
298else ifeq (${BRANCH_PROTECTION},3)
299	# Extend the signing to include leaf functions
300	BP_OPTION := pac-ret+leaf
301	ENABLE_PAUTH := 1
302else ifeq (${BRANCH_PROTECTION},4)
303	# Turn on branch target identification mechanism
304	BP_OPTION := bti
305	ENABLE_BTI := 1
306else ifeq (${BRANCH_PROTECTION},5)
307	# Turn on branch target identification mechanism
308	BP_OPTION := standard
309	ENABLE_BTI := 2
310	ENABLE_PAUTH := 2
311else
312        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
313endif #(BRANCH_PROTECTION)
314
315ifneq ($(ENABLE_PAUTH),0)
316	CTX_INCLUDE_PAUTH_REGS	:= ${ENABLE_PAUTH}
317endif
318
319# Pointer Authentication sources
320ifneq (${ENABLE_PAUTH},0)
321# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
322# Pauth support. As it's not secure, it must be reimplemented for real platforms
323	BL_COMMON_SOURCES	+=	lib/extensions/pauth/pauth.c
324endif
325
326################################################################################
327# RME dependent flags configuration, Enable optional features for RME.
328################################################################################
329# FEAT_RME
330ifeq (${ENABLE_RME},1)
331	# RME requires el2 context to be saved for now.
332	CTX_INCLUDE_EL2_REGS := 1
333	CTX_INCLUDE_AARCH32_REGS := 0
334	CTX_INCLUDE_PAUTH_REGS := 1
335
336	ifneq ($(ENABLE_FEAT_MPAM), 0)
337		CTX_INCLUDE_MPAM_REGS := 1
338	endif
339
340	# RME enables CSV2_2 extension by default.
341	ENABLE_FEAT_CSV2_2 = 1
342endif #(FEAT_RME)
343
344################################################################################
345# Include rmmd Makefile if RME is enabled
346################################################################################
347ifneq (${ENABLE_RME},0)
348include services/std_svc/rmmd/rmmd.mk
349$(warning "RME is an experimental feature")
350endif
351
352################################################################################
353# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
354################################################################################
355ifneq (${ENABLE_FEAT_D128}, 0)
356        BL_COMMON_SOURCES       +=      lib/extensions/sysreg128/sysreg128.S
357endif
358
359# This internal flag is common option which is set to 1 for scenarios
360# when the BL2 is running in EL3 level. This occurs in two scenarios -
361# 4 world system running BL2 at EL3 and two world system without BL1 running
362# BL2 in EL3
363
364ifeq (${RESET_TO_BL2},1)
365	BL2_RUNS_AT_EL3	:=	1
366	ifeq (${ENABLE_RME},1)
367                $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
368                supported at the moment.)
369	endif
370else ifeq (${ENABLE_RME},1)
371	BL2_RUNS_AT_EL3	:=	1
372else
373	BL2_RUNS_AT_EL3	:=	0
374endif
375
376# This internal flag is set to 1 when Firmware First handling of External aborts
377# is required by lowe ELs. Currently only NS requires this support.
378ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
379	FFH_SUPPORT := 1
380else
381	FFH_SUPPORT := 0
382endif
383
384ifneq ($(filter 1,${ERRATA_A53_1530924} ${ERRATA_A55_1530923}	\
385        ${ERRATA_A57_1319537} ${ERRATA_A72_1319367} ${ERRATA_A76_1165522}),)
386ERRATA_SPECULATIVE_AT	:= 1
387else
388ERRATA_SPECULATIVE_AT	:= 0
389endif
390
391################################################################################
392# Build `AARCH32_SP` as BL32 image for AArch32
393################################################################################
394ifeq (${ARCH},aarch32)
395        NEED_BL32 := yes
396
397        ifneq (${AARCH32_SP},none)
398        # We expect to locate an sp.mk under the specified AARCH32_SP directory
399		AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
400
401                ifeq (${AARCH32_SP_MAKE},)
402                        $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
403                endif
404                $(info Including ${AARCH32_SP_MAKE})
405                include ${AARCH32_SP_MAKE}
406        endif
407endif #(ARCH=aarch32)
408
409################################################################################
410# Include libc if not overridden
411################################################################################
412ifeq (${OVERRIDE_LIBC},0)
413include lib/libc/libc.mk
414endif
415
416ifneq (${USE_GIC_DRIVER},0)
417include drivers/arm/gic/gic.mk
418endif
419
420################################################################################
421# Check incompatible options and dependencies
422################################################################################
423include ${MAKE_HELPERS_DIRECTORY}constraints.mk
424
425# The cert_create tool cannot generate certificates individually, so we use the
426# target 'certificates' to create them all
427ifneq (${GENERATE_COT},0)
428    FIP_DEPS += certificates
429    FWU_FIP_DEPS += fwu_certificates
430    BL2_FIP_DEPS += bl2_certificates
431endif
432
433ifneq (${DECRYPTION_SUPPORT},none)
434	ENC_ARGS += -f ${FW_ENC_STATUS}
435	ENC_ARGS += -k ${ENC_KEY}
436	ENC_ARGS += -n ${ENC_NONCE}
437	FIP_DEPS += enctool
438	FWU_FIP_DEPS += enctool
439	BL2_FIP_DEPS += enctool
440endif #(DECRYPTION_SUPPORT)
441
442################################################################################
443# Process platform overrideable behaviour
444################################################################################
445
446ifdef BL1_SOURCES
447	NEED_BL1 := yes
448endif #(BL1_SOURCES)
449
450ifdef BL2_SOURCES
451	NEED_BL2 := yes
452
453	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
454	# Certificate generation tools. This flag can be overridden by the platform.
455	ifdef EL3_PAYLOAD_BASE
456		# If booting an EL3 payload there is no need for a BL33 image
457		# in the FIP file.
458		NEED_BL33		:=	no
459	else
460		ifdef PRELOADED_BL33_BASE
461			# If booting a BL33 preloaded image there is no need of
462			# another one in the FIP file.
463			NEED_BL33		:=	no
464		else
465			NEED_BL33		?=	yes
466		endif
467	endif
468endif #(BL2_SOURCES)
469
470ifdef BL2U_SOURCES
471	NEED_BL2U := yes
472endif #(BL2U_SOURCES)
473
474# If SCP_BL2 is given, we always want FIP to include it.
475ifdef SCP_BL2
476	NEED_SCP_BL2		:=	yes
477endif #(SCP_BL2)
478
479# For AArch32, BL31 is not currently supported.
480ifneq (${ARCH},aarch32)
481	ifdef BL31_SOURCES
482	# When booting an EL3 payload, there is no need to compile the BL31
483	# image nor put it in the FIP.
484		ifndef EL3_PAYLOAD_BASE
485			NEED_BL31 := yes
486		endif
487	endif
488endif #(ARCH=aarch64)
489
490# Process TBB related flags
491ifneq (${GENERATE_COT},0)
492    # Common cert_create options
493    ifneq (${CREATE_KEYS},0)
494        $(eval CRT_ARGS += -n)
495        $(eval FWU_CRT_ARGS += -n)
496        $(eval BL2_CRT_ARGS += -n)
497        ifneq (${SAVE_KEYS},0)
498            $(eval CRT_ARGS += -k)
499            $(eval FWU_CRT_ARGS += -k)
500            $(eval BL2_CRT_ARGS += -k)
501        endif
502    endif
503    # Include TBBR makefile (unless the platform indicates otherwise)
504    ifeq (${INCLUDE_TBBR_MK},1)
505        include make_helpers/tbbr/tbbr_tools.mk
506    endif
507endif #(GENERATE_COT)
508
509ifneq (${FIP_ALIGN},0)
510	FIP_ARGS += --align ${FIP_ALIGN}
511endif #(FIP_ALIGN)
512
513ifdef FDT_SOURCES
514	NEED_FDT := yes
515endif #(FDT_SOURCES)
516
517################################################################################
518# Include libraries' Makefile that are used in all BL
519################################################################################
520
521include lib/stack_protector/stack_protector.mk
522
523################################################################################
524# Include BL specific makefiles
525################################################################################
526
527ifeq (${NEED_BL1},yes)
528include bl1/bl1.mk
529endif
530
531ifeq (${NEED_BL2},yes)
532include bl2/bl2.mk
533endif
534
535ifeq (${NEED_BL2U},yes)
536include bl2u/bl2u.mk
537endif
538
539ifeq (${NEED_BL31},yes)
540include bl31/bl31.mk
541endif
542
543################################################################################
544# Build options checks
545################################################################################
546
547# Boolean_Flags
548$(eval $(call assert_booleans,\
549    $(sort \
550	ALLOW_RO_XLAT_TABLES \
551	BL2_ENABLE_SP_LOAD \
552	COLD_BOOT_SINGLE_CPU \
553	$(CPU_FLAG_LIST) \
554	CREATE_KEYS \
555	CTX_INCLUDE_AARCH32_REGS \
556	CTX_INCLUDE_FPREGS \
557	CTX_INCLUDE_SVE_REGS \
558	CTX_INCLUDE_EL2_REGS \
559	CTX_INCLUDE_MPAM_REGS \
560	DEBUG \
561	DYN_DISABLE_AUTH \
562	EL3_EXCEPTION_HANDLING \
563	ENABLE_AMU_AUXILIARY_COUNTERS \
564	AMU_RESTRICT_COUNTERS \
565	ENABLE_ASSERTIONS \
566	ENABLE_PIE \
567	ENABLE_PMF \
568	ENABLE_PSCI_STAT \
569	ENABLE_RUNTIME_INSTRUMENTATION \
570	ENABLE_SME_FOR_SWD \
571	ENABLE_SVE_FOR_SWD \
572	ENABLE_FEAT_GCIE \
573	ENABLE_FEAT_RAS	\
574	FFH_SUPPORT	\
575	ERROR_DEPRECATED \
576	FAULT_INJECTION_SUPPORT \
577	GENERATE_COT \
578	GICV2_G0_FOR_EL3 \
579	HANDLE_EA_EL3_FIRST_NS \
580	HARDEN_SLS \
581	HW_ASSISTED_COHERENCY \
582	MEASURED_BOOT \
583	DISCRETE_TPM \
584	DICE_PROTECTION_ENVIRONMENT \
585	RMMD_ENABLE_EL3_TOKEN_SIGN \
586	RMMD_ENABLE_IDE_KEY_PROG \
587	DRTM_SUPPORT \
588	NS_TIMER_SWITCH \
589	OVERRIDE_LIBC \
590	PL011_GENERIC_UART \
591	PLAT_EXTRA_LD_SCRIPT \
592	PROGRAMMABLE_RESET_ADDRESS \
593	PSCI_EXTENDED_STATE_ID \
594	PSCI_OS_INIT_MODE \
595	ARCH_FEATURE_AVAILABILITY \
596	RESET_TO_BL31 \
597	SAVE_KEYS \
598	SEPARATE_CODE_AND_RODATA \
599	SEPARATE_BL2_NOLOAD_REGION \
600	SEPARATE_NOBITS_REGION \
601	SEPARATE_RWDATA_REGION \
602	SEPARATE_SIMD_SECTION \
603	SPIN_ON_BL1_EXIT \
604	SPM_MM \
605	SPMC_AT_EL3 \
606	SPMC_AT_EL3_SEL0_SP \
607	SPMD_SPM_AT_SEL2 \
608	ENABLE_SPMD_LP \
609	TRANSFER_LIST \
610	TRUSTED_BOARD_BOOT \
611	USE_COHERENT_MEM \
612	USE_DEBUGFS \
613	USE_KERNEL_DT_CONVENTION \
614	ARM_IO_IN_DTB \
615	SDEI_IN_FCONF \
616	SEC_INT_DESC_IN_FCONF \
617	USE_ROMLIB \
618	USE_TBBR_DEFS \
619	WARMBOOT_ENABLE_DCACHE_EARLY \
620	RESET_TO_BL2 \
621	BL2_IN_XIP_MEM \
622	BL2_INV_DCACHE \
623	USE_SPINLOCK_CAS \
624	ENCRYPT_BL31 \
625	ENCRYPT_BL32 \
626	ERRATA_SPECULATIVE_AT \
627	ERRATA_SME_POWER_DOWN \
628	RAS_TRAP_NS_ERR_REC_ACCESS \
629	COT_DESC_IN_DTB \
630	USE_SP804_TIMER \
631	PSA_FWU_SUPPORT \
632	PSA_FWU_METADATA_FW_STORE_DESC \
633	ENABLE_MPMM \
634	FEATURE_DETECTION \
635	TRNG_SUPPORT \
636	ENABLE_ERRATA_ALL \
637	ERRATA_ABI_SUPPORT \
638	ERRATA_NON_ARM_INTERCONNECT \
639	CONDITIONAL_CMO \
640	PSA_CRYPTO	\
641	ENABLE_CONSOLE_GETC \
642	INIT_UNUSED_NS_EL2	\
643	PLATFORM_REPORT_CTX_MEM_USE \
644	EARLY_CONSOLE \
645	PRESERVE_DSU_PMU_REGS \
646	HOB_LIST \
647	LFA_SUPPORT \
648)))
649
650# Numeric_Flags
651$(eval $(call assert_numerics,\
652    $(sort \
653	ARM_ARCH_MAJOR \
654	ARM_ARCH_MINOR \
655	BRANCH_PROTECTION \
656	CTX_INCLUDE_PAUTH_REGS \
657	CTX_INCLUDE_NEVE_REGS \
658	DISABLE_MTPMU \
659	ENABLE_BRBE_FOR_NS \
660	ENABLE_TRBE_FOR_NS \
661	ENABLE_BTI \
662	ENABLE_PAUTH \
663	ENABLE_FEAT_PAUTH_LR \
664	ENABLE_FEAT_AIE \
665	ENABLE_FEAT_AMU \
666	ENABLE_FEAT_AMUv1p1 \
667	ENABLE_FEAT_CLRBHB \
668	ENABLE_FEAT_CPA2 \
669	ENABLE_FEAT_CSV2_2 \
670	ENABLE_FEAT_CSV2_3 \
671	ENABLE_FEAT_DEBUGV8P9 \
672	ENABLE_FEAT_DIT \
673	ENABLE_FEAT_ECV \
674	ENABLE_FEAT_EBEP \
675	ENABLE_FEAT_FGT \
676	ENABLE_FEAT_FGT2 \
677	ENABLE_FEAT_FGWTE3 \
678	ENABLE_FEAT_FPMR \
679	ENABLE_FEAT_HCX \
680	ENABLE_FEAT_LS64_ACCDATA \
681	ENABLE_FEAT_MEC \
682	ENABLE_FEAT_MOPS \
683	ENABLE_FEAT_MTE2 \
684	ENABLE_FEAT_PAN \
685	ENABLE_FEAT_PFAR \
686	ENABLE_FEAT_RNG \
687	ENABLE_FEAT_RNG_TRAP \
688	ENABLE_FEAT_SEL2 \
689	ENABLE_FEAT_TCR2 \
690	ENABLE_FEAT_THE \
691	ENABLE_FEAT_SB \
692	ENABLE_FEAT_S2PIE \
693	ENABLE_FEAT_S1PIE \
694	ENABLE_FEAT_S2POE \
695	ENABLE_FEAT_S1POE \
696	ENABLE_FEAT_SCTLR2 \
697	ENABLE_FEAT_D128 \
698	ENABLE_FEAT_RME_GDI \
699	ENABLE_FEAT_GCS \
700	ENABLE_FEAT_VHE \
701	ENABLE_FEAT_MPAM \
702	ENABLE_FEAT_MPAM_PE_BW_CTRL \
703	ENABLE_RME \
704	ENABLE_SPE_FOR_NS \
705	ENABLE_SYS_REG_TRACE_FOR_NS \
706	ENABLE_SME_FOR_NS \
707	ENABLE_SME2_FOR_NS \
708	ENABLE_SVE_FOR_NS \
709	ENABLE_TRF_FOR_NS \
710	FW_ENC_STATUS \
711	NR_OF_FW_BANKS \
712	NR_OF_IMAGES_IN_FW_BANK \
713	SPMC_AT_EL3_PARTITION_MAX_UUIDS \
714	TWED_DELAY \
715	ENABLE_FEAT_TWED \
716	SVE_VECTOR_LEN \
717	IMPDEF_SYSREG_TRAP \
718	W \
719)))
720
721ifdef KEY_SIZE
722        $(eval $(call assert_numeric,KEY_SIZE))
723endif
724
725ifeq ($(filter $(SANITIZE_UB), on off trap),)
726        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
727endif
728
729################################################################################
730# Add definitions to the cpp preprocessor based on the current build options.
731# This is done after including the platform specific makefile to allow the
732# platform to overwrite the default options
733################################################################################
734
735$(eval $(call add_defines,\
736    $(sort \
737	ALLOW_RO_XLAT_TABLES \
738	ARM_ARCH_MAJOR \
739	ARM_ARCH_MINOR \
740	BL2_ENABLE_SP_LOAD \
741	COLD_BOOT_SINGLE_CPU \
742	$(CPU_FLAG_LIST) \
743	CTX_INCLUDE_AARCH32_REGS \
744	CTX_INCLUDE_FPREGS \
745	CTX_INCLUDE_SVE_REGS \
746	CTX_INCLUDE_PAUTH_REGS \
747	CTX_INCLUDE_MPAM_REGS \
748	EL3_EXCEPTION_HANDLING \
749	CTX_INCLUDE_EL2_REGS \
750	CTX_INCLUDE_NEVE_REGS \
751	DEBUG \
752	DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
753	DISABLE_MTPMU \
754	ENABLE_FEAT_AMU \
755	ENABLE_AMU_AUXILIARY_COUNTERS \
756	AMU_RESTRICT_COUNTERS \
757	ENABLE_ASSERTIONS \
758	ENABLE_BTI \
759	ENABLE_FEAT_DEBUGV8P9 \
760	ENABLE_FEAT_MPAM \
761	ENABLE_FEAT_MPAM_PE_BW_CTRL \
762	ENABLE_PAUTH \
763	ENABLE_FEAT_PAUTH_LR \
764	ENABLE_PIE \
765	ENABLE_PMF \
766	ENABLE_PSCI_STAT \
767	ENABLE_RME \
768	RMMD_ENABLE_EL3_TOKEN_SIGN \
769	RMMD_ENABLE_IDE_KEY_PROG \
770	ENABLE_RUNTIME_INSTRUMENTATION \
771	ENABLE_SME_FOR_NS \
772	ENABLE_SME2_FOR_NS \
773	ENABLE_SME_FOR_SWD \
774	ENABLE_SPE_FOR_NS \
775	ENABLE_SVE_FOR_NS \
776	ENABLE_SVE_FOR_SWD \
777	ENABLE_FEAT_RAS \
778	FFH_SUPPORT \
779	ENCRYPT_BL31 \
780	ENCRYPT_BL32 \
781	ERROR_DEPRECATED \
782	FAULT_INJECTION_SUPPORT \
783	GICV2_G0_FOR_EL3 \
784	HANDLE_EA_EL3_FIRST_NS \
785	HW_ASSISTED_COHERENCY \
786	LOG_LEVEL \
787	MEASURED_BOOT \
788	DISCRETE_TPM \
789	DICE_PROTECTION_ENVIRONMENT \
790	DRTM_SUPPORT \
791	NS_TIMER_SWITCH \
792	PLATFORM_NODE_COUNT \
793	PL011_GENERIC_UART \
794	PLAT_EXTRA_LD_SCRIPT \
795	PLAT_${PLAT} \
796	PROGRAMMABLE_RESET_ADDRESS \
797	PSCI_EXTENDED_STATE_ID \
798	PSCI_OS_INIT_MODE \
799	ARCH_FEATURE_AVAILABILITY \
800	RESET_TO_BL31 \
801	RME_GPT_BITLOCK_BLOCK \
802	RME_GPT_MAX_BLOCK \
803	SEPARATE_CODE_AND_RODATA \
804	SEPARATE_BL2_FIP \
805	SEPARATE_BL2_NOLOAD_REGION \
806	SEPARATE_NOBITS_REGION \
807	SEPARATE_RWDATA_REGION \
808	SEPARATE_SIMD_SECTION \
809	RECLAIM_INIT_CODE \
810	SPD_${SPD} \
811	SPIN_ON_BL1_EXIT \
812	SPM_MM \
813	SPMC_AT_EL3 \
814	SPMC_AT_EL3_PARTITION_MAX_UUIDS \
815	SPMC_AT_EL3_SEL0_SP \
816	SPMD_SPM_AT_SEL2 \
817	TRANSFER_LIST \
818	TRUSTED_BOARD_BOOT \
819	TRNG_SUPPORT \
820	ERRATA_ABI_SUPPORT \
821	ERRATA_NON_ARM_INTERCONNECT \
822	USE_COHERENT_MEM \
823	USE_DEBUGFS \
824	ARM_IO_IN_DTB \
825	SDEI_IN_FCONF \
826	SEC_INT_DESC_IN_FCONF \
827	USE_ROMLIB \
828	USE_TBBR_DEFS \
829	USE_KERNEL_DT_CONVENTION \
830	WARMBOOT_ENABLE_DCACHE_EARLY \
831	RESET_TO_BL2 \
832	BL2_RUNS_AT_EL3	\
833	BL2_IN_XIP_MEM \
834	BL2_INV_DCACHE \
835	USE_SPINLOCK_CAS \
836	ERRATA_SPECULATIVE_AT \
837	ERRATA_SME_POWER_DOWN \
838	RAS_TRAP_NS_ERR_REC_ACCESS \
839	COT_DESC_IN_DTB \
840	USE_SP804_TIMER \
841	ENABLE_FEAT_RNG \
842	ENABLE_FEAT_RNG_TRAP \
843	ENABLE_FEAT_SB \
844	ENABLE_FEAT_DIT \
845	NR_OF_FW_BANKS \
846	NR_OF_IMAGES_IN_FW_BANK \
847	PSA_FWU_SUPPORT \
848	PSA_FWU_METADATA_FW_STORE_DESC \
849	ENABLE_BRBE_FOR_NS \
850	ENABLE_TRBE_FOR_NS \
851	ENABLE_SYS_REG_TRACE_FOR_NS \
852	ENABLE_TRF_FOR_NS \
853	ENABLE_FEAT_AIE \
854	ENABLE_FEAT_HCX \
855	ENABLE_MPMM \
856	ENABLE_FEAT_FGT \
857	ENABLE_FEAT_FGT2 \
858	ENABLE_FEAT_FGWTE3 \
859	ENABLE_FEAT_FPMR \
860	ENABLE_FEAT_ECV \
861	ENABLE_FEAT_EBEP \
862	ENABLE_FEAT_AMUv1p1 \
863	ENABLE_FEAT_SEL2 \
864	ENABLE_FEAT_VHE \
865	ENABLE_FEAT_CLRBHB \
866	ENABLE_FEAT_CPA2 \
867	ENABLE_FEAT_CSV2_2 \
868	ENABLE_FEAT_CSV2_3 \
869	ENABLE_FEAT_LS64_ACCDATA \
870	ENABLE_FEAT_MEC \
871	ENABLE_FEAT_PAN \
872	ENABLE_FEAT_TCR2 \
873	ENABLE_FEAT_THE \
874	ENABLE_FEAT_S2PIE \
875	ENABLE_FEAT_S1PIE \
876	ENABLE_FEAT_S2POE \
877	ENABLE_FEAT_S1POE \
878	ENABLE_FEAT_SCTLR2 \
879	ENABLE_FEAT_D128 \
880	ENABLE_FEAT_RME_GDI \
881	ENABLE_FEAT_GCS \
882	ENABLE_FEAT_MOPS \
883	ENABLE_FEAT_GCIE \
884	ENABLE_FEAT_MTE2 \
885	ENABLE_FEAT_PFAR \
886	FEATURE_DETECTION \
887	TWED_DELAY \
888	ENABLE_FEAT_TWED \
889	CONDITIONAL_CMO \
890	IMPDEF_SYSREG_TRAP \
891	SVE_VECTOR_LEN \
892	ENABLE_SPMD_LP \
893	PSA_CRYPTO	\
894	ENABLE_CONSOLE_GETC \
895	INIT_UNUSED_NS_EL2	\
896	PLATFORM_REPORT_CTX_MEM_USE \
897	EARLY_CONSOLE \
898	PRESERVE_DSU_PMU_REGS \
899	HOB_LIST \
900	HW_CONFIG_BASE \
901	LFA_SUPPORT \
902)))
903
904ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
905ifeq (${DEBUG}, 0)
906        $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
907        override PLATFORM_REPORT_CTX_MEM_USE := 0
908endif
909endif
910
911ifeq (${SANITIZE_UB},trap)
912        $(eval $(call add_define,MONITOR_TRAPS))
913endif #(SANITIZE_UB)
914
915# Define the EL3_PAYLOAD_BASE flag only if it is provided.
916ifdef EL3_PAYLOAD_BASE
917        $(eval $(call add_define,EL3_PAYLOAD_BASE))
918else
919# Define the PRELOADED_BL33_BASE flag only if it is provided and
920# EL3_PAYLOAD_BASE is not defined, as it has priority.
921	ifdef PRELOADED_BL33_BASE
922                $(eval $(call add_define,PRELOADED_BL33_BASE))
923	endif
924endif #(EL3_PAYLOAD_BASE)
925
926# Define the DYN_DISABLE_AUTH flag only if set.
927ifeq (${DYN_DISABLE_AUTH},1)
928        $(eval $(call add_define,DYN_DISABLE_AUTH))
929endif
930
931ifeq ($($(ARCH)-ld-id),arm-link)
932        $(eval $(call add_define,USE_ARM_LINK))
933endif
934
935# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
936ifeq (${SPD},spmd)
937ifdef SP_LAYOUT_FILE
938	-include $(BUILD_PLAT)/sp_gen.mk
939	FIP_DEPS += sp
940	CRT_DEPS += sp
941	NEED_SP_PKG := yes
942else
943	ifeq (${SPMD_SPM_AT_SEL2},1)
944                $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
945	endif
946endif #(SP_LAYOUT_FILE)
947endif #(SPD)
948
949################################################################################
950# Configure the flags for the specified compiler and linker
951################################################################################
952include ${MAKE_HELPERS_DIRECTORY}cflags.mk
953
954################################################################################
955# Build targets
956################################################################################
957
958.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
959
960all: msg_start
961
962msg_start:
963	$(s)echo "Building ${PLAT}"
964
965$(eval $(call MAKE_LIB,c))
966
967# Expand build macros for the different images
968ifeq (${NEED_BL1},yes)
969BL1_SOURCES := $(sort ${BL1_SOURCES})
970$(eval $(call MAKE_BL,bl1))
971endif #(NEED_BL1)
972
973ifeq (${NEED_BL2},yes)
974
975ifeq (${RESET_TO_BL2}, 0)
976FIP_BL2_ARGS := tb-fw
977endif
978
979BL2_SOURCES := $(sort ${BL2_SOURCES})
980
981ifeq (${SEPARATE_BL2_FIP},1)
982$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS},BL2_)), \
983	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS},BL2_)))
984else
985$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})), \
986	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
987endif #(SEPARATE_BL2_FIP)
988
989endif #(NEED_BL2)
990
991ifeq (${NEED_SCP_BL2},yes)
992$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
993endif #(NEED_SCP_BL2)
994
995ifeq (${NEED_BL31},yes)
996BL31_SOURCES += ${SPD_SOURCES}
997# Sort BL31 source files to remove duplicates
998BL31_SOURCES := $(sort ${BL31_SOURCES})
999ifneq (${DECRYPTION_SUPPORT},none)
1000$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1001	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1002else
1003$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1004	$(eval $(call MAKE_BL,bl31,soc-fw)))
1005endif #(DECRYPTION_SUPPORT)
1006endif #(NEED_BL31)
1007
1008# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1009# build system will call TOOL_ADD_IMG to print a warning message and abort the
1010# process. Note that the dependency on BL32 applies to the FIP only.
1011ifeq (${NEED_BL32},yes)
1012# Sort BL32 source files to remove duplicates
1013BL32_SOURCES := $(sort ${BL32_SOURCES})
1014BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1015
1016ifneq (${DECRYPTION_SUPPORT},none)
1017$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1018	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1019else
1020$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
1021	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1022endif #(DECRYPTION_SUPPORT)
1023endif #(NEED_BL32)
1024
1025# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1026# needs to be built from RMM_SOURCES.
1027ifeq (${NEED_RMM},yes)
1028# Sort RMM source files to remove duplicates
1029RMM_SOURCES := $(sort ${RMM_SOURCES})
1030BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1031
1032$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1033	 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1034endif #(NEED_RMM)
1035
1036# Add the BL33 image if required by the platform
1037ifeq (${NEED_BL33},yes)
1038$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1039endif #(NEED_BL33)
1040
1041ifeq (${NEED_BL2U},yes)
1042$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1043	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1044endif #(NEED_BL2U)
1045
1046# Expand build macros for the different images
1047ifeq (${NEED_FDT},yes)
1048    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
1049
1050    ifneq (${INITRD_SIZE}${INITRD_PATH},)
1051        ifndef INITRD_BASE
1052            $(error INITRD_BASE must be set when inserting initrd properties to the DTB.)
1053        endif
1054
1055        INITRD_SIZE ?= $(shell printf "0x%x\n" $$(stat -Lc %s $(INITRD_PATH)))
1056        initrd_end = $(shell printf "0x%x\n" $$(expr $$(($(INITRD_BASE) + $(INITRD_SIZE)))))
1057
1058        define $(HW_CONFIG)-after +=
1059            $(s)echo "  INITRD  $(HW_CONFIG)"
1060            $(q)fdtput -t x $@ /chosen linux,initrd-start $(INITRD_BASE)
1061            $(q)fdtput -t x $@ /chosen linux,initrd-end $(initrd_end)
1062        endef
1063    endif
1064endif #(NEED_FDT)
1065
1066# Add Secure Partition packages
1067ifeq (${NEED_SP_PKG},yes)
1068$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
1069	$(if $(host-poetry),$(q)poetry -q install --no-root)
1070	$(q)$(if $(host-poetry),poetry run )${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
1071sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1072	$(s)echo
1073	$(s)echo "Built SP Images successfully"
1074	$(s)echo
1075endif #(NEED_SP_PKG)
1076
1077locate-checkpatch:
1078ifndef CHECKPATCH
1079	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1080else
1081ifeq (,$(wildcard ${CHECKPATCH}))
1082	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1083endif
1084endif #(CHECKPATCH)
1085
1086clean:
1087	$(s)echo "  CLEAN"
1088	$(q)rm -rf $(BUILD_PLAT)
1089	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean
1090	$(q)rm -rf ${FIPTOOLPATH}/fiptool
1091	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1092	$(q)rm -rf ${CRTTOOLPATH}/cert_create
1093	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1094	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1095
1096realclean distclean:
1097	$(s)echo "  REALCLEAN"
1098	$(q)rm -rf $(BUILD_BASE)
1099	$(q)rm -rf $(CURDIR)/cscope.*
1100	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${FIPTOOLPATH} clean
1101	$(q)rm -rf ${FIPTOOLPATH}/fiptool
1102	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1103	$(q)rm -rf ${CRTTOOLPATH}/cert_create
1104	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=${BUILD_PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1105	$(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1106
1107checkcodebase:		locate-checkpatch
1108	$(s)echo "  CHECKING STYLE"
1109	$(q)if test -d .git ; then						\
1110		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
1111		while read GIT_FILE ;					\
1112		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
1113		done ;							\
1114	else								\
1115		 find . -type f -not -iwholename "*.git*"		\
1116		 -not -iwholename "*build*"				\
1117		 -not -iwholename "*libfdt*"				\
1118		 -not -iwholename "*libc*"				\
1119		 -not -iwholename "*docs*"				\
1120		 -not -iwholename "*.rst"				\
1121		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
1122	fi
1123
1124checkpatch:		locate-checkpatch
1125	$(s)echo "  CHECKING STYLE"
1126	$(q)if test -n "${CHECKPATCH_OPTS}"; then				\
1127		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
1128	fi
1129	$(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
1130	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
1131	do								\
1132		printf "\n[*] Checking style of '$$commit'\n\n";	\
1133		( git log --format=email "$$commit~..$$commit"		\
1134			-- ${CHECK_PATHS} ;				\
1135		  git diff --format=email "$$commit~..$$commit"		\
1136			-- ${CHECK_PATHS}; ) |				\
1137			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
1138	done
1139
1140certtool: ${CRTTOOL}
1141
1142${CRTTOOL}: FORCE | $$(@D)/
1143	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all
1144	$(q)ln -sf ${CRTTOOL} ${CRTTOOLPATH}/cert_create
1145	$(s)echo
1146	$(s)echo "Built $@ successfully"
1147	$(s)echo
1148
1149ifneq (${GENERATE_COT},0)
1150certificates: ${CRT_DEPS} ${CRTTOOL} ${DTBS}
1151	$(q)${CRTTOOL} ${CRT_ARGS}
1152	$(s)echo
1153	$(s)echo "Built $@ successfully"
1154	$(s)echo "Certificates can be found in ${BUILD_PLAT}"
1155	$(s)echo
1156endif #(GENERATE_COT)
1157
1158ifeq (${SEPARATE_BL2_FIP},1)
1159${BUILD_PLAT}/${BL2_FIP_NAME}: ${BL2_FIP_DEPS} ${FIPTOOL} | $$(@D)/
1160	$(eval ${CHECK_BL2_FIP_CMD})
1161	$(q)${FIPTOOL} create ${BL2_FIP_ARGS} $@
1162	$(q)${FIPTOOL} info $@
1163	$(s)echo
1164	$(s)echo "Built $@ successfully"
1165	$(s)echo
1166endif #(SEPARATE_BL2_FIP)
1167
1168${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} | $$(@D)/
1169	$(eval ${CHECK_FIP_CMD})
1170	$(q)${FIPTOOL} create ${FIP_ARGS} $@
1171	$(q)${FIPTOOL} info $@
1172	$(s)echo
1173	$(s)echo "Built $@ successfully"
1174	$(s)echo
1175
1176ifneq (${GENERATE_COT},0)
1177fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1178	$(q)${CRTTOOL} ${FWU_CRT_ARGS}
1179	$(s)echo
1180	$(s)echo "Built $@ successfully"
1181	$(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1182	$(s)echo
1183endif #(GENERATE_COT)
1184
1185ifneq (${GENERATE_COT},0)
1186bl2_certificates: ${BUILD_PLAT}/${FIP_NAME} ${BL2_CRT_DEPS} ${CRTTOOL} | ${BUILD_PLAT}/
1187	$(q)${CRTTOOL} ${BL2_CRT_ARGS}
1188	$(s)echo
1189	$(s)echo "Built $@ successfully"
1190	$(s)echo "BL2 certificates can be found in ${BUILD_PLAT}"
1191	$(s)echo
1192endif #(GENERATE_COT)
1193
1194${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} | $$(@D)/
1195	$(eval ${CHECK_FWU_FIP_CMD})
1196	$(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1197	$(q)${FIPTOOL} info $@
1198	$(s)echo
1199	$(s)echo "Built $@ successfully"
1200	$(s)echo
1201
1202fiptool: ${FIPTOOL}
1203ifeq (${SEPARATE_BL2_FIP},1)
1204bl2_fip: ${BUILD_PLAT}/${BL2_FIP_NAME}
1205fip: bl2_fip
1206else
1207fip: ${BUILD_PLAT}/${FIP_NAME}
1208endif #(SEPARATE_BL2_FIP)
1209fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
1210
1211# symlink for compatibility before tools were in the build directory
1212${FIPTOOL}: FORCE | $$(@D)/
1213	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
1214	$(q)ln -sf ${FIPTOOL} ${FIPTOOLPATH}/fiptool
1215
1216$(BUILD_PLAT)/romlib/romlib.bin $(BUILD_PLAT)/lib/libwrappers.a $&: $(BUILD_PLAT)/lib/libfdt.a $(BUILD_PLAT)/lib/libc.a $(CRYPTO_LIB) | $$(@D)/
1217	$(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} CRYPTO_LIB=$(CRYPTO_LIB) ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
1218
1219memmap: all
1220	$(if $(host-poetry),$(q)poetry -q install --no-root)
1221	$(q)$(if $(host-poetry),poetry run )memory --root ${BUILD_PLAT} symbols
1222
1223tl: ${BUILD_PLAT}/tl.bin
1224${BUILD_PLAT}/tl.bin: ${HW_CONFIG} | $$(@D)/
1225	$(if $(host-poetry),$(q)poetry -q install --no-root)
1226	$(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
1227
1228doc:
1229	$(s)echo "  BUILD DOCUMENTATION"
1230	$(if $(host-poetry),$(q)poetry -q install --with docs --no-root)
1231	$(q)$(if $(host-poetry),poetry run )${MAKE} --no-print-directory -C ${DOCS_PATH} BUILDDIR=$(abspath ${BUILD_BASE}/docs) html
1232
1233enctool: ${ENCTOOL}
1234
1235${ENCTOOL}: FORCE | $$(@D)/
1236	$(q)${MAKE} PLAT=${PLAT} BUILD_PLAT=$(abspath ${BUILD_PLAT}) BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1237	$(s)echo
1238	$(s)echo "Built $@ successfully"
1239	$(s)echo
1240
1241cscope:
1242	$(s)echo "  CSCOPE"
1243	$(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1244	$(q)cscope -b -q -k
1245
1246help:
1247	$(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1248	$(s)echo ""
1249	$(s)echo "PLAT is used to specify which platform you wish to build."
1250	$(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1251	$(s)echo ""
1252	$(s)echo "platform = ${PLATFORM_LIST}"
1253	$(s)echo ""
1254	$(s)echo "Please refer to the User Guide for a list of all supported options."
1255	$(s)echo "Note that the build system doesn't track dependencies for build "
1256	$(s)echo "options. Therefore, if any of the build options are changed "
1257	$(s)echo "from a previous build, a clean build must be performed."
1258	$(s)echo ""
1259	$(s)echo "Supported Targets:"
1260	$(s)echo "  all            Build all individual bootloader binaries"
1261	$(s)echo "  bl1            Build the BL1 binary"
1262	$(s)echo "  bl2            Build the BL2 binary"
1263	$(s)echo "  bl2u           Build the BL2U binary"
1264	$(s)echo "  bl31           Build the BL31 binary"
1265	$(s)echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
1266	$(s)echo "                 this builds secure payload specified by AARCH32_SP"
1267	$(s)echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
1268	$(s)echo "  fip            Build the Firmware Image Package (FIP)"
1269	$(s)echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
1270	$(s)echo "  checkcodebase  Check the coding style of the entire source tree"
1271	$(s)echo "  checkpatch     Check the coding style on changes in the current"
1272	$(s)echo "                 branch against BASE_COMMIT (default origin/master)"
1273	$(s)echo "  clean          Clean the build for the selected platform"
1274	$(s)echo "  cscope         Generate cscope index"
1275	$(s)echo "  distclean      Remove all build artifacts for all platforms"
1276	$(s)echo "  certtool       Build the Certificate generation tool"
1277	$(s)echo "  enctool        Build the Firmware encryption tool"
1278	$(s)echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1279	$(s)echo "  sp             Build the Secure Partition Packages"
1280	$(s)echo "  sptool         Build the Secure Partition Package creation tool"
1281	$(s)echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1282	$(s)echo "  memmap         Print the memory map of the built binaries"
1283	$(s)echo "  doc            Build html based documentation using Sphinx tool"
1284	$(s)echo ""
1285	$(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1286	$(s)echo ""
1287	$(s)echo "example: build all targets for the FVP platform:"
1288	$(s)echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1289
1290.PHONY: FORCE
1291FORCE:;
1292