xref: /rk3399_ARM-atf/Makefile (revision 619bc13eda5b69a8c1e76b5fc0c6ee1f5dbb8a8e)
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_SME_FOR_NS), 0)
865    $(info ENABLE_SME_FOR_NS is an experimental feature)
866endif
867
868ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
869    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
870        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
871    endif
872endif
873
874ifneq (${DECRYPTION_SUPPORT},none)
875    ifeq (${TRUSTED_BOARD_BOOT}, 0)
876        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
877    endif
878endif
879
880# Ensure that no Aarch64-only features are enabled in Aarch32 build
881ifeq (${ARCH},aarch32)
882
883    # SME/SVE only supported on AArch64
884    ifneq (${ENABLE_SME_FOR_NS},0)
885        $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
886    endif
887    ifeq (${ENABLE_SVE_FOR_NS},1)
888        # Warning instead of error due to CI dependency on this
889        $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
890    endif
891
892    # BRBE is not supported in AArch32
893    ifeq (${ENABLE_BRBE_FOR_NS},1)
894        $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
895    endif
896
897    # FEAT_RNG_TRAP is not supported in AArch32
898    ifeq (${ENABLE_FEAT_RNG_TRAP},1)
899        $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
900    endif
901endif
902
903# Ensure ENABLE_RME is not used with SME
904ifeq (${ENABLE_RME},1)
905    ifneq (${ENABLE_SME_FOR_NS},0)
906        $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
907    endif
908endif
909
910# Secure SME/SVE requires the non-secure component as well
911ifeq (${ENABLE_SME_FOR_SWD},1)
912    ifeq (${ENABLE_SME_FOR_NS},0)
913        $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
914    endif
915endif
916ifeq (${ENABLE_SVE_FOR_SWD},1)
917    ifeq (${ENABLE_SVE_FOR_NS},0)
918        $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
919    endif
920endif
921
922# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
923# its own context management including FPU registers.
924ifeq (${CTX_INCLUDE_FPREGS},1)
925    ifneq (${ENABLE_SME_FOR_NS},0)
926        $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
927    endif
928    ifeq (${ENABLE_SVE_FOR_NS},1)
929        # Warning instead of error due to CI dependency on this
930        $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
931        $(warning "Forced ENABLE_SVE_FOR_NS=0")
932        override ENABLE_SVE_FOR_NS	:= 0
933    endif
934endif
935
936ifeq ($(DRTM_SUPPORT),1)
937    $(info DRTM_SUPPORT is an experimental feature)
938endif
939
940ifeq (${ENABLE_RME},1)
941    ifneq (${SEPARATE_CODE_AND_RODATA},1)
942        $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
943    endif
944endif
945
946################################################################################
947# Process platform overrideable behaviour
948################################################################################
949
950ifdef BL1_SOURCES
951NEED_BL1 := yes
952endif
953
954ifdef BL2_SOURCES
955	NEED_BL2 := yes
956
957	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
958	# Certificate generation tools. This flag can be overridden by the platform.
959	ifdef EL3_PAYLOAD_BASE
960                # If booting an EL3 payload there is no need for a BL33 image
961                # in the FIP file.
962                NEED_BL33		:=	no
963        else
964                ifdef PRELOADED_BL33_BASE
965                        # If booting a BL33 preloaded image there is no need of
966                        # another one in the FIP file.
967                        NEED_BL33		:=	no
968                else
969                        NEED_BL33		?=	yes
970                endif
971        endif
972endif
973
974ifdef BL2U_SOURCES
975NEED_BL2U := yes
976endif
977
978# If SCP_BL2 is given, we always want FIP to include it.
979ifdef SCP_BL2
980        NEED_SCP_BL2		:=	yes
981endif
982
983# For AArch32, BL31 is not currently supported.
984ifneq (${ARCH},aarch32)
985    ifdef BL31_SOURCES
986        # When booting an EL3 payload, there is no need to compile the BL31 image nor
987        # put it in the FIP.
988        ifndef EL3_PAYLOAD_BASE
989            NEED_BL31 := yes
990        endif
991    endif
992endif
993
994# Process TBB related flags
995ifneq (${GENERATE_COT},0)
996        # Common cert_create options
997        ifneq (${CREATE_KEYS},0)
998                $(eval CRT_ARGS += -n)
999                $(eval FWU_CRT_ARGS += -n)
1000                ifneq (${SAVE_KEYS},0)
1001                        $(eval CRT_ARGS += -k)
1002                        $(eval FWU_CRT_ARGS += -k)
1003                endif
1004        endif
1005        # Include TBBR makefile (unless the platform indicates otherwise)
1006        ifeq (${INCLUDE_TBBR_MK},1)
1007                include make_helpers/tbbr/tbbr_tools.mk
1008        endif
1009endif
1010
1011ifneq (${FIP_ALIGN},0)
1012FIP_ARGS += --align ${FIP_ALIGN}
1013endif
1014
1015ifdef FDT_SOURCES
1016NEED_FDT := yes
1017endif
1018
1019################################################################################
1020# Include libraries' Makefile that are used in all BL
1021################################################################################
1022
1023include lib/stack_protector/stack_protector.mk
1024
1025################################################################################
1026# Auxiliary tools (fiptool, cert_create, etc)
1027################################################################################
1028
1029# Variables for use with Certificate Generation Tool
1030CRTTOOLPATH		?=	tools/cert_create
1031CRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
1032
1033# Variables for use with Firmware Encryption Tool
1034ENCTOOLPATH		?=	tools/encrypt_fw
1035ENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
1036
1037# Variables for use with Firmware Image Package
1038FIPTOOLPATH		?=	tools/fiptool
1039FIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
1040
1041# Variables for use with sptool
1042SPTOOLPATH		?=	tools/sptool
1043SPTOOL			?=	${SPTOOLPATH}/sptool.py
1044SP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
1045
1046# Variables for use with ROMLIB
1047ROMLIBPATH		?=	lib/romlib
1048
1049# Variable for use with Python
1050PYTHON			?=	python3
1051
1052# Variables for use with PRINT_MEMORY_MAP
1053PRINT_MEMORY_MAP_PATH		?=	tools/memory
1054PRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
1055
1056# Variables for use with documentation build using Sphinx tool
1057DOCS_PATH		?=	docs
1058
1059# Defination of SIMICS flag
1060SIMICS_BUILD	?=	0
1061
1062################################################################################
1063# Include BL specific makefiles
1064################################################################################
1065
1066ifeq (${NEED_BL1},yes)
1067include bl1/bl1.mk
1068endif
1069
1070ifeq (${NEED_BL2},yes)
1071include bl2/bl2.mk
1072endif
1073
1074ifeq (${NEED_BL2U},yes)
1075include bl2u/bl2u.mk
1076endif
1077
1078ifeq (${NEED_BL31},yes)
1079include bl31/bl31.mk
1080endif
1081
1082################################################################################
1083# Build options checks
1084################################################################################
1085
1086$(eval $(call assert_booleans,\
1087    $(sort \
1088        ALLOW_RO_XLAT_TABLES \
1089        BL2_ENABLE_SP_LOAD \
1090        COLD_BOOT_SINGLE_CPU \
1091        CREATE_KEYS \
1092        CTX_INCLUDE_AARCH32_REGS \
1093        CTX_INCLUDE_FPREGS \
1094        CTX_INCLUDE_EL2_REGS \
1095        DEBUG \
1096        DISABLE_MTPMU \
1097        DYN_DISABLE_AUTH \
1098        EL3_EXCEPTION_HANDLING \
1099        ENABLE_AMU_AUXILIARY_COUNTERS \
1100        ENABLE_AMU_FCONF \
1101        AMU_RESTRICT_COUNTERS \
1102        ENABLE_ASSERTIONS \
1103        ENABLE_FEAT_SB \
1104        ENABLE_PIE \
1105        ENABLE_PMF \
1106        ENABLE_PSCI_STAT \
1107        ENABLE_RUNTIME_INSTRUMENTATION \
1108        ENABLE_SME_FOR_SWD \
1109        ENABLE_SVE_FOR_SWD \
1110        ERROR_DEPRECATED \
1111        FAULT_INJECTION_SUPPORT \
1112        GENERATE_COT \
1113        GICV2_G0_FOR_EL3 \
1114        HANDLE_EA_EL3_FIRST_NS \
1115        HW_ASSISTED_COHERENCY \
1116        INVERTED_MEMMAP \
1117        MEASURED_BOOT \
1118        DRTM_SUPPORT \
1119        NS_TIMER_SWITCH \
1120        OVERRIDE_LIBC \
1121        PL011_GENERIC_UART \
1122        PLAT_RSS_NOT_SUPPORTED \
1123        PROGRAMMABLE_RESET_ADDRESS \
1124        PSCI_EXTENDED_STATE_ID \
1125        PSCI_OS_INIT_MODE \
1126        RESET_TO_BL31 \
1127        SAVE_KEYS \
1128        SEPARATE_CODE_AND_RODATA \
1129        SEPARATE_BL2_NOLOAD_REGION \
1130        SEPARATE_NOBITS_REGION \
1131        SPIN_ON_BL1_EXIT \
1132        SPM_MM \
1133        SPMC_AT_EL3 \
1134        SPMD_SPM_AT_SEL2 \
1135        TRUSTED_BOARD_BOOT \
1136        USE_COHERENT_MEM \
1137        USE_DEBUGFS \
1138        ARM_IO_IN_DTB \
1139        SDEI_IN_FCONF \
1140        SEC_INT_DESC_IN_FCONF \
1141        USE_ROMLIB \
1142        USE_TBBR_DEFS \
1143        WARMBOOT_ENABLE_DCACHE_EARLY \
1144        RESET_TO_BL2 \
1145        BL2_IN_XIP_MEM \
1146        BL2_INV_DCACHE \
1147        USE_SPINLOCK_CAS \
1148        ENCRYPT_BL31 \
1149        ENCRYPT_BL32 \
1150        ERRATA_SPECULATIVE_AT \
1151        RAS_TRAP_NS_ERR_REC_ACCESS \
1152        COT_DESC_IN_DTB \
1153        USE_SP804_TIMER \
1154        PSA_FWU_SUPPORT \
1155        ENABLE_MPMM \
1156        ENABLE_MPMM_FCONF \
1157        SIMICS_BUILD \
1158        FEATURE_DETECTION \
1159	TRNG_SUPPORT \
1160	CONDITIONAL_CMO \
1161)))
1162
1163$(eval $(call assert_numerics,\
1164    $(sort \
1165        ARM_ARCH_MAJOR \
1166        ARM_ARCH_MINOR \
1167        BRANCH_PROTECTION \
1168        CTX_INCLUDE_PAUTH_REGS \
1169        CTX_INCLUDE_MTE_REGS \
1170        CTX_INCLUDE_NEVE_REGS \
1171        CRYPTO_SUPPORT \
1172        ENABLE_BRBE_FOR_NS \
1173        ENABLE_TRBE_FOR_NS \
1174        ENABLE_BTI \
1175        ENABLE_PAUTH \
1176        ENABLE_FEAT_AMU \
1177        ENABLE_FEAT_AMUv1p1 \
1178        ENABLE_FEAT_CSV2_2 \
1179        ENABLE_FEAT_DIT \
1180        ENABLE_FEAT_ECV \
1181        ENABLE_FEAT_FGT \
1182        ENABLE_FEAT_HCX \
1183        ENABLE_FEAT_PAN \
1184        ENABLE_FEAT_RNG \
1185        ENABLE_FEAT_RNG_TRAP \
1186        ENABLE_FEAT_SEL2 \
1187        ENABLE_FEAT_TCR2 \
1188        ENABLE_FEAT_S2PIE \
1189        ENABLE_FEAT_S1PIE \
1190        ENABLE_FEAT_S2POE \
1191        ENABLE_FEAT_S1POE \
1192        ENABLE_FEAT_VHE \
1193        ENABLE_MPAM_FOR_LOWER_ELS \
1194        ENABLE_RME \
1195        ENABLE_SPE_FOR_NS \
1196        ENABLE_SYS_REG_TRACE_FOR_NS \
1197        ENABLE_SME_FOR_NS \
1198        ENABLE_SVE_FOR_NS \
1199        ENABLE_TRF_FOR_NS \
1200        FW_ENC_STATUS \
1201        NR_OF_FW_BANKS \
1202        NR_OF_IMAGES_IN_FW_BANK \
1203        RAS_EXTENSION \
1204        TWED_DELAY \
1205        ENABLE_FEAT_TWED \
1206        SVE_VECTOR_LEN \
1207)))
1208
1209ifdef KEY_SIZE
1210        $(eval $(call assert_numeric,KEY_SIZE))
1211endif
1212
1213ifeq ($(filter $(SANITIZE_UB), on off trap),)
1214        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1215endif
1216
1217################################################################################
1218# Add definitions to the cpp preprocessor based on the current build options.
1219# This is done after including the platform specific makefile to allow the
1220# platform to overwrite the default options
1221################################################################################
1222
1223$(eval $(call add_defines,\
1224    $(sort \
1225        ALLOW_RO_XLAT_TABLES \
1226        ARM_ARCH_MAJOR \
1227        ARM_ARCH_MINOR \
1228        BL2_ENABLE_SP_LOAD \
1229        COLD_BOOT_SINGLE_CPU \
1230        CTX_INCLUDE_AARCH32_REGS \
1231        CTX_INCLUDE_FPREGS \
1232        CTX_INCLUDE_PAUTH_REGS \
1233        EL3_EXCEPTION_HANDLING \
1234        CTX_INCLUDE_MTE_REGS \
1235        CTX_INCLUDE_EL2_REGS \
1236        CTX_INCLUDE_NEVE_REGS \
1237        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1238        DISABLE_MTPMU \
1239        ENABLE_FEAT_AMU \
1240        ENABLE_AMU_AUXILIARY_COUNTERS \
1241        ENABLE_AMU_FCONF \
1242        AMU_RESTRICT_COUNTERS \
1243        ENABLE_ASSERTIONS \
1244        ENABLE_BTI \
1245        ENABLE_MPAM_FOR_LOWER_ELS \
1246        ENABLE_PAUTH \
1247        ENABLE_PIE \
1248        ENABLE_PMF \
1249        ENABLE_PSCI_STAT \
1250        ENABLE_RME \
1251        ENABLE_RUNTIME_INSTRUMENTATION \
1252        ENABLE_SME_FOR_NS \
1253        ENABLE_SME_FOR_SWD \
1254        ENABLE_SPE_FOR_NS \
1255        ENABLE_SVE_FOR_NS \
1256        ENABLE_SVE_FOR_SWD \
1257        ENCRYPT_BL31 \
1258        ENCRYPT_BL32 \
1259        ERROR_DEPRECATED \
1260        FAULT_INJECTION_SUPPORT \
1261        GICV2_G0_FOR_EL3 \
1262        HANDLE_EA_EL3_FIRST_NS \
1263        HW_ASSISTED_COHERENCY \
1264        LOG_LEVEL \
1265        MEASURED_BOOT \
1266        DRTM_SUPPORT \
1267        NS_TIMER_SWITCH \
1268        PL011_GENERIC_UART \
1269        PLAT_${PLAT} \
1270        PLAT_RSS_NOT_SUPPORTED \
1271        PROGRAMMABLE_RESET_ADDRESS \
1272        PSCI_EXTENDED_STATE_ID \
1273        PSCI_OS_INIT_MODE \
1274        RAS_EXTENSION \
1275        RESET_TO_BL31 \
1276        SEPARATE_CODE_AND_RODATA \
1277        SEPARATE_BL2_NOLOAD_REGION \
1278        SEPARATE_NOBITS_REGION \
1279        RECLAIM_INIT_CODE \
1280        SPD_${SPD} \
1281        SPIN_ON_BL1_EXIT \
1282        SPM_MM \
1283        SPMC_AT_EL3 \
1284        SPMD_SPM_AT_SEL2 \
1285        TRUSTED_BOARD_BOOT \
1286        CRYPTO_SUPPORT \
1287        TRNG_SUPPORT \
1288        USE_COHERENT_MEM \
1289        USE_DEBUGFS \
1290        ARM_IO_IN_DTB \
1291        SDEI_IN_FCONF \
1292        SEC_INT_DESC_IN_FCONF \
1293        USE_ROMLIB \
1294        USE_TBBR_DEFS \
1295        WARMBOOT_ENABLE_DCACHE_EARLY \
1296        RESET_TO_BL2 \
1297        BL2_RUNS_AT_EL3	\
1298        BL2_IN_XIP_MEM \
1299        BL2_INV_DCACHE \
1300        USE_SPINLOCK_CAS \
1301        ERRATA_SPECULATIVE_AT \
1302        RAS_TRAP_NS_ERR_REC_ACCESS \
1303        COT_DESC_IN_DTB \
1304        USE_SP804_TIMER \
1305        ENABLE_FEAT_RNG \
1306        ENABLE_FEAT_RNG_TRAP \
1307        ENABLE_FEAT_SB \
1308        ENABLE_FEAT_DIT \
1309        NR_OF_FW_BANKS \
1310        NR_OF_IMAGES_IN_FW_BANK \
1311        PSA_FWU_SUPPORT \
1312        ENABLE_BRBE_FOR_NS \
1313        ENABLE_TRBE_FOR_NS \
1314        ENABLE_SYS_REG_TRACE_FOR_NS \
1315        ENABLE_TRF_FOR_NS \
1316        ENABLE_FEAT_HCX \
1317        ENABLE_MPMM \
1318        ENABLE_MPMM_FCONF \
1319        ENABLE_FEAT_FGT \
1320        ENABLE_FEAT_ECV \
1321        SIMICS_BUILD \
1322        ENABLE_FEAT_AMUv1p1 \
1323        ENABLE_FEAT_SEL2 \
1324        ENABLE_FEAT_VHE \
1325        ENABLE_FEAT_CSV2_2 \
1326        ENABLE_FEAT_PAN \
1327        ENABLE_FEAT_TCR2 \
1328        ENABLE_FEAT_S2PIE \
1329        ENABLE_FEAT_S1PIE \
1330        ENABLE_FEAT_S2POE \
1331        ENABLE_FEAT_S1POE \
1332        FEATURE_DETECTION \
1333        TWED_DELAY \
1334        ENABLE_FEAT_TWED \
1335	CONDITIONAL_CMO \
1336)))
1337
1338ifeq (${SANITIZE_UB},trap)
1339        $(eval $(call add_define,MONITOR_TRAPS))
1340endif
1341
1342# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1343ifdef EL3_PAYLOAD_BASE
1344        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1345else
1346        # Define the PRELOADED_BL33_BASE flag only if it is provided and
1347        # EL3_PAYLOAD_BASE is not defined, as it has priority.
1348        ifdef PRELOADED_BL33_BASE
1349                $(eval $(call add_define,PRELOADED_BL33_BASE))
1350        endif
1351endif
1352
1353# Define the DYN_DISABLE_AUTH flag only if set.
1354ifeq (${DYN_DISABLE_AUTH},1)
1355$(eval $(call add_define,DYN_DISABLE_AUTH))
1356endif
1357
1358ifneq ($(findstring armlink,$(notdir $(LD))),)
1359$(eval $(call add_define,USE_ARM_LINK))
1360endif
1361
1362# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1363ifeq (${SPD},spmd)
1364ifdef SP_LAYOUT_FILE
1365        -include $(BUILD_PLAT)/sp_gen.mk
1366        FIP_DEPS += sp
1367        CRT_DEPS += sp
1368        NEED_SP_PKG := yes
1369else
1370        ifeq (${SPMD_SPM_AT_SEL2},1)
1371            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1372        endif
1373endif
1374endif
1375
1376################################################################################
1377# Build targets
1378################################################################################
1379
1380.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
1381.SUFFIXES:
1382
1383all: msg_start
1384
1385msg_start:
1386	@echo "Building ${PLAT}"
1387
1388ifeq (${ERROR_DEPRECATED},0)
1389# Check if deprecated declarations and cpp warnings should be treated as error or not.
1390ifneq ($(findstring clang,$(notdir $(CC))),)
1391    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1392else
1393    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
1394endif
1395endif # !ERROR_DEPRECATED
1396
1397$(eval $(call MAKE_LIB_DIRS))
1398$(eval $(call MAKE_LIB,c))
1399
1400# Expand build macros for the different images
1401ifeq (${NEED_BL1},yes)
1402BL1_SOURCES := $(sort ${BL1_SOURCES})
1403
1404$(eval $(call MAKE_BL,bl1))
1405endif
1406
1407ifeq (${NEED_BL2},yes)
1408ifeq (${RESET_TO_BL2}, 0)
1409FIP_BL2_ARGS := tb-fw
1410endif
1411
1412BL2_SOURCES := $(sort ${BL2_SOURCES})
1413
1414$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1415	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1416endif
1417
1418ifeq (${NEED_SCP_BL2},yes)
1419$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1420endif
1421
1422ifeq (${NEED_BL31},yes)
1423BL31_SOURCES += ${SPD_SOURCES}
1424# Sort BL31 source files to remove duplicates
1425BL31_SOURCES := $(sort ${BL31_SOURCES})
1426ifneq (${DECRYPTION_SUPPORT},none)
1427$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1428	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1429else
1430$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1431	$(eval $(call MAKE_BL,bl31,soc-fw)))
1432endif
1433endif
1434
1435# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1436# build system will call TOOL_ADD_IMG to print a warning message and abort the
1437# process. Note that the dependency on BL32 applies to the FIP only.
1438ifeq (${NEED_BL32},yes)
1439# Sort BL32 source files to remove duplicates
1440BL32_SOURCES := $(sort ${BL32_SOURCES})
1441BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1442
1443ifneq (${DECRYPTION_SUPPORT},none)
1444$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1445	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1446else
1447$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
1448	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1449endif
1450endif
1451
1452# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1453# needs to be built from RMM_SOURCES.
1454ifeq (${NEED_RMM},yes)
1455# Sort RMM source files to remove duplicates
1456RMM_SOURCES := $(sort ${RMM_SOURCES})
1457BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1458
1459$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1460         $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1461endif
1462
1463# Add the BL33 image if required by the platform
1464ifeq (${NEED_BL33},yes)
1465$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1466endif
1467
1468ifeq (${NEED_BL2U},yes)
1469$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1470	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1471endif
1472
1473# Expand build macros for the different images
1474ifeq (${NEED_FDT},yes)
1475    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
1476endif
1477
1478# Add Secure Partition packages
1479ifeq (${NEED_SP_PKG},yes)
1480$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1481	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1482sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1483	@${ECHO_BLANK_LINE}
1484	@echo "Built SP Images successfully"
1485	@${ECHO_BLANK_LINE}
1486endif
1487
1488locate-checkpatch:
1489ifndef CHECKPATCH
1490	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1491else
1492ifeq (,$(wildcard ${CHECKPATCH}))
1493	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1494endif
1495endif
1496
1497clean:
1498	@echo "  CLEAN"
1499	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
1500ifdef UNIX_MK
1501	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1502else
1503# Clear the MAKEFLAGS as we do not want
1504# to pass the gnumake flags to nmake.
1505	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1506endif
1507	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1508	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1509	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1510
1511realclean distclean:
1512	@echo "  REALCLEAN"
1513	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1514	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
1515ifdef UNIX_MK
1516	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1517else
1518# Clear the MAKEFLAGS as we do not want
1519# to pass the gnumake flags to nmake.
1520	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1521endif
1522	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1523	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1524	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1525
1526checkcodebase:		locate-checkpatch
1527	@echo "  CHECKING STYLE"
1528	@if test -d .git ; then						\
1529		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
1530		while read GIT_FILE ;					\
1531		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
1532		done ;							\
1533	else								\
1534		 find . -type f -not -iwholename "*.git*"		\
1535		 -not -iwholename "*build*"				\
1536		 -not -iwholename "*libfdt*"				\
1537		 -not -iwholename "*libc*"				\
1538		 -not -iwholename "*docs*"				\
1539		 -not -iwholename "*.rst"				\
1540		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
1541	fi
1542
1543checkpatch:		locate-checkpatch
1544	@echo "  CHECKING STYLE"
1545	@if test -n "${CHECKPATCH_OPTS}"; then				\
1546		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
1547	fi
1548	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
1549	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
1550	do								\
1551		printf "\n[*] Checking style of '$$commit'\n\n";	\
1552		git log --format=email "$$commit~..$$commit"		\
1553			-- ${CHECK_PATHS} |				\
1554			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
1555		git diff --format=email "$$commit~..$$commit"		\
1556			-- ${CHECK_PATHS} |				\
1557			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
1558	done
1559
1560certtool: ${CRTTOOL}
1561
1562${CRTTOOL}: FORCE
1563	${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
1564	@${ECHO_BLANK_LINE}
1565	@echo "Built $@ successfully"
1566	@${ECHO_BLANK_LINE}
1567
1568ifneq (${GENERATE_COT},0)
1569certificates: ${CRT_DEPS} ${CRTTOOL}
1570	${Q}${CRTTOOL} ${CRT_ARGS}
1571	@${ECHO_BLANK_LINE}
1572	@echo "Built $@ successfully"
1573	@echo "Certificates can be found in ${BUILD_PLAT}"
1574	@${ECHO_BLANK_LINE}
1575endif
1576
1577${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
1578	$(eval ${CHECK_FIP_CMD})
1579	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1580	${Q}${FIPTOOL} info $@
1581	@${ECHO_BLANK_LINE}
1582	@echo "Built $@ successfully"
1583	@${ECHO_BLANK_LINE}
1584
1585ifneq (${GENERATE_COT},0)
1586fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1587	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1588	@${ECHO_BLANK_LINE}
1589	@echo "Built $@ successfully"
1590	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1591	@${ECHO_BLANK_LINE}
1592endif
1593
1594${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
1595	$(eval ${CHECK_FWU_FIP_CMD})
1596	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1597	${Q}${FIPTOOL} info $@
1598	@${ECHO_BLANK_LINE}
1599	@echo "Built $@ successfully"
1600	@${ECHO_BLANK_LINE}
1601
1602fiptool: ${FIPTOOL}
1603fip: ${BUILD_PLAT}/${FIP_NAME}
1604fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
1605
1606${FIPTOOL}: FORCE
1607ifdef UNIX_MK
1608	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
1609else
1610# Clear the MAKEFLAGS as we do not want
1611# to pass the gnumake flags to nmake.
1612	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1613endif
1614
1615romlib.bin: libraries FORCE
1616	${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
1617
1618# Call print_memory_map tool
1619memmap: all
1620	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1621
1622doc:
1623	@echo "  BUILD DOCUMENTATION"
1624	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1625
1626enctool: ${ENCTOOL}
1627
1628${ENCTOOL}: FORCE
1629	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
1630	@${ECHO_BLANK_LINE}
1631	@echo "Built $@ successfully"
1632	@${ECHO_BLANK_LINE}
1633
1634cscope:
1635	@echo "  CSCOPE"
1636	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1637	${Q}cscope -b -q -k
1638
1639help:
1640	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1641	@echo ""
1642	@echo "PLAT is used to specify which platform you wish to build."
1643	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1644	@echo ""
1645	@echo "platform = ${PLATFORM_LIST}"
1646	@echo ""
1647	@echo "Please refer to the User Guide for a list of all supported options."
1648	@echo "Note that the build system doesn't track dependencies for build "
1649	@echo "options. Therefore, if any of the build options are changed "
1650	@echo "from a previous build, a clean build must be performed."
1651	@echo ""
1652	@echo "Supported Targets:"
1653	@echo "  all            Build all individual bootloader binaries"
1654	@echo "  bl1            Build the BL1 binary"
1655	@echo "  bl2            Build the BL2 binary"
1656	@echo "  bl2u           Build the BL2U binary"
1657	@echo "  bl31           Build the BL31 binary"
1658	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
1659	@echo "                 this builds secure payload specified by AARCH32_SP"
1660	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
1661	@echo "  fip            Build the Firmware Image Package (FIP)"
1662	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
1663	@echo "  checkcodebase  Check the coding style of the entire source tree"
1664	@echo "  checkpatch     Check the coding style on changes in the current"
1665	@echo "                 branch against BASE_COMMIT (default origin/master)"
1666	@echo "  clean          Clean the build for the selected platform"
1667	@echo "  cscope         Generate cscope index"
1668	@echo "  distclean      Remove all build artifacts for all platforms"
1669	@echo "  certtool       Build the Certificate generation tool"
1670	@echo "  enctool        Build the Firmware encryption tool"
1671	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1672	@echo "  sp             Build the Secure Partition Packages"
1673	@echo "  sptool         Build the Secure Partition Package creation tool"
1674	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1675	@echo "  memmap         Print the memory map of the built binaries"
1676	@echo "  doc            Build html based documentation using Sphinx tool"
1677	@echo ""
1678	@echo "Note: most build targets require PLAT to be set to a specific platform."
1679	@echo ""
1680	@echo "example: build all targets for the FVP platform:"
1681	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1682
1683.PHONY: FORCE
1684FORCE:;
1685