blob: fa68215b611f1d46ecc99e5825e40ed207f8f1f0 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Maksims Svecovs01cf14d2023-02-02 16:10:22 +00002# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-arm82cb2c12017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharane35c4042014-05-15 14:40:58 +01007#
Juan Castilloaaa3e722014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathew1a0f1122018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Manish V Badarkhe98735802023-11-21 14:35:13 +000011VERSION_MINOR := 10
Yann Gautier822bfa32024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
Release CIc1e80682025-04-18 16:12:01 +000013VERSION_PATCH := 15
Yann Gautier055ebec2023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castilloaaa3e722014-06-30 11:41:46 +010015
Juan Castillo88154672015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard72fc70e2016-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 Lloyd231c1472015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000026include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Juan Castillo73c99d42015-08-18 14:23:04 +010027
28################################################################################
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010029# Default values for build configurations, and their dependencies
Juan Castillo73c99d42015-08-18 14:23:04 +010030################################################################################
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010031
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010032include ${MAKE_HELPERS_DIRECTORY}defaults.mk
dp-arm872be882016-09-19 11:18:44 +010033
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010034# Assertions enabled for DEBUG builds by default
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010035ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010036ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
37PLAT := ${DEFAULT_PLAT}
Juan Castillo73c99d42015-08-18 14:23:04 +010038
39################################################################################
40# Checkpatch script options
41################################################################################
42
Sandrine Bailleuxf6077392016-06-02 11:19:59 +010043CHECKCODE_ARGS := --no-patch
Dan Handleyf0b489c2016-06-02 17:15:13 +010044# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030045INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
46 include/drivers/arm, \
47 $(wildcard include/drivers/*)))
Dan Handleyf0b489c2016-06-02 17:15:13 +010048INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley1a41e8c2016-06-02 18:21:02 +010049 include/lib/libfdt \
Roberto Vargas61f72a32018-05-08 10:27:10 +010050 include/lib/libc, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010051 $(wildcard include/lib/*)))
52INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030053 include/lib \
54 include/drivers, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010055 $(wildcard include/*)))
56LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-armd801fbb2017-05-04 12:15:35 +010057 lib/compiler-rt \
Antonio Nino Diaz55cdcf72017-01-16 17:20:45 +000058 lib/libfdt% \
Roberto Vargas61f72a32018-05-08 10:27:10 +010059 lib/libc, \
Daniel Boulbya1942552022-10-05 11:05:22 +010060 lib/zlib \
Dan Handleyf0b489c2016-06-02 17:15:13 +010061 $(wildcard lib/*)))
62ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
63 lib \
64 include \
65 docs \
Paul Beesley1ef35512019-03-07 16:42:31 +000066 %.rst, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010067 $(wildcard *)))
68CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
69 ${INC_DIRS_TO_CHECK} \
70 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030071 ${LIB_DIRS_TO_CHECK} \
72 ${INC_DRV_DIRS_TO_CHECK} \
73 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000074
Juan Castillo73c99d42015-08-18 14:23:04 +010075################################################################################
76# Process build options
77################################################################################
78
79# Verbose flag
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010080ifeq (${V},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010081 Q:=@
82 ECHO:=@echo
83 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010084else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010085 Q:=
86 ECHO:=$(ECHO_QUIET)
Achin Gupta4f6ad662013-10-25 09:08:21 +010087endif
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010088
89ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010090 Q:=@
91 ECHO:=$(ECHO_QUIET)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010092endif
93
94export Q ECHO
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000095
Juan Castillo73c99d42015-08-18 14:23:04 +010096################################################################################
97# Toolchain
98################################################################################
99
dp-arm72610c42017-05-02 11:09:11 +0100100HOSTCC := gcc
101export HOSTCC
102
Juan Castillo73c99d42015-08-18 14:23:04 +0100103CC := ${CROSS_COMPILE}gcc
104CPP := ${CROSS_COMPILE}cpp
105AS := ${CROSS_COMPILE}gcc
106AR := ${CROSS_COMPILE}ar
Roberto Vargas2adee762018-04-13 14:26:47 +0100107LINKER := ${CROSS_COMPILE}ld
Juan Castillo73c99d42015-08-18 14:23:04 +0100108OC := ${CROSS_COMPILE}objcopy
109OD := ${CROSS_COMPILE}objdump
110NM := ${CROSS_COMPILE}nm
111PP := ${CROSS_COMPILE}gcc -E
Soby Mathew38c14d82017-12-14 17:44:56 +0000112DTC := dtc
Juan Castillo73c99d42015-08-18 14:23:04 +0100113
Julius Wernerb25a5772018-01-10 15:12:47 -0800114# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
115ifneq ($(strip $(wildcard ${LD}.bfd) \
Roberto Vargas2adee762018-04-13 14:26:47 +0100116 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
117LINKER := ${LINKER}.bfd
Julius Wernerb25a5772018-01-10 15:12:47 -0800118endif
119
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100120################################################################################
121# Auxiliary tools (fiptool, cert_create, etc)
122################################################################################
123
124# Variables for use with Certificate Generation Tool
125CRTTOOLPATH ?= tools/cert_create
126CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
127
128# Variables for use with Firmware Encryption Tool
129ENCTOOLPATH ?= tools/encrypt_fw
130ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
131
132# Variables for use with Firmware Image Package
133FIPTOOLPATH ?= tools/fiptool
134FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
135
136# Variables for use with sptool
137SPTOOLPATH ?= tools/sptool
138SPTOOL ?= ${SPTOOLPATH}/sptool.py
139SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakin20629b32023-02-14 11:56:02 +0000140SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100141
142# Variables for use with ROMLIB
143ROMLIBPATH ?= lib/romlib
144
145# Variable for use with Python
146PYTHON ?= python3
147
148# Variables for use with documentation build using Sphinx tool
149DOCS_PATH ?= docs
150
151################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100152# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
153################################################################################
Etienne Carriere26e63c42017-11-08 13:48:40 +0100154ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100155 target32-directive = -target arm-none-eabi
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500156# Will set march-directive from platform configuration
Etienne Carriere26e63c42017-11-08 13:48:40 +0100157else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100158 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100159endif #(ARM_ARCH_MAJOR)
160
161################################################################################
162# Get Architecture Feature Modifiers
163################################################################################
164arch-features = ${ARM_ARCH_FEATURE}
165
originc8a992f2022-01-19 16:30:14 +0000166ifneq ($(findstring clang,$(notdir $(CC))),)
167 ifneq ($(findstring armclang,$(notdir $(CC))),)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500168 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
169 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originc8a992f2022-01-19 16:30:14 +0000170 LD := $(LINKER)
171 else
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500172 TF_CFLAGS_aarch32 = $(target32-directive)
173 TF_CFLAGS_aarch64 := -target aarch64-elf
originc8a992f2022-01-19 16:30:14 +0000174 LD := $(shell $(CC) --print-prog-name ld.lld)
175
176 AR := $(shell $(CC) --print-prog-name llvm-ar)
177 OD := $(shell $(CC) --print-prog-name llvm-objdump)
178 OC := $(shell $(CC) --print-prog-name llvm-objcopy)
179 endif
180
181 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
182 PP := $(CC) -E $(TF_CFLAGS_$(ARCH))
183 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600184else ifneq ($(findstring gcc,$(notdir $(CC))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100185 ifeq ($(ENABLE_LTO),1)
186 # Enable LTO only for aarch64
187 ifeq (${ARCH},aarch64)
188 LTO_CFLAGS = -flto
189 # Use gcc as a wrapper for the ld, recommended for LTO
190 LINKER := ${CROSS_COMPILE}gcc
191 endif
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600192 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100193 LD = $(LINKER)
dp-armd5461852017-05-02 12:00:08 +0100194else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100195 LD = $(LINKER)
196endif #(clang)
dp-armd5461852017-05-02 12:00:08 +0100197
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100198# Process Debug flag
199$(eval $(call add_define,DEBUG))
200ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100201 BUILD_TYPE := debug
202 TF_CFLAGS += -g -gdwarf-4
203 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100204
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100205 # Use LOG_LEVEL_INFO by default for debug builds
206 LOG_LEVEL := 40
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100207else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100208 BUILD_TYPE := release
209 # Use LOG_LEVEL_NOTICE by default for release builds
210 LOG_LEVEL := 20
211endif #(Debug)
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100212
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800213# Default build string (git branch and commit)
214ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100215 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800216endif
laurenw-armdddf4282022-07-12 10:12:05 -0500217VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800218
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100219ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100220 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100221else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100222 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100223else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100224 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
225endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100226
Sandrine Bailleuxa9c4dde2018-07-03 09:14:45 +0200227TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-armd5461852017-05-02 12:00:08 +0100228TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathew9d29c222016-05-05 14:33:33 +0100229
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100230##############################################################################
231# WARNINGS Configuration
232###############################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100233# General warnings
234WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier34b508b2021-05-20 13:18:14 +0200235 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000236 -Wredundant-decls
237# stricter warnings
238WARNINGS += -Wextra -Wno-trigraphs
239# too verbose for generic build
240WARNINGS += -Wno-missing-field-initializers \
241 -Wno-type-limits -Wno-sign-compare \
242# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
243WARNINGS += -Wno-unused-parameter
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100244
245# Additional warnings
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000246# Level 1 - infrequent warnings we should have none of
247# full -Wextra
248WARNING1 += -Wsign-compare
249WARNING1 += -Wtype-limits
250WARNING1 += -Wmissing-field-initializers
Yann Gautiere7c645b2018-12-10 18:00:26 +0100251
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000252# Level 2 - problematic warnings that we want
253# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
254# TODO: disable just for them and move into default build
255WARNING2 += -Wold-style-definition
256WARNING2 += -Wmissing-prototypes
257WARNING2 += -Wmissing-format-attribute
258# TF-A aims to comply with this eventually. Effort too large at present
259WARNING2 += -Wundef
Boyan Karatotevd141e632022-11-21 14:49:05 +0000260# currently very involved and many platforms set this off
261WARNING2 += -Wunused-const-variable=2
Yann Gautiere7c645b2018-12-10 18:00:26 +0100262
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000263# Level 3 - very pedantic, frequently ignored
Yann Gautiere7c645b2018-12-10 18:00:26 +0100264WARNING3 := -Wbad-function-cast
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000265WARNING3 += -Waggregate-return
266WARNING3 += -Wnested-externs
267WARNING3 += -Wcast-align
Yann Gautiere7c645b2018-12-10 18:00:26 +0100268WARNING3 += -Wcast-qual
269WARNING3 += -Wconversion
270WARNING3 += -Wpacked
Yann Gautiere7c645b2018-12-10 18:00:26 +0100271WARNING3 += -Wpointer-arith
Yann Gautiere7c645b2018-12-10 18:00:26 +0100272WARNING3 += -Wswitch-default
Yann Gautiere7c645b2018-12-10 18:00:26 +0100273
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000274# Setting W is quite verbose and most warnings will be pre-existing issues
275# outside of the contributor's control. Don't fail the build on them so warnings
276# can be seen and hopefully addressed
277ifdef W
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100278 ifneq (${W},0)
279 E ?= 0
280 endif
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000281endif
282
Yann Gautiere7c645b2018-12-10 18:00:26 +0100283ifeq (${W},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100284 WARNINGS += $(WARNING1)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100285else ifeq (${W},2)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100286 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100287else ifeq (${W},3)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100288 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
289endif #(W)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100290
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100291# Compiler specific warnings
Ambroise Vincent00296572019-05-24 12:47:43 +0100292ifeq ($(findstring clang,$(notdir $(CC))),)
Justin Chadwell93c690e2019-07-03 14:15:56 +0100293# not using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100294WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
295 -Wpacked-bitfield-compat -Wshift-overflow=2 \
296 -Wlogical-op
Govindraj Rajadea23e22023-05-05 09:09:36 -0500297
298# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
299TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
300
Bipin Ravi9cec5492023-09-28 13:17:24 -0500301ifeq ($(HARDEN_SLS), 1)
302 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
303endif
304
Justin Chadwell93c690e2019-07-03 14:15:56 +0100305else
306# using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100307WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
308 -Wlogical-op-parentheses
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100309endif #(Clang Warning)
Ambroise Vincent00296572019-05-24 12:47:43 +0100310
Yann Gautier6336b072018-12-10 18:08:53 +0100311ifneq (${E},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100312 ERRORS := -Werror
313endif #(E)
Yann Gautier6336b072018-12-10 18:08:53 +0100314
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100315################################################################################
316# Compiler and Linker Directives
317################################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100318CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
319 $(ERRORS) $(WARNINGS)
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500320ASFLAGS += $(CPPFLAGS) \
Julius Wernerd5dfdeb2019-07-09 13:49:11 -0700321 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada59de5092016-12-22 12:51:53 +0900322TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Hollandebd6efa2019-10-20 16:11:25 -0500323 -ffunction-sections -fdata-sections \
324 -ffreestanding -fno-builtin -fno-common \
325 -Os -std=gnu99
Juan Castillo73c99d42015-08-18 14:23:04 +0100326
Justin Chadwell1f461972019-08-20 11:01:52 +0100327ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100328 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
329endif #(${SANITIZE_UB},on)
330
Justin Chadwell1f461972019-08-20 11:01:52 +0100331ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100332 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell1f461972019-08-20 11:01:52 +0100333 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100334endif #(${SANITIZE_UB},trap)
Justin Chadwell1f461972019-08-20 11:01:52 +0100335
david cunadof7ec31d2017-11-30 21:58:01 +0000336GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
david cunadof7ec31d2017-11-30 21:58:01 +0000337
Marco Felsch1f49db52022-11-09 12:59:09 +0100338TF_LDFLAGS += -z noexecstack
339
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100340# LD = armlink
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800341ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100342 TF_LDFLAGS += --diag_error=warning --lto_level=O1
343 TF_LDFLAGS += --remove --info=unused,unusedsymbols
344 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100345
346# LD = gcc (used when GCC LTO is enabled)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600347else ifneq ($(findstring gcc,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100348 # Pass ld options with Wl or Xlinker switches
349 TF_LDFLAGS += -Wl,--fatal-warnings -O1
350 TF_LDFLAGS += -Wl,--gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000351
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100352 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
353 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Chris Kayac98b822022-12-22 13:26:37 +0000354
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100355 ifeq ($(ENABLE_LTO),1)
356 ifeq (${ARCH},aarch64)
357 TF_LDFLAGS += -flto -fuse-linker-plugin
358 endif
359 endif #(ENABLE_LTO)
360
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600361# GCC automatically adds fix-cortex-a53-843419 flag when used to link
362# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautiercfe67672023-03-15 16:18:16 +0100363 ifeq (${ARCH},aarch64)
364 ifneq (${ERRATA_A53_843419},1)
365 TF_LDFLAGS += -mno-fix-cortex-a53-843419
366 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100367 endif
368 TF_LDFLAGS += -nostdlib
369 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100370
371# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800372else
Marco Felsch1f49db52022-11-09 12:59:09 +0100373# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
374# are not loaded by a elf loader.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100375 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
376 TF_LDFLAGS += -O1
377 TF_LDFLAGS += --gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000378
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100379 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
380 TF_LDFLAGS += -z max-page-size=4096
Chris Kayac98b822022-12-22 13:26:37 +0000381
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100382# ld.lld doesn't recognize the errata flags,
Yabin Cuiebac6922023-01-19 20:06:04 +0000383# therefore don't add those in that case.
384# ld.lld reports section type mismatch warnings,
385# therefore don't add --fatal-warnings to it.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100386 ifeq ($(findstring ld.lld,$(notdir $(LD))),)
387 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
388 endif
389
390endif #(LD = armlink)
Juan Castillo73c99d42015-08-18 14:23:04 +0100391
392################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500393# Setup ARCH_MAJOR/MINOR before parsing arch_features.
394################################################################################
395ifeq (${ENABLE_RME},1)
396 ARM_ARCH_MAJOR := 8
397 ARM_ARCH_MINOR := 6
398endif
399
400################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100401# Common sources and include directories
402################################################################################
dp-armd801fbb2017-05-04 12:15:35 +0100403include lib/compiler-rt/compiler-rt.mk
Juan Castillo73c99d42015-08-18 14:23:04 +0100404
405BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100406 common/tf_log.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100407 common/${ARCH}/debug.S \
Julius Werner91b48c92018-11-27 22:10:56 -0800408 drivers/console/multi_console.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100409 lib/${ARCH}/cache_helpers.S \
410 lib/${ARCH}/misc_helpers.S \
Boyan Karatotevc73686a2023-02-15 13:21:50 +0000411 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew566034f2018-02-08 17:45:12 +0000412 plat/common/plat_bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100413 plat/common/plat_log_common.c \
dp-arm75311202017-03-07 11:02:47 +0000414 plat/common/${ARCH}/plat_common.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100415 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas61f72a32018-05-08 10:27:10 +0100416 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000417
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100418ifeq ($(notdir $(CC)),armclang)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100419 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100420endif
421
Justin Chadwell1f461972019-08-20 11:01:52 +0100422ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100423 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell1f461972019-08-20 11:01:52 +0100424endif
425
Yann Gautier01d237c2018-06-18 16:00:23 +0200426INCLUDES += -Iinclude \
Antonio Nino Diazf5478de2018-12-17 17:20:57 +0000427 -Iinclude/arch/${ARCH} \
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +0000428 -Iinclude/lib/cpus/${ARCH} \
429 -Iinclude/lib/el3_runtime/${ARCH} \
430 ${PLAT_INCLUDES} \
431 ${SPD_INCLUDES}
432
Nishant Sharmae03dcc82022-08-15 16:37:07 +0100433DTC_FLAGS += -I dts -O dtb
434DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
435 -x assembler-with-cpp $(DEFINES)
436
Antonio Nino Diaz9c6d1c52018-11-19 11:48:30 +0000437include common/backtrace/backtrace.mk
438
Juan Castillo73c99d42015-08-18 14:23:04 +0100439################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500440# Generic definitions
441################################################################################
442include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
443
444ifeq (${BUILD_BASE},)
445 BUILD_BASE := ./build
446endif
447BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
448
449SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
450
451# Platforms providing their own TBB makefile may override this value
452INCLUDE_TBBR_MK := 1
453
454################################################################################
455# Include SPD Makefile if one has been specified
456################################################################################
457
458ifneq (${SPD},none)
459 ifeq (${ARCH},aarch32)
460 $(error "Error: SPD is incompatible with AArch32.")
461 endif
462
463 ifdef EL3_PAYLOAD_BASE
464 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
465 $(warning "The SPD and its BL32 companion will be present but \
466 ignored.")
467 endif
468
469 ifeq (${SPD},spmd)
470 # SPMD is located in std_svc directory
471 SPD_DIR := std_svc
472
473 ifeq ($(SPMD_SPM_AT_SEL2),1)
474 CTX_INCLUDE_EL2_REGS := 1
475 ifeq ($(SPMC_AT_EL3),1)
476 $(error SPM cannot be enabled in both S-EL2 and EL3.)
477 endif
478 endif
479
480 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
481 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
482 endif
483
484 ifeq ($(TS_SP_FW_CONFIG),1)
485 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
486 endif
487
488 ifneq ($(ARM_BL2_SP_LIST_DTS),)
489 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
490 endif
491
492 ifneq ($(SP_LAYOUT_FILE),)
493 BL2_ENABLE_SP_LOAD := 1
494 endif
Govindraj Rajac189adb2023-10-31 14:48:11 -0500495
496 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
497 ifneq ($(SPMC_AT_EL3),1)
498 $(error SEL0 SP cannot be enabled without SPMC at EL3)
499 endif
500 endif
Govindraj Raja35472702023-09-20 14:32:24 -0500501 else
502 # All other SPDs in spd directory
503 SPD_DIR := spd
504 endif #(SPD)
505
506 # We expect to locate an spd.mk under the specified SPD directory
507 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
508
509 ifeq (${SPD_MAKE},)
510 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
511 endif
512 $(info Including ${SPD_MAKE})
513 include ${SPD_MAKE}
514
515 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
516 # Makefile would set NEED_BL32 to "yes". In this case, the build system
517 # supports two mutually exclusive options:
518 # * BL32 is built from source: then BL32_SOURCES must contain the list
519 # of source files to build BL32
520 # * BL32 is a prebuilt binary: then BL32 must point to the image file
521 # that will be included in the FIP
522 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
523 # over the sources.
524endif #(SPD=none)
525
526ifeq (${ENABLE_SPMD_LP}, 1)
527ifneq (${SPD},spmd)
528 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
529endif
530ifeq ($(SPMC_AT_EL3),1)
531 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
532endif
533endif
534
535################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500536# Process BRANCH_PROTECTION value and set
537# Pointer Authentication and Branch Target Identification flags
538################################################################################
539ifeq (${BRANCH_PROTECTION},0)
540 # Default value turns off all types of branch protection
541 BP_OPTION := none
542else ifneq (${ARCH},aarch64)
543 $(error BRANCH_PROTECTION requires AArch64)
544else ifeq (${BRANCH_PROTECTION},1)
545 # Enables all types of branch protection features
546 BP_OPTION := standard
547 ENABLE_BTI := 1
548 ENABLE_PAUTH := 1
549else ifeq (${BRANCH_PROTECTION},2)
550 # Return address signing to its standard level
551 BP_OPTION := pac-ret
552 ENABLE_PAUTH := 1
553else ifeq (${BRANCH_PROTECTION},3)
554 # Extend the signing to include leaf functions
555 BP_OPTION := pac-ret+leaf
556 ENABLE_PAUTH := 1
557else ifeq (${BRANCH_PROTECTION},4)
558 # Turn on branch target identification mechanism
559 BP_OPTION := bti
560 ENABLE_BTI := 1
561else
562 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
563endif #(BRANCH_PROTECTION)
564
565ifeq ($(ENABLE_PAUTH),1)
566 CTX_INCLUDE_PAUTH_REGS := 1
567endif
568ifneq (${BP_OPTION},none)
569 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
570endif #(BP_OPTION)
571
572# Pointer Authentication sources
573ifeq (${ENABLE_PAUTH}, 1)
574# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
575# Pauth support. As it's not secure, it must be reimplemented for real platforms
576 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
577endif
578
Govindraj Raja35472702023-09-20 14:32:24 -0500579################################################################################
580# Include the platform specific Makefile after the SPD Makefile (the platform
581# makefile may use all previous definitions in this file)
582################################################################################
583include ${PLAT_MAKEFILE_FULL}
584
585################################################################################
586# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
587# platform.
588################################################################################
589include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
590
Govindraj Rajaf5211422023-08-17 10:41:48 -0500591####################################################
592# Enable required options for Memory Stack Tagging.
593####################################################
594
595# Currently, these options are enabled only for clang and armclang compiler.
596ifeq (${SUPPORT_STACK_MEMTAG},yes)
597 ifdef mem_tag_arch_support
598 # Check for armclang and clang compilers
599 ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
600 # Add "memtag" architecture feature modifier if not specified
601 ifeq ( ,$(findstring memtag,$(arch-features)))
602 arch-features := $(arch-features)+memtag
603 endif # memtag
604 ifeq ($(notdir $(CC)),armclang)
605 TF_CFLAGS += -mmemtag-stack
606 else ifeq ($(notdir $(CC)),clang)
607 TF_CFLAGS += -fsanitize=memtag
608 endif # armclang
609 endif
610 else
611 $(error "Error: stack memory tagging is not supported for \
612 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
613 endif #(mem_tag_arch_support)
614endif #(SUPPORT_STACK_MEMTAG)
615
616################################################################################
617# RME dependent flags configuration, Enable optional features for RME.
618################################################################################
619# FEAT_RME
620ifeq (${ENABLE_RME},1)
Govindraj Rajad6380292023-10-12 16:57:46 -0500621 # RME doesn't support BRBE
622 ENABLE_BRBE_FOR_NS := 0
623
Govindraj Rajaf5211422023-08-17 10:41:48 -0500624 # RME doesn't support PIE
625 ifneq (${ENABLE_PIE},0)
626 $(error ENABLE_RME does not support PIE)
627 endif
628
629 # RME doesn't support BRBE
630 ifneq (${ENABLE_BRBE_FOR_NS},0)
631 $(error ENABLE_RME does not support BRBE.)
632 endif
633
634 # RME requires AARCH64
635 ifneq (${ARCH},aarch64)
636 $(error ENABLE_RME requires AArch64)
637 endif
638
639 # RME requires el2 context to be saved for now.
640 CTX_INCLUDE_EL2_REGS := 1
641 CTX_INCLUDE_AARCH32_REGS := 0
642 CTX_INCLUDE_PAUTH_REGS := 1
643
644 # RME enables CSV2_2 extension by default.
645 ENABLE_FEAT_CSV2_2 = 1
646endif #(FEAT_RME)
647
648################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500649# Include rmmd Makefile if RME is enabled
650################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500651ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100652 ifneq (${ARCH},aarch64)
653 $(error ENABLE_RME requires AArch64)
654 endif
655 ifeq ($(SPMC_AT_EL3),1)
656 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
657 endif
658
659 ifneq (${SPD}, none)
660 ifneq (${SPD}, spmd)
661 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
662 endif
663 endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500664include services/std_svc/rmmd/rmmd.mk
665$(warning "RME is an experimental feature")
666endif
667
Govindraj Raja35472702023-09-20 14:32:24 -0500668ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
669 ifeq (${SPD},none)
670 ifeq (${ENABLE_RME},0)
671 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
672 or RME is enabled)
673 endif
674 endif
675endif
Juan Castillo0f21c542014-06-25 17:26:36 +0100676
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500677################################################################################
678# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
679# up with appropriate march values for compiler.
680################################################################################
681include ${MAKE_HELPERS_DIRECTORY}march.mk
682
683TF_CFLAGS += $(march-directive)
Govindraj Rajaeb26e782024-01-23 16:00:19 -0600684ASFLAGS += $(march-directive)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500685
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600686# This internal flag is common option which is set to 1 for scenarios
687# when the BL2 is running in EL3 level. This occurs in two scenarios -
688# 4 world system running BL2 at EL3 and two world system without BL1 running
689# BL2 in EL3
690
691ifeq (${RESET_TO_BL2},1)
692 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100693 ifeq (${ENABLE_RME},1)
694 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
695 supported at the moment.)
696 endif
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600697else ifeq (${ENABLE_RME},1)
698 BL2_RUNS_AT_EL3 := 1
699else
700 BL2_RUNS_AT_EL3 := 0
701endif
702
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100703# This internal flag is set to 1 when Firmware First handling of External aborts
704# is required by lowe ELs. Currently only NS requires this support.
705ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
706 FFH_SUPPORT := 1
707else
708 FFH_SUPPORT := 0
709endif
710
Masahiro Yamada8012cc52017-11-04 03:12:28 +0900711$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
712
Etienne Carriere26e63c42017-11-08 13:48:40 +0100713ifeq (${ARM_ARCH_MAJOR},7)
714include make_helpers/armv7-a-cpus.mk
715endif
716
Masahiro Yamada320920c2020-01-17 13:44:37 +0900717PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
718ifneq ($(PIE_FOUND),)
719 TF_CFLAGS += -fno-PIE
Samuel Holland7b592412022-04-08 21:56:02 -0500720ifneq ($(findstring gcc,$(notdir $(LD))),)
721 TF_LDFLAGS += -no-pie
722endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100723endif #(PIE_FOUND)
Masahiro Yamada320920c2020-01-17 13:44:37 +0900724
725ifneq ($(findstring gcc,$(notdir $(LD))),)
726 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew3bd17c02018-08-28 11:13:55 +0100727else
Masahiro Yamada320920c2020-01-17 13:44:37 +0900728 PIE_LDFLAGS += -pie --no-dynamic-linker
729endif
730
731ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100732 ifeq ($(RESET_TO_BL2),1)
733 ifneq ($(BL2_IN_XIP_MEM),1)
734 BL2_CPPFLAGS += -fpie
735 BL2_CFLAGS += -fpie
736 BL2_LDFLAGS += $(PIE_LDFLAGS)
737 endif #(BL2_IN_XIP_MEM)
738 endif #(RESET_TO_BL2)
Chris Kay966660e2023-02-02 14:39:03 +0000739 BL31_CPPFLAGS += -fpie
740 BL31_CFLAGS += -fpie
Masahiro Yamada320920c2020-01-17 13:44:37 +0900741 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay966660e2023-02-02 14:39:03 +0000742
743 BL32_CPPFLAGS += -fpie
Masahiro Yamadad9743012020-01-17 13:45:14 +0900744 BL32_CFLAGS += -fpie
745 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100746endif #(ENABLE_PIE)
Soby Mathew3bd17c02018-08-28 11:13:55 +0100747
Boyan Karatotev007433d2023-01-25 16:55:18 +0000748BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
749BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
750BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
751
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900752BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600753ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100754 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900755else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100756 BL2_CPPFLAGS += -DIMAGE_AT_EL1
757endif #(RESET_TO_BL2)
Boyan Karatotev007433d2023-01-25 16:55:18 +0000758
759ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100760 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
761 BL31_CPPFLAGS += -DIMAGE_AT_EL3
762 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatotev007433d2023-01-25 16:55:18 +0000763else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100764 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900765endif
766
Sandrine Bailleux54035fc2016-01-13 14:57:38 +0000767# Include the CPU specific operations makefile, which provides default
768# values for all CPU errata workarounds and CPU specific optimisations.
769# This can be overridden by the platform.
Juan Castillo73c99d42015-08-18 14:23:04 +0100770include lib/cpus/cpu-ops.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100771
dp-arma4409002017-02-15 11:07:55 +0000772################################################################################
773# Build `AARCH32_SP` as BL32 image for AArch32
774################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100775ifeq (${ARCH},aarch32)
776 NEED_BL32 := yes
dp-arma4409002017-02-15 11:07:55 +0000777
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100778 ifneq (${AARCH32_SP},none)
779 # We expect to locate an sp.mk under the specified AARCH32_SP directory
780 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-arma4409002017-02-15 11:07:55 +0000781
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100782 ifeq (${AARCH32_SP_MAKE},)
783 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
784 endif
Juan Pablo Conde043f38f2023-08-09 13:19:21 -0500785 $(info Including ${AARCH32_SP_MAKE})
786 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100787 endif
788endif #(ARCH=aarch32)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100789
Juan Castillo73c99d42015-08-18 14:23:04 +0100790################################################################################
Varun Wadekar77f1f7a2019-01-31 09:22:30 -0800791# Include libc if not overridden
792################################################################################
793ifeq (${OVERRIDE_LIBC},0)
794include lib/libc/libc.mk
795endif
796
797################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100798# Check incompatible options and dependencies
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000799################################################################################
800
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100801# USE_DEBUGFS experimental feature recommended only in debug builds
802ifeq (${USE_DEBUGFS},1)
803 ifeq (${DEBUG},1)
804 $(warning DEBUGFS experimental feature is enabled.)
805 else
806 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000807 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100808endif #(USE_DEBUGFS)
809
810# USE_SPINLOCK_CAS requires AArch64 build
811ifeq (${USE_SPINLOCK_CAS},1)
812 ifneq (${ARCH},aarch64)
813 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xu76580f32017-08-24 11:03:23 +0800814 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100815endif #(USE_SPINLOCK_CAS)
816
817# The cert_create tool cannot generate certificates individually, so we use the
818# target 'certificates' to create them all
819ifneq (${GENERATE_COT},0)
820 FIP_DEPS += certificates
821 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000822endif
823
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100824ifneq (${DECRYPTION_SUPPORT},none)
825 ENC_ARGS += -f ${FW_ENC_STATUS}
826 ENC_ARGS += -k ${ENC_KEY}
827 ENC_ARGS += -n ${ENC_NONCE}
828 FIP_DEPS += enctool
829 FWU_FIP_DEPS += enctool
830endif #(DECRYPTION_SUPPORT)
831
832ifdef EL3_PAYLOAD_BASE
833 ifdef PRELOADED_BL33_BASE
834 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
835 incompatible build options. EL3_PAYLOAD_BASE has priority.")
836 endif
837 ifneq (${GENERATE_COT},0)
838 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
839 build options.")
840 endif
841 ifneq (${TRUSTED_BOARD_BOOT},0)
842 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
843 incompatible \ build options.")
844 endif
845endif #(EL3_PAYLOAD_BASE)
846
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000847ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100848 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000849 $(warning "BL33 image is not needed when option \
850 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100851 endif
852 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100853 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100854 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
855 endif
856endif #(NEED_BL33)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000857
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000858# When building for systems with hardware-assisted coherency, there's no need to
859# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
860ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100861 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000862endif
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +0100863
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600864#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
865ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100866 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan7d173fc2018-03-21 07:20:09 +0000867endif
868
Manish Pandey9202d512023-02-13 12:39:17 +0000869# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100870ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100871 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100872 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandey9202d512023-02-13 12:39:17 +0000873endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100874
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100875
Manish Pandey9202d512023-02-13 12:39:17 +0000876# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000877ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100878 ifeq ($(ENABLE_FEAT_RAS),0)
879 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
880 endif
881endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000882
Roberto Vargased51b512018-09-24 17:20:48 +0100883# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew209a60c2018-03-26 12:43:37 +0100884ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100885 ifeq (${TRUSTED_BOARD_BOOT}, 0)
886 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
887 to be set.")
888 endif
889endif #(DYN_DISABLE_AUTH)
Soby Mathew209a60c2018-03-26 12:43:37 +0100890
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100891ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
892# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100893 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100894else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
895# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100896 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100897else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
898# Support hash calculation only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100899 CRYPTO_SUPPORT := 2
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100900else ifeq (${TRUSTED_BOARD_BOOT},1)
901# Support authentication verification only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100902 CRYPTO_SUPPORT := 1
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000903else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100904 CRYPTO_SUPPORT := 0
905endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000906
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100907# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
908ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100909 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhe84ef9cd2020-06-29 10:32:53 +0100910endif
911
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000912# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100913# registers associated to it are also saved and restored.
914# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000915ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100916 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
917 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
918 endif
919endif #(ENABLE_PAUTH)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100920
921ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100922 ifneq (${ARCH},aarch64)
923 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
924 endif
925endif #(CTX_INCLUDE_PAUTH_REGS)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100926
Justin Chadwell9dd94382019-07-18 14:25:33 +0100927ifeq ($(CTX_INCLUDE_MTE_REGS),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100928 ifneq (${ARCH},aarch64)
929 $(error CTX_INCLUDE_MTE_REGS requires AArch64)
930 endif
931endif #(CTX_INCLUDE_MTE_REGS)
Justin Chadwell9dd94382019-07-18 14:25:33 +0100932
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100933ifeq ($(PSA_FWU_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100934 $(info PSA_FWU_SUPPORT is an experimental feature)
935endif #(PSA_FWU_SUPPORT)
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100936
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000937ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100938 $(info FEATURE_DETECTION is an experimental feature)
939endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000940
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000941ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100942 ifeq (${ENABLE_SME_FOR_NS}, 0)
943 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
944 to be set")
945 $(warning "Forced ENABLE_SME_FOR_NS=1")
946 override ENABLE_SME_FOR_NS := 1
947 endif
948endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand45007ac2023-03-06 23:56:14 +0000949
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000950ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100951 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
952 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
953 library v2")
954 endif
955endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000956
Sumit Garg7cda17b2019-11-15 10:43:00 +0530957ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100958 ifeq (${TRUSTED_BOARD_BOOT}, 0)
959 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
960 to be set)
961 endif
962endif #(DECRYPTION_SUPPORT)
Sumit Garg7cda17b2019-11-15 10:43:00 +0530963
johpow01744ad972022-01-28 17:06:20 -0600964# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow01dc78e622021-07-08 14:14:00 -0500965ifeq (${ARCH},aarch32)
johpow01744ad972022-01-28 17:06:20 -0600966
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100967 # SME/SVE only supported on AArch64
968 ifneq (${ENABLE_SME_FOR_NS},0)
969 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
970 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000971
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100972 ifeq (${ENABLE_SVE_FOR_NS},1)
973 # Warning instead of error due to CI dependency on this
974 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
975 endif
johpow01744ad972022-01-28 17:06:20 -0600976
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100977 # BRBE is not supported in AArch32
978 ifeq (${ENABLE_BRBE_FOR_NS},1)
979 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
980 endif
johpow01744ad972022-01-28 17:06:20 -0600981
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100982 # FEAT_RNG_TRAP is not supported in AArch32
983 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
984 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
985 endif
986endif #(ARCH=aarch32)
johpow01dc78e622021-07-08 14:14:00 -0500987
Boyan Karatotev0d122942023-03-08 16:29:26 +0000988ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100989 ifeq (${ENABLE_SVE_FOR_NS},0)
990 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
991 endif
992endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev0d122942023-03-08 16:29:26 +0000993
johpow01dc78e622021-07-08 14:14:00 -0500994# Secure SME/SVE requires the non-secure component as well
995ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100996 ifeq (${ENABLE_SME_FOR_NS},0)
997 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
998 endif
999 ifeq (${ENABLE_SVE_FOR_SWD},0)
1000 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
1001 endif
1002endif #(ENABLE_SME_FOR_SWD)
1003
johpow01dc78e622021-07-08 14:14:00 -05001004ifeq (${ENABLE_SVE_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001005 ifeq (${ENABLE_SVE_FOR_NS},0)
1006 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1007 endif
1008endif #(ENABLE_SVE_FOR_SWD)
johpow01dc78e622021-07-08 14:14:00 -05001009
1010# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
1011# its own context management including FPU registers.
1012ifeq (${CTX_INCLUDE_FPREGS},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001013 ifneq (${ENABLE_SME_FOR_NS},0)
1014 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1015 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +00001016
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001017 ifeq (${ENABLE_SVE_FOR_NS},1)
1018 # Warning instead of error due to CI dependency on this
1019 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1020 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1021 override ENABLE_SVE_FOR_NS := 0
1022 endif
1023endif #(CTX_INCLUDE_FPREGS)
johpow01dc78e622021-07-08 14:14:00 -05001024
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001025ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001026 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001027endif
1028
Raymond Mao3ba2c152023-07-25 07:53:35 -07001029ifeq (${TRANSFER_LIST},1)
1030 $(info TRANSFER_LIST is an experimental feature)
1031endif
1032
Chris Kay274a69e2022-09-29 16:21:24 +01001033ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001034 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1035 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1036 endif
Chris Kay274a69e2022-09-29 16:21:24 +01001037endif
1038
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001039ifeq ($(PSA_CRYPTO),1)
1040 $(info PSA_CRYPTO is an experimental feature)
1041endif
1042
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001043################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001044# Process platform overrideable behaviour
1045################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001046
Manish Pandey5f24ce92021-10-06 10:59:52 +01001047ifdef BL1_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001048 NEED_BL1 := yes
1049endif #(BL1_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001050
Juan Castillo73c99d42015-08-18 14:23:04 +01001051ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +01001052 NEED_BL2 := yes
1053
1054 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1055 # Certificate generation tools. This flag can be overridden by the platform.
1056 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001057 # If booting an EL3 payload there is no need for a BL33 image
1058 # in the FIP file.
1059 NEED_BL33 := no
1060 else
1061 ifdef PRELOADED_BL33_BASE
1062 # If booting a BL33 preloaded image there is no need of
1063 # another one in the FIP file.
1064 NEED_BL33 := no
1065 else
1066 NEED_BL33 ?= yes
1067 endif
1068 endif
1069endif #(BL2_SOURCES)
Juan Castillo73c99d42015-08-18 14:23:04 +01001070
Manish Pandey5f24ce92021-10-06 10:59:52 +01001071ifdef BL2U_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001072 NEED_BL2U := yes
1073endif #(BL2U_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001074
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001075# If SCP_BL2 is given, we always want FIP to include it.
1076ifdef SCP_BL2
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001077 NEED_SCP_BL2 := yes
1078endif #(SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001079
Soby Mathew5744e872017-11-14 14:10:10 +00001080# For AArch32, BL31 is not currently supported.
1081ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001082 ifdef BL31_SOURCES
1083 # When booting an EL3 payload, there is no need to compile the BL31
1084 # image nor put it in the FIP.
1085 ifndef EL3_PAYLOAD_BASE
1086 NEED_BL31 := yes
1087 endif
1088 endif
1089endif #(ARCH=aarch64)
Soby Mathew5744e872017-11-14 14:10:10 +00001090
Juan Castillo73c99d42015-08-18 14:23:04 +01001091# Process TBB related flags
1092ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001093 # Common cert_create options
1094 ifneq (${CREATE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001095 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +01001096 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001097 ifneq (${SAVE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001098 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +01001099 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001100 endif
1101 endif
1102 # Include TBBR makefile (unless the platform indicates otherwise)
1103 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001104 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001105 endif
1106endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001107
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001108ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001109 FIP_ARGS += --align ${FIP_ALIGN}
1110endif #(FIP_ALIGN)
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001111
Manish Pandey5f24ce92021-10-06 10:59:52 +01001112ifdef FDT_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001113 NEED_FDT := yes
1114endif #(FDT_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001115
Juan Castillo73c99d42015-08-18 14:23:04 +01001116################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +08001117# Include libraries' Makefile that are used in all BL
1118################################################################################
1119
1120include lib/stack_protector/stack_protector.mk
1121
1122################################################################################
Soby Mathew8a860522017-02-14 10:05:07 +00001123# Include BL specific makefiles
1124################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +01001125
1126ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001127include bl1/bl1.mk
1128endif
1129
Manish Pandey5f24ce92021-10-06 10:59:52 +01001130ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001131include bl2/bl2.mk
1132endif
1133
Manish Pandey5f24ce92021-10-06 10:59:52 +01001134ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001135include bl2u/bl2u.mk
1136endif
1137
Soby Mathew5744e872017-11-14 14:10:10 +00001138ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001139include bl31/bl31.mk
1140endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001141
Juan Castillo73c99d42015-08-18 14:23:04 +01001142################################################################################
1143# Build options checks
1144################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001145
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001146# Boolean_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001147$(eval $(call assert_booleans,\
1148 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001149 ALLOW_RO_XLAT_TABLES \
1150 BL2_ENABLE_SP_LOAD \
1151 COLD_BOOT_SINGLE_CPU \
1152 CREATE_KEYS \
1153 CTX_INCLUDE_AARCH32_REGS \
1154 CTX_INCLUDE_FPREGS \
1155 CTX_INCLUDE_EL2_REGS \
1156 DEBUG \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001157 DYN_DISABLE_AUTH \
1158 EL3_EXCEPTION_HANDLING \
1159 ENABLE_AMU_AUXILIARY_COUNTERS \
1160 ENABLE_AMU_FCONF \
1161 AMU_RESTRICT_COUNTERS \
1162 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001163 ENABLE_PIE \
1164 ENABLE_PMF \
1165 ENABLE_PSCI_STAT \
1166 ENABLE_RUNTIME_INSTRUMENTATION \
1167 ENABLE_SME_FOR_SWD \
1168 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001169 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001170 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001171 ERROR_DEPRECATED \
1172 FAULT_INJECTION_SUPPORT \
1173 GENERATE_COT \
1174 GICV2_G0_FOR_EL3 \
1175 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravi9cec5492023-09-28 13:17:24 -05001176 HARDEN_SLS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001177 HW_ASSISTED_COHERENCY \
1178 MEASURED_BOOT \
1179 DRTM_SUPPORT \
1180 NS_TIMER_SWITCH \
1181 OVERRIDE_LIBC \
1182 PL011_GENERIC_UART \
1183 PLAT_RSS_NOT_SUPPORTED \
1184 PROGRAMMABLE_RESET_ADDRESS \
1185 PSCI_EXTENDED_STATE_ID \
1186 PSCI_OS_INIT_MODE \
1187 RESET_TO_BL31 \
1188 SAVE_KEYS \
1189 SEPARATE_CODE_AND_RODATA \
1190 SEPARATE_BL2_NOLOAD_REGION \
1191 SEPARATE_NOBITS_REGION \
1192 SPIN_ON_BL1_EXIT \
1193 SPM_MM \
1194 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001195 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001196 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001197 ENABLE_SPMD_LP \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001198 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001199 TRUSTED_BOARD_BOOT \
1200 USE_COHERENT_MEM \
1201 USE_DEBUGFS \
1202 ARM_IO_IN_DTB \
1203 SDEI_IN_FCONF \
1204 SEC_INT_DESC_IN_FCONF \
1205 USE_ROMLIB \
1206 USE_TBBR_DEFS \
1207 WARMBOOT_ENABLE_DCACHE_EARLY \
1208 RESET_TO_BL2 \
1209 BL2_IN_XIP_MEM \
1210 BL2_INV_DCACHE \
1211 USE_SPINLOCK_CAS \
1212 ENCRYPT_BL31 \
1213 ENCRYPT_BL32 \
1214 ERRATA_SPECULATIVE_AT \
1215 RAS_TRAP_NS_ERR_REC_ACCESS \
1216 COT_DESC_IN_DTB \
1217 USE_SP804_TIMER \
1218 PSA_FWU_SUPPORT \
1219 ENABLE_MPMM \
1220 ENABLE_MPMM_FCONF \
1221 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001222 TRNG_SUPPORT \
Yann Gautierb9e252a2025-02-12 14:05:14 +01001223 ENABLE_ERRATA_ALL \
Sona Mathewffea3842022-11-18 18:05:38 -06001224 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001225 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001226 CONDITIONAL_CMO \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001227 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001228 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001229 INIT_UNUSED_NS_EL2 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001230)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001231
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001232# Numeric_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001233$(eval $(call assert_numerics,\
1234 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001235 ARM_ARCH_MAJOR \
1236 ARM_ARCH_MINOR \
1237 BRANCH_PROTECTION \
1238 CTX_INCLUDE_PAUTH_REGS \
1239 CTX_INCLUDE_MTE_REGS \
1240 CTX_INCLUDE_NEVE_REGS \
1241 CRYPTO_SUPPORT \
Boyan Karatotev83a4dae2023-02-16 09:45:29 +00001242 DISABLE_MTPMU \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001243 ENABLE_BRBE_FOR_NS \
1244 ENABLE_TRBE_FOR_NS \
1245 ENABLE_BTI \
1246 ENABLE_PAUTH \
1247 ENABLE_FEAT_AMU \
1248 ENABLE_FEAT_AMUv1p1 \
1249 ENABLE_FEAT_CSV2_2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001250 ENABLE_FEAT_DIT \
1251 ENABLE_FEAT_ECV \
1252 ENABLE_FEAT_FGT \
1253 ENABLE_FEAT_HCX \
1254 ENABLE_FEAT_PAN \
1255 ENABLE_FEAT_RNG \
1256 ENABLE_FEAT_RNG_TRAP \
1257 ENABLE_FEAT_SEL2 \
1258 ENABLE_FEAT_TCR2 \
Govindraj Raja9e469a82024-01-23 16:03:53 -06001259 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001260 ENABLE_FEAT_S2PIE \
1261 ENABLE_FEAT_S1PIE \
1262 ENABLE_FEAT_S2POE \
1263 ENABLE_FEAT_S1POE \
1264 ENABLE_FEAT_GCS \
1265 ENABLE_FEAT_VHE \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001266 ENABLE_FEAT_MTE_PERM \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001267 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001268 ENABLE_RME \
1269 ENABLE_SPE_FOR_NS \
1270 ENABLE_SYS_REG_TRACE_FOR_NS \
1271 ENABLE_SME_FOR_NS \
1272 ENABLE_SME2_FOR_NS \
1273 ENABLE_SVE_FOR_NS \
1274 ENABLE_TRF_FOR_NS \
1275 FW_ENC_STATUS \
1276 NR_OF_FW_BANKS \
1277 NR_OF_IMAGES_IN_FW_BANK \
1278 TWED_DELAY \
1279 ENABLE_FEAT_TWED \
1280 SVE_VECTOR_LEN \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001281 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001282)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001283
Justin Chadwellaacff742019-07-29 17:13:10 +01001284ifdef KEY_SIZE
1285 $(eval $(call assert_numeric,KEY_SIZE))
1286endif
1287
Justin Chadwell1f461972019-08-20 11:01:52 +01001288ifeq ($(filter $(SANITIZE_UB), on off trap),)
1289 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1290endif
1291
Juan Castillo73c99d42015-08-18 14:23:04 +01001292################################################################################
1293# Add definitions to the cpp preprocessor based on the current build options.
1294# This is done after including the platform specific makefile to allow the
1295# platform to overwrite the default options
1296################################################################################
1297
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001298$(eval $(call add_defines,\
1299 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001300 ALLOW_RO_XLAT_TABLES \
1301 ARM_ARCH_MAJOR \
1302 ARM_ARCH_MINOR \
1303 BL2_ENABLE_SP_LOAD \
1304 COLD_BOOT_SINGLE_CPU \
1305 CTX_INCLUDE_AARCH32_REGS \
1306 CTX_INCLUDE_FPREGS \
1307 CTX_INCLUDE_PAUTH_REGS \
1308 EL3_EXCEPTION_HANDLING \
1309 CTX_INCLUDE_MTE_REGS \
1310 CTX_INCLUDE_EL2_REGS \
1311 CTX_INCLUDE_NEVE_REGS \
1312 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1313 DISABLE_MTPMU \
1314 ENABLE_FEAT_AMU \
1315 ENABLE_AMU_AUXILIARY_COUNTERS \
1316 ENABLE_AMU_FCONF \
1317 AMU_RESTRICT_COUNTERS \
1318 ENABLE_ASSERTIONS \
1319 ENABLE_BTI \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001320 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001321 ENABLE_PAUTH \
1322 ENABLE_PIE \
1323 ENABLE_PMF \
1324 ENABLE_PSCI_STAT \
1325 ENABLE_RME \
1326 ENABLE_RUNTIME_INSTRUMENTATION \
1327 ENABLE_SME_FOR_NS \
1328 ENABLE_SME2_FOR_NS \
1329 ENABLE_SME_FOR_SWD \
1330 ENABLE_SPE_FOR_NS \
1331 ENABLE_SVE_FOR_NS \
1332 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001333 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001334 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001335 ENCRYPT_BL31 \
1336 ENCRYPT_BL32 \
1337 ERROR_DEPRECATED \
1338 FAULT_INJECTION_SUPPORT \
1339 GICV2_G0_FOR_EL3 \
1340 HANDLE_EA_EL3_FIRST_NS \
1341 HW_ASSISTED_COHERENCY \
1342 LOG_LEVEL \
1343 MEASURED_BOOT \
1344 DRTM_SUPPORT \
1345 NS_TIMER_SWITCH \
1346 PL011_GENERIC_UART \
1347 PLAT_${PLAT} \
1348 PLAT_RSS_NOT_SUPPORTED \
1349 PROGRAMMABLE_RESET_ADDRESS \
1350 PSCI_EXTENDED_STATE_ID \
1351 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001352 RESET_TO_BL31 \
1353 SEPARATE_CODE_AND_RODATA \
1354 SEPARATE_BL2_NOLOAD_REGION \
1355 SEPARATE_NOBITS_REGION \
1356 RECLAIM_INIT_CODE \
1357 SPD_${SPD} \
1358 SPIN_ON_BL1_EXIT \
1359 SPM_MM \
1360 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001361 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001362 SPMD_SPM_AT_SEL2 \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001363 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001364 TRUSTED_BOARD_BOOT \
1365 CRYPTO_SUPPORT \
1366 TRNG_SUPPORT \
1367 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001368 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001369 USE_COHERENT_MEM \
1370 USE_DEBUGFS \
1371 ARM_IO_IN_DTB \
1372 SDEI_IN_FCONF \
1373 SEC_INT_DESC_IN_FCONF \
1374 USE_ROMLIB \
1375 USE_TBBR_DEFS \
1376 WARMBOOT_ENABLE_DCACHE_EARLY \
1377 RESET_TO_BL2 \
1378 BL2_RUNS_AT_EL3 \
1379 BL2_IN_XIP_MEM \
1380 BL2_INV_DCACHE \
1381 USE_SPINLOCK_CAS \
1382 ERRATA_SPECULATIVE_AT \
1383 RAS_TRAP_NS_ERR_REC_ACCESS \
1384 COT_DESC_IN_DTB \
1385 USE_SP804_TIMER \
1386 ENABLE_FEAT_RNG \
1387 ENABLE_FEAT_RNG_TRAP \
1388 ENABLE_FEAT_SB \
1389 ENABLE_FEAT_DIT \
1390 NR_OF_FW_BANKS \
1391 NR_OF_IMAGES_IN_FW_BANK \
1392 PSA_FWU_SUPPORT \
1393 ENABLE_BRBE_FOR_NS \
1394 ENABLE_TRBE_FOR_NS \
1395 ENABLE_SYS_REG_TRACE_FOR_NS \
1396 ENABLE_TRF_FOR_NS \
1397 ENABLE_FEAT_HCX \
1398 ENABLE_MPMM \
1399 ENABLE_MPMM_FCONF \
1400 ENABLE_FEAT_FGT \
1401 ENABLE_FEAT_ECV \
1402 ENABLE_FEAT_AMUv1p1 \
1403 ENABLE_FEAT_SEL2 \
1404 ENABLE_FEAT_VHE \
1405 ENABLE_FEAT_CSV2_2 \
1406 ENABLE_FEAT_PAN \
1407 ENABLE_FEAT_TCR2 \
1408 ENABLE_FEAT_S2PIE \
1409 ENABLE_FEAT_S1PIE \
1410 ENABLE_FEAT_S2POE \
1411 ENABLE_FEAT_S1POE \
1412 ENABLE_FEAT_GCS \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001413 ENABLE_FEAT_MTE_PERM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001414 FEATURE_DETECTION \
1415 TWED_DELAY \
1416 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001417 CONDITIONAL_CMO \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001418 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidananda8cf6fa2023-04-26 15:57:30 +01001419 SVE_VECTOR_LEN \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001420 ENABLE_SPMD_LP \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001421 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001422 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001423 INIT_UNUSED_NS_EL2 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001424)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001425
Justin Chadwell1f461972019-08-20 11:01:52 +01001426ifeq (${SANITIZE_UB},trap)
1427 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001428endif #(SANITIZE_UB)
Justin Chadwell1f461972019-08-20 11:01:52 +01001429
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001430# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1431ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001432 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1433else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001434# Define the PRELOADED_BL33_BASE flag only if it is provided and
1435# EL3_PAYLOAD_BASE is not defined, as it has priority.
1436 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001437 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001438 endif
1439endif #(EL3_PAYLOAD_BASE)
Juan Castillo73c99d42015-08-18 14:23:04 +01001440
Soby Mathew209a60c2018-03-26 12:43:37 +01001441# Define the DYN_DISABLE_AUTH flag only if set.
1442ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001443 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew209a60c2018-03-26 12:43:37 +01001444endif
1445
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001446ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001447 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001448endif
1449
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001450# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001451ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001452ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001453 -include $(BUILD_PLAT)/sp_gen.mk
1454 FIP_DEPS += sp
1455 CRT_DEPS += sp
1456 NEED_SP_PKG := yes
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001457else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001458 ifeq (${SPMD_SPM_AT_SEL2},1)
1459 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1460 endif
1461endif #(SP_LAYOUT_FILE)
1462endif #(SPD)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001463
Juan Castillo73c99d42015-08-18 14:23:04 +01001464################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001465# Build targets
1466################################################################################
1467
Sumit Garg90aa9012019-11-11 18:46:36 +05301468.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
Juan Castillo73c99d42015-08-18 14:23:04 +01001469.SUFFIXES:
1470
1471all: msg_start
1472
1473msg_start:
1474 @echo "Building ${PLAT}"
1475
Soby Mathew7a24cba2015-10-26 14:29:21 +00001476ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001477# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001478ifneq ($(findstring clang,$(notdir $(CC))),)
1479 CPPFLAGS += -Wno-error=deprecated-declarations
1480else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001481 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001482endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001483endif #(!ERROR_DEPRECATED)
Soby Mathew7a24cba2015-10-26 14:29:21 +00001484
Roberto Vargas5accce52018-05-22 16:05:42 +01001485$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas61f72a32018-05-08 10:27:10 +01001486$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001487
Juan Castillo73c99d42015-08-18 14:23:04 +01001488# Expand build macros for the different images
1489ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001490BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Aweke434d0492021-07-11 17:25:48 -05001491$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001492endif #(NEED_BL1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001493
1494ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001495
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -06001496ifeq (${RESET_TO_BL2}, 0)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001497FIP_BL2_ARGS := tb-fw
1498endif
1499
Chris Kayeb1acfb2021-09-28 15:44:37 +01001500BL2_SOURCES := $(sort ${BL2_SOURCES})
1501
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001502$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001503 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001504
1505endif #(NEED_BL2)
Juan Castillo73c99d42015-08-18 14:23:04 +01001506
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001507ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001508$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001509endif #(NEED_SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001510
Juan Castillo73c99d42015-08-18 14:23:04 +01001511ifeq (${NEED_BL31},yes)
1512BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001513# Sort BL31 source files to remove duplicates
1514BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301515ifneq (${DECRYPTION_SUPPORT},none)
1516$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001517 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301518else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001519$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001520 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001521endif #(DECRYPTION_SUPPORT)
1522endif #(NEED_BL31)
Juan Castillo73c99d42015-08-18 14:23:04 +01001523
Juan Castillo70d1fc52015-11-12 10:59:26 +00001524# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001525# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001526# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001527ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001528# Sort BL32 source files to remove duplicates
1529BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001530BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1531
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301532ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001533$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301534 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1535else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001536$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001537 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001538endif #(DECRYPTION_SUPPORT)
1539endif #(NEED_BL32)
Juan Castillo73c99d42015-08-18 14:23:04 +01001540
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001541# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1542# needs to be built from RMM_SOURCES.
1543ifeq (${NEED_RMM},yes)
1544# Sort RMM source files to remove duplicates
1545RMM_SOURCES := $(sort ${RMM_SOURCES})
1546BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1547
1548$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001549 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1550endif #(NEED_RMM)
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001551
Juan Castillo73c99d42015-08-18 14:23:04 +01001552# Add the BL33 image if required by the platform
1553ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001554$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001555endif #(NEED_BL33)
Juan Castillodb6071c2015-01-13 12:21:04 +00001556
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001557ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001558$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001559 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001560endif #(NEED_BL2U)
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001561
Nishanth Menon03b397a2016-10-14 01:13:57 +00001562# Expand build macros for the different images
1563ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001564 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001565endif #(NEED_FDT)
Nishanth Menon03b397a2016-10-14 01:13:57 +00001566
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001567# Add Secure Partition packages
1568ifeq (${NEED_SP_PKG},yes)
Karl Meakin20629b32023-02-14 11:56:02 +00001569$(BUILD_PLAT)/sp_gen.mk : ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1570 ${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alves822c7272022-03-22 16:28:51 +00001571sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001572 @${ECHO_BLANK_LINE}
1573 @echo "Built SP Images successfully"
1574 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001575endif #(NEED_SP_PKG)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001576
Ian Spray36eaaf32014-01-30 17:25:28 +00001577locate-checkpatch:
1578ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001579 $(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 +00001580else
1581ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001582 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001583endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001584endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001585
Achin Gupta4f6ad662013-10-25 09:08:21 +01001586clean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001587 @echo " CLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001588 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001589ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001590 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001591else
1592# Clear the MAKEFLAGS as we do not want
1593# to pass the gnumake flags to nmake.
1594 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001595endif #(UNIX_MK)
Juan Castillo73c99d42015-08-18 14:23:04 +01001596 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Garg90aa9012019-11-11 18:46:36 +05301597 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargas5accce52018-05-22 16:05:42 +01001598 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001599
James Morrisseyeaaeece2013-11-01 13:56:59 +00001600realclean distclean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001601 @echo " REALCLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001602 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1603 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001604ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001605 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001606else
1607# Clear the MAKEFLAGS as we do not want
1608# to pass the gnumake flags to nmake.
1609 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001610endif #(UNIX_MK)
Nicolas Boulengueze15591a2021-03-31 12:22:45 +02001611 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Garg90aa9012019-11-11 18:46:36 +05301612 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargas5accce52018-05-22 16:05:42 +01001613 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001614
Ian Spray36eaaf32014-01-30 17:25:28 +00001615checkcodebase: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001616 @echo " CHECKING STYLE"
Dan Handley1a41e8c2016-06-02 18:21:02 +01001617 @if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001618 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001619 while read GIT_FILE ; \
1620 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1621 done ; \
1622 else \
1623 find . -type f -not -iwholename "*.git*" \
1624 -not -iwholename "*build*" \
1625 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001626 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001627 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001628 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001629 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1630 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001631
1632checkpatch: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001633 @echo " CHECKING STYLE"
Yann Gautier02a76d52019-03-08 15:44:00 +01001634 @if test -n "${CHECKPATCH_OPTS}"; then \
1635 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1636 fi
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001637 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001638 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1639 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001640 printf "\n[*] Checking style of '$$commit'\n\n"; \
1641 git log --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001642 -- ${CHECK_PATHS} | \
1643 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001644 git diff --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001645 -- ${CHECK_PATHS} | \
1646 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001647 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001648
1649certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001650
Pali Rohára9812202020-11-24 15:38:08 +01001651${CRTTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001652 ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${CRTTOOLPATH} all
Evan Lloydf1477d42015-12-02 18:33:55 +00001653 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001654 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001655 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001656
1657ifneq (${GENERATE_COT},0)
1658certificates: ${CRT_DEPS} ${CRTTOOL}
1659 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloydf1477d42015-12-02 18:33:55 +00001660 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001661 @echo "Built $@ successfully"
1662 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloydf1477d42015-12-02 18:33:55 +00001663 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001664endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001665
1666${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001667 $(eval ${CHECK_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001668 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1669 ${Q}${FIPTOOL} info $@
Evan Lloydf1477d42015-12-02 18:33:55 +00001670 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001671 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001672 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001673
Yatharth Kochar01912622015-10-12 12:33:47 +01001674ifneq (${GENERATE_COT},0)
1675fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1676 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd052ab522017-04-11 16:52:00 +01001677 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001678 @echo "Built $@ successfully"
1679 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd052ab522017-04-11 16:52:00 +01001680 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001681endif #(GENERATE_COT)
Yatharth Kochar01912622015-10-12 12:33:47 +01001682
1683${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001684 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001685 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1686 ${Q}${FIPTOOL} info $@
Evan Lloyd052ab522017-04-11 16:52:00 +01001687 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001688 @echo "Built $@ successfully"
Evan Lloyd052ab522017-04-11 16:52:00 +01001689 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001690
Juan Castillo73c99d42015-08-18 14:23:04 +01001691fiptool: ${FIPTOOL}
1692fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001693fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001694
Pali Rohára9812202020-11-24 15:38:08 +01001695${FIPTOOL}: FORCE
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001696ifdef UNIX_MK
Lionel Debieve598b1662022-11-14 11:05:09 +01001697 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001698else
1699# Clear the MAKEFLAGS as we do not want
1700# to pass the gnumake flags to nmake.
1701 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001702endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001703
Pali Rohára9812202020-11-24 15:38:08 +01001704romlib.bin: libraries FORCE
John Tsichritzisbbb24f62019-05-21 15:47:37 +01001705 ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all
Roberto Vargas5accce52018-05-22 16:05:42 +01001706
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001707memmap: all
Harrison Mutaiaf5b49e2023-02-23 10:33:58 +00001708ifdef UNIX_MK
1709 ${Q}PYTHONPATH=${CURDIR}/tools/memory \
1710 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1711else
1712 ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
1713 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1714endif
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001715
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001716doc:
1717 @echo " BUILD DOCUMENTATION"
1718 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1719
Sumit Garg90aa9012019-11-11 18:46:36 +05301720enctool: ${ENCTOOL}
1721
Pali Rohára9812202020-11-24 15:38:08 +01001722${ENCTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001723 ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
Sumit Garg90aa9012019-11-11 18:46:36 +05301724 @${ECHO_BLANK_LINE}
1725 @echo "Built $@ successfully"
1726 @${ECHO_BLANK_LINE}
1727
Joakim Bech35fab8c2014-01-23 14:51:49 +01001728cscope:
1729 @echo " CSCOPE"
1730 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1731 ${Q}cscope -b -q -k
1732
Ryan Harkin72ee3312014-01-15 16:55:07 +00001733help:
John Tsichritzis7c231262019-05-21 15:57:31 +01001734 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001735 @echo ""
1736 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +00001737 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001738 @echo ""
John Tsichritzis7c231262019-05-21 15:57:31 +01001739 @echo "platform = ${PLATFORM_LIST}"
1740 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001741 @echo "Please refer to the User Guide for a list of all supported options."
1742 @echo "Note that the build system doesn't track dependencies for build "
1743 @echo "options. Therefore, if any of the build options are changed "
1744 @echo "from a previous build, a clean build must be performed."
1745 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001746 @echo "Supported Targets:"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001747 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001748 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001749 @echo " bl2 Build the BL2 binary"
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001750 @echo " bl2u Build the BL2U binary"
Juan Castillod1786372015-12-14 09:35:25 +00001751 @echo " bl31 Build the BL31 binary"
Soby Mathew9d29c222016-05-05 14:33:33 +01001752 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1753 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castillo73c99d42015-08-18 14:23:04 +01001754 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001755 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochar01912622015-10-12 12:33:47 +01001756 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001757 @echo " checkcodebase Check the coding style of the entire source tree"
1758 @echo " checkpatch Check the coding style on changes in the current"
1759 @echo " branch against BASE_COMMIT (default origin/master)"
1760 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001761 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001762 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo6f971622014-10-21 11:30:42 +01001763 @echo " certtool Build the Certificate generation tool"
Sumit Garg90aa9012019-11-11 18:46:36 +05301764 @echo " enctool Build the Firmware encryption tool"
Andreas Färber59dead22016-10-10 05:18:49 +02001765 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001766 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaz26010da2018-11-27 14:58:04 +00001767 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathew38c14d82017-12-14 17:44:56 +00001768 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001769 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001770 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001771 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001772 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001773 @echo ""
1774 @echo "example: build all targets for the FVP platform:"
1775 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001776
1777.PHONY: FORCE
1778FORCE:;