blob: 43ff4672fb58df6fbe4233b2ba84588f1d111c6e [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Varun Wadekarc7e8bda2023-02-10 21:23:51 +00002# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-arm82cb2c12017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharane35c4042014-05-15 14:40:58 +01007#
Juan Castilloaaa3e722014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathew1a0f1122018-10-01 16:16:34 +010010VERSION_MAJOR := 2
laurenw-arm0fa7fe52022-11-15 10:15:34 -060011VERSION_MINOR := 8
Varun Wadekarea81ab52023-04-20 11:45:02 +010012VERSION_PATCH := 6
Varun Wadekarc7e8bda2023-02-10 21:23:51 +000013VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castilloaaa3e722014-06-30 11:41:46 +010014
Juan Castillo88154672015-10-22 11:34:44 +010015# Default goal is build all images
16.DEFAULT_GOAL := all
17
Douglas Raillard72fc70e2016-12-28 14:47:50 +000018# Avoid any implicit propagation of command line variable definitions to
19# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
20# usage. Other command line options like "-s" are still propagated as usual.
21MAKEOVERRIDES =
22
Evan Lloyd231c1472015-12-02 18:17:37 +000023MAKE_HELPERS_DIRECTORY := make_helpers/
24include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000025include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Juan Castillo73c99d42015-08-18 14:23:04 +010026
27################################################################################
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010028# Default values for build configurations, and their dependencies
Juan Castillo73c99d42015-08-18 14:23:04 +010029################################################################################
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010030
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010031include ${MAKE_HELPERS_DIRECTORY}defaults.mk
dp-arm872be882016-09-19 11:18:44 +010032
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010033# Assertions enabled for DEBUG builds by default
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010034ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010035ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
36PLAT := ${DEFAULT_PLAT}
Juan Castillo73c99d42015-08-18 14:23:04 +010037
38################################################################################
39# Checkpatch script options
40################################################################################
41
Sandrine Bailleuxf6077392016-06-02 11:19:59 +010042CHECKCODE_ARGS := --no-patch
Dan Handleyf0b489c2016-06-02 17:15:13 +010043# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030044INC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \
45 include/drivers/arm/cryptocell, \
46 $(wildcard include/drivers/arm/*)))
47INC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h
48INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
49 include/drivers/arm, \
50 $(wildcard include/drivers/*)))
Dan Handleyf0b489c2016-06-02 17:15:13 +010051INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley1a41e8c2016-06-02 18:21:02 +010052 include/lib/libfdt \
Roberto Vargas61f72a32018-05-08 10:27:10 +010053 include/lib/libc, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010054 $(wildcard include/lib/*)))
55INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030056 include/lib \
57 include/drivers, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010058 $(wildcard include/*)))
59LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-armd801fbb2017-05-04 12:15:35 +010060 lib/compiler-rt \
Antonio Nino Diaz55cdcf72017-01-16 17:20:45 +000061 lib/libfdt% \
Roberto Vargas61f72a32018-05-08 10:27:10 +010062 lib/libc, \
Daniel Boulbya1942552022-10-05 11:05:22 +010063 lib/zlib \
Dan Handleyf0b489c2016-06-02 17:15:13 +010064 $(wildcard lib/*)))
65ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
66 lib \
67 include \
68 docs \
Paul Beesley1ef35512019-03-07 16:42:31 +000069 %.rst, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010070 $(wildcard *)))
71CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
72 ${INC_DIRS_TO_CHECK} \
73 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030074 ${LIB_DIRS_TO_CHECK} \
75 ${INC_DRV_DIRS_TO_CHECK} \
76 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000077
Juan Castillo73c99d42015-08-18 14:23:04 +010078
79################################################################################
80# Process build options
81################################################################################
82
83# Verbose flag
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010084ifeq (${V},0)
Evan Lloydb169f6a2015-12-03 09:47:51 +000085 Q:=@
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010086 ECHO:=@echo
Juan Castillo73c99d42015-08-18 14:23:04 +010087 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010088else
Evan Lloydb169f6a2015-12-03 09:47:51 +000089 Q:=
Antonio Nino Diazb5a0f4b2018-10-19 15:44:30 +010090 ECHO:=$(ECHO_QUIET)
Achin Gupta4f6ad662013-10-25 09:08:21 +010091endif
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010092
93ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
94 Q:=@
Antonio Nino Diazb5a0f4b2018-10-19 15:44:30 +010095 ECHO:=$(ECHO_QUIET)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010096endif
97
98export Q ECHO
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000099
Juan Castillo73c99d42015-08-18 14:23:04 +0100100# The cert_create tool cannot generate certificates individually, so we use the
101# target 'certificates' to create them all
102ifneq (${GENERATE_COT},0)
103 FIP_DEPS += certificates
Yatharth Kochar01912622015-10-12 12:33:47 +0100104 FWU_FIP_DEPS += fwu_certificates
Juan Castillo73c99d42015-08-18 14:23:04 +0100105endif
106
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100107# Process BRANCH_PROTECTION value and set
108# Pointer Authentication and Branch Target Identification flags
109ifeq (${BRANCH_PROTECTION},0)
110 # Default value turns off all types of branch protection
111 BP_OPTION := none
112else ifneq (${ARCH},aarch64)
113 $(error BRANCH_PROTECTION requires AArch64)
114else ifeq (${BRANCH_PROTECTION},1)
115 # Enables all types of branch protection features
116 BP_OPTION := standard
117 ENABLE_BTI := 1
118 ENABLE_PAUTH := 1
119else ifeq (${BRANCH_PROTECTION},2)
120 # Return address signing to its standard level
121 BP_OPTION := pac-ret
122 ENABLE_PAUTH := 1
123else ifeq (${BRANCH_PROTECTION},3)
124 # Extend the signing to include leaf functions
125 BP_OPTION := pac-ret+leaf
126 ENABLE_PAUTH := 1
Alexei Fedorov3768fec2020-06-19 14:33:49 +0100127else ifeq (${BRANCH_PROTECTION},4)
128 # Turn on branch target identification mechanism
129 BP_OPTION := bti
130 ENABLE_BTI := 1
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100131else
132 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
133endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100134
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500135# FEAT_RME
136ifeq (${ENABLE_RME},1)
137# RME doesn't support PIE
138ifneq (${ENABLE_PIE},0)
139 $(error ENABLE_RME does not support PIE)
140endif
johpow01744ad972022-01-28 17:06:20 -0600141# RME doesn't support BRBE
142ifneq (${ENABLE_BRBE_FOR_NS},0)
143 $(error ENABLE_RME does not support BRBE.)
144endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500145# RME requires AARCH64
146ifneq (${ARCH},aarch64)
147 $(error ENABLE_RME requires AArch64)
148endif
149# RME requires el2 context to be saved for now.
150CTX_INCLUDE_EL2_REGS := 1
151CTX_INCLUDE_AARCH32_REGS := 0
152ARM_ARCH_MAJOR := 8
Andre Przywara7670ddb2022-10-04 13:56:49 +0100153ARM_ARCH_MINOR := 5
154ENABLE_FEAT_ECV = 1
155ENABLE_FEAT_FGT = 1
156
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500157endif
158
Soby Mathewc97cba42019-09-25 14:03:41 +0100159# USE_SPINLOCK_CAS requires AArch64 build
160ifeq (${USE_SPINLOCK_CAS},1)
161ifneq (${ARCH},aarch64)
162 $(error USE_SPINLOCK_CAS requires AArch64)
Soby Mathewc97cba42019-09-25 14:03:41 +0100163endif
164endif
165
Olivier Deprez0ca39132019-09-19 17:46:46 +0200166# USE_DEBUGFS experimental feature recommended only in debug builds
167ifeq (${USE_DEBUGFS},1)
168ifeq (${DEBUG},1)
169 $(warning DEBUGFS experimental feature is enabled.)
170else
171 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
172endif
173endif
174
Sumit Gargc6ba9b42019-11-14 16:33:45 +0530175ifneq (${DECRYPTION_SUPPORT},none)
176ENC_ARGS += -f ${FW_ENC_STATUS}
177ENC_ARGS += -k ${ENC_KEY}
178ENC_ARGS += -n ${ENC_NONCE}
179FIP_DEPS += enctool
180FWU_FIP_DEPS += enctool
181endif
182
Juan Castillo73c99d42015-08-18 14:23:04 +0100183################################################################################
184# Toolchain
185################################################################################
186
dp-arm72610c42017-05-02 11:09:11 +0100187HOSTCC := gcc
188export HOSTCC
189
Juan Castillo73c99d42015-08-18 14:23:04 +0100190CC := ${CROSS_COMPILE}gcc
191CPP := ${CROSS_COMPILE}cpp
192AS := ${CROSS_COMPILE}gcc
193AR := ${CROSS_COMPILE}ar
Roberto Vargas2adee762018-04-13 14:26:47 +0100194LINKER := ${CROSS_COMPILE}ld
Juan Castillo73c99d42015-08-18 14:23:04 +0100195OC := ${CROSS_COMPILE}objcopy
196OD := ${CROSS_COMPILE}objdump
197NM := ${CROSS_COMPILE}nm
198PP := ${CROSS_COMPILE}gcc -E
Soby Mathew38c14d82017-12-14 17:44:56 +0000199DTC := dtc
Juan Castillo73c99d42015-08-18 14:23:04 +0100200
Julius Wernerb25a5772018-01-10 15:12:47 -0800201# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
202ifneq ($(strip $(wildcard ${LD}.bfd) \
Roberto Vargas2adee762018-04-13 14:26:47 +0100203 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
204LINKER := ${LINKER}.bfd
Julius Wernerb25a5772018-01-10 15:12:47 -0800205endif
206
Etienne Carriere26e63c42017-11-08 13:48:40 +0100207ifeq (${ARM_ARCH_MAJOR},7)
208target32-directive = -target arm-none-eabi
209# Will set march32-directive from platform configuration
210else
211target32-directive = -target armv8a-none-eabi
Alexei Fedorovfa6f7742019-03-11 16:51:47 +0000212
Alexei Fedorovf1821792020-12-07 16:38:53 +0000213# Set the compiler's target architecture profile based on
214# ARM_ARCH_MAJOR ARM_ARCH_MINOR options
Alexei Fedorovfa6f7742019-03-11 16:51:47 +0000215ifeq (${ARM_ARCH_MINOR},0)
Alexei Fedorovf1821792020-12-07 16:38:53 +0000216march32-directive = -march=armv${ARM_ARCH_MAJOR}-a
217march64-directive = -march=armv${ARM_ARCH_MAJOR}-a
Alexei Fedorovfa6f7742019-03-11 16:51:47 +0000218else
Alexei Fedorovf1821792020-12-07 16:38:53 +0000219march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
220march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
Alexei Fedorovfa6f7742019-03-11 16:51:47 +0000221endif
Etienne Carriere26e63c42017-11-08 13:48:40 +0100222endif
223
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000224# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
225ifeq ($(ARCH), aarch64)
Sami Mujawar4a565bd2020-04-23 09:28:37 +0100226# Check if revision is greater than or equal to 8.5
227ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000228mem_tag_arch_support = yes
229endif
230endif
231
Alexei Fedorovf1821792020-12-07 16:38:53 +0000232# Get architecture feature modifiers
233arch-features = ${ARM_ARCH_FEATURE}
234
235# Enable required options for memory stack tagging.
236# Currently, these options are enabled only for clang and armclang compiler.
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000237ifeq (${SUPPORT_STACK_MEMTAG},yes)
238ifdef mem_tag_arch_support
Alexei Fedorovf1821792020-12-07 16:38:53 +0000239# Check for armclang and clang compilers
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000240ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
Alexei Fedorovf1821792020-12-07 16:38:53 +0000241# Add "memtag" architecture feature modifier if not specified
242ifeq ( ,$(findstring memtag,$(arch-features)))
243arch-features := $(arch-features)+memtag
244endif # memtag
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000245ifeq ($(notdir $(CC)),armclang)
246TF_CFLAGS += -mmemtag-stack
247else ifeq ($(notdir $(CC)),clang)
248TF_CFLAGS += -fsanitize=memtag
Alexei Fedorovf1821792020-12-07 16:38:53 +0000249endif # armclang
250endif # armclang clang
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000251else
252$(error "Error: stack memory tagging is not supported for architecture \
253 ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
Alexei Fedorovf1821792020-12-07 16:38:53 +0000254endif # mem_tag_arch_support
255endif # SUPPORT_STACK_MEMTAG
256
257# Set the compiler's architecture feature modifiers
258ifneq ($(arch-features), none)
259# Strip "none+" from arch-features
260arch-features := $(subst none+,,$(arch-features))
261ifeq ($(ARCH), aarch32)
262march32-directive := $(march32-directive)+$(arch-features)
263else
264march64-directive := $(march64-directive)+$(arch-features)
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000265endif
Alexei Fedorovf1821792020-12-07 16:38:53 +0000266# Print features
267$(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
268endif # arch-features
Manish V Badarkhe7ff088d2020-03-22 05:06:38 +0000269
Tomas Pilar12cd65e2020-10-29 13:01:16 +0000270# Determine if FEAT_RNG is supported
271ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0)
272
Chris Kay4e044782021-03-09 13:34:35 +0000273# Determine if FEAT_SB is supported
274ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0)
275
originc8a992f2022-01-19 16:30:14 +0000276ifneq ($(findstring clang,$(notdir $(CC))),)
277 ifneq ($(findstring armclang,$(notdir $(CC))),)
278 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march32-directive)
279 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march64-directive)
280 LD := $(LINKER)
281 else
Arvind Ram Prakash94eb1272022-10-19 15:44:51 -0500282 TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive)
originc8a992f2022-01-19 16:30:14 +0000283 TF_CFLAGS_aarch64 := -target aarch64-elf $(march64-directive)
284 LD := $(shell $(CC) --print-prog-name ld.lld)
285
286 AR := $(shell $(CC) --print-prog-name llvm-ar)
287 OD := $(shell $(CC) --print-prog-name llvm-objdump)
288 OC := $(shell $(CC) --print-prog-name llvm-objcopy)
289 endif
290
291 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
292 PP := $(CC) -E $(TF_CFLAGS_$(ARCH))
293 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600294else ifneq ($(findstring gcc,$(notdir $(CC))),)
295TF_CFLAGS_aarch32 = $(march32-directive)
296TF_CFLAGS_aarch64 = $(march64-directive)
297ifeq ($(ENABLE_LTO),1)
298 # Enable LTO only for aarch64
299 ifeq (${ARCH},aarch64)
300 LTO_CFLAGS = -flto
301 # Use gcc as a wrapper for the ld, recommended for LTO
302 LINKER := ${CROSS_COMPILE}gcc
303 endif
304endif
305LD = $(LINKER)
dp-armd5461852017-05-02 12:00:08 +0100306else
Etienne Carriere26e63c42017-11-08 13:48:40 +0100307TF_CFLAGS_aarch32 = $(march32-directive)
Alexei Fedorovfa6f7742019-03-11 16:51:47 +0000308TF_CFLAGS_aarch64 = $(march64-directive)
Roberto Vargas2adee762018-04-13 14:26:47 +0100309LD = $(LINKER)
dp-armd5461852017-05-02 12:00:08 +0100310endif
311
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100312# Process Debug flag
313$(eval $(call add_define,DEBUG))
314ifneq (${DEBUG}, 0)
315 BUILD_TYPE := debug
Daniel Boulby4466cf82022-05-03 16:46:16 +0100316 TF_CFLAGS += -g -gdwarf-4
317 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100318
319 # Use LOG_LEVEL_INFO by default for debug builds
320 LOG_LEVEL := 40
321else
322 BUILD_TYPE := release
323 # Use LOG_LEVEL_NOTICE by default for release builds
324 LOG_LEVEL := 20
325endif
326
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800327# Default build string (git branch and commit)
328ifeq (${BUILD_STRING},)
329 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
330endif
Varun Wadekarc7e8bda2023-02-10 21:23:51 +0000331VERSION_STRING := lts-v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800332
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100333ifeq (${AARCH32_INSTRUCTION_SET},A32)
334TF_CFLAGS_aarch32 += -marm
335else ifeq (${AARCH32_INSTRUCTION_SET},T32)
336TF_CFLAGS_aarch32 += -mthumb
337else
338$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
339endif
340
Sandrine Bailleuxa9c4dde2018-07-03 09:14:45 +0200341TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-armd5461852017-05-02 12:00:08 +0100342TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathew9d29c222016-05-05 14:33:33 +0100343
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100344ifneq (${BP_OPTION},none)
345TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
346endif
347
Etienne Carriere26e63c42017-11-08 13:48:40 +0100348ASFLAGS_aarch32 = $(march32-directive)
Alexei Fedorovfa6f7742019-03-11 16:51:47 +0000349ASFLAGS_aarch64 = $(march64-directive)
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000350
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100351# General warnings
352WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier34b508b2021-05-20 13:18:14 +0200353 -Wdisabled-optimization -Wvla -Wshadow \
Madhukar Pappireddyca661a02019-12-23 14:49:52 -0600354 -Wno-unused-parameter -Wredundant-decls
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100355
356# Additional warnings
357# Level 1
Yann Gautiere7c645b2018-12-10 18:00:26 +0100358WARNING1 := -Wextra
Yann Gautiere7c645b2018-12-10 18:00:26 +0100359WARNING1 += -Wmissing-format-attribute
360WARNING1 += -Wmissing-prototypes
361WARNING1 += -Wold-style-definition
Yann Gautiere7c645b2018-12-10 18:00:26 +0100362
Justin Chadwellb7f65252019-09-17 15:21:50 +0100363# Level 2
Yann Gautiere7c645b2018-12-10 18:00:26 +0100364WARNING2 := -Waggregate-return
365WARNING2 += -Wcast-align
Yann Gautiere7c645b2018-12-10 18:00:26 +0100366WARNING2 += -Wnested-externs
Yann Gautiere7c645b2018-12-10 18:00:26 +0100367
368WARNING3 := -Wbad-function-cast
369WARNING3 += -Wcast-qual
370WARNING3 += -Wconversion
371WARNING3 += -Wpacked
Yann Gautiere7c645b2018-12-10 18:00:26 +0100372WARNING3 += -Wpointer-arith
Yann Gautiere7c645b2018-12-10 18:00:26 +0100373WARNING3 += -Wswitch-default
Yann Gautiere7c645b2018-12-10 18:00:26 +0100374
375ifeq (${W},1)
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100376WARNINGS += $(WARNING1)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100377else ifeq (${W},2)
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100378WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100379else ifeq (${W},3)
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100380WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100381endif
382
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100383# Compiler specific warnings
Ambroise Vincent00296572019-05-24 12:47:43 +0100384ifeq ($(findstring clang,$(notdir $(CC))),)
Justin Chadwell93c690e2019-07-03 14:15:56 +0100385# not using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100386WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
387 -Wpacked-bitfield-compat -Wshift-overflow=2 \
388 -Wlogical-op
Justin Chadwell93c690e2019-07-03 14:15:56 +0100389else
390# using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100391WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
392 -Wlogical-op-parentheses
Ambroise Vincent00296572019-05-24 12:47:43 +0100393endif
394
Yann Gautier6336b072018-12-10 18:08:53 +0100395ifneq (${E},0)
396ERRORS := -Werror
397endif
398
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100399CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
400 $(ERRORS) $(WARNINGS)
Masahiro Yamada59de5092016-12-22 12:51:53 +0900401ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
Julius Wernerd5dfdeb2019-07-09 13:49:11 -0700402 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada59de5092016-12-22 12:51:53 +0900403TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Hollandebd6efa2019-10-20 16:11:25 -0500404 -ffunction-sections -fdata-sections \
405 -ffreestanding -fno-builtin -fno-common \
406 -Os -std=gnu99
Juan Castillo73c99d42015-08-18 14:23:04 +0100407
Mark Brownbebcf272022-04-20 18:14:32 +0100408$(eval $(call add_define,SVE_VECTOR_LEN))
409
Justin Chadwell1f461972019-08-20 11:01:52 +0100410ifeq (${SANITIZE_UB},on)
411TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
412endif
413ifeq (${SANITIZE_UB},trap)
414TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
415 -fsanitize-undefined-trap-on-error
416endif
417
david cunadof7ec31d2017-11-30 21:58:01 +0000418GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
david cunadof7ec31d2017-11-30 21:58:01 +0000419
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100420# LD = armlink
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800421ifneq ($(findstring armlink,$(notdir $(LD))),)
422TF_LDFLAGS += --diag_error=warning --lto_level=O1
423TF_LDFLAGS += --remove --info=unused,unusedsymbols
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600424TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100425
426# LD = gcc (used when GCC LTO is enabled)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600427else ifneq ($(findstring gcc,$(notdir $(LD))),)
428# Pass ld options with Wl or Xlinker switches
429TF_LDFLAGS += -Wl,--fatal-warnings -O1
430TF_LDFLAGS += -Wl,--gc-sections
431ifeq ($(ENABLE_LTO),1)
432 ifeq (${ARCH},aarch64)
433 TF_LDFLAGS += -flto -fuse-linker-plugin
434 endif
435endif
436# GCC automatically adds fix-cortex-a53-843419 flag when used to link
437# which breaks some builds, so disable if errata fix is not explicitly enabled
438ifneq (${ERRATA_A53_843419},1)
439 TF_LDFLAGS += -mno-fix-cortex-a53-843419
440endif
441TF_LDFLAGS += -nostdlib
442TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100443
444# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800445else
Douglas Raillardc2b88062017-06-22 14:44:48 +0100446TF_LDFLAGS += --fatal-warnings -O1
447TF_LDFLAGS += --gc-sections
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100448# ld.lld doesn't recognize the errata flags,
449# therefore don't add those in that case
450ifeq ($(findstring ld.lld,$(notdir $(LD))),)
Douglas Raillardc2b88062017-06-22 14:44:48 +0100451TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600452endif
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100453endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100454
Nishanth Menon03b397a2016-10-14 01:13:57 +0000455DTC_FLAGS += -I dts -O dtb
Louis Mayencourta6de8242020-02-28 16:57:30 +0000456DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \
457 -x assembler-with-cpp $(DEFINES)
Nishanth Menon03b397a2016-10-14 01:13:57 +0000458
Juan Castillo73c99d42015-08-18 14:23:04 +0100459################################################################################
460# Common sources and include directories
461################################################################################
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000462include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
dp-armd801fbb2017-05-04 12:15:35 +0100463include lib/compiler-rt/compiler-rt.mk
Juan Castillo73c99d42015-08-18 14:23:04 +0100464
465BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100466 common/tf_log.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100467 common/${ARCH}/debug.S \
Julius Werner91b48c92018-11-27 22:10:56 -0800468 drivers/console/multi_console.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100469 lib/${ARCH}/cache_helpers.S \
470 lib/${ARCH}/misc_helpers.S \
Soby Mathew566034f2018-02-08 17:45:12 +0000471 plat/common/plat_bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100472 plat/common/plat_log_common.c \
dp-arm75311202017-03-07 11:02:47 +0000473 plat/common/${ARCH}/plat_common.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100474 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas61f72a32018-05-08 10:27:10 +0100475 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000476
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100477ifeq ($(notdir $(CC)),armclang)
478BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
479endif
480
Justin Chadwell1f461972019-08-20 11:01:52 +0100481ifeq (${SANITIZE_UB},on)
482BL_COMMON_SOURCES += plat/common/ubsan.c
483endif
484
Yann Gautier01d237c2018-06-18 16:00:23 +0200485INCLUDES += -Iinclude \
Antonio Nino Diazf5478de2018-12-17 17:20:57 +0000486 -Iinclude/arch/${ARCH} \
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +0000487 -Iinclude/lib/cpus/${ARCH} \
488 -Iinclude/lib/el3_runtime/${ARCH} \
489 ${PLAT_INCLUDES} \
490 ${SPD_INCLUDES}
491
Antonio Nino Diaz9c6d1c52018-11-19 11:48:30 +0000492include common/backtrace/backtrace.mk
493
Juan Castillo73c99d42015-08-18 14:23:04 +0100494################################################################################
495# Generic definitions
496################################################################################
497
Evan Lloyd231c1472015-12-02 18:17:37 +0000498include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
499
Grant Likely29214e92020-07-30 08:50:10 +0100500ifeq (${BUILD_BASE},)
501 BUILD_BASE := ./build
502endif
503BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
Juan Castillo73c99d42015-08-18 14:23:04 +0100504
Evan Lloyd231c1472015-12-02 18:17:37 +0000505SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
Juan Castillo73c99d42015-08-18 14:23:04 +0100506
507# Platforms providing their own TBB makefile may override this value
508INCLUDE_TBBR_MK := 1
509
510
511################################################################################
512# Include SPD Makefile if one has been specified
513################################################################################
514
515ifneq (${SPD},none)
Max Shvetsov28f39f02020-02-25 13:56:19 +0000516 ifeq (${ARCH},aarch32)
Sandrine Bailleux44a87382018-10-03 14:56:38 +0200517 $(error "Error: SPD is incompatible with AArch32.")
Max Shvetsov28f39f02020-02-25 13:56:19 +0000518 endif
519
520 ifdef EL3_PAYLOAD_BASE
Sandrine Bailleux4c117f62015-11-26 16:31:34 +0000521 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
522 $(warning "The SPD and its BL32 companion will be present but ignored.")
Max Shvetsov28f39f02020-02-25 13:56:19 +0000523 endif
Achin Guptac3fb00d2019-10-11 15:50:43 +0100524
Max Shvetsov28f39f02020-02-25 13:56:19 +0000525 ifeq (${SPD},spmd)
526 # SPMD is located in std_svc directory
527 SPD_DIR := std_svc
Achin Guptac3fb00d2019-10-11 15:50:43 +0100528
Max Shvetsov033039f2020-02-25 13:55:00 +0000529 ifeq ($(SPMD_SPM_AT_SEL2),1)
530 ifeq ($(CTX_INCLUDE_EL2_REGS),0)
531 $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
532 endif
Marc Bonnici1d63ae42021-12-01 18:00:40 +0000533 ifeq ($(SPMC_AT_EL3),1)
534 $(error SPM cannot be enabled in both S-EL2 and EL3.)
535 endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100536 endif
Olivier Deprezdb1ef412020-04-01 21:28:26 +0200537
538 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
539 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
540 endif
Davidson Kca932482021-03-10 12:07:15 +0530541
542 ifeq ($(TS_SP_FW_CONFIG),1)
543 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
544 endif
Balint Dobszay33993a32021-03-26 15:19:11 +0100545
546 ifneq ($(ARM_BL2_SP_LIST_DTS),)
547 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
548 endif
Balint Dobszay46789a72021-03-26 16:23:18 +0100549
550 ifneq ($(SP_LAYOUT_FILE),)
551 BL2_ENABLE_SP_LOAD := 1
552 endif
Max Shvetsov28f39f02020-02-25 13:56:19 +0000553 else
554 # All other SPDs in spd directory
555 SPD_DIR := spd
556 endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100557
Max Shvetsov28f39f02020-02-25 13:56:19 +0000558 # We expect to locate an spd.mk under the specified SPD directory
559 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
560
561 ifeq (${SPD_MAKE},)
562 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
563 endif
564 $(info Including ${SPD_MAKE})
565 include ${SPD_MAKE}
566
567 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
568 # Makefile would set NEED_BL32 to "yes". In this case, the build system
569 # supports two mutually exclusive options:
570 # * BL32 is built from source: then BL32_SOURCES must contain the list
571 # of source files to build BL32
572 # * BL32 is a prebuilt binary: then BL32 must point to the image file
573 # that will be included in the FIP
574 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
575 # over the sources.
Jeenu Viswambharane35c4042014-05-15 14:40:58 +0100576endif
577
Douglas Raillard51faada2017-02-24 18:14:15 +0000578################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500579# Include rmmd Makefile if RME is enabled
580################################################################################
581
582ifneq (${ENABLE_RME},0)
583ifneq (${ARCH},aarch64)
584 $(error ENABLE_RME requires AArch64)
585endif
Marc Bonnici1d63ae42021-12-01 18:00:40 +0000586ifeq ($(SPMC_AT_EL3),1)
587 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
588endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500589include services/std_svc/rmmd/rmmd.mk
590$(warning "RME is an experimental feature")
591endif
592
593################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100594# Include the platform specific Makefile after the SPD Makefile (the platform
595# makefile may use all previous definitions in this file)
596################################################################################
Jeenu Viswambharan2da8d8b2014-05-12 15:28:47 +0100597
Juan Castillo73c99d42015-08-18 14:23:04 +0100598include ${PLAT_MAKEFILE_FULL}
Juan Castillo0f21c542014-06-25 17:26:36 +0100599
Masahiro Yamada8012cc52017-11-04 03:12:28 +0900600$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
601
Etienne Carriere26e63c42017-11-08 13:48:40 +0100602ifeq (${ARM_ARCH_MAJOR},7)
603include make_helpers/armv7-a-cpus.mk
604endif
605
Masahiro Yamada320920c2020-01-17 13:44:37 +0900606PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
607ifneq ($(PIE_FOUND),)
608 TF_CFLAGS += -fno-PIE
Samuel Holland7b592412022-04-08 21:56:02 -0500609ifneq ($(findstring gcc,$(notdir $(LD))),)
610 TF_LDFLAGS += -no-pie
611endif
Masahiro Yamada320920c2020-01-17 13:44:37 +0900612endif
613
614ifneq ($(findstring gcc,$(notdir $(LD))),)
615 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew3bd17c02018-08-28 11:13:55 +0100616else
Masahiro Yamada320920c2020-01-17 13:44:37 +0900617 PIE_LDFLAGS += -pie --no-dynamic-linker
618endif
619
620ifeq ($(ENABLE_PIE),1)
Masahiro Yamada69af7fc2020-01-17 13:45:02 +0900621ifeq ($(BL2_AT_EL3),1)
622ifneq ($(BL2_IN_XIP_MEM),1)
623 BL2_CFLAGS += -fpie
624 BL2_LDFLAGS += $(PIE_LDFLAGS)
625endif
626endif
Masahiro Yamada320920c2020-01-17 13:44:37 +0900627 BL31_CFLAGS += -fpie
628 BL31_LDFLAGS += $(PIE_LDFLAGS)
Masahiro Yamadad9743012020-01-17 13:45:14 +0900629 BL32_CFLAGS += -fpie
630 BL32_LDFLAGS += $(PIE_LDFLAGS)
631endif
Soby Mathew3bd17c02018-08-28 11:13:55 +0100632
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900633ifeq (${ARCH},aarch64)
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900634BL1_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900635ifeq ($(BL2_AT_EL3),1)
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900636BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900637else
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900638BL2_CPPFLAGS += -DIMAGE_AT_EL1
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900639endif
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900640BL2U_CPPFLAGS += -DIMAGE_AT_EL1
641BL31_CPPFLAGS += -DIMAGE_AT_EL3
642BL32_CPPFLAGS += -DIMAGE_AT_EL1
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900643endif
644
Sandrine Bailleux54035fc2016-01-13 14:57:38 +0000645# Include the CPU specific operations makefile, which provides default
646# values for all CPU errata workarounds and CPU specific optimisations.
647# This can be overridden by the platform.
Juan Castillo73c99d42015-08-18 14:23:04 +0100648include lib/cpus/cpu-ops.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100649
dp-arma4409002017-02-15 11:07:55 +0000650ifeq (${ARCH},aarch32)
651NEED_BL32 := yes
652
653################################################################################
654# Build `AARCH32_SP` as BL32 image for AArch32
655################################################################################
656ifneq (${AARCH32_SP},none)
657# We expect to locate an sp.mk under the specified AARCH32_SP directory
658AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
659
660ifeq (${AARCH32_SP_MAKE},)
661 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
662endif
663
664$(info Including ${AARCH32_SP_MAKE})
665include ${AARCH32_SP_MAKE}
666endif
667
668endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100669
Juan Castillo73c99d42015-08-18 14:23:04 +0100670################################################################################
Varun Wadekar77f1f7a2019-01-31 09:22:30 -0800671# Include libc if not overridden
672################################################################################
673ifeq (${OVERRIDE_LIBC},0)
674include lib/libc/libc.mk
675endif
676
677################################################################################
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000678# Check incompatible options
679################################################################################
680
681ifdef EL3_PAYLOAD_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100682 ifdef PRELOADED_BL33_BASE
683 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
684 incompatible build options. EL3_PAYLOAD_BASE has priority.")
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000685 endif
Qixiang Xu76580f32017-08-24 11:03:23 +0800686 ifneq (${GENERATE_COT},0)
687 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
688 endif
689 ifneq (${TRUSTED_BOARD_BOOT},0)
690 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
691 endif
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000692endif
693
694ifeq (${NEED_BL33},yes)
695 ifdef EL3_PAYLOAD_BASE
696 $(warning "BL33 image is not needed when option \
697 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
698 endif
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100699 ifdef PRELOADED_BL33_BASE
700 $(warning "BL33 image is not needed when option \
701 PRELOADED_BL33_BASE is used and won't be added to the FIP \
702 file.")
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000703 endif
704endif
705
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000706# When building for systems with hardware-assisted coherency, there's no need to
707# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
708ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
709$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
710endif
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +0100711
Jiafei Pan7d173fc2018-03-21 07:20:09 +0000712#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
713ifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
714$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
715endif
716
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100717# For RAS_EXTENSION, require that EAs are handled in EL3 first
718ifeq ($(RAS_EXTENSION),1)
Manish Pandey46cc41d2022-10-10 11:43:08 +0100719 ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
720 $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1)
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100721 endif
722endif
723
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000724# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
725ifeq ($(FAULT_INJECTION_SUPPORT),1)
726 ifneq ($(RAS_EXTENSION),1)
727 $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
728 endif
729endif
730
Roberto Vargased51b512018-09-24 17:20:48 +0100731# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew209a60c2018-03-26 12:43:37 +0100732ifeq ($(DYN_DISABLE_AUTH), 1)
733 ifeq (${TRUSTED_BOARD_BOOT}, 0)
734 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
735 endif
Soby Mathew209a60c2018-03-26 12:43:37 +0100736endif
737
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100738ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
739# Support authentication verification and hash calculation
740 CRYPTO_SUPPORT := 3
741else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
742# Support authentication verification and hash calculation
743 CRYPTO_SUPPORT := 3
744else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
745# Support hash calculation only
746 CRYPTO_SUPPORT := 2
747else ifeq (${TRUSTED_BOARD_BOOT},1)
748# Support authentication verification only
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000749 CRYPTO_SUPPORT := 1
750else
751 CRYPTO_SUPPORT := 0
752endif
753
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100754# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
755ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Manish Pandey700e7682021-10-21 21:53:49 +0100756$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhe84ef9cd2020-06-29 10:32:53 +0100757endif
758
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000759# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100760# registers associated to it are also saved and restored.
761# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000762ifeq ($(ENABLE_PAUTH),1)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100763 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
764 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
765 endif
766endif
767
768ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
769 ifneq (${ARCH},aarch64)
770 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
Alexei Fedorov06715f82019-03-13 11:05:07 +0000771 endif
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100772endif
773
Justin Chadwell9dd94382019-07-18 14:25:33 +0100774ifeq ($(CTX_INCLUDE_MTE_REGS),1)
775 ifneq (${ARCH},aarch64)
776 $(error CTX_INCLUDE_MTE_REGS requires AArch64)
Justin Chadwell9dd94382019-07-18 14:25:33 +0100777 endif
778endif
779
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100780ifeq ($(PSA_FWU_SUPPORT),1)
781 $(info PSA_FWU_SUPPORT is an experimental feature)
782endif
783
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000784ifeq ($(FEATURE_DETECTION),1)
785 $(info FEATURE_DETECTION is an experimental feature)
786endif
787
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000788ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
789 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
790 $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
791 endif
792endif
793
Sumit Garg7cda17b2019-11-15 10:43:00 +0530794ifneq (${DECRYPTION_SUPPORT},none)
795 ifeq (${TRUSTED_BOARD_BOOT}, 0)
796 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
Sumit Garg7cda17b2019-11-15 10:43:00 +0530797 endif
798endif
799
johpow01744ad972022-01-28 17:06:20 -0600800# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow01dc78e622021-07-08 14:14:00 -0500801ifeq (${ARCH},aarch32)
johpow01744ad972022-01-28 17:06:20 -0600802
803 # SME/SVE only supported on AArch64
johpow01dc78e622021-07-08 14:14:00 -0500804 ifeq (${ENABLE_SME_FOR_NS},1)
805 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
806 endif
807 ifeq (${ENABLE_SVE_FOR_NS},1)
808 # Warning instead of error due to CI dependency on this
Yann Gautier24ab2c02021-11-19 11:35:46 +0100809 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
johpow01dc78e622021-07-08 14:14:00 -0500810 endif
johpow01744ad972022-01-28 17:06:20 -0600811
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -0400812 # BRBE is not supported in AArch32
johpow01744ad972022-01-28 17:06:20 -0600813 ifeq (${ENABLE_BRBE_FOR_NS},1)
814 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
815 endif
816
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -0400817 # FEAT_RNG_TRAP is not supported in AArch32
818 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
819 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
820 endif
johpow01dc78e622021-07-08 14:14:00 -0500821endif
822
823# Ensure ENABLE_RME is not used with SME
824ifeq (${ENABLE_RME},1)
825 ifeq (${ENABLE_SME_FOR_NS},1)
826 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
827 endif
828endif
829
830# Secure SME/SVE requires the non-secure component as well
831ifeq (${ENABLE_SME_FOR_SWD},1)
832 ifeq (${ENABLE_SME_FOR_NS},0)
833 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
834 endif
835endif
836ifeq (${ENABLE_SVE_FOR_SWD},1)
837 ifeq (${ENABLE_SVE_FOR_NS},0)
838 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
839 endif
840endif
841
842# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
843# its own context management including FPU registers.
844ifeq (${CTX_INCLUDE_FPREGS},1)
845 ifeq (${ENABLE_SME_FOR_NS},1)
846 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
847 endif
848 ifeq (${ENABLE_SVE_FOR_NS},1)
849 # Warning instead of error due to CI dependency on this
850 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
851 $(warning "Forced ENABLE_SVE_FOR_NS=0")
852 override ENABLE_SVE_FOR_NS := 0
853 endif
854endif
855
Manish V Badarkhe00e28872022-03-02 12:06:35 +0000856ifeq ($(DRTM_SUPPORT),1)
857 $(info DRTM_SUPPORT is an experimental feature)
858endif
859
Chris Kay274a69e2022-09-29 16:21:24 +0100860ifeq (${ENABLE_RME},1)
861 ifneq (${SEPARATE_CODE_AND_RODATA},1)
862 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
863 endif
864endif
865
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000866################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100867# Process platform overrideable behaviour
868################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +0100869
Manish Pandey5f24ce92021-10-06 10:59:52 +0100870ifdef BL1_SOURCES
871NEED_BL1 := yes
872endif
873
Juan Castillo73c99d42015-08-18 14:23:04 +0100874ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +0100875 NEED_BL2 := yes
876
877 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
878 # Certificate generation tools. This flag can be overridden by the platform.
879 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000880 # If booting an EL3 payload there is no need for a BL33 image
881 # in the FIP file.
882 NEED_BL33 := no
883 else
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100884 ifdef PRELOADED_BL33_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000885 # If booting a BL33 preloaded image there is no need of
886 # another one in the FIP file.
887 NEED_BL33 := no
888 else
889 NEED_BL33 ?= yes
890 endif
891 endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100892endif
893
Manish Pandey5f24ce92021-10-06 10:59:52 +0100894ifdef BL2U_SOURCES
895NEED_BL2U := yes
896endif
897
Masahiro Yamada4d045d02017-04-05 19:11:41 +0900898# If SCP_BL2 is given, we always want FIP to include it.
899ifdef SCP_BL2
900 NEED_SCP_BL2 := yes
901endif
902
Soby Mathew5744e872017-11-14 14:10:10 +0000903# For AArch32, BL31 is not currently supported.
904ifneq (${ARCH},aarch32)
905 ifdef BL31_SOURCES
906 # When booting an EL3 payload, there is no need to compile the BL31 image nor
907 # put it in the FIP.
908 ifndef EL3_PAYLOAD_BASE
909 NEED_BL31 := yes
910 endif
911 endif
912endif
913
Juan Castillo73c99d42015-08-18 14:23:04 +0100914# Process TBB related flags
915ifneq (${GENERATE_COT},0)
916 # Common cert_create options
917 ifneq (${CREATE_KEYS},0)
918 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +0100919 $(eval FWU_CRT_ARGS += -n)
Juan Castillo73c99d42015-08-18 14:23:04 +0100920 ifneq (${SAVE_KEYS},0)
921 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +0100922 $(eval FWU_CRT_ARGS += -k)
Juan Castillo73c99d42015-08-18 14:23:04 +0100923 endif
924 endif
925 # Include TBBR makefile (unless the platform indicates otherwise)
926 ifeq (${INCLUDE_TBBR_MK},1)
927 include make_helpers/tbbr/tbbr_tools.mk
928 endif
929endif
930
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +0900931ifneq (${FIP_ALIGN},0)
932FIP_ARGS += --align ${FIP_ALIGN}
933endif
934
Manish Pandey5f24ce92021-10-06 10:59:52 +0100935ifdef FDT_SOURCES
936NEED_FDT := yes
937endif
938
Juan Castillo73c99d42015-08-18 14:23:04 +0100939################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +0800940# Include libraries' Makefile that are used in all BL
941################################################################################
942
943include lib/stack_protector/stack_protector.mk
944
945################################################################################
dp-arm819281e2016-05-25 16:20:20 +0100946# Auxiliary tools (fiptool, cert_create, etc)
Juan Castillo73c99d42015-08-18 14:23:04 +0100947################################################################################
Harry Liebelf58ad362014-01-10 18:00:33 +0000948
Juan Castillo6f971622014-10-21 11:30:42 +0100949# Variables for use with Certificate Generation Tool
950CRTTOOLPATH ?= tools/cert_create
Evan Lloyd42a45b52015-12-03 11:35:40 +0000951CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
Juan Castillo6f971622014-10-21 11:30:42 +0100952
Sumit Garg90aa9012019-11-11 18:46:36 +0530953# Variables for use with Firmware Encryption Tool
954ENCTOOLPATH ?= tools/encrypt_fw
955ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
956
Juan Castillo73c99d42015-08-18 14:23:04 +0100957# Variables for use with Firmware Image Package
dp-arm819281e2016-05-25 16:20:20 +0100958FIPTOOLPATH ?= tools/fiptool
959FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
Juan Castillo6f971622014-10-21 11:30:42 +0100960
Antonio Nino Diaz26010da2018-11-27 14:58:04 +0000961# Variables for use with sptool
962SPTOOLPATH ?= tools/sptool
J-Alves822c7272022-03-22 16:28:51 +0000963SPTOOL ?= ${SPTOOLPATH}/sptool.py
Manish Pandeyce2b1ec2020-01-14 11:52:05 +0000964SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Antonio Nino Diaz26010da2018-11-27 14:58:04 +0000965
Roberto Vargas5accce52018-05-22 16:05:42 +0100966# Variables for use with ROMLIB
967ROMLIBPATH ?= lib/romlib
968
Louis Mayencourtcfe83912019-10-16 14:30:51 +0100969# Variable for use with Python
970PYTHON ?= python3
971
972# Variables for use with PRINT_MEMORY_MAP
973PRINT_MEMORY_MAP_PATH ?= tools/memory
974PRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
975
Madhukar Pappireddy6de32372020-01-28 12:41:20 -0600976# Variables for use with documentation build using Sphinx tool
977DOCS_PATH ?= docs
978
Abdul Halim, Muhammad Hadi Asyrafi1f1c0202020-06-29 12:15:27 +0800979# Defination of SIMICS flag
980SIMICS_BUILD ?= 0
981
Soby Mathew8a860522017-02-14 10:05:07 +0000982################################################################################
983# Include BL specific makefiles
984################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +0100985
986ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +0000987include bl1/bl1.mk
988endif
989
Manish Pandey5f24ce92021-10-06 10:59:52 +0100990ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +0000991include bl2/bl2.mk
992endif
993
Manish Pandey5f24ce92021-10-06 10:59:52 +0100994ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +0000995include bl2u/bl2u.mk
996endif
997
Soby Mathew5744e872017-11-14 14:10:10 +0000998ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +0000999include bl31/bl31.mk
1000endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001001
Juan Castillo73c99d42015-08-18 14:23:04 +01001002################################################################################
1003# Build options checks
1004################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001005
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001006$(eval $(call assert_booleans,\
1007 $(sort \
1008 ALLOW_RO_XLAT_TABLES \
Balint Dobszay46789a72021-03-26 16:23:18 +01001009 BL2_ENABLE_SP_LOAD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001010 COLD_BOOT_SINGLE_CPU \
1011 CREATE_KEYS \
1012 CTX_INCLUDE_AARCH32_REGS \
1013 CTX_INCLUDE_FPREGS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001014 CTX_INCLUDE_EL2_REGS \
1015 DEBUG \
Javier Almansa Sobrino0063dd12020-11-23 18:38:15 +00001016 DISABLE_MTPMU \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001017 DYN_DISABLE_AUTH \
1018 EL3_EXCEPTION_HANDLING \
1019 ENABLE_AMU \
Chris Kay1fd685a2021-05-25 10:42:56 +01001020 ENABLE_AMU_AUXILIARY_COUNTERS \
Chris Kay742ca232021-08-19 11:21:52 +01001021 ENABLE_AMU_FCONF \
johpow01873d4242020-10-02 13:41:11 -05001022 AMU_RESTRICT_COUNTERS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001023 ENABLE_ASSERTIONS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001024 ENABLE_PIE \
1025 ENABLE_PMF \
1026 ENABLE_PSCI_STAT \
1027 ENABLE_RUNTIME_INSTRUMENTATION \
johpow01dc78e622021-07-08 14:14:00 -05001028 ENABLE_SME_FOR_NS \
1029 ENABLE_SME_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001030 ENABLE_SPE_FOR_LOWER_ELS \
1031 ENABLE_SVE_FOR_NS \
Max Shvetsov0c5e7d12021-03-22 11:59:37 +00001032 ENABLE_SVE_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001033 ERROR_DEPRECATED \
1034 FAULT_INJECTION_SUPPORT \
1035 GENERATE_COT \
1036 GICV2_G0_FOR_EL3 \
Manish Pandey46cc41d2022-10-10 11:43:08 +01001037 HANDLE_EA_EL3_FIRST_NS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001038 HW_ASSISTED_COHERENCY \
1039 INVERTED_MEMMAP \
1040 MEASURED_BOOT \
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001041 DRTM_SUPPORT \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001042 NS_TIMER_SWITCH \
1043 OVERRIDE_LIBC \
1044 PL011_GENERIC_UART \
Tamas Ban0ce20722022-01-18 16:20:47 +01001045 PLAT_RSS_NOT_SUPPORTED \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001046 PROGRAMMABLE_RESET_ADDRESS \
1047 PSCI_EXTENDED_STATE_ID \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001048 RESET_TO_BL31 \
Jorge Ramirez-Ortiz25844ff2022-04-15 11:46:47 +02001049 RESET_TO_BL31_WITH_PARAMS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001050 SAVE_KEYS \
1051 SEPARATE_CODE_AND_RODATA \
Jiafei Pan96a8ed12022-02-24 10:47:33 +08001052 SEPARATE_BL2_NOLOAD_REGION \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001053 SEPARATE_NOBITS_REGION \
1054 SPIN_ON_BL1_EXIT \
1055 SPM_MM \
Marc Bonnici1d63ae42021-12-01 18:00:40 +00001056 SPMC_AT_EL3 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001057 SPMD_SPM_AT_SEL2 \
1058 TRUSTED_BOARD_BOOT \
1059 USE_COHERENT_MEM \
1060 USE_DEBUGFS \
1061 ARM_IO_IN_DTB \
1062 SDEI_IN_FCONF \
1063 SEC_INT_DESC_IN_FCONF \
1064 USE_ROMLIB \
1065 USE_TBBR_DEFS \
1066 WARMBOOT_ENABLE_DCACHE_EARLY \
1067 BL2_AT_EL3 \
1068 BL2_IN_XIP_MEM \
1069 BL2_INV_DCACHE \
1070 USE_SPINLOCK_CAS \
1071 ENCRYPT_BL31 \
1072 ENCRYPT_BL32 \
1073 ERRATA_SPECULATIVE_AT \
Manish Pandey00e8f792022-09-27 14:30:34 +01001074 RAS_TRAP_NS_ERR_REC_ACCESS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001075 COT_DESC_IN_DTB \
1076 USE_SP804_TIMER \
Manish V Badarkhe396b3392021-06-25 23:28:59 +01001077 PSA_FWU_SUPPORT \
Manish V Badarkhed4582d32021-06-29 11:44:20 +01001078 ENABLE_SYS_REG_TRACE_FOR_NS \
Chris Kay68120782021-05-05 13:38:30 +01001079 ENABLE_MPMM \
1080 ENABLE_MPMM_FCONF \
Abdul Halim, Muhammad Hadi Asyrafi1f1c0202020-06-29 12:15:27 +08001081 SIMICS_BUILD \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001082 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001083 TRNG_SUPPORT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001084 CONDITIONAL_CMO \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001085)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001086
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001087$(eval $(call assert_numerics,\
1088 $(sort \
1089 ARM_ARCH_MAJOR \
1090 ARM_ARCH_MINOR \
1091 BRANCH_PROTECTION \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001092 CTX_INCLUDE_PAUTH_REGS \
1093 CTX_INCLUDE_MTE_REGS \
1094 CTX_INCLUDE_NEVE_REGS \
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +01001095 CRYPTO_SUPPORT \
Jayanth Dodderi Chidanand1298f2f2022-05-09 12:33:03 +01001096 ENABLE_BRBE_FOR_NS \
Jayanth Dodderi Chidanand47c681b2022-05-19 14:08:28 +01001097 ENABLE_TRBE_FOR_NS \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001098 ENABLE_BTI \
1099 ENABLE_PAUTH \
1100 ENABLE_FEAT_AMUv1 \
1101 ENABLE_FEAT_AMUv1p1 \
1102 ENABLE_FEAT_CSV2_2 \
1103 ENABLE_FEAT_DIT \
1104 ENABLE_FEAT_ECV \
1105 ENABLE_FEAT_FGT \
1106 ENABLE_FEAT_HCX \
1107 ENABLE_FEAT_PAN \
1108 ENABLE_FEAT_RNG \
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -04001109 ENABLE_FEAT_RNG_TRAP \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001110 ENABLE_FEAT_SB \
1111 ENABLE_FEAT_SEL2 \
1112 ENABLE_FEAT_VHE \
1113 ENABLE_MPAM_FOR_LOWER_ELS \
1114 ENABLE_RME \
1115 ENABLE_TRF_FOR_NS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001116 FW_ENC_STATUS \
Manish V Badarkhe5357f832021-03-16 10:01:27 +00001117 NR_OF_FW_BANKS \
1118 NR_OF_IMAGES_IN_FW_BANK \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001119 RAS_EXTENSION \
Jayanth Dodderi Chidanand781d07a2022-03-28 15:28:55 +01001120 TWED_DELAY \
1121 ENABLE_FEAT_TWED \
Mark Brownbebcf272022-04-20 18:14:32 +01001122 SVE_VECTOR_LEN \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001123)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001124
Justin Chadwellaacff742019-07-29 17:13:10 +01001125ifdef KEY_SIZE
1126 $(eval $(call assert_numeric,KEY_SIZE))
1127endif
1128
Justin Chadwell1f461972019-08-20 11:01:52 +01001129ifeq ($(filter $(SANITIZE_UB), on off trap),)
1130 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1131endif
1132
Juan Castillo73c99d42015-08-18 14:23:04 +01001133################################################################################
1134# Add definitions to the cpp preprocessor based on the current build options.
1135# This is done after including the platform specific makefile to allow the
1136# platform to overwrite the default options
1137################################################################################
1138
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001139$(eval $(call add_defines,\
1140 $(sort \
1141 ALLOW_RO_XLAT_TABLES \
1142 ARM_ARCH_MAJOR \
1143 ARM_ARCH_MINOR \
Balint Dobszay46789a72021-03-26 16:23:18 +01001144 BL2_ENABLE_SP_LOAD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001145 COLD_BOOT_SINGLE_CPU \
1146 CTX_INCLUDE_AARCH32_REGS \
1147 CTX_INCLUDE_FPREGS \
1148 CTX_INCLUDE_PAUTH_REGS \
1149 EL3_EXCEPTION_HANDLING \
1150 CTX_INCLUDE_MTE_REGS \
1151 CTX_INCLUDE_EL2_REGS \
Arunachalam Ganapathy062f8aa2020-05-28 11:57:09 +01001152 CTX_INCLUDE_NEVE_REGS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001153 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
Javier Almansa Sobrino0063dd12020-11-23 18:38:15 +00001154 DISABLE_MTPMU \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001155 ENABLE_AMU \
Chris Kay1fd685a2021-05-25 10:42:56 +01001156 ENABLE_AMU_AUXILIARY_COUNTERS \
Chris Kay742ca232021-08-19 11:21:52 +01001157 ENABLE_AMU_FCONF \
johpow01873d4242020-10-02 13:41:11 -05001158 AMU_RESTRICT_COUNTERS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001159 ENABLE_ASSERTIONS \
1160 ENABLE_BTI \
1161 ENABLE_MPAM_FOR_LOWER_ELS \
1162 ENABLE_PAUTH \
1163 ENABLE_PIE \
1164 ENABLE_PMF \
1165 ENABLE_PSCI_STAT \
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001166 ENABLE_RME \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001167 ENABLE_RUNTIME_INSTRUMENTATION \
johpow01dc78e622021-07-08 14:14:00 -05001168 ENABLE_SME_FOR_NS \
1169 ENABLE_SME_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001170 ENABLE_SPE_FOR_LOWER_ELS \
1171 ENABLE_SVE_FOR_NS \
Max Shvetsov0c5e7d12021-03-22 11:59:37 +00001172 ENABLE_SVE_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001173 ENCRYPT_BL31 \
1174 ENCRYPT_BL32 \
1175 ERROR_DEPRECATED \
1176 FAULT_INJECTION_SUPPORT \
1177 GICV2_G0_FOR_EL3 \
Manish Pandey46cc41d2022-10-10 11:43:08 +01001178 HANDLE_EA_EL3_FIRST_NS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001179 HW_ASSISTED_COHERENCY \
1180 LOG_LEVEL \
1181 MEASURED_BOOT \
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001182 DRTM_SUPPORT \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001183 NS_TIMER_SWITCH \
1184 PL011_GENERIC_UART \
1185 PLAT_${PLAT} \
Tamas Ban0ce20722022-01-18 16:20:47 +01001186 PLAT_RSS_NOT_SUPPORTED \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001187 PROGRAMMABLE_RESET_ADDRESS \
1188 PSCI_EXTENDED_STATE_ID \
1189 RAS_EXTENSION \
1190 RESET_TO_BL31 \
Jorge Ramirez-Ortiz25844ff2022-04-15 11:46:47 +02001191 RESET_TO_BL31_WITH_PARAMS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001192 SEPARATE_CODE_AND_RODATA \
Jiafei Pan96a8ed12022-02-24 10:47:33 +08001193 SEPARATE_BL2_NOLOAD_REGION \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001194 SEPARATE_NOBITS_REGION \
1195 RECLAIM_INIT_CODE \
1196 SPD_${SPD} \
1197 SPIN_ON_BL1_EXIT \
1198 SPM_MM \
Marc Bonnici1d63ae42021-12-01 18:00:40 +00001199 SPMC_AT_EL3 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001200 SPMD_SPM_AT_SEL2 \
1201 TRUSTED_BOARD_BOOT \
Manish V Badarkhec9c56f62022-01-08 22:56:06 +00001202 CRYPTO_SUPPORT \
Jimmy Brisson7dfb9912020-06-22 14:18:42 -05001203 TRNG_SUPPORT \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001204 USE_COHERENT_MEM \
1205 USE_DEBUGFS \
1206 ARM_IO_IN_DTB \
1207 SDEI_IN_FCONF \
1208 SEC_INT_DESC_IN_FCONF \
1209 USE_ROMLIB \
1210 USE_TBBR_DEFS \
1211 WARMBOOT_ENABLE_DCACHE_EARLY \
1212 BL2_AT_EL3 \
1213 BL2_IN_XIP_MEM \
1214 BL2_INV_DCACHE \
1215 USE_SPINLOCK_CAS \
1216 ERRATA_SPECULATIVE_AT \
Manish Pandey00e8f792022-09-27 14:30:34 +01001217 RAS_TRAP_NS_ERR_REC_ACCESS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001218 COT_DESC_IN_DTB \
1219 USE_SP804_TIMER \
Tomas Pilar12cd65e2020-10-29 13:01:16 +00001220 ENABLE_FEAT_RNG \
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -04001221 ENABLE_FEAT_RNG_TRAP \
Chris Kay4e044782021-03-09 13:34:35 +00001222 ENABLE_FEAT_SB \
Daniel Boulby7d33ffe2021-05-25 18:09:34 +01001223 ENABLE_FEAT_DIT \
Manish V Badarkhe5357f832021-03-16 10:01:27 +00001224 NR_OF_FW_BANKS \
1225 NR_OF_IMAGES_IN_FW_BANK \
Manish V Badarkhe396b3392021-06-25 23:28:59 +01001226 PSA_FWU_SUPPORT \
johpow01744ad972022-01-28 17:06:20 -06001227 ENABLE_BRBE_FOR_NS \
Manish V Badarkhe813524e2021-07-02 09:10:56 +01001228 ENABLE_TRBE_FOR_NS \
Manish V Badarkhed4582d32021-06-29 11:44:20 +01001229 ENABLE_SYS_REG_TRACE_FOR_NS \
Manish V Badarkhe8fcd3d92021-07-08 09:33:18 +01001230 ENABLE_TRF_FOR_NS \
johpow01cb4ec472021-08-04 19:38:18 -05001231 ENABLE_FEAT_HCX \
Chris Kay68120782021-05-05 13:38:30 +01001232 ENABLE_MPMM \
1233 ENABLE_MPMM_FCONF \
Jayanth Dodderi Chidanandf74cb0b2021-11-25 14:59:30 +00001234 ENABLE_FEAT_FGT \
1235 ENABLE_FEAT_AMUv1 \
1236 ENABLE_FEAT_ECV \
Abdul Halim, Muhammad Hadi Asyrafi1f1c0202020-06-29 12:15:27 +08001237 SIMICS_BUILD \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001238 ENABLE_FEAT_AMUv1p1 \
1239 ENABLE_FEAT_SEL2 \
1240 ENABLE_FEAT_VHE \
1241 ENABLE_FEAT_CSV2_2 \
1242 ENABLE_FEAT_PAN \
1243 FEATURE_DETECTION \
Jayanth Dodderi Chidanand781d07a2022-03-28 15:28:55 +01001244 TWED_DELAY \
1245 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001246 CONDITIONAL_CMO \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001247)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001248
Justin Chadwell1f461972019-08-20 11:01:52 +01001249ifeq (${SANITIZE_UB},trap)
1250 $(eval $(call add_define,MONITOR_TRAPS))
1251endif
1252
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001253# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1254ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001255 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1256else
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001257 # Define the PRELOADED_BL33_BASE flag only if it is provided and
1258 # EL3_PAYLOAD_BASE is not defined, as it has priority.
1259 ifdef PRELOADED_BL33_BASE
1260 $(eval $(call add_define,PRELOADED_BL33_BASE))
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001261 endif
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001262endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001263
Soby Mathew209a60c2018-03-26 12:43:37 +01001264# Define the DYN_DISABLE_AUTH flag only if set.
1265ifeq (${DYN_DISABLE_AUTH},1)
1266$(eval $(call add_define,DYN_DISABLE_AUTH))
1267endif
1268
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001269ifneq ($(findstring armlink,$(notdir $(LD))),)
1270$(eval $(call add_define,USE_ARM_LINK))
1271endif
1272
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001273# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001274ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001275ifdef SP_LAYOUT_FILE
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001276 -include $(BUILD_PLAT)/sp_gen.mk
1277 FIP_DEPS += sp
Manish Pandey07c44472020-05-26 23:59:36 +01001278 CRT_DEPS += sp
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001279 NEED_SP_PKG := yes
1280else
Olivier Deprezc33ff192020-03-19 09:27:11 +01001281 ifeq (${SPMD_SPM_AT_SEL2},1)
1282 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1283 endif
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001284endif
1285endif
1286
Juan Castillo73c99d42015-08-18 14:23:04 +01001287################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001288# Build targets
1289################################################################################
1290
Sumit Garg90aa9012019-11-11 18:46:36 +05301291.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
Juan Castillo73c99d42015-08-18 14:23:04 +01001292.SUFFIXES:
1293
1294all: msg_start
1295
1296msg_start:
1297 @echo "Building ${PLAT}"
1298
Soby Mathew7a24cba2015-10-26 14:29:21 +00001299ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001300# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001301ifneq ($(findstring clang,$(notdir $(CC))),)
1302 CPPFLAGS += -Wno-error=deprecated-declarations
1303else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001304 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001305endif
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001306endif # !ERROR_DEPRECATED
Soby Mathew7a24cba2015-10-26 14:29:21 +00001307
Roberto Vargas5accce52018-05-22 16:05:42 +01001308$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas61f72a32018-05-08 10:27:10 +01001309$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001310
Juan Castillo73c99d42015-08-18 14:23:04 +01001311# Expand build macros for the different images
1312ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001313BL1_SOURCES := $(sort ${BL1_SOURCES})
1314
Zelalem Aweke434d0492021-07-11 17:25:48 -05001315$(eval $(call MAKE_BL,bl1))
Juan Castillo73c99d42015-08-18 14:23:04 +01001316endif
1317
1318ifeq (${NEED_BL2},yes)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001319ifeq (${BL2_AT_EL3}, 0)
1320FIP_BL2_ARGS := tb-fw
1321endif
1322
Chris Kayeb1acfb2021-09-28 15:44:37 +01001323BL2_SOURCES := $(sort ${BL2_SOURCES})
1324
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001325$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001326 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Juan Castillo73c99d42015-08-18 14:23:04 +01001327endif
1328
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001329ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001330$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001331endif
1332
Juan Castillo73c99d42015-08-18 14:23:04 +01001333ifeq (${NEED_BL31},yes)
1334BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001335# Sort BL31 source files to remove duplicates
1336BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301337ifneq (${DECRYPTION_SUPPORT},none)
1338$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001339 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301340else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001341$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001342 $(eval $(call MAKE_BL,bl31,soc-fw)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001343endif
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301344endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001345
Juan Castillo70d1fc52015-11-12 10:59:26 +00001346# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001347# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001348# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001349ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001350# Sort BL32 source files to remove duplicates
1351BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001352BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1353
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301354ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001355$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301356 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1357else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001358$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001359 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001360endif
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301361endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001362
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001363# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1364# needs to be built from RMM_SOURCES.
1365ifeq (${NEED_RMM},yes)
1366# Sort RMM source files to remove duplicates
1367RMM_SOURCES := $(sort ${RMM_SOURCES})
1368BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1369
1370$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1371 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1372endif
1373
Juan Castillo73c99d42015-08-18 14:23:04 +01001374# Add the BL33 image if required by the platform
1375ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001376$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Juan Castillodb6071c2015-01-13 12:21:04 +00001377endif
1378
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001379ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001380$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001381 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001382endif
1383
Nishanth Menon03b397a2016-10-14 01:13:57 +00001384# Expand build macros for the different images
1385ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001386 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Nishanth Menon03b397a2016-10-14 01:13:57 +00001387endif
1388
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001389# Add Secure Partition packages
1390ifeq (${NEED_SP_PKG},yes)
1391$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
Ruari Phipps1e7528e2020-07-24 16:20:57 +01001392 ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
J-Alves822c7272022-03-22 16:28:51 +00001393sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001394 @${ECHO_BLANK_LINE}
1395 @echo "Built SP Images successfully"
1396 @${ECHO_BLANK_LINE}
1397endif
1398
Ian Spray36eaaf32014-01-30 17:25:28 +00001399locate-checkpatch:
1400ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001401 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001402else
1403ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001404 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001405endif
1406endif
1407
Achin Gupta4f6ad662013-10-25 09:08:21 +01001408clean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001409 @echo " CLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001410 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001411ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001412 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001413else
1414# Clear the MAKEFLAGS as we do not want
1415# to pass the gnumake flags to nmake.
1416 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1417endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001418 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Garg90aa9012019-11-11 18:46:36 +05301419 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargas5accce52018-05-22 16:05:42 +01001420 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001421
James Morrisseyeaaeece2013-11-01 13:56:59 +00001422realclean distclean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001423 @echo " REALCLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001424 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1425 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001426ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001427 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001428else
1429# Clear the MAKEFLAGS as we do not want
1430# to pass the gnumake flags to nmake.
1431 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1432endif
Nicolas Boulengueze15591a2021-03-31 12:22:45 +02001433 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Garg90aa9012019-11-11 18:46:36 +05301434 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargas5accce52018-05-22 16:05:42 +01001435 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001436
Ian Spray36eaaf32014-01-30 17:25:28 +00001437checkcodebase: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001438 @echo " CHECKING STYLE"
Dan Handley1a41e8c2016-06-02 18:21:02 +01001439 @if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001440 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001441 while read GIT_FILE ; \
1442 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1443 done ; \
1444 else \
1445 find . -type f -not -iwholename "*.git*" \
1446 -not -iwholename "*build*" \
1447 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001448 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001449 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001450 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001451 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1452 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001453
1454checkpatch: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001455 @echo " CHECKING STYLE"
Yann Gautier02a76d52019-03-08 15:44:00 +01001456 @if test -n "${CHECKPATCH_OPTS}"; then \
1457 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1458 fi
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001459 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001460 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1461 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001462 printf "\n[*] Checking style of '$$commit'\n\n"; \
1463 git log --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001464 -- ${CHECK_PATHS} | \
1465 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001466 git diff --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001467 -- ${CHECK_PATHS} | \
1468 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001469 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001470
1471certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001472
Pali Rohára9812202020-11-24 15:38:08 +01001473${CRTTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001474 ${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
Evan Lloydf1477d42015-12-02 18:33:55 +00001475 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001476 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001477 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001478
1479ifneq (${GENERATE_COT},0)
1480certificates: ${CRT_DEPS} ${CRTTOOL}
1481 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloydf1477d42015-12-02 18:33:55 +00001482 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001483 @echo "Built $@ successfully"
1484 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloydf1477d42015-12-02 18:33:55 +00001485 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001486endif
1487
1488${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001489 $(eval ${CHECK_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001490 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1491 ${Q}${FIPTOOL} info $@
Evan Lloydf1477d42015-12-02 18:33:55 +00001492 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001493 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001494 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001495
Yatharth Kochar01912622015-10-12 12:33:47 +01001496ifneq (${GENERATE_COT},0)
1497fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1498 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd052ab522017-04-11 16:52:00 +01001499 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001500 @echo "Built $@ successfully"
1501 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd052ab522017-04-11 16:52:00 +01001502 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001503endif
1504
1505${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001506 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001507 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1508 ${Q}${FIPTOOL} info $@
Evan Lloyd052ab522017-04-11 16:52:00 +01001509 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001510 @echo "Built $@ successfully"
Evan Lloyd052ab522017-04-11 16:52:00 +01001511 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001512
Juan Castillo73c99d42015-08-18 14:23:04 +01001513fiptool: ${FIPTOOL}
1514fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001515fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001516
Pali Rohára9812202020-11-24 15:38:08 +01001517${FIPTOOL}: FORCE
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001518ifdef UNIX_MK
Lionel Debieve598b1662022-11-14 11:05:09 +01001519 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001520else
1521# Clear the MAKEFLAGS as we do not want
1522# to pass the gnumake flags to nmake.
1523 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1524endif
Harry Liebelf58ad362014-01-10 18:00:33 +00001525
Pali Rohára9812202020-11-24 15:38:08 +01001526romlib.bin: libraries FORCE
John Tsichritzisbbb24f62019-05-21 15:47:37 +01001527 ${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
Roberto Vargas5accce52018-05-22 16:05:42 +01001528
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001529# Call print_memory_map tool
1530memmap: all
Louis Mayencourtb890b362020-02-13 08:21:34 +00001531 ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001532
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001533doc:
1534 @echo " BUILD DOCUMENTATION"
1535 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1536
Sumit Garg90aa9012019-11-11 18:46:36 +05301537enctool: ${ENCTOOL}
1538
Pali Rohára9812202020-11-24 15:38:08 +01001539${ENCTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001540 ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
Sumit Garg90aa9012019-11-11 18:46:36 +05301541 @${ECHO_BLANK_LINE}
1542 @echo "Built $@ successfully"
1543 @${ECHO_BLANK_LINE}
1544
Joakim Bech35fab8c2014-01-23 14:51:49 +01001545cscope:
1546 @echo " CSCOPE"
1547 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1548 ${Q}cscope -b -q -k
1549
Ryan Harkin72ee3312014-01-15 16:55:07 +00001550help:
John Tsichritzis7c231262019-05-21 15:57:31 +01001551 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001552 @echo ""
1553 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +00001554 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001555 @echo ""
John Tsichritzis7c231262019-05-21 15:57:31 +01001556 @echo "platform = ${PLATFORM_LIST}"
1557 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001558 @echo "Please refer to the User Guide for a list of all supported options."
1559 @echo "Note that the build system doesn't track dependencies for build "
1560 @echo "options. Therefore, if any of the build options are changed "
1561 @echo "from a previous build, a clean build must be performed."
1562 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001563 @echo "Supported Targets:"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001564 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001565 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001566 @echo " bl2 Build the BL2 binary"
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001567 @echo " bl2u Build the BL2U binary"
Juan Castillod1786372015-12-14 09:35:25 +00001568 @echo " bl31 Build the BL31 binary"
Soby Mathew9d29c222016-05-05 14:33:33 +01001569 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1570 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castillo73c99d42015-08-18 14:23:04 +01001571 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001572 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochar01912622015-10-12 12:33:47 +01001573 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001574 @echo " checkcodebase Check the coding style of the entire source tree"
1575 @echo " checkpatch Check the coding style on changes in the current"
1576 @echo " branch against BASE_COMMIT (default origin/master)"
1577 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001578 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001579 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo6f971622014-10-21 11:30:42 +01001580 @echo " certtool Build the Certificate generation tool"
Sumit Garg90aa9012019-11-11 18:46:36 +05301581 @echo " enctool Build the Firmware encryption tool"
Andreas Färber59dead22016-10-10 05:18:49 +02001582 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001583 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaz26010da2018-11-27 14:58:04 +00001584 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathew38c14d82017-12-14 17:44:56 +00001585 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001586 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001587 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001588 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001589 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001590 @echo ""
1591 @echo "example: build all targets for the FVP platform:"
1592 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001593
1594.PHONY: FORCE
1595FORCE:;