blob: e9e0f59202decf9fe94ce3a221488bf8813a0b60 [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
dp-arm3cac7862016-09-19 11:18:44 +010035
Chris Kayc8a47ba2023-10-20 09:17:33 +000036################################################################################
37# Configure the toolchains used to build TF-A and its tools
38################################################################################
39
40include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
41
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010042# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010043ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010044ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
45PLAT := ${DEFAULT_PLAT}
Achin Gupta4f6ad662013-10-25 09:08:21 +010046
Juan Castilloa3487d12015-08-18 14:23:04 +010047################################################################################
48# Checkpatch script options
49################################################################################
50
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010051CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010052# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030053INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
54 include/drivers/arm, \
55 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010056INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010057 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010058 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010059 $(wildcard include/lib/*)))
60INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030061 include/lib \
62 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010063 $(wildcard include/*)))
64LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010065 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000066 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010067 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010068 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010069 $(wildcard lib/*)))
70ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
71 lib \
72 include \
73 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000074 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010075 $(wildcard *)))
76CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
77 ${INC_DIRS_TO_CHECK} \
78 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030079 ${LIB_DIRS_TO_CHECK} \
80 ${INC_DRV_DIRS_TO_CHECK} \
81 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000082
Juan Castilloa3487d12015-08-18 14:23:04 +010083################################################################################
84# Process build options
85################################################################################
86
Chris Kay1870c722024-05-02 17:52:37 +000087ifeq ($(verbose),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010088 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010089endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010090
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010091################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010092# Auxiliary tools (fiptool, cert_create, etc)
93################################################################################
94
95# Variables for use with Certificate Generation Tool
96CRTTOOLPATH ?= tools/cert_create
97CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
98
99# Variables for use with Firmware Encryption Tool
100ENCTOOLPATH ?= tools/encrypt_fw
101ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
102
103# Variables for use with Firmware Image Package
104FIPTOOLPATH ?= tools/fiptool
105FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
106
107# Variables for use with sptool
108SPTOOLPATH ?= tools/sptool
109SPTOOL ?= ${SPTOOLPATH}/sptool.py
110SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakinaba46182023-02-14 11:56:02 +0000111SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100112
113# Variables for use with ROMLIB
114ROMLIBPATH ?= lib/romlib
115
116# Variable for use with Python
117PYTHON ?= python3
118
119# Variables for use with documentation build using Sphinx tool
120DOCS_PATH ?= docs
121
122################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100123# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100124################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100125ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100126 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500127# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100128else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100129 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100130endif #(ARM_ARCH_MAJOR)
131
132################################################################################
133# Get Architecture Feature Modifiers
134################################################################################
135arch-features = ${ARM_ARCH_FEATURE}
136
Chris Kaycfba6452023-12-04 09:55:50 +0000137ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
138 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja69096412023-06-01 16:29:16 -0500139 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
140 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000141 else
Govindraj Raja69096412023-06-01 16:29:16 -0500142 TF_CFLAGS_aarch32 = $(target32-directive)
143 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000144 endif
145
Chris Kaycfba6452023-12-04 09:55:50 +0000146else ifeq ($($(ARCH)-cc-id),gnu-gcc)
Chris Kay00416dc2024-02-20 16:19:54 +0000147 # Enable LTO only for aarch64
148 ifeq (${ARCH},aarch64)
149 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
zelalem-aweked5f45272019-11-12 16:20:17 -0600150 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100151endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100152
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100153# Process Debug flag
154$(eval $(call add_define,DEBUG))
155ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100156 BUILD_TYPE := debug
157 TF_CFLAGS += -g -gdwarf-4
158 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100159
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100160 # Use LOG_LEVEL_INFO by default for debug builds
161 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100162else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100163 BUILD_TYPE := release
164 # Use LOG_LEVEL_NOTICE by default for release builds
165 LOG_LEVEL := 20
166endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100167
Peiyuan Song44f8f472020-04-25 16:53:43 +0800168# Default build string (git branch and commit)
169ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100170 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800171endif
laurenw-arme954f652022-07-12 10:12:05 -0500172VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800173
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100174ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100175 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100176else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100177 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100178else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100179 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
180endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100181
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200182TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100183TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100184
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100185##############################################################################
186# WARNINGS Configuration
187###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100188# General warnings
189WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200190 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000191 -Wredundant-decls
192# stricter warnings
193WARNINGS += -Wextra -Wno-trigraphs
194# too verbose for generic build
195WARNINGS += -Wno-missing-field-initializers \
196 -Wno-type-limits -Wno-sign-compare \
197# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
198WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100199
200# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000201# Level 1 - infrequent warnings we should have none of
202# full -Wextra
203WARNING1 += -Wsign-compare
204WARNING1 += -Wtype-limits
205WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100206
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000207# Level 2 - problematic warnings that we want
208# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
209# TODO: disable just for them and move into default build
210WARNING2 += -Wold-style-definition
211WARNING2 += -Wmissing-prototypes
212WARNING2 += -Wmissing-format-attribute
213# TF-A aims to comply with this eventually. Effort too large at present
214WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000215# currently very involved and many platforms set this off
216WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100217
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000218# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100219WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000220WARNING3 += -Waggregate-return
221WARNING3 += -Wnested-externs
222WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100223WARNING3 += -Wcast-qual
224WARNING3 += -Wconversion
225WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100226WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100227WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100228
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000229# Setting W is quite verbose and most warnings will be pre-existing issues
230# outside of the contributor's control. Don't fail the build on them so warnings
231# can be seen and hopefully addressed
232ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100233 ifneq (${W},0)
234 E ?= 0
235 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000236endif
237
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100238ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100239 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100240else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100241 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100242else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100243 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
244endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100245
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100246# Compiler specific warnings
Chris Kaycfba6452023-12-04 09:55:50 +0000247ifeq ($(filter %-clang,$($(ARCH)-cc-id)),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100248# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100249WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
250 -Wpacked-bitfield-compat -Wshift-overflow=2 \
251 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500252
253# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
254TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
255
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500256ifeq ($(HARDEN_SLS), 1)
257 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
258endif
259
Justin Chadwell7a914232019-07-03 14:15:56 +0100260else
261# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100262WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
263 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100264endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100265
Yann Gautier957c3532018-12-10 18:08:53 +0100266ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100267 ERRORS := -Werror
268endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100269
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100270################################################################################
271# Compiler and Linker Directives
272################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100273CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
274 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500275ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700276 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900277TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500278 -ffunction-sections -fdata-sections \
279 -ffreestanding -fno-builtin -fno-common \
280 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100281
Justin Chadwell83e04882019-08-20 11:01:52 +0100282ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100283 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
284endif #(${SANITIZE_UB},on)
285
Justin Chadwell83e04882019-08-20 11:01:52 +0100286ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100287 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100288 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100289endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100290
Chris Kay0adde4e2024-05-14 13:08:31 +0000291GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1))
david cunado34ab6092017-11-30 21:58:01 +0000292
Marco Felsch24ad8402022-11-09 12:59:09 +0100293TF_LDFLAGS += -z noexecstack
294
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100295# LD = armlink
Chris Kaycfba6452023-12-04 09:55:50 +0000296ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100297 TF_LDFLAGS += --diag_error=warning --lto_level=O1
298 TF_LDFLAGS += --remove --info=unused,unusedsymbols
299 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100300
301# LD = gcc (used when GCC LTO is enabled)
Chris Kaycfba6452023-12-04 09:55:50 +0000302else ifeq ($($(ARCH)-ld-id),gnu-gcc)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100303 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000304 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100305 TF_LDFLAGS += -Wl,--fatal-warnings -O1
306 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000307
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100308 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
309 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300310 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000311
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100312 ifeq ($(ENABLE_LTO),1)
313 ifeq (${ARCH},aarch64)
314 TF_LDFLAGS += -flto -fuse-linker-plugin
Andrey Skvortsov664d6502023-12-08 18:04:51 +0300315 TF_LDFLAGS += -flto-partition=one
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100316 endif
317 endif #(ENABLE_LTO)
318
zelalem-aweked5f45272019-11-12 16:20:17 -0600319# GCC automatically adds fix-cortex-a53-843419 flag when used to link
320# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100321 ifeq (${ARCH},aarch64)
322 ifneq (${ERRATA_A53_843419},1)
323 TF_LDFLAGS += -mno-fix-cortex-a53-843419
324 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100325 endif
326 TF_LDFLAGS += -nostdlib
327 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100328
329# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800330else
Marco Felsch24ad8402022-11-09 12:59:09 +0100331# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
332# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100333 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
334 TF_LDFLAGS += -O1
335 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000336
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100337 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
338 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300339 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000340
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100341# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000342# therefore don't add those in that case.
343# ld.lld reports section type mismatch warnings,
344# therefore don't add --fatal-warnings to it.
Chris Kaycfba6452023-12-04 09:55:50 +0000345 ifneq ($($(ARCH)-ld-id),llvm-lld)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100346 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
347 endif
348
349endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100350
351################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500352# Setup ARCH_MAJOR/MINOR before parsing arch_features.
353################################################################################
354ifeq (${ENABLE_RME},1)
AlexeiFedorov65258452024-03-13 11:53:44 +0000355 ARM_ARCH_MAJOR := 9
356 ARM_ARCH_MINOR := 2
Govindraj Raja0386e312023-08-17 10:41:48 -0500357endif
358
359################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100360# Common sources and include directories
361################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100362include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100363
Chris Kay99b5b2e2024-03-08 16:08:31 +0000364# Allow overriding the timestamp, for example for reproducible builds, or to
365# synchronize timestamps across multiple projects.
366# This must be set to a C string (including quotes where applicable).
367BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
368
369DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)'
370DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"'
371DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"'
372
Juan Castilloa3487d12015-08-18 14:23:04 +0100373BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100374 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100375 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800376 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100377 lib/${ARCH}/cache_helpers.S \
378 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000379 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000380 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100381 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000382 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100383 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100384 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000385
Chris Kaycfba6452023-12-04 09:55:50 +0000386ifeq ($($(ARCH)-cc-id),arm-clang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100387 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100388endif
389
Justin Chadwell83e04882019-08-20 11:01:52 +0100390ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100391 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100392endif
393
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200394INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000395 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000396 -Iinclude/lib/cpus/${ARCH} \
397 -Iinclude/lib/el3_runtime/${ARCH} \
398 ${PLAT_INCLUDES} \
399 ${SPD_INCLUDES}
400
Nishant Sharma331b5682022-08-15 16:37:07 +0100401DTC_FLAGS += -I dts -O dtb
402DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
403 -x assembler-with-cpp $(DEFINES)
404
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000405include common/backtrace/backtrace.mk
406
Juan Castilloa3487d12015-08-18 14:23:04 +0100407################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500408# Generic definitions
409################################################################################
410include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
411
412ifeq (${BUILD_BASE},)
413 BUILD_BASE := ./build
414endif
415BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
416
417SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
418
419# Platforms providing their own TBB makefile may override this value
420INCLUDE_TBBR_MK := 1
421
422################################################################################
423# Include SPD Makefile if one has been specified
424################################################################################
425
426ifneq (${SPD},none)
427 ifeq (${ARCH},aarch32)
428 $(error "Error: SPD is incompatible with AArch32.")
429 endif
430
431 ifdef EL3_PAYLOAD_BASE
432 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
433 $(warning "The SPD and its BL32 companion will be present but \
434 ignored.")
435 endif
436
437 ifeq (${SPD},spmd)
438 # SPMD is located in std_svc directory
439 SPD_DIR := std_svc
440
441 ifeq ($(SPMD_SPM_AT_SEL2),1)
442 CTX_INCLUDE_EL2_REGS := 1
443 ifeq ($(SPMC_AT_EL3),1)
444 $(error SPM cannot be enabled in both S-EL2 and EL3.)
445 endif
Madhukar Pappireddy7503cdc2024-04-25 23:01:00 -0500446 ifeq ($(CTX_INCLUDE_SVE_REGS),1)
447 $(error SVE context management not needed with Hafnium SPMC.)
448 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500449 endif
450
451 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
452 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
453 endif
454
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100455 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp)
456 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG
457 endif
458
Govindraj Raja1a211292023-09-20 14:32:24 -0500459 ifeq ($(TS_SP_FW_CONFIG),1)
Arunachalam Ganapathyfd29d582022-04-11 14:36:54 +0100460 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
Govindraj Raja1a211292023-09-20 14:32:24 -0500461 endif
462
463 ifneq ($(ARM_BL2_SP_LIST_DTS),)
464 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
465 endif
466
467 ifneq ($(SP_LAYOUT_FILE),)
468 BL2_ENABLE_SP_LOAD := 1
469 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500470
471 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
472 ifneq ($(SPMC_AT_EL3),1)
473 $(error SEL0 SP cannot be enabled without SPMC at EL3)
474 endif
475 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500476 else
477 # All other SPDs in spd directory
478 SPD_DIR := spd
479 endif #(SPD)
480
481 # We expect to locate an spd.mk under the specified SPD directory
482 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
483
484 ifeq (${SPD_MAKE},)
485 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
486 endif
487 $(info Including ${SPD_MAKE})
488 include ${SPD_MAKE}
489
490 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
491 # Makefile would set NEED_BL32 to "yes". In this case, the build system
492 # supports two mutually exclusive options:
493 # * BL32 is built from source: then BL32_SOURCES must contain the list
494 # of source files to build BL32
495 # * BL32 is a prebuilt binary: then BL32 must point to the image file
496 # that will be included in the FIP
497 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
498 # over the sources.
499endif #(SPD=none)
500
501ifeq (${ENABLE_SPMD_LP}, 1)
502ifneq (${SPD},spmd)
503 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
504endif
505ifeq ($(SPMC_AT_EL3),1)
506 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
507endif
508endif
509
510################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500511# Process BRANCH_PROTECTION value and set
512# Pointer Authentication and Branch Target Identification flags
513################################################################################
514ifeq (${BRANCH_PROTECTION},0)
515 # Default value turns off all types of branch protection
516 BP_OPTION := none
517else ifneq (${ARCH},aarch64)
518 $(error BRANCH_PROTECTION requires AArch64)
519else ifeq (${BRANCH_PROTECTION},1)
520 # Enables all types of branch protection features
521 BP_OPTION := standard
522 ENABLE_BTI := 1
523 ENABLE_PAUTH := 1
524else ifeq (${BRANCH_PROTECTION},2)
525 # Return address signing to its standard level
526 BP_OPTION := pac-ret
527 ENABLE_PAUTH := 1
528else ifeq (${BRANCH_PROTECTION},3)
529 # Extend the signing to include leaf functions
530 BP_OPTION := pac-ret+leaf
531 ENABLE_PAUTH := 1
532else ifeq (${BRANCH_PROTECTION},4)
533 # Turn on branch target identification mechanism
534 BP_OPTION := bti
535 ENABLE_BTI := 1
536else
537 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
538endif #(BRANCH_PROTECTION)
539
540ifeq ($(ENABLE_PAUTH),1)
541 CTX_INCLUDE_PAUTH_REGS := 1
542endif
543ifneq (${BP_OPTION},none)
544 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
545endif #(BP_OPTION)
546
547# Pointer Authentication sources
548ifeq (${ENABLE_PAUTH}, 1)
549# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
550# Pauth support. As it's not secure, it must be reimplemented for real platforms
551 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
552endif
553
Govindraj Raja1a211292023-09-20 14:32:24 -0500554################################################################################
555# Include the platform specific Makefile after the SPD Makefile (the platform
556# makefile may use all previous definitions in this file)
557################################################################################
558include ${PLAT_MAKEFILE_FULL}
559
560################################################################################
561# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
562# platform.
563################################################################################
564include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
565
Govindraj Raja0386e312023-08-17 10:41:48 -0500566####################################################
567# Enable required options for Memory Stack Tagging.
568####################################################
569
570# Currently, these options are enabled only for clang and armclang compiler.
571ifeq (${SUPPORT_STACK_MEMTAG},yes)
572 ifdef mem_tag_arch_support
573 # Check for armclang and clang compilers
Chris Kaycfba6452023-12-04 09:55:50 +0000574 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Govindraj Raja0386e312023-08-17 10:41:48 -0500575 # Add "memtag" architecture feature modifier if not specified
576 ifeq ( ,$(findstring memtag,$(arch-features)))
577 arch-features := $(arch-features)+memtag
578 endif # memtag
Chris Kaycfba6452023-12-04 09:55:50 +0000579 ifeq ($($(ARCH)-cc-id),arm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500580 TF_CFLAGS += -mmemtag-stack
Chris Kaycfba6452023-12-04 09:55:50 +0000581 else ifeq ($($(ARCH)-cc-id),llvm-clang)
Govindraj Raja0386e312023-08-17 10:41:48 -0500582 TF_CFLAGS += -fsanitize=memtag
583 endif # armclang
584 endif
585 else
586 $(error "Error: stack memory tagging is not supported for \
587 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
588 endif #(mem_tag_arch_support)
589endif #(SUPPORT_STACK_MEMTAG)
590
591################################################################################
592# RME dependent flags configuration, Enable optional features for RME.
593################################################################################
594# FEAT_RME
595ifeq (${ENABLE_RME},1)
Govindraj Raja60f52662023-10-12 16:57:46 -0500596 # RME doesn't support BRBE
597 ENABLE_BRBE_FOR_NS := 0
598
Govindraj Raja0386e312023-08-17 10:41:48 -0500599 # RME doesn't support PIE
600 ifneq (${ENABLE_PIE},0)
601 $(error ENABLE_RME does not support PIE)
602 endif
603
604 # RME doesn't support BRBE
605 ifneq (${ENABLE_BRBE_FOR_NS},0)
606 $(error ENABLE_RME does not support BRBE.)
607 endif
608
609 # RME requires AARCH64
610 ifneq (${ARCH},aarch64)
611 $(error ENABLE_RME requires AArch64)
612 endif
613
614 # RME requires el2 context to be saved for now.
615 CTX_INCLUDE_EL2_REGS := 1
616 CTX_INCLUDE_AARCH32_REGS := 0
617 CTX_INCLUDE_PAUTH_REGS := 1
618
619 # RME enables CSV2_2 extension by default.
620 ENABLE_FEAT_CSV2_2 = 1
621endif #(FEAT_RME)
622
623################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500624# Include rmmd Makefile if RME is enabled
625################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500626ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100627 ifneq (${ARCH},aarch64)
628 $(error ENABLE_RME requires AArch64)
629 endif
630 ifeq ($(SPMC_AT_EL3),1)
631 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
632 endif
633
634 ifneq (${SPD}, none)
635 ifneq (${SPD}, spmd)
636 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
637 endif
638 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500639include services/std_svc/rmmd/rmmd.mk
640$(warning "RME is an experimental feature")
641endif
642
Govindraj Raja1a211292023-09-20 14:32:24 -0500643ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
644 ifeq (${SPD},none)
645 ifeq (${ENABLE_RME},0)
646 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
647 or RME is enabled)
648 endif
649 endif
650endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000651
Govindraj Raja69096412023-06-01 16:29:16 -0500652################################################################################
653# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
654# up with appropriate march values for compiler.
655################################################################################
656include ${MAKE_HELPERS_DIRECTORY}march.mk
657
658TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600659ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500660
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600661# This internal flag is common option which is set to 1 for scenarios
662# when the BL2 is running in EL3 level. This occurs in two scenarios -
663# 4 world system running BL2 at EL3 and two world system without BL1 running
664# BL2 in EL3
665
666ifeq (${RESET_TO_BL2},1)
667 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100668 ifeq (${ENABLE_RME},1)
669 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
670 supported at the moment.)
671 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600672else ifeq (${ENABLE_RME},1)
673 BL2_RUNS_AT_EL3 := 1
674else
675 BL2_RUNS_AT_EL3 := 0
676endif
677
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100678# This internal flag is set to 1 when Firmware First handling of External aborts
679# is required by lowe ELs. Currently only NS requires this support.
680ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
681 FFH_SUPPORT := 1
682else
683 FFH_SUPPORT := 0
684endif
685
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100686ifeq (${ARM_ARCH_MAJOR},7)
687include make_helpers/armv7-a-cpus.mk
688endif
689
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900690PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
691ifneq ($(PIE_FOUND),)
692 TF_CFLAGS += -fno-PIE
Chris Kaycfba6452023-12-04 09:55:50 +0000693ifeq ($($(ARCH)-ld-id),gnu-gcc)
Samuel Holland9286c022022-04-08 21:56:02 -0500694 TF_LDFLAGS += -no-pie
695endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100696endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900697
Chris Kaycfba6452023-12-04 09:55:50 +0000698ifeq ($($(ARCH)-ld-id),gnu-gcc)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900699 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100700else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900701 PIE_LDFLAGS += -pie --no-dynamic-linker
702endif
703
704ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100705 ifeq ($(RESET_TO_BL2),1)
706 ifneq ($(BL2_IN_XIP_MEM),1)
707 BL2_CPPFLAGS += -fpie
708 BL2_CFLAGS += -fpie
709 BL2_LDFLAGS += $(PIE_LDFLAGS)
710 endif #(BL2_IN_XIP_MEM)
711 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000712 BL31_CPPFLAGS += -fpie
713 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900714 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000715
716 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900717 BL32_CFLAGS += -fpie
718 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100719endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100720
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000721BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
722BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
723BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
724
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900725BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600726ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100727 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900728else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100729 BL2_CPPFLAGS += -DIMAGE_AT_EL1
730endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000731
732ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100733 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
734 BL31_CPPFLAGS += -DIMAGE_AT_EL3
735 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000736else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100737 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900738endif
739
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000740# Include the CPU specific operations makefile, which provides default
741# values for all CPU errata workarounds and CPU specific optimisations.
742# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100743include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100744
dp-armcdd03cb2017-02-15 11:07:55 +0000745################################################################################
746# Build `AARCH32_SP` as BL32 image for AArch32
747################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100748ifeq (${ARCH},aarch32)
749 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000750
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100751 ifneq (${AARCH32_SP},none)
752 # We expect to locate an sp.mk under the specified AARCH32_SP directory
753 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000754
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100755 ifeq (${AARCH32_SP_MAKE},)
756 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
757 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500758 $(info Including ${AARCH32_SP_MAKE})
759 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100760 endif
761endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800762
763################################################################################
764# Include libc if not overridden
765################################################################################
766ifeq (${OVERRIDE_LIBC},0)
767include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000768endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100769
770################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100771# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000772################################################################################
773
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100774# USE_DEBUGFS experimental feature recommended only in debug builds
775ifeq (${USE_DEBUGFS},1)
776 ifeq (${DEBUG},1)
777 $(warning DEBUGFS experimental feature is enabled.)
778 else
779 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800780 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100781endif #(USE_DEBUGFS)
782
783# USE_SPINLOCK_CAS requires AArch64 build
784ifeq (${USE_SPINLOCK_CAS},1)
785 ifneq (${ARCH},aarch64)
786 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800787 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100788endif #(USE_SPINLOCK_CAS)
789
790# The cert_create tool cannot generate certificates individually, so we use the
791# target 'certificates' to create them all
792ifneq (${GENERATE_COT},0)
793 FIP_DEPS += certificates
794 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000795endif
796
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100797ifneq (${DECRYPTION_SUPPORT},none)
798 ENC_ARGS += -f ${FW_ENC_STATUS}
799 ENC_ARGS += -k ${ENC_KEY}
800 ENC_ARGS += -n ${ENC_NONCE}
801 FIP_DEPS += enctool
802 FWU_FIP_DEPS += enctool
803endif #(DECRYPTION_SUPPORT)
804
805ifdef EL3_PAYLOAD_BASE
806 ifdef PRELOADED_BL33_BASE
807 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
808 incompatible build options. EL3_PAYLOAD_BASE has priority.")
809 endif
810 ifneq (${GENERATE_COT},0)
811 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
812 build options.")
813 endif
814 ifneq (${TRUSTED_BOARD_BOOT},0)
815 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
816 incompatible \ build options.")
817 endif
818endif #(EL3_PAYLOAD_BASE)
819
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000820ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100821 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000822 $(warning "BL33 image is not needed when option \
823 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100824 endif
825 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100826 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100827 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
828 endif
829endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000830
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000831# When building for systems with hardware-assisted coherency, there's no need to
832# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
833ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100834 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000835endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100836
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600837#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
838ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100839 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000840endif
841
Manish Pandeyd419e222023-02-13 12:39:17 +0000842# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100843ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100844 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100845 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000846endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100847
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100848
Manish Pandeyd419e222023-02-13 12:39:17 +0000849# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000850ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100851 ifeq ($(ENABLE_FEAT_RAS),0)
852 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
853 endif
854endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000855
Roberto Vargas025946a2018-09-24 17:20:48 +0100856# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100857ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100858 ifeq (${TRUSTED_BOARD_BOOT}, 0)
859 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
860 to be set.")
861 endif
862endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100863
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100864ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
865# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100866 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100867else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
868# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100869 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100870else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
871# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100872 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100873else ifeq (${TRUSTED_BOARD_BOOT},1)
874# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100875 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000876else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100877 CRYPTO_SUPPORT := 0
878endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000879
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100880# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
881ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100882 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100883endif
884
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000885# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100886# registers associated to it are also saved and restored.
887# 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 +0000888ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100889 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
890 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
891 endif
892endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100893
894ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100895 ifneq (${ARCH},aarch64)
896 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
897 endif
898endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000899
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000900ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100901 $(info FEATURE_DETECTION is an experimental feature)
902endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000903
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000904ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100905 ifeq (${ENABLE_SME_FOR_NS}, 0)
906 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
907 to be set")
908 $(warning "Forced ENABLE_SME_FOR_NS=1")
909 override ENABLE_SME_FOR_NS := 1
910 endif
911endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000912
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000913ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100914 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
915 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
916 library v2")
917 endif
918endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000919
Sumit Garg392e4df2019-11-15 10:43:00 +0530920ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100921 ifeq (${TRUSTED_BOARD_BOOT}, 0)
922 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
923 to be set)
924 endif
925endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530926
johpow0181865962022-01-28 17:06:20 -0600927# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500928ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600929
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100930 # SME/SVE only supported on AArch64
931 ifneq (${ENABLE_SME_FOR_NS},0)
932 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
933 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000934
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100935 ifeq (${ENABLE_SVE_FOR_NS},1)
936 # Warning instead of error due to CI dependency on this
937 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
938 endif
johpow0181865962022-01-28 17:06:20 -0600939
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100940 # BRBE is not supported in AArch32
941 ifeq (${ENABLE_BRBE_FOR_NS},1)
942 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
943 endif
johpow0181865962022-01-28 17:06:20 -0600944
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100945 # FEAT_RNG_TRAP is not supported in AArch32
946 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
947 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
948 endif
949endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500950
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000951ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100952 ifeq (${ENABLE_SVE_FOR_NS},0)
953 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
954 endif
955endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000956
johpow019baade32021-07-08 14:14:00 -0500957# Secure SME/SVE requires the non-secure component as well
958ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100959 ifeq (${ENABLE_SME_FOR_NS},0)
960 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
961 endif
962 ifeq (${ENABLE_SVE_FOR_SWD},0)
963 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
964 endif
965endif #(ENABLE_SME_FOR_SWD)
966
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500967# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
968# mechanism.
johpow019baade32021-07-08 14:14:00 -0500969ifeq (${ENABLE_SVE_FOR_SWD},1)
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500970 ifeq (${ENABLE_SVE_FOR_NS},0)
971 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
972 endif
973endif
johpow019baade32021-07-08 14:14:00 -0500974
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500975# Enabling SVE for both the worlds typically requires the context
976# management of SVE registers. The only exception being SPMC at S-EL2.
977ifeq (${ENABLE_SVE_FOR_SWD}, 1)
978 ifneq (${ENABLE_SVE_FOR_NS}, 0)
979 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
980 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
981 endif
982 endif
983endif
984
985# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
986# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
987# and SVE registers.
988ifeq (${CTX_INCLUDE_FPREGS}, 1)
989 ifneq (${ENABLE_SVE_FOR_NS},0)
990 ifeq (${CTX_INCLUDE_SVE_REGS},0)
991 # Warning instead of error due to CI dependency on this
992 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
993 $(warning "Forced ENABLE_SVE_FOR_NS=0")
994 override ENABLE_SVE_FOR_NS := 0
995 endif
996 endif
997endif #(CTX_INCLUDE_FPREGS)
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000998
Madhukar Pappireddy7ff1be82024-06-17 15:28:33 -0500999# SVE context management is only required if secure world has access to SVE/FP
1000# functionality.
1001ifeq (${CTX_INCLUDE_SVE_REGS},1)
1002 ifeq (${ENABLE_SVE_FOR_SWD},0)
1003 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
1004 endif
1005endif
1006
1007# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
1008# management including FPU registers.
1009ifeq (${CTX_INCLUDE_FPREGS},1)
1010 ifneq (${ENABLE_SME_FOR_NS},0)
1011 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1012 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001013endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001014
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001015ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001016 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001017endif
1018
Raymond Mao98983392023-07-25 07:53:35 -07001019ifeq (${TRANSFER_LIST},1)
1020 $(info TRANSFER_LIST is an experimental feature)
1021endif
1022
Chris Kayd02c2312022-09-29 16:21:24 +01001023ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001024 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1025 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1026 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001027endif
1028
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001029ifeq ($(PSA_CRYPTO),1)
1030 $(info PSA_CRYPTO is an experimental feature)
1031endif
1032
Manish V Badarkhed8d7d932024-05-09 12:14:13 +01001033ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
1034 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
1035endif
1036
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001037################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001038# Process platform overrideable behaviour
1039################################################################################
1040
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001041ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001042 NEED_BL1 := yes
1043endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001044
Jon Medhurst66573cb2014-02-13 15:19:28 +00001045ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001046 NEED_BL2 := yes
1047
1048 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1049 # Certificate generation tools. This flag can be overridden by the platform.
1050 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001051 # If booting an EL3 payload there is no need for a BL33 image
1052 # in the FIP file.
1053 NEED_BL33 := no
1054 else
1055 ifdef PRELOADED_BL33_BASE
1056 # If booting a BL33 preloaded image there is no need of
1057 # another one in the FIP file.
1058 NEED_BL33 := no
1059 else
1060 NEED_BL33 ?= yes
1061 endif
1062 endif
1063endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001064
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001065ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001066 NEED_BL2U := yes
1067endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001068
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001069# If SCP_BL2 is given, we always want FIP to include it.
1070ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001071 NEED_SCP_BL2 := yes
1072endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001073
Soby Mathewbf169232017-11-14 14:10:10 +00001074# For AArch32, BL31 is not currently supported.
1075ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001076 ifdef BL31_SOURCES
1077 # When booting an EL3 payload, there is no need to compile the BL31
1078 # image nor put it in the FIP.
1079 ifndef EL3_PAYLOAD_BASE
1080 NEED_BL31 := yes
1081 endif
1082 endif
1083endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001084
Juan Castilloa3487d12015-08-18 14:23:04 +01001085# Process TBB related flags
1086ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001087 # Common cert_create options
1088 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001089 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001090 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001091 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001092 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001093 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001094 endif
1095 endif
1096 # Include TBBR makefile (unless the platform indicates otherwise)
1097 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001098 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001099 endif
1100endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001101
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001102ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001103 FIP_ARGS += --align ${FIP_ALIGN}
1104endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001105
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001106ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001107 NEED_FDT := yes
1108endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001109
Juan Castilloa3487d12015-08-18 14:23:04 +01001110################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001111# Include libraries' Makefile that are used in all BL
1112################################################################################
1113
1114include lib/stack_protector/stack_protector.mk
1115
1116################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001117# Include BL specific makefiles
1118################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001119
1120ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001121include bl1/bl1.mk
1122endif
1123
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001124ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001125include bl2/bl2.mk
1126endif
1127
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001128ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001129include bl2u/bl2u.mk
1130endif
1131
Soby Mathewbf169232017-11-14 14:10:10 +00001132ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001133include bl31/bl31.mk
1134endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001135
Soby Mathew574e01e2017-02-14 10:05:07 +00001136################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001137# Build options checks
1138################################################################################
1139
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001140# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001141$(eval $(call assert_booleans,\
1142 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001143 ALLOW_RO_XLAT_TABLES \
1144 BL2_ENABLE_SP_LOAD \
1145 COLD_BOOT_SINGLE_CPU \
1146 CREATE_KEYS \
1147 CTX_INCLUDE_AARCH32_REGS \
1148 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001149 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001150 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001151 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001152 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001153 DYN_DISABLE_AUTH \
1154 EL3_EXCEPTION_HANDLING \
1155 ENABLE_AMU_AUXILIARY_COUNTERS \
1156 ENABLE_AMU_FCONF \
1157 AMU_RESTRICT_COUNTERS \
1158 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001159 ENABLE_PIE \
1160 ENABLE_PMF \
1161 ENABLE_PSCI_STAT \
1162 ENABLE_RUNTIME_INSTRUMENTATION \
1163 ENABLE_SME_FOR_SWD \
1164 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001165 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001166 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001167 ERROR_DEPRECATED \
1168 FAULT_INJECTION_SUPPORT \
1169 GENERATE_COT \
1170 GICV2_G0_FOR_EL3 \
1171 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001172 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001173 HW_ASSISTED_COHERENCY \
1174 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001175 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001176 DRTM_SUPPORT \
1177 NS_TIMER_SWITCH \
1178 OVERRIDE_LIBC \
1179 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001180 PROGRAMMABLE_RESET_ADDRESS \
1181 PSCI_EXTENDED_STATE_ID \
1182 PSCI_OS_INIT_MODE \
1183 RESET_TO_BL31 \
1184 SAVE_KEYS \
1185 SEPARATE_CODE_AND_RODATA \
1186 SEPARATE_BL2_NOLOAD_REGION \
1187 SEPARATE_NOBITS_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001188 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001189 SPIN_ON_BL1_EXIT \
1190 SPM_MM \
1191 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001192 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001193 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001194 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001195 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001196 TRUSTED_BOARD_BOOT \
1197 USE_COHERENT_MEM \
1198 USE_DEBUGFS \
1199 ARM_IO_IN_DTB \
1200 SDEI_IN_FCONF \
1201 SEC_INT_DESC_IN_FCONF \
1202 USE_ROMLIB \
1203 USE_TBBR_DEFS \
1204 WARMBOOT_ENABLE_DCACHE_EARLY \
1205 RESET_TO_BL2 \
1206 BL2_IN_XIP_MEM \
1207 BL2_INV_DCACHE \
1208 USE_SPINLOCK_CAS \
1209 ENCRYPT_BL31 \
1210 ENCRYPT_BL32 \
1211 ERRATA_SPECULATIVE_AT \
1212 RAS_TRAP_NS_ERR_REC_ACCESS \
1213 COT_DESC_IN_DTB \
1214 USE_SP804_TIMER \
1215 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301216 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001217 ENABLE_MPMM \
1218 ENABLE_MPMM_FCONF \
1219 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001220 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001221 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001222 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001223 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001224 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001225 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001226 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001227 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001228 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001229 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001230)))
Dan Handley81be1002015-03-27 17:44:35 +00001231
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001232# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001233$(eval $(call assert_numerics,\
1234 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001235 ARM_ARCH_MAJOR \
1236 ARM_ARCH_MINOR \
1237 BRANCH_PROTECTION \
1238 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001239 CTX_INCLUDE_NEVE_REGS \
1240 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001241 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001242 ENABLE_BRBE_FOR_NS \
1243 ENABLE_TRBE_FOR_NS \
1244 ENABLE_BTI \
1245 ENABLE_PAUTH \
1246 ENABLE_FEAT_AMU \
1247 ENABLE_FEAT_AMUv1p1 \
1248 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001249 ENABLE_FEAT_CSV2_3 \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001250 ENABLE_FEAT_DEBUGV8P9 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001251 ENABLE_FEAT_DIT \
1252 ENABLE_FEAT_ECV \
1253 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001254 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001255 ENABLE_FEAT_HCX \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001256 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001257 ENABLE_FEAT_PAN \
1258 ENABLE_FEAT_RNG \
1259 ENABLE_FEAT_RNG_TRAP \
1260 ENABLE_FEAT_SEL2 \
1261 ENABLE_FEAT_TCR2 \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001262 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001263 ENABLE_FEAT_S2PIE \
1264 ENABLE_FEAT_S1PIE \
1265 ENABLE_FEAT_S2POE \
1266 ENABLE_FEAT_S1POE \
1267 ENABLE_FEAT_GCS \
1268 ENABLE_FEAT_VHE \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001269 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001270 ENABLE_RME \
1271 ENABLE_SPE_FOR_NS \
1272 ENABLE_SYS_REG_TRACE_FOR_NS \
1273 ENABLE_SME_FOR_NS \
1274 ENABLE_SME2_FOR_NS \
1275 ENABLE_SVE_FOR_NS \
1276 ENABLE_TRF_FOR_NS \
1277 FW_ENC_STATUS \
1278 NR_OF_FW_BANKS \
1279 NR_OF_IMAGES_IN_FW_BANK \
1280 TWED_DELAY \
1281 ENABLE_FEAT_TWED \
1282 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001283 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001284)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001285
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001286ifdef KEY_SIZE
1287 $(eval $(call assert_numeric,KEY_SIZE))
1288endif
1289
Justin Chadwell83e04882019-08-20 11:01:52 +01001290ifeq ($(filter $(SANITIZE_UB), on off trap),)
1291 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1292endif
1293
Juan Castilloa3487d12015-08-18 14:23:04 +01001294################################################################################
1295# Add definitions to the cpp preprocessor based on the current build options.
1296# This is done after including the platform specific makefile to allow the
1297# platform to overwrite the default options
1298################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001299
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001300$(eval $(call add_defines,\
1301 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001302 ALLOW_RO_XLAT_TABLES \
1303 ARM_ARCH_MAJOR \
1304 ARM_ARCH_MINOR \
1305 BL2_ENABLE_SP_LOAD \
1306 COLD_BOOT_SINGLE_CPU \
1307 CTX_INCLUDE_AARCH32_REGS \
1308 CTX_INCLUDE_FPREGS \
Madhukar Pappireddydd9af9b2024-06-17 15:17:03 -05001309 CTX_INCLUDE_SVE_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001310 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001311 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001312 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001313 CTX_INCLUDE_EL2_REGS \
1314 CTX_INCLUDE_NEVE_REGS \
1315 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1316 DISABLE_MTPMU \
1317 ENABLE_FEAT_AMU \
1318 ENABLE_AMU_AUXILIARY_COUNTERS \
1319 ENABLE_AMU_FCONF \
1320 AMU_RESTRICT_COUNTERS \
1321 ENABLE_ASSERTIONS \
1322 ENABLE_BTI \
Arvind Ram Prakash05b47632024-05-22 15:24:00 -05001323 ENABLE_FEAT_DEBUGV8P9 \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001324 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001325 ENABLE_PAUTH \
1326 ENABLE_PIE \
1327 ENABLE_PMF \
1328 ENABLE_PSCI_STAT \
1329 ENABLE_RME \
1330 ENABLE_RUNTIME_INSTRUMENTATION \
1331 ENABLE_SME_FOR_NS \
1332 ENABLE_SME2_FOR_NS \
1333 ENABLE_SME_FOR_SWD \
1334 ENABLE_SPE_FOR_NS \
1335 ENABLE_SVE_FOR_NS \
1336 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001337 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001338 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001339 ENCRYPT_BL31 \
1340 ENCRYPT_BL32 \
1341 ERROR_DEPRECATED \
1342 FAULT_INJECTION_SUPPORT \
1343 GICV2_G0_FOR_EL3 \
1344 HANDLE_EA_EL3_FIRST_NS \
1345 HW_ASSISTED_COHERENCY \
1346 LOG_LEVEL \
1347 MEASURED_BOOT \
Tamas Bana4260892023-06-07 13:35:04 +02001348 DICE_PROTECTION_ENVIRONMENT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001349 DRTM_SUPPORT \
1350 NS_TIMER_SWITCH \
1351 PL011_GENERIC_UART \
1352 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001353 PROGRAMMABLE_RESET_ADDRESS \
1354 PSCI_EXTENDED_STATE_ID \
1355 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001356 RESET_TO_BL31 \
AlexeiFedorovc0ca2d72024-05-13 15:35:54 +01001357 RME_GPT_BITLOCK_BLOCK \
AlexeiFedorovbd8b1bb2024-03-13 17:07:03 +00001358 RME_GPT_MAX_BLOCK \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001359 SEPARATE_CODE_AND_RODATA \
1360 SEPARATE_BL2_NOLOAD_REGION \
1361 SEPARATE_NOBITS_REGION \
Madhukar Pappireddy5c1b8d92024-06-17 15:26:00 -05001362 SEPARATE_SIMD_SECTION \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001363 RECLAIM_INIT_CODE \
1364 SPD_${SPD} \
1365 SPIN_ON_BL1_EXIT \
1366 SPM_MM \
1367 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001368 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001369 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001370 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001371 TRUSTED_BOARD_BOOT \
1372 CRYPTO_SUPPORT \
1373 TRNG_SUPPORT \
1374 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001375 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001376 USE_COHERENT_MEM \
1377 USE_DEBUGFS \
1378 ARM_IO_IN_DTB \
1379 SDEI_IN_FCONF \
1380 SEC_INT_DESC_IN_FCONF \
1381 USE_ROMLIB \
1382 USE_TBBR_DEFS \
1383 WARMBOOT_ENABLE_DCACHE_EARLY \
1384 RESET_TO_BL2 \
1385 BL2_RUNS_AT_EL3 \
1386 BL2_IN_XIP_MEM \
1387 BL2_INV_DCACHE \
1388 USE_SPINLOCK_CAS \
1389 ERRATA_SPECULATIVE_AT \
1390 RAS_TRAP_NS_ERR_REC_ACCESS \
1391 COT_DESC_IN_DTB \
1392 USE_SP804_TIMER \
1393 ENABLE_FEAT_RNG \
1394 ENABLE_FEAT_RNG_TRAP \
1395 ENABLE_FEAT_SB \
1396 ENABLE_FEAT_DIT \
1397 NR_OF_FW_BANKS \
1398 NR_OF_IMAGES_IN_FW_BANK \
1399 PSA_FWU_SUPPORT \
Sughosh Ganu61905e52024-02-01 12:51:20 +05301400 PSA_FWU_METADATA_FW_STORE_DESC \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001401 ENABLE_BRBE_FOR_NS \
1402 ENABLE_TRBE_FOR_NS \
1403 ENABLE_SYS_REG_TRACE_FOR_NS \
1404 ENABLE_TRF_FOR_NS \
1405 ENABLE_FEAT_HCX \
1406 ENABLE_MPMM \
1407 ENABLE_MPMM_FCONF \
1408 ENABLE_FEAT_FGT \
Arvind Ram Prakash62d87e72024-06-06 11:33:37 -05001409 ENABLE_FEAT_FGT2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001410 ENABLE_FEAT_ECV \
1411 ENABLE_FEAT_AMUv1p1 \
1412 ENABLE_FEAT_SEL2 \
1413 ENABLE_FEAT_VHE \
1414 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001415 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001416 ENABLE_FEAT_PAN \
1417 ENABLE_FEAT_TCR2 \
1418 ENABLE_FEAT_S2PIE \
1419 ENABLE_FEAT_S1PIE \
1420 ENABLE_FEAT_S2POE \
1421 ENABLE_FEAT_S1POE \
1422 ENABLE_FEAT_GCS \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001423 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001424 FEATURE_DETECTION \
1425 TWED_DELAY \
1426 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001427 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001428 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001429 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001430 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001431 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001432 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001433 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001434 PLATFORM_REPORT_CTX_MEM_USE \
Yann Gautier5ae29c02024-01-16 19:39:31 +01001435 EARLY_CONSOLE \
Arvind Ram Prakasheaa90192023-12-21 00:25:52 -06001436 PRESERVE_DSU_PMU_REGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001437)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001438
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001439ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1440ifeq (${DEBUG}, 0)
1441 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1442 override PLATFORM_REPORT_CTX_MEM_USE := 0
1443endif
1444endif
1445
Justin Chadwell83e04882019-08-20 11:01:52 +01001446ifeq (${SANITIZE_UB},trap)
1447 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001448endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001449
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001450# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1451ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001452 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1453else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001454# Define the PRELOADED_BL33_BASE flag only if it is provided and
1455# EL3_PAYLOAD_BASE is not defined, as it has priority.
1456 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001457 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001458 endif
1459endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001460
Soby Mathew9fe88042018-03-26 12:43:37 +01001461# Define the DYN_DISABLE_AUTH flag only if set.
1462ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001463 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001464endif
1465
Chris Kaycfba6452023-12-04 09:55:50 +00001466ifeq ($($(ARCH)-ld-id),arm-link)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001467 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001468endif
1469
Manish Pandey3f90ad72020-01-14 11:52:05 +00001470# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001471ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001472ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001473 -include $(BUILD_PLAT)/sp_gen.mk
1474 FIP_DEPS += sp
1475 CRT_DEPS += sp
1476 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001477else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001478 ifeq (${SPMD_SPM_AT_SEL2},1)
1479 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1480 endif
1481endif #(SP_LAYOUT_FILE)
1482endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001483
Juan Castilloa3487d12015-08-18 14:23:04 +01001484################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001485# Build targets
1486################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001487
Harrison Mutai36d971a2024-08-28 13:27:19 +00001488.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool
Juan Castilloa3487d12015-08-18 14:23:04 +01001489.SUFFIXES:
Achin Gupta4f6ad662013-10-25 09:08:21 +01001490
Juan Castilloa3487d12015-08-18 14:23:04 +01001491all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001492
Juan Castilloa3487d12015-08-18 14:23:04 +01001493msg_start:
Chris Kay1870c722024-05-02 17:52:37 +00001494 $(s)echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001495
Soby Mathew18a62042015-10-26 14:29:21 +00001496ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001497# Check if deprecated declarations and cpp warnings should be treated as error or not.
Chris Kaycfba6452023-12-04 09:55:50 +00001498ifneq ($(filter %-clang,$($(ARCH)-cc-id)),)
Varun Wadekar4d034c52019-01-11 14:47:48 -08001499 CPPFLAGS += -Wno-error=deprecated-declarations
1500else
Dan Handley6fa89a22018-02-27 16:03:58 +00001501 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001502endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001503endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001504
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001505$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001506
Juan Castilloa3487d12015-08-18 14:23:04 +01001507# Expand build macros for the different images
1508ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001509BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001510$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001511endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001512
Juan Castilloa3487d12015-08-18 14:23:04 +01001513ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001514
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001515ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001516FIP_BL2_ARGS := tb-fw
1517endif
1518
Chris Kayfb3b0512021-09-28 15:44:37 +01001519BL2_SOURCES := $(sort ${BL2_SOURCES})
1520
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001521$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001522 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001523
1524endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001525
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001526ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001527$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001528endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001529
Juan Castilloa3487d12015-08-18 14:23:04 +01001530ifeq (${NEED_BL31},yes)
1531BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001532# Sort BL31 source files to remove duplicates
1533BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301534ifneq (${DECRYPTION_SUPPORT},none)
1535$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001536 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301537else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001538$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001539 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001540endif #(DECRYPTION_SUPPORT)
1541endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001542
Juan Castillo671b8db2015-11-12 10:59:26 +00001543# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001544# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001545# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001546ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001547# Sort BL32 source files to remove duplicates
1548BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001549BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1550
Sumit Gargeec52442019-11-14 16:33:45 +05301551ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001552$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301553 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1554else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001555$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001556 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001557endif #(DECRYPTION_SUPPORT)
1558endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001559
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001560# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1561# needs to be built from RMM_SOURCES.
1562ifeq (${NEED_RMM},yes)
1563# Sort RMM source files to remove duplicates
1564RMM_SOURCES := $(sort ${RMM_SOURCES})
1565BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1566
1567$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001568 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1569endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001570
Juan Castilloa3487d12015-08-18 14:23:04 +01001571# Add the BL33 image if required by the platform
1572ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001573$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001574endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001575
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001576ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001577$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001578 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001579endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001580
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001581# Expand build macros for the different images
1582ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001583 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001584endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001585
Manish Pandey3f90ad72020-01-14 11:52:05 +00001586# Add Secure Partition packages
1587ifeq (${NEED_SP_PKG},yes)
Chris Kayd67442e2024-07-30 13:33:56 +00001588$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/
Chris Kay1870c722024-05-02 17:52:37 +00001589 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001590sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Chris Kay1870c722024-05-02 17:52:37 +00001591 $(s)echo
1592 $(s)echo "Built SP Images successfully"
1593 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001594endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001595
Ian Spray36eaaf32014-01-30 17:25:28 +00001596locate-checkpatch:
1597ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001598 $(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 +00001599else
1600ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001601 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001602endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001603endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001604
Achin Gupta4f6ad662013-10-25 09:08:21 +01001605clean:
Chris Kay1870c722024-05-02 17:52:37 +00001606 $(s)echo " CLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001607 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001608ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001609 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001610else
1611# Clear the MAKEFLAGS as we do not want
1612# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001613 $(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 +01001614endif #(UNIX_MK)
Chris Kay1870c722024-05-02 17:52:37 +00001615 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
1616 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
1617 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001618
James Morrisseyeaaeece2013-11-01 13:56:59 +00001619realclean distclean:
Chris Kay1870c722024-05-02 17:52:37 +00001620 $(s)echo " REALCLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001621 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1622 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
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)) realclean
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} realclean
1631 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
1632 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001633
Ian Spray36eaaf32014-01-30 17:25:28 +00001634checkcodebase: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001635 $(s)echo " CHECKING STYLE"
1636 $(q)if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001637 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001638 while read GIT_FILE ; \
1639 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1640 done ; \
1641 else \
1642 find . -type f -not -iwholename "*.git*" \
1643 -not -iwholename "*build*" \
1644 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001645 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001646 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001647 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001648 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1649 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001650
1651checkpatch: locate-checkpatch
Chris Kay1870c722024-05-02 17:52:37 +00001652 $(s)echo " CHECKING STYLE"
1653 $(q)if test -n "${CHECKPATCH_OPTS}"; then \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001654 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1655 fi
Chris Kay1870c722024-05-02 17:52:37 +00001656 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001657 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1658 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001659 printf "\n[*] Checking style of '$$commit'\n\n"; \
Yann Gautierfaf8c612024-08-09 11:52:03 +02001660 ( git log --format=email "$$commit~..$$commit" \
1661 -- ${CHECK_PATHS} ; \
1662 git diff --format=email "$$commit~..$$commit" \
1663 -- ${CHECK_PATHS}; ) | \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001664 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001665 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001666
1667certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001668
Pali Rohár54ff2132020-11-24 15:38:08 +01001669${CRTTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001670 $(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
1671 $(s)echo
1672 $(s)echo "Built $@ successfully"
1673 $(s)echo
Jon Medhurst407a95c2014-02-12 15:54:48 +00001674
Juan Castillo11abdcd2014-10-21 11:30:42 +01001675ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001676certificates: ${CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001677 $(q)${CRTTOOL} ${CRT_ARGS}
1678 $(s)echo
1679 $(s)echo "Built $@ successfully"
1680 $(s)echo "Certificates can be found in ${BUILD_PLAT}"
1681 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001682endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001683
Juan Castilloa3487d12015-08-18 14:23:04 +01001684${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001685 $(eval ${CHECK_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001686 $(q)${FIPTOOL} create ${FIP_ARGS} $@
1687 $(q)${FIPTOOL} info $@
1688 $(s)echo
1689 $(s)echo "Built $@ successfully"
1690 $(s)echo
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001691
Yatharth Kochard1a93432015-10-12 12:33:47 +01001692ifneq (${GENERATE_COT},0)
1693fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
Chris Kay1870c722024-05-02 17:52:37 +00001694 $(q)${CRTTOOL} ${FWU_CRT_ARGS}
1695 $(s)echo
1696 $(s)echo "Built $@ successfully"
1697 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}"
1698 $(s)echo
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001699endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001700
1701${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001702 $(eval ${CHECK_FWU_FIP_CMD})
Chris Kay1870c722024-05-02 17:52:37 +00001703 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@
1704 $(q)${FIPTOOL} info $@
1705 $(s)echo
1706 $(s)echo "Built $@ successfully"
1707 $(s)echo
Yatharth Kochard1a93432015-10-12 12:33:47 +01001708
Juan Castilloa3487d12015-08-18 14:23:04 +01001709fiptool: ${FIPTOOL}
1710fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001711fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001712
Pali Rohár54ff2132020-11-24 15:38:08 +01001713${FIPTOOL}: FORCE
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001714ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001715 $(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 +01001716else
1717# Clear the MAKEFLAGS as we do not want
1718# to pass the gnumake flags to nmake.
Chris Kay1870c722024-05-02 17:52:37 +00001719 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001720endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001721
Pali Rohár54ff2132020-11-24 15:38:08 +01001722romlib.bin: libraries FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001723 $(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 +01001724
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001725memmap: all
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001726ifdef UNIX_MK
Chris Kay1870c722024-05-02 17:52:37 +00001727 $(q)PYTHONPATH=${CURDIR}/tools/memory \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001728 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1729else
Chris Kay1870c722024-05-02 17:52:37 +00001730 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001731 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1732endif
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001733
Harrison Mutai36d971a2024-08-28 13:27:19 +00001734tl: ${BUILD_PLAT}/tl.bin
1735${BUILD_PLAT}/tl.bin: ${HW_CONFIG}
Chris Kaya152e752024-09-26 14:18:04 +00001736 $(if $(host-poetry),$(q)poetry -q install)
1737 $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@
Harrison Mutai36d971a2024-08-28 13:27:19 +00001738
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001739doc:
Chris Kay1870c722024-05-02 17:52:37 +00001740 $(s)echo " BUILD DOCUMENTATION"
1741 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001742
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301743enctool: ${ENCTOOL}
1744
Pali Rohár54ff2132020-11-24 15:38:08 +01001745${ENCTOOL}: FORCE
Chris Kay1870c722024-05-02 17:52:37 +00001746 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all
1747 $(s)echo
1748 $(s)echo "Built $@ successfully"
1749 $(s)echo
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301750
Joakim Bech35fab8c2014-01-23 14:51:49 +01001751cscope:
Chris Kay1870c722024-05-02 17:52:37 +00001752 $(s)echo " CSCOPE"
1753 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files
1754 $(q)cscope -b -q -k
Joakim Bech35fab8c2014-01-23 14:51:49 +01001755
Ryan Harkin72ee3312014-01-15 16:55:07 +00001756help:
Chris Kay1870c722024-05-02 17:52:37 +00001757 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
1758 $(s)echo ""
1759 $(s)echo "PLAT is used to specify which platform you wish to build."
1760 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
1761 $(s)echo ""
1762 $(s)echo "platform = ${PLATFORM_LIST}"
1763 $(s)echo ""
1764 $(s)echo "Please refer to the User Guide for a list of all supported options."
1765 $(s)echo "Note that the build system doesn't track dependencies for build "
1766 $(s)echo "options. Therefore, if any of the build options are changed "
1767 $(s)echo "from a previous build, a clean build must be performed."
1768 $(s)echo ""
1769 $(s)echo "Supported Targets:"
1770 $(s)echo " all Build all individual bootloader binaries"
1771 $(s)echo " bl1 Build the BL1 binary"
1772 $(s)echo " bl2 Build the BL2 binary"
1773 $(s)echo " bl2u Build the BL2U binary"
1774 $(s)echo " bl31 Build the BL31 binary"
1775 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1776 $(s)echo " this builds secure payload specified by AARCH32_SP"
1777 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
1778 $(s)echo " fip Build the Firmware Image Package (FIP)"
1779 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
1780 $(s)echo " checkcodebase Check the coding style of the entire source tree"
1781 $(s)echo " checkpatch Check the coding style on changes in the current"
1782 $(s)echo " branch against BASE_COMMIT (default origin/master)"
1783 $(s)echo " clean Clean the build for the selected platform"
1784 $(s)echo " cscope Generate cscope index"
1785 $(s)echo " distclean Remove all build artifacts for all platforms"
1786 $(s)echo " certtool Build the Certificate generation tool"
1787 $(s)echo " enctool Build the Firmware encryption tool"
1788 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool"
1789 $(s)echo " sp Build the Secure Partition Packages"
1790 $(s)echo " sptool Build the Secure Partition Package creation tool"
1791 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)"
1792 $(s)echo " memmap Print the memory map of the built binaries"
1793 $(s)echo " doc Build html based documentation using Sphinx tool"
1794 $(s)echo ""
1795 $(s)echo "Note: most build targets require PLAT to be set to a specific platform."
1796 $(s)echo ""
1797 $(s)echo "example: build all targets for the FVP platform:"
1798 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001799
1800.PHONY: FORCE
1801FORCE:;