blob: 9e5f51982122a1b87739f89d167f81b454aebe1a [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 CIb1f57502025-02-14 17:10:59 +000013VERSION_PATCH := 13
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
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001039# Determine if FEAT_RNG is supported
1040ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0)
1041
1042# Determine if FEAT_SB is supported
1043ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0)
1044
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001045ifeq ($(PSA_CRYPTO),1)
1046 $(info PSA_CRYPTO is an experimental feature)
1047endif
1048
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001049################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001050# Process platform overrideable behaviour
1051################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001052
Manish Pandey5f24ce92021-10-06 10:59:52 +01001053ifdef BL1_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001054 NEED_BL1 := yes
1055endif #(BL1_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001056
Juan Castillo73c99d42015-08-18 14:23:04 +01001057ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +01001058 NEED_BL2 := yes
1059
1060 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1061 # Certificate generation tools. This flag can be overridden by the platform.
1062 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001063 # If booting an EL3 payload there is no need for a BL33 image
1064 # in the FIP file.
1065 NEED_BL33 := no
1066 else
1067 ifdef PRELOADED_BL33_BASE
1068 # If booting a BL33 preloaded image there is no need of
1069 # another one in the FIP file.
1070 NEED_BL33 := no
1071 else
1072 NEED_BL33 ?= yes
1073 endif
1074 endif
1075endif #(BL2_SOURCES)
Juan Castillo73c99d42015-08-18 14:23:04 +01001076
Manish Pandey5f24ce92021-10-06 10:59:52 +01001077ifdef BL2U_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001078 NEED_BL2U := yes
1079endif #(BL2U_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001080
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001081# If SCP_BL2 is given, we always want FIP to include it.
1082ifdef SCP_BL2
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001083 NEED_SCP_BL2 := yes
1084endif #(SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001085
Soby Mathew5744e872017-11-14 14:10:10 +00001086# For AArch32, BL31 is not currently supported.
1087ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001088 ifdef BL31_SOURCES
1089 # When booting an EL3 payload, there is no need to compile the BL31
1090 # image nor put it in the FIP.
1091 ifndef EL3_PAYLOAD_BASE
1092 NEED_BL31 := yes
1093 endif
1094 endif
1095endif #(ARCH=aarch64)
Soby Mathew5744e872017-11-14 14:10:10 +00001096
Juan Castillo73c99d42015-08-18 14:23:04 +01001097# Process TBB related flags
1098ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001099 # Common cert_create options
1100 ifneq (${CREATE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001101 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +01001102 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001103 ifneq (${SAVE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001104 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +01001105 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001106 endif
1107 endif
1108 # Include TBBR makefile (unless the platform indicates otherwise)
1109 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001110 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001111 endif
1112endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001113
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001114ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001115 FIP_ARGS += --align ${FIP_ALIGN}
1116endif #(FIP_ALIGN)
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001117
Manish Pandey5f24ce92021-10-06 10:59:52 +01001118ifdef FDT_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001119 NEED_FDT := yes
1120endif #(FDT_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001121
Juan Castillo73c99d42015-08-18 14:23:04 +01001122################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +08001123# Include libraries' Makefile that are used in all BL
1124################################################################################
1125
1126include lib/stack_protector/stack_protector.mk
1127
1128################################################################################
Soby Mathew8a860522017-02-14 10:05:07 +00001129# Include BL specific makefiles
1130################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +01001131
1132ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001133include bl1/bl1.mk
1134endif
1135
Manish Pandey5f24ce92021-10-06 10:59:52 +01001136ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001137include bl2/bl2.mk
1138endif
1139
Manish Pandey5f24ce92021-10-06 10:59:52 +01001140ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001141include bl2u/bl2u.mk
1142endif
1143
Soby Mathew5744e872017-11-14 14:10:10 +00001144ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001145include bl31/bl31.mk
1146endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001147
Juan Castillo73c99d42015-08-18 14:23:04 +01001148################################################################################
1149# Build options checks
1150################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001151
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001152# Boolean_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001153$(eval $(call assert_booleans,\
1154 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001155 ALLOW_RO_XLAT_TABLES \
1156 BL2_ENABLE_SP_LOAD \
1157 COLD_BOOT_SINGLE_CPU \
1158 CREATE_KEYS \
1159 CTX_INCLUDE_AARCH32_REGS \
1160 CTX_INCLUDE_FPREGS \
1161 CTX_INCLUDE_EL2_REGS \
1162 DEBUG \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001163 DYN_DISABLE_AUTH \
1164 EL3_EXCEPTION_HANDLING \
1165 ENABLE_AMU_AUXILIARY_COUNTERS \
1166 ENABLE_AMU_FCONF \
1167 AMU_RESTRICT_COUNTERS \
1168 ENABLE_ASSERTIONS \
1169 ENABLE_FEAT_SB \
1170 ENABLE_PIE \
1171 ENABLE_PMF \
1172 ENABLE_PSCI_STAT \
1173 ENABLE_RUNTIME_INSTRUMENTATION \
1174 ENABLE_SME_FOR_SWD \
1175 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001176 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001177 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001178 ERROR_DEPRECATED \
1179 FAULT_INJECTION_SUPPORT \
1180 GENERATE_COT \
1181 GICV2_G0_FOR_EL3 \
1182 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravi9cec5492023-09-28 13:17:24 -05001183 HARDEN_SLS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001184 HW_ASSISTED_COHERENCY \
1185 MEASURED_BOOT \
1186 DRTM_SUPPORT \
1187 NS_TIMER_SWITCH \
1188 OVERRIDE_LIBC \
1189 PL011_GENERIC_UART \
1190 PLAT_RSS_NOT_SUPPORTED \
1191 PROGRAMMABLE_RESET_ADDRESS \
1192 PSCI_EXTENDED_STATE_ID \
1193 PSCI_OS_INIT_MODE \
1194 RESET_TO_BL31 \
1195 SAVE_KEYS \
1196 SEPARATE_CODE_AND_RODATA \
1197 SEPARATE_BL2_NOLOAD_REGION \
1198 SEPARATE_NOBITS_REGION \
1199 SPIN_ON_BL1_EXIT \
1200 SPM_MM \
1201 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001202 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001203 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001204 ENABLE_SPMD_LP \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001205 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001206 TRUSTED_BOARD_BOOT \
1207 USE_COHERENT_MEM \
1208 USE_DEBUGFS \
1209 ARM_IO_IN_DTB \
1210 SDEI_IN_FCONF \
1211 SEC_INT_DESC_IN_FCONF \
1212 USE_ROMLIB \
1213 USE_TBBR_DEFS \
1214 WARMBOOT_ENABLE_DCACHE_EARLY \
1215 RESET_TO_BL2 \
1216 BL2_IN_XIP_MEM \
1217 BL2_INV_DCACHE \
1218 USE_SPINLOCK_CAS \
1219 ENCRYPT_BL31 \
1220 ENCRYPT_BL32 \
1221 ERRATA_SPECULATIVE_AT \
1222 RAS_TRAP_NS_ERR_REC_ACCESS \
1223 COT_DESC_IN_DTB \
1224 USE_SP804_TIMER \
1225 PSA_FWU_SUPPORT \
1226 ENABLE_MPMM \
1227 ENABLE_MPMM_FCONF \
1228 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001229 TRNG_SUPPORT \
Sona Mathewffea3842022-11-18 18:05:38 -06001230 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001231 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001232 CONDITIONAL_CMO \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001233 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001234 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001235 INIT_UNUSED_NS_EL2 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001236)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001237
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001238# Numeric_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001239$(eval $(call assert_numerics,\
1240 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001241 ARM_ARCH_MAJOR \
1242 ARM_ARCH_MINOR \
1243 BRANCH_PROTECTION \
1244 CTX_INCLUDE_PAUTH_REGS \
1245 CTX_INCLUDE_MTE_REGS \
1246 CTX_INCLUDE_NEVE_REGS \
1247 CRYPTO_SUPPORT \
Boyan Karatotev83a4dae2023-02-16 09:45:29 +00001248 DISABLE_MTPMU \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001249 ENABLE_BRBE_FOR_NS \
1250 ENABLE_TRBE_FOR_NS \
1251 ENABLE_BTI \
1252 ENABLE_PAUTH \
1253 ENABLE_FEAT_AMU \
1254 ENABLE_FEAT_AMUv1p1 \
1255 ENABLE_FEAT_CSV2_2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001256 ENABLE_FEAT_DIT \
1257 ENABLE_FEAT_ECV \
1258 ENABLE_FEAT_FGT \
1259 ENABLE_FEAT_HCX \
1260 ENABLE_FEAT_PAN \
1261 ENABLE_FEAT_RNG \
1262 ENABLE_FEAT_RNG_TRAP \
1263 ENABLE_FEAT_SEL2 \
1264 ENABLE_FEAT_TCR2 \
1265 ENABLE_FEAT_S2PIE \
1266 ENABLE_FEAT_S1PIE \
1267 ENABLE_FEAT_S2POE \
1268 ENABLE_FEAT_S1POE \
1269 ENABLE_FEAT_GCS \
1270 ENABLE_FEAT_VHE \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001271 ENABLE_FEAT_MTE_PERM \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001272 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001273 ENABLE_RME \
1274 ENABLE_SPE_FOR_NS \
1275 ENABLE_SYS_REG_TRACE_FOR_NS \
1276 ENABLE_SME_FOR_NS \
1277 ENABLE_SME2_FOR_NS \
1278 ENABLE_SVE_FOR_NS \
1279 ENABLE_TRF_FOR_NS \
1280 FW_ENC_STATUS \
1281 NR_OF_FW_BANKS \
1282 NR_OF_IMAGES_IN_FW_BANK \
1283 TWED_DELAY \
1284 ENABLE_FEAT_TWED \
1285 SVE_VECTOR_LEN \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001286 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001287)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001288
Justin Chadwellaacff742019-07-29 17:13:10 +01001289ifdef KEY_SIZE
1290 $(eval $(call assert_numeric,KEY_SIZE))
1291endif
1292
Justin Chadwell1f461972019-08-20 11:01:52 +01001293ifeq ($(filter $(SANITIZE_UB), on off trap),)
1294 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1295endif
1296
Juan Castillo73c99d42015-08-18 14:23:04 +01001297################################################################################
1298# Add definitions to the cpp preprocessor based on the current build options.
1299# This is done after including the platform specific makefile to allow the
1300# platform to overwrite the default options
1301################################################################################
1302
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001303$(eval $(call add_defines,\
1304 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001305 ALLOW_RO_XLAT_TABLES \
1306 ARM_ARCH_MAJOR \
1307 ARM_ARCH_MINOR \
1308 BL2_ENABLE_SP_LOAD \
1309 COLD_BOOT_SINGLE_CPU \
1310 CTX_INCLUDE_AARCH32_REGS \
1311 CTX_INCLUDE_FPREGS \
1312 CTX_INCLUDE_PAUTH_REGS \
1313 EL3_EXCEPTION_HANDLING \
1314 CTX_INCLUDE_MTE_REGS \
1315 CTX_INCLUDE_EL2_REGS \
1316 CTX_INCLUDE_NEVE_REGS \
1317 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1318 DISABLE_MTPMU \
1319 ENABLE_FEAT_AMU \
1320 ENABLE_AMU_AUXILIARY_COUNTERS \
1321 ENABLE_AMU_FCONF \
1322 AMU_RESTRICT_COUNTERS \
1323 ENABLE_ASSERTIONS \
1324 ENABLE_BTI \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001325 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001326 ENABLE_PAUTH \
1327 ENABLE_PIE \
1328 ENABLE_PMF \
1329 ENABLE_PSCI_STAT \
1330 ENABLE_RME \
1331 ENABLE_RUNTIME_INSTRUMENTATION \
1332 ENABLE_SME_FOR_NS \
1333 ENABLE_SME2_FOR_NS \
1334 ENABLE_SME_FOR_SWD \
1335 ENABLE_SPE_FOR_NS \
1336 ENABLE_SVE_FOR_NS \
1337 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001338 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001339 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001340 ENCRYPT_BL31 \
1341 ENCRYPT_BL32 \
1342 ERROR_DEPRECATED \
1343 FAULT_INJECTION_SUPPORT \
1344 GICV2_G0_FOR_EL3 \
1345 HANDLE_EA_EL3_FIRST_NS \
1346 HW_ASSISTED_COHERENCY \
1347 LOG_LEVEL \
1348 MEASURED_BOOT \
1349 DRTM_SUPPORT \
1350 NS_TIMER_SWITCH \
1351 PL011_GENERIC_UART \
1352 PLAT_${PLAT} \
1353 PLAT_RSS_NOT_SUPPORTED \
1354 PROGRAMMABLE_RESET_ADDRESS \
1355 PSCI_EXTENDED_STATE_ID \
1356 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001357 RESET_TO_BL31 \
1358 SEPARATE_CODE_AND_RODATA \
1359 SEPARATE_BL2_NOLOAD_REGION \
1360 SEPARATE_NOBITS_REGION \
1361 RECLAIM_INIT_CODE \
1362 SPD_${SPD} \
1363 SPIN_ON_BL1_EXIT \
1364 SPM_MM \
1365 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001366 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001367 SPMD_SPM_AT_SEL2 \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001368 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001369 TRUSTED_BOARD_BOOT \
1370 CRYPTO_SUPPORT \
1371 TRNG_SUPPORT \
1372 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001373 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001374 USE_COHERENT_MEM \
1375 USE_DEBUGFS \
1376 ARM_IO_IN_DTB \
1377 SDEI_IN_FCONF \
1378 SEC_INT_DESC_IN_FCONF \
1379 USE_ROMLIB \
1380 USE_TBBR_DEFS \
1381 WARMBOOT_ENABLE_DCACHE_EARLY \
1382 RESET_TO_BL2 \
1383 BL2_RUNS_AT_EL3 \
1384 BL2_IN_XIP_MEM \
1385 BL2_INV_DCACHE \
1386 USE_SPINLOCK_CAS \
1387 ERRATA_SPECULATIVE_AT \
1388 RAS_TRAP_NS_ERR_REC_ACCESS \
1389 COT_DESC_IN_DTB \
1390 USE_SP804_TIMER \
1391 ENABLE_FEAT_RNG \
1392 ENABLE_FEAT_RNG_TRAP \
1393 ENABLE_FEAT_SB \
1394 ENABLE_FEAT_DIT \
1395 NR_OF_FW_BANKS \
1396 NR_OF_IMAGES_IN_FW_BANK \
1397 PSA_FWU_SUPPORT \
1398 ENABLE_BRBE_FOR_NS \
1399 ENABLE_TRBE_FOR_NS \
1400 ENABLE_SYS_REG_TRACE_FOR_NS \
1401 ENABLE_TRF_FOR_NS \
1402 ENABLE_FEAT_HCX \
1403 ENABLE_MPMM \
1404 ENABLE_MPMM_FCONF \
1405 ENABLE_FEAT_FGT \
1406 ENABLE_FEAT_ECV \
1407 ENABLE_FEAT_AMUv1p1 \
1408 ENABLE_FEAT_SEL2 \
1409 ENABLE_FEAT_VHE \
1410 ENABLE_FEAT_CSV2_2 \
1411 ENABLE_FEAT_PAN \
1412 ENABLE_FEAT_TCR2 \
1413 ENABLE_FEAT_S2PIE \
1414 ENABLE_FEAT_S1PIE \
1415 ENABLE_FEAT_S2POE \
1416 ENABLE_FEAT_S1POE \
1417 ENABLE_FEAT_GCS \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001418 ENABLE_FEAT_MTE_PERM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001419 FEATURE_DETECTION \
1420 TWED_DELAY \
1421 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001422 CONDITIONAL_CMO \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001423 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidananda8cf6fa2023-04-26 15:57:30 +01001424 SVE_VECTOR_LEN \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001425 ENABLE_SPMD_LP \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001426 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001427 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001428 INIT_UNUSED_NS_EL2 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001429)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001430
Justin Chadwell1f461972019-08-20 11:01:52 +01001431ifeq (${SANITIZE_UB},trap)
1432 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001433endif #(SANITIZE_UB)
Justin Chadwell1f461972019-08-20 11:01:52 +01001434
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001435# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1436ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001437 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1438else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001439# Define the PRELOADED_BL33_BASE flag only if it is provided and
1440# EL3_PAYLOAD_BASE is not defined, as it has priority.
1441 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001442 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001443 endif
1444endif #(EL3_PAYLOAD_BASE)
Juan Castillo73c99d42015-08-18 14:23:04 +01001445
Soby Mathew209a60c2018-03-26 12:43:37 +01001446# Define the DYN_DISABLE_AUTH flag only if set.
1447ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001448 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew209a60c2018-03-26 12:43:37 +01001449endif
1450
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001451ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001452 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001453endif
1454
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001455# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001456ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001457ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001458 -include $(BUILD_PLAT)/sp_gen.mk
1459 FIP_DEPS += sp
1460 CRT_DEPS += sp
1461 NEED_SP_PKG := yes
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001462else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001463 ifeq (${SPMD_SPM_AT_SEL2},1)
1464 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1465 endif
1466endif #(SP_LAYOUT_FILE)
1467endif #(SPD)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001468
Juan Castillo73c99d42015-08-18 14:23:04 +01001469################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001470# Build targets
1471################################################################################
1472
Sumit Garg90aa9012019-11-11 18:46:36 +05301473.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 +01001474.SUFFIXES:
1475
1476all: msg_start
1477
1478msg_start:
1479 @echo "Building ${PLAT}"
1480
Soby Mathew7a24cba2015-10-26 14:29:21 +00001481ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001482# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001483ifneq ($(findstring clang,$(notdir $(CC))),)
1484 CPPFLAGS += -Wno-error=deprecated-declarations
1485else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001486 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001487endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001488endif #(!ERROR_DEPRECATED)
Soby Mathew7a24cba2015-10-26 14:29:21 +00001489
Roberto Vargas5accce52018-05-22 16:05:42 +01001490$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas61f72a32018-05-08 10:27:10 +01001491$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001492
Juan Castillo73c99d42015-08-18 14:23:04 +01001493# Expand build macros for the different images
1494ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001495BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Aweke434d0492021-07-11 17:25:48 -05001496$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001497endif #(NEED_BL1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001498
1499ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001500
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -06001501ifeq (${RESET_TO_BL2}, 0)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001502FIP_BL2_ARGS := tb-fw
1503endif
1504
Chris Kayeb1acfb2021-09-28 15:44:37 +01001505BL2_SOURCES := $(sort ${BL2_SOURCES})
1506
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001507$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001508 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001509
1510endif #(NEED_BL2)
Juan Castillo73c99d42015-08-18 14:23:04 +01001511
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001512ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001513$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001514endif #(NEED_SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001515
Juan Castillo73c99d42015-08-18 14:23:04 +01001516ifeq (${NEED_BL31},yes)
1517BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001518# Sort BL31 source files to remove duplicates
1519BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301520ifneq (${DECRYPTION_SUPPORT},none)
1521$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001522 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301523else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001524$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001525 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001526endif #(DECRYPTION_SUPPORT)
1527endif #(NEED_BL31)
Juan Castillo73c99d42015-08-18 14:23:04 +01001528
Juan Castillo70d1fc52015-11-12 10:59:26 +00001529# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001530# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001531# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001532ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001533# Sort BL32 source files to remove duplicates
1534BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001535BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1536
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301537ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001538$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301539 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1540else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001541$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001542 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001543endif #(DECRYPTION_SUPPORT)
1544endif #(NEED_BL32)
Juan Castillo73c99d42015-08-18 14:23:04 +01001545
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001546# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1547# needs to be built from RMM_SOURCES.
1548ifeq (${NEED_RMM},yes)
1549# Sort RMM source files to remove duplicates
1550RMM_SOURCES := $(sort ${RMM_SOURCES})
1551BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1552
1553$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001554 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1555endif #(NEED_RMM)
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001556
Juan Castillo73c99d42015-08-18 14:23:04 +01001557# Add the BL33 image if required by the platform
1558ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001559$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001560endif #(NEED_BL33)
Juan Castillodb6071c2015-01-13 12:21:04 +00001561
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001562ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001563$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001564 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001565endif #(NEED_BL2U)
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001566
Nishanth Menon03b397a2016-10-14 01:13:57 +00001567# Expand build macros for the different images
1568ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001569 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001570endif #(NEED_FDT)
Nishanth Menon03b397a2016-10-14 01:13:57 +00001571
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001572# Add Secure Partition packages
1573ifeq (${NEED_SP_PKG},yes)
Karl Meakin20629b32023-02-14 11:56:02 +00001574$(BUILD_PLAT)/sp_gen.mk : ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1575 ${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alves822c7272022-03-22 16:28:51 +00001576sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001577 @${ECHO_BLANK_LINE}
1578 @echo "Built SP Images successfully"
1579 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001580endif #(NEED_SP_PKG)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001581
Ian Spray36eaaf32014-01-30 17:25:28 +00001582locate-checkpatch:
1583ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001584 $(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 +00001585else
1586ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001587 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001588endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001589endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001590
Achin Gupta4f6ad662013-10-25 09:08:21 +01001591clean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001592 @echo " CLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001593 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001594ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001595 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001596else
1597# Clear the MAKEFLAGS as we do not want
1598# to pass the gnumake flags to nmake.
1599 ${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 +01001600endif #(UNIX_MK)
Juan Castillo73c99d42015-08-18 14:23:04 +01001601 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Garg90aa9012019-11-11 18:46:36 +05301602 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargas5accce52018-05-22 16:05:42 +01001603 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001604
James Morrisseyeaaeece2013-11-01 13:56:59 +00001605realclean distclean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001606 @echo " REALCLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001607 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1608 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001609ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001610 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001611else
1612# Clear the MAKEFLAGS as we do not want
1613# to pass the gnumake flags to nmake.
1614 ${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 +01001615endif #(UNIX_MK)
Nicolas Boulengueze15591a2021-03-31 12:22:45 +02001616 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Garg90aa9012019-11-11 18:46:36 +05301617 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargas5accce52018-05-22 16:05:42 +01001618 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001619
Ian Spray36eaaf32014-01-30 17:25:28 +00001620checkcodebase: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001621 @echo " CHECKING STYLE"
Dan Handley1a41e8c2016-06-02 18:21:02 +01001622 @if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001623 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001624 while read GIT_FILE ; \
1625 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1626 done ; \
1627 else \
1628 find . -type f -not -iwholename "*.git*" \
1629 -not -iwholename "*build*" \
1630 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001631 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001632 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001633 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001634 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1635 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001636
1637checkpatch: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001638 @echo " CHECKING STYLE"
Yann Gautier02a76d52019-03-08 15:44:00 +01001639 @if test -n "${CHECKPATCH_OPTS}"; then \
1640 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1641 fi
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001642 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001643 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1644 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001645 printf "\n[*] Checking style of '$$commit'\n\n"; \
1646 git log --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001647 -- ${CHECK_PATHS} | \
1648 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001649 git diff --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001650 -- ${CHECK_PATHS} | \
1651 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001652 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001653
1654certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001655
Pali Rohára9812202020-11-24 15:38:08 +01001656${CRTTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001657 ${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 +00001658 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001659 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001660 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001661
1662ifneq (${GENERATE_COT},0)
1663certificates: ${CRT_DEPS} ${CRTTOOL}
1664 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloydf1477d42015-12-02 18:33:55 +00001665 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001666 @echo "Built $@ successfully"
1667 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloydf1477d42015-12-02 18:33:55 +00001668 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001669endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001670
1671${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001672 $(eval ${CHECK_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001673 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1674 ${Q}${FIPTOOL} info $@
Evan Lloydf1477d42015-12-02 18:33:55 +00001675 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001676 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001677 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001678
Yatharth Kochar01912622015-10-12 12:33:47 +01001679ifneq (${GENERATE_COT},0)
1680fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1681 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd052ab522017-04-11 16:52:00 +01001682 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001683 @echo "Built $@ successfully"
1684 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd052ab522017-04-11 16:52:00 +01001685 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001686endif #(GENERATE_COT)
Yatharth Kochar01912622015-10-12 12:33:47 +01001687
1688${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001689 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001690 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1691 ${Q}${FIPTOOL} info $@
Evan Lloyd052ab522017-04-11 16:52:00 +01001692 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001693 @echo "Built $@ successfully"
Evan Lloyd052ab522017-04-11 16:52:00 +01001694 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001695
Juan Castillo73c99d42015-08-18 14:23:04 +01001696fiptool: ${FIPTOOL}
1697fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001698fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001699
Pali Rohára9812202020-11-24 15:38:08 +01001700${FIPTOOL}: FORCE
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001701ifdef UNIX_MK
Lionel Debieve598b1662022-11-14 11:05:09 +01001702 ${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 +01001703else
1704# Clear the MAKEFLAGS as we do not want
1705# to pass the gnumake flags to nmake.
1706 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001707endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001708
Pali Rohára9812202020-11-24 15:38:08 +01001709romlib.bin: libraries FORCE
John Tsichritzisbbb24f62019-05-21 15:47:37 +01001710 ${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 +01001711
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001712memmap: all
Harrison Mutaiaf5b49e2023-02-23 10:33:58 +00001713ifdef UNIX_MK
1714 ${Q}PYTHONPATH=${CURDIR}/tools/memory \
1715 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1716else
1717 ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
1718 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1719endif
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001720
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001721doc:
1722 @echo " BUILD DOCUMENTATION"
1723 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1724
Sumit Garg90aa9012019-11-11 18:46:36 +05301725enctool: ${ENCTOOL}
1726
Pali Rohára9812202020-11-24 15:38:08 +01001727${ENCTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001728 ${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 +05301729 @${ECHO_BLANK_LINE}
1730 @echo "Built $@ successfully"
1731 @${ECHO_BLANK_LINE}
1732
Joakim Bech35fab8c2014-01-23 14:51:49 +01001733cscope:
1734 @echo " CSCOPE"
1735 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1736 ${Q}cscope -b -q -k
1737
Ryan Harkin72ee3312014-01-15 16:55:07 +00001738help:
John Tsichritzis7c231262019-05-21 15:57:31 +01001739 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001740 @echo ""
1741 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +00001742 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001743 @echo ""
John Tsichritzis7c231262019-05-21 15:57:31 +01001744 @echo "platform = ${PLATFORM_LIST}"
1745 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001746 @echo "Please refer to the User Guide for a list of all supported options."
1747 @echo "Note that the build system doesn't track dependencies for build "
1748 @echo "options. Therefore, if any of the build options are changed "
1749 @echo "from a previous build, a clean build must be performed."
1750 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001751 @echo "Supported Targets:"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001752 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001753 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001754 @echo " bl2 Build the BL2 binary"
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001755 @echo " bl2u Build the BL2U binary"
Juan Castillod1786372015-12-14 09:35:25 +00001756 @echo " bl31 Build the BL31 binary"
Soby Mathew9d29c222016-05-05 14:33:33 +01001757 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1758 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castillo73c99d42015-08-18 14:23:04 +01001759 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001760 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochar01912622015-10-12 12:33:47 +01001761 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001762 @echo " checkcodebase Check the coding style of the entire source tree"
1763 @echo " checkpatch Check the coding style on changes in the current"
1764 @echo " branch against BASE_COMMIT (default origin/master)"
1765 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001766 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001767 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo6f971622014-10-21 11:30:42 +01001768 @echo " certtool Build the Certificate generation tool"
Sumit Garg90aa9012019-11-11 18:46:36 +05301769 @echo " enctool Build the Firmware encryption tool"
Andreas Färber59dead22016-10-10 05:18:49 +02001770 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001771 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaz26010da2018-11-27 14:58:04 +00001772 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathew38c14d82017-12-14 17:44:56 +00001773 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001774 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001775 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001776 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001777 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001778 @echo ""
1779 @echo "example: build all targets for the FVP platform:"
1780 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001781
1782.PHONY: FORCE
1783FORCE:;