xref: /rk3399_ARM-atf/Makefile (revision 4fba2e1ff7d8e9386a333fe3624286e1abab35a8)
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
645ifneq (${SPD}, none)
646ifneq (${SPD}, spmd)
647       $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
648endif
649endif
650include services/std_svc/rmmd/rmmd.mk
651$(warning "RME is an experimental feature")
652endif
653
654################################################################################
655# Include the platform specific Makefile after the SPD Makefile (the platform
656# makefile may use all previous definitions in this file)
657################################################################################
658
659include ${PLAT_MAKEFILE_FULL}
660
661# This internal flag is common option which is set to 1 for scenarios
662# when the BL2 is running in EL3 level. This occurs in two scenarios -
663# 4 world system running BL2 at EL3 and two world system without BL1 running
664# BL2 in EL3
665
666ifeq (${RESET_TO_BL2},1)
667	BL2_RUNS_AT_EL3	:=	1
668    ifeq (${ENABLE_RME},1)
669        $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not supported at the moment.)
670    endif
671else ifeq (${ENABLE_RME},1)
672	BL2_RUNS_AT_EL3	:=	1
673else
674	BL2_RUNS_AT_EL3	:=	0
675endif
676
677$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
678
679ifeq (${ARM_ARCH_MAJOR},7)
680include make_helpers/armv7-a-cpus.mk
681endif
682
683PIE_FOUND		:=	$(findstring --enable-default-pie,${GCC_V_OUTPUT})
684ifneq ($(PIE_FOUND),)
685	TF_CFLAGS	+=	-fno-PIE
686ifneq ($(findstring gcc,$(notdir $(LD))),)
687	TF_LDFLAGS	+=	-no-pie
688endif
689endif
690
691ifneq ($(findstring gcc,$(notdir $(LD))),)
692	PIE_LDFLAGS	+=	-Wl,-pie -Wl,--no-dynamic-linker
693else
694	PIE_LDFLAGS	+=	-pie --no-dynamic-linker
695endif
696
697ifeq ($(ENABLE_PIE),1)
698ifeq ($(RESET_TO_BL2),1)
699ifneq ($(BL2_IN_XIP_MEM),1)
700	BL2_CPPFLAGS	+=	-fpie
701	BL2_CFLAGS	+=	-fpie
702	BL2_LDFLAGS	+=	$(PIE_LDFLAGS)
703endif
704endif
705	BL31_CPPFLAGS	+=	-fpie
706	BL31_CFLAGS 	+=	-fpie
707	BL31_LDFLAGS	+=	$(PIE_LDFLAGS)
708
709	BL32_CPPFLAGS	+=	-fpie
710	BL32_CFLAGS	+=	-fpie
711	BL32_LDFLAGS	+=	$(PIE_LDFLAGS)
712endif
713
714ifeq (${ARCH},aarch64)
715BL1_CPPFLAGS += -DIMAGE_AT_EL3
716ifeq ($(RESET_TO_BL2),1)
717BL2_CPPFLAGS += -DIMAGE_AT_EL3
718else
719BL2_CPPFLAGS += -DIMAGE_AT_EL1
720endif
721BL2U_CPPFLAGS += -DIMAGE_AT_EL1
722BL31_CPPFLAGS += -DIMAGE_AT_EL3
723BL32_CPPFLAGS += -DIMAGE_AT_EL1
724endif
725
726# Include the CPU specific operations makefile, which provides default
727# values for all CPU errata workarounds and CPU specific optimisations.
728# This can be overridden by the platform.
729include lib/cpus/cpu-ops.mk
730
731ifeq (${ARCH},aarch32)
732NEED_BL32 := yes
733
734################################################################################
735# Build `AARCH32_SP` as BL32 image for AArch32
736################################################################################
737ifneq (${AARCH32_SP},none)
738# We expect to locate an sp.mk under the specified AARCH32_SP directory
739AARCH32_SP_MAKE	:=	$(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
740
741ifeq (${AARCH32_SP_MAKE},)
742  $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
743endif
744
745$(info Including ${AARCH32_SP_MAKE})
746include ${AARCH32_SP_MAKE}
747endif
748
749endif
750
751################################################################################
752# Include libc if not overridden
753################################################################################
754ifeq (${OVERRIDE_LIBC},0)
755include lib/libc/libc.mk
756endif
757
758################################################################################
759# Check incompatible options
760################################################################################
761
762ifdef EL3_PAYLOAD_BASE
763        ifdef PRELOADED_BL33_BASE
764                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
765                incompatible build options. EL3_PAYLOAD_BASE has priority.")
766        endif
767        ifneq (${GENERATE_COT},0)
768                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
769        endif
770        ifneq (${TRUSTED_BOARD_BOOT},0)
771                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
772        endif
773endif
774
775ifeq (${NEED_BL33},yes)
776        ifdef EL3_PAYLOAD_BASE
777                $(warning "BL33 image is not needed when option \
778                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
779        endif
780        ifdef PRELOADED_BL33_BASE
781                $(warning "BL33 image is not needed when option \
782                PRELOADED_BL33_BASE is used and won't be added to the FIP \
783                file.")
784        endif
785endif
786
787# When building for systems with hardware-assisted coherency, there's no need to
788# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
789ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
790$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
791endif
792
793#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
794ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
795$(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
796endif
797
798# For RAS_EXTENSION, require that EAs are handled in EL3 first
799ifeq ($(RAS_EXTENSION),1)
800    ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
801        $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1)
802    endif
803endif
804
805# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
806ifeq ($(FAULT_INJECTION_SUPPORT),1)
807    ifneq ($(RAS_EXTENSION),1)
808        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
809    endif
810endif
811
812# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
813ifeq ($(DYN_DISABLE_AUTH), 1)
814    ifeq (${TRUSTED_BOARD_BOOT}, 0)
815        $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
816    endif
817endif
818
819ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
820# Support authentication verification and hash calculation
821    CRYPTO_SUPPORT := 3
822else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
823# Support authentication verification and hash calculation
824    CRYPTO_SUPPORT := 3
825else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
826# Support hash calculation only
827    CRYPTO_SUPPORT := 2
828else ifeq (${TRUSTED_BOARD_BOOT},1)
829# Support authentication verification only
830    CRYPTO_SUPPORT := 1
831else
832    CRYPTO_SUPPORT := 0
833endif
834
835# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
836ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
837$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
838endif
839
840# If pointer authentication is used in the firmware, make sure that all the
841# registers associated to it are also saved and restored.
842# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
843ifeq ($(ENABLE_PAUTH),1)
844    ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
845        $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
846    endif
847endif
848
849ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
850    ifneq (${ARCH},aarch64)
851        $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
852    endif
853endif
854
855ifeq ($(CTX_INCLUDE_MTE_REGS),1)
856    ifneq (${ARCH},aarch64)
857        $(error CTX_INCLUDE_MTE_REGS requires AArch64)
858    endif
859endif
860
861ifeq ($(PSA_FWU_SUPPORT),1)
862    $(info PSA_FWU_SUPPORT is an experimental feature)
863endif
864
865ifeq ($(FEATURE_DETECTION),1)
866    $(info FEATURE_DETECTION is an experimental feature)
867endif
868
869ifneq ($(ENABLE_SME_FOR_NS), 0)
870    $(info ENABLE_SME_FOR_NS is an experimental feature)
871endif
872
873ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
874    ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
875        $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
876    endif
877endif
878
879ifneq (${DECRYPTION_SUPPORT},none)
880    ifeq (${TRUSTED_BOARD_BOOT}, 0)
881        $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
882    endif
883endif
884
885# Ensure that no Aarch64-only features are enabled in Aarch32 build
886ifeq (${ARCH},aarch32)
887
888    # SME/SVE only supported on AArch64
889    ifneq (${ENABLE_SME_FOR_NS},0)
890        $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
891    endif
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    ifeq (${ENABLE_SVE_FOR_NS},1)
934        # Warning instead of error due to CI dependency on this
935        $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
936        $(warning "Forced ENABLE_SVE_FOR_NS=0")
937        override ENABLE_SVE_FOR_NS	:= 0
938    endif
939endif
940
941ifeq ($(DRTM_SUPPORT),1)
942    $(info DRTM_SUPPORT is an experimental feature)
943endif
944
945ifeq (${ENABLE_RME},1)
946    ifneq (${SEPARATE_CODE_AND_RODATA},1)
947        $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
948    endif
949endif
950
951################################################################################
952# Process platform overrideable behaviour
953################################################################################
954
955ifdef BL1_SOURCES
956NEED_BL1 := yes
957endif
958
959ifdef BL2_SOURCES
960	NEED_BL2 := yes
961
962	# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
963	# Certificate generation tools. This flag can be overridden by the platform.
964	ifdef EL3_PAYLOAD_BASE
965                # If booting an EL3 payload there is no need for a BL33 image
966                # in the FIP file.
967                NEED_BL33		:=	no
968        else
969                ifdef PRELOADED_BL33_BASE
970                        # If booting a BL33 preloaded image there is no need of
971                        # another one in the FIP file.
972                        NEED_BL33		:=	no
973                else
974                        NEED_BL33		?=	yes
975                endif
976        endif
977endif
978
979ifdef BL2U_SOURCES
980NEED_BL2U := yes
981endif
982
983# If SCP_BL2 is given, we always want FIP to include it.
984ifdef SCP_BL2
985        NEED_SCP_BL2		:=	yes
986endif
987
988# For AArch32, BL31 is not currently supported.
989ifneq (${ARCH},aarch32)
990    ifdef BL31_SOURCES
991        # When booting an EL3 payload, there is no need to compile the BL31 image nor
992        # put it in the FIP.
993        ifndef EL3_PAYLOAD_BASE
994            NEED_BL31 := yes
995        endif
996    endif
997endif
998
999# Process TBB related flags
1000ifneq (${GENERATE_COT},0)
1001        # Common cert_create options
1002        ifneq (${CREATE_KEYS},0)
1003                $(eval CRT_ARGS += -n)
1004                $(eval FWU_CRT_ARGS += -n)
1005                ifneq (${SAVE_KEYS},0)
1006                        $(eval CRT_ARGS += -k)
1007                        $(eval FWU_CRT_ARGS += -k)
1008                endif
1009        endif
1010        # Include TBBR makefile (unless the platform indicates otherwise)
1011        ifeq (${INCLUDE_TBBR_MK},1)
1012                include make_helpers/tbbr/tbbr_tools.mk
1013        endif
1014endif
1015
1016ifneq (${FIP_ALIGN},0)
1017FIP_ARGS += --align ${FIP_ALIGN}
1018endif
1019
1020ifdef FDT_SOURCES
1021NEED_FDT := yes
1022endif
1023
1024################################################################################
1025# Include libraries' Makefile that are used in all BL
1026################################################################################
1027
1028include lib/stack_protector/stack_protector.mk
1029
1030################################################################################
1031# Auxiliary tools (fiptool, cert_create, etc)
1032################################################################################
1033
1034# Variables for use with Certificate Generation Tool
1035CRTTOOLPATH		?=	tools/cert_create
1036CRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
1037
1038# Variables for use with Firmware Encryption Tool
1039ENCTOOLPATH		?=	tools/encrypt_fw
1040ENCTOOL			?=	${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
1041
1042# Variables for use with Firmware Image Package
1043FIPTOOLPATH		?=	tools/fiptool
1044FIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
1045
1046# Variables for use with sptool
1047SPTOOLPATH		?=	tools/sptool
1048SPTOOL			?=	${SPTOOLPATH}/sptool.py
1049SP_MK_GEN		?=	${SPTOOLPATH}/sp_mk_generator.py
1050
1051# Variables for use with ROMLIB
1052ROMLIBPATH		?=	lib/romlib
1053
1054# Variable for use with Python
1055PYTHON			?=	python3
1056
1057# Variables for use with PRINT_MEMORY_MAP
1058PRINT_MEMORY_MAP_PATH		?=	tools/memory
1059PRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
1060
1061# Variables for use with documentation build using Sphinx tool
1062DOCS_PATH		?=	docs
1063
1064# Defination of SIMICS flag
1065SIMICS_BUILD	?=	0
1066
1067################################################################################
1068# Include BL specific makefiles
1069################################################################################
1070
1071ifeq (${NEED_BL1},yes)
1072include bl1/bl1.mk
1073endif
1074
1075ifeq (${NEED_BL2},yes)
1076include bl2/bl2.mk
1077endif
1078
1079ifeq (${NEED_BL2U},yes)
1080include bl2u/bl2u.mk
1081endif
1082
1083ifeq (${NEED_BL31},yes)
1084include bl31/bl31.mk
1085endif
1086
1087################################################################################
1088# Build options checks
1089################################################################################
1090
1091$(eval $(call assert_booleans,\
1092    $(sort \
1093        ALLOW_RO_XLAT_TABLES \
1094        BL2_ENABLE_SP_LOAD \
1095        COLD_BOOT_SINGLE_CPU \
1096        CREATE_KEYS \
1097        CTX_INCLUDE_AARCH32_REGS \
1098        CTX_INCLUDE_FPREGS \
1099        CTX_INCLUDE_EL2_REGS \
1100        DEBUG \
1101        DISABLE_MTPMU \
1102        DYN_DISABLE_AUTH \
1103        EL3_EXCEPTION_HANDLING \
1104        ENABLE_AMU_AUXILIARY_COUNTERS \
1105        ENABLE_AMU_FCONF \
1106        AMU_RESTRICT_COUNTERS \
1107        ENABLE_ASSERTIONS \
1108        ENABLE_FEAT_SB \
1109        ENABLE_PIE \
1110        ENABLE_PMF \
1111        ENABLE_PSCI_STAT \
1112        ENABLE_RUNTIME_INSTRUMENTATION \
1113        ENABLE_SME_FOR_SWD \
1114        ENABLE_SVE_FOR_SWD \
1115        ERROR_DEPRECATED \
1116        FAULT_INJECTION_SUPPORT \
1117        GENERATE_COT \
1118        GICV2_G0_FOR_EL3 \
1119        HANDLE_EA_EL3_FIRST_NS \
1120        HW_ASSISTED_COHERENCY \
1121        INVERTED_MEMMAP \
1122        MEASURED_BOOT \
1123        DRTM_SUPPORT \
1124        NS_TIMER_SWITCH \
1125        OVERRIDE_LIBC \
1126        PL011_GENERIC_UART \
1127        PLAT_RSS_NOT_SUPPORTED \
1128        PROGRAMMABLE_RESET_ADDRESS \
1129        PSCI_EXTENDED_STATE_ID \
1130        PSCI_OS_INIT_MODE \
1131        RESET_TO_BL31 \
1132        SAVE_KEYS \
1133        SEPARATE_CODE_AND_RODATA \
1134        SEPARATE_BL2_NOLOAD_REGION \
1135        SEPARATE_NOBITS_REGION \
1136        SPIN_ON_BL1_EXIT \
1137        SPM_MM \
1138        SPMC_AT_EL3 \
1139        SPMD_SPM_AT_SEL2 \
1140        TRUSTED_BOARD_BOOT \
1141        USE_COHERENT_MEM \
1142        USE_DEBUGFS \
1143        ARM_IO_IN_DTB \
1144        SDEI_IN_FCONF \
1145        SEC_INT_DESC_IN_FCONF \
1146        USE_ROMLIB \
1147        USE_TBBR_DEFS \
1148        WARMBOOT_ENABLE_DCACHE_EARLY \
1149        RESET_TO_BL2 \
1150        BL2_IN_XIP_MEM \
1151        BL2_INV_DCACHE \
1152        USE_SPINLOCK_CAS \
1153        ENCRYPT_BL31 \
1154        ENCRYPT_BL32 \
1155        ERRATA_SPECULATIVE_AT \
1156        RAS_TRAP_NS_ERR_REC_ACCESS \
1157        COT_DESC_IN_DTB \
1158        USE_SP804_TIMER \
1159        PSA_FWU_SUPPORT \
1160        ENABLE_MPMM \
1161        ENABLE_MPMM_FCONF \
1162        SIMICS_BUILD \
1163        FEATURE_DETECTION \
1164	TRNG_SUPPORT \
1165	CONDITIONAL_CMO \
1166)))
1167
1168$(eval $(call assert_numerics,\
1169    $(sort \
1170        ARM_ARCH_MAJOR \
1171        ARM_ARCH_MINOR \
1172        BRANCH_PROTECTION \
1173        CTX_INCLUDE_PAUTH_REGS \
1174        CTX_INCLUDE_MTE_REGS \
1175        CTX_INCLUDE_NEVE_REGS \
1176        CRYPTO_SUPPORT \
1177        ENABLE_BRBE_FOR_NS \
1178        ENABLE_TRBE_FOR_NS \
1179        ENABLE_BTI \
1180        ENABLE_PAUTH \
1181        ENABLE_FEAT_AMU \
1182        ENABLE_FEAT_AMUv1p1 \
1183        ENABLE_FEAT_CSV2_2 \
1184        ENABLE_FEAT_DIT \
1185        ENABLE_FEAT_ECV \
1186        ENABLE_FEAT_FGT \
1187        ENABLE_FEAT_HCX \
1188        ENABLE_FEAT_PAN \
1189        ENABLE_FEAT_RNG \
1190        ENABLE_FEAT_RNG_TRAP \
1191        ENABLE_FEAT_SEL2 \
1192        ENABLE_FEAT_TCR2 \
1193        ENABLE_FEAT_S2PIE \
1194        ENABLE_FEAT_S1PIE \
1195        ENABLE_FEAT_S2POE \
1196        ENABLE_FEAT_S1POE \
1197        ENABLE_FEAT_GCS \
1198        ENABLE_FEAT_VHE \
1199        ENABLE_MPAM_FOR_LOWER_ELS \
1200        ENABLE_RME \
1201        ENABLE_SPE_FOR_NS \
1202        ENABLE_SYS_REG_TRACE_FOR_NS \
1203        ENABLE_SME_FOR_NS \
1204        ENABLE_SVE_FOR_NS \
1205        ENABLE_TRF_FOR_NS \
1206        FW_ENC_STATUS \
1207        NR_OF_FW_BANKS \
1208        NR_OF_IMAGES_IN_FW_BANK \
1209        RAS_EXTENSION \
1210        TWED_DELAY \
1211        ENABLE_FEAT_TWED \
1212        SVE_VECTOR_LEN \
1213)))
1214
1215ifdef KEY_SIZE
1216        $(eval $(call assert_numeric,KEY_SIZE))
1217endif
1218
1219ifeq ($(filter $(SANITIZE_UB), on off trap),)
1220        $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1221endif
1222
1223################################################################################
1224# Add definitions to the cpp preprocessor based on the current build options.
1225# This is done after including the platform specific makefile to allow the
1226# platform to overwrite the default options
1227################################################################################
1228
1229$(eval $(call add_defines,\
1230    $(sort \
1231        ALLOW_RO_XLAT_TABLES \
1232        ARM_ARCH_MAJOR \
1233        ARM_ARCH_MINOR \
1234        BL2_ENABLE_SP_LOAD \
1235        COLD_BOOT_SINGLE_CPU \
1236        CTX_INCLUDE_AARCH32_REGS \
1237        CTX_INCLUDE_FPREGS \
1238        CTX_INCLUDE_PAUTH_REGS \
1239        EL3_EXCEPTION_HANDLING \
1240        CTX_INCLUDE_MTE_REGS \
1241        CTX_INCLUDE_EL2_REGS \
1242        CTX_INCLUDE_NEVE_REGS \
1243        DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1244        DISABLE_MTPMU \
1245        ENABLE_FEAT_AMU \
1246        ENABLE_AMU_AUXILIARY_COUNTERS \
1247        ENABLE_AMU_FCONF \
1248        AMU_RESTRICT_COUNTERS \
1249        ENABLE_ASSERTIONS \
1250        ENABLE_BTI \
1251        ENABLE_MPAM_FOR_LOWER_ELS \
1252        ENABLE_PAUTH \
1253        ENABLE_PIE \
1254        ENABLE_PMF \
1255        ENABLE_PSCI_STAT \
1256        ENABLE_RME \
1257        ENABLE_RUNTIME_INSTRUMENTATION \
1258        ENABLE_SME_FOR_NS \
1259        ENABLE_SME_FOR_SWD \
1260        ENABLE_SPE_FOR_NS \
1261        ENABLE_SVE_FOR_NS \
1262        ENABLE_SVE_FOR_SWD \
1263        ENCRYPT_BL31 \
1264        ENCRYPT_BL32 \
1265        ERROR_DEPRECATED \
1266        FAULT_INJECTION_SUPPORT \
1267        GICV2_G0_FOR_EL3 \
1268        HANDLE_EA_EL3_FIRST_NS \
1269        HW_ASSISTED_COHERENCY \
1270        LOG_LEVEL \
1271        MEASURED_BOOT \
1272        DRTM_SUPPORT \
1273        NS_TIMER_SWITCH \
1274        PL011_GENERIC_UART \
1275        PLAT_${PLAT} \
1276        PLAT_RSS_NOT_SUPPORTED \
1277        PROGRAMMABLE_RESET_ADDRESS \
1278        PSCI_EXTENDED_STATE_ID \
1279        PSCI_OS_INIT_MODE \
1280        RAS_EXTENSION \
1281        RESET_TO_BL31 \
1282        SEPARATE_CODE_AND_RODATA \
1283        SEPARATE_BL2_NOLOAD_REGION \
1284        SEPARATE_NOBITS_REGION \
1285        RECLAIM_INIT_CODE \
1286        SPD_${SPD} \
1287        SPIN_ON_BL1_EXIT \
1288        SPM_MM \
1289        SPMC_AT_EL3 \
1290        SPMD_SPM_AT_SEL2 \
1291        TRUSTED_BOARD_BOOT \
1292        CRYPTO_SUPPORT \
1293        TRNG_SUPPORT \
1294        USE_COHERENT_MEM \
1295        USE_DEBUGFS \
1296        ARM_IO_IN_DTB \
1297        SDEI_IN_FCONF \
1298        SEC_INT_DESC_IN_FCONF \
1299        USE_ROMLIB \
1300        USE_TBBR_DEFS \
1301        WARMBOOT_ENABLE_DCACHE_EARLY \
1302        RESET_TO_BL2 \
1303        BL2_RUNS_AT_EL3	\
1304        BL2_IN_XIP_MEM \
1305        BL2_INV_DCACHE \
1306        USE_SPINLOCK_CAS \
1307        ERRATA_SPECULATIVE_AT \
1308        RAS_TRAP_NS_ERR_REC_ACCESS \
1309        COT_DESC_IN_DTB \
1310        USE_SP804_TIMER \
1311        ENABLE_FEAT_RNG \
1312        ENABLE_FEAT_RNG_TRAP \
1313        ENABLE_FEAT_SB \
1314        ENABLE_FEAT_DIT \
1315        NR_OF_FW_BANKS \
1316        NR_OF_IMAGES_IN_FW_BANK \
1317        PSA_FWU_SUPPORT \
1318        ENABLE_BRBE_FOR_NS \
1319        ENABLE_TRBE_FOR_NS \
1320        ENABLE_SYS_REG_TRACE_FOR_NS \
1321        ENABLE_TRF_FOR_NS \
1322        ENABLE_FEAT_HCX \
1323        ENABLE_MPMM \
1324        ENABLE_MPMM_FCONF \
1325        ENABLE_FEAT_FGT \
1326        ENABLE_FEAT_ECV \
1327        SIMICS_BUILD \
1328        ENABLE_FEAT_AMUv1p1 \
1329        ENABLE_FEAT_SEL2 \
1330        ENABLE_FEAT_VHE \
1331        ENABLE_FEAT_CSV2_2 \
1332        ENABLE_FEAT_PAN \
1333        ENABLE_FEAT_TCR2 \
1334        ENABLE_FEAT_S2PIE \
1335        ENABLE_FEAT_S1PIE \
1336        ENABLE_FEAT_S2POE \
1337        ENABLE_FEAT_S1POE \
1338        ENABLE_FEAT_GCS \
1339        FEATURE_DETECTION \
1340        TWED_DELAY \
1341        ENABLE_FEAT_TWED \
1342	CONDITIONAL_CMO \
1343)))
1344
1345ifeq (${SANITIZE_UB},trap)
1346        $(eval $(call add_define,MONITOR_TRAPS))
1347endif
1348
1349# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1350ifdef EL3_PAYLOAD_BASE
1351        $(eval $(call add_define,EL3_PAYLOAD_BASE))
1352else
1353        # Define the PRELOADED_BL33_BASE flag only if it is provided and
1354        # EL3_PAYLOAD_BASE is not defined, as it has priority.
1355        ifdef PRELOADED_BL33_BASE
1356                $(eval $(call add_define,PRELOADED_BL33_BASE))
1357        endif
1358endif
1359
1360# Define the DYN_DISABLE_AUTH flag only if set.
1361ifeq (${DYN_DISABLE_AUTH},1)
1362$(eval $(call add_define,DYN_DISABLE_AUTH))
1363endif
1364
1365ifneq ($(findstring armlink,$(notdir $(LD))),)
1366$(eval $(call add_define,USE_ARM_LINK))
1367endif
1368
1369# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
1370ifeq (${SPD},spmd)
1371ifdef SP_LAYOUT_FILE
1372        -include $(BUILD_PLAT)/sp_gen.mk
1373        FIP_DEPS += sp
1374        CRT_DEPS += sp
1375        NEED_SP_PKG := yes
1376else
1377        ifeq (${SPMD_SPM_AT_SEL2},1)
1378            $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1379        endif
1380endif
1381endif
1382
1383################################################################################
1384# Build targets
1385################################################################################
1386
1387.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
1388.SUFFIXES:
1389
1390all: msg_start
1391
1392msg_start:
1393	@echo "Building ${PLAT}"
1394
1395ifeq (${ERROR_DEPRECATED},0)
1396# Check if deprecated declarations and cpp warnings should be treated as error or not.
1397ifneq ($(findstring clang,$(notdir $(CC))),)
1398    CPPFLAGS		+= 	-Wno-error=deprecated-declarations
1399else
1400    CPPFLAGS		+= 	-Wno-error=deprecated-declarations -Wno-error=cpp
1401endif
1402endif # !ERROR_DEPRECATED
1403
1404$(eval $(call MAKE_LIB_DIRS))
1405$(eval $(call MAKE_LIB,c))
1406
1407# Expand build macros for the different images
1408ifeq (${NEED_BL1},yes)
1409BL1_SOURCES := $(sort ${BL1_SOURCES})
1410
1411$(eval $(call MAKE_BL,bl1))
1412endif
1413
1414ifeq (${NEED_BL2},yes)
1415ifeq (${RESET_TO_BL2}, 0)
1416FIP_BL2_ARGS := tb-fw
1417endif
1418
1419BL2_SOURCES := $(sort ${BL2_SOURCES})
1420
1421$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
1422	$(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
1423endif
1424
1425ifeq (${NEED_SCP_BL2},yes)
1426$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
1427endif
1428
1429ifeq (${NEED_BL31},yes)
1430BL31_SOURCES += ${SPD_SOURCES}
1431# Sort BL31 source files to remove duplicates
1432BL31_SOURCES := $(sort ${BL31_SOURCES})
1433ifneq (${DECRYPTION_SUPPORT},none)
1434$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
1435	$(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
1436else
1437$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
1438	$(eval $(call MAKE_BL,bl31,soc-fw)))
1439endif
1440endif
1441
1442# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
1443# build system will call TOOL_ADD_IMG to print a warning message and abort the
1444# process. Note that the dependency on BL32 applies to the FIP only.
1445ifeq (${NEED_BL32},yes)
1446# Sort BL32 source files to remove duplicates
1447BL32_SOURCES := $(sort ${BL32_SOURCES})
1448BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1449
1450ifneq (${DECRYPTION_SUPPORT},none)
1451$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
1452	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1453else
1454$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
1455	$(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
1456endif
1457endif
1458
1459# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1460# needs to be built from RMM_SOURCES.
1461ifeq (${NEED_RMM},yes)
1462# Sort RMM source files to remove duplicates
1463RMM_SOURCES := $(sort ${RMM_SOURCES})
1464BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1465
1466$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1467         $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1468endif
1469
1470# Add the BL33 image if required by the platform
1471ifeq (${NEED_BL33},yes)
1472$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
1473endif
1474
1475ifeq (${NEED_BL2U},yes)
1476$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
1477	$(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
1478endif
1479
1480# Expand build macros for the different images
1481ifeq (${NEED_FDT},yes)
1482    $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
1483endif
1484
1485# Add Secure Partition packages
1486ifeq (${NEED_SP_PKG},yes)
1487$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1488	${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
1489sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
1490	@${ECHO_BLANK_LINE}
1491	@echo "Built SP Images successfully"
1492	@${ECHO_BLANK_LINE}
1493endif
1494
1495locate-checkpatch:
1496ifndef CHECKPATCH
1497	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1498else
1499ifeq (,$(wildcard ${CHECKPATCH}))
1500	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
1501endif
1502endif
1503
1504clean:
1505	@echo "  CLEAN"
1506	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
1507ifdef UNIX_MK
1508	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1509else
1510# Clear the MAKEFLAGS as we do not want
1511# to pass the gnumake flags to nmake.
1512	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1513endif
1514	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1515	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1516	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1517
1518realclean distclean:
1519	@echo "  REALCLEAN"
1520	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
1521	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
1522ifdef UNIX_MK
1523	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
1524else
1525# Clear the MAKEFLAGS as we do not want
1526# to pass the gnumake flags to nmake.
1527	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1528endif
1529	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1530	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1531	${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
1532
1533checkcodebase:		locate-checkpatch
1534	@echo "  CHECKING STYLE"
1535	@if test -d .git ; then						\
1536		git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' |	\
1537		while read GIT_FILE ;					\
1538		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
1539		done ;							\
1540	else								\
1541		 find . -type f -not -iwholename "*.git*"		\
1542		 -not -iwholename "*build*"				\
1543		 -not -iwholename "*libfdt*"				\
1544		 -not -iwholename "*libc*"				\
1545		 -not -iwholename "*docs*"				\
1546		 -not -iwholename "*.rst"				\
1547		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
1548	fi
1549
1550checkpatch:		locate-checkpatch
1551	@echo "  CHECKING STYLE"
1552	@if test -n "${CHECKPATCH_OPTS}"; then				\
1553		echo "    with ${CHECKPATCH_OPTS} option(s)";		\
1554	fi
1555	${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT});	\
1556	for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`;	\
1557	do								\
1558		printf "\n[*] Checking style of '$$commit'\n\n";	\
1559		git log --format=email "$$commit~..$$commit"		\
1560			-- ${CHECK_PATHS} |				\
1561			${CHECKPATCH} ${CHECKPATCH_OPTS} - || true;	\
1562		git diff --format=email "$$commit~..$$commit"		\
1563			-- ${CHECK_PATHS} |				\
1564			${CHECKPATCH}  ${CHECKPATCH_OPTS} - || true;	\
1565	done
1566
1567certtool: ${CRTTOOL}
1568
1569${CRTTOOL}: FORCE
1570	${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
1571	@${ECHO_BLANK_LINE}
1572	@echo "Built $@ successfully"
1573	@${ECHO_BLANK_LINE}
1574
1575ifneq (${GENERATE_COT},0)
1576certificates: ${CRT_DEPS} ${CRTTOOL}
1577	${Q}${CRTTOOL} ${CRT_ARGS}
1578	@${ECHO_BLANK_LINE}
1579	@echo "Built $@ successfully"
1580	@echo "Certificates can be found in ${BUILD_PLAT}"
1581	@${ECHO_BLANK_LINE}
1582endif
1583
1584${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
1585	$(eval ${CHECK_FIP_CMD})
1586	${Q}${FIPTOOL} create ${FIP_ARGS} $@
1587	${Q}${FIPTOOL} info $@
1588	@${ECHO_BLANK_LINE}
1589	@echo "Built $@ successfully"
1590	@${ECHO_BLANK_LINE}
1591
1592ifneq (${GENERATE_COT},0)
1593fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1594	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
1595	@${ECHO_BLANK_LINE}
1596	@echo "Built $@ successfully"
1597	@echo "FWU certificates can be found in ${BUILD_PLAT}"
1598	@${ECHO_BLANK_LINE}
1599endif
1600
1601${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
1602	$(eval ${CHECK_FWU_FIP_CMD})
1603	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1604	${Q}${FIPTOOL} info $@
1605	@${ECHO_BLANK_LINE}
1606	@echo "Built $@ successfully"
1607	@${ECHO_BLANK_LINE}
1608
1609fiptool: ${FIPTOOL}
1610fip: ${BUILD_PLAT}/${FIP_NAME}
1611fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
1612
1613${FIPTOOL}: FORCE
1614ifdef UNIX_MK
1615	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
1616else
1617# Clear the MAKEFLAGS as we do not want
1618# to pass the gnumake flags to nmake.
1619	${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1620endif
1621
1622romlib.bin: libraries FORCE
1623	${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
1624
1625# Call print_memory_map tool
1626memmap: all
1627	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
1628
1629doc:
1630	@echo "  BUILD DOCUMENTATION"
1631	${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1632
1633enctool: ${ENCTOOL}
1634
1635${ENCTOOL}: FORCE
1636	${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
1637	@${ECHO_BLANK_LINE}
1638	@echo "Built $@ successfully"
1639	@${ECHO_BLANK_LINE}
1640
1641cscope:
1642	@echo "  CSCOPE"
1643	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1644	${Q}cscope -b -q -k
1645
1646help:
1647	@echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1648	@echo ""
1649	@echo "PLAT is used to specify which platform you wish to build."
1650	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1651	@echo ""
1652	@echo "platform = ${PLATFORM_LIST}"
1653	@echo ""
1654	@echo "Please refer to the User Guide for a list of all supported options."
1655	@echo "Note that the build system doesn't track dependencies for build "
1656	@echo "options. Therefore, if any of the build options are changed "
1657	@echo "from a previous build, a clean build must be performed."
1658	@echo ""
1659	@echo "Supported Targets:"
1660	@echo "  all            Build all individual bootloader binaries"
1661	@echo "  bl1            Build the BL1 binary"
1662	@echo "  bl2            Build the BL2 binary"
1663	@echo "  bl2u           Build the BL2U binary"
1664	@echo "  bl31           Build the BL31 binary"
1665	@echo "  bl32           Build the BL32 binary. If ARCH=aarch32, then "
1666	@echo "                 this builds secure payload specified by AARCH32_SP"
1667	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
1668	@echo "  fip            Build the Firmware Image Package (FIP)"
1669	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
1670	@echo "  checkcodebase  Check the coding style of the entire source tree"
1671	@echo "  checkpatch     Check the coding style on changes in the current"
1672	@echo "                 branch against BASE_COMMIT (default origin/master)"
1673	@echo "  clean          Clean the build for the selected platform"
1674	@echo "  cscope         Generate cscope index"
1675	@echo "  distclean      Remove all build artifacts for all platforms"
1676	@echo "  certtool       Build the Certificate generation tool"
1677	@echo "  enctool        Build the Firmware encryption tool"
1678	@echo "  fiptool        Build the Firmware Image Package (FIP) creation tool"
1679	@echo "  sp             Build the Secure Partition Packages"
1680	@echo "  sptool         Build the Secure Partition Package creation tool"
1681	@echo "  dtbs           Build the Device Tree Blobs (if required for the platform)"
1682	@echo "  memmap         Print the memory map of the built binaries"
1683	@echo "  doc            Build html based documentation using Sphinx tool"
1684	@echo ""
1685	@echo "Note: most build targets require PLAT to be set to a specific platform."
1686	@echo ""
1687	@echo "example: build all targets for the FVP platform:"
1688	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
1689
1690.PHONY: FORCE
1691FORCE:;
1692