blob: a2ff9ce608974f38dac5d47193623d1242390034 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06002# Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +01007#
Juan Castillo04be3a52014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathewd42eaee2018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Manish V Badarkhe8a7af842024-05-17 11:09:28 +010011VERSION_MINOR := 11
Yann Gautier5f4cbed2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH := 0
Yann Gautier57078a92023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castillo04be3a52014-06-30 11:41:46 +010015
Juan Castillo396644b2015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard527cd902016-12-28 14:47:50 +000019# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
Evan Lloydf2697142015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000026include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kay1559f642024-06-04 00:04:48 +000027include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
Chris Kay1870c722024-05-02 17:52:37 +000028include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010029
30################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010031# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010032################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010033
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010034include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Andrey Skvortsov89c3a142024-02-18 11:43:12 +030035include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
36
37# To be able to set platform specific defaults
38ifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),)
39include ${PLAT_DEFAULTS_MAKEFILE_FULL}
40endif
dp-arm3cac7862016-09-19 11:18:44 +010041
Chris Kayc8a47ba2023-10-20 09:17:33 +000042################################################################################
43# Configure the toolchains used to build TF-A and its tools
44################################################################################
45
Chris Kay0adde4e2024-05-14 13:08:31 +000046#
47# The clean and check targets do not behave correctly if the user's environment
48# does not appropriately configure a toolchain. While we try to find a permanent
49# solution to this, do not try to detect any toolchains if we are building
50# exclusively with targets which do not use any toolchain tools.
51#
52
53ifeq ($(filter-out check% %clean doc %tool,$(or $(MAKECMDGOALS),all)),)
54 toolchains :=
55endif
56
Chris Kayc8a47ba2023-10-20 09:17:33 +000057include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
58
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010059# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010060ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010061ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
Achin Gupta4f6ad662013-10-25 09:08:21 +010062
Juan Castilloa3487d12015-08-18 14:23:04 +010063################################################################################
64# Checkpatch script options
65################################################################################
66
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010067CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010068# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030069INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
70 include/drivers/arm, \
71 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010072INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010073 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010074 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010075 $(wildcard include/lib/*)))
76INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030077 include/lib \
78 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010079 $(wildcard include/*)))
80LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010081 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000082 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010083 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010084 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010085 $(wildcard lib/*)))
86ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
87 lib \
88 include \
89 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000090 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010091 $(wildcard *)))
92CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
93 ${INC_DIRS_TO_CHECK} \
94 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030095 ${LIB_DIRS_TO_CHECK} \
96 ${INC_DRV_DIRS_TO_CHECK} \
97 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000098
Juan Castilloa3487d12015-08-18 14:23:04 +010099################################################################################
100# Process build options
101################################################################################
102
Chris Kay1870c722024-05-02 17:52:37 +0000103ifeq ($(verbose),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100104 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +0100105endif
Andre Przywaracf2bb082018-09-27 10:56:05 +0100106
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100107################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100108# Auxiliary tools (fiptool, cert_create, etc)
109################################################################################
110
111# Variables for use with Certificate Generation Tool
112CRTTOOLPATH ?= tools/cert_create
113CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
114
115# Variables for use with Firmware Encryption Tool
116ENCTOOLPATH ?= tools/encrypt_fw
117ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
118
119# Variables for use with Firmware Image Package
120FIPTOOLPATH ?= tools/fiptool
121FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
122
123# Variables for use with sptool
124SPTOOLPATH ?= tools/sptool
125SPTOOL ?= ${SPTOOLPATH}/sptool.py
126SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakinaba46182023-02-14 11:56:02 +0000127SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100128
129# Variables for use with ROMLIB
130ROMLIBPATH ?= lib/romlib
131
132# Variable for use with Python
133PYTHON ?= python3
134
135# Variables for use with documentation build using Sphinx tool
136DOCS_PATH ?= docs
137
138################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100139# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100140################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100141ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100142 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500143# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100144else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100145 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100146endif #(ARM_ARCH_MAJOR)
147
148################################################################################
149# Get Architecture Feature Modifiers
150################################################################################
151arch-features = ${ARM_ARCH_FEATURE}
152
Chris Kaycfba6452023-12-04 09:55:50 +0000153ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
154 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja69096412023-06-01 16:29:16 -0500155 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
156 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000157 else
Govindraj Raja69096412023-06-01 16:29:16 -0500158 TF_CFLAGS_aarch32 = $(target32-directive)
159 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000160 endif
161
Chris Kaycfba6452023-12-04 09:55:50 +0000162else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kay00416dc2024-02-20 16:19:54 +0000163 # Enable LTO only for aarch64
164 ifeq (${ARCH},aarch64)
165 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-aweked5f45272019-11-12 16:20:17 -0600166 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100167endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100168
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100169# Process Debug flag
170$(eval $(call add_define,DEBUG))
171ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100172 BUILD_TYPE := debug
173 TF_CFLAGS += -g -gdwarf-4
174 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100175
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100176 # Use LOG_LEVEL_INFO by default for debug builds
177 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100178else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100179 BUILD_TYPE := release
180 # Use LOG_LEVEL_NOTICE by default for release builds
181 LOG_LEVEL := 20
182endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100183
Peiyuan Song44f8f472020-04-25 16:53:43 +0800184# Default build string (git branch and commit)
185ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100186 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800187endif
laurenw-arme954f652022-07-12 10:12:05 -0500188VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800189
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100190ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100191 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100192else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100193 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100194else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100195 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
196endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100197
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200198TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100199TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100200
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100201##############################################################################
202# WARNINGS Configuration
203###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100204# General warnings
205WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200206 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000207 -Wredundant-decls
208# stricter warnings
209WARNINGS += -Wextra -Wno-trigraphs
210# too verbose for generic build
211WARNINGS += -Wno-missing-field-initializers \
212 -Wno-type-limits -Wno-sign-compare \
213# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
214WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100215
216# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000217# Level 1 - infrequent warnings we should have none of
218# full -Wextra
219WARNING1 += -Wsign-compare
220WARNING1 += -Wtype-limits
221WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100222
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000223# Level 2 - problematic warnings that we want
224# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
225# TODO: disable just for them and move into default build
226WARNING2 += -Wold-style-definition
227WARNING2 += -Wmissing-prototypes
228WARNING2 += -Wmissing-format-attribute
229# TF-A aims to comply with this eventually. Effort too large at present
230WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000231# currently very involved and many platforms set this off
232WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100233
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000234# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100235WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000236WARNING3 += -Waggregate-return
237WARNING3 += -Wnested-externs
238WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100239WARNING3 += -Wcast-qual
240WARNING3 += -Wconversion
241WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100242WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100243WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100244
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000245# Setting W is quite verbose and most warnings will be pre-existing issues
246# outside of the contributor's control. Don't fail the build on them so warnings
247# can be seen and hopefully addressed
248ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100249 ifneq (${W},0)
250 E ?= 0
251 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000252endif
253
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100254ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100255 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100256else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100257 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100258else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100259 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
260endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100261
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100262# Compiler specific warnings
Chris Kaycfba6452023-12-04 09:55:50 +0000263ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100264# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100265WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
266 -Wpacked-bitfield-compat -Wshift-overflow=2 \
267 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500268
269# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
270TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
271
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500272ifeq ($(HARDEN_SLS), 1)
273 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
274endif
275
Justin Chadwell7a914232019-07-03 14:15:56 +0100276else
277# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100278WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
279 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100280endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100281
Yann Gautier957c3532018-12-10 18:08:53 +0100282ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100283 ERRORS := -Werror
284endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100285
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100286################################################################################
287# Compiler and Linker Directives
288################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100289CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
290 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500291ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700292 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900293TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500294 -ffunction-sections -fdata-sections \
295 -ffreestanding -fno-builtin -fno-common \
296 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100297
Justin Chadwell83e04882019-08-20 11:01:52 +0100298ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100299 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
300endif #(${SANITIZE_UB},on)
301
Justin Chadwell83e04882019-08-20 11:01:52 +0100302ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100303 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100304 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100305endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100306
Chris Kay0adde4e2024-05-14 13:08:31 +0000307GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunado34ab6092017-11-30 21:58:01 +0000308
Marco Felsch24ad8402022-11-09 12:59:09 +0100309TF_LDFLAGS += -z noexecstack
310
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100311# LD = armlink
Chris Kaycfba6452023-12-04 09:55:50 +0000312ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100313 TF_LDFLAGS += --diag_error=warning --lto_level=O1
314 TF_LDFLAGS += --remove --info=unused,unusedsymbols
315 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100316
317# LD = gcc (used when GCC LTO is enabled)
Chris Kaycfba6452023-12-04 09:55:50 +0000318else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100319 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000320 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100321 TF_LDFLAGS += -Wl,--fatal-warnings -O1
322 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000323
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100324 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
325 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300326 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000327
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100328 ifeq ($(ENABLE_LTO),1)
329 ifeq (${ARCH},aarch64)
330 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov664d6502023-12-08 18:04:51 +0300331 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100332 endif
333 endif #(ENABLE_LTO)
334
zelalem-aweked5f45272019-11-12 16:20:17 -0600335# GCC automatically adds fix-cortex-a53-843419 flag when used to link
336# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100337 ifeq (${ARCH},aarch64)
338 ifneq (${ERRATA_A53_843419},1)
339 TF_LDFLAGS += -mno-fix-cortex-a53-843419
340 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100341 endif
342 TF_LDFLAGS += -nostdlib
343 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100344
345# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800346else
Marco Felsch24ad8402022-11-09 12:59:09 +0100347# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
348# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100349 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
350 TF_LDFLAGS += -O1
351 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000352
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100353 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
354 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300355 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000356
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100357# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000358# therefore don't add those in that case.
359# ld.lld reports section type mismatch warnings,
360# therefore don't add --fatal-warnings to it.
Chris Kaycfba6452023-12-04 09:55:50 +0000361 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100362 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
363 endif
364
365endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100366
367################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500368# Setup ARCH_MAJOR/MINOR before parsing arch_features.
369################################################################################
370ifeq (${ENABLE_RME},1)
AlexeiFedorov65258452024-03-13 11:53:44 +0000371 ARM_ARCH_MAJOR := 9
372 ARM_ARCH_MINOR := 2
Govindraj Raja0386e312023-08-17 10:41:48 -0500373endif
374
375################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100376# Common sources and include directories
377################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100378include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100379
Chris Kay99b5b2e2024-03-08 16:08:31 +0000380# Allow overriding the timestamp, for example for reproducible builds, or to
381# synchronize timestamps across multiple projects.
382# This must be set to a C string (including quotes where applicable).
383BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
384
385DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
386DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
387DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
388
Juan Castilloa3487d12015-08-18 14:23:04 +0100389BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100390 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100391 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800392 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100393 lib/${ARCH}/cache_helpers.S \
394 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000395 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000396 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100397 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000398 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100399 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100400 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000401
Chris Kaycfba6452023-12-04 09:55:50 +0000402ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100403 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100404endif
405
Justin Chadwell83e04882019-08-20 11:01:52 +0100406ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100407 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100408endif
409
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200410INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000411 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000412 -Iinclude/lib/cpus/${ARCH} \
413 -Iinclude/lib/el3_runtime/${ARCH} \
414 ${PLAT_INCLUDES} \
415 ${SPD_INCLUDES}
416
Nishant Sharma331b5682022-08-15 16:37:07 +0100417DTC_FLAGS += -I dts -O dtb
418DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
419 -x assembler-with-cpp $(DEFINES)
420
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000421include common/backtrace/backtrace.mk
422
Juan Castilloa3487d12015-08-18 14:23:04 +0100423################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500424# Generic definitions
425################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500426
427ifeq (${BUILD_BASE},)
428 BUILD_BASE := ./build
429endif
430BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
431
432SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
433
434# Platforms providing their own TBB makefile may override this value
435INCLUDE_TBBR_MK := 1
436
437################################################################################
438# Include SPD Makefile if one has been specified
439################################################################################
440
441ifneq (${SPD},none)
442 ifeq (${ARCH},aarch32)
443 $(error "Error: SPD is incompatible with AArch32.")
444 endif
445
446 ifdef EL3_PAYLOAD_BASE
447 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
448 $(warning "The SPD and its BL32 companion will be present but \
449 ignored.")
450 endif
451
452 ifeq (${SPD},spmd)
453 # SPMD is located in std_svc directory
454 SPD_DIR := std_svc
455
456 ifeq ($(SPMD_SPM_AT_SEL2),1)
457 CTX_INCLUDE_EL2_REGS := 1
458 ifeq ($(SPMC_AT_EL3),1)
459 $(error SPM cannot be enabled in both S-EL2 and EL3.)
460 endif
Madhukar Pappireddy7503cdc2024-04-25 23:01:00 -0500461 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
462 $(error SVE context management not needed with Hafnium SPMC.)
463 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500464 endif
465
466 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
467 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
468 endif
469
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100470 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
471 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
472 endif
473
Govindraj Raja1a211292023-09-20 14:32:24 -0500474 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100475 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja1a211292023-09-20 14:32:24 -0500476 endif
477
478 ifneq ($(ARM_BL2_SP_LIST_DTS),)
479 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
480 endif
481
482 ifneq ($(SP_LAYOUT_FILE),)
483 BL2_ENABLE_SP_LOAD := 1
484 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500485
486 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
487 ifneq ($(SPMC_AT_EL3),1)
488 $(error SEL0 SP cannot be enabled without SPMC at EL3)
489 endif
490 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500491 else
492 # All other SPDs in spd directory
493 SPD_DIR := spd
494 endif #(SPD)
495
496 # We expect to locate an spd.mk under the specified SPD directory
497 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
498
499 ifeq (${SPD_MAKE},)
500 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
501 endif
502 $(info Including ${SPD_MAKE})
503 include ${SPD_MAKE}
504
505 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
506 # Makefile would set NEED_BL32 to "yes". In this case, the build system
507 # supports two mutually exclusive options:
508 # * BL32 is built from source: then BL32_SOURCES must contain the list
509 # of source files to build BL32
510 # * BL32 is a prebuilt binary: then BL32 must point to the image file
511 # that will be included in the FIP
512 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
513 # over the sources.
514endif #(SPD=none)
515
516ifeq (${ENABLE_SPMD_LP}, 1)
517ifneq (${SPD},spmd)
518 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
519endif
520ifeq ($(SPMC_AT_EL3),1)
521 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
522endif
523endif
524
525################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500526# Process BRANCH_PROTECTION value and set
527# Pointer Authentication and Branch Target Identification flags
528################################################################################
529ifeq (${BRANCH_PROTECTION},0)
530 # Default value turns off all types of branch protection
531 BP_OPTION := none
532else ifneq (${ARCH},aarch64)
533 $(error BRANCH_PROTECTION requires AArch64)
534else ifeq (${BRANCH_PROTECTION},1)
535 # Enables all types of branch protection features
536 BP_OPTION := standard
537 ENABLE_BTI := 1
538 ENABLE_PAUTH := 1
539else ifeq (${BRANCH_PROTECTION},2)
540 # Return address signing to its standard level
541 BP_OPTION := pac-ret
542 ENABLE_PAUTH := 1
543else ifeq (${BRANCH_PROTECTION},3)
544 # Extend the signing to include leaf functions
545 BP_OPTION := pac-ret+leaf
546 ENABLE_PAUTH := 1
547else ifeq (${BRANCH_PROTECTION},4)
548 # Turn on branch target identification mechanism
549 BP_OPTION := bti
550 ENABLE_BTI := 1
551else
552 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
553endif #(BRANCH_PROTECTION)
554
555ifeq ($(ENABLE_PAUTH),1)
556 CTX_INCLUDE_PAUTH_REGS := 1
557endif
558ifneq (${BP_OPTION},none)
559 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
560endif #(BP_OPTION)
561
562# Pointer Authentication sources
563ifeq (${ENABLE_PAUTH}, 1)
564# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
565# Pauth support. As it's not secure, it must be reimplemented for real platforms
566 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
567endif
568
Govindraj Raja1a211292023-09-20 14:32:24 -0500569################################################################################
570# Include the platform specific Makefile after the SPD Makefile (the platform
571# makefile may use all previous definitions in this file)
572################################################################################
573include ${PLAT_MAKEFILE_FULL}
574
575################################################################################
576# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
577# platform.
578################################################################################
579include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
580
Govindraj Raja0386e312023-08-17 10:41:48 -0500581####################################################
582# Enable required options for Memory Stack Tagging.
583####################################################
584
585# Currently, these options are enabled only for clang and armclang compiler.
586ifeq (${SUPPORT_STACK_MEMTAG},yes)
587 ifdef mem_tag_arch_support
588 # Check for armclang and clang compilers
Chris Kaycfba6452023-12-04 09:55:50 +0000589 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Raja0386e312023-08-17 10:41:48 -0500590 # Add "memtag" architecture feature modifier if not specified
591 ifeq ( ,$(findstring memtag,$(arch-features)))
592 arch-features := $(arch-features)+memtag
593 endif # memtag
Chris Kaycfba6452023-12-04 09:55:50 +0000594 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500595 TF_CFLAGS += -mmemtag-stack
Chris Kaycfba6452023-12-04 09:55:50 +0000596 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500597 TF_CFLAGS += -fsanitize=memtag
598 endif # armclang
599 endif
600 else
601 $(error "Error: stack memory tagging is not supported for \
602 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
603 endif #(mem_tag_arch_support)
604endif #(SUPPORT_STACK_MEMTAG)
605
606################################################################################
607# RME dependent flags configuration, Enable optional features for RME.
608################################################################################
609# FEAT_RME
610ifeq (${ENABLE_RME},1)
Govindraj Raja60f52662023-10-12 16:57:46 -0500611 # RME doesn't support BRBE
612 ENABLE_BRBE_FOR_NS := 0
613
Govindraj Raja0386e312023-08-17 10:41:48 -0500614 # RME doesn't support PIE
615 ifneq (${ENABLE_PIE},0)
616 $(error ENABLE_RME does not support PIE)
617 endif
618
619 # RME doesn't support BRBE
620 ifneq (${ENABLE_BRBE_FOR_NS},0)
621 $(error ENABLE_RME does not support BRBE.)
622 endif
623
624 # RME requires AARCH64
625 ifneq (${ARCH},aarch64)
626 $(error ENABLE_RME requires AArch64)
627 endif
628
629 # RME requires el2 context to be saved for now.
630 CTX_INCLUDE_EL2_REGS := 1
631 CTX_INCLUDE_AARCH32_REGS := 0
632 CTX_INCLUDE_PAUTH_REGS := 1
633
634 # RME enables CSV2_2 extension by default.
635 ENABLE_FEAT_CSV2_2 = 1
636endif #(FEAT_RME)
637
638################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500639# Include rmmd Makefile if RME is enabled
640################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500641ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100642 ifneq (${ARCH},aarch64)
643 $(error ENABLE_RME requires AArch64)
644 endif
645 ifeq ($(SPMC_AT_EL3),1)
646 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
647 endif
648
649 ifneq (${SPD}, none)
650 ifneq (${SPD}, spmd)
651 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
652 endif
653 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500654include services/std_svc/rmmd/rmmd.mk
655$(warning "RME is an experimental feature")
656endif
657
Govindraj Raja1a211292023-09-20 14:32:24 -0500658ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
659 ifeq (${SPD},none)
660 ifeq (${ENABLE_RME},0)
661 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
662 or RME is enabled)
663 endif
664 endif
665endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000666
Govindraj Raja69096412023-06-01 16:29:16 -0500667################################################################################
668# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
669# up with appropriate march values for compiler.
670################################################################################
671include ${MAKE_HELPERS_DIRECTORY}march.mk
672
673TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600674ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500675
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600676# This internal flag is common option which is set to 1 for scenarios
677# when the BL2 is running in EL3 level. This occurs in two scenarios -
678# 4 world system running BL2 at EL3 and two world system without BL1 running
679# BL2 in EL3
680
681ifeq (${RESET_TO_BL2},1)
682 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100683 ifeq (${ENABLE_RME},1)
684 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
685 supported at the moment.)
686 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600687else ifeq (${ENABLE_RME},1)
688 BL2_RUNS_AT_EL3 := 1
689else
690 BL2_RUNS_AT_EL3 := 0
691endif
692
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100693# This internal flag is set to 1 when Firmware First handling of External aborts
694# is required by lowe ELs. Currently only NS requires this support.
695ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
696 FFH_SUPPORT := 1
697else
698 FFH_SUPPORT := 0
699endif
700
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100701ifeq (${ARM_ARCH_MAJOR},7)
702include make_helpers/armv7-a-cpus.mk
703endif
704
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900705PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
706ifneq ($(PIE_FOUND),)
707 TF_CFLAGS += -fno-PIE
Chris Kaycfba6452023-12-04 09:55:50 +0000708ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland9286c022022-04-08 21:56:02 -0500709 TF_LDFLAGS += -no-pie
710endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100711endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900712
Chris Kaycfba6452023-12-04 09:55:50 +0000713ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900714 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100715else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900716 PIE_LDFLAGS += -pie --no-dynamic-linker
717endif
718
719ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100720 ifeq ($(RESET_TO_BL2),1)
721 ifneq ($(BL2_IN_XIP_MEM),1)
722 BL2_CPPFLAGS += -fpie
723 BL2_CFLAGS += -fpie
724 BL2_LDFLAGS += $(PIE_LDFLAGS)
725 endif #(BL2_IN_XIP_MEM)
726 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000727 BL31_CPPFLAGS += -fpie
728 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900729 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000730
731 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900732 BL32_CFLAGS += -fpie
733 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100734endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100735
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000736BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
737BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
738BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
739
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900740BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600741ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100742 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900743else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100744 BL2_CPPFLAGS += -DIMAGE_AT_EL1
745endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000746
747ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100748 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
749 BL31_CPPFLAGS += -DIMAGE_AT_EL3
750 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000751else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100752 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900753endif
754
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000755# Include the CPU specific operations makefile, which provides default
756# values for all CPU errata workarounds and CPU specific optimisations.
757# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100758include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100759
dp-armcdd03cb2017-02-15 11:07:55 +0000760################################################################################
761# Build `AARCH32_SP` as BL32 image for AArch32
762################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100763ifeq (${ARCH},aarch32)
764 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000765
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100766 ifneq (${AARCH32_SP},none)
767 # We expect to locate an sp.mk under the specified AARCH32_SP directory
768 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000769
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100770 ifeq (${AARCH32_SP_MAKE},)
771 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
772 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500773 $(info Including ${AARCH32_SP_MAKE})
774 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100775 endif
776endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800777
778################################################################################
779# Include libc if not overridden
780################################################################################
781ifeq (${OVERRIDE_LIBC},0)
782include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000783endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100784
785################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100786# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000787################################################################################
788
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100789# USE_DEBUGFS experimental feature recommended only in debug builds
790ifeq (${USE_DEBUGFS},1)
791 ifeq (${DEBUG},1)
792 $(warning DEBUGFS experimental feature is enabled.)
793 else
794 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800795 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100796endif #(USE_DEBUGFS)
797
798# USE_SPINLOCK_CAS requires AArch64 build
799ifeq (${USE_SPINLOCK_CAS},1)
800 ifneq (${ARCH},aarch64)
801 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800802 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100803endif #(USE_SPINLOCK_CAS)
804
805# The cert_create tool cannot generate certificates individually, so we use the
806# target 'certificates' to create them all
807ifneq (${GENERATE_COT},0)
808 FIP_DEPS += certificates
809 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000810endif
811
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100812ifneq (${DECRYPTION_SUPPORT},none)
813 ENC_ARGS += -f ${FW_ENC_STATUS}
814 ENC_ARGS += -k ${ENC_KEY}
815 ENC_ARGS += -n ${ENC_NONCE}
816 FIP_DEPS += enctool
817 FWU_FIP_DEPS += enctool
818endif #(DECRYPTION_SUPPORT)
819
820ifdef EL3_PAYLOAD_BASE
821 ifdef PRELOADED_BL33_BASE
822 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
823 incompatible build options. EL3_PAYLOAD_BASE has priority.")
824 endif
825 ifneq (${GENERATE_COT},0)
826 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
827 build options.")
828 endif
829 ifneq (${TRUSTED_BOARD_BOOT},0)
830 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
831 incompatible \ build options.")
832 endif
833endif #(EL3_PAYLOAD_BASE)
834
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000835ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100836 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000837 $(warning "BL33 image is not needed when option \
838 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100839 endif
840 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100841 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100842 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
843 endif
844endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000845
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000846# When building for systems with hardware-assisted coherency, there's no need to
847# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
848ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100849 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000850endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100851
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600852#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
853ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100854 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000855endif
856
Manish Pandeyd419e222023-02-13 12:39:17 +0000857# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100858ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100859 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100860 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000861endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100862
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100863
Manish Pandeyd419e222023-02-13 12:39:17 +0000864# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000865ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100866 ifeq ($(ENABLE_FEAT_RAS),0)
867 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
868 endif
869endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000870
Roberto Vargas025946a2018-09-24 17:20:48 +0100871# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100872ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100873 ifeq (${TRUSTED_BOARD_BOOT}, 0)
874 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
875 to be set.")
876 endif
877endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100878
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100879ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
880# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100881 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100882else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
883# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100884 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100885else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
886# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100887 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100888else ifeq (${TRUSTED_BOARD_BOOT},1)
889# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100890 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000891else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100892 CRYPTO_SUPPORT := 0
893endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000894
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100895# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
896ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100897 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100898endif
899
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000900# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100901# registers associated to it are also saved and restored.
902# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000903ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100904 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
905 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
906 endif
907endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100908
909ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100910 ifneq (${ARCH},aarch64)
911 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
912 endif
913endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000914
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000915ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100916 $(info FEATURE_DETECTION is an experimental feature)
917endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000918
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000919ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100920 ifeq (${ENABLE_SME_FOR_NS}, 0)
921 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
922 to be set")
923 $(warning "Forced ENABLE_SME_FOR_NS=1")
924 override ENABLE_SME_FOR_NS := 1
925 endif
926endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000927
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000928ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100929 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
930 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
931 library v2")
932 endif
933endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000934
Sumit Garg392e4df2019-11-15 10:43:00 +0530935ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100936 ifeq (${TRUSTED_BOARD_BOOT}, 0)
937 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
938 to be set)
939 endif
940endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530941
johpow0181865962022-01-28 17:06:20 -0600942# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500943ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600944
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100945 # SME/SVE only supported on AArch64
946 ifneq (${ENABLE_SME_FOR_NS},0)
947 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
948 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000949
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100950 ifeq (${ENABLE_SVE_FOR_NS},1)
951 # Warning instead of error due to CI dependency on this
952 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
953 endif
johpow0181865962022-01-28 17:06:20 -0600954
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100955 # BRBE is not supported in AArch32
956 ifeq (${ENABLE_BRBE_FOR_NS},1)
957 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
958 endif
johpow0181865962022-01-28 17:06:20 -0600959
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100960 # FEAT_RNG_TRAP is not supported in AArch32
961 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
962 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
963 endif
964endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500965
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000966ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100967 ifeq (${ENABLE_SVE_FOR_NS},0)
968 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
969 endif
970endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000971
johpow019baade32021-07-08 14:14:00 -0500972# Secure SME/SVE requires the non-secure component as well
973ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100974 ifeq (${ENABLE_SME_FOR_NS},0)
975 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
976 endif
977 ifeq (${ENABLE_SVE_FOR_SWD},0)
978 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
979 endif
980endif #(ENABLE_SME_FOR_SWD)
981
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500982# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
983# mechanism.
johpow019baade32021-07-08 14:14:00 -0500984ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500985 ifeq (${ENABLE_SVE_FOR_NS},0)
986 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
987 endif
988endif
johpow019baade32021-07-08 14:14:00 -0500989
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500990# Enabling SVE for both the worlds typically requires the context
991# management of SVE registers. The only exception being SPMC at S-EL2.
992ifeq (${ENABLE_SVE_FOR_SWD}, 1)
993 ifneq (${ENABLE_SVE_FOR_NS}, 0)
994 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
995 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
996 endif
997 endif
998endif
999
1000# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
1001# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
1002# and SVE registers.
1003ifeq (${CTX_INCLUDE_FPREGS}, 1)
1004 ifneq (${ENABLE_SVE_FOR_NS},0)
1005 ifeq (${CTX_INCLUDE_SVE_REGS},0)
1006 # Warning instead of error due to CI dependency on this
1007 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
1008 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1009 override ENABLE_SVE_FOR_NS := 0
1010 endif
1011 endif
1012endif #(CTX_INCLUDE_FPREGS)
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +00001013
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -05001014# SVE context management is only required if secure world has access to SVE/FP
1015# functionality.
1016ifeq (${CTX_INCLUDE_SVE_REGS},1)
1017 ifeq (${ENABLE_SVE_FOR_SWD},0)
1018 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1019 endif
1020endif
1021
1022# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1023# management including FPU registers.
1024ifeq (${CTX_INCLUDE_FPREGS},1)
1025 ifneq (${ENABLE_SME_FOR_NS},0)
1026 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1027 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001028endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001029
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001030ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001031 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001032endif
1033
Raymond Mao98983392023-07-25 07:53:35 -07001034ifeq (${TRANSFER_LIST},1)
1035 $(info TRANSFER_LIST is an experimental feature)
1036endif
1037
Chris Kayd02c2312022-09-29 16:21:24 +01001038ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001039 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1040 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1041 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001042endif
1043
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001044ifeq ($(PSA_CRYPTO),1)
1045 $(info PSA_CRYPTO is an experimental feature)
1046endif
1047
Manish V Badarkhed8d7d932024-05-09 12:14:13 +01001048ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1049 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1050endif
1051
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001052################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001053# Process platform overrideable behaviour
1054################################################################################
1055
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001056ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001057 NEED_BL1 := yes
1058endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001059
Jon Medhurst66573cb2014-02-13 15:19:28 +00001060ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001061 NEED_BL2 := yes
1062
1063 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1064 # Certificate generation tools. This flag can be overridden by the platform.
1065 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001066 # If booting an EL3 payload there is no need for a BL33 image
1067 # in the FIP file.
1068 NEED_BL33 := no
1069 else
1070 ifdef PRELOADED_BL33_BASE
1071 # If booting a BL33 preloaded image there is no need of
1072 # another one in the FIP file.
1073 NEED_BL33 := no
1074 else
1075 NEED_BL33 ?= yes
1076 endif
1077 endif
1078endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001079
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001080ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001081 NEED_BL2U := yes
1082endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001083
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001084# If SCP_BL2 is given, we always want FIP to include it.
1085ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001086 NEED_SCP_BL2 := yes
1087endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001088
Soby Mathewbf169232017-11-14 14:10:10 +00001089# For AArch32, BL31 is not currently supported.
1090ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001091 ifdef BL31_SOURCES
1092 # When booting an EL3 payload, there is no need to compile the BL31
1093 # image nor put it in the FIP.
1094 ifndef EL3_PAYLOAD_BASE
1095 NEED_BL31 := yes
1096 endif
1097 endif
1098endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001099
Juan Castilloa3487d12015-08-18 14:23:04 +01001100# Process TBB related flags
1101ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001102 # Common cert_create options
1103 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001104 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001105 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001106 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001107 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001108 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001109 endif
1110 endif
1111 # Include TBBR makefile (unless the platform indicates otherwise)
1112 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001113 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001114 endif
1115endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001116
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001117ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001118 FIP_ARGS += --align ${FIP_ALIGN}
1119endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001120
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001121ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001122 NEED_FDT := yes
1123endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001124
Juan Castilloa3487d12015-08-18 14:23:04 +01001125################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001126# Include libraries' Makefile that are used in all BL
1127################################################################################
1128
1129include lib/stack_protector/stack_protector.mk
1130
1131################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001132# Include BL specific makefiles
1133################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001134
1135ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001136include bl1/bl1.mk
1137endif
1138
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001139ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001140include bl2/bl2.mk
1141endif
1142
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001143ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001144include bl2u/bl2u.mk
1145endif
1146
Soby Mathewbf169232017-11-14 14:10:10 +00001147ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001148include bl31/bl31.mk
1149endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001150
Soby Mathew574e01e2017-02-14 10:05:07 +00001151################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001152# Build options checks
1153################################################################################
1154
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001155# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001156$(eval $(call assert_booleans,\
1157 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001158 ALLOW_RO_XLAT_TABLES \
1159 BL2_ENABLE_SP_LOAD \
1160 COLD_BOOT_SINGLE_CPU \
1161 CREATE_KEYS \
1162 CTX_INCLUDE_AARCH32_REGS \
1163 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001164 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001165 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001166 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001167 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001168 DYN_DISABLE_AUTH \
1169 EL3_EXCEPTION_HANDLING \
1170 ENABLE_AMU_AUXILIARY_COUNTERS \
1171 ENABLE_AMU_FCONF \
1172 AMU_RESTRICT_COUNTERS \
1173 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001174 ENABLE_PIE \
1175 ENABLE_PMF \
1176 ENABLE_PSCI_STAT \
1177 ENABLE_RUNTIME_INSTRUMENTATION \
1178 ENABLE_SME_FOR_SWD \
1179 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001180 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001181 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001182 ERROR_DEPRECATED \
1183 FAULT_INJECTION_SUPPORT \
1184 GENERATE_COT \
1185 GICV2_G0_FOR_EL3 \
1186 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001187 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001188 HW_ASSISTED_COHERENCY \
1189 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001190 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001191 DRTM_SUPPORT \
1192 NS_TIMER_SWITCH \
1193 OVERRIDE_LIBC \
1194 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001195 PROGRAMMABLE_RESET_ADDRESS \
1196 PSCI_EXTENDED_STATE_ID \
1197 PSCI_OS_INIT_MODE \
1198 RESET_TO_BL31 \
1199 SAVE_KEYS \
1200 SEPARATE_CODE_AND_RODATA \
1201 SEPARATE_BL2_NOLOAD_REGION \
1202 SEPARATE_NOBITS_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001203 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001204 SPIN_ON_BL1_EXIT \
1205 SPM_MM \
1206 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001207 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001208 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001209 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001210 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001211 TRUSTED_BOARD_BOOT \
1212 USE_COHERENT_MEM \
1213 USE_DEBUGFS \
1214 ARM_IO_IN_DTB \
1215 SDEI_IN_FCONF \
1216 SEC_INT_DESC_IN_FCONF \
1217 USE_ROMLIB \
1218 USE_TBBR_DEFS \
1219 WARMBOOT_ENABLE_DCACHE_EARLY \
1220 RESET_TO_BL2 \
1221 BL2_IN_XIP_MEM \
1222 BL2_INV_DCACHE \
1223 USE_SPINLOCK_CAS \
1224 ENCRYPT_BL31 \
1225 ENCRYPT_BL32 \
1226 ERRATA_SPECULATIVE_AT \
1227 RAS_TRAP_NS_ERR_REC_ACCESS \
1228 COT_DESC_IN_DTB \
1229 USE_SP804_TIMER \
1230 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301231 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001232 ENABLE_MPMM \
1233 ENABLE_MPMM_FCONF \
1234 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001235 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001236 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001237 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001238 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001239 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001240 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001241 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001242 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001243 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001244 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001245)))
Dan Handley81be1002015-03-27 17:44:35 +00001246
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001247# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001248$(eval $(call assert_numerics,\
1249 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001250 ARM_ARCH_MAJOR \
1251 ARM_ARCH_MINOR \
1252 BRANCH_PROTECTION \
1253 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001254 CTX_INCLUDE_NEVE_REGS \
1255 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001256 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001257 ENABLE_BRBE_FOR_NS \
1258 ENABLE_TRBE_FOR_NS \
1259 ENABLE_BTI \
1260 ENABLE_PAUTH \
1261 ENABLE_FEAT_AMU \
1262 ENABLE_FEAT_AMUv1p1 \
1263 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001264 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001265 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001266 ENABLE_FEAT_DIT \
1267 ENABLE_FEAT_ECV \
1268 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001269 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001270 ENABLE_FEAT_HCX \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001271 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001272 ENABLE_FEAT_PAN \
1273 ENABLE_FEAT_RNG \
1274 ENABLE_FEAT_RNG_TRAP \
1275 ENABLE_FEAT_SEL2 \
1276 ENABLE_FEAT_TCR2 \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001277 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001278 ENABLE_FEAT_S2PIE \
1279 ENABLE_FEAT_S1PIE \
1280 ENABLE_FEAT_S2POE \
1281 ENABLE_FEAT_S1POE \
1282 ENABLE_FEAT_GCS \
1283 ENABLE_FEAT_VHE \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001284 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001285 ENABLE_RME \
1286 ENABLE_SPE_FOR_NS \
1287 ENABLE_SYS_REG_TRACE_FOR_NS \
1288 ENABLE_SME_FOR_NS \
1289 ENABLE_SME2_FOR_NS \
1290 ENABLE_SVE_FOR_NS \
1291 ENABLE_TRF_FOR_NS \
1292 FW_ENC_STATUS \
1293 NR_OF_FW_BANKS \
1294 NR_OF_IMAGES_IN_FW_BANK \
1295 TWED_DELAY \
1296 ENABLE_FEAT_TWED \
1297 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001298 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001299)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001300
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001301ifdef KEY_SIZE
1302 $(eval $(call assert_numeric,KEY_SIZE))
1303endif
1304
Justin Chadwell83e04882019-08-20 11:01:52 +01001305ifeq ($(filter $(SANITIZE_UB), on off trap),)
1306 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1307endif
1308
Juan Castilloa3487d12015-08-18 14:23:04 +01001309################################################################################
1310# Add definitions to the cpp preprocessor based on the current build options.
1311# This is done after including the platform specific makefile to allow the
1312# platform to overwrite the default options
1313################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001314
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001315$(eval $(call add_defines,\
1316 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001317 ALLOW_RO_XLAT_TABLES \
1318 ARM_ARCH_MAJOR \
1319 ARM_ARCH_MINOR \
1320 BL2_ENABLE_SP_LOAD \
1321 COLD_BOOT_SINGLE_CPU \
1322 CTX_INCLUDE_AARCH32_REGS \
1323 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001324 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001325 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001326 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001327 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001328 CTX_INCLUDE_EL2_REGS \
1329 CTX_INCLUDE_NEVE_REGS \
1330 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1331 DISABLE_MTPMU \
1332 ENABLE_FEAT_AMU \
1333 ENABLE_AMU_AUXILIARY_COUNTERS \
1334 ENABLE_AMU_FCONF \
1335 AMU_RESTRICT_COUNTERS \
1336 ENABLE_ASSERTIONS \
1337 ENABLE_BTI \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001338 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001339 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001340 ENABLE_PAUTH \
1341 ENABLE_PIE \
1342 ENABLE_PMF \
1343 ENABLE_PSCI_STAT \
1344 ENABLE_RME \
1345 ENABLE_RUNTIME_INSTRUMENTATION \
1346 ENABLE_SME_FOR_NS \
1347 ENABLE_SME2_FOR_NS \
1348 ENABLE_SME_FOR_SWD \
1349 ENABLE_SPE_FOR_NS \
1350 ENABLE_SVE_FOR_NS \
1351 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001352 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001353 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001354 ENCRYPT_BL31 \
1355 ENCRYPT_BL32 \
1356 ERROR_DEPRECATED \
1357 FAULT_INJECTION_SUPPORT \
1358 GICV2_G0_FOR_EL3 \
1359 HANDLE_EA_EL3_FIRST_NS \
1360 HW_ASSISTED_COHERENCY \
1361 LOG_LEVEL \
1362 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001363 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001364 DRTM_SUPPORT \
1365 NS_TIMER_SWITCH \
1366 PL011_GENERIC_UART \
1367 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001368 PROGRAMMABLE_RESET_ADDRESS \
1369 PSCI_EXTENDED_STATE_ID \
1370 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001371 RESET_TO_BL31 \
AlexeiFedorovc0ca2d72024-05-13 15:35:54 +01001372 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovbd8b1bb2024-03-13 17:07:03 +00001373 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001374 SEPARATE_CODE_AND_RODATA \
1375 SEPARATE_BL2_NOLOAD_REGION \
1376 SEPARATE_NOBITS_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001377 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001378 RECLAIM_INIT_CODE \
1379 SPD_${SPD} \
1380 SPIN_ON_BL1_EXIT \
1381 SPM_MM \
1382 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001383 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001384 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001385 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001386 TRUSTED_BOARD_BOOT \
1387 CRYPTO_SUPPORT \
1388 TRNG_SUPPORT \
1389 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001390 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001391 USE_COHERENT_MEM \
1392 USE_DEBUGFS \
1393 ARM_IO_IN_DTB \
1394 SDEI_IN_FCONF \
1395 SEC_INT_DESC_IN_FCONF \
1396 USE_ROMLIB \
1397 USE_TBBR_DEFS \
1398 WARMBOOT_ENABLE_DCACHE_EARLY \
1399 RESET_TO_BL2 \
1400 BL2_RUNS_AT_EL3 \
1401 BL2_IN_XIP_MEM \
1402 BL2_INV_DCACHE \
1403 USE_SPINLOCK_CAS \
1404 ERRATA_SPECULATIVE_AT \
1405 RAS_TRAP_NS_ERR_REC_ACCESS \
1406 COT_DESC_IN_DTB \
1407 USE_SP804_TIMER \
1408 ENABLE_FEAT_RNG \
1409 ENABLE_FEAT_RNG_TRAP \
1410 ENABLE_FEAT_SB \
1411 ENABLE_FEAT_DIT \
1412 NR_OF_FW_BANKS \
1413 NR_OF_IMAGES_IN_FW_BANK \
1414 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301415 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001416 ENABLE_BRBE_FOR_NS \
1417 ENABLE_TRBE_FOR_NS \
1418 ENABLE_SYS_REG_TRACE_FOR_NS \
1419 ENABLE_TRF_FOR_NS \
1420 ENABLE_FEAT_HCX \
1421 ENABLE_MPMM \
1422 ENABLE_MPMM_FCONF \
1423 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001424 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001425 ENABLE_FEAT_ECV \
1426 ENABLE_FEAT_AMUv1p1 \
1427 ENABLE_FEAT_SEL2 \
1428 ENABLE_FEAT_VHE \
1429 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001430 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001431 ENABLE_FEAT_PAN \
1432 ENABLE_FEAT_TCR2 \
1433 ENABLE_FEAT_S2PIE \
1434 ENABLE_FEAT_S1PIE \
1435 ENABLE_FEAT_S2POE \
1436 ENABLE_FEAT_S1POE \
1437 ENABLE_FEAT_GCS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001438 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001439 FEATURE_DETECTION \
1440 TWED_DELAY \
1441 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001442 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001443 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001444 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001445 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001446 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001447 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001448 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001449 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001450 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001451 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001452)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001453
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001454ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1455ifeq (${DEBUG}, 0)
1456 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1457 override PLATFORM_REPORT_CTX_MEM_USE := 0
1458endif
1459endif
1460
Justin Chadwell83e04882019-08-20 11:01:52 +01001461ifeq (${SANITIZE_UB},trap)
1462 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001463endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001464
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001465# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1466ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001467 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1468else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001469# Define the PRELOADED_BL33_BASE flag only if it is provided and
1470# EL3_PAYLOAD_BASE is not defined, as it has priority.
1471 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001472 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001473 endif
1474endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001475
Soby Mathew9fe88042018-03-26 12:43:37 +01001476# Define the DYN_DISABLE_AUTH flag only if set.
1477ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001478 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001479endif
1480
Chris Kaycfba6452023-12-04 09:55:50 +00001481ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001482 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001483endif
1484
Manish Pandey3f90ad72020-01-14 11:52:05 +00001485# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001486ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001487ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001488 -include $(BUILD_PLAT)/sp_gen.mk
1489 FIP_DEPS += sp
1490 CRT_DEPS += sp
1491 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001492else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001493 ifeq (${SPMD_SPM_AT_SEL2},1)
1494 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1495 endif
1496endif #(SP_LAYOUT_FILE)
1497endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001498
Juan Castilloa3487d12015-08-18 14:23:04 +01001499################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001500# Build targets
1501################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001502
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301503.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
Juan Castilloa3487d12015-08-18 14:23:04 +01001504.SUFFIXES:
Achin Gupta4f6ad662013-10-25 09:08:21 +01001505
Juan Castilloa3487d12015-08-18 14:23:04 +01001506all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001507
Juan Castilloa3487d12015-08-18 14:23:04 +01001508msg_start:
Chris Kay1870c722024-05-02 17:52:37 +00001509 $(s)echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001510
Soby Mathew18a62042015-10-26 14:29:21 +00001511ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001512# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kaycfba6452023-12-04 09:55:50 +00001513ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekar4d034c52019-01-11 14:47:48 -08001514 CPPFLAGS += -Wno-error=deprecated-declarations
1515else
Dan Handley6fa89a22018-02-27 16:03:58 +00001516 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001517endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001518endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001519
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001520$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001521
Juan Castilloa3487d12015-08-18 14:23:04 +01001522# Expand build macros for the different images
1523ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001524BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001525$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001526endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001527
Juan Castilloa3487d12015-08-18 14:23:04 +01001528ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001529
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001530ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001531FIP_BL2_ARGS := tb-fw
1532endif
1533
Chris Kayfb3b0512021-09-28 15:44:37 +01001534BL2_SOURCES := $(sort ${BL2_SOURCES})
1535
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001536$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001537 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001538
1539endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001540
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001541ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001542$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001543endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001544
Juan Castilloa3487d12015-08-18 14:23:04 +01001545ifeq (${NEED_BL31},yes)
1546BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001547# Sort BL31 source files to remove duplicates
1548BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301549ifneq (${DECRYPTION_SUPPORT},none)
1550$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001551 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301552else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001553$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001554 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001555endif #(DECRYPTION_SUPPORT)
1556endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001557
Juan Castillo671b8db2015-11-12 10:59:26 +00001558# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001559# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001560# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001561ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001562# Sort BL32 source files to remove duplicates
1563BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001564BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1565
Sumit Gargeec52442019-11-14 16:33:45 +05301566ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001567$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301568 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1569else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001570$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001571 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001572endif #(DECRYPTION_SUPPORT)
1573endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001574
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001575# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1576# needs to be built from RMM_SOURCES.
1577ifeq (${NEED_RMM},yes)
1578# Sort RMM source files to remove duplicates
1579RMM_SOURCES := $(sort ${RMM_SOURCES})
1580BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1581
1582$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001583 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1584endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001585
Juan Castilloa3487d12015-08-18 14:23:04 +01001586# Add the BL33 image if required by the platform
1587ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001588$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001589endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001590
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001591ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001592$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001593 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001594endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001595
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001596# Expand build macros for the different images
1597ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001598 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001599endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001600
Manish Pandey3f90ad72020-01-14 11:52:05 +00001601# Add Secure Partition packages
1602ifeq (${NEED_SP_PKG},yes)
Chris Kayd67442e2024-07-30 13:33:56 +00001603$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay1870c722024-05-02 17:52:37 +00001604 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001605sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay1870c722024-05-02 17:52:37 +00001606 $(s)echo
1607 $(s)echo "Built SP Images successfully"
1608 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001609endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001610
Ian Spray36eaaf32014-01-30 17:25:28 +00001611locate-checkpatch:
1612ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001613 $(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 +00001614else
1615ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001616 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001617endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001618endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001619
Achin Gupta4f6ad662013-10-25 09:08:21 +01001620clean:
Chris Kay1870c722024-05-02 17:52:37 +00001621 $(s)echo " CLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001622 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001623ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001624 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001625else
1626# Clear the MAKEFLAGS as we do not want
1627# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001628 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001629endif #(UNIX_MK)
Chris Kay1870c722024-05-02 17:52:37 +00001630 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1631 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1632 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001633
James Morrisseyeaaeece2013-11-01 13:56:59 +00001634realclean distclean:
Chris Kay1870c722024-05-02 17:52:37 +00001635 $(s)echo " REALCLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001636 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1637 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001638ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001639 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001640else
1641# Clear the MAKEFLAGS as we do not want
1642# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001643 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001644endif #(UNIX_MK)
Chris Kay1870c722024-05-02 17:52:37 +00001645 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
1646 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1647 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001648
Ian Spray36eaaf32014-01-30 17:25:28 +00001649checkcodebase: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001650 $(s)echo " CHECKING STYLE"
1651 $(q)if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001652 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001653 while read GIT_FILE ; \
1654 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1655 done ; \
1656 else \
1657 find . -type f -not -iwholename "*.git*" \
1658 -not -iwholename "*build*" \
1659 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001660 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001661 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001662 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001663 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1664 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001665
1666checkpatch: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001667 $(s)echo " CHECKING STYLE"
1668 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001669 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1670 fi
Chris Kay1870c722024-05-02 17:52:37 +00001671 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001672 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1673 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001674 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautierfaf8c612024-08-09 11:52:03 +02001675 ( git log --format=email "$$commit~..$$commit" \
1676 -- ${CHECK_PATHS} ; \
1677 git diff --format=email "$$commit~..$$commit" \
1678 -- ${CHECK_PATHS}; ) | \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001679 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001680 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001681
1682certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001683
Pali Rohár54ff2132020-11-24 15:38:08 +01001684${CRTTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001685 $(q)${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all
1686 $(s)echo
1687 $(s)echo "Built $@ successfully"
1688 $(s)echo
Jon Medhurst407a95c2014-02-12 15:54:48 +00001689
Juan Castillo11abdcd2014-10-21 11:30:42 +01001690ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001691certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001692 $(q)${CRTTOOL} ${CRT_ARGS}
1693 $(s)echo
1694 $(s)echo "Built $@ successfully"
1695 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1696 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001697endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001698
Juan Castilloa3487d12015-08-18 14:23:04 +01001699${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001700 $(eval ${CHECK_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001701 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1702 $(q)${FIPTOOL} info $@
1703 $(s)echo
1704 $(s)echo "Built $@ successfully"
1705 $(s)echo
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001706
Yatharth Kochard1a93432015-10-12 12:33:47 +01001707ifneq (${GENERATE_COT},0)
1708fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001709 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1710 $(s)echo
1711 $(s)echo "Built $@ successfully"
1712 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1713 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001714endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001715
1716${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001717 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001718 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1719 $(q)${FIPTOOL} info $@
1720 $(s)echo
1721 $(s)echo "Built $@ successfully"
1722 $(s)echo
Yatharth Kochard1a93432015-10-12 12:33:47 +01001723
Juan Castilloa3487d12015-08-18 14:23:04 +01001724fiptool: ${FIPTOOL}
1725fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001726fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001727
Pali Rohár54ff2132020-11-24 15:38:08 +01001728${FIPTOOL}: FORCE
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001729ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001730 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001731else
1732# Clear the MAKEFLAGS as we do not want
1733# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001734 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001735endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001736
Pali Rohár54ff2132020-11-24 15:38:08 +01001737romlib.bin: libraries FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001738 $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargase92111a2018-05-22 16:05:42 +01001739
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001740memmap: all
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001741ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001742 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001743 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1744else
Chris Kay1870c722024-05-02 17:52:37 +00001745 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001746 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1747endif
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001748
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001749doc:
Chris Kay1870c722024-05-02 17:52:37 +00001750 $(s)echo " BUILD DOCUMENTATION"
1751 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001752
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301753enctool: ${ENCTOOL}
1754
Pali Rohár54ff2132020-11-24 15:38:08 +01001755${ENCTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001756 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1757 $(s)echo
1758 $(s)echo "Built $@ successfully"
1759 $(s)echo
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301760
Joakim Bech35fab8c2014-01-23 14:51:49 +01001761cscope:
Chris Kay1870c722024-05-02 17:52:37 +00001762 $(s)echo " CSCOPE"
1763 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1764 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001765
Ryan Harkin72ee3312014-01-15 16:55:07 +00001766help:
Chris Kay1870c722024-05-02 17:52:37 +00001767 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1768 $(s)echo ""
1769 $(s)echo "PLAT is used to specify which platform you wish to build."
1770 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1771 $(s)echo ""
1772 $(s)echo "platform = ${PLATFORM_LIST}"
1773 $(s)echo ""
1774 $(s)echo "Please refer to the User Guide for a list of all supported options."
1775 $(s)echo "Note that the build system doesn't track dependencies for build "
1776 $(s)echo "options. Therefore, if any of the build options are changed "
1777 $(s)echo "from a previous build, a clean build must be performed."
1778 $(s)echo ""
1779 $(s)echo "Supported Targets:"
1780 $(s)echo " all Build all individual bootloader binaries"
1781 $(s)echo " bl1 Build the BL1 binary"
1782 $(s)echo " bl2 Build the BL2 binary"
1783 $(s)echo " bl2u Build the BL2U binary"
1784 $(s)echo " bl31 Build the BL31 binary"
1785 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1786 $(s)echo " this builds secure payload specified by AARCH32_SP"
1787 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1788 $(s)echo " fip Build the Firmware Image Package (FIP)"
1789 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1790 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1791 $(s)echo " checkpatch Check the coding style on changes in the current"
1792 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1793 $(s)echo " clean Clean the build for the selected platform"
1794 $(s)echo " cscope Generate cscope index"
1795 $(s)echo " distclean Remove all build artifacts for all platforms"
1796 $(s)echo " certtool Build the Certificate generation tool"
1797 $(s)echo " enctool Build the Firmware encryption tool"
1798 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1799 $(s)echo " sp Build the Secure Partition Packages"
1800 $(s)echo " sptool Build the Secure Partition Package creation tool"
1801 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1802 $(s)echo " memmap Print the memory map of the built binaries"
1803 $(s)echo " doc Build html based documentation using Sphinx tool"
1804 $(s)echo ""
1805 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1806 $(s)echo ""
1807 $(s)echo "example: build all targets for the FVP platform:"
1808 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001809
1810.PHONY: FORCE
1811FORCE:;