blob: fc416975711716ca3ddf4296010c6408f59bb168 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Govindraj Raja0a33adc2023-12-21 13:57:49 -06002# Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-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 Gautier3e56c692023-10-04 18:59:44 +020012VERSION_PATCH := 0 # Only used for LTS releases
Yann Gautier055ebec2023-10-03 11:09:07 +020013VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castilloaaa3e722014-06-30 11:41:46 +010014
Juan Castillo88154672015-10-22 11:34:44 +010015# Default goal is build all images
16.DEFAULT_GOAL := all
17
Douglas Raillard72fc70e2016-12-28 14:47:50 +000018# Avoid any implicit propagation of command line variable definitions to
19# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
20# usage. Other command line options like "-s" are still propagated as usual.
21MAKEOVERRIDES =
22
Evan Lloyd231c1472015-12-02 18:17:37 +000023MAKE_HELPERS_DIRECTORY := make_helpers/
24include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000025include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Juan Castillo73c99d42015-08-18 14:23:04 +010026
27################################################################################
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010028# Default values for build configurations, and their dependencies
Juan Castillo73c99d42015-08-18 14:23:04 +010029################################################################################
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010030
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010031include ${MAKE_HELPERS_DIRECTORY}defaults.mk
dp-arm872be882016-09-19 11:18:44 +010032
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010033# Assertions enabled for DEBUG builds by default
Antonio Nino Diazcc8b5632017-04-18 15:16:05 +010034ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +010035ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
36PLAT := ${DEFAULT_PLAT}
Juan Castillo73c99d42015-08-18 14:23:04 +010037
38################################################################################
39# Checkpatch script options
40################################################################################
41
Sandrine Bailleuxf6077392016-06-02 11:19:59 +010042CHECKCODE_ARGS := --no-patch
Dan Handleyf0b489c2016-06-02 17:15:13 +010043# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030044INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
45 include/drivers/arm, \
46 $(wildcard include/drivers/*)))
Dan Handleyf0b489c2016-06-02 17:15:13 +010047INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley1a41e8c2016-06-02 18:21:02 +010048 include/lib/libfdt \
Roberto Vargas61f72a32018-05-08 10:27:10 +010049 include/lib/libc, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010050 $(wildcard include/lib/*)))
51INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030052 include/lib \
53 include/drivers, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010054 $(wildcard include/*)))
55LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-armd801fbb2017-05-04 12:15:35 +010056 lib/compiler-rt \
Antonio Nino Diaz55cdcf72017-01-16 17:20:45 +000057 lib/libfdt% \
Roberto Vargas61f72a32018-05-08 10:27:10 +010058 lib/libc, \
Daniel Boulbya1942552022-10-05 11:05:22 +010059 lib/zlib \
Dan Handleyf0b489c2016-06-02 17:15:13 +010060 $(wildcard lib/*)))
61ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
62 lib \
63 include \
64 docs \
Paul Beesley1ef35512019-03-07 16:42:31 +000065 %.rst, \
Dan Handleyf0b489c2016-06-02 17:15:13 +010066 $(wildcard *)))
67CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
68 ${INC_DIRS_TO_CHECK} \
69 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef45018432019-05-15 09:24:04 +030070 ${LIB_DIRS_TO_CHECK} \
71 ${INC_DRV_DIRS_TO_CHECK} \
72 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000073
Juan Castillo73c99d42015-08-18 14:23:04 +010074################################################################################
75# Process build options
76################################################################################
77
78# Verbose flag
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010079ifeq (${V},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010080 Q:=@
81 ECHO:=@echo
82 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010083else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010084 Q:=
85 ECHO:=$(ECHO_QUIET)
Achin Gupta4f6ad662013-10-25 09:08:21 +010086endif
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010087
88ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +010089 Q:=@
90 ECHO:=$(ECHO_QUIET)
Andre Przywaraee1ba6d2018-09-27 10:56:05 +010091endif
92
93export Q ECHO
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000094
Juan Castillo73c99d42015-08-18 14:23:04 +010095################################################################################
96# Toolchain
97################################################################################
98
dp-arm72610c42017-05-02 11:09:11 +010099HOSTCC := gcc
100export HOSTCC
101
Juan Castillo73c99d42015-08-18 14:23:04 +0100102CC := ${CROSS_COMPILE}gcc
Chris Kay781cb312024-01-15 18:45:07 +0000103CPP := ${CROSS_COMPILE}gcc -E
Juan Castillo73c99d42015-08-18 14:23:04 +0100104AS := ${CROSS_COMPILE}gcc
Chris Kay7e387582024-01-15 19:55:11 +0000105AR := ${CROSS_COMPILE}gcc-ar
Roberto Vargas2adee762018-04-13 14:26:47 +0100106LINKER := ${CROSS_COMPILE}ld
Juan Castillo73c99d42015-08-18 14:23:04 +0100107OC := ${CROSS_COMPILE}objcopy
108OD := ${CROSS_COMPILE}objdump
Soby Mathew38c14d82017-12-14 17:44:56 +0000109DTC := dtc
Juan Castillo73c99d42015-08-18 14:23:04 +0100110
Julius Wernerb25a5772018-01-10 15:12:47 -0800111# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
112ifneq ($(strip $(wildcard ${LD}.bfd) \
Roberto Vargas2adee762018-04-13 14:26:47 +0100113 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
114LINKER := ${LINKER}.bfd
Julius Wernerb25a5772018-01-10 15:12:47 -0800115endif
116
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100117################################################################################
118# Auxiliary tools (fiptool, cert_create, etc)
119################################################################################
120
121# Variables for use with Certificate Generation Tool
122CRTTOOLPATH ?= tools/cert_create
123CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
124
125# Variables for use with Firmware Encryption Tool
126ENCTOOLPATH ?= tools/encrypt_fw
127ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
128
129# Variables for use with Firmware Image Package
130FIPTOOLPATH ?= tools/fiptool
131FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
132
133# Variables for use with sptool
134SPTOOLPATH ?= tools/sptool
135SPTOOL ?= ${SPTOOLPATH}/sptool.py
136SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakin20629b32023-02-14 11:56:02 +0000137SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100138
139# Variables for use with ROMLIB
140ROMLIBPATH ?= lib/romlib
141
142# Variable for use with Python
143PYTHON ?= python3
144
145# Variables for use with documentation build using Sphinx tool
146DOCS_PATH ?= docs
147
148################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100149# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
150################################################################################
Etienne Carriere26e63c42017-11-08 13:48:40 +0100151ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100152 target32-directive = -target arm-none-eabi
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500153# Will set march-directive from platform configuration
Etienne Carriere26e63c42017-11-08 13:48:40 +0100154else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100155 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100156endif #(ARM_ARCH_MAJOR)
157
158################################################################################
159# Get Architecture Feature Modifiers
160################################################################################
161arch-features = ${ARM_ARCH_FEATURE}
162
originc8a992f2022-01-19 16:30:14 +0000163ifneq ($(findstring clang,$(notdir $(CC))),)
164 ifneq ($(findstring armclang,$(notdir $(CC))),)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500165 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
166 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originc8a992f2022-01-19 16:30:14 +0000167 LD := $(LINKER)
168 else
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500169 TF_CFLAGS_aarch32 = $(target32-directive)
170 TF_CFLAGS_aarch64 := -target aarch64-elf
originc8a992f2022-01-19 16:30:14 +0000171 LD := $(shell $(CC) --print-prog-name ld.lld)
172
173 AR := $(shell $(CC) --print-prog-name llvm-ar)
174 OD := $(shell $(CC) --print-prog-name llvm-objdump)
175 OC := $(shell $(CC) --print-prog-name llvm-objcopy)
176 endif
177
178 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
originc8a992f2022-01-19 16:30:14 +0000179 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600180else ifneq ($(findstring gcc,$(notdir $(CC))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100181 ifeq ($(ENABLE_LTO),1)
182 # Enable LTO only for aarch64
183 ifeq (${ARCH},aarch64)
184 LTO_CFLAGS = -flto
185 # Use gcc as a wrapper for the ld, recommended for LTO
186 LINKER := ${CROSS_COMPILE}gcc
187 endif
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600188 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100189 LD = $(LINKER)
dp-armd5461852017-05-02 12:00:08 +0100190else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100191 LD = $(LINKER)
192endif #(clang)
dp-armd5461852017-05-02 12:00:08 +0100193
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100194# Process Debug flag
195$(eval $(call add_define,DEBUG))
196ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100197 BUILD_TYPE := debug
198 TF_CFLAGS += -g -gdwarf-4
199 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100200
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100201 # Use LOG_LEVEL_INFO by default for debug builds
202 LOG_LEVEL := 40
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100203else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100204 BUILD_TYPE := release
205 # Use LOG_LEVEL_NOTICE by default for release builds
206 LOG_LEVEL := 20
207endif #(Debug)
Ahmad Fatoum32b209b2020-02-25 11:25:08 +0100208
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800209# Default build string (git branch and commit)
210ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100211 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800212endif
laurenw-armdddf4282022-07-12 10:12:05 -0500213VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Songf1de4c82020-04-25 16:53:43 +0800214
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100215ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100216 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100217else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100218 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100219else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100220 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
221endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz8fd9d4d2018-08-08 16:28:43 +0100222
Sandrine Bailleuxa9c4dde2018-07-03 09:14:45 +0200223TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-armd5461852017-05-02 12:00:08 +0100224TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathew9d29c222016-05-05 14:33:33 +0100225
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100226##############################################################################
227# WARNINGS Configuration
228###############################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100229# General warnings
230WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier34b508b2021-05-20 13:18:14 +0200231 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000232 -Wredundant-decls
233# stricter warnings
234WARNINGS += -Wextra -Wno-trigraphs
235# too verbose for generic build
236WARNINGS += -Wno-missing-field-initializers \
237 -Wno-type-limits -Wno-sign-compare \
238# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
239WARNINGS += -Wno-unused-parameter
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100240
241# Additional warnings
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000242# Level 1 - infrequent warnings we should have none of
243# full -Wextra
244WARNING1 += -Wsign-compare
245WARNING1 += -Wtype-limits
246WARNING1 += -Wmissing-field-initializers
Yann Gautiere7c645b2018-12-10 18:00:26 +0100247
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000248# Level 2 - problematic warnings that we want
249# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
250# TODO: disable just for them and move into default build
251WARNING2 += -Wold-style-definition
252WARNING2 += -Wmissing-prototypes
253WARNING2 += -Wmissing-format-attribute
254# TF-A aims to comply with this eventually. Effort too large at present
255WARNING2 += -Wundef
Boyan Karatotevd141e632022-11-21 14:49:05 +0000256# currently very involved and many platforms set this off
257WARNING2 += -Wunused-const-variable=2
Yann Gautiere7c645b2018-12-10 18:00:26 +0100258
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000259# Level 3 - very pedantic, frequently ignored
Yann Gautiere7c645b2018-12-10 18:00:26 +0100260WARNING3 := -Wbad-function-cast
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000261WARNING3 += -Waggregate-return
262WARNING3 += -Wnested-externs
263WARNING3 += -Wcast-align
Yann Gautiere7c645b2018-12-10 18:00:26 +0100264WARNING3 += -Wcast-qual
265WARNING3 += -Wconversion
266WARNING3 += -Wpacked
Yann Gautiere7c645b2018-12-10 18:00:26 +0100267WARNING3 += -Wpointer-arith
Yann Gautiere7c645b2018-12-10 18:00:26 +0100268WARNING3 += -Wswitch-default
Yann Gautiere7c645b2018-12-10 18:00:26 +0100269
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000270# Setting W is quite verbose and most warnings will be pre-existing issues
271# outside of the contributor's control. Don't fail the build on them so warnings
272# can be seen and hopefully addressed
273ifdef W
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100274 ifneq (${W},0)
275 E ?= 0
276 endif
Boyan Karatotevd75a9ec2022-11-21 14:16:43 +0000277endif
278
Yann Gautiere7c645b2018-12-10 18:00:26 +0100279ifeq (${W},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100280 WARNINGS += $(WARNING1)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100281else ifeq (${W},2)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100282 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100283else ifeq (${W},3)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100284 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
285endif #(W)
Yann Gautiere7c645b2018-12-10 18:00:26 +0100286
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100287# Compiler specific warnings
Ambroise Vincent00296572019-05-24 12:47:43 +0100288ifeq ($(findstring clang,$(notdir $(CC))),)
Justin Chadwell93c690e2019-07-03 14:15:56 +0100289# not using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100290WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
291 -Wpacked-bitfield-compat -Wshift-overflow=2 \
292 -Wlogical-op
Govindraj Rajadea23e22023-05-05 09:09:36 -0500293
294# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
295TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
296
Bipin Ravi538516f2023-09-28 13:17:24 -0500297ifeq ($(HARDEN_SLS), 1)
298 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
299endif
300
Justin Chadwell93c690e2019-07-03 14:15:56 +0100301else
302# using clang
Justin Chadwelld7b4cd42019-09-18 14:13:42 +0100303WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
304 -Wlogical-op-parentheses
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100305endif #(Clang Warning)
Ambroise Vincent00296572019-05-24 12:47:43 +0100306
Yann Gautier6336b072018-12-10 18:08:53 +0100307ifneq (${E},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100308 ERRORS := -Werror
309endif #(E)
Yann Gautier6336b072018-12-10 18:08:53 +0100310
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100311################################################################################
312# Compiler and Linker Directives
313################################################################################
Justin Chadwell9ab81b52019-07-31 11:36:41 +0100314CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
315 $(ERRORS) $(WARNINGS)
Govindraj Rajad4089fb2023-05-30 16:52:15 -0500316ASFLAGS += $(CPPFLAGS) \
Julius Wernerd5dfdeb2019-07-09 13:49:11 -0700317 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada59de5092016-12-22 12:51:53 +0900318TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Hollandebd6efa2019-10-20 16:11:25 -0500319 -ffunction-sections -fdata-sections \
320 -ffreestanding -fno-builtin -fno-common \
321 -Os -std=gnu99
Juan Castillo73c99d42015-08-18 14:23:04 +0100322
Justin Chadwell1f461972019-08-20 11:01:52 +0100323ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100324 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
325endif #(${SANITIZE_UB},on)
326
Justin Chadwell1f461972019-08-20 11:01:52 +0100327ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100328 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell1f461972019-08-20 11:01:52 +0100329 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100330endif #(${SANITIZE_UB},trap)
Justin Chadwell1f461972019-08-20 11:01:52 +0100331
david cunadof7ec31d2017-11-30 21:58:01 +0000332GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
david cunadof7ec31d2017-11-30 21:58:01 +0000333
Marco Felsch1f49db52022-11-09 12:59:09 +0100334TF_LDFLAGS += -z noexecstack
335
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100336# LD = armlink
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800337ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100338 TF_LDFLAGS += --diag_error=warning --lto_level=O1
339 TF_LDFLAGS += --remove --info=unused,unusedsymbols
340 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100341
342# LD = gcc (used when GCC LTO is enabled)
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600343else ifneq ($(findstring gcc,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100344 # Pass ld options with Wl or Xlinker switches
Chris Kay86e489c2024-01-16 11:53:35 +0000345 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100346 TF_LDFLAGS += -Wl,--fatal-warnings -O1
347 TF_LDFLAGS += -Wl,--gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000348
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100349 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
350 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsov304ad942023-09-05 23:06:29 +0300351 TF_LDFLAGS += -Wl,--build-id=none
Chris Kayac98b822022-12-22 13:26:37 +0000352
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100353 ifeq ($(ENABLE_LTO),1)
354 ifeq (${ARCH},aarch64)
355 TF_LDFLAGS += -flto -fuse-linker-plugin
356 endif
357 endif #(ENABLE_LTO)
358
zelalem-awekeedbce9a2019-11-12 16:20:17 -0600359# GCC automatically adds fix-cortex-a53-843419 flag when used to link
360# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautiercfe67672023-03-15 16:18:16 +0100361 ifeq (${ARCH},aarch64)
362 ifneq (${ERRATA_A53_843419},1)
363 TF_LDFLAGS += -mno-fix-cortex-a53-843419
364 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100365 endif
366 TF_LDFLAGS += -nostdlib
367 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100368
369# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekarc2ad38c2019-01-11 14:47:48 -0800370else
Marco Felsch1f49db52022-11-09 12:59:09 +0100371# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
372# are not loaded by a elf loader.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100373 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
374 TF_LDFLAGS += -O1
375 TF_LDFLAGS += --gc-sections
Chris Kayac98b822022-12-22 13:26:37 +0000376
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100377 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
378 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsov304ad942023-09-05 23:06:29 +0300379 TF_LDFLAGS += --build-id=none
Chris Kayac98b822022-12-22 13:26:37 +0000380
Ambroise Vincent641f16e2019-07-17 11:08:38 +0100381# ld.lld doesn't recognize the errata flags,
Yabin Cuiebac6922023-01-19 20:06:04 +0000382# therefore don't add those in that case.
383# ld.lld reports section type mismatch warnings,
384# therefore don't add --fatal-warnings to it.
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100385 ifeq ($(findstring ld.lld,$(notdir $(LD))),)
386 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
387 endif
388
389endif #(LD = armlink)
Juan Castillo73c99d42015-08-18 14:23:04 +0100390
391################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500392# Setup ARCH_MAJOR/MINOR before parsing arch_features.
393################################################################################
394ifeq (${ENABLE_RME},1)
395 ARM_ARCH_MAJOR := 8
396 ARM_ARCH_MINOR := 6
397endif
398
399################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +0100400# Common sources and include directories
401################################################################################
dp-armd801fbb2017-05-04 12:15:35 +0100402include lib/compiler-rt/compiler-rt.mk
Juan Castillo73c99d42015-08-18 14:23:04 +0100403
404BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100405 common/tf_log.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100406 common/${ARCH}/debug.S \
Julius Werner91b48c92018-11-27 22:10:56 -0800407 drivers/console/multi_console.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100408 lib/${ARCH}/cache_helpers.S \
409 lib/${ARCH}/misc_helpers.S \
Boyan Karatotevc73686a2023-02-15 13:21:50 +0000410 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew566034f2018-02-08 17:45:12 +0000411 plat/common/plat_bl_common.c \
Soby Mathew7f56e9a2017-09-04 11:49:29 +0100412 plat/common/plat_log_common.c \
dp-arm75311202017-03-07 11:02:47 +0000413 plat/common/${ARCH}/plat_common.c \
Soby Mathew9d29c222016-05-05 14:33:33 +0100414 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas61f72a32018-05-08 10:27:10 +0100415 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000416
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100417ifeq ($(notdir $(CC)),armclang)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100418 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diaz8422a842018-08-16 15:42:44 +0100419endif
420
Justin Chadwell1f461972019-08-20 11:01:52 +0100421ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100422 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell1f461972019-08-20 11:01:52 +0100423endif
424
Yann Gautier01d237c2018-06-18 16:00:23 +0200425INCLUDES += -Iinclude \
Antonio Nino Diazf5478de2018-12-17 17:20:57 +0000426 -Iinclude/arch/${ARCH} \
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +0000427 -Iinclude/lib/cpus/${ARCH} \
428 -Iinclude/lib/el3_runtime/${ARCH} \
429 ${PLAT_INCLUDES} \
430 ${SPD_INCLUDES}
431
Nishant Sharmae03dcc82022-08-15 16:37:07 +0100432DTC_FLAGS += -I dts -O dtb
433DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
434 -x assembler-with-cpp $(DEFINES)
435
Antonio Nino Diaz9c6d1c52018-11-19 11:48:30 +0000436include common/backtrace/backtrace.mk
437
Juan Castillo73c99d42015-08-18 14:23:04 +0100438################################################################################
Govindraj Raja35472702023-09-20 14:32:24 -0500439# Generic definitions
440################################################################################
441include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
442
443ifeq (${BUILD_BASE},)
444 BUILD_BASE := ./build
445endif
446BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
447
448SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
449
450# Platforms providing their own TBB makefile may override this value
451INCLUDE_TBBR_MK := 1
452
453################################################################################
454# Include SPD Makefile if one has been specified
455################################################################################
456
457ifneq (${SPD},none)
458 ifeq (${ARCH},aarch32)
459 $(error "Error: SPD is incompatible with AArch32.")
460 endif
461
462 ifdef EL3_PAYLOAD_BASE
463 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
464 $(warning "The SPD and its BL32 companion will be present but \
465 ignored.")
466 endif
467
468 ifeq (${SPD},spmd)
469 # SPMD is located in std_svc directory
470 SPD_DIR := std_svc
471
472 ifeq ($(SPMD_SPM_AT_SEL2),1)
473 CTX_INCLUDE_EL2_REGS := 1
474 ifeq ($(SPMC_AT_EL3),1)
475 $(error SPM cannot be enabled in both S-EL2 and EL3.)
476 endif
477 endif
478
479 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
480 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
481 endif
482
483 ifeq ($(TS_SP_FW_CONFIG),1)
484 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
485 endif
486
487 ifneq ($(ARM_BL2_SP_LIST_DTS),)
488 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
489 endif
490
491 ifneq ($(SP_LAYOUT_FILE),)
492 BL2_ENABLE_SP_LOAD := 1
493 endif
Govindraj Rajac189adb2023-10-31 14:48:11 -0500494
495 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
496 ifneq ($(SPMC_AT_EL3),1)
497 $(error SEL0 SP cannot be enabled without SPMC at EL3)
498 endif
499 endif
Govindraj Raja35472702023-09-20 14:32:24 -0500500 else
501 # All other SPDs in spd directory
502 SPD_DIR := spd
503 endif #(SPD)
504
505 # We expect to locate an spd.mk under the specified SPD directory
506 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
507
508 ifeq (${SPD_MAKE},)
509 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
510 endif
511 $(info Including ${SPD_MAKE})
512 include ${SPD_MAKE}
513
514 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
515 # Makefile would set NEED_BL32 to "yes". In this case, the build system
516 # supports two mutually exclusive options:
517 # * BL32 is built from source: then BL32_SOURCES must contain the list
518 # of source files to build BL32
519 # * BL32 is a prebuilt binary: then BL32 must point to the image file
520 # that will be included in the FIP
521 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
522 # over the sources.
523endif #(SPD=none)
524
525ifeq (${ENABLE_SPMD_LP}, 1)
526ifneq (${SPD},spmd)
527 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
528endif
529ifeq ($(SPMC_AT_EL3),1)
530 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
531endif
532endif
533
534################################################################################
Govindraj Rajaf5211422023-08-17 10:41:48 -0500535# Process BRANCH_PROTECTION value and set
536# Pointer Authentication and Branch Target Identification flags
537################################################################################
538ifeq (${BRANCH_PROTECTION},0)
539 # Default value turns off all types of branch protection
540 BP_OPTION := none
541else ifneq (${ARCH},aarch64)
542 $(error BRANCH_PROTECTION requires AArch64)
543else ifeq (${BRANCH_PROTECTION},1)
544 # Enables all types of branch protection features
545 BP_OPTION := standard
546 ENABLE_BTI := 1
547 ENABLE_PAUTH := 1
548else ifeq (${BRANCH_PROTECTION},2)
549 # Return address signing to its standard level
550 BP_OPTION := pac-ret
551 ENABLE_PAUTH := 1
552else ifeq (${BRANCH_PROTECTION},3)
553 # Extend the signing to include leaf functions
554 BP_OPTION := pac-ret+leaf
555 ENABLE_PAUTH := 1
556else ifeq (${BRANCH_PROTECTION},4)
557 # Turn on branch target identification mechanism
558 BP_OPTION := bti
559 ENABLE_BTI := 1
560else
561 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
562endif #(BRANCH_PROTECTION)
563
564ifeq ($(ENABLE_PAUTH),1)
565 CTX_INCLUDE_PAUTH_REGS := 1
566endif
567ifneq (${BP_OPTION},none)
568 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
569endif #(BP_OPTION)
570
571# Pointer Authentication sources
572ifeq (${ENABLE_PAUTH}, 1)
573# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
574# Pauth support. As it's not secure, it must be reimplemented for real platforms
575 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
576endif
577
Govindraj Raja35472702023-09-20 14:32:24 -0500578################################################################################
579# Include the platform specific Makefile after the SPD Makefile (the platform
580# makefile may use all previous definitions in this file)
581################################################################################
582include ${PLAT_MAKEFILE_FULL}
583
584################################################################################
585# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
586# platform.
587################################################################################
588include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
589
Govindraj Rajaf5211422023-08-17 10:41:48 -0500590####################################################
591# Enable required options for Memory Stack Tagging.
592####################################################
593
594# Currently, these options are enabled only for clang and armclang compiler.
595ifeq (${SUPPORT_STACK_MEMTAG},yes)
596 ifdef mem_tag_arch_support
597 # Check for armclang and clang compilers
598 ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
599 # Add "memtag" architecture feature modifier if not specified
600 ifeq ( ,$(findstring memtag,$(arch-features)))
601 arch-features := $(arch-features)+memtag
602 endif # memtag
603 ifeq ($(notdir $(CC)),armclang)
604 TF_CFLAGS += -mmemtag-stack
605 else ifeq ($(notdir $(CC)),clang)
606 TF_CFLAGS += -fsanitize=memtag
607 endif # armclang
608 endif
609 else
610 $(error "Error: stack memory tagging is not supported for \
611 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
612 endif #(mem_tag_arch_support)
613endif #(SUPPORT_STACK_MEMTAG)
614
615################################################################################
616# RME dependent flags configuration, Enable optional features for RME.
617################################################################################
618# FEAT_RME
619ifeq (${ENABLE_RME},1)
Govindraj Rajad6380292023-10-12 16:57:46 -0500620 # RME doesn't support BRBE
621 ENABLE_BRBE_FOR_NS := 0
622
Govindraj Rajaf5211422023-08-17 10:41:48 -0500623 # RME doesn't support PIE
624 ifneq (${ENABLE_PIE},0)
625 $(error ENABLE_RME does not support PIE)
626 endif
627
628 # RME doesn't support BRBE
629 ifneq (${ENABLE_BRBE_FOR_NS},0)
630 $(error ENABLE_RME does not support BRBE.)
631 endif
632
633 # RME requires AARCH64
634 ifneq (${ARCH},aarch64)
635 $(error ENABLE_RME requires AArch64)
636 endif
637
638 # RME requires el2 context to be saved for now.
639 CTX_INCLUDE_EL2_REGS := 1
640 CTX_INCLUDE_AARCH32_REGS := 0
641 CTX_INCLUDE_PAUTH_REGS := 1
642
643 # RME enables CSV2_2 extension by default.
644 ENABLE_FEAT_CSV2_2 = 1
645endif #(FEAT_RME)
646
647################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500648# Include rmmd Makefile if RME is enabled
649################################################################################
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500650ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100651 ifneq (${ARCH},aarch64)
652 $(error ENABLE_RME requires AArch64)
653 endif
654 ifeq ($(SPMC_AT_EL3),1)
655 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
656 endif
657
658 ifneq (${SPD}, none)
659 ifneq (${SPD}, spmd)
660 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
661 endif
662 endif
Zelalem Aweke5b18de02021-07-11 18:33:20 -0500663include services/std_svc/rmmd/rmmd.mk
664$(warning "RME is an experimental feature")
665endif
666
Govindraj Raja35472702023-09-20 14:32:24 -0500667ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
668 ifeq (${SPD},none)
669 ifeq (${ENABLE_RME},0)
670 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
671 or RME is enabled)
672 endif
673 endif
674endif
Juan Castillo0f21c542014-06-25 17:26:36 +0100675
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500676################################################################################
677# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
678# up with appropriate march values for compiler.
679################################################################################
680include ${MAKE_HELPERS_DIRECTORY}march.mk
681
682TF_CFLAGS += $(march-directive)
Govindraj Raja7275ac22024-01-23 16:00:19 -0600683ASFLAGS += $(march-directive)
Govindraj Raja7794d6c2023-06-01 16:29:16 -0500684
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600685# This internal flag is common option which is set to 1 for scenarios
686# when the BL2 is running in EL3 level. This occurs in two scenarios -
687# 4 world system running BL2 at EL3 and two world system without BL1 running
688# BL2 in EL3
689
690ifeq (${RESET_TO_BL2},1)
691 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100692 ifeq (${ENABLE_RME},1)
693 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
694 supported at the moment.)
695 endif
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600696else ifeq (${ENABLE_RME},1)
697 BL2_RUNS_AT_EL3 := 1
698else
699 BL2_RUNS_AT_EL3 := 0
700endif
701
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100702# This internal flag is set to 1 when Firmware First handling of External aborts
703# is required by lowe ELs. Currently only NS requires this support.
704ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
705 FFH_SUPPORT := 1
706else
707 FFH_SUPPORT := 0
708endif
709
Masahiro Yamada8012cc52017-11-04 03:12:28 +0900710$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
711
Etienne Carriere26e63c42017-11-08 13:48:40 +0100712ifeq (${ARM_ARCH_MAJOR},7)
713include make_helpers/armv7-a-cpus.mk
714endif
715
Masahiro Yamada320920c2020-01-17 13:44:37 +0900716PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
717ifneq ($(PIE_FOUND),)
718 TF_CFLAGS += -fno-PIE
Samuel Holland7b592412022-04-08 21:56:02 -0500719ifneq ($(findstring gcc,$(notdir $(LD))),)
720 TF_LDFLAGS += -no-pie
721endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100722endif #(PIE_FOUND)
Masahiro Yamada320920c2020-01-17 13:44:37 +0900723
724ifneq ($(findstring gcc,$(notdir $(LD))),)
725 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew3bd17c02018-08-28 11:13:55 +0100726else
Masahiro Yamada320920c2020-01-17 13:44:37 +0900727 PIE_LDFLAGS += -pie --no-dynamic-linker
728endif
729
730ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100731 ifeq ($(RESET_TO_BL2),1)
732 ifneq ($(BL2_IN_XIP_MEM),1)
733 BL2_CPPFLAGS += -fpie
734 BL2_CFLAGS += -fpie
735 BL2_LDFLAGS += $(PIE_LDFLAGS)
736 endif #(BL2_IN_XIP_MEM)
737 endif #(RESET_TO_BL2)
Chris Kay966660e2023-02-02 14:39:03 +0000738 BL31_CPPFLAGS += -fpie
739 BL31_CFLAGS += -fpie
Masahiro Yamada320920c2020-01-17 13:44:37 +0900740 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay966660e2023-02-02 14:39:03 +0000741
742 BL32_CPPFLAGS += -fpie
Masahiro Yamadad9743012020-01-17 13:45:14 +0900743 BL32_CFLAGS += -fpie
744 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100745endif #(ENABLE_PIE)
Soby Mathew3bd17c02018-08-28 11:13:55 +0100746
Boyan Karatotev007433d2023-01-25 16:55:18 +0000747BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
748BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
749BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
750
Masahiro Yamada9cefb4b2020-04-01 14:20:58 +0900751BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600752ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100753 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900754else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100755 BL2_CPPFLAGS += -DIMAGE_AT_EL1
756endif #(RESET_TO_BL2)
Boyan Karatotev007433d2023-01-25 16:55:18 +0000757
758ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100759 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
760 BL31_CPPFLAGS += -DIMAGE_AT_EL3
761 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatotev007433d2023-01-25 16:55:18 +0000762else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100763 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamadad5e97a12020-03-26 13:18:48 +0900764endif
765
Sandrine Bailleux54035fc2016-01-13 14:57:38 +0000766# Include the CPU specific operations makefile, which provides default
767# values for all CPU errata workarounds and CPU specific optimisations.
768# This can be overridden by the platform.
Juan Castillo73c99d42015-08-18 14:23:04 +0100769include lib/cpus/cpu-ops.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100770
dp-arma4409002017-02-15 11:07:55 +0000771################################################################################
772# Build `AARCH32_SP` as BL32 image for AArch32
773################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100774ifeq (${ARCH},aarch32)
775 NEED_BL32 := yes
dp-arma4409002017-02-15 11:07:55 +0000776
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100777 ifneq (${AARCH32_SP},none)
778 # We expect to locate an sp.mk under the specified AARCH32_SP directory
779 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-arma4409002017-02-15 11:07:55 +0000780
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100781 ifeq (${AARCH32_SP_MAKE},)
782 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
783 endif
Juan Pablo Conde043f38f2023-08-09 13:19:21 -0500784 $(info Including ${AARCH32_SP_MAKE})
785 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100786 endif
787endif #(ARCH=aarch32)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100788
Juan Castillo73c99d42015-08-18 14:23:04 +0100789################################################################################
Varun Wadekar77f1f7a2019-01-31 09:22:30 -0800790# Include libc if not overridden
791################################################################################
792ifeq (${OVERRIDE_LIBC},0)
793include lib/libc/libc.mk
794endif
795
796################################################################################
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100797# Check incompatible options and dependencies
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000798################################################################################
799
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100800# USE_DEBUGFS experimental feature recommended only in debug builds
801ifeq (${USE_DEBUGFS},1)
802 ifeq (${DEBUG},1)
803 $(warning DEBUGFS experimental feature is enabled.)
804 else
805 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000806 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100807endif #(USE_DEBUGFS)
808
809# USE_SPINLOCK_CAS requires AArch64 build
810ifeq (${USE_SPINLOCK_CAS},1)
811 ifneq (${ARCH},aarch64)
812 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xu76580f32017-08-24 11:03:23 +0800813 endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100814endif #(USE_SPINLOCK_CAS)
815
816# The cert_create tool cannot generate certificates individually, so we use the
817# target 'certificates' to create them all
818ifneq (${GENERATE_COT},0)
819 FIP_DEPS += certificates
820 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000821endif
822
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100823ifneq (${DECRYPTION_SUPPORT},none)
824 ENC_ARGS += -f ${FW_ENC_STATUS}
825 ENC_ARGS += -k ${ENC_KEY}
826 ENC_ARGS += -n ${ENC_NONCE}
827 FIP_DEPS += enctool
828 FWU_FIP_DEPS += enctool
829endif #(DECRYPTION_SUPPORT)
830
831ifdef EL3_PAYLOAD_BASE
832 ifdef PRELOADED_BL33_BASE
833 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
834 incompatible build options. EL3_PAYLOAD_BASE has priority.")
835 endif
836 ifneq (${GENERATE_COT},0)
837 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
838 build options.")
839 endif
840 ifneq (${TRUSTED_BOARD_BOOT},0)
841 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
842 incompatible \ build options.")
843 endif
844endif #(EL3_PAYLOAD_BASE)
845
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000846ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100847 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000848 $(warning "BL33 image is not needed when option \
849 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100850 endif
851 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +0100852 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100853 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
854 endif
855endif #(NEED_BL33)
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +0000856
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000857# When building for systems with hardware-assisted coherency, there's no need to
858# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
859ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100860 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharand4593e42017-01-06 16:14:42 +0000861endif
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +0100862
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600863#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
864ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100865 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan7d173fc2018-03-21 07:20:09 +0000866endif
867
Manish Pandey9202d512023-02-13 12:39:17 +0000868# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan14c60162018-04-04 16:07:11 +0100869ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100870 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100871 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandey9202d512023-02-13 12:39:17 +0000872endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100873
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100874
Manish Pandey9202d512023-02-13 12:39:17 +0000875# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000876ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100877 ifeq ($(ENABLE_FEAT_RAS),0)
878 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
879 endif
880endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharan1a7c1cf2017-12-08 12:13:51 +0000881
Roberto Vargased51b512018-09-24 17:20:48 +0100882# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew209a60c2018-03-26 12:43:37 +0100883ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100884 ifeq (${TRUSTED_BOARD_BOOT}, 0)
885 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
886 to be set.")
887 endif
888endif #(DYN_DISABLE_AUTH)
Soby Mathew209a60c2018-03-26 12:43:37 +0100889
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100890ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
891# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100892 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100893else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
894# Support authentication verification and hash calculation
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100895 CRYPTO_SUPPORT := 3
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100896else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
897# Support hash calculation only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100898 CRYPTO_SUPPORT := 2
Manish V Badarkhe2bf4f272022-06-20 15:32:38 +0100899else ifeq (${TRUSTED_BOARD_BOOT},1)
900# Support authentication verification only
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100901 CRYPTO_SUPPORT := 1
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000902else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100903 CRYPTO_SUPPORT := 0
904endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhec9c56f62022-01-08 22:56:06 +0000905
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100906# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
907ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100908 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhe84ef9cd2020-06-29 10:32:53 +0100909endif
910
Antonio Nino Diazb86048c2019-02-19 11:53:51 +0000911# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100912# registers associated to it are also saved and restored.
913# 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 +0000914ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100915 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
916 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
917 endif
918endif #(ENABLE_PAUTH)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100919
920ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100921 ifneq (${ARCH},aarch64)
922 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
923 endif
924endif #(CTX_INCLUDE_PAUTH_REGS)
Alexei Fedorov9fc59632019-05-24 12:17:09 +0100925
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100926ifeq ($(PSA_FWU_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100927 $(info PSA_FWU_SUPPORT is an experimental feature)
928endif #(PSA_FWU_SUPPORT)
Manish V Badarkhe396b3392021-06-25 23:28:59 +0100929
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000930ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100931 $(info FEATURE_DETECTION is an experimental feature)
932endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand6a0da732022-01-17 18:57:17 +0000933
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000934ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100935 ifeq (${ENABLE_SME_FOR_NS}, 0)
936 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
937 to be set")
938 $(warning "Forced ENABLE_SME_FOR_NS=1")
939 override ENABLE_SME_FOR_NS := 1
940 endif
941endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand45007ac2023-03-06 23:56:14 +0000942
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000943ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100944 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
945 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
946 library v2")
947 endif
948endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudor60e8f3c2019-11-07 15:18:03 +0000949
Sumit Garg7cda17b2019-11-15 10:43:00 +0530950ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100951 ifeq (${TRUSTED_BOARD_BOOT}, 0)
952 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
953 to be set)
954 endif
955endif #(DECRYPTION_SUPPORT)
Sumit Garg7cda17b2019-11-15 10:43:00 +0530956
johpow01744ad972022-01-28 17:06:20 -0600957# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow01dc78e622021-07-08 14:14:00 -0500958ifeq (${ARCH},aarch32)
johpow01744ad972022-01-28 17:06:20 -0600959
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100960 # SME/SVE only supported on AArch64
961 ifneq (${ENABLE_SME_FOR_NS},0)
962 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
963 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +0000964
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100965 ifeq (${ENABLE_SVE_FOR_NS},1)
966 # Warning instead of error due to CI dependency on this
967 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
968 endif
johpow01744ad972022-01-28 17:06:20 -0600969
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100970 # BRBE is not supported in AArch32
971 ifeq (${ENABLE_BRBE_FOR_NS},1)
972 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
973 endif
johpow01744ad972022-01-28 17:06:20 -0600974
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100975 # FEAT_RNG_TRAP is not supported in AArch32
976 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
977 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
978 endif
979endif #(ARCH=aarch32)
johpow01dc78e622021-07-08 14:14:00 -0500980
Boyan Karatotev0d122942023-03-08 16:29:26 +0000981ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100982 ifeq (${ENABLE_SVE_FOR_NS},0)
983 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
984 endif
985endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev0d122942023-03-08 16:29:26 +0000986
johpow01dc78e622021-07-08 14:14:00 -0500987# Secure SME/SVE requires the non-secure component as well
988ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100989 ifeq (${ENABLE_SME_FOR_NS},0)
990 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
991 endif
992 ifeq (${ENABLE_SVE_FOR_SWD},0)
993 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
994 endif
995endif #(ENABLE_SME_FOR_SWD)
996
johpow01dc78e622021-07-08 14:14:00 -0500997ifeq (${ENABLE_SVE_FOR_SWD},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +0100998 ifeq (${ENABLE_SVE_FOR_NS},0)
999 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1000 endif
1001endif #(ENABLE_SVE_FOR_SWD)
johpow01dc78e622021-07-08 14:14:00 -05001002
1003# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
1004# its own context management including FPU registers.
1005ifeq (${CTX_INCLUDE_FPREGS},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001006 ifneq (${ENABLE_SME_FOR_NS},0)
1007 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1008 endif
Jayanth Dodderi Chidanand03d3c0d2022-11-08 10:31:07 +00001009
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001010 ifeq (${ENABLE_SVE_FOR_NS},1)
1011 # Warning instead of error due to CI dependency on this
1012 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1013 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1014 override ENABLE_SVE_FOR_NS := 0
1015 endif
1016endif #(CTX_INCLUDE_FPREGS)
johpow01dc78e622021-07-08 14:14:00 -05001017
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001018ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001019 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe00e28872022-03-02 12:06:35 +00001020endif
1021
Raymond Mao3ba2c152023-07-25 07:53:35 -07001022ifeq (${TRANSFER_LIST},1)
1023 $(info TRANSFER_LIST is an experimental feature)
1024endif
1025
Chris Kay274a69e2022-09-29 16:21:24 +01001026ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001027 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1028 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1029 endif
Chris Kay274a69e2022-09-29 16:21:24 +01001030endif
1031
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001032ifeq ($(PSA_CRYPTO),1)
1033 $(info PSA_CRYPTO is an experimental feature)
1034endif
1035
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001036################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001037# Process platform overrideable behaviour
1038################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001039
Manish Pandey5f24ce92021-10-06 10:59:52 +01001040ifdef BL1_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001041 NEED_BL1 := yes
1042endif #(BL1_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001043
Juan Castillo73c99d42015-08-18 14:23:04 +01001044ifdef BL2_SOURCES
Manish Pandey5f24ce92021-10-06 10:59:52 +01001045 NEED_BL2 := yes
1046
1047 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1048 # Certificate generation tools. This flag can be overridden by the platform.
1049 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001050 # If booting an EL3 payload there is no need for a BL33 image
1051 # in the FIP file.
1052 NEED_BL33 := no
1053 else
1054 ifdef PRELOADED_BL33_BASE
1055 # If booting a BL33 preloaded image there is no need of
1056 # another one in the FIP file.
1057 NEED_BL33 := no
1058 else
1059 NEED_BL33 ?= yes
1060 endif
1061 endif
1062endif #(BL2_SOURCES)
Juan Castillo73c99d42015-08-18 14:23:04 +01001063
Manish Pandey5f24ce92021-10-06 10:59:52 +01001064ifdef BL2U_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001065 NEED_BL2U := yes
1066endif #(BL2U_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001067
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001068# If SCP_BL2 is given, we always want FIP to include it.
1069ifdef SCP_BL2
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001070 NEED_SCP_BL2 := yes
1071endif #(SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001072
Soby Mathew5744e872017-11-14 14:10:10 +00001073# For AArch32, BL31 is not currently supported.
1074ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001075 ifdef BL31_SOURCES
1076 # When booting an EL3 payload, there is no need to compile the BL31
1077 # image nor put it in the FIP.
1078 ifndef EL3_PAYLOAD_BASE
1079 NEED_BL31 := yes
1080 endif
1081 endif
1082endif #(ARCH=aarch64)
Soby Mathew5744e872017-11-14 14:10:10 +00001083
Juan Castillo73c99d42015-08-18 14:23:04 +01001084# Process TBB related flags
1085ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001086 # Common cert_create options
1087 ifneq (${CREATE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001088 $(eval CRT_ARGS += -n)
Yatharth Kochar01912622015-10-12 12:33:47 +01001089 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001090 ifneq (${SAVE_KEYS},0)
Juan Castillo73c99d42015-08-18 14:23:04 +01001091 $(eval CRT_ARGS += -k)
Yatharth Kochar01912622015-10-12 12:33:47 +01001092 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001093 endif
1094 endif
1095 # Include TBBR makefile (unless the platform indicates otherwise)
1096 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001097 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001098 endif
1099endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001100
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001101ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001102 FIP_ARGS += --align ${FIP_ALIGN}
1103endif #(FIP_ALIGN)
Masahiro Yamada1c75d5d2016-12-25 13:52:22 +09001104
Manish Pandey5f24ce92021-10-06 10:59:52 +01001105ifdef FDT_SOURCES
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001106 NEED_FDT := yes
1107endif #(FDT_SOURCES)
Manish Pandey5f24ce92021-10-06 10:59:52 +01001108
Juan Castillo73c99d42015-08-18 14:23:04 +01001109################################################################################
Michalis Pappas46e5e032018-03-20 13:01:27 +08001110# Include libraries' Makefile that are used in all BL
1111################################################################################
1112
1113include lib/stack_protector/stack_protector.mk
1114
1115################################################################################
Soby Mathew8a860522017-02-14 10:05:07 +00001116# Include BL specific makefiles
1117################################################################################
Manish Pandey5f24ce92021-10-06 10:59:52 +01001118
1119ifeq (${NEED_BL1},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001120include bl1/bl1.mk
1121endif
1122
Manish Pandey5f24ce92021-10-06 10:59:52 +01001123ifeq (${NEED_BL2},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001124include bl2/bl2.mk
1125endif
1126
Manish Pandey5f24ce92021-10-06 10:59:52 +01001127ifeq (${NEED_BL2U},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001128include bl2u/bl2u.mk
1129endif
1130
Soby Mathew5744e872017-11-14 14:10:10 +00001131ifeq (${NEED_BL31},yes)
Soby Mathew8a860522017-02-14 10:05:07 +00001132include bl31/bl31.mk
1133endif
Nishanth Menon03b397a2016-10-14 01:13:57 +00001134
Juan Castillo73c99d42015-08-18 14:23:04 +01001135################################################################################
1136# Build options checks
1137################################################################################
Juan Castillob7124ea2014-11-04 17:36:40 +00001138
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001139# Boolean_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001140$(eval $(call assert_booleans,\
1141 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001142 ALLOW_RO_XLAT_TABLES \
1143 BL2_ENABLE_SP_LOAD \
1144 COLD_BOOT_SINGLE_CPU \
1145 CREATE_KEYS \
1146 CTX_INCLUDE_AARCH32_REGS \
1147 CTX_INCLUDE_FPREGS \
1148 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash9acff282023-10-06 14:35:21 -05001149 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001150 DEBUG \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001151 DYN_DISABLE_AUTH \
1152 EL3_EXCEPTION_HANDLING \
1153 ENABLE_AMU_AUXILIARY_COUNTERS \
1154 ENABLE_AMU_FCONF \
1155 AMU_RESTRICT_COUNTERS \
1156 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001157 ENABLE_PIE \
1158 ENABLE_PMF \
1159 ENABLE_PSCI_STAT \
1160 ENABLE_RUNTIME_INSTRUMENTATION \
1161 ENABLE_SME_FOR_SWD \
1162 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001163 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001164 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001165 ERROR_DEPRECATED \
1166 FAULT_INJECTION_SUPPORT \
1167 GENERATE_COT \
1168 GICV2_G0_FOR_EL3 \
1169 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravi538516f2023-09-28 13:17:24 -05001170 HARDEN_SLS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001171 HW_ASSISTED_COHERENCY \
1172 MEASURED_BOOT \
1173 DRTM_SUPPORT \
1174 NS_TIMER_SWITCH \
1175 OVERRIDE_LIBC \
1176 PL011_GENERIC_UART \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001177 PROGRAMMABLE_RESET_ADDRESS \
1178 PSCI_EXTENDED_STATE_ID \
1179 PSCI_OS_INIT_MODE \
1180 RESET_TO_BL31 \
1181 SAVE_KEYS \
1182 SEPARATE_CODE_AND_RODATA \
1183 SEPARATE_BL2_NOLOAD_REGION \
1184 SEPARATE_NOBITS_REGION \
1185 SPIN_ON_BL1_EXIT \
1186 SPM_MM \
1187 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001188 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001189 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001190 ENABLE_SPMD_LP \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001191 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001192 TRUSTED_BOARD_BOOT \
1193 USE_COHERENT_MEM \
1194 USE_DEBUGFS \
1195 ARM_IO_IN_DTB \
1196 SDEI_IN_FCONF \
1197 SEC_INT_DESC_IN_FCONF \
1198 USE_ROMLIB \
1199 USE_TBBR_DEFS \
1200 WARMBOOT_ENABLE_DCACHE_EARLY \
1201 RESET_TO_BL2 \
1202 BL2_IN_XIP_MEM \
1203 BL2_INV_DCACHE \
1204 USE_SPINLOCK_CAS \
1205 ENCRYPT_BL31 \
1206 ENCRYPT_BL32 \
1207 ERRATA_SPECULATIVE_AT \
1208 RAS_TRAP_NS_ERR_REC_ACCESS \
1209 COT_DESC_IN_DTB \
1210 USE_SP804_TIMER \
1211 PSA_FWU_SUPPORT \
1212 ENABLE_MPMM \
1213 ENABLE_MPMM_FCONF \
1214 FEATURE_DETECTION \
Jayanth Dodderi Chidanand0b22e592022-10-11 17:16:07 +01001215 TRNG_SUPPORT \
Sona Mathewffea3842022-11-18 18:05:38 -06001216 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001217 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja04c73032022-11-04 12:38:01 +00001218 CONDITIONAL_CMO \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001219 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001220 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001221 INIT_UNUSED_NS_EL2 \
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001222 PLATFORM_REPORT_CTX_MEM_USE \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001223)))
Juan Castillo73c99d42015-08-18 14:23:04 +01001224
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001225# Numeric_Flags
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001226$(eval $(call assert_numerics,\
1227 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001228 ARM_ARCH_MAJOR \
1229 ARM_ARCH_MINOR \
1230 BRANCH_PROTECTION \
1231 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001232 CTX_INCLUDE_NEVE_REGS \
1233 CRYPTO_SUPPORT \
Boyan Karatotev83a4dae2023-02-16 09:45:29 +00001234 DISABLE_MTPMU \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001235 ENABLE_BRBE_FOR_NS \
1236 ENABLE_TRBE_FOR_NS \
1237 ENABLE_BTI \
1238 ENABLE_PAUTH \
1239 ENABLE_FEAT_AMU \
1240 ENABLE_FEAT_AMUv1p1 \
1241 ENABLE_FEAT_CSV2_2 \
Sona Mathew30019d82023-10-25 16:48:19 -05001242 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001243 ENABLE_FEAT_DIT \
1244 ENABLE_FEAT_ECV \
1245 ENABLE_FEAT_FGT \
1246 ENABLE_FEAT_HCX \
Govindraj Raja0a33adc2023-12-21 13:57:49 -06001247 ENABLE_FEAT_MTE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001248 ENABLE_FEAT_PAN \
1249 ENABLE_FEAT_RNG \
1250 ENABLE_FEAT_RNG_TRAP \
1251 ENABLE_FEAT_SEL2 \
1252 ENABLE_FEAT_TCR2 \
Govindraj Raja0e4daed2024-01-23 16:03:53 -06001253 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001254 ENABLE_FEAT_S2PIE \
1255 ENABLE_FEAT_S1PIE \
1256 ENABLE_FEAT_S2POE \
1257 ENABLE_FEAT_S1POE \
1258 ENABLE_FEAT_GCS \
1259 ENABLE_FEAT_VHE \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001260 ENABLE_FEAT_MTE_PERM \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001261 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001262 ENABLE_RME \
1263 ENABLE_SPE_FOR_NS \
1264 ENABLE_SYS_REG_TRACE_FOR_NS \
1265 ENABLE_SME_FOR_NS \
1266 ENABLE_SME2_FOR_NS \
1267 ENABLE_SVE_FOR_NS \
1268 ENABLE_TRF_FOR_NS \
1269 FW_ENC_STATUS \
1270 NR_OF_FW_BANKS \
1271 NR_OF_IMAGES_IN_FW_BANK \
1272 TWED_DELAY \
1273 ENABLE_FEAT_TWED \
1274 SVE_VECTOR_LEN \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001275 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001276)))
Jeenu Viswambharanc877b412017-01-16 16:52:35 +00001277
Justin Chadwellaacff742019-07-29 17:13:10 +01001278ifdef KEY_SIZE
1279 $(eval $(call assert_numeric,KEY_SIZE))
1280endif
1281
Justin Chadwell1f461972019-08-20 11:01:52 +01001282ifeq ($(filter $(SANITIZE_UB), on off trap),)
1283 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1284endif
1285
Juan Castillo73c99d42015-08-18 14:23:04 +01001286################################################################################
1287# Add definitions to the cpp preprocessor based on the current build options.
1288# This is done after including the platform specific makefile to allow the
1289# platform to overwrite the default options
1290################################################################################
1291
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001292$(eval $(call add_defines,\
1293 $(sort \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001294 ALLOW_RO_XLAT_TABLES \
1295 ARM_ARCH_MAJOR \
1296 ARM_ARCH_MINOR \
1297 BL2_ENABLE_SP_LOAD \
1298 COLD_BOOT_SINGLE_CPU \
1299 CTX_INCLUDE_AARCH32_REGS \
1300 CTX_INCLUDE_FPREGS \
1301 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash9acff282023-10-06 14:35:21 -05001302 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001303 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001304 CTX_INCLUDE_EL2_REGS \
1305 CTX_INCLUDE_NEVE_REGS \
1306 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1307 DISABLE_MTPMU \
1308 ENABLE_FEAT_AMU \
1309 ENABLE_AMU_AUXILIARY_COUNTERS \
1310 ENABLE_AMU_FCONF \
1311 AMU_RESTRICT_COUNTERS \
1312 ENABLE_ASSERTIONS \
1313 ENABLE_BTI \
Arvind Ram Prakashedebefb2023-10-11 12:10:56 -05001314 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001315 ENABLE_PAUTH \
1316 ENABLE_PIE \
1317 ENABLE_PMF \
1318 ENABLE_PSCI_STAT \
1319 ENABLE_RME \
1320 ENABLE_RUNTIME_INSTRUMENTATION \
1321 ENABLE_SME_FOR_NS \
1322 ENABLE_SME2_FOR_NS \
1323 ENABLE_SME_FOR_SWD \
1324 ENABLE_SPE_FOR_NS \
1325 ENABLE_SVE_FOR_NS \
1326 ENABLE_SVE_FOR_SWD \
Manish Pandey970a4a82023-10-10 13:53:25 +01001327 ENABLE_FEAT_RAS \
Manish Pandeyf87e54f2023-10-10 15:42:19 +01001328 FFH_SUPPORT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001329 ENCRYPT_BL31 \
1330 ENCRYPT_BL32 \
1331 ERROR_DEPRECATED \
1332 FAULT_INJECTION_SUPPORT \
1333 GICV2_G0_FOR_EL3 \
1334 HANDLE_EA_EL3_FIRST_NS \
1335 HW_ASSISTED_COHERENCY \
1336 LOG_LEVEL \
1337 MEASURED_BOOT \
1338 DRTM_SUPPORT \
1339 NS_TIMER_SWITCH \
1340 PL011_GENERIC_UART \
1341 PLAT_${PLAT} \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001342 PROGRAMMABLE_RESET_ADDRESS \
1343 PSCI_EXTENDED_STATE_ID \
1344 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001345 RESET_TO_BL31 \
1346 SEPARATE_CODE_AND_RODATA \
1347 SEPARATE_BL2_NOLOAD_REGION \
1348 SEPARATE_NOBITS_REGION \
1349 RECLAIM_INIT_CODE \
1350 SPD_${SPD} \
1351 SPIN_ON_BL1_EXIT \
1352 SPM_MM \
1353 SPMC_AT_EL3 \
Nishant Sharma801cd3c2023-06-27 00:36:01 +01001354 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001355 SPMD_SPM_AT_SEL2 \
Raymond Mao3ba2c152023-07-25 07:53:35 -07001356 TRANSFER_LIST \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001357 TRUSTED_BOARD_BOOT \
1358 CRYPTO_SUPPORT \
1359 TRNG_SUPPORT \
1360 ERRATA_ABI_SUPPORT \
Sona Mathewef63f5b2023-03-14 14:02:03 -05001361 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001362 USE_COHERENT_MEM \
1363 USE_DEBUGFS \
1364 ARM_IO_IN_DTB \
1365 SDEI_IN_FCONF \
1366 SEC_INT_DESC_IN_FCONF \
1367 USE_ROMLIB \
1368 USE_TBBR_DEFS \
1369 WARMBOOT_ENABLE_DCACHE_EARLY \
1370 RESET_TO_BL2 \
1371 BL2_RUNS_AT_EL3 \
1372 BL2_IN_XIP_MEM \
1373 BL2_INV_DCACHE \
1374 USE_SPINLOCK_CAS \
1375 ERRATA_SPECULATIVE_AT \
1376 RAS_TRAP_NS_ERR_REC_ACCESS \
1377 COT_DESC_IN_DTB \
1378 USE_SP804_TIMER \
1379 ENABLE_FEAT_RNG \
1380 ENABLE_FEAT_RNG_TRAP \
1381 ENABLE_FEAT_SB \
1382 ENABLE_FEAT_DIT \
1383 NR_OF_FW_BANKS \
1384 NR_OF_IMAGES_IN_FW_BANK \
1385 PSA_FWU_SUPPORT \
1386 ENABLE_BRBE_FOR_NS \
1387 ENABLE_TRBE_FOR_NS \
1388 ENABLE_SYS_REG_TRACE_FOR_NS \
1389 ENABLE_TRF_FOR_NS \
1390 ENABLE_FEAT_HCX \
1391 ENABLE_MPMM \
1392 ENABLE_MPMM_FCONF \
1393 ENABLE_FEAT_FGT \
1394 ENABLE_FEAT_ECV \
1395 ENABLE_FEAT_AMUv1p1 \
1396 ENABLE_FEAT_SEL2 \
1397 ENABLE_FEAT_VHE \
1398 ENABLE_FEAT_CSV2_2 \
Sona Mathew30019d82023-10-25 16:48:19 -05001399 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001400 ENABLE_FEAT_PAN \
1401 ENABLE_FEAT_TCR2 \
1402 ENABLE_FEAT_S2PIE \
1403 ENABLE_FEAT_S1PIE \
1404 ENABLE_FEAT_S2POE \
1405 ENABLE_FEAT_S1POE \
1406 ENABLE_FEAT_GCS \
Govindraj Raja0a33adc2023-12-21 13:57:49 -06001407 ENABLE_FEAT_MTE \
Maksims Svecovs4d0b6632023-03-24 13:05:09 +00001408 ENABLE_FEAT_MTE_PERM \
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001409 FEATURE_DETECTION \
1410 TWED_DELAY \
1411 ENABLE_FEAT_TWED \
Okash Khawaja04c73032022-11-04 12:38:01 +00001412 CONDITIONAL_CMO \
Varun Wadekar0ed3be62023-04-13 21:06:18 +01001413 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidananda8cf6fa2023-04-26 15:57:30 +01001414 SVE_VECTOR_LEN \
Raghu Krishnamurthy890b5082023-02-25 13:26:10 -08001415 ENABLE_SPMD_LP \
Manish V Badarkhe5782b892023-09-06 09:08:28 +01001416 PSA_CRYPTO \
Sandrine Bailleux85bebe12023-10-11 08:38:00 +02001417 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash183329a2023-08-15 16:28:06 -05001418 INIT_UNUSED_NS_EL2 \
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001419 PLATFORM_REPORT_CTX_MEM_USE \
Leonardo Sandoval327131c2020-09-10 12:18:27 -05001420)))
Jeenu Viswambharan2fae4b12016-10-24 14:31:51 +01001421
Juan Pablo Condebfef8b92023-11-08 16:14:28 -06001422ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1423ifeq (${DEBUG}, 0)
1424 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1425 override PLATFORM_REPORT_CTX_MEM_USE := 0
1426endif
1427endif
1428
Justin Chadwell1f461972019-08-20 11:01:52 +01001429ifeq (${SANITIZE_UB},trap)
1430 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001431endif #(SANITIZE_UB)
Justin Chadwell1f461972019-08-20 11:01:52 +01001432
Sandrine Bailleux4c117f62015-11-26 16:31:34 +00001433# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1434ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazcf2c8a32016-02-15 14:53:10 +00001435 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1436else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001437# Define the PRELOADED_BL33_BASE flag only if it is provided and
1438# EL3_PAYLOAD_BASE is not defined, as it has priority.
1439 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz68450a62016-04-06 17:31:57 +01001440 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001441 endif
1442endif #(EL3_PAYLOAD_BASE)
Juan Castillo73c99d42015-08-18 14:23:04 +01001443
Soby Mathew209a60c2018-03-26 12:43:37 +01001444# Define the DYN_DISABLE_AUTH flag only if set.
1445ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001446 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew209a60c2018-03-26 12:43:37 +01001447endif
1448
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001449ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001450 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001451endif
1452
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001453# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001454ifeq (${SPD},spmd)
Olivier Deprezc33ff192020-03-19 09:27:11 +01001455ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001456 -include $(BUILD_PLAT)/sp_gen.mk
1457 FIP_DEPS += sp
1458 CRT_DEPS += sp
1459 NEED_SP_PKG := yes
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001460else
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001461 ifeq (${SPMD_SPM_AT_SEL2},1)
1462 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1463 endif
1464endif #(SP_LAYOUT_FILE)
1465endif #(SPD)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001466
Juan Castillo73c99d42015-08-18 14:23:04 +01001467################################################################################
Juan Castillo73c99d42015-08-18 14:23:04 +01001468# Build targets
1469################################################################################
1470
Sumit Garg90aa9012019-11-11 18:46:36 +05301471.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 +01001472.SUFFIXES:
1473
1474all: msg_start
1475
1476msg_start:
1477 @echo "Building ${PLAT}"
1478
Soby Mathew7a24cba2015-10-26 14:29:21 +00001479ifeq (${ERROR_DEPRECATED},0)
Julius Wernerd5dfdeb2019-07-09 13:49:11 -07001480# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekarc2ad38c2019-01-11 14:47:48 -08001481ifneq ($(findstring clang,$(notdir $(CC))),)
1482 CPPFLAGS += -Wno-error=deprecated-declarations
1483else
Dan Handleybc1a03c2018-02-27 16:03:58 +00001484 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew7a24cba2015-10-26 14:29:21 +00001485endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001486endif #(!ERROR_DEPRECATED)
Soby Mathew7a24cba2015-10-26 14:29:21 +00001487
Roberto Vargas5accce52018-05-22 16:05:42 +01001488$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas61f72a32018-05-08 10:27:10 +01001489$(eval $(call MAKE_LIB,c))
Roberto Vargas5fee0282018-05-08 10:27:10 +01001490
Juan Castillo73c99d42015-08-18 14:23:04 +01001491# Expand build macros for the different images
1492ifeq (${NEED_BL1},yes)
Chris Kayb34635a2021-09-28 15:44:19 +01001493BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Aweke434d0492021-07-11 17:25:48 -05001494$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001495endif #(NEED_BL1)
Juan Castillo73c99d42015-08-18 14:23:04 +01001496
1497ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001498
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -06001499ifeq (${RESET_TO_BL2}, 0)
Roberto Vargasc9b31ae2018-01-02 11:23:41 +00001500FIP_BL2_ARGS := tb-fw
1501endif
1502
Chris Kayeb1acfb2021-09-28 15:44:37 +01001503BL2_SOURCES := $(sort ${BL2_SOURCES})
1504
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001505$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001506 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001507
1508endif #(NEED_BL2)
Juan Castillo73c99d42015-08-18 14:23:04 +01001509
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001510ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001511$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001512endif #(NEED_SCP_BL2)
Masahiro Yamada4d045d02017-04-05 19:11:41 +09001513
Juan Castillo73c99d42015-08-18 14:23:04 +01001514ifeq (${NEED_BL31},yes)
1515BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001516# Sort BL31 source files to remove duplicates
1517BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301518ifneq (${DECRYPTION_SUPPORT},none)
1519$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001520 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301521else
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001522$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001523 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001524endif #(DECRYPTION_SUPPORT)
1525endif #(NEED_BL31)
Juan Castillo73c99d42015-08-18 14:23:04 +01001526
Juan Castillo70d1fc52015-11-12 10:59:26 +00001527# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamadac939d132018-01-26 11:42:01 +09001528# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo70d1fc52015-11-12 10:59:26 +00001529# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castillo73c99d42015-08-18 14:23:04 +01001530ifeq (${NEED_BL32},yes)
Madhukar Pappireddy26d1e0c2020-01-27 13:37:51 -06001531# Sort BL32 source files to remove duplicates
1532BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada9cd15232018-01-26 11:42:01 +09001533BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1534
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301535ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Aweke434d0492021-07-11 17:25:48 -05001536$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargc6ba9b42019-11-14 16:33:45 +05301537 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1538else
Zelalem Aweke434d0492021-07-11 17:25:48 -05001539$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001540 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001541endif #(DECRYPTION_SUPPORT)
1542endif #(NEED_BL32)
Juan Castillo73c99d42015-08-18 14:23:04 +01001543
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001544# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1545# needs to be built from RMM_SOURCES.
1546ifeq (${NEED_RMM},yes)
1547# Sort RMM source files to remove duplicates
1548RMM_SOURCES := $(sort ${RMM_SOURCES})
1549BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1550
1551$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001552 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1553endif #(NEED_RMM)
Zelalem Aweke5b18de02021-07-11 18:33:20 -05001554
Juan Castillo73c99d42015-08-18 14:23:04 +01001555# Add the BL33 image if required by the platform
1556ifeq (${NEED_BL33},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001557$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001558endif #(NEED_BL33)
Juan Castillodb6071c2015-01-13 12:21:04 +00001559
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001560ifeq (${NEED_BL2U},yes)
Masahiro Yamada33950dd2018-01-26 11:42:01 +09001561$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Aweke434d0492021-07-11 17:25:48 -05001562 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001563endif #(NEED_BL2U)
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001564
Nishanth Menon03b397a2016-10-14 01:13:57 +00001565# Expand build macros for the different images
1566ifeq (${NEED_FDT},yes)
Soby Mathew38c14d82017-12-14 17:44:56 +00001567 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001568endif #(NEED_FDT)
Nishanth Menon03b397a2016-10-14 01:13:57 +00001569
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001570# Add Secure Partition packages
1571ifeq (${NEED_SP_PKG},yes)
Olivier Deprezfbd32ac2024-01-26 12:05:36 +01001572$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1573 @${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alves822c7272022-03-22 16:28:51 +00001574sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001575 @${ECHO_BLANK_LINE}
1576 @echo "Built SP Images successfully"
1577 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001578endif #(NEED_SP_PKG)
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001579
Ian Spray36eaaf32014-01-30 17:25:28 +00001580locate-checkpatch:
1581ifndef CHECKPATCH
Etienne Carriere66079b02017-08-23 15:44:01 +02001582 $(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 +00001583else
1584ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carriere66079b02017-08-23 15:44:01 +02001585 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001586endif
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001587endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001588
Achin Gupta4f6ad662013-10-25 09:08:21 +01001589clean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001590 @echo " CLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001591 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001592ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001593 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001594else
1595# Clear the MAKEFLAGS as we do not want
1596# to pass the gnumake flags to nmake.
1597 ${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 +01001598endif #(UNIX_MK)
Juan Castillo73c99d42015-08-18 14:23:04 +01001599 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Garg90aa9012019-11-11 18:46:36 +05301600 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargas5accce52018-05-22 16:05:42 +01001601 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001602
James Morrisseyeaaeece2013-11-01 13:56:59 +00001603realclean distclean:
Juan Castillo73c99d42015-08-18 14:23:04 +01001604 @echo " REALCLEAN"
Evan Lloydf1477d42015-12-02 18:33:55 +00001605 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1606 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001607ifdef UNIX_MK
Juan Castillo73c99d42015-08-18 14:23:04 +01001608 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001609else
1610# Clear the MAKEFLAGS as we do not want
1611# to pass the gnumake flags to nmake.
1612 ${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 +01001613endif #(UNIX_MK)
Nicolas Boulengueze15591a2021-03-31 12:22:45 +02001614 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Garg90aa9012019-11-11 18:46:36 +05301615 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargas5accce52018-05-22 16:05:42 +01001616 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001617
Ian Spray36eaaf32014-01-30 17:25:28 +00001618checkcodebase: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001619 @echo " CHECKING STYLE"
Dan Handley1a41e8c2016-06-02 18:21:02 +01001620 @if test -d .git ; then \
Paul Beesley1ef35512019-03-07 16:42:31 +00001621 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001622 while read GIT_FILE ; \
1623 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1624 done ; \
1625 else \
1626 find . -type f -not -iwholename "*.git*" \
1627 -not -iwholename "*build*" \
1628 -not -iwholename "*libfdt*" \
Roberto Vargas61f72a32018-05-08 10:27:10 +01001629 -not -iwholename "*libc*" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001630 -not -iwholename "*docs*" \
Paul Beesley1ef35512019-03-07 16:42:31 +00001631 -not -iwholename "*.rst" \
Dan Handley1a41e8c2016-06-02 18:21:02 +01001632 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1633 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001634
1635checkpatch: locate-checkpatch
Juan Castillo73c99d42015-08-18 14:23:04 +01001636 @echo " CHECKING STYLE"
Yann Gautier02a76d52019-03-08 15:44:00 +01001637 @if test -n "${CHECKPATCH_OPTS}"; then \
1638 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1639 fi
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001640 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautier77a0a7f2021-11-02 18:03:31 +01001641 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1642 do \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001643 printf "\n[*] Checking style of '$$commit'\n\n"; \
1644 git log --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001645 -- ${CHECK_PATHS} | \
1646 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001647 git diff --format=email "$$commit~..$$commit" \
Yann Gautier02a76d52019-03-08 15:44:00 +01001648 -- ${CHECK_PATHS} | \
1649 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz51d28932018-01-29 12:00:31 +00001650 done
Juan Castillo73c99d42015-08-18 14:23:04 +01001651
1652certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001653
Pali Rohára9812202020-11-24 15:38:08 +01001654${CRTTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001655 ${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 +00001656 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001657 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001658 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001659
1660ifneq (${GENERATE_COT},0)
1661certificates: ${CRT_DEPS} ${CRTTOOL}
1662 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloydf1477d42015-12-02 18:33:55 +00001663 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001664 @echo "Built $@ successfully"
1665 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloydf1477d42015-12-02 18:33:55 +00001666 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001667endif #(GENERATE_COT)
Juan Castillo73c99d42015-08-18 14:23:04 +01001668
1669${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001670 $(eval ${CHECK_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001671 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1672 ${Q}${FIPTOOL} info $@
Evan Lloydf1477d42015-12-02 18:33:55 +00001673 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001674 @echo "Built $@ successfully"
Evan Lloydf1477d42015-12-02 18:33:55 +00001675 @${ECHO_BLANK_LINE}
Juan Castillo73c99d42015-08-18 14:23:04 +01001676
Yatharth Kochar01912622015-10-12 12:33:47 +01001677ifneq (${GENERATE_COT},0)
1678fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1679 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd052ab522017-04-11 16:52:00 +01001680 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001681 @echo "Built $@ successfully"
1682 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd052ab522017-04-11 16:52:00 +01001683 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001684endif #(GENERATE_COT)
Yatharth Kochar01912622015-10-12 12:33:47 +01001685
1686${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohár4727fd12020-11-24 16:53:04 +01001687 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm819281e2016-05-25 16:20:20 +01001688 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1689 ${Q}${FIPTOOL} info $@
Evan Lloyd052ab522017-04-11 16:52:00 +01001690 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001691 @echo "Built $@ successfully"
Evan Lloyd052ab522017-04-11 16:52:00 +01001692 @${ECHO_BLANK_LINE}
Yatharth Kochar01912622015-10-12 12:33:47 +01001693
Juan Castillo73c99d42015-08-18 14:23:04 +01001694fiptool: ${FIPTOOL}
1695fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochar01912622015-10-12 12:33:47 +01001696fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Juan Castillo6f971622014-10-21 11:30:42 +01001697
Pali Rohára9812202020-11-24 15:38:08 +01001698${FIPTOOL}: FORCE
Sami Mujawar88a1cf12020-04-30 12:41:57 +01001699ifdef UNIX_MK
Lionel Debieve598b1662022-11-14 11:05:09 +01001700 ${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 +01001701else
1702# Clear the MAKEFLAGS as we do not want
1703# to pass the gnumake flags to nmake.
1704 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanandc5e1da82023-04-24 15:57:05 +01001705endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001706
Pali Rohára9812202020-11-24 15:38:08 +01001707romlib.bin: libraries FORCE
John Tsichritzisbbb24f62019-05-21 15:47:37 +01001708 ${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 +01001709
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001710memmap: all
Harrison Mutaiaf5b49e2023-02-23 10:33:58 +00001711ifdef UNIX_MK
1712 ${Q}PYTHONPATH=${CURDIR}/tools/memory \
1713 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1714else
1715 ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
1716 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1717endif
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001718
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001719doc:
1720 @echo " BUILD DOCUMENTATION"
1721 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1722
Sumit Garg90aa9012019-11-11 18:46:36 +05301723enctool: ${ENCTOOL}
1724
Pali Rohára9812202020-11-24 15:38:08 +01001725${ENCTOOL}: FORCE
Lionel Debieve598b1662022-11-14 11:05:09 +01001726 ${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 +05301727 @${ECHO_BLANK_LINE}
1728 @echo "Built $@ successfully"
1729 @${ECHO_BLANK_LINE}
1730
Joakim Bech35fab8c2014-01-23 14:51:49 +01001731cscope:
1732 @echo " CSCOPE"
1733 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1734 ${Q}cscope -b -q -k
1735
Ryan Harkin72ee3312014-01-15 16:55:07 +00001736help:
John Tsichritzis7c231262019-05-21 15:57:31 +01001737 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001738 @echo ""
1739 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +00001740 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001741 @echo ""
John Tsichritzis7c231262019-05-21 15:57:31 +01001742 @echo "platform = ${PLATFORM_LIST}"
1743 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001744 @echo "Please refer to the User Guide for a list of all supported options."
1745 @echo "Note that the build system doesn't track dependencies for build "
1746 @echo "options. Therefore, if any of the build options are changed "
1747 @echo "from a previous build, a clean build must be performed."
1748 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001749 @echo "Supported Targets:"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001750 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001751 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001752 @echo " bl2 Build the BL2 binary"
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001753 @echo " bl2u Build the BL2U binary"
Juan Castillod1786372015-12-14 09:35:25 +00001754 @echo " bl31 Build the BL31 binary"
Soby Mathew9d29c222016-05-05 14:33:33 +01001755 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1756 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castillo73c99d42015-08-18 14:23:04 +01001757 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001758 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochar01912622015-10-12 12:33:47 +01001759 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001760 @echo " checkcodebase Check the coding style of the entire source tree"
1761 @echo " checkpatch Check the coding style on changes in the current"
1762 @echo " branch against BASE_COMMIT (default origin/master)"
1763 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001764 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001765 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo6f971622014-10-21 11:30:42 +01001766 @echo " certtool Build the Certificate generation tool"
Sumit Garg90aa9012019-11-11 18:46:36 +05301767 @echo " enctool Build the Firmware encryption tool"
Andreas Färber59dead22016-10-10 05:18:49 +02001768 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandeyce2b1ec2020-01-14 11:52:05 +00001769 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaz26010da2018-11-27 14:58:04 +00001770 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathew38c14d82017-12-14 17:44:56 +00001771 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcfe83912019-10-16 14:30:51 +01001772 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy6de32372020-01-28 12:41:20 -06001773 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001774 @echo ""
Sandrine Bailleux1b578592015-02-18 16:18:00 +00001775 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001776 @echo ""
1777 @echo "example: build all targets for the FVP platform:"
1778 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohára9812202020-11-24 15:38:08 +01001779
1780.PHONY: FORCE
1781FORCE:;