blob: 3aa8bb8721504dfbd4ffd77930038d534a7ed1e3 [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
Okash Khawaja70771072023-07-13 16:28:05 +010012VERSION_PATCH := 7
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
Marco Felsch1fdc9792022-11-09 12:59:09 +0100420TF_LDFLAGS += -z noexecstack
421
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100422# LD = armlink
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800423ifneq ($(findstring armlink,$(notdir $(LD))),)
424TF_LDFLAGS += --diag_error=warning --lto_level=O1
425TF_LDFLAGS += --remove --info=unused,unusedsymbols
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600426TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100427
428# LD = gcc (used when GCC LTO is enabled)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600429else ifneq ($(findstring gcc,$(notdir $(LD))),)
430# Pass ld options with Wl or Xlinker switches
431TF_LDFLAGS += -Wl,--fatal-warnings -O1
432TF_LDFLAGS += -Wl,--gc-sections
433ifeq ($(ENABLE_LTO),1)
434 ifeq (${ARCH},aarch64)
435 TF_LDFLAGS += -flto -fuse-linker-plugin
436 endif
437endif
438# GCC automatically adds fix-cortex-a53-843419 flag when used to link
439# which breaks some builds, so disable if errata fix is not explicitly enabled
440ifneq (${ERRATA_A53_843419},1)
441 TF_LDFLAGS += -mno-fix-cortex-a53-843419
442endif
443TF_LDFLAGS += -nostdlib
444TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100445
446# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800447else
Marco Felsch1fdc9792022-11-09 12:59:09 +0100448# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
449# are not loaded by a elf loader.
450TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
Yabin Cui37bee492023-01-19 20:06:04 +0000451TF_LDFLAGS += -O1
Douglas Raillardc2b88062017-06-22 14:44:48 +0100452TF_LDFLAGS += --gc-sections
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100453# ld.lld doesn't recognize the errata flags,
Yabin Cui37bee492023-01-19 20:06:04 +0000454# therefore don't add those in that case.
455# ld.lld reports section type mismatch warnings,
456# therefore don't add --fatal-warnings to it.
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100457ifeq ($(findstring ld.lld,$(notdir $(LD))),)
Yabin Cui37bee492023-01-19 20:06:04 +0000458TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600459endif
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100460endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100461
Nishanth Menon03b397a2016-10-14 01:13:57 +0000462DTC_FLAGS += -I dts -O dtb
Louis Mayencourta6de8242020-02-28 16:57:30 +0000463DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \
464 -x assembler-with-cpp $(DEFINES)
Nishanth Menon03b397a2016-10-14 01:13:57 +0000465
Juan Castillo73c99d42015-08-18 14:23:04 +0100466################################################################################
467# Common sources and include directories
468################################################################################
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000469include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
dp-armd801fbb2017-05-04 12:15:35 +0100470include lib/compiler-rt/compiler-rt.mk
Juan Castillo73c99d42015-08-18 14:23:04 +0100471
472BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100473 common/tf_log.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100474 common/${ARCH}/debug.S \
Julius Werner91b48c92018-11-27 22:10:56 -0800475 drivers/console/multi_console.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100476 lib/${ARCH}/cache_helpers.S \
477 lib/${ARCH}/misc_helpers.S \
Soby Mathew566034f2018-02-08 17:45:12 +0000478 plat/common/plat_bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100479 plat/common/plat_log_common.c \
dp-arm75311202017-03-07 11:02:47 +0000480 plat/common/${ARCH}/plat_common.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100481 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas61f72a32018-05-08 10:27:10 +0100482 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000483
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100484ifeq ($(notdir $(CC)),armclang)
485BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
486endif
487
Justin Chadwell1f461972019-08-20 11:01:52 +0100488ifeq (${SANITIZE_UB},on)
489BL_COMMON_SOURCES += plat/common/ubsan.c
490endif
491
Yann Gautier01d237c2018-06-18 16:00:23 +0200492INCLUDES += -Iinclude \
Antonio Nino Diazf5478de2018-12-17 17:20:57 +0000493 -Iinclude/arch/${ARCH} \
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +0000494 -Iinclude/lib/cpus/${ARCH} \
495 -Iinclude/lib/el3_runtime/${ARCH} \
496 ${PLAT_INCLUDES} \
497 ${SPD_INCLUDES}
498
Antonio Nino Diaz9c6d1c52018-11-19 11:48:30 +0000499include common/backtrace/backtrace.mk
500
Juan Castillo73c99d42015-08-18 14:23:04 +0100501################################################################################
502# Generic definitions
503################################################################################
504
Evan Lloyd231c1472015-12-02 18:17:37 +0000505include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
506
Grant Likely29214e92020-07-30 08:50:10 +0100507ifeq (${BUILD_BASE},)
508 BUILD_BASE := ./build
509endif
510BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
Juan Castillo73c99d42015-08-18 14:23:04 +0100511
Evan Lloyd231c1472015-12-02 18:17:37 +0000512SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
Juan Castillo73c99d42015-08-18 14:23:04 +0100513
514# Platforms providing their own TBB makefile may override this value
515INCLUDE_TBBR_MK := 1
516
517
518################################################################################
519# Include SPD Makefile if one has been specified
520################################################################################
521
522ifneq (${SPD},none)
Max Shvetsov28f39f02020-02-25 13:56:19 +0000523 ifeq (${ARCH},aarch32)
Sandrine Bailleux44a87382018-10-03 14:56:38 +0200524 $(error "Error: SPD is incompatible with AArch32.")
Max Shvetsov28f39f02020-02-25 13:56:19 +0000525 endif
526
527 ifdef EL3_PAYLOAD_BASE
Sandrine Bailleux4c117f62015-11-26 16:31:34 +0000528 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
529 $(warning "The SPD and its BL32 companion will be present but ignored.")
Max Shvetsov28f39f02020-02-25 13:56:19 +0000530 endif
Achin Guptac3fb00d2019-10-11 15:50:43 +0100531
Max Shvetsov28f39f02020-02-25 13:56:19 +0000532 ifeq (${SPD},spmd)
533 # SPMD is located in std_svc directory
534 SPD_DIR := std_svc
Achin Guptac3fb00d2019-10-11 15:50:43 +0100535
Max Shvetsov033039f2020-02-25 13:55:00 +0000536 ifeq ($(SPMD_SPM_AT_SEL2),1)
537 ifeq ($(CTX_INCLUDE_EL2_REGS),0)
538 $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
539 endif
Marc Bonnici1d63ae42021-12-01 18:00:40 +0000540 ifeq ($(SPMC_AT_EL3),1)
541 $(error SPM cannot be enabled in both S-EL2 and EL3.)
542 endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100543 endif
Olivier Deprezdb1ef412020-04-01 21:28:26 +0200544
545 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
546 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
547 endif
Davidson Kca932482021-03-10 12:07:15 +0530548
549 ifeq ($(TS_SP_FW_CONFIG),1)
550 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
551 endif
Balint Dobszay33993a32021-03-26 15:19:11 +0100552
553 ifneq ($(ARM_BL2_SP_LIST_DTS),)
554 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
555 endif
Balint Dobszay46789a72021-03-26 16:23:18 +0100556
557 ifneq ($(SP_LAYOUT_FILE),)
558 BL2_ENABLE_SP_LOAD := 1
559 endif
Max Shvetsov28f39f02020-02-25 13:56:19 +0000560 else
561 # All other SPDs in spd directory
562 SPD_DIR := spd
563 endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100564
Max Shvetsov28f39f02020-02-25 13:56:19 +0000565 # We expect to locate an spd.mk under the specified SPD directory
566 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
567
568 ifeq (${SPD_MAKE},)
569 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
570 endif
571 $(info Including ${SPD_MAKE})
572 include ${SPD_MAKE}
573
574 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
575 # Makefile would set NEED_BL32 to "yes". In this case, the build system
576 # supports two mutually exclusive options:
577 # * BL32 is built from source: then BL32_SOURCES must contain the list
578 # of source files to build BL32
579 # * BL32 is a prebuilt binary: then BL32 must point to the image file
580 # that will be included in the FIP
581 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
582 # over the sources.
Jeenu Viswambharane35c4042014-05-15 14:40:58 +0100583endif
584
Douglas Raillard51faada2017-02-24 18:14:15 +0000585################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500586# Include rmmd Makefile if RME is enabled
587################################################################################
588
589ifneq (${ENABLE_RME},0)
590ifneq (${ARCH},aarch64)
591 $(error ENABLE_RME requires AArch64)
592endif
Marc Bonnici1d63ae42021-12-01 18:00:40 +0000593ifeq ($(SPMC_AT_EL3),1)
594 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
595endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500596include services/std_svc/rmmd/rmmd.mk
597$(warning "RME is an experimental feature")
598endif
599
600################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100601# Include the platform specific Makefile after the SPD Makefile (the platform
602# makefile may use all previous definitions in this file)
603################################################################################
Jeenu Viswambharan2da8d8b2014-05-12 15:28:47 +0100604
Juan Castillo73c99d42015-08-18 14:23:04 +0100605include ${PLAT_MAKEFILE_FULL}
Juan Castillo0f21c542014-06-25 17:26:36 +0100606
Masahiro Yamada8012cc52017-11-04 03:12:28 +0900607$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
608
Etienne Carriere26e63c42017-11-08 13:48:40 +0100609ifeq (${ARM_ARCH_MAJOR},7)
610include make_helpers/armv7-a-cpus.mk
611endif
612
Masahiro Yamada320920c2020-01-17 13:44:37 +0900613PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
614ifneq ($(PIE_FOUND),)
615 TF_CFLAGS += -fno-PIE
Samuel Holland7b592412022-04-08 21:56:02 -0500616ifneq ($(findstring gcc,$(notdir $(LD))),)
617 TF_LDFLAGS += -no-pie
618endif
Masahiro Yamada320920c2020-01-17 13:44:37 +0900619endif
620
621ifneq ($(findstring gcc,$(notdir $(LD))),)
622 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew3bd17c02018-08-28 11:13:55 +0100623else
Masahiro Yamada320920c2020-01-17 13:44:37 +0900624 PIE_LDFLAGS += -pie --no-dynamic-linker
625endif
626
627ifeq ($(ENABLE_PIE),1)
Masahiro Yamada69af7fc2020-01-17 13:45:02 +0900628ifeq ($(BL2_AT_EL3),1)
629ifneq ($(BL2_IN_XIP_MEM),1)
630 BL2_CFLAGS += -fpie
631 BL2_LDFLAGS += $(PIE_LDFLAGS)
632endif
633endif
Masahiro Yamada320920c2020-01-17 13:44:37 +0900634 BL31_CFLAGS += -fpie
635 BL31_LDFLAGS += $(PIE_LDFLAGS)
Masahiro Yamadad9743012020-01-17 13:45:14 +0900636 BL32_CFLAGS += -fpie
637 BL32_LDFLAGS += $(PIE_LDFLAGS)
638endif
Soby Mathew3bd17c02018-08-28 11:13:55 +0100639
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900640ifeq (${ARCH},aarch64)
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900641BL1_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900642ifeq ($(BL2_AT_EL3),1)
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900643BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900644else
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900645BL2_CPPFLAGS += -DIMAGE_AT_EL1
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900646endif
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900647BL2U_CPPFLAGS += -DIMAGE_AT_EL1
648BL31_CPPFLAGS += -DIMAGE_AT_EL3
649BL32_CPPFLAGS += -DIMAGE_AT_EL1
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900650endif
651
Sandrine Bailleux54035fc2016-01-13 14:57:38 +0000652# Include the CPU specific operations makefile, which provides default
653# values for all CPU errata workarounds and CPU specific optimisations.
654# This can be overridden by the platform.
Juan Castillo73c99d42015-08-18 14:23:04 +0100655include lib/cpus/cpu-ops.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100656
dp-arma4409002017-02-15 11:07:55 +0000657ifeq (${ARCH},aarch32)
658NEED_BL32 := yes
659
660################################################################################
661# Build `AARCH32_SP` as BL32 image for AArch32
662################################################################################
663ifneq (${AARCH32_SP},none)
664# We expect to locate an sp.mk under the specified AARCH32_SP directory
665AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
666
667ifeq (${AARCH32_SP_MAKE},)
668 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
669endif
670
671$(info Including ${AARCH32_SP_MAKE})
672include ${AARCH32_SP_MAKE}
673endif
674
675endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100676
Juan Castillo73c99d42015-08-18 14:23:04 +0100677################################################################################
Varun Wadekar77f1f7a2019-01-31 09:22:30 -0800678# Include libc if not overridden
679################################################################################
680ifeq (${OVERRIDE_LIBC},0)
681include lib/libc/libc.mk
682endif
683
684################################################################################
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000685# Check incompatible options
686################################################################################
687
688ifdef EL3_PAYLOAD_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100689 ifdef PRELOADED_BL33_BASE
690 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
691 incompatible build options. EL3_PAYLOAD_BASE has priority.")
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000692 endif
Qixiang Xu76580f32017-08-24 11:03:23 +0800693 ifneq (${GENERATE_COT},0)
694 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
695 endif
696 ifneq (${TRUSTED_BOARD_BOOT},0)
697 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
698 endif
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000699endif
700
701ifeq (${NEED_BL33},yes)
702 ifdef EL3_PAYLOAD_BASE
703 $(warning "BL33 image is not needed when option \
704 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
705 endif
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100706 ifdef PRELOADED_BL33_BASE
707 $(warning "BL33 image is not needed when option \
708 PRELOADED_BL33_BASE is used and won't be added to the FIP \
709 file.")
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000710 endif
711endif
712
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000713# When building for systems with hardware-assisted coherency, there's no need to
714# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
715ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
716$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
717endif
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +0100718
Jiafei Pan7d173fc2018-03-21 07:20:09 +0000719#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
720ifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
721$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
722endif
723
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100724# For RAS_EXTENSION, require that EAs are handled in EL3 first
725ifeq ($(RAS_EXTENSION),1)
Manish Pandey46cc41d2022-10-10 11:43:08 +0100726 ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
727 $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1)
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100728 endif
729endif
730
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000731# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
732ifeq ($(FAULT_INJECTION_SUPPORT),1)
733 ifneq ($(RAS_EXTENSION),1)
734 $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
735 endif
736endif
737
Roberto Vargased51b512018-09-24 17:20:48 +0100738# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew209a60c2018-03-26 12:43:37 +0100739ifeq ($(DYN_DISABLE_AUTH), 1)
740 ifeq (${TRUSTED_BOARD_BOOT}, 0)
741 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
742 endif
Soby Mathew209a60c2018-03-26 12:43:37 +0100743endif
744
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100745ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
746# Support authentication verification and hash calculation
747 CRYPTO_SUPPORT := 3
748else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
749# Support authentication verification and hash calculation
750 CRYPTO_SUPPORT := 3
751else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
752# Support hash calculation only
753 CRYPTO_SUPPORT := 2
754else ifeq (${TRUSTED_BOARD_BOOT},1)
755# Support authentication verification only
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000756 CRYPTO_SUPPORT := 1
757else
758 CRYPTO_SUPPORT := 0
759endif
760
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100761# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
762ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Manish Pandey700e7682021-10-21 21:53:49 +0100763$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhe84ef9cd2020-06-29 10:32:53 +0100764endif
765
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000766# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100767# registers associated to it are also saved and restored.
768# 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 +0000769ifeq ($(ENABLE_PAUTH),1)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100770 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
771 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
772 endif
773endif
774
775ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
776 ifneq (${ARCH},aarch64)
777 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
Alexei Fedorov06715f82019-03-13 11:05:07 +0000778 endif
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100779endif
780
Justin Chadwell9dd94382019-07-18 14:25:33 +0100781ifeq ($(CTX_INCLUDE_MTE_REGS),1)
782 ifneq (${ARCH},aarch64)
783 $(error CTX_INCLUDE_MTE_REGS requires AArch64)
Justin Chadwell9dd94382019-07-18 14:25:33 +0100784 endif
785endif
786
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100787ifeq ($(PSA_FWU_SUPPORT),1)
788 $(info PSA_FWU_SUPPORT is an experimental feature)
789endif
790
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000791ifeq ($(FEATURE_DETECTION),1)
792 $(info FEATURE_DETECTION is an experimental feature)
793endif
794
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000795ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
796 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
797 $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
798 endif
799endif
800
Sumit Garg7cda17b2019-11-15 10:43:00 +0530801ifneq (${DECRYPTION_SUPPORT},none)
802 ifeq (${TRUSTED_BOARD_BOOT}, 0)
803 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
Sumit Garg7cda17b2019-11-15 10:43:00 +0530804 endif
805endif
806
johpow01744ad972022-01-28 17:06:20 -0600807# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow01dc78e622021-07-08 14:14:00 -0500808ifeq (${ARCH},aarch32)
johpow01744ad972022-01-28 17:06:20 -0600809
810 # SME/SVE only supported on AArch64
johpow01dc78e622021-07-08 14:14:00 -0500811 ifeq (${ENABLE_SME_FOR_NS},1)
812 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
813 endif
814 ifeq (${ENABLE_SVE_FOR_NS},1)
815 # Warning instead of error due to CI dependency on this
Yann Gautier24ab2c02021-11-19 11:35:46 +0100816 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
johpow01dc78e622021-07-08 14:14:00 -0500817 endif
johpow01744ad972022-01-28 17:06:20 -0600818
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -0400819 # BRBE is not supported in AArch32
johpow01744ad972022-01-28 17:06:20 -0600820 ifeq (${ENABLE_BRBE_FOR_NS},1)
821 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
822 endif
823
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -0400824 # FEAT_RNG_TRAP is not supported in AArch32
825 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
826 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
827 endif
johpow01dc78e622021-07-08 14:14:00 -0500828endif
829
830# Ensure ENABLE_RME is not used with SME
831ifeq (${ENABLE_RME},1)
832 ifeq (${ENABLE_SME_FOR_NS},1)
833 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
834 endif
835endif
836
837# Secure SME/SVE requires the non-secure component as well
838ifeq (${ENABLE_SME_FOR_SWD},1)
839 ifeq (${ENABLE_SME_FOR_NS},0)
840 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
841 endif
842endif
843ifeq (${ENABLE_SVE_FOR_SWD},1)
844 ifeq (${ENABLE_SVE_FOR_NS},0)
845 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
846 endif
847endif
848
849# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
850# its own context management including FPU registers.
851ifeq (${CTX_INCLUDE_FPREGS},1)
852 ifeq (${ENABLE_SME_FOR_NS},1)
853 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
854 endif
855 ifeq (${ENABLE_SVE_FOR_NS},1)
856 # Warning instead of error due to CI dependency on this
857 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
858 $(warning "Forced ENABLE_SVE_FOR_NS=0")
859 override ENABLE_SVE_FOR_NS := 0
860 endif
861endif
862
Manish V Badarkhe00e28872022-03-02 12:06:35 +0000863ifeq ($(DRTM_SUPPORT),1)
864 $(info DRTM_SUPPORT is an experimental feature)
865endif
866
Chris Kay274a69e2022-09-29 16:21:24 +0100867ifeq (${ENABLE_RME},1)
868 ifneq (${SEPARATE_CODE_AND_RODATA},1)
869 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
870 endif
871endif
872
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000873################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100874# Process platform overrideable behaviour
875################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +0100876
Manish Pandey5f24ce92021-10-06 10:59:52 +0100877ifdef BL1_SOURCES
878NEED_BL1 := yes
879endif
880
Juan Castillo73c99d42015-08-18 14:23:04 +0100881ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +0100882 NEED_BL2 := yes
883
884 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
885 # Certificate generation tools. This flag can be overridden by the platform.
886 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000887 # If booting an EL3 payload there is no need for a BL33 image
888 # in the FIP file.
889 NEED_BL33 := no
890 else
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100891 ifdef PRELOADED_BL33_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000892 # If booting a BL33 preloaded image there is no need of
893 # another one in the FIP file.
894 NEED_BL33 := no
895 else
896 NEED_BL33 ?= yes
897 endif
898 endif
Juan Castillo73c99d42015-08-18 14:23:04 +0100899endif
900
Manish Pandey5f24ce92021-10-06 10:59:52 +0100901ifdef BL2U_SOURCES
902NEED_BL2U := yes
903endif
904
Masahiro Yamada4d045d02017-04-05 19:11:41 +0900905# If SCP_BL2 is given, we always want FIP to include it.
906ifdef SCP_BL2
907 NEED_SCP_BL2 := yes
908endif
909
Soby Mathew5744e872017-11-14 14:10:10 +0000910# For AArch32, BL31 is not currently supported.
911ifneq (${ARCH},aarch32)
912 ifdef BL31_SOURCES
913 # When booting an EL3 payload, there is no need to compile the BL31 image nor
914 # put it in the FIP.
915 ifndef EL3_PAYLOAD_BASE
916 NEED_BL31 := yes
917 endif
918 endif
919endif
920
Juan Castillo73c99d42015-08-18 14:23:04 +0100921# Process TBB related flags
922ifneq (${GENERATE_COT},0)
923 # Common cert_create options
924 ifneq (${CREATE_KEYS},0)
925 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +0100926 $(eval FWU_CRT_ARGS += -n)
Juan Castillo73c99d42015-08-18 14:23:04 +0100927 ifneq (${SAVE_KEYS},0)
928 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +0100929 $(eval FWU_CRT_ARGS += -k)
Juan Castillo73c99d42015-08-18 14:23:04 +0100930 endif
931 endif
932 # Include TBBR makefile (unless the platform indicates otherwise)
933 ifeq (${INCLUDE_TBBR_MK},1)
934 include make_helpers/tbbr/tbbr_tools.mk
935 endif
936endif
937
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +0900938ifneq (${FIP_ALIGN},0)
939FIP_ARGS += --align ${FIP_ALIGN}
940endif
941
Manish Pandey5f24ce92021-10-06 10:59:52 +0100942ifdef FDT_SOURCES
943NEED_FDT := yes
944endif
945
Juan Castillo73c99d42015-08-18 14:23:04 +0100946################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +0800947# Include libraries' Makefile that are used in all BL
948################################################################################
949
950include lib/stack_protector/stack_protector.mk
951
952################################################################################
dp-arm819281e2016-05-25 16:20:20 +0100953# Auxiliary tools (fiptool, cert_create, etc)
Juan Castillo73c99d42015-08-18 14:23:04 +0100954################################################################################
Harry Liebelf58ad362014-01-10 18:00:33 +0000955
Juan Castillo6f971622014-10-21 11:30:42 +0100956# Variables for use with Certificate Generation Tool
957CRTTOOLPATH ?= tools/cert_create
Evan Lloyd42a45b52015-12-03 11:35:40 +0000958CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
Juan Castillo6f971622014-10-21 11:30:42 +0100959
Sumit Garg90aa9012019-11-11 18:46:36 +0530960# Variables for use with Firmware Encryption Tool
961ENCTOOLPATH ?= tools/encrypt_fw
962ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
963
Juan Castillo73c99d42015-08-18 14:23:04 +0100964# Variables for use with Firmware Image Package
dp-arm819281e2016-05-25 16:20:20 +0100965FIPTOOLPATH ?= tools/fiptool
966FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
Juan Castillo6f971622014-10-21 11:30:42 +0100967
Antonio Nino Diaz26010da2018-11-27 14:58:04 +0000968# Variables for use with sptool
969SPTOOLPATH ?= tools/sptool
J-Alves822c7272022-03-22 16:28:51 +0000970SPTOOL ?= ${SPTOOLPATH}/sptool.py
Manish Pandeyce2b1ec2020-01-14 11:52:05 +0000971SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Antonio Nino Diaz26010da2018-11-27 14:58:04 +0000972
Roberto Vargas5accce52018-05-22 16:05:42 +0100973# Variables for use with ROMLIB
974ROMLIBPATH ?= lib/romlib
975
Louis Mayencourtcfe83912019-10-16 14:30:51 +0100976# Variable for use with Python
977PYTHON ?= python3
978
979# Variables for use with PRINT_MEMORY_MAP
980PRINT_MEMORY_MAP_PATH ?= tools/memory
981PRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
982
Madhukar Pappireddy6de32372020-01-28 12:41:20 -0600983# Variables for use with documentation build using Sphinx tool
984DOCS_PATH ?= docs
985
Abdul Halim, Muhammad Hadi Asyrafi1f1c0202020-06-29 12:15:27 +0800986# Defination of SIMICS flag
987SIMICS_BUILD ?= 0
988
Soby Mathew8a860522017-02-14 10:05:07 +0000989################################################################################
990# Include BL specific makefiles
991################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +0100992
993ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +0000994include bl1/bl1.mk
995endif
996
Manish Pandey5f24ce92021-10-06 10:59:52 +0100997ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +0000998include bl2/bl2.mk
999endif
1000
Manish Pandey5f24ce92021-10-06 10:59:52 +01001001ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001002include bl2u/bl2u.mk
1003endif
1004
Soby Mathew5744e872017-11-14 14:10:10 +00001005ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001006include bl31/bl31.mk
1007endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001008
Juan Castillo73c99d42015-08-18 14:23:04 +01001009################################################################################
1010# Build options checks
1011################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001012
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001013$(eval $(call assert_booleans,\
1014 $(sort \
1015 ALLOW_RO_XLAT_TABLES \
Balint Dobszay46789a72021-03-26 16:23:18 +01001016 BL2_ENABLE_SP_LOAD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001017 COLD_BOOT_SINGLE_CPU \
1018 CREATE_KEYS \
1019 CTX_INCLUDE_AARCH32_REGS \
1020 CTX_INCLUDE_FPREGS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001021 CTX_INCLUDE_EL2_REGS \
1022 DEBUG \
Javier Almansa Sobrino0063dd12020-11-23 18:38:15 +00001023 DISABLE_MTPMU \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001024 DYN_DISABLE_AUTH \
1025 EL3_EXCEPTION_HANDLING \
1026 ENABLE_AMU \
Chris Kay1fd685a2021-05-25 10:42:56 +01001027 ENABLE_AMU_AUXILIARY_COUNTERS \
Chris Kay742ca232021-08-19 11:21:52 +01001028 ENABLE_AMU_FCONF \
johpow01873d4242020-10-02 13:41:11 -05001029 AMU_RESTRICT_COUNTERS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001030 ENABLE_ASSERTIONS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001031 ENABLE_PIE \
1032 ENABLE_PMF \
1033 ENABLE_PSCI_STAT \
1034 ENABLE_RUNTIME_INSTRUMENTATION \
johpow01dc78e622021-07-08 14:14:00 -05001035 ENABLE_SME_FOR_NS \
1036 ENABLE_SME_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001037 ENABLE_SPE_FOR_LOWER_ELS \
1038 ENABLE_SVE_FOR_NS \
Max Shvetsov0c5e7d12021-03-22 11:59:37 +00001039 ENABLE_SVE_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001040 ERROR_DEPRECATED \
1041 FAULT_INJECTION_SUPPORT \
1042 GENERATE_COT \
1043 GICV2_G0_FOR_EL3 \
Manish Pandey46cc41d2022-10-10 11:43:08 +01001044 HANDLE_EA_EL3_FIRST_NS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001045 HW_ASSISTED_COHERENCY \
1046 INVERTED_MEMMAP \
1047 MEASURED_BOOT \
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001048 DRTM_SUPPORT \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001049 NS_TIMER_SWITCH \
1050 OVERRIDE_LIBC \
1051 PL011_GENERIC_UART \
Tamas Ban0ce20722022-01-18 16:20:47 +01001052 PLAT_RSS_NOT_SUPPORTED \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001053 PROGRAMMABLE_RESET_ADDRESS \
1054 PSCI_EXTENDED_STATE_ID \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001055 RESET_TO_BL31 \
Jorge Ramirez-Ortiz25844ff2022-04-15 11:46:47 +02001056 RESET_TO_BL31_WITH_PARAMS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001057 SAVE_KEYS \
1058 SEPARATE_CODE_AND_RODATA \
Jiafei Pan96a8ed12022-02-24 10:47:33 +08001059 SEPARATE_BL2_NOLOAD_REGION \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001060 SEPARATE_NOBITS_REGION \
1061 SPIN_ON_BL1_EXIT \
1062 SPM_MM \
Marc Bonnici1d63ae42021-12-01 18:00:40 +00001063 SPMC_AT_EL3 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001064 SPMD_SPM_AT_SEL2 \
1065 TRUSTED_BOARD_BOOT \
1066 USE_COHERENT_MEM \
1067 USE_DEBUGFS \
1068 ARM_IO_IN_DTB \
1069 SDEI_IN_FCONF \
1070 SEC_INT_DESC_IN_FCONF \
1071 USE_ROMLIB \
1072 USE_TBBR_DEFS \
1073 WARMBOOT_ENABLE_DCACHE_EARLY \
1074 BL2_AT_EL3 \
1075 BL2_IN_XIP_MEM \
1076 BL2_INV_DCACHE \
1077 USE_SPINLOCK_CAS \
1078 ENCRYPT_BL31 \
1079 ENCRYPT_BL32 \
1080 ERRATA_SPECULATIVE_AT \
Manish Pandey00e8f792022-09-27 14:30:34 +01001081 RAS_TRAP_NS_ERR_REC_ACCESS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001082 COT_DESC_IN_DTB \
1083 USE_SP804_TIMER \
Manish V Badarkhe396b3392021-06-25 23:28:59 +01001084 PSA_FWU_SUPPORT \
Manish V Badarkhed4582d32021-06-29 11:44:20 +01001085 ENABLE_SYS_REG_TRACE_FOR_NS \
Chris Kay68120782021-05-05 13:38:30 +01001086 ENABLE_MPMM \
1087 ENABLE_MPMM_FCONF \
Abdul Halim, Muhammad Hadi Asyrafi1f1c0202020-06-29 12:15:27 +08001088 SIMICS_BUILD \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001089 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001090 TRNG_SUPPORT \
Sona Mathewbb9d6fa2022-11-18 18:05:38 -06001091 ERRATA_ABI_SUPPORT \
Sona Mathew4a001ff2023-03-14 14:02:03 -05001092 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001093 CONDITIONAL_CMO \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001094)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001095
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001096$(eval $(call assert_numerics,\
1097 $(sort \
1098 ARM_ARCH_MAJOR \
1099 ARM_ARCH_MINOR \
1100 BRANCH_PROTECTION \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001101 CTX_INCLUDE_PAUTH_REGS \
1102 CTX_INCLUDE_MTE_REGS \
1103 CTX_INCLUDE_NEVE_REGS \
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +01001104 CRYPTO_SUPPORT \
Jayanth Dodderi Chidanand1298f2f2022-05-09 12:33:03 +01001105 ENABLE_BRBE_FOR_NS \
Jayanth Dodderi Chidanand47c681b2022-05-19 14:08:28 +01001106 ENABLE_TRBE_FOR_NS \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001107 ENABLE_BTI \
1108 ENABLE_PAUTH \
1109 ENABLE_FEAT_AMUv1 \
1110 ENABLE_FEAT_AMUv1p1 \
1111 ENABLE_FEAT_CSV2_2 \
1112 ENABLE_FEAT_DIT \
1113 ENABLE_FEAT_ECV \
1114 ENABLE_FEAT_FGT \
1115 ENABLE_FEAT_HCX \
1116 ENABLE_FEAT_PAN \
1117 ENABLE_FEAT_RNG \
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -04001118 ENABLE_FEAT_RNG_TRAP \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001119 ENABLE_FEAT_SB \
1120 ENABLE_FEAT_SEL2 \
1121 ENABLE_FEAT_VHE \
1122 ENABLE_MPAM_FOR_LOWER_ELS \
1123 ENABLE_RME \
1124 ENABLE_TRF_FOR_NS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001125 FW_ENC_STATUS \
Manish V Badarkhe5357f832021-03-16 10:01:27 +00001126 NR_OF_FW_BANKS \
1127 NR_OF_IMAGES_IN_FW_BANK \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001128 RAS_EXTENSION \
Jayanth Dodderi Chidanand781d07a2022-03-28 15:28:55 +01001129 TWED_DELAY \
1130 ENABLE_FEAT_TWED \
Mark Brownbebcf272022-04-20 18:14:32 +01001131 SVE_VECTOR_LEN \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001132)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001133
Justin Chadwellaacff742019-07-29 17:13:10 +01001134ifdef KEY_SIZE
1135 $(eval $(call assert_numeric,KEY_SIZE))
1136endif
1137
Justin Chadwell1f461972019-08-20 11:01:52 +01001138ifeq ($(filter $(SANITIZE_UB), on off trap),)
1139 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1140endif
1141
Juan Castillo73c99d42015-08-18 14:23:04 +01001142################################################################################
1143# Add definitions to the cpp preprocessor based on the current build options.
1144# This is done after including the platform specific makefile to allow the
1145# platform to overwrite the default options
1146################################################################################
1147
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001148$(eval $(call add_defines,\
1149 $(sort \
1150 ALLOW_RO_XLAT_TABLES \
1151 ARM_ARCH_MAJOR \
1152 ARM_ARCH_MINOR \
Balint Dobszay46789a72021-03-26 16:23:18 +01001153 BL2_ENABLE_SP_LOAD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001154 COLD_BOOT_SINGLE_CPU \
1155 CTX_INCLUDE_AARCH32_REGS \
1156 CTX_INCLUDE_FPREGS \
1157 CTX_INCLUDE_PAUTH_REGS \
1158 EL3_EXCEPTION_HANDLING \
1159 CTX_INCLUDE_MTE_REGS \
1160 CTX_INCLUDE_EL2_REGS \
Arunachalam Ganapathy062f8aa2020-05-28 11:57:09 +01001161 CTX_INCLUDE_NEVE_REGS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001162 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
Javier Almansa Sobrino0063dd12020-11-23 18:38:15 +00001163 DISABLE_MTPMU \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001164 ENABLE_AMU \
Chris Kay1fd685a2021-05-25 10:42:56 +01001165 ENABLE_AMU_AUXILIARY_COUNTERS \
Chris Kay742ca232021-08-19 11:21:52 +01001166 ENABLE_AMU_FCONF \
johpow01873d4242020-10-02 13:41:11 -05001167 AMU_RESTRICT_COUNTERS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001168 ENABLE_ASSERTIONS \
1169 ENABLE_BTI \
1170 ENABLE_MPAM_FOR_LOWER_ELS \
1171 ENABLE_PAUTH \
1172 ENABLE_PIE \
1173 ENABLE_PMF \
1174 ENABLE_PSCI_STAT \
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001175 ENABLE_RME \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001176 ENABLE_RUNTIME_INSTRUMENTATION \
johpow01dc78e622021-07-08 14:14:00 -05001177 ENABLE_SME_FOR_NS \
1178 ENABLE_SME_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001179 ENABLE_SPE_FOR_LOWER_ELS \
1180 ENABLE_SVE_FOR_NS \
Max Shvetsov0c5e7d12021-03-22 11:59:37 +00001181 ENABLE_SVE_FOR_SWD \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001182 ENCRYPT_BL31 \
1183 ENCRYPT_BL32 \
1184 ERROR_DEPRECATED \
1185 FAULT_INJECTION_SUPPORT \
1186 GICV2_G0_FOR_EL3 \
Manish Pandey46cc41d2022-10-10 11:43:08 +01001187 HANDLE_EA_EL3_FIRST_NS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001188 HW_ASSISTED_COHERENCY \
1189 LOG_LEVEL \
1190 MEASURED_BOOT \
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001191 DRTM_SUPPORT \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001192 NS_TIMER_SWITCH \
1193 PL011_GENERIC_UART \
1194 PLAT_${PLAT} \
Tamas Ban0ce20722022-01-18 16:20:47 +01001195 PLAT_RSS_NOT_SUPPORTED \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001196 PROGRAMMABLE_RESET_ADDRESS \
1197 PSCI_EXTENDED_STATE_ID \
1198 RAS_EXTENSION \
1199 RESET_TO_BL31 \
Jorge Ramirez-Ortiz25844ff2022-04-15 11:46:47 +02001200 RESET_TO_BL31_WITH_PARAMS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001201 SEPARATE_CODE_AND_RODATA \
Jiafei Pan96a8ed12022-02-24 10:47:33 +08001202 SEPARATE_BL2_NOLOAD_REGION \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001203 SEPARATE_NOBITS_REGION \
1204 RECLAIM_INIT_CODE \
1205 SPD_${SPD} \
1206 SPIN_ON_BL1_EXIT \
1207 SPM_MM \
Marc Bonnici1d63ae42021-12-01 18:00:40 +00001208 SPMC_AT_EL3 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001209 SPMD_SPM_AT_SEL2 \
1210 TRUSTED_BOARD_BOOT \
Manish V Badarkhec9c56f62022-01-08 22:56:06 +00001211 CRYPTO_SUPPORT \
Jimmy Brisson7dfb9912020-06-22 14:18:42 -05001212 TRNG_SUPPORT \
Sona Mathewbb9d6fa2022-11-18 18:05:38 -06001213 ERRATA_ABI_SUPPORT \
Sona Mathew4a001ff2023-03-14 14:02:03 -05001214 ERRATA_NON_ARM_INTERCONNECT \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001215 USE_COHERENT_MEM \
1216 USE_DEBUGFS \
1217 ARM_IO_IN_DTB \
1218 SDEI_IN_FCONF \
1219 SEC_INT_DESC_IN_FCONF \
1220 USE_ROMLIB \
1221 USE_TBBR_DEFS \
1222 WARMBOOT_ENABLE_DCACHE_EARLY \
1223 BL2_AT_EL3 \
1224 BL2_IN_XIP_MEM \
1225 BL2_INV_DCACHE \
1226 USE_SPINLOCK_CAS \
1227 ERRATA_SPECULATIVE_AT \
Manish Pandey00e8f792022-09-27 14:30:34 +01001228 RAS_TRAP_NS_ERR_REC_ACCESS \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001229 COT_DESC_IN_DTB \
1230 USE_SP804_TIMER \
Tomas Pilar12cd65e2020-10-29 13:01:16 +00001231 ENABLE_FEAT_RNG \
Juan Pablo Condeff86e0b2022-07-12 16:40:29 -04001232 ENABLE_FEAT_RNG_TRAP \
Chris Kay4e044782021-03-09 13:34:35 +00001233 ENABLE_FEAT_SB \
Daniel Boulby7d33ffe2021-05-25 18:09:34 +01001234 ENABLE_FEAT_DIT \
Manish V Badarkhe5357f832021-03-16 10:01:27 +00001235 NR_OF_FW_BANKS \
1236 NR_OF_IMAGES_IN_FW_BANK \
Manish V Badarkhe396b3392021-06-25 23:28:59 +01001237 PSA_FWU_SUPPORT \
johpow01744ad972022-01-28 17:06:20 -06001238 ENABLE_BRBE_FOR_NS \
Manish V Badarkhe813524e2021-07-02 09:10:56 +01001239 ENABLE_TRBE_FOR_NS \
Manish V Badarkhed4582d32021-06-29 11:44:20 +01001240 ENABLE_SYS_REG_TRACE_FOR_NS \
Manish V Badarkhe8fcd3d92021-07-08 09:33:18 +01001241 ENABLE_TRF_FOR_NS \
johpow01cb4ec472021-08-04 19:38:18 -05001242 ENABLE_FEAT_HCX \
Chris Kay68120782021-05-05 13:38:30 +01001243 ENABLE_MPMM \
1244 ENABLE_MPMM_FCONF \
Jayanth Dodderi Chidanandf74cb0b2021-11-25 14:59:30 +00001245 ENABLE_FEAT_FGT \
1246 ENABLE_FEAT_AMUv1 \
1247 ENABLE_FEAT_ECV \
Abdul Halim, Muhammad Hadi Asyrafi1f1c0202020-06-29 12:15:27 +08001248 SIMICS_BUILD \
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +00001249 ENABLE_FEAT_AMUv1p1 \
1250 ENABLE_FEAT_SEL2 \
1251 ENABLE_FEAT_VHE \
1252 ENABLE_FEAT_CSV2_2 \
1253 ENABLE_FEAT_PAN \
1254 FEATURE_DETECTION \
Jayanth Dodderi Chidanand781d07a2022-03-28 15:28:55 +01001255 TWED_DELAY \
1256 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001257 CONDITIONAL_CMO \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001258)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001259
Justin Chadwell1f461972019-08-20 11:01:52 +01001260ifeq (${SANITIZE_UB},trap)
1261 $(eval $(call add_define,MONITOR_TRAPS))
1262endif
1263
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001264# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1265ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001266 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1267else
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001268 # Define the PRELOADED_BL33_BASE flag only if it is provided and
1269 # EL3_PAYLOAD_BASE is not defined, as it has priority.
1270 ifdef PRELOADED_BL33_BASE
1271 $(eval $(call add_define,PRELOADED_BL33_BASE))
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001272 endif
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001273endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001274
Soby Mathew209a60c2018-03-26 12:43:37 +01001275# Define the DYN_DISABLE_AUTH flag only if set.
1276ifeq (${DYN_DISABLE_AUTH},1)
1277$(eval $(call add_define,DYN_DISABLE_AUTH))
1278endif
1279
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001280ifneq ($(findstring armlink,$(notdir $(LD))),)
1281$(eval $(call add_define,USE_ARM_LINK))
1282endif
1283
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001284# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001285ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001286ifdef SP_LAYOUT_FILE
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001287 -include $(BUILD_PLAT)/sp_gen.mk
1288 FIP_DEPS += sp
Manish Pandey07c44472020-05-26 23:59:36 +01001289 CRT_DEPS += sp
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001290 NEED_SP_PKG := yes
1291else
Olivier Deprezc33ff192020-03-19 09:27:11 +01001292 ifeq (${SPMD_SPM_AT_SEL2},1)
1293 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1294 endif
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001295endif
1296endif
1297
Juan Castillo73c99d42015-08-18 14:23:04 +01001298################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001299# Build targets
1300################################################################################
1301
Sumit Garg90aa9012019-11-11 18:46:36 +05301302.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 +01001303.SUFFIXES:
1304
1305all: msg_start
1306
1307msg_start:
1308 @echo "Building ${PLAT}"
1309
Soby Mathew7a24cba2015-10-26 14:29:21 +00001310ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001311# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001312ifneq ($(findstring clang,$(notdir $(CC))),)
1313 CPPFLAGS += -Wno-error=deprecated-declarations
1314else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001315 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001316endif
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001317endif # !ERROR_DEPRECATED
Soby Mathew7a24cba2015-10-26 14:29:21 +00001318
Roberto Vargas5accce52018-05-22 16:05:42 +01001319$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas61f72a32018-05-08 10:27:10 +01001320$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001321
Juan Castillo73c99d42015-08-18 14:23:04 +01001322# Expand build macros for the different images
1323ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001324BL1_SOURCES := $(sort ${BL1_SOURCES})
1325
Zelalem Aweke434d0492021-07-11 17:25:48 -05001326$(eval $(call MAKE_BL,bl1))
Juan Castillo73c99d42015-08-18 14:23:04 +01001327endif
1328
1329ifeq (${NEED_BL2},yes)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001330ifeq (${BL2_AT_EL3}, 0)
1331FIP_BL2_ARGS := tb-fw
1332endif
1333
Chris Kayeb1acfb2021-09-28 15:44:37 +01001334BL2_SOURCES := $(sort ${BL2_SOURCES})
1335
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001336$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001337 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Juan Castillo73c99d42015-08-18 14:23:04 +01001338endif
1339
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001340ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001341$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001342endif
1343
Juan Castillo73c99d42015-08-18 14:23:04 +01001344ifeq (${NEED_BL31},yes)
1345BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001346# Sort BL31 source files to remove duplicates
1347BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301348ifneq (${DECRYPTION_SUPPORT},none)
1349$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001350 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301351else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001352$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001353 $(eval $(call MAKE_BL,bl31,soc-fw)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001354endif
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301355endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001356
Juan Castillo70d1fc52015-11-12 10:59:26 +00001357# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001358# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001359# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001360ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001361# Sort BL32 source files to remove duplicates
1362BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001363BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1364
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301365ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001366$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301367 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1368else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001369$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001370 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001371endif
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301372endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001373
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001374# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1375# needs to be built from RMM_SOURCES.
1376ifeq (${NEED_RMM},yes)
1377# Sort RMM source files to remove duplicates
1378RMM_SOURCES := $(sort ${RMM_SOURCES})
1379BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1380
1381$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1382 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1383endif
1384
Juan Castillo73c99d42015-08-18 14:23:04 +01001385# Add the BL33 image if required by the platform
1386ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001387$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Juan Castillodb6071c2015-01-13 12:21:04 +00001388endif
1389
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001390ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001391$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001392 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001393endif
1394
Nishanth Menon03b397a2016-10-14 01:13:57 +00001395# Expand build macros for the different images
1396ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001397 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Nishanth Menon03b397a2016-10-14 01:13:57 +00001398endif
1399
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001400# Add Secure Partition packages
1401ifeq (${NEED_SP_PKG},yes)
1402$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
Ruari Phipps1e7528e2020-07-24 16:20:57 +01001403 ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
J-Alves822c7272022-03-22 16:28:51 +00001404sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001405 @${ECHO_BLANK_LINE}
1406 @echo "Built SP Images successfully"
1407 @${ECHO_BLANK_LINE}
1408endif
1409
Ian Spray36eaaf32014-01-30 17:25:28 +00001410locate-checkpatch:
1411ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001412 $(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 +00001413else
1414ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001415 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001416endif
1417endif
1418
Achin Gupta4f6ad662013-10-25 09:08:21 +01001419clean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001420 @echo " CLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001421 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001422ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001423 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001424else
1425# Clear the MAKEFLAGS as we do not want
1426# to pass the gnumake flags to nmake.
1427 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1428endif
Juan Castillo73c99d42015-08-18 14:23:04 +01001429 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Garg90aa9012019-11-11 18:46:36 +05301430 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargas5accce52018-05-22 16:05:42 +01001431 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001432
James Morrisseyeaaeece2013-11-01 13:56:59 +00001433realclean distclean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001434 @echo " REALCLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001435 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1436 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001437ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001438 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001439else
1440# Clear the MAKEFLAGS as we do not want
1441# to pass the gnumake flags to nmake.
1442 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1443endif
Nicolas Boulengueze15591a2021-03-31 12:22:45 +02001444 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Garg90aa9012019-11-11 18:46:36 +05301445 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargas5accce52018-05-22 16:05:42 +01001446 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001447
Ian Spray36eaaf32014-01-30 17:25:28 +00001448checkcodebase: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001449 @echo " CHECKING STYLE"
Dan Handley1a41e8c2016-06-02 18:21:02 +01001450 @if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001451 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001452 while read GIT_FILE ; \
1453 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1454 done ; \
1455 else \
1456 find . -type f -not -iwholename "*.git*" \
1457 -not -iwholename "*build*" \
1458 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001459 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001460 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001461 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001462 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1463 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001464
1465checkpatch: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001466 @echo " CHECKING STYLE"
Yann Gautier02a76d52019-03-08 15:44:00 +01001467 @if test -n "${CHECKPATCH_OPTS}"; then \
1468 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1469 fi
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001470 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001471 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1472 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001473 printf "\n[*] Checking style of '$$commit'\n\n"; \
1474 git log --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001475 -- ${CHECK_PATHS} | \
1476 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001477 git diff --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001478 -- ${CHECK_PATHS} | \
1479 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001480 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001481
1482certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001483
Pali Rohára9812202020-11-24 15:38:08 +01001484${CRTTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001485 ${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 +00001486 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001487 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001488 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001489
1490ifneq (${GENERATE_COT},0)
1491certificates: ${CRT_DEPS} ${CRTTOOL}
1492 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloydf1477d42015-12-02 18:33:55 +00001493 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001494 @echo "Built $@ successfully"
1495 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloydf1477d42015-12-02 18:33:55 +00001496 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001497endif
1498
1499${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001500 $(eval ${CHECK_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001501 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1502 ${Q}${FIPTOOL} info $@
Evan Lloydf1477d42015-12-02 18:33:55 +00001503 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001504 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001505 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001506
Yatharth Kochar01912622015-10-12 12:33:47 +01001507ifneq (${GENERATE_COT},0)
1508fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1509 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd052ab522017-04-11 16:52:00 +01001510 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001511 @echo "Built $@ successfully"
1512 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd052ab522017-04-11 16:52:00 +01001513 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001514endif
1515
1516${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001517 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001518 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1519 ${Q}${FIPTOOL} info $@
Evan Lloyd052ab522017-04-11 16:52:00 +01001520 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001521 @echo "Built $@ successfully"
Evan Lloyd052ab522017-04-11 16:52:00 +01001522 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001523
Juan Castillo73c99d42015-08-18 14:23:04 +01001524fiptool: ${FIPTOOL}
1525fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001526fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001527
Pali Rohára9812202020-11-24 15:38:08 +01001528${FIPTOOL}: FORCE
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001529ifdef UNIX_MK
Lionel Debieve598b1662022-11-14 11:05:09 +01001530 ${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 +01001531else
1532# Clear the MAKEFLAGS as we do not want
1533# to pass the gnumake flags to nmake.
1534 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1535endif
Harry Liebelf58ad362014-01-10 18:00:33 +00001536
Pali Rohára9812202020-11-24 15:38:08 +01001537romlib.bin: libraries FORCE
John Tsichritzisbbb24f62019-05-21 15:47:37 +01001538 ${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 +01001539
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001540# Call print_memory_map tool
1541memmap: all
Louis Mayencourtb890b362020-02-13 08:21:34 +00001542 ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001543
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001544doc:
1545 @echo " BUILD DOCUMENTATION"
1546 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1547
Sumit Garg90aa9012019-11-11 18:46:36 +05301548enctool: ${ENCTOOL}
1549
Pali Rohára9812202020-11-24 15:38:08 +01001550${ENCTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001551 ${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 +05301552 @${ECHO_BLANK_LINE}
1553 @echo "Built $@ successfully"
1554 @${ECHO_BLANK_LINE}
1555
Joakim Bech35fab8c2014-01-23 14:51:49 +01001556cscope:
1557 @echo " CSCOPE"
1558 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1559 ${Q}cscope -b -q -k
1560
Ryan Harkin72ee3312014-01-15 16:55:07 +00001561help:
John Tsichritzis7c231262019-05-21 15:57:31 +01001562 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001563 @echo ""
1564 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +00001565 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001566 @echo ""
John Tsichritzis7c231262019-05-21 15:57:31 +01001567 @echo "platform = ${PLATFORM_LIST}"
1568 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001569 @echo "Please refer to the User Guide for a list of all supported options."
1570 @echo "Note that the build system doesn't track dependencies for build "
1571 @echo "options. Therefore, if any of the build options are changed "
1572 @echo "from a previous build, a clean build must be performed."
1573 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001574 @echo "Supported Targets:"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001575 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001576 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001577 @echo " bl2 Build the BL2 binary"
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001578 @echo " bl2u Build the BL2U binary"
Juan Castillod1786372015-12-14 09:35:25 +00001579 @echo " bl31 Build the BL31 binary"
Soby Mathew9d29c222016-05-05 14:33:33 +01001580 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1581 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castillo73c99d42015-08-18 14:23:04 +01001582 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001583 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochar01912622015-10-12 12:33:47 +01001584 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001585 @echo " checkcodebase Check the coding style of the entire source tree"
1586 @echo " checkpatch Check the coding style on changes in the current"
1587 @echo " branch against BASE_COMMIT (default origin/master)"
1588 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001589 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001590 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo6f971622014-10-21 11:30:42 +01001591 @echo " certtool Build the Certificate generation tool"
Sumit Garg90aa9012019-11-11 18:46:36 +05301592 @echo " enctool Build the Firmware encryption tool"
Andreas Färber59dead22016-10-10 05:18:49 +02001593 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001594 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaz26010da2018-11-27 14:58:04 +00001595 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathew38c14d82017-12-14 17:44:56 +00001596 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001597 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001598 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001599 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001600 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001601 @echo ""
1602 @echo "example: build all targets for the FVP platform:"
1603 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001604
1605.PHONY: FORCE
1606FORCE:;