xref: /rk3399_ARM-atf/Makefile (revision fda676d3d2b0d59a7eb6ff22a7fa27a006987c2e)
1#
2# Copyright (c) 2013-2023, 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			:= 8
12VERSION				:= ${VERSION_MAJOR}.${VERSION_MINOR}
13
14# Default goal is build all images
15.DEFAULT_GOAL			:= all
16
17# Avoid any implicit propagation of command line variable definitions to
18# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
19# usage. Other command line options like "-s" are still propagated as usual.
20MAKEOVERRIDES =
21
22MAKE_HELPERS_DIRECTORY := make_helpers/
23include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
24include ${MAKE_HELPERS_DIRECTORY}build_env.mk
25
26################################################################################
27# Default values for build configurations, and their dependencies
28################################################################################
29
30include ${MAKE_HELPERS_DIRECTORY}defaults.mk
31
32# Assertions enabled for DEBUG builds by default
33ENABLE_ASSERTIONS		:= ${DEBUG}
34ENABLE_PMF			:= ${ENABLE_RUNTIME_INSTRUMENTATION}
35PLAT				:= ${DEFAULT_PLAT}
36
37################################################################################
38# Checkpatch script options
39################################################################################
40
41CHECKCODE_ARGS		:=	--no-patch
42# Do not check the coding style on imported library files or documentation files
43INC_ARM_DIRS_TO_CHECK	:=	$(sort $(filter-out                     \
44					include/drivers/arm/cryptocell,	\
45					$(wildcard include/drivers/arm/*)))
46INC_ARM_DIRS_TO_CHECK	+=	include/drivers/arm/cryptocell/*.h
47INC_DRV_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
48					include/drivers/arm,		\
49					$(wildcard include/drivers/*)))
50INC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
51					include/lib/libfdt		\
52					include/lib/libc,		\
53					$(wildcard include/lib/*)))
54INC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
55					include/lib			\
56					include/drivers,		\
57					$(wildcard include/*)))
58LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
59					lib/compiler-rt			\
60					lib/libfdt%			\
61					lib/libc,			\
62					lib/zlib			\
63					$(wildcard lib/*)))
64ROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
65					lib				\
66					include				\
67					docs				\
68					%.rst,				\
69					$(wildcard *)))
70CHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
71				${INC_DIRS_TO_CHECK}			\
72				${INC_LIB_DIRS_TO_CHECK}		\
73				${LIB_DIRS_TO_CHECK}			\
74				${INC_DRV_DIRS_TO_CHECK}		\
75				${INC_ARM_DIRS_TO_CHECK}
76
77
78################################################################################
79# Process build options
80################################################################################
81
82# Verbose flag
83ifeq (${V},0)
84        Q:=@
85        ECHO:=@echo
86        CHECKCODE_ARGS	+=	--no-summary --terse
87else
88        Q:=
89        ECHO:=$(ECHO_QUIET)
90endif
91
92ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
93        Q:=@
94        ECHO:=$(ECHO_QUIET)
95endif
96
97export Q ECHO
98
99# The cert_create tool cannot generate certificates individually, so we use the
100# target 'certificates' to create them all
101ifneq (${GENERATE_COT},0)
102        FIP_DEPS += certificates
103        FWU_FIP_DEPS += fwu_certificates
104endif
105
106# Process BRANCH_PROTECTION value and set
107# Pointer Authentication and Branch Target Identification flags
108ifeq (${BRANCH_PROTECTION},0)
109	# Default value turns off all types of branch protection
110	BP_OPTION := none
111else ifneq (${ARCH},aarch64)
112        $(error BRANCH_PROTECTION requires AArch64)
113else ifeq (${BRANCH_PROTECTION},1)
114	# Enables all types of branch protection features
115	BP_OPTION := standard
116	ENABLE_BTI := 1
117	ENABLE_PAUTH := 1
118else ifeq (${BRANCH_PROTECTION},2)
119	# Return address signing to its standard level
120	BP_OPTION := pac-ret
121	ENABLE_PAUTH := 1
122else ifeq (${BRANCH_PROTECTION},3)
123	# Extend the signing to include leaf functions
124	BP_OPTION := pac-ret+leaf
125	ENABLE_PAUTH := 1
126else ifeq (${BRANCH_PROTECTION},4)
127	# Turn on branch target identification mechanism
128	BP_OPTION := bti
129	ENABLE_BTI := 1
130else
131        $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
132endif
133
134# FEAT_RME
135ifeq (${ENABLE_RME},1)
136# RME doesn't support PIE
137ifneq (${ENABLE_PIE},0)
138        $(error ENABLE_RME does not support PIE)
139endif
140# RME doesn't support BRBE
141ifneq (${ENABLE_BRBE_FOR_NS},0)
142        $(error ENABLE_RME does not support BRBE.)
143endif
144# RME requires AARCH64
145ifneq (${ARCH},aarch64)
146        $(error ENABLE_RME requires AArch64)
147endif
148# RME requires el2 context to be saved for now.
149CTX_INCLUDE_EL2_REGS := 1
150CTX_INCLUDE_AARCH32_REGS := 0
151ARM_ARCH_MAJOR := 8
152ARM_ARCH_MINOR := 5
153ENABLE_FEAT_ECV = 1
154ENABLE_FEAT_FGT = 1
155
156# RME enables CSV2_2 extension by default.
157ENABLE_FEAT_CSV2_2 = 1
158
159endif
160
161# USE_SPINLOCK_CAS requires AArch64 build
162ifeq (${USE_SPINLOCK_CAS},1)
163ifneq (${ARCH},aarch64)
164        $(error USE_SPINLOCK_CAS requires AArch64)
165endif
166endif
167
168# USE_DEBUGFS experimental feature recommended only in debug builds
169ifeq (${USE_DEBUGFS},1)
170ifeq (${DEBUG},1)
171        $(warning DEBUGFS experimental feature is enabled.)
172else
173        $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
174endif
175endif
176
177ifneq (${DECRYPTION_SUPPORT},none)
178ENC_ARGS += -f ${FW_ENC_STATUS}
179ENC_ARGS += -k ${ENC_KEY}
180ENC_ARGS += -n ${ENC_NONCE}
181FIP_DEPS += enctool
182FWU_FIP_DEPS += enctool
183endif
184
185################################################################################
186# Toolchain
187################################################################################
188
189HOSTCC			:=	gcc
190export HOSTCC
191
192CC			:=	${CROSS_COMPILE}gcc
193CPP			:=	${CROSS_COMPILE}cpp
194AS			:=	${CROSS_COMPILE}gcc
195AR			:=	${CROSS_COMPILE}ar
196LINKER			:=	${CROSS_COMPILE}ld
197OC			:=	${CROSS_COMPILE}objcopy
198OD			:=	${CROSS_COMPILE}objdump
199NM			:=	${CROSS_COMPILE}nm
200PP			:=	${CROSS_COMPILE}gcc -E
201DTC			:=	dtc
202
203# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
204ifneq ($(strip $(wildcard ${LD}.bfd) \
205	$(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
206LINKER			:=	${LINKER}.bfd
207endif
208
209ifeq (${ARM_ARCH_MAJOR},7)
210target32-directive	= 	-target arm-none-eabi
211# Will set march32-directive from platform configuration
212else
213target32-directive	= 	-target armv8a-none-eabi
214
215# Set the compiler's target architecture profile based on
216# ARM_ARCH_MAJOR ARM_ARCH_MINOR options
217ifeq (${ARM_ARCH_MINOR},0)
218march32-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
219march64-directive	= 	-march=armv${ARM_ARCH_MAJOR}-a
220else
221march32-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
222march64-directive	= 	-march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
223endif
224endif
225
226# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
227ifeq ($(ARCH), aarch64)
228# Check if revision is greater than or equal to 8.5
229ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
230mem_tag_arch_support	= 	yes
231endif
232endif
233
234# Get architecture feature modifiers
235arch-features		=	${ARM_ARCH_FEATURE}
236
237# Enable required options for memory stack tagging.
238# Currently, these options are enabled only for clang and armclang compiler.
239ifeq (${SUPPORT_STACK_MEMTAG},yes)
240ifdef mem_tag_arch_support
241# Check for armclang and clang compilers
242ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
243# Add "memtag" architecture feature modifier if not specified
244ifeq ( ,$(findstring memtag,$(arch-features)))
245arch-features       	:=       $(arch-features)+memtag
246endif	# memtag
247ifeq ($(notdir $(CC)),armclang)
248TF_CFLAGS		+=	-mmemtag-stack
249else ifeq ($(notdir $(CC)),clang)
250TF_CFLAGS		+=	-fsanitize=memtag
251endif	# armclang
252endif	# armclang clang
253else
254$(error "Error: stack memory tagging is not supported for architecture \
255	${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
256endif	# mem_tag_arch_support
257endif	# SUPPORT_STACK_MEMTAG
258
259# Set the compiler's architecture feature modifiers
260ifneq ($(arch-features), none)
261# Strip "none+" from arch-features
262arch-features		:=	$(subst none+,,$(arch-features))
263ifeq ($(ARCH), aarch32)
264march32-directive	:=	$(march32-directive)+$(arch-features)
265else
266march64-directive	:=	$(march64-directive)+$(arch-features)
267endif
268# Print features
269$(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
270endif	# arch-features
271
272# Determine if FEAT_RNG is supported
273ENABLE_FEAT_RNG		=	$(if $(findstring rng,${arch-features}),1,0)
274
275# Determine if FEAT_SB is supported
276ENABLE_FEAT_SB		=	$(if $(findstring sb,${arch-features}),1,0)
277
278ifneq ($(findstring clang,$(notdir $(CC))),)
279	ifneq ($(findstring armclang,$(notdir $(CC))),)
280		TF_CFLAGS_aarch32	:=	-target arm-arm-none-eabi $(march32-directive)
281		TF_CFLAGS_aarch64	:=	-target aarch64-arm-none-eabi $(march64-directive)
282		LD			:=	$(LINKER)
283	else
284		TF_CFLAGS_aarch32	=	$(target32-directive) $(march32-directive)
285		TF_CFLAGS_aarch64	:=	-target aarch64-elf $(march64-directive)
286		LD			:=	$(shell $(CC) --print-prog-name ld.lld)
287
288		AR			:=	$(shell $(CC) --print-prog-name llvm-ar)
289		OD			:=	$(shell $(CC) --print-prog-name llvm-objdump)
290		OC			:=	$(shell $(CC) --print-prog-name llvm-objcopy)
291	endif
292
293	CPP		:=	$(CC) -E $(TF_CFLAGS_$(ARCH))
294	PP		:=	$(CC) -E $(TF_CFLAGS_$(ARCH))
295	AS		:=	$(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
296else ifneq ($(findstring gcc,$(notdir $(CC))),)
297TF_CFLAGS_aarch32	=	$(march32-directive)
298TF_CFLAGS_aarch64	=	$(march64-directive)
299ifeq ($(ENABLE_LTO),1)
300	# Enable LTO only for aarch64
301	ifeq (${ARCH},aarch64)
302		LTO_CFLAGS	=	-flto
303		# Use gcc as a wrapper for the ld, recommended for LTO
304		LINKER		:=	${CROSS_COMPILE}gcc
305	endif
306endif
307LD			=	$(LINKER)
308else
309TF_CFLAGS_aarch32	=	$(march32-directive)
310TF_CFLAGS_aarch64	=	$(march64-directive)
311LD			=	$(LINKER)
312endif
313
314# Process Debug flag
315$(eval $(call add_define,DEBUG))
316ifneq (${DEBUG}, 0)
317        BUILD_TYPE	:=	debug
318        TF_CFLAGS	+=	-g -gdwarf-4
319        ASFLAGS		+=	-g -Wa,-gdwarf-4
320
321        # Use LOG_LEVEL_INFO by default for debug builds
322        LOG_LEVEL	:=	40
323else
324        BUILD_TYPE	:=	release
325        # Use LOG_LEVEL_NOTICE by default for release builds
326        LOG_LEVEL	:=	20
327endif
328
329# Default build string (git branch and commit)
330ifeq (${BUILD_STRING},)
331        BUILD_STRING  :=  $(shell git describe --always --dirty --tags 2> /dev/null)
332endif
333VERSION_STRING    :=  v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
334
335ifeq (${AARCH32_INSTRUCTION_SET},A32)
336TF_CFLAGS_aarch32	+=	-marm
337else ifeq (${AARCH32_INSTRUCTION_SET},T32)
338TF_CFLAGS_aarch32	+=	-mthumb
339else
340$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
341endif
342
343TF_CFLAGS_aarch32	+=	-mno-unaligned-access
344TF_CFLAGS_aarch64	+=	-mgeneral-regs-only -mstrict-align
345
346ifneq (${BP_OPTION},none)
347TF_CFLAGS_aarch64	+=	-mbranch-protection=${BP_OPTION}
348endif
349
350ASFLAGS_aarch32		=	$(march32-directive)
351ASFLAGS_aarch64		=	$(march64-directive)
352
353# General warnings
354WARNINGS		:=	-Wall -Wmissing-include-dirs -Wunused	\
355				-Wdisabled-optimization -Wvla -Wshadow	\
356				-Wredundant-decls
357# stricter warnings
358WARNINGS		+=	-Wextra -Wno-trigraphs
359# too verbose for generic build
360WARNINGS		+=	-Wno-missing-field-initializers \
361				-Wno-type-limits -Wno-sign-compare \
362# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
363WARNINGS		+=	-Wno-unused-parameter
364
365# Additional warnings
366# Level 1 - infrequent warnings we should have none of
367# full -Wextra
368WARNING1 += -Wsign-compare
369WARNING1 += -Wtype-limits
370WARNING1 += -Wmissing-field-initializers
371
372# Level 2 - problematic warnings that we want
373# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
374# TODO: disable just for them and move into default build
375WARNING2 += -Wold-style-definition
376WARNING2 += -Wmissing-prototypes
377WARNING2 += -Wmissing-format-attribute
378# TF-A aims to comply with this eventually. Effort too large at present
379WARNING2 += -Wundef
380# currently very involved and many platforms set this off
381WARNING2 += -Wunused-const-variable=2
382
383# Level 3 - very pedantic, frequently ignored
384WARNING3 := -Wbad-function-cast
385WARNING3 += -Waggregate-return
386WARNING3 += -Wnested-externs
387WARNING3 += -Wcast-align
388WARNING3 += -Wcast-qual
389WARNING3 += -Wconversion
390WARNING3 += -Wpacked
391WARNING3 += -Wpointer-arith
392WARNING3 += -Wswitch-default
393
394# Setting W is quite verbose and most warnings will be pre-existing issues
395# outside of the contributor's control. Don't fail the build on them so warnings
396# can be seen and hopefully addressed
397ifdef W
398ifneq (${W},0)
399E	 ?= 0
400endif
401endif
402
403ifeq (${W},1)
404WARNINGS += $(WARNING1)
405else ifeq (${W},2)
406WARNINGS += $(WARNING1) $(WARNING2)
407else ifeq (${W},3)
408WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
409endif
410
411# Compiler specific warnings
412ifeq ($(findstring clang,$(notdir $(CC))),)
413# not using clang
414WARNINGS	+=		-Wunused-but-set-variable -Wmaybe-uninitialized	\
415				-Wpacked-bitfield-compat -Wshift-overflow=2 \
416				-Wlogical-op
417else
418# using clang
419WARNINGS	+=		-Wshift-overflow -Wshift-sign-overflow \
420				-Wlogical-op-parentheses
421endif
422
423ifneq (${E},0)
424ERRORS := -Werror
425endif
426
427CPPFLAGS		=	${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc	\
428				$(ERRORS) $(WARNINGS)
429ASFLAGS			+=	$(CPPFLAGS) $(ASFLAGS_$(ARCH))			\
430				-ffreestanding -Wa,--fatal-warnings
431TF_CFLAGS		+=	$(CPPFLAGS) $(TF_CFLAGS_$(ARCH))		\
432				-ffunction-sections -fdata-sections		\
433				-ffreestanding -fno-builtin -fno-common		\
434				-Os -std=gnu99
435
436$(eval $(call add_define,SVE_VECTOR_LEN))
437
438ifeq (${SANITIZE_UB},on)
439TF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover
440endif
441ifeq (${SANITIZE_UB},trap)
442TF_CFLAGS		+=	-fsanitize=undefined -fno-sanitize-recover	\
443				-fsanitize-undefined-trap-on-error
444endif
445
446GCC_V_OUTPUT		:=	$(shell $(CC) -v 2>&1)
447
448TF_LDFLAGS		+=	-z noexecstack
449
450# LD = armlink
451ifneq ($(findstring armlink,$(notdir $(LD))),)
452TF_LDFLAGS		+=	--diag_error=warning --lto_level=O1
453TF_LDFLAGS		+=	--remove --info=unused,unusedsymbols
454TF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH))
455
456# LD = gcc (used when GCC LTO is enabled)
457else ifneq ($(findstring gcc,$(notdir $(LD))),)
458# Pass ld options with Wl or Xlinker switches
459TF_LDFLAGS		+=	-Wl,--fatal-warnings -O1
460TF_LDFLAGS		+=	-Wl,--gc-sections
461
462TF_LDFLAGS		+=	-Wl,-z,common-page-size=4096 # Configure page size constants
463TF_LDFLAGS		+=	-Wl,-z,max-page-size=4096
464
465ifeq ($(ENABLE_LTO),1)
466	ifeq (${ARCH},aarch64)
467		TF_LDFLAGS	+=	-flto -fuse-linker-plugin
468	endif
469endif
470# GCC automatically adds fix-cortex-a53-843419 flag when used to link
471# which breaks some builds, so disable if errata fix is not explicitly enabled
472ifneq (${ERRATA_A53_843419},1)
473	TF_LDFLAGS	+= 	-mno-fix-cortex-a53-843419
474endif
475TF_LDFLAGS		+= 	-nostdlib
476TF_LDFLAGS		+=	$(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
477
478# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
479else
480# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
481# are not loaded by a elf loader.
482TF_LDFLAGS		+=	$(call ld_option, --no-warn-rwx-segments)
483TF_LDFLAGS		+=	-O1
484TF_LDFLAGS		+=	--gc-sections
485
486TF_LDFLAGS		+=	-z common-page-size=4096 # Configure page size constants
487TF_LDFLAGS		+=	-z max-page-size=4096
488
489# ld.lld doesn't recognize the errata flags,
490# therefore don't add those in that case.
491# ld.lld reports section type mismatch warnings,
492# therefore don't add --fatal-warnings to it.
493ifeq ($(findstring ld.lld,$(notdir $(LD))),)
494TF_LDFLAGS		+=	$(TF_LDFLAGS_$(ARCH)) --fatal-warnings
495endif
496endif
497
498DTC_FLAGS		+=	-I dts -O dtb
499DTC_CPPFLAGS		+=	-P -nostdinc -Iinclude -Ifdts -undef \
500				-x assembler-with-cpp $(DEFINES)
501
502################################################################################
503# Common sources and include directories
504################################################################################
505include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
506include lib/compiler-rt/compiler-rt.mk
507
508BL_COMMON_SOURCES	+=	common/bl_common.c			\
509				common/tf_log.c				\
510				common/${ARCH}/debug.S			\
511				drivers/console/multi_console.c		\
512				lib/${ARCH}/cache_helpers.S		\
513				lib/${ARCH}/misc_helpers.S		\
514				plat/common/plat_bl_common.c		\
515				plat/common/plat_log_common.c		\
516				plat/common/${ARCH}/plat_common.c	\
517				plat/common/${ARCH}/platform_helpers.S	\
518				${COMPILER_RT_SRCS}
519
520# Pointer Authentication sources
521ifeq (${ENABLE_PAUTH}, 1)
522# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
523# Pauth support. As it's not secure, it must be reimplemented for real platforms
524BL_COMMON_SOURCES	+=	lib/extensions/pauth/pauth_helpers.S
525endif
526
527ifeq ($(notdir $(CC)),armclang)
528BL_COMMON_SOURCES	+=	lib/${ARCH}/armclang_printf.S
529endif
530
531ifeq (${SANITIZE_UB},on)
532BL_COMMON_SOURCES	+=	plat/common/ubsan.c
533endif
534
535INCLUDES		+=	-Iinclude				\
536				-Iinclude/arch/${ARCH}			\
537				-Iinclude/lib/cpus/${ARCH}		\
538				-Iinclude/lib/el3_runtime/${ARCH}	\
539				${PLAT_INCLUDES}			\
540				${SPD_INCLUDES}
541
542include common/backtrace/backtrace.mk
543
544################################################################################
545# Generic definitions
546################################################################################
547
548include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
549
550ifeq (${BUILD_BASE},)
551     BUILD_BASE		:=	./build
552endif
553BUILD_PLAT		:=	$(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
554
555SPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
556
557# Platforms providing their own TBB makefile may override this value
558INCLUDE_TBBR_MK		:=	1
559
560
561################################################################################
562# Include SPD Makefile if one has been specified
563################################################################################
564
565ifneq (${SPD},none)
566    ifeq (${ARCH},aarch32)
567        $(error "Error: SPD is incompatible with AArch32.")
568    endif
569
570    ifdef EL3_PAYLOAD_BASE
571        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
572        $(warning "The SPD and its BL32 companion will be present but ignored.")
573    endif
574
575    ifeq (${SPD},spmd)
576        # SPMD is located in std_svc directory
577        SPD_DIR := std_svc
578
579        ifeq ($(SPMD_SPM_AT_SEL2),1)
580            CTX_INCLUDE_EL2_REGS := 1
581	    ifeq ($(SPMC_AT_EL3),1)
582                $(error SPM cannot be enabled in both S-EL2 and EL3.)
583            endif
584        endif
585
586        ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
587            DTC_CPPFLAGS	+=	-DOPTEE_SP_FW_CONFIG
588        endif
589
590        ifeq ($(TS_SP_FW_CONFIG),1)
591            DTC_CPPFLAGS	+=	-DTS_SP_FW_CONFIG
592        endif
593
594        ifneq ($(ARM_BL2_SP_LIST_DTS),)
595            DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
596        endif
597
598        ifneq ($(SP_LAYOUT_FILE),)
599            BL2_ENABLE_SP_LOAD := 1
600        endif
601    else
602        # All other SPDs in spd directory
603        SPD_DIR := spd
604    endif
605
606    # We expect to locate an spd.mk under the specified SPD directory
607    SPD_MAKE	:=	$(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
608
609    ifeq (${SPD_MAKE},)
610        $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
611    endif
612    $(info Including ${SPD_MAKE})
613    include ${SPD_MAKE}
614
615    # If there's BL32 companion for the chosen SPD, we expect that the SPD's
616    # Makefile would set NEED_BL32 to "yes". In this case, the build system
617    # supports two mutually exclusive options:
618    # * BL32 is built from source: then BL32_SOURCES must contain the list
619    #   of source files to build BL32
620    # * BL32 is a prebuilt binary: then BL32 must point to the image file
621    #   that will be included in the FIP
622    # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
623    # over the sources.
624endif
625
626ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
627ifeq (${SPD},none)
628ifeq (${ENABLE_RME},0)
629    $(error CTX_INCLUDE_EL2_REGS is available only when SPD or RME is enabled)
630endif
631endif
632endif
633
634################################################################################
635# Include rmmd Makefile if RME is enabled
636################################################################################
637
638ifneq (${ENABLE_RME},0)
639ifneq (${ARCH},aarch64)
640	$(error ENABLE_RME requires AArch64)
641endif
642ifeq ($(SPMC_AT_EL3),1)
643	$(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
644endif
645include services/std_svc/rmmd/rmmd.mk
646$(warning "RME is an experimental feature")
647endif
648
649################################################################################
650# Include the platform specific Makefile after the SPD Makefile (the platform
651# makefile may use all previous definitions in this file)
652################################################################################
653
654include ${PLAT_MAKEFILE_FULL}
655
656# This internal flag is common option which is set to 1 for scenarios
657# when the BL2 is running in EL3 level. This occurs in two scenarios -
658# 4 world system running BL2 at EL3 and two world system without BL1 running
659# BL2 in EL3
660
661ifeq (${RESET_TO_BL2},1)
662	BL2_RUNS_AT_EL3	:=	1
663    ifeq (${ENABLE_RME},1)
664        $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not supported at the moment.)
665    endif
666else ifeq (${ENABLE_RME},1)
667	BL2_RUNS_AT_EL3	:=	1
668else
669	BL2_RUNS_AT_EL3	:=	0
670endif
671
672$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
673
674ifeq (${ARM_ARCH_MAJOR},7)
675include make_helpers/armv7-a-cpus.mk
676endif
677
678PIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
679ifneq ($(PIE_FOUND),)
680	TF_CFLAGS	+=	-fno-PIE
681ifneq ($(findstring gcc,$(notdir $(LD))),)
682	TF_LDFLAGS	+=	-no-pie
683endif
684endif
685
686ifneq ($(findstring gcc,$(notdir $(LD))),)
687	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
688else
689	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
690endif
691
692ifeq ($(ENABLE_PIE),1)
693ifeq ($(RESET_TO_BL2),1)
694ifneq ($(BL2_IN_XIP_MEM),1)
695	BL2_CPPFLAGS	+=	-fpie
696	BL2_CFLAGS	+=	-fpie
697	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
698endif
699endif
700	BL31_CPPFLAGS	+=	-fpie
701	BL31_CFLAGS 	+=	-fpie
702	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
703
704	BL32_CPPFLAGS	+=	-fpie
705	BL32_CFLAGS	+=	-fpie
706	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
707endif
708
709ifeq (${ARCH},aarch64)
710BL1_CPPFLAGS += -DIMAGE_AT_EL3
711ifeq ($(RESET_TO_BL2),1)
712BL2_CPPFLAGS += -DIMAGE_AT_EL3
713else
714BL2_CPPFLAGS += -DIMAGE_AT_EL1
715endif
716BL2U_CPPFLAGS += -DIMAGE_AT_EL1
717BL31_CPPFLAGS += -DIMAGE_AT_EL3
718BL32_CPPFLAGS += -DIMAGE_AT_EL1
719endif
720
721# Include the CPU specific operations makefile, which provides default
722# values for all CPU errata workarounds and CPU specific optimisations.
723# This can be overridden by the platform.
724include lib/cpus/cpu-ops.mk
725
726ifeq (${ARCH},aarch32)
727NEED_BL32 := yes
728
729################################################################################
730# Build `AARCH32_SP` as BL32 image for AArch32
731################################################################################
732ifneq (${AARCH32_SP},none)
733# We expect to locate an sp.mk under the specified AARCH32_SP directory
734AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
735
736ifeq (${AARCH32_SP_MAKE},)
737  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
738endif
739
740$(info Including ${AARCH32_SP_MAKE})
741include ${AARCH32_SP_MAKE}
742endif
743
744endif
745
746################################################################################
747# Include libc if not overridden
748################################################################################
749ifeq (${OVERRIDE_LIBC},0)
750include lib/libc/libc.mk
751endif
752
753################################################################################
754# Check incompatible options
755################################################################################
756
757ifdef EL3_PAYLOAD_BASE
758        ifdef PRELOADED_BL33_BASE
759                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
760                incompatible build options. EL3_PAYLOAD_BASE has priority.")
761        endif
762        ifneq (${GENERATE_COT},0)
763                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
764        endif
765        ifneq (${TRUSTED_BOARD_BOOT},0)
766                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
767        endif
768endif
769
770ifeq (${NEED_BL33},yes)
771        ifdef EL3_PAYLOAD_BASE
772                $(warning "BL33 image is not needed when option \
773                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
774        endif
775        ifdef PRELOADED_BL33_BASE
776                $(warning "BL33 image is not needed when option \
777                PRELOADED_BL33_BASE is used and won't be added to the FIP \
778                file.")
779        endif
780endif
781
782# When building for systems with hardware-assisted coherency, there's no need to
783# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
784ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
785$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
786endif
787
788#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
789ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
790$(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
791endif
792
793# For RAS_EXTENSION, require that EAs are handled in EL3 first
794ifeq ($(RAS_EXTENSION),1)
795    ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
796        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1)
797    endif
798endif
799
800# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
801ifeq ($(FAULT_INJECTION_SUPPORT),1)
802    ifneq ($(RAS_EXTENSION),1)
803        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
804    endif
805endif
806
807# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
808ifeq ($(DYN_DISABLE_AUTH), 1)
809    ifeq (${TRUSTED_BOARD_BOOT}, 0)
810        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
811    endif
812endif
813
814ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
815# Support authentication verification and hash calculation
816    CRYPTO_SUPPORT := 3
817else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
818# Support authentication verification and hash calculation
819    CRYPTO_SUPPORT := 3
820else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
821# Support hash calculation only
822    CRYPTO_SUPPORT := 2
823else ifeq (${TRUSTED_BOARD_BOOT},1)
824# Support authentication verification only
825    CRYPTO_SUPPORT := 1
826else
827    CRYPTO_SUPPORT := 0
828endif
829
830# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
831ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
832$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
833endif
834
835# If pointer authentication is used in the firmware, make sure that all the
836# registers associated to it are also saved and restored.
837# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
838ifeq ($(ENABLE_PAUTH),1)
839    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
840        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
841    endif
842endif
843
844ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
845    ifneq (${ARCH},aarch64)
846        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
847    endif
848endif
849
850ifeq ($(CTX_INCLUDE_MTE_REGS),1)
851    ifneq (${ARCH},aarch64)
852        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
853    endif
854endif
855
856ifeq ($(PSA_FWU_SUPPORT),1)
857    $(info PSA_FWU_SUPPORT is an experimental feature)
858endif
859
860ifeq ($(FEATURE_DETECTION),1)
861    $(info FEATURE_DETECTION is an experimental feature)
862endif
863
864ifneq ($(ENABLE_SME2_FOR_NS), 0)
865    ifeq (${ENABLE_SME_FOR_NS}, 0)
866        $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also to be set")
867        $(warning "Forced ENABLE_SME_FOR_NS=1")
868        override ENABLE_SME_FOR_NS	:= 1
869    endif
870endif
871
872ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
873    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
874        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
875    endif
876endif
877
878ifneq (${DECRYPTION_SUPPORT},none)
879    ifeq (${TRUSTED_BOARD_BOOT}, 0)
880        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
881    endif
882endif
883
884# Ensure that no Aarch64-only features are enabled in Aarch32 build
885ifeq (${ARCH},aarch32)
886
887    # SME/SVE only supported on AArch64
888    ifneq (${ENABLE_SME_FOR_NS},0)
889        $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
890    endif
891
892    ifeq (${ENABLE_SVE_FOR_NS},1)
893        # Warning instead of error due to CI dependency on this
894        $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
895    endif
896
897    # BRBE is not supported in AArch32
898    ifeq (${ENABLE_BRBE_FOR_NS},1)
899        $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
900    endif
901
902    # FEAT_RNG_TRAP is not supported in AArch32
903    ifeq (${ENABLE_FEAT_RNG_TRAP},1)
904        $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
905    endif
906endif
907
908# Ensure ENABLE_RME is not used with SME
909ifeq (${ENABLE_RME},1)
910    ifneq (${ENABLE_SME_FOR_NS},0)
911        $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
912    endif
913endif
914
915# Secure SME/SVE requires the non-secure component as well
916ifeq (${ENABLE_SME_FOR_SWD},1)
917    ifeq (${ENABLE_SME_FOR_NS},0)
918        $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
919    endif
920endif
921ifeq (${ENABLE_SVE_FOR_SWD},1)
922    ifeq (${ENABLE_SVE_FOR_NS},0)
923        $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
924    endif
925endif
926
927# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
928# its own context management including FPU registers.
929ifeq (${CTX_INCLUDE_FPREGS},1)
930    ifneq (${ENABLE_SME_FOR_NS},0)
931        $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
932    endif
933
934    ifeq (${ENABLE_SVE_FOR_NS},1)
935        # Warning instead of error due to CI dependency on this
936        $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
937        $(warning "Forced ENABLE_SVE_FOR_NS=0")
938        override ENABLE_SVE_FOR_NS	:= 0
939    endif
940endif
941
942ifeq ($(DRTM_SUPPORT),1)
943    $(info DRTM_SUPPORT is an experimental feature)
944endif
945
946ifeq (${ENABLE_RME},1)
947    ifneq (${SEPARATE_CODE_AND_RODATA},1)
948        $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
949    endif
950endif
951
952################################################################################
953# Process platform overrideable behaviour
954################################################################################
955
956ifdef BL1_SOURCES
957NEED_BL1 := yes
958endif
959
960ifdef BL2_SOURCES
961	NEED_BL2 := yes
962
963	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
964	# Certificate generation tools. This flag can be overridden by the platform.
965	ifdef EL3_PAYLOAD_BASE
966                # If booting an EL3 payload there is no need for a BL33 image
967                # in the FIP file.
968                NEED_BL33		:=	no
969        else
970                ifdef PRELOADED_BL33_BASE
971                        # If booting a BL33 preloaded image there is no need of
972                        # another one in the FIP file.
973                        NEED_BL33		:=	no
974                else
975                        NEED_BL33		?=	yes
976                endif
977        endif
978endif
979
980ifdef BL2U_SOURCES
981NEED_BL2U := yes
982endif
983
984# If SCP_BL2 is given, we always want FIP to include it.
985ifdef SCP_BL2
986        NEED_SCP_BL2		:=	yes
987endif
988
989# For AArch32, BL31 is not currently supported.
990ifneq (${ARCH},aarch32)
991    ifdef BL31_SOURCES
992        # When booting an EL3 payload, there is no need to compile the BL31 image nor
993        # put it in the FIP.
994        ifndef EL3_PAYLOAD_BASE
995            NEED_BL31 := yes
996        endif
997    endif
998endif
999
1000# Process TBB related flags
1001ifneq (${GENERATE_COT},0)
1002        # Common cert_create options
1003        ifneq (${CREATE_KEYS},0)
1004                $(eval CRT_ARGS += -n)
1005                $(eval FWU_CRT_ARGS += -n)
1006                ifneq (${SAVE_KEYS},0)
1007                        $(eval CRT_ARGS += -k)
1008                        $(eval FWU_CRT_ARGS += -k)
1009                endif
1010        endif
1011        # Include TBBR makefile (unless the platform indicates otherwise)
1012        ifeq (${INCLUDE_TBBR_MK},1)
1013                include make_helpers/tbbr/tbbr_tools.mk
1014        endif
1015endif
1016
1017ifneq (${FIP_ALIGN},0)
1018FIP_ARGS += --align ${FIP_ALIGN}
1019endif
1020
1021ifdef FDT_SOURCES
1022NEED_FDT := yes
1023endif
1024
1025################################################################################
1026# Include libraries' Makefile that are used in all BL
1027################################################################################
1028
1029include lib/stack_protector/stack_protector.mk
1030
1031################################################################################
1032# Auxiliary tools (fiptool, cert_create, etc)
1033################################################################################
1034
1035# Variables for use with Certificate Generation Tool
1036CRTTOOLPATH		?=	tools/cert_create
1037CRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
1038
1039# Variables for use with Firmware Encryption Tool
1040ENCTOOLPATH		?=	tools/encrypt_fw
1041ENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
1042
1043# Variables for use with Firmware Image Package
1044FIPTOOLPATH		?=	tools/fiptool
1045FIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
1046
1047# Variables for use with sptool
1048SPTOOLPATH		?=	tools/sptool
1049SPTOOL			?=	${SPTOOLPATH}/sptool.py
1050SP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
1051
1052# Variables for use with ROMLIB
1053ROMLIBPATH		?=	lib/romlib
1054
1055# Variable for use with Python
1056PYTHON			?=	python3
1057
1058# Variables for use with PRINT_MEMORY_MAP
1059PRINT_MEMORY_MAP_PATH		?=	tools/memory
1060PRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
1061
1062# Variables for use with documentation build using Sphinx tool
1063DOCS_PATH		?=	docs
1064
1065# Defination of SIMICS flag
1066SIMICS_BUILD	?=	0
1067
1068################################################################################
1069# Include BL specific makefiles
1070################################################################################
1071
1072ifeq (${NEED_BL1},yes)
1073include bl1/bl1.mk
1074endif
1075
1076ifeq (${NEED_BL2},yes)
1077include bl2/bl2.mk
1078endif
1079
1080ifeq (${NEED_BL2U},yes)
1081include bl2u/bl2u.mk
1082endif
1083
1084ifeq (${NEED_BL31},yes)
1085include bl31/bl31.mk
1086endif
1087
1088################################################################################
1089# Build options checks
1090################################################################################
1091
1092$(eval $(call assert_booleans,\
1093    $(sort \
1094        ALLOW_RO_XLAT_TABLES \
1095        BL2_ENABLE_SP_LOAD \
1096        COLD_BOOT_SINGLE_CPU \
1097        CREATE_KEYS \
1098        CTX_INCLUDE_AARCH32_REGS \
1099        CTX_INCLUDE_FPREGS \
1100        CTX_INCLUDE_EL2_REGS \
1101        DEBUG \
1102        DISABLE_MTPMU \
1103        DYN_DISABLE_AUTH \
1104        EL3_EXCEPTION_HANDLING \
1105        ENABLE_AMU_AUXILIARY_COUNTERS \
1106        ENABLE_AMU_FCONF \
1107        AMU_RESTRICT_COUNTERS \
1108        ENABLE_ASSERTIONS \
1109        ENABLE_FEAT_SB \
1110        ENABLE_PIE \
1111        ENABLE_PMF \
1112        ENABLE_PSCI_STAT \
1113        ENABLE_RUNTIME_INSTRUMENTATION \
1114        ENABLE_SME_FOR_SWD \
1115        ENABLE_SVE_FOR_SWD \
1116        ERROR_DEPRECATED \
1117        FAULT_INJECTION_SUPPORT \
1118        GENERATE_COT \
1119        GICV2_G0_FOR_EL3 \
1120        HANDLE_EA_EL3_FIRST_NS \
1121        HW_ASSISTED_COHERENCY \
1122        INVERTED_MEMMAP \
1123        MEASURED_BOOT \
1124        DRTM_SUPPORT \
1125        NS_TIMER_SWITCH \
1126        OVERRIDE_LIBC \
1127        PL011_GENERIC_UART \
1128        PLAT_RSS_NOT_SUPPORTED \
1129        PROGRAMMABLE_RESET_ADDRESS \
1130        PSCI_EXTENDED_STATE_ID \
1131        PSCI_OS_INIT_MODE \
1132        RESET_TO_BL31 \
1133        SAVE_KEYS \
1134        SEPARATE_CODE_AND_RODATA \
1135        SEPARATE_BL2_NOLOAD_REGION \
1136        SEPARATE_NOBITS_REGION \
1137        SPIN_ON_BL1_EXIT \
1138        SPM_MM \
1139        SPMC_AT_EL3 \
1140        SPMD_SPM_AT_SEL2 \
1141        TRUSTED_BOARD_BOOT \
1142        USE_COHERENT_MEM \
1143        USE_DEBUGFS \
1144        ARM_IO_IN_DTB \
1145        SDEI_IN_FCONF \
1146        SEC_INT_DESC_IN_FCONF \
1147        USE_ROMLIB \
1148        USE_TBBR_DEFS \
1149        WARMBOOT_ENABLE_DCACHE_EARLY \
1150        RESET_TO_BL2 \
1151        BL2_IN_XIP_MEM \
1152        BL2_INV_DCACHE \
1153        USE_SPINLOCK_CAS \
1154        ENCRYPT_BL31 \
1155        ENCRYPT_BL32 \
1156        ERRATA_SPECULATIVE_AT \
1157        RAS_TRAP_NS_ERR_REC_ACCESS \
1158        COT_DESC_IN_DTB \
1159        USE_SP804_TIMER \
1160        PSA_FWU_SUPPORT \
1161        ENABLE_MPMM \
1162        ENABLE_MPMM_FCONF \
1163        SIMICS_BUILD \
1164        FEATURE_DETECTION \
1165	TRNG_SUPPORT \
1166	CONDITIONAL_CMO \
1167)))
1168
1169$(eval $(call assert_numerics,\
1170    $(sort \
1171        ARM_ARCH_MAJOR \
1172        ARM_ARCH_MINOR \
1173        BRANCH_PROTECTION \
1174        CTX_INCLUDE_PAUTH_REGS \
1175        CTX_INCLUDE_MTE_REGS \
1176        CTX_INCLUDE_NEVE_REGS \
1177        CRYPTO_SUPPORT \
1178        ENABLE_BRBE_FOR_NS \
1179        ENABLE_TRBE_FOR_NS \
1180        ENABLE_BTI \
1181        ENABLE_PAUTH \
1182        ENABLE_FEAT_AMU \
1183        ENABLE_FEAT_AMUv1p1 \
1184        ENABLE_FEAT_CSV2_2 \
1185        ENABLE_FEAT_DIT \
1186        ENABLE_FEAT_ECV \
1187        ENABLE_FEAT_FGT \
1188        ENABLE_FEAT_HCX \
1189        ENABLE_FEAT_PAN \
1190        ENABLE_FEAT_RNG \
1191        ENABLE_FEAT_RNG_TRAP \
1192        ENABLE_FEAT_SEL2 \
1193        ENABLE_FEAT_TCR2 \
1194        ENABLE_FEAT_S2PIE \
1195        ENABLE_FEAT_S1PIE \
1196        ENABLE_FEAT_S2POE \
1197        ENABLE_FEAT_S1POE \
1198        ENABLE_FEAT_GCS \
1199        ENABLE_FEAT_VHE \
1200        ENABLE_MPAM_FOR_LOWER_ELS \
1201        ENABLE_RME \
1202        ENABLE_SPE_FOR_NS \
1203        ENABLE_SYS_REG_TRACE_FOR_NS \
1204        ENABLE_SME_FOR_NS \
1205        ENABLE_SME2_FOR_NS \
1206        ENABLE_SVE_FOR_NS \
1207        ENABLE_TRF_FOR_NS \
1208        FW_ENC_STATUS \
1209        NR_OF_FW_BANKS \
1210        NR_OF_IMAGES_IN_FW_BANK \
1211        RAS_EXTENSION \
1212        TWED_DELAY \
1213        ENABLE_FEAT_TWED \
1214        SVE_VECTOR_LEN \
1215)))
1216
1217ifdef KEY_SIZE
1218        $(eval $(call assert_numeric,KEY_SIZE))
1219endif
1220
1221ifeq ($(filter $(SANITIZE_UB), on off trap),)
1222        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1223endif
1224
1225################################################################################
1226# Add definitions to the cpp preprocessor based on the current build options.
1227# This is done after including the platform specific makefile to allow the
1228# platform to overwrite the default options
1229################################################################################
1230
1231$(eval $(call add_defines,\
1232    $(sort \
1233        ALLOW_RO_XLAT_TABLES \
1234        ARM_ARCH_MAJOR \
1235        ARM_ARCH_MINOR \
1236        BL2_ENABLE_SP_LOAD \
1237        COLD_BOOT_SINGLE_CPU \
1238        CTX_INCLUDE_AARCH32_REGS \
1239        CTX_INCLUDE_FPREGS \
1240        CTX_INCLUDE_PAUTH_REGS \
1241        EL3_EXCEPTION_HANDLING \
1242        CTX_INCLUDE_MTE_REGS \
1243        CTX_INCLUDE_EL2_REGS \
1244        CTX_INCLUDE_NEVE_REGS \
1245        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1246        DISABLE_MTPMU \
1247        ENABLE_FEAT_AMU \
1248        ENABLE_AMU_AUXILIARY_COUNTERS \
1249        ENABLE_AMU_FCONF \
1250        AMU_RESTRICT_COUNTERS \
1251        ENABLE_ASSERTIONS \
1252        ENABLE_BTI \
1253        ENABLE_MPAM_FOR_LOWER_ELS \
1254        ENABLE_PAUTH \
1255        ENABLE_PIE \
1256        ENABLE_PMF \
1257        ENABLE_PSCI_STAT \
1258        ENABLE_RME \
1259        ENABLE_RUNTIME_INSTRUMENTATION \
1260        ENABLE_SME_FOR_NS \
1261        ENABLE_SME2_FOR_NS \
1262        ENABLE_SME_FOR_SWD \
1263        ENABLE_SPE_FOR_NS \
1264        ENABLE_SVE_FOR_NS \
1265        ENABLE_SVE_FOR_SWD \
1266        ENCRYPT_BL31 \
1267        ENCRYPT_BL32 \
1268        ERROR_DEPRECATED \
1269        FAULT_INJECTION_SUPPORT \
1270        GICV2_G0_FOR_EL3 \
1271        HANDLE_EA_EL3_FIRST_NS \
1272        HW_ASSISTED_COHERENCY \
1273        LOG_LEVEL \
1274        MEASURED_BOOT \
1275        DRTM_SUPPORT \
1276        NS_TIMER_SWITCH \
1277        PL011_GENERIC_UART \
1278        PLAT_${PLAT} \
1279        PLAT_RSS_NOT_SUPPORTED \
1280        PROGRAMMABLE_RESET_ADDRESS \
1281        PSCI_EXTENDED_STATE_ID \
1282        PSCI_OS_INIT_MODE \
1283        RAS_EXTENSION \
1284        RESET_TO_BL31 \
1285        SEPARATE_CODE_AND_RODATA \
1286        SEPARATE_BL2_NOLOAD_REGION \
1287        SEPARATE_NOBITS_REGION \
1288        RECLAIM_INIT_CODE \
1289        SPD_${SPD} \
1290        SPIN_ON_BL1_EXIT \
1291        SPM_MM \
1292        SPMC_AT_EL3 \
1293        SPMD_SPM_AT_SEL2 \
1294        TRUSTED_BOARD_BOOT \
1295        CRYPTO_SUPPORT \
1296        TRNG_SUPPORT \
1297        USE_COHERENT_MEM \
1298        USE_DEBUGFS \
1299        ARM_IO_IN_DTB \
1300        SDEI_IN_FCONF \
1301        SEC_INT_DESC_IN_FCONF \
1302        USE_ROMLIB \
1303        USE_TBBR_DEFS \
1304        WARMBOOT_ENABLE_DCACHE_EARLY \
1305        RESET_TO_BL2 \
1306        BL2_RUNS_AT_EL3	\
1307        BL2_IN_XIP_MEM \
1308        BL2_INV_DCACHE \
1309        USE_SPINLOCK_CAS \
1310        ERRATA_SPECULATIVE_AT \
1311        RAS_TRAP_NS_ERR_REC_ACCESS \
1312        COT_DESC_IN_DTB \
1313        USE_SP804_TIMER \
1314        ENABLE_FEAT_RNG \
1315        ENABLE_FEAT_RNG_TRAP \
1316        ENABLE_FEAT_SB \
1317        ENABLE_FEAT_DIT \
1318        NR_OF_FW_BANKS \
1319        NR_OF_IMAGES_IN_FW_BANK \
1320        PSA_FWU_SUPPORT \
1321        ENABLE_BRBE_FOR_NS \
1322        ENABLE_TRBE_FOR_NS \
1323        ENABLE_SYS_REG_TRACE_FOR_NS \
1324        ENABLE_TRF_FOR_NS \
1325        ENABLE_FEAT_HCX \
1326        ENABLE_MPMM \
1327        ENABLE_MPMM_FCONF \
1328        ENABLE_FEAT_FGT \
1329        ENABLE_FEAT_ECV \
1330        SIMICS_BUILD \
1331        ENABLE_FEAT_AMUv1p1 \
1332        ENABLE_FEAT_SEL2 \
1333        ENABLE_FEAT_VHE \
1334        ENABLE_FEAT_CSV2_2 \
1335        ENABLE_FEAT_PAN \
1336        ENABLE_FEAT_TCR2 \
1337        ENABLE_FEAT_S2PIE \
1338        ENABLE_FEAT_S1PIE \
1339        ENABLE_FEAT_S2POE \
1340        ENABLE_FEAT_S1POE \
1341        ENABLE_FEAT_GCS \
1342        FEATURE_DETECTION \
1343        TWED_DELAY \
1344        ENABLE_FEAT_TWED \
1345	CONDITIONAL_CMO \
1346)))
1347
1348ifeq (${SANITIZE_UB},trap)
1349        $(eval $(call add_define,MONITOR_TRAPS))
1350endif
1351
1352# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1353ifdef EL3_PAYLOAD_BASE
1354        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1355else
1356        # Define the PRELOADED_BL33_BASE flag only if it is provided and
1357        # EL3_PAYLOAD_BASE is not defined, as it has priority.
1358        ifdef PRELOADED_BL33_BASE
1359                $(eval $(call add_define,PRELOADED_BL33_BASE))
1360        endif
1361endif
1362
1363# Define the DYN_DISABLE_AUTH flag only if set.
1364ifeq (${DYN_DISABLE_AUTH},1)
1365$(eval $(call add_define,DYN_DISABLE_AUTH))
1366endif
1367
1368ifneq ($(findstring armlink,$(notdir $(LD))),)
1369$(eval $(call add_define,USE_ARM_LINK))
1370endif
1371
1372# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1373ifeq (${SPD},spmd)
1374ifdef SP_LAYOUT_FILE
1375        -include $(BUILD_PLAT)/sp_gen.mk
1376        FIP_DEPS += sp
1377        CRT_DEPS += sp
1378        NEED_SP_PKG := yes
1379else
1380        ifeq (${SPMD_SPM_AT_SEL2},1)
1381            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1382        endif
1383endif
1384endif
1385
1386################################################################################
1387# Build targets
1388################################################################################
1389
1390.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
1391.SUFFIXES:
1392
1393all: msg_start
1394
1395msg_start:
1396	@echo "Building ${PLAT}"
1397
1398ifeq (${ERROR_DEPRECATED},0)
1399# Check if deprecated declarations and cpp warnings should be treated as error or not.
1400ifneq ($(findstring clang,$(notdir $(CC))),)
1401    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1402else
1403    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
1404endif
1405endif # !ERROR_DEPRECATED
1406
1407$(eval $(call MAKE_LIB_DIRS))
1408$(eval $(call MAKE_LIB,c))
1409
1410# Expand build macros for the different images
1411ifeq (${NEED_BL1},yes)
1412BL1_SOURCES := $(sort ${BL1_SOURCES})
1413
1414$(eval $(call MAKE_BL,bl1))
1415endif
1416
1417ifeq (${NEED_BL2},yes)
1418ifeq (${RESET_TO_BL2}, 0)
1419FIP_BL2_ARGS := tb-fw
1420endif
1421
1422BL2_SOURCES := $(sort ${BL2_SOURCES})
1423
1424$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1425	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1426endif
1427
1428ifeq (${NEED_SCP_BL2},yes)
1429$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1430endif
1431
1432ifeq (${NEED_BL31},yes)
1433BL31_SOURCES += ${SPD_SOURCES}
1434# Sort BL31 source files to remove duplicates
1435BL31_SOURCES := $(sort ${BL31_SOURCES})
1436ifneq (${DECRYPTION_SUPPORT},none)
1437$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1438	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1439else
1440$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1441	$(eval $(call MAKE_BL,bl31,soc-fw)))
1442endif
1443endif
1444
1445# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1446# build system will call TOOL_ADD_IMG to print a warning message and abort the
1447# process. Note that the dependency on BL32 applies to the FIP only.
1448ifeq (${NEED_BL32},yes)
1449# Sort BL32 source files to remove duplicates
1450BL32_SOURCES := $(sort ${BL32_SOURCES})
1451BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1452
1453ifneq (${DECRYPTION_SUPPORT},none)
1454$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1455	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1456else
1457$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
1458	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1459endif
1460endif
1461
1462# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1463# needs to be built from RMM_SOURCES.
1464ifeq (${NEED_RMM},yes)
1465# Sort RMM source files to remove duplicates
1466RMM_SOURCES := $(sort ${RMM_SOURCES})
1467BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1468
1469$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1470         $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1471endif
1472
1473# Add the BL33 image if required by the platform
1474ifeq (${NEED_BL33},yes)
1475$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1476endif
1477
1478ifeq (${NEED_BL2U},yes)
1479$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1480	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1481endif
1482
1483# Expand build macros for the different images
1484ifeq (${NEED_FDT},yes)
1485    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
1486endif
1487
1488# Add Secure Partition packages
1489ifeq (${NEED_SP_PKG},yes)
1490$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1491	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1492sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1493	@${ECHO_BLANK_LINE}
1494	@echo "Built SP Images successfully"
1495	@${ECHO_BLANK_LINE}
1496endif
1497
1498locate-checkpatch:
1499ifndef CHECKPATCH
1500	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1501else
1502ifeq (,$(wildcard ${CHECKPATCH}))
1503	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1504endif
1505endif
1506
1507clean:
1508	@echo "  CLEAN"
1509	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
1510ifdef UNIX_MK
1511	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1512else
1513# Clear the MAKEFLAGS as we do not want
1514# to pass the gnumake flags to nmake.
1515	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1516endif
1517	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1518	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1519	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1520
1521realclean distclean:
1522	@echo "  REALCLEAN"
1523	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1524	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
1525ifdef UNIX_MK
1526	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1527else
1528# Clear the MAKEFLAGS as we do not want
1529# to pass the gnumake flags to nmake.
1530	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1531endif
1532	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1533	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1534	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1535
1536checkcodebase:		locate-checkpatch
1537	@echo "  CHECKING STYLE"
1538	@if test -d .git ; then						\
1539		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
1540		while read GIT_FILE ;					\
1541		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
1542		done ;							\
1543	else								\
1544		 find . -type f -not -iwholename "*.git*"		\
1545		 -not -iwholename "*build*"				\
1546		 -not -iwholename "*libfdt*"				\
1547		 -not -iwholename "*libc*"				\
1548		 -not -iwholename "*docs*"				\
1549		 -not -iwholename "*.rst"				\
1550		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
1551	fi
1552
1553checkpatch:		locate-checkpatch
1554	@echo "  CHECKING STYLE"
1555	@if test -n "${CHECKPATCH_OPTS}"; then				\
1556		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
1557	fi
1558	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
1559	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
1560	do								\
1561		printf "\n[*] Checking style of '$$commit'\n\n";	\
1562		git log --format=email "$$commit~..$$commit"		\
1563			-- ${CHECK_PATHS} |				\
1564			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
1565		git diff --format=email "$$commit~..$$commit"		\
1566			-- ${CHECK_PATHS} |				\
1567			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
1568	done
1569
1570certtool: ${CRTTOOL}
1571
1572${CRTTOOL}: FORCE
1573	${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${CRTTOOLPATH} all
1574	@${ECHO_BLANK_LINE}
1575	@echo "Built $@ successfully"
1576	@${ECHO_BLANK_LINE}
1577
1578ifneq (${GENERATE_COT},0)
1579certificates: ${CRT_DEPS} ${CRTTOOL}
1580	${Q}${CRTTOOL} ${CRT_ARGS}
1581	@${ECHO_BLANK_LINE}
1582	@echo "Built $@ successfully"
1583	@echo "Certificates can be found in ${BUILD_PLAT}"
1584	@${ECHO_BLANK_LINE}
1585endif
1586
1587${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
1588	$(eval ${CHECK_FIP_CMD})
1589	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1590	${Q}${FIPTOOL} info $@
1591	@${ECHO_BLANK_LINE}
1592	@echo "Built $@ successfully"
1593	@${ECHO_BLANK_LINE}
1594
1595ifneq (${GENERATE_COT},0)
1596fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1597	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1598	@${ECHO_BLANK_LINE}
1599	@echo "Built $@ successfully"
1600	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1601	@${ECHO_BLANK_LINE}
1602endif
1603
1604${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
1605	$(eval ${CHECK_FWU_FIP_CMD})
1606	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1607	${Q}${FIPTOOL} info $@
1608	@${ECHO_BLANK_LINE}
1609	@echo "Built $@ successfully"
1610	@${ECHO_BLANK_LINE}
1611
1612fiptool: ${FIPTOOL}
1613fip: ${BUILD_PLAT}/${FIP_NAME}
1614fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
1615
1616${FIPTOOL}: FORCE
1617ifdef UNIX_MK
1618	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
1619else
1620# Clear the MAKEFLAGS as we do not want
1621# to pass the gnumake flags to nmake.
1622	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1623endif
1624
1625romlib.bin: libraries FORCE
1626	${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
1627
1628# Call print_memory_map tool
1629memmap: all
1630	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1631
1632doc:
1633	@echo "  BUILD DOCUMENTATION"
1634	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1635
1636enctool: ${ENCTOOL}
1637
1638${ENCTOOL}: FORCE
1639	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
1640	@${ECHO_BLANK_LINE}
1641	@echo "Built $@ successfully"
1642	@${ECHO_BLANK_LINE}
1643
1644cscope:
1645	@echo "  CSCOPE"
1646	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1647	${Q}cscope -b -q -k
1648
1649help:
1650	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1651	@echo ""
1652	@echo "PLAT is used to specify which platform you wish to build."
1653	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1654	@echo ""
1655	@echo "platform = ${PLATFORM_LIST}"
1656	@echo ""
1657	@echo "Please refer to the User Guide for a list of all supported options."
1658	@echo "Note that the build system doesn't track dependencies for build "
1659	@echo "options. Therefore, if any of the build options are changed "
1660	@echo "from a previous build, a clean build must be performed."
1661	@echo ""
1662	@echo "Supported Targets:"
1663	@echo "  all            Build all individual bootloader binaries"
1664	@echo "  bl1            Build the BL1 binary"
1665	@echo "  bl2            Build the BL2 binary"
1666	@echo "  bl2u           Build the BL2U binary"
1667	@echo "  bl31           Build the BL31 binary"
1668	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
1669	@echo "                 this builds secure payload specified by AARCH32_SP"
1670	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
1671	@echo "  fip            Build the Firmware Image Package (FIP)"
1672	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
1673	@echo "  checkcodebase  Check the coding style of the entire source tree"
1674	@echo "  checkpatch     Check the coding style on changes in the current"
1675	@echo "                 branch against BASE_COMMIT (default origin/master)"
1676	@echo "  clean          Clean the build for the selected platform"
1677	@echo "  cscope         Generate cscope index"
1678	@echo "  distclean      Remove all build artifacts for all platforms"
1679	@echo "  certtool       Build the Certificate generation tool"
1680	@echo "  enctool        Build the Firmware encryption tool"
1681	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1682	@echo "  sp             Build the Secure Partition Packages"
1683	@echo "  sptool         Build the Secure Partition Package creation tool"
1684	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1685	@echo "  memmap         Print the memory map of the built binaries"
1686	@echo "  doc            Build html based documentation using Sphinx tool"
1687	@echo ""
1688	@echo "Note: most build targets require PLAT to be set to a specific platform."
1689	@echo ""
1690	@echo "example: build all targets for the FVP platform:"
1691	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1692
1693.PHONY: FORCE
1694FORCE:;
1695