blob: 700a56189bb6665975918a6d1c9ff3ea4661b4d8 [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 CId29b9922024-03-18 09:21:32 +000013VERSION_PATCH := 5
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
Alexei Fedorovf1821792020-12-07 16:38:53 +0000166# Set the compiler's architecture feature modifiers
167ifneq ($(arch-features), none)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100168 # Strip "none+" from arch-features
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500169 arch-features := $(subst none+,,$(arch-features))
170 march-directive := $(march-directive)+$(arch-features)
Alexei Fedorovf1821792020-12-07 16:38:53 +0000171# Print features
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100172 $(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
173endif #(arch-features)
Chris Kay4e044782021-03-09 13:34:35 +0000174
originc8a992f2022-01-19 16:30:14 +0000175ifneq ($(findstring clang,$(notdir $(CC))),)
176 ifneq ($(findstring armclang,$(notdir $(CC))),)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500177 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
178 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originc8a992f2022-01-19 16:30:14 +0000179 LD := $(LINKER)
180 else
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500181 TF_CFLAGS_aarch32 = $(target32-directive)
182 TF_CFLAGS_aarch64 := -target aarch64-elf
originc8a992f2022-01-19 16:30:14 +0000183 LD := $(shell $(CC) --print-prog-name ld.lld)
184
185 AR := $(shell $(CC) --print-prog-name llvm-ar)
186 OD := $(shell $(CC) --print-prog-name llvm-objdump)
187 OC := $(shell $(CC) --print-prog-name llvm-objcopy)
188 endif
189
190 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
191 PP := $(CC) -E $(TF_CFLAGS_$(ARCH))
192 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600193else ifneq ($(findstring gcc,$(notdir $(CC))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100194 ifeq ($(ENABLE_LTO),1)
195 # Enable LTO only for aarch64
196 ifeq (${ARCH},aarch64)
197 LTO_CFLAGS = -flto
198 # Use gcc as a wrapper for the ld, recommended for LTO
199 LINKER := ${CROSS_COMPILE}gcc
200 endif
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600201 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100202 LD = $(LINKER)
dp-armd5461852017-05-02 12:00:08 +0100203else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100204 LD = $(LINKER)
205endif #(clang)
dp-armd5461852017-05-02 12:00:08 +0100206
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100207# Process Debug flag
208$(eval $(call add_define,DEBUG))
209ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100210 BUILD_TYPE := debug
211 TF_CFLAGS += -g -gdwarf-4
212 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100213
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100214 # Use LOG_LEVEL_INFO by default for debug builds
215 LOG_LEVEL := 40
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100216else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100217 BUILD_TYPE := release
218 # Use LOG_LEVEL_NOTICE by default for release builds
219 LOG_LEVEL := 20
220endif #(Debug)
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100221
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800222# Default build string (git branch and commit)
223ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100224 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800225endif
laurenw-armdddf4282022-07-12 10:12:05 -0500226VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800227
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100228ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100229 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100230else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100231 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100232else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100233 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
234endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100235
Sandrine Bailleuxa9c4dde2018-07-03 09:14:45 +0200236TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-armd5461852017-05-02 12:00:08 +0100237TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathew9d29c222016-05-05 14:33:33 +0100238
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500239ASFLAGS += $(march-directive)
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000240
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100241##############################################################################
242# WARNINGS Configuration
243###############################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100244# General warnings
245WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier34b508b2021-05-20 13:18:14 +0200246 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000247 -Wredundant-decls
248# stricter warnings
249WARNINGS += -Wextra -Wno-trigraphs
250# too verbose for generic build
251WARNINGS += -Wno-missing-field-initializers \
252 -Wno-type-limits -Wno-sign-compare \
253# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
254WARNINGS += -Wno-unused-parameter
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100255
256# Additional warnings
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000257# Level 1 - infrequent warnings we should have none of
258# full -Wextra
259WARNING1 += -Wsign-compare
260WARNING1 += -Wtype-limits
261WARNING1 += -Wmissing-field-initializers
Yann Gautiere7c645b2018-12-10 18:00:26 +0100262
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000263# Level 2 - problematic warnings that we want
264# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
265# TODO: disable just for them and move into default build
266WARNING2 += -Wold-style-definition
267WARNING2 += -Wmissing-prototypes
268WARNING2 += -Wmissing-format-attribute
269# TF-A aims to comply with this eventually. Effort too large at present
270WARNING2 += -Wundef
Boyan Karatotevd141e632022-11-21 14:49:05 +0000271# currently very involved and many platforms set this off
272WARNING2 += -Wunused-const-variable=2
Yann Gautiere7c645b2018-12-10 18:00:26 +0100273
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000274# Level 3 - very pedantic, frequently ignored
Yann Gautiere7c645b2018-12-10 18:00:26 +0100275WARNING3 := -Wbad-function-cast
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000276WARNING3 += -Waggregate-return
277WARNING3 += -Wnested-externs
278WARNING3 += -Wcast-align
Yann Gautiere7c645b2018-12-10 18:00:26 +0100279WARNING3 += -Wcast-qual
280WARNING3 += -Wconversion
281WARNING3 += -Wpacked
Yann Gautiere7c645b2018-12-10 18:00:26 +0100282WARNING3 += -Wpointer-arith
Yann Gautiere7c645b2018-12-10 18:00:26 +0100283WARNING3 += -Wswitch-default
Yann Gautiere7c645b2018-12-10 18:00:26 +0100284
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000285# Setting W is quite verbose and most warnings will be pre-existing issues
286# outside of the contributor's control. Don't fail the build on them so warnings
287# can be seen and hopefully addressed
288ifdef W
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100289 ifneq (${W},0)
290 E ?= 0
291 endif
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000292endif
293
Yann Gautiere7c645b2018-12-10 18:00:26 +0100294ifeq (${W},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100295 WARNINGS += $(WARNING1)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100296else ifeq (${W},2)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100297 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100298else ifeq (${W},3)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100299 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
300endif #(W)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100301
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100302# Compiler specific warnings
Ambroise Vincent00296572019-05-24 12:47:43 +0100303ifeq ($(findstring clang,$(notdir $(CC))),)
Justin Chadwell93c690e2019-07-03 14:15:56 +0100304# not using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100305WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
306 -Wpacked-bitfield-compat -Wshift-overflow=2 \
307 -Wlogical-op
Govindraj Rajadea23e22023-05-05 09:09:36 -0500308
309# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
310TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
311
Bipin Ravi9cec5492023-09-28 13:17:24 -0500312ifeq ($(HARDEN_SLS), 1)
313 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
314endif
315
Justin Chadwell93c690e2019-07-03 14:15:56 +0100316else
317# using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100318WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
319 -Wlogical-op-parentheses
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100320endif #(Clang Warning)
Ambroise Vincent00296572019-05-24 12:47:43 +0100321
Yann Gautier6336b072018-12-10 18:08:53 +0100322ifneq (${E},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100323 ERRORS := -Werror
324endif #(E)
Yann Gautier6336b072018-12-10 18:08:53 +0100325
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100326################################################################################
327# Compiler and Linker Directives
328################################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100329CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
330 $(ERRORS) $(WARNINGS)
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500331ASFLAGS += $(CPPFLAGS) \
Julius Wernerd5dfdeb2019-07-09 13:49:11 -0700332 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada59de5092016-12-22 12:51:53 +0900333TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Hollandebd6efa2019-10-20 16:11:25 -0500334 -ffunction-sections -fdata-sections \
335 -ffreestanding -fno-builtin -fno-common \
336 -Os -std=gnu99
Juan Castillo73c99d42015-08-18 14:23:04 +0100337
Justin Chadwell1f461972019-08-20 11:01:52 +0100338ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100339 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
340endif #(${SANITIZE_UB},on)
341
Justin Chadwell1f461972019-08-20 11:01:52 +0100342ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100343 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell1f461972019-08-20 11:01:52 +0100344 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100345endif #(${SANITIZE_UB},trap)
Justin Chadwell1f461972019-08-20 11:01:52 +0100346
david cunadof7ec31d2017-11-30 21:58:01 +0000347GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
david cunadof7ec31d2017-11-30 21:58:01 +0000348
Marco Felsch1f49db52022-11-09 12:59:09 +0100349TF_LDFLAGS += -z noexecstack
350
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100351# LD = armlink
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800352ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100353 TF_LDFLAGS += --diag_error=warning --lto_level=O1
354 TF_LDFLAGS += --remove --info=unused,unusedsymbols
355 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100356
357# LD = gcc (used when GCC LTO is enabled)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600358else ifneq ($(findstring gcc,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100359 # Pass ld options with Wl or Xlinker switches
360 TF_LDFLAGS += -Wl,--fatal-warnings -O1
361 TF_LDFLAGS += -Wl,--gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000362
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100363 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
364 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Chris Kayac98b822022-12-22 13:26:37 +0000365
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100366 ifeq ($(ENABLE_LTO),1)
367 ifeq (${ARCH},aarch64)
368 TF_LDFLAGS += -flto -fuse-linker-plugin
369 endif
370 endif #(ENABLE_LTO)
371
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600372# GCC automatically adds fix-cortex-a53-843419 flag when used to link
373# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautiercfe67672023-03-15 16:18:16 +0100374 ifeq (${ARCH},aarch64)
375 ifneq (${ERRATA_A53_843419},1)
376 TF_LDFLAGS += -mno-fix-cortex-a53-843419
377 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100378 endif
379 TF_LDFLAGS += -nostdlib
380 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100381
382# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800383else
Marco Felsch1f49db52022-11-09 12:59:09 +0100384# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
385# are not loaded by a elf loader.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100386 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
387 TF_LDFLAGS += -O1
388 TF_LDFLAGS += --gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000389
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100390 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
391 TF_LDFLAGS += -z max-page-size=4096
Chris Kayac98b822022-12-22 13:26:37 +0000392
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100393# ld.lld doesn't recognize the errata flags,
Yabin Cuiebac6922023-01-19 20:06:04 +0000394# therefore don't add those in that case.
395# ld.lld reports section type mismatch warnings,
396# therefore don't add --fatal-warnings to it.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100397 ifeq ($(findstring ld.lld,$(notdir $(LD))),)
398 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
399 endif
400
401endif #(LD = armlink)
Juan Castillo73c99d42015-08-18 14:23:04 +0100402
403################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500404# Setup ARCH_MAJOR/MINOR before parsing arch_features.
405################################################################################
406ifeq (${ENABLE_RME},1)
407 ARM_ARCH_MAJOR := 8
408 ARM_ARCH_MINOR := 6
409endif
410
411################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100412# Common sources and include directories
413################################################################################
dp-armd801fbb2017-05-04 12:15:35 +0100414include lib/compiler-rt/compiler-rt.mk
Juan Castillo73c99d42015-08-18 14:23:04 +0100415
416BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100417 common/tf_log.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100418 common/${ARCH}/debug.S \
Julius Werner91b48c92018-11-27 22:10:56 -0800419 drivers/console/multi_console.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100420 lib/${ARCH}/cache_helpers.S \
421 lib/${ARCH}/misc_helpers.S \
Boyan Karatotevc73686a2023-02-15 13:21:50 +0000422 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew566034f2018-02-08 17:45:12 +0000423 plat/common/plat_bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100424 plat/common/plat_log_common.c \
dp-arm75311202017-03-07 11:02:47 +0000425 plat/common/${ARCH}/plat_common.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100426 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas61f72a32018-05-08 10:27:10 +0100427 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000428
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100429ifeq ($(notdir $(CC)),armclang)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100430 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100431endif
432
Justin Chadwell1f461972019-08-20 11:01:52 +0100433ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100434 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell1f461972019-08-20 11:01:52 +0100435endif
436
Yann Gautier01d237c2018-06-18 16:00:23 +0200437INCLUDES += -Iinclude \
Antonio Nino Diazf5478de2018-12-17 17:20:57 +0000438 -Iinclude/arch/${ARCH} \
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +0000439 -Iinclude/lib/cpus/${ARCH} \
440 -Iinclude/lib/el3_runtime/${ARCH} \
441 ${PLAT_INCLUDES} \
442 ${SPD_INCLUDES}
443
Nishant Sharmae03dcc82022-08-15 16:37:07 +0100444DTC_FLAGS += -I dts -O dtb
445DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
446 -x assembler-with-cpp $(DEFINES)
447
Antonio Nino Diaz9c6d1c52018-11-19 11:48:30 +0000448include common/backtrace/backtrace.mk
449
Juan Castillo73c99d42015-08-18 14:23:04 +0100450################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500451# Generic definitions
452################################################################################
453include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
454
455ifeq (${BUILD_BASE},)
456 BUILD_BASE := ./build
457endif
458BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
459
460SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
461
462# Platforms providing their own TBB makefile may override this value
463INCLUDE_TBBR_MK := 1
464
465################################################################################
466# Include SPD Makefile if one has been specified
467################################################################################
468
469ifneq (${SPD},none)
470 ifeq (${ARCH},aarch32)
471 $(error "Error: SPD is incompatible with AArch32.")
472 endif
473
474 ifdef EL3_PAYLOAD_BASE
475 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
476 $(warning "The SPD and its BL32 companion will be present but \
477 ignored.")
478 endif
479
480 ifeq (${SPD},spmd)
481 # SPMD is located in std_svc directory
482 SPD_DIR := std_svc
483
484 ifeq ($(SPMD_SPM_AT_SEL2),1)
485 CTX_INCLUDE_EL2_REGS := 1
486 ifeq ($(SPMC_AT_EL3),1)
487 $(error SPM cannot be enabled in both S-EL2 and EL3.)
488 endif
489 endif
490
491 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
492 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
493 endif
494
495 ifeq ($(TS_SP_FW_CONFIG),1)
496 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
497 endif
498
499 ifneq ($(ARM_BL2_SP_LIST_DTS),)
500 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
501 endif
502
503 ifneq ($(SP_LAYOUT_FILE),)
504 BL2_ENABLE_SP_LOAD := 1
505 endif
Govindraj Rajac189adb2023-10-31 14:48:11 -0500506
507 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
508 ifneq ($(SPMC_AT_EL3),1)
509 $(error SEL0 SP cannot be enabled without SPMC at EL3)
510 endif
511 endif
Govindraj Raja35472702023-09-20 14:32:24 -0500512 else
513 # All other SPDs in spd directory
514 SPD_DIR := spd
515 endif #(SPD)
516
517 # We expect to locate an spd.mk under the specified SPD directory
518 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
519
520 ifeq (${SPD_MAKE},)
521 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
522 endif
523 $(info Including ${SPD_MAKE})
524 include ${SPD_MAKE}
525
526 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
527 # Makefile would set NEED_BL32 to "yes". In this case, the build system
528 # supports two mutually exclusive options:
529 # * BL32 is built from source: then BL32_SOURCES must contain the list
530 # of source files to build BL32
531 # * BL32 is a prebuilt binary: then BL32 must point to the image file
532 # that will be included in the FIP
533 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
534 # over the sources.
535endif #(SPD=none)
536
537ifeq (${ENABLE_SPMD_LP}, 1)
538ifneq (${SPD},spmd)
539 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
540endif
541ifeq ($(SPMC_AT_EL3),1)
542 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
543endif
544endif
545
546################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500547# Process BRANCH_PROTECTION value and set
548# Pointer Authentication and Branch Target Identification flags
549################################################################################
550ifeq (${BRANCH_PROTECTION},0)
551 # Default value turns off all types of branch protection
552 BP_OPTION := none
553else ifneq (${ARCH},aarch64)
554 $(error BRANCH_PROTECTION requires AArch64)
555else ifeq (${BRANCH_PROTECTION},1)
556 # Enables all types of branch protection features
557 BP_OPTION := standard
558 ENABLE_BTI := 1
559 ENABLE_PAUTH := 1
560else ifeq (${BRANCH_PROTECTION},2)
561 # Return address signing to its standard level
562 BP_OPTION := pac-ret
563 ENABLE_PAUTH := 1
564else ifeq (${BRANCH_PROTECTION},3)
565 # Extend the signing to include leaf functions
566 BP_OPTION := pac-ret+leaf
567 ENABLE_PAUTH := 1
568else ifeq (${BRANCH_PROTECTION},4)
569 # Turn on branch target identification mechanism
570 BP_OPTION := bti
571 ENABLE_BTI := 1
572else
573 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
574endif #(BRANCH_PROTECTION)
575
576ifeq ($(ENABLE_PAUTH),1)
577 CTX_INCLUDE_PAUTH_REGS := 1
578endif
579ifneq (${BP_OPTION},none)
580 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
581endif #(BP_OPTION)
582
583# Pointer Authentication sources
584ifeq (${ENABLE_PAUTH}, 1)
585# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
586# Pauth support. As it's not secure, it must be reimplemented for real platforms
587 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
588endif
589
Govindraj Raja35472702023-09-20 14:32:24 -0500590################################################################################
591# Include the platform specific Makefile after the SPD Makefile (the platform
592# makefile may use all previous definitions in this file)
593################################################################################
594include ${PLAT_MAKEFILE_FULL}
595
596################################################################################
597# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
598# platform.
599################################################################################
600include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
601
Govindraj Rajaf5211422023-08-17 10:41:48 -0500602####################################################
603# Enable required options for Memory Stack Tagging.
604####################################################
605
606# Currently, these options are enabled only for clang and armclang compiler.
607ifeq (${SUPPORT_STACK_MEMTAG},yes)
608 ifdef mem_tag_arch_support
609 # Check for armclang and clang compilers
610 ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
611 # Add "memtag" architecture feature modifier if not specified
612 ifeq ( ,$(findstring memtag,$(arch-features)))
613 arch-features := $(arch-features)+memtag
614 endif # memtag
615 ifeq ($(notdir $(CC)),armclang)
616 TF_CFLAGS += -mmemtag-stack
617 else ifeq ($(notdir $(CC)),clang)
618 TF_CFLAGS += -fsanitize=memtag
619 endif # armclang
620 endif
621 else
622 $(error "Error: stack memory tagging is not supported for \
623 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
624 endif #(mem_tag_arch_support)
625endif #(SUPPORT_STACK_MEMTAG)
626
627################################################################################
628# RME dependent flags configuration, Enable optional features for RME.
629################################################################################
630# FEAT_RME
631ifeq (${ENABLE_RME},1)
Govindraj Rajad6380292023-10-12 16:57:46 -0500632 # RME doesn't support BRBE
633 ENABLE_BRBE_FOR_NS := 0
634
Govindraj Rajaf5211422023-08-17 10:41:48 -0500635 # RME doesn't support PIE
636 ifneq (${ENABLE_PIE},0)
637 $(error ENABLE_RME does not support PIE)
638 endif
639
640 # RME doesn't support BRBE
641 ifneq (${ENABLE_BRBE_FOR_NS},0)
642 $(error ENABLE_RME does not support BRBE.)
643 endif
644
645 # RME requires AARCH64
646 ifneq (${ARCH},aarch64)
647 $(error ENABLE_RME requires AArch64)
648 endif
649
650 # RME requires el2 context to be saved for now.
651 CTX_INCLUDE_EL2_REGS := 1
652 CTX_INCLUDE_AARCH32_REGS := 0
653 CTX_INCLUDE_PAUTH_REGS := 1
654
655 # RME enables CSV2_2 extension by default.
656 ENABLE_FEAT_CSV2_2 = 1
657endif #(FEAT_RME)
658
659################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500660# Include rmmd Makefile if RME is enabled
661################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500662ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100663 ifneq (${ARCH},aarch64)
664 $(error ENABLE_RME requires AArch64)
665 endif
666 ifeq ($(SPMC_AT_EL3),1)
667 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
668 endif
669
670 ifneq (${SPD}, none)
671 ifneq (${SPD}, spmd)
672 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
673 endif
674 endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500675include services/std_svc/rmmd/rmmd.mk
676$(warning "RME is an experimental feature")
677endif
678
Govindraj Raja35472702023-09-20 14:32:24 -0500679ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
680 ifeq (${SPD},none)
681 ifeq (${ENABLE_RME},0)
682 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
683 or RME is enabled)
684 endif
685 endif
686endif
Juan Castillo0f21c542014-06-25 17:26:36 +0100687
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500688################################################################################
689# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
690# up with appropriate march values for compiler.
691################################################################################
692include ${MAKE_HELPERS_DIRECTORY}march.mk
693
694TF_CFLAGS += $(march-directive)
695
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600696# This internal flag is common option which is set to 1 for scenarios
697# when the BL2 is running in EL3 level. This occurs in two scenarios -
698# 4 world system running BL2 at EL3 and two world system without BL1 running
699# BL2 in EL3
700
701ifeq (${RESET_TO_BL2},1)
702 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100703 ifeq (${ENABLE_RME},1)
704 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
705 supported at the moment.)
706 endif
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600707else ifeq (${ENABLE_RME},1)
708 BL2_RUNS_AT_EL3 := 1
709else
710 BL2_RUNS_AT_EL3 := 0
711endif
712
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100713# This internal flag is set to 1 when Firmware First handling of External aborts
714# is required by lowe ELs. Currently only NS requires this support.
715ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
716 FFH_SUPPORT := 1
717else
718 FFH_SUPPORT := 0
719endif
720
Masahiro Yamada8012cc52017-11-04 03:12:28 +0900721$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
722
Etienne Carriere26e63c42017-11-08 13:48:40 +0100723ifeq (${ARM_ARCH_MAJOR},7)
724include make_helpers/armv7-a-cpus.mk
725endif
726
Masahiro Yamada320920c2020-01-17 13:44:37 +0900727PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
728ifneq ($(PIE_FOUND),)
729 TF_CFLAGS += -fno-PIE
Samuel Holland7b592412022-04-08 21:56:02 -0500730ifneq ($(findstring gcc,$(notdir $(LD))),)
731 TF_LDFLAGS += -no-pie
732endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100733endif #(PIE_FOUND)
Masahiro Yamada320920c2020-01-17 13:44:37 +0900734
735ifneq ($(findstring gcc,$(notdir $(LD))),)
736 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew3bd17c02018-08-28 11:13:55 +0100737else
Masahiro Yamada320920c2020-01-17 13:44:37 +0900738 PIE_LDFLAGS += -pie --no-dynamic-linker
739endif
740
741ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100742 ifeq ($(RESET_TO_BL2),1)
743 ifneq ($(BL2_IN_XIP_MEM),1)
744 BL2_CPPFLAGS += -fpie
745 BL2_CFLAGS += -fpie
746 BL2_LDFLAGS += $(PIE_LDFLAGS)
747 endif #(BL2_IN_XIP_MEM)
748 endif #(RESET_TO_BL2)
Chris Kay966660e2023-02-02 14:39:03 +0000749 BL31_CPPFLAGS += -fpie
750 BL31_CFLAGS += -fpie
Masahiro Yamada320920c2020-01-17 13:44:37 +0900751 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay966660e2023-02-02 14:39:03 +0000752
753 BL32_CPPFLAGS += -fpie
Masahiro Yamadad9743012020-01-17 13:45:14 +0900754 BL32_CFLAGS += -fpie
755 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100756endif #(ENABLE_PIE)
Soby Mathew3bd17c02018-08-28 11:13:55 +0100757
Boyan Karatotev007433d2023-01-25 16:55:18 +0000758BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
759BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
760BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
761
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900762BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600763ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100764 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900765else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100766 BL2_CPPFLAGS += -DIMAGE_AT_EL1
767endif #(RESET_TO_BL2)
Boyan Karatotev007433d2023-01-25 16:55:18 +0000768
769ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100770 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
771 BL31_CPPFLAGS += -DIMAGE_AT_EL3
772 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatotev007433d2023-01-25 16:55:18 +0000773else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100774 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900775endif
776
Sandrine Bailleux54035fc2016-01-13 14:57:38 +0000777# Include the CPU specific operations makefile, which provides default
778# values for all CPU errata workarounds and CPU specific optimisations.
779# This can be overridden by the platform.
Juan Castillo73c99d42015-08-18 14:23:04 +0100780include lib/cpus/cpu-ops.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100781
dp-arma4409002017-02-15 11:07:55 +0000782################################################################################
783# Build `AARCH32_SP` as BL32 image for AArch32
784################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100785ifeq (${ARCH},aarch32)
786 NEED_BL32 := yes
dp-arma4409002017-02-15 11:07:55 +0000787
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100788 ifneq (${AARCH32_SP},none)
789 # We expect to locate an sp.mk under the specified AARCH32_SP directory
790 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-arma4409002017-02-15 11:07:55 +0000791
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100792 ifeq (${AARCH32_SP_MAKE},)
793 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
794 endif
Juan Pablo Conde043f38f2023-08-09 13:19:21 -0500795 $(info Including ${AARCH32_SP_MAKE})
796 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100797 endif
798endif #(ARCH=aarch32)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100799
Juan Castillo73c99d42015-08-18 14:23:04 +0100800################################################################################
Varun Wadekar77f1f7a2019-01-31 09:22:30 -0800801# Include libc if not overridden
802################################################################################
803ifeq (${OVERRIDE_LIBC},0)
804include lib/libc/libc.mk
805endif
806
807################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100808# Check incompatible options and dependencies
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000809################################################################################
810
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100811# USE_DEBUGFS experimental feature recommended only in debug builds
812ifeq (${USE_DEBUGFS},1)
813 ifeq (${DEBUG},1)
814 $(warning DEBUGFS experimental feature is enabled.)
815 else
816 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000817 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100818endif #(USE_DEBUGFS)
819
820# USE_SPINLOCK_CAS requires AArch64 build
821ifeq (${USE_SPINLOCK_CAS},1)
822 ifneq (${ARCH},aarch64)
823 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xu76580f32017-08-24 11:03:23 +0800824 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100825endif #(USE_SPINLOCK_CAS)
826
827# The cert_create tool cannot generate certificates individually, so we use the
828# target 'certificates' to create them all
829ifneq (${GENERATE_COT},0)
830 FIP_DEPS += certificates
831 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000832endif
833
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100834ifneq (${DECRYPTION_SUPPORT},none)
835 ENC_ARGS += -f ${FW_ENC_STATUS}
836 ENC_ARGS += -k ${ENC_KEY}
837 ENC_ARGS += -n ${ENC_NONCE}
838 FIP_DEPS += enctool
839 FWU_FIP_DEPS += enctool
840endif #(DECRYPTION_SUPPORT)
841
842ifdef EL3_PAYLOAD_BASE
843 ifdef PRELOADED_BL33_BASE
844 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
845 incompatible build options. EL3_PAYLOAD_BASE has priority.")
846 endif
847 ifneq (${GENERATE_COT},0)
848 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
849 build options.")
850 endif
851 ifneq (${TRUSTED_BOARD_BOOT},0)
852 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
853 incompatible \ build options.")
854 endif
855endif #(EL3_PAYLOAD_BASE)
856
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000857ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100858 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000859 $(warning "BL33 image is not needed when option \
860 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100861 endif
862 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100863 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100864 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
865 endif
866endif #(NEED_BL33)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000867
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000868# When building for systems with hardware-assisted coherency, there's no need to
869# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
870ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100871 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000872endif
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +0100873
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600874#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
875ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100876 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan7d173fc2018-03-21 07:20:09 +0000877endif
878
Manish Pandey9202d512023-02-13 12:39:17 +0000879# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100880ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100881 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100882 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandey9202d512023-02-13 12:39:17 +0000883endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100884
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100885
Manish Pandey9202d512023-02-13 12:39:17 +0000886# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000887ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100888 ifeq ($(ENABLE_FEAT_RAS),0)
889 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
890 endif
891endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000892
Roberto Vargased51b512018-09-24 17:20:48 +0100893# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew209a60c2018-03-26 12:43:37 +0100894ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100895 ifeq (${TRUSTED_BOARD_BOOT}, 0)
896 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
897 to be set.")
898 endif
899endif #(DYN_DISABLE_AUTH)
Soby Mathew209a60c2018-03-26 12:43:37 +0100900
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100901ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
902# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100903 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100904else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
905# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100906 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100907else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
908# Support hash calculation only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100909 CRYPTO_SUPPORT := 2
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100910else ifeq (${TRUSTED_BOARD_BOOT},1)
911# Support authentication verification only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100912 CRYPTO_SUPPORT := 1
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000913else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100914 CRYPTO_SUPPORT := 0
915endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000916
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100917# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
918ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100919 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhe84ef9cd2020-06-29 10:32:53 +0100920endif
921
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000922# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100923# registers associated to it are also saved and restored.
924# 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 +0000925ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100926 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
927 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
928 endif
929endif #(ENABLE_PAUTH)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100930
931ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100932 ifneq (${ARCH},aarch64)
933 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
934 endif
935endif #(CTX_INCLUDE_PAUTH_REGS)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100936
Justin Chadwell9dd94382019-07-18 14:25:33 +0100937ifeq ($(CTX_INCLUDE_MTE_REGS),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100938 ifneq (${ARCH},aarch64)
939 $(error CTX_INCLUDE_MTE_REGS requires AArch64)
940 endif
941endif #(CTX_INCLUDE_MTE_REGS)
Justin Chadwell9dd94382019-07-18 14:25:33 +0100942
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100943ifeq ($(PSA_FWU_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100944 $(info PSA_FWU_SUPPORT is an experimental feature)
945endif #(PSA_FWU_SUPPORT)
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100946
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000947ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100948 $(info FEATURE_DETECTION is an experimental feature)
949endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000950
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000951ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100952 ifeq (${ENABLE_SME_FOR_NS}, 0)
953 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
954 to be set")
955 $(warning "Forced ENABLE_SME_FOR_NS=1")
956 override ENABLE_SME_FOR_NS := 1
957 endif
958endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand45007ac2023-03-06 23:56:14 +0000959
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000960ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100961 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
962 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
963 library v2")
964 endif
965endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000966
Sumit Garg7cda17b2019-11-15 10:43:00 +0530967ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100968 ifeq (${TRUSTED_BOARD_BOOT}, 0)
969 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
970 to be set)
971 endif
972endif #(DECRYPTION_SUPPORT)
Sumit Garg7cda17b2019-11-15 10:43:00 +0530973
johpow01744ad972022-01-28 17:06:20 -0600974# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow01dc78e622021-07-08 14:14:00 -0500975ifeq (${ARCH},aarch32)
johpow01744ad972022-01-28 17:06:20 -0600976
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100977 # SME/SVE only supported on AArch64
978 ifneq (${ENABLE_SME_FOR_NS},0)
979 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
980 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000981
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100982 ifeq (${ENABLE_SVE_FOR_NS},1)
983 # Warning instead of error due to CI dependency on this
984 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
985 endif
johpow01744ad972022-01-28 17:06:20 -0600986
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100987 # BRBE is not supported in AArch32
988 ifeq (${ENABLE_BRBE_FOR_NS},1)
989 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
990 endif
johpow01744ad972022-01-28 17:06:20 -0600991
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100992 # FEAT_RNG_TRAP is not supported in AArch32
993 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
994 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
995 endif
996endif #(ARCH=aarch32)
johpow01dc78e622021-07-08 14:14:00 -0500997
Boyan Karatotev0d122942023-03-08 16:29:26 +0000998ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100999 ifeq (${ENABLE_SVE_FOR_NS},0)
1000 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
1001 endif
1002endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev0d122942023-03-08 16:29:26 +00001003
johpow01dc78e622021-07-08 14:14:00 -05001004# Secure SME/SVE requires the non-secure component as well
1005ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001006 ifeq (${ENABLE_SME_FOR_NS},0)
1007 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
1008 endif
1009 ifeq (${ENABLE_SVE_FOR_SWD},0)
1010 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
1011 endif
1012endif #(ENABLE_SME_FOR_SWD)
1013
johpow01dc78e622021-07-08 14:14:00 -05001014ifeq (${ENABLE_SVE_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001015 ifeq (${ENABLE_SVE_FOR_NS},0)
1016 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1017 endif
1018endif #(ENABLE_SVE_FOR_SWD)
johpow01dc78e622021-07-08 14:14:00 -05001019
1020# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
1021# its own context management including FPU registers.
1022ifeq (${CTX_INCLUDE_FPREGS},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001023 ifneq (${ENABLE_SME_FOR_NS},0)
1024 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1025 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +00001026
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001027 ifeq (${ENABLE_SVE_FOR_NS},1)
1028 # Warning instead of error due to CI dependency on this
1029 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1030 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1031 override ENABLE_SVE_FOR_NS := 0
1032 endif
1033endif #(CTX_INCLUDE_FPREGS)
johpow01dc78e622021-07-08 14:14:00 -05001034
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001035ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001036 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001037endif
1038
Raymond Mao3ba2c152023-07-25 07:53:35 -07001039ifeq (${TRANSFER_LIST},1)
1040 $(info TRANSFER_LIST is an experimental feature)
1041endif
1042
Chris Kay274a69e2022-09-29 16:21:24 +01001043ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001044 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1045 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1046 endif
Chris Kay274a69e2022-09-29 16:21:24 +01001047endif
1048
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001049# Determine if FEAT_RNG is supported
1050ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0)
1051
1052# Determine if FEAT_SB is supported
1053ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0)
1054
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001055ifeq ($(PSA_CRYPTO),1)
1056 $(info PSA_CRYPTO is an experimental feature)
1057endif
1058
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001059################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001060# Process platform overrideable behaviour
1061################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001062
Manish Pandey5f24ce92021-10-06 10:59:52 +01001063ifdef BL1_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001064 NEED_BL1 := yes
1065endif #(BL1_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001066
Juan Castillo73c99d42015-08-18 14:23:04 +01001067ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +01001068 NEED_BL2 := yes
1069
1070 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1071 # Certificate generation tools. This flag can be overridden by the platform.
1072 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001073 # If booting an EL3 payload there is no need for a BL33 image
1074 # in the FIP file.
1075 NEED_BL33 := no
1076 else
1077 ifdef PRELOADED_BL33_BASE
1078 # If booting a BL33 preloaded image there is no need of
1079 # another one in the FIP file.
1080 NEED_BL33 := no
1081 else
1082 NEED_BL33 ?= yes
1083 endif
1084 endif
1085endif #(BL2_SOURCES)
Juan Castillo73c99d42015-08-18 14:23:04 +01001086
Manish Pandey5f24ce92021-10-06 10:59:52 +01001087ifdef BL2U_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001088 NEED_BL2U := yes
1089endif #(BL2U_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001090
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001091# If SCP_BL2 is given, we always want FIP to include it.
1092ifdef SCP_BL2
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001093 NEED_SCP_BL2 := yes
1094endif #(SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001095
Soby Mathew5744e872017-11-14 14:10:10 +00001096# For AArch32, BL31 is not currently supported.
1097ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001098 ifdef BL31_SOURCES
1099 # When booting an EL3 payload, there is no need to compile the BL31
1100 # image nor put it in the FIP.
1101 ifndef EL3_PAYLOAD_BASE
1102 NEED_BL31 := yes
1103 endif
1104 endif
1105endif #(ARCH=aarch64)
Soby Mathew5744e872017-11-14 14:10:10 +00001106
Juan Castillo73c99d42015-08-18 14:23:04 +01001107# Process TBB related flags
1108ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001109 # Common cert_create options
1110 ifneq (${CREATE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001111 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +01001112 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001113 ifneq (${SAVE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001114 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +01001115 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001116 endif
1117 endif
1118 # Include TBBR makefile (unless the platform indicates otherwise)
1119 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001120 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001121 endif
1122endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001123
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001124ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001125 FIP_ARGS += --align ${FIP_ALIGN}
1126endif #(FIP_ALIGN)
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001127
Manish Pandey5f24ce92021-10-06 10:59:52 +01001128ifdef FDT_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001129 NEED_FDT := yes
1130endif #(FDT_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001131
Juan Castillo73c99d42015-08-18 14:23:04 +01001132################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +08001133# Include libraries' Makefile that are used in all BL
1134################################################################################
1135
1136include lib/stack_protector/stack_protector.mk
1137
1138################################################################################
Soby Mathew8a860522017-02-14 10:05:07 +00001139# Include BL specific makefiles
1140################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +01001141
1142ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001143include bl1/bl1.mk
1144endif
1145
Manish Pandey5f24ce92021-10-06 10:59:52 +01001146ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001147include bl2/bl2.mk
1148endif
1149
Manish Pandey5f24ce92021-10-06 10:59:52 +01001150ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001151include bl2u/bl2u.mk
1152endif
1153
Soby Mathew5744e872017-11-14 14:10:10 +00001154ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001155include bl31/bl31.mk
1156endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001157
Juan Castillo73c99d42015-08-18 14:23:04 +01001158################################################################################
1159# Build options checks
1160################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001161
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001162# Boolean_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001163$(eval $(call assert_booleans,\
1164 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001165 ALLOW_RO_XLAT_TABLES \
1166 BL2_ENABLE_SP_LOAD \
1167 COLD_BOOT_SINGLE_CPU \
1168 CREATE_KEYS \
1169 CTX_INCLUDE_AARCH32_REGS \
1170 CTX_INCLUDE_FPREGS \
1171 CTX_INCLUDE_EL2_REGS \
1172 DEBUG \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001173 DYN_DISABLE_AUTH \
1174 EL3_EXCEPTION_HANDLING \
1175 ENABLE_AMU_AUXILIARY_COUNTERS \
1176 ENABLE_AMU_FCONF \
1177 AMU_RESTRICT_COUNTERS \
1178 ENABLE_ASSERTIONS \
1179 ENABLE_FEAT_SB \
1180 ENABLE_PIE \
1181 ENABLE_PMF \
1182 ENABLE_PSCI_STAT \
1183 ENABLE_RUNTIME_INSTRUMENTATION \
1184 ENABLE_SME_FOR_SWD \
1185 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001186 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001187 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001188 ERROR_DEPRECATED \
1189 FAULT_INJECTION_SUPPORT \
1190 GENERATE_COT \
1191 GICV2_G0_FOR_EL3 \
1192 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravi9cec5492023-09-28 13:17:24 -05001193 HARDEN_SLS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001194 HW_ASSISTED_COHERENCY \
1195 MEASURED_BOOT \
1196 DRTM_SUPPORT \
1197 NS_TIMER_SWITCH \
1198 OVERRIDE_LIBC \
1199 PL011_GENERIC_UART \
1200 PLAT_RSS_NOT_SUPPORTED \
1201 PROGRAMMABLE_RESET_ADDRESS \
1202 PSCI_EXTENDED_STATE_ID \
1203 PSCI_OS_INIT_MODE \
1204 RESET_TO_BL31 \
1205 SAVE_KEYS \
1206 SEPARATE_CODE_AND_RODATA \
1207 SEPARATE_BL2_NOLOAD_REGION \
1208 SEPARATE_NOBITS_REGION \
1209 SPIN_ON_BL1_EXIT \
1210 SPM_MM \
1211 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001212 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001213 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001214 ENABLE_SPMD_LP \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001215 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001216 TRUSTED_BOARD_BOOT \
1217 USE_COHERENT_MEM \
1218 USE_DEBUGFS \
1219 ARM_IO_IN_DTB \
1220 SDEI_IN_FCONF \
1221 SEC_INT_DESC_IN_FCONF \
1222 USE_ROMLIB \
1223 USE_TBBR_DEFS \
1224 WARMBOOT_ENABLE_DCACHE_EARLY \
1225 RESET_TO_BL2 \
1226 BL2_IN_XIP_MEM \
1227 BL2_INV_DCACHE \
1228 USE_SPINLOCK_CAS \
1229 ENCRYPT_BL31 \
1230 ENCRYPT_BL32 \
1231 ERRATA_SPECULATIVE_AT \
1232 RAS_TRAP_NS_ERR_REC_ACCESS \
1233 COT_DESC_IN_DTB \
1234 USE_SP804_TIMER \
1235 PSA_FWU_SUPPORT \
1236 ENABLE_MPMM \
1237 ENABLE_MPMM_FCONF \
1238 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001239 TRNG_SUPPORT \
Sona Mathewffea3842022-11-18 18:05:38 -06001240 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001241 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001242 CONDITIONAL_CMO \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001243 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001244 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001245 INIT_UNUSED_NS_EL2 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001246)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001247
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001248# Numeric_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001249$(eval $(call assert_numerics,\
1250 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001251 ARM_ARCH_MAJOR \
1252 ARM_ARCH_MINOR \
1253 BRANCH_PROTECTION \
1254 CTX_INCLUDE_PAUTH_REGS \
1255 CTX_INCLUDE_MTE_REGS \
1256 CTX_INCLUDE_NEVE_REGS \
1257 CRYPTO_SUPPORT \
Boyan Karatotev83a4dae2023-02-16 09:45:29 +00001258 DISABLE_MTPMU \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001259 ENABLE_BRBE_FOR_NS \
1260 ENABLE_TRBE_FOR_NS \
1261 ENABLE_BTI \
1262 ENABLE_PAUTH \
1263 ENABLE_FEAT_AMU \
1264 ENABLE_FEAT_AMUv1p1 \
1265 ENABLE_FEAT_CSV2_2 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001266 ENABLE_FEAT_DIT \
1267 ENABLE_FEAT_ECV \
1268 ENABLE_FEAT_FGT \
1269 ENABLE_FEAT_HCX \
1270 ENABLE_FEAT_PAN \
1271 ENABLE_FEAT_RNG \
1272 ENABLE_FEAT_RNG_TRAP \
1273 ENABLE_FEAT_SEL2 \
1274 ENABLE_FEAT_TCR2 \
1275 ENABLE_FEAT_S2PIE \
1276 ENABLE_FEAT_S1PIE \
1277 ENABLE_FEAT_S2POE \
1278 ENABLE_FEAT_S1POE \
1279 ENABLE_FEAT_GCS \
1280 ENABLE_FEAT_VHE \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001281 ENABLE_FEAT_MTE_PERM \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001282 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001283 ENABLE_RME \
1284 ENABLE_SPE_FOR_NS \
1285 ENABLE_SYS_REG_TRACE_FOR_NS \
1286 ENABLE_SME_FOR_NS \
1287 ENABLE_SME2_FOR_NS \
1288 ENABLE_SVE_FOR_NS \
1289 ENABLE_TRF_FOR_NS \
1290 FW_ENC_STATUS \
1291 NR_OF_FW_BANKS \
1292 NR_OF_IMAGES_IN_FW_BANK \
1293 TWED_DELAY \
1294 ENABLE_FEAT_TWED \
1295 SVE_VECTOR_LEN \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001296 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001297)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001298
Justin Chadwellaacff742019-07-29 17:13:10 +01001299ifdef KEY_SIZE
1300 $(eval $(call assert_numeric,KEY_SIZE))
1301endif
1302
Justin Chadwell1f461972019-08-20 11:01:52 +01001303ifeq ($(filter $(SANITIZE_UB), on off trap),)
1304 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1305endif
1306
Juan Castillo73c99d42015-08-18 14:23:04 +01001307################################################################################
1308# Add definitions to the cpp preprocessor based on the current build options.
1309# This is done after including the platform specific makefile to allow the
1310# platform to overwrite the default options
1311################################################################################
1312
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001313$(eval $(call add_defines,\
1314 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001315 ALLOW_RO_XLAT_TABLES \
1316 ARM_ARCH_MAJOR \
1317 ARM_ARCH_MINOR \
1318 BL2_ENABLE_SP_LOAD \
1319 COLD_BOOT_SINGLE_CPU \
1320 CTX_INCLUDE_AARCH32_REGS \
1321 CTX_INCLUDE_FPREGS \
1322 CTX_INCLUDE_PAUTH_REGS \
1323 EL3_EXCEPTION_HANDLING \
1324 CTX_INCLUDE_MTE_REGS \
1325 CTX_INCLUDE_EL2_REGS \
1326 CTX_INCLUDE_NEVE_REGS \
1327 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1328 DISABLE_MTPMU \
1329 ENABLE_FEAT_AMU \
1330 ENABLE_AMU_AUXILIARY_COUNTERS \
1331 ENABLE_AMU_FCONF \
1332 AMU_RESTRICT_COUNTERS \
1333 ENABLE_ASSERTIONS \
1334 ENABLE_BTI \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001335 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001336 ENABLE_PAUTH \
1337 ENABLE_PIE \
1338 ENABLE_PMF \
1339 ENABLE_PSCI_STAT \
1340 ENABLE_RME \
1341 ENABLE_RUNTIME_INSTRUMENTATION \
1342 ENABLE_SME_FOR_NS \
1343 ENABLE_SME2_FOR_NS \
1344 ENABLE_SME_FOR_SWD \
1345 ENABLE_SPE_FOR_NS \
1346 ENABLE_SVE_FOR_NS \
1347 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001348 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001349 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001350 ENCRYPT_BL31 \
1351 ENCRYPT_BL32 \
1352 ERROR_DEPRECATED \
1353 FAULT_INJECTION_SUPPORT \
1354 GICV2_G0_FOR_EL3 \
1355 HANDLE_EA_EL3_FIRST_NS \
1356 HW_ASSISTED_COHERENCY \
1357 LOG_LEVEL \
1358 MEASURED_BOOT \
1359 DRTM_SUPPORT \
1360 NS_TIMER_SWITCH \
1361 PL011_GENERIC_UART \
1362 PLAT_${PLAT} \
1363 PLAT_RSS_NOT_SUPPORTED \
1364 PROGRAMMABLE_RESET_ADDRESS \
1365 PSCI_EXTENDED_STATE_ID \
1366 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001367 RESET_TO_BL31 \
1368 SEPARATE_CODE_AND_RODATA \
1369 SEPARATE_BL2_NOLOAD_REGION \
1370 SEPARATE_NOBITS_REGION \
1371 RECLAIM_INIT_CODE \
1372 SPD_${SPD} \
1373 SPIN_ON_BL1_EXIT \
1374 SPM_MM \
1375 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001376 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001377 SPMD_SPM_AT_SEL2 \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001378 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001379 TRUSTED_BOARD_BOOT \
1380 CRYPTO_SUPPORT \
1381 TRNG_SUPPORT \
1382 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001383 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001384 USE_COHERENT_MEM \
1385 USE_DEBUGFS \
1386 ARM_IO_IN_DTB \
1387 SDEI_IN_FCONF \
1388 SEC_INT_DESC_IN_FCONF \
1389 USE_ROMLIB \
1390 USE_TBBR_DEFS \
1391 WARMBOOT_ENABLE_DCACHE_EARLY \
1392 RESET_TO_BL2 \
1393 BL2_RUNS_AT_EL3 \
1394 BL2_IN_XIP_MEM \
1395 BL2_INV_DCACHE \
1396 USE_SPINLOCK_CAS \
1397 ERRATA_SPECULATIVE_AT \
1398 RAS_TRAP_NS_ERR_REC_ACCESS \
1399 COT_DESC_IN_DTB \
1400 USE_SP804_TIMER \
1401 ENABLE_FEAT_RNG \
1402 ENABLE_FEAT_RNG_TRAP \
1403 ENABLE_FEAT_SB \
1404 ENABLE_FEAT_DIT \
1405 NR_OF_FW_BANKS \
1406 NR_OF_IMAGES_IN_FW_BANK \
1407 PSA_FWU_SUPPORT \
1408 ENABLE_BRBE_FOR_NS \
1409 ENABLE_TRBE_FOR_NS \
1410 ENABLE_SYS_REG_TRACE_FOR_NS \
1411 ENABLE_TRF_FOR_NS \
1412 ENABLE_FEAT_HCX \
1413 ENABLE_MPMM \
1414 ENABLE_MPMM_FCONF \
1415 ENABLE_FEAT_FGT \
1416 ENABLE_FEAT_ECV \
1417 ENABLE_FEAT_AMUv1p1 \
1418 ENABLE_FEAT_SEL2 \
1419 ENABLE_FEAT_VHE \
1420 ENABLE_FEAT_CSV2_2 \
1421 ENABLE_FEAT_PAN \
1422 ENABLE_FEAT_TCR2 \
1423 ENABLE_FEAT_S2PIE \
1424 ENABLE_FEAT_S1PIE \
1425 ENABLE_FEAT_S2POE \
1426 ENABLE_FEAT_S1POE \
1427 ENABLE_FEAT_GCS \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001428 ENABLE_FEAT_MTE_PERM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001429 FEATURE_DETECTION \
1430 TWED_DELAY \
1431 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001432 CONDITIONAL_CMO \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001433 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidananda8cf6fa2023-04-26 15:57:30 +01001434 SVE_VECTOR_LEN \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001435 ENABLE_SPMD_LP \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001436 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001437 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001438 INIT_UNUSED_NS_EL2 \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001439)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001440
Justin Chadwell1f461972019-08-20 11:01:52 +01001441ifeq (${SANITIZE_UB},trap)
1442 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001443endif #(SANITIZE_UB)
Justin Chadwell1f461972019-08-20 11:01:52 +01001444
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001445# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1446ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001447 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1448else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001449# Define the PRELOADED_BL33_BASE flag only if it is provided and
1450# EL3_PAYLOAD_BASE is not defined, as it has priority.
1451 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001452 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001453 endif
1454endif #(EL3_PAYLOAD_BASE)
Juan Castillo73c99d42015-08-18 14:23:04 +01001455
Soby Mathew209a60c2018-03-26 12:43:37 +01001456# Define the DYN_DISABLE_AUTH flag only if set.
1457ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001458 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew209a60c2018-03-26 12:43:37 +01001459endif
1460
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001461ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001462 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001463endif
1464
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001465# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001466ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001467ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001468 -include $(BUILD_PLAT)/sp_gen.mk
1469 FIP_DEPS += sp
1470 CRT_DEPS += sp
1471 NEED_SP_PKG := yes
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001472else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001473 ifeq (${SPMD_SPM_AT_SEL2},1)
1474 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1475 endif
1476endif #(SP_LAYOUT_FILE)
1477endif #(SPD)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001478
Juan Castillo73c99d42015-08-18 14:23:04 +01001479################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001480# Build targets
1481################################################################################
1482
Sumit Garg90aa9012019-11-11 18:46:36 +05301483.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 +01001484.SUFFIXES:
1485
1486all: msg_start
1487
1488msg_start:
1489 @echo "Building ${PLAT}"
1490
Soby Mathew7a24cba2015-10-26 14:29:21 +00001491ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001492# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001493ifneq ($(findstring clang,$(notdir $(CC))),)
1494 CPPFLAGS += -Wno-error=deprecated-declarations
1495else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001496 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001497endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001498endif #(!ERROR_DEPRECATED)
Soby Mathew7a24cba2015-10-26 14:29:21 +00001499
Roberto Vargas5accce52018-05-22 16:05:42 +01001500$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas61f72a32018-05-08 10:27:10 +01001501$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001502
Juan Castillo73c99d42015-08-18 14:23:04 +01001503# Expand build macros for the different images
1504ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001505BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Aweke434d0492021-07-11 17:25:48 -05001506$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001507endif #(NEED_BL1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001508
1509ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001510
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -06001511ifeq (${RESET_TO_BL2}, 0)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001512FIP_BL2_ARGS := tb-fw
1513endif
1514
Chris Kayeb1acfb2021-09-28 15:44:37 +01001515BL2_SOURCES := $(sort ${BL2_SOURCES})
1516
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001517$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001518 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001519
1520endif #(NEED_BL2)
Juan Castillo73c99d42015-08-18 14:23:04 +01001521
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001522ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001523$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001524endif #(NEED_SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001525
Juan Castillo73c99d42015-08-18 14:23:04 +01001526ifeq (${NEED_BL31},yes)
1527BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001528# Sort BL31 source files to remove duplicates
1529BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301530ifneq (${DECRYPTION_SUPPORT},none)
1531$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001532 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301533else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001534$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001535 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001536endif #(DECRYPTION_SUPPORT)
1537endif #(NEED_BL31)
Juan Castillo73c99d42015-08-18 14:23:04 +01001538
Juan Castillo70d1fc52015-11-12 10:59:26 +00001539# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001540# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001541# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001542ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001543# Sort BL32 source files to remove duplicates
1544BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001545BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1546
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301547ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001548$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301549 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1550else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001551$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001552 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001553endif #(DECRYPTION_SUPPORT)
1554endif #(NEED_BL32)
Juan Castillo73c99d42015-08-18 14:23:04 +01001555
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001556# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1557# needs to be built from RMM_SOURCES.
1558ifeq (${NEED_RMM},yes)
1559# Sort RMM source files to remove duplicates
1560RMM_SOURCES := $(sort ${RMM_SOURCES})
1561BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1562
1563$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001564 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1565endif #(NEED_RMM)
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001566
Juan Castillo73c99d42015-08-18 14:23:04 +01001567# Add the BL33 image if required by the platform
1568ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001569$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001570endif #(NEED_BL33)
Juan Castillodb6071c2015-01-13 12:21:04 +00001571
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001572ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001573$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001574 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001575endif #(NEED_BL2U)
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001576
Nishanth Menon03b397a2016-10-14 01:13:57 +00001577# Expand build macros for the different images
1578ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001579 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001580endif #(NEED_FDT)
Nishanth Menon03b397a2016-10-14 01:13:57 +00001581
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001582# Add Secure Partition packages
1583ifeq (${NEED_SP_PKG},yes)
Karl Meakin20629b32023-02-14 11:56:02 +00001584$(BUILD_PLAT)/sp_gen.mk : ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1585 ${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alves822c7272022-03-22 16:28:51 +00001586sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001587 @${ECHO_BLANK_LINE}
1588 @echo "Built SP Images successfully"
1589 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001590endif #(NEED_SP_PKG)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001591
Ian Spray36eaaf32014-01-30 17:25:28 +00001592locate-checkpatch:
1593ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001594 $(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 +00001595else
1596ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001597 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001598endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001599endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001600
Achin Gupta4f6ad662013-10-25 09:08:21 +01001601clean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001602 @echo " CLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001603 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001604ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001605 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001606else
1607# Clear the MAKEFLAGS as we do not want
1608# to pass the gnumake flags to nmake.
1609 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001610endif #(UNIX_MK)
Juan Castillo73c99d42015-08-18 14:23:04 +01001611 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Garg90aa9012019-11-11 18:46:36 +05301612 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargas5accce52018-05-22 16:05:42 +01001613 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001614
James Morrisseyeaaeece2013-11-01 13:56:59 +00001615realclean distclean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001616 @echo " REALCLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001617 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1618 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001619ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001620 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001621else
1622# Clear the MAKEFLAGS as we do not want
1623# to pass the gnumake flags to nmake.
1624 ${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 +01001625endif #(UNIX_MK)
Nicolas Boulengueze15591a2021-03-31 12:22:45 +02001626 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Garg90aa9012019-11-11 18:46:36 +05301627 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargas5accce52018-05-22 16:05:42 +01001628 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001629
Ian Spray36eaaf32014-01-30 17:25:28 +00001630checkcodebase: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001631 @echo " CHECKING STYLE"
Dan Handley1a41e8c2016-06-02 18:21:02 +01001632 @if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001633 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001634 while read GIT_FILE ; \
1635 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1636 done ; \
1637 else \
1638 find . -type f -not -iwholename "*.git*" \
1639 -not -iwholename "*build*" \
1640 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001641 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001642 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001643 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001644 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1645 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001646
1647checkpatch: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001648 @echo " CHECKING STYLE"
Yann Gautier02a76d52019-03-08 15:44:00 +01001649 @if test -n "${CHECKPATCH_OPTS}"; then \
1650 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1651 fi
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001652 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001653 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1654 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001655 printf "\n[*] Checking style of '$$commit'\n\n"; \
1656 git log --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001657 -- ${CHECK_PATHS} | \
1658 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001659 git diff --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001660 -- ${CHECK_PATHS} | \
1661 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001662 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001663
1664certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001665
Pali Rohára9812202020-11-24 15:38:08 +01001666${CRTTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001667 ${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 +00001668 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001669 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001670 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001671
1672ifneq (${GENERATE_COT},0)
1673certificates: ${CRT_DEPS} ${CRTTOOL}
1674 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloydf1477d42015-12-02 18:33:55 +00001675 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001676 @echo "Built $@ successfully"
1677 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloydf1477d42015-12-02 18:33:55 +00001678 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001679endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001680
1681${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001682 $(eval ${CHECK_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001683 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1684 ${Q}${FIPTOOL} info $@
Evan Lloydf1477d42015-12-02 18:33:55 +00001685 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001686 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001687 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001688
Yatharth Kochar01912622015-10-12 12:33:47 +01001689ifneq (${GENERATE_COT},0)
1690fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1691 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd052ab522017-04-11 16:52:00 +01001692 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001693 @echo "Built $@ successfully"
1694 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd052ab522017-04-11 16:52:00 +01001695 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001696endif #(GENERATE_COT)
Yatharth Kochar01912622015-10-12 12:33:47 +01001697
1698${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001699 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001700 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1701 ${Q}${FIPTOOL} info $@
Evan Lloyd052ab522017-04-11 16:52:00 +01001702 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001703 @echo "Built $@ successfully"
Evan Lloyd052ab522017-04-11 16:52:00 +01001704 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001705
Juan Castillo73c99d42015-08-18 14:23:04 +01001706fiptool: ${FIPTOOL}
1707fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001708fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001709
Pali Rohára9812202020-11-24 15:38:08 +01001710${FIPTOOL}: FORCE
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001711ifdef UNIX_MK
Lionel Debieve598b1662022-11-14 11:05:09 +01001712 ${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 +01001713else
1714# Clear the MAKEFLAGS as we do not want
1715# to pass the gnumake flags to nmake.
1716 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001717endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001718
Pali Rohára9812202020-11-24 15:38:08 +01001719romlib.bin: libraries FORCE
John Tsichritzisbbb24f62019-05-21 15:47:37 +01001720 ${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 +01001721
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001722memmap: all
Harrison Mutaiaf5b49e2023-02-23 10:33:58 +00001723ifdef UNIX_MK
1724 ${Q}PYTHONPATH=${CURDIR}/tools/memory \
1725 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1726else
1727 ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
1728 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1729endif
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001730
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001731doc:
1732 @echo " BUILD DOCUMENTATION"
1733 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1734
Sumit Garg90aa9012019-11-11 18:46:36 +05301735enctool: ${ENCTOOL}
1736
Pali Rohára9812202020-11-24 15:38:08 +01001737${ENCTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001738 ${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 +05301739 @${ECHO_BLANK_LINE}
1740 @echo "Built $@ successfully"
1741 @${ECHO_BLANK_LINE}
1742
Joakim Bech35fab8c2014-01-23 14:51:49 +01001743cscope:
1744 @echo " CSCOPE"
1745 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1746 ${Q}cscope -b -q -k
1747
Ryan Harkin72ee3312014-01-15 16:55:07 +00001748help:
John Tsichritzis7c231262019-05-21 15:57:31 +01001749 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001750 @echo ""
1751 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +00001752 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001753 @echo ""
John Tsichritzis7c231262019-05-21 15:57:31 +01001754 @echo "platform = ${PLATFORM_LIST}"
1755 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001756 @echo "Please refer to the User Guide for a list of all supported options."
1757 @echo "Note that the build system doesn't track dependencies for build "
1758 @echo "options. Therefore, if any of the build options are changed "
1759 @echo "from a previous build, a clean build must be performed."
1760 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001761 @echo "Supported Targets:"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001762 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001763 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001764 @echo " bl2 Build the BL2 binary"
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001765 @echo " bl2u Build the BL2U binary"
Juan Castillod1786372015-12-14 09:35:25 +00001766 @echo " bl31 Build the BL31 binary"
Soby Mathew9d29c222016-05-05 14:33:33 +01001767 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1768 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castillo73c99d42015-08-18 14:23:04 +01001769 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001770 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochar01912622015-10-12 12:33:47 +01001771 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001772 @echo " checkcodebase Check the coding style of the entire source tree"
1773 @echo " checkpatch Check the coding style on changes in the current"
1774 @echo " branch against BASE_COMMIT (default origin/master)"
1775 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001776 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001777 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo6f971622014-10-21 11:30:42 +01001778 @echo " certtool Build the Certificate generation tool"
Sumit Garg90aa9012019-11-11 18:46:36 +05301779 @echo " enctool Build the Firmware encryption tool"
Andreas Färber59dead22016-10-10 05:18:49 +02001780 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001781 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaz26010da2018-11-27 14:58:04 +00001782 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathew38c14d82017-12-14 17:44:56 +00001783 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001784 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001785 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001786 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001787 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001788 @echo ""
1789 @echo "example: build all targets for the FVP platform:"
1790 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001791
1792.PHONY: FORCE
1793FORCE:;