blob: f324ebcc670fa0f70671c62a903f01e9b04d4828 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06002# Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005#
6
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +01007#
Juan Castillo04be3a52014-06-30 11:41:46 +01008# Trusted Firmware Version
9#
Soby Mathewd42eaee2018-10-01 16:16:34 +010010VERSION_MAJOR := 2
Manish V Badarkhe5eeeb0c2023-11-21 14:35:13 +000011VERSION_MINOR := 10
Yann Gautier5f4cbed2024-02-08 18:40:27 +010012# VERSION_PATCH is only used for LTS releases
13VERSION_PATCH := 0
Yann Gautier57078a92023-10-03 11:09:07 +020014VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castillo04be3a52014-06-30 11:41:46 +010015
Juan Castillo396644b2015-10-22 11:34:44 +010016# Default goal is build all images
17.DEFAULT_GOAL := all
18
Douglas Raillard527cd902016-12-28 14:47:50 +000019# Avoid any implicit propagation of command line variable definitions to
20# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
21# usage. Other command line options like "-s" are still propagated as usual.
22MAKEOVERRIDES =
23
Evan Lloydf2697142015-12-02 18:17:37 +000024MAKE_HELPERS_DIRECTORY := make_helpers/
25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000026include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010027
28################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010029# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010030################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010031
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010032include ${MAKE_HELPERS_DIRECTORY}defaults.mk
dp-arm3cac7862016-09-19 11:18:44 +010033
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010034# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010035ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010036ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
37PLAT := ${DEFAULT_PLAT}
Achin Gupta4f6ad662013-10-25 09:08:21 +010038
Juan Castilloa3487d12015-08-18 14:23:04 +010039################################################################################
40# Checkpatch script options
41################################################################################
42
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010043CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010044# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030045INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
46 include/drivers/arm, \
47 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010048INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010049 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010050 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010051 $(wildcard include/lib/*)))
52INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030053 include/lib \
54 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010055 $(wildcard include/*)))
56LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010057 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000058 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010059 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010060 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010061 $(wildcard lib/*)))
62ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
63 lib \
64 include \
65 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000066 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010067 $(wildcard *)))
68CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
69 ${INC_DIRS_TO_CHECK} \
70 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030071 ${LIB_DIRS_TO_CHECK} \
72 ${INC_DRV_DIRS_TO_CHECK} \
73 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000074
Juan Castilloa3487d12015-08-18 14:23:04 +010075################################################################################
76# Process build options
77################################################################################
78
79# Verbose flag
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010080ifeq (${V},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010081 Q:=@
82 ECHO:=@echo
83 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010084else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010085 Q:=
86 ECHO:=$(ECHO_QUIET)
Andre Przywaracf2bb082018-09-27 10:56:05 +010087endif
88
89ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010090 Q:=@
91 ECHO:=$(ECHO_QUIET)
Achin Gupta4f6ad662013-10-25 09:08:21 +010092endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010093
94export Q ECHO
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000095
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010096################################################################################
97# Toolchain
98################################################################################
99
100HOSTCC := gcc
101export HOSTCC
102
103CC := ${CROSS_COMPILE}gcc
Chris Kayc7ea3472024-01-15 18:45:07 +0000104CPP := ${CROSS_COMPILE}gcc -E
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100105AS := ${CROSS_COMPILE}gcc
Chris Kayfdb6f422024-01-15 19:55:11 +0000106AR := ${CROSS_COMPILE}gcc-ar
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100107LINKER := ${CROSS_COMPILE}ld
108OC := ${CROSS_COMPILE}objcopy
109OD := ${CROSS_COMPILE}objdump
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100110DTC := dtc
111
112# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
113ifneq ($(strip $(wildcard ${LD}.bfd) \
114 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
115LINKER := ${LINKER}.bfd
Juan Castilloa3487d12015-08-18 14:23:04 +0100116endif
117
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100118################################################################################
119# Auxiliary tools (fiptool, cert_create, etc)
120################################################################################
121
122# Variables for use with Certificate Generation Tool
123CRTTOOLPATH ?= tools/cert_create
124CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
125
126# Variables for use with Firmware Encryption Tool
127ENCTOOLPATH ?= tools/encrypt_fw
128ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
129
130# Variables for use with Firmware Image Package
131FIPTOOLPATH ?= tools/fiptool
132FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
133
134# Variables for use with sptool
135SPTOOLPATH ?= tools/sptool
136SPTOOL ?= ${SPTOOLPATH}/sptool.py
137SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakinaba46182023-02-14 11:56:02 +0000138SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100139
140# Variables for use with ROMLIB
141ROMLIBPATH ?= lib/romlib
142
143# Variable for use with Python
144PYTHON ?= python3
145
146# Variables for use with documentation build using Sphinx tool
147DOCS_PATH ?= docs
148
149################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100150# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100151################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100152ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100153 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500154# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100155else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100156 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100157endif #(ARM_ARCH_MAJOR)
158
159################################################################################
160# Get Architecture Feature Modifiers
161################################################################################
162arch-features = ${ARM_ARCH_FEATURE}
163
originfba80d82022-01-19 16:30:14 +0000164ifneq ($(findstring clang,$(notdir $(CC))),)
165 ifneq ($(findstring armclang,$(notdir $(CC))),)
Govindraj Raja69096412023-06-01 16:29:16 -0500166 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
167 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000168 LD := $(LINKER)
169 else
Govindraj Raja69096412023-06-01 16:29:16 -0500170 TF_CFLAGS_aarch32 = $(target32-directive)
171 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000172 LD := $(shell $(CC) --print-prog-name ld.lld)
173
174 AR := $(shell $(CC) --print-prog-name llvm-ar)
175 OD := $(shell $(CC) --print-prog-name llvm-objdump)
176 OC := $(shell $(CC) --print-prog-name llvm-objcopy)
177 endif
178
179 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
originfba80d82022-01-19 16:30:14 +0000180 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
zelalem-aweked5f45272019-11-12 16:20:17 -0600181else ifneq ($(findstring gcc,$(notdir $(CC))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100182 ifeq ($(ENABLE_LTO),1)
183 # Enable LTO only for aarch64
184 ifeq (${ARCH},aarch64)
185 LTO_CFLAGS = -flto
186 # Use gcc as a wrapper for the ld, recommended for LTO
187 LINKER := ${CROSS_COMPILE}gcc
188 endif
zelalem-aweked5f45272019-11-12 16:20:17 -0600189 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100190 LD = $(LINKER)
dp-arm320e8442017-05-02 12:00:08 +0100191else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100192 LD = $(LINKER)
193endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100194
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100195# Process Debug flag
196$(eval $(call add_define,DEBUG))
197ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100198 BUILD_TYPE := debug
199 TF_CFLAGS += -g -gdwarf-4
200 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100201
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100202 # Use LOG_LEVEL_INFO by default for debug builds
203 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100204else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100205 BUILD_TYPE := release
206 # Use LOG_LEVEL_NOTICE by default for release builds
207 LOG_LEVEL := 20
208endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100209
Peiyuan Song44f8f472020-04-25 16:53:43 +0800210# Default build string (git branch and commit)
211ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100212 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800213endif
laurenw-arme954f652022-07-12 10:12:05 -0500214VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800215
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100216ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100217 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100218else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100219 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100220else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100221 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
222endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100223
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200224TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100225TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100226
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100227##############################################################################
228# WARNINGS Configuration
229###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100230# General warnings
231WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200232 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000233 -Wredundant-decls
234# stricter warnings
235WARNINGS += -Wextra -Wno-trigraphs
236# too verbose for generic build
237WARNINGS += -Wno-missing-field-initializers \
238 -Wno-type-limits -Wno-sign-compare \
239# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
240WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100241
242# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000243# Level 1 - infrequent warnings we should have none of
244# full -Wextra
245WARNING1 += -Wsign-compare
246WARNING1 += -Wtype-limits
247WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100248
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000249# Level 2 - problematic warnings that we want
250# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
251# TODO: disable just for them and move into default build
252WARNING2 += -Wold-style-definition
253WARNING2 += -Wmissing-prototypes
254WARNING2 += -Wmissing-format-attribute
255# TF-A aims to comply with this eventually. Effort too large at present
256WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000257# currently very involved and many platforms set this off
258WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100259
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000260# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100261WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000262WARNING3 += -Waggregate-return
263WARNING3 += -Wnested-externs
264WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100265WARNING3 += -Wcast-qual
266WARNING3 += -Wconversion
267WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100268WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100269WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100270
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000271# Setting W is quite verbose and most warnings will be pre-existing issues
272# outside of the contributor's control. Don't fail the build on them so warnings
273# can be seen and hopefully addressed
274ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100275 ifneq (${W},0)
276 E ?= 0
277 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000278endif
279
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100280ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100281 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100282else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100283 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100284else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100285 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
286endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100287
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100288# Compiler specific warnings
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100289ifeq ($(findstring clang,$(notdir $(CC))),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100290# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100291WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
292 -Wpacked-bitfield-compat -Wshift-overflow=2 \
293 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500294
295# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
296TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
297
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500298ifeq ($(HARDEN_SLS), 1)
299 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
300endif
301
Justin Chadwell7a914232019-07-03 14:15:56 +0100302else
303# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100304WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
305 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100306endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100307
Yann Gautier957c3532018-12-10 18:08:53 +0100308ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100309 ERRORS := -Werror
310endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100311
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100312################################################################################
313# Compiler and Linker Directives
314################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100315CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
316 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500317ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700318 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900319TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500320 -ffunction-sections -fdata-sections \
321 -ffreestanding -fno-builtin -fno-common \
322 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100323
Justin Chadwell83e04882019-08-20 11:01:52 +0100324ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100325 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
326endif #(${SANITIZE_UB},on)
327
Justin Chadwell83e04882019-08-20 11:01:52 +0100328ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100329 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100330 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100331endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100332
david cunado34ab6092017-11-30 21:58:01 +0000333GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
david cunado34ab6092017-11-30 21:58:01 +0000334
Marco Felsch24ad8402022-11-09 12:59:09 +0100335TF_LDFLAGS += -z noexecstack
336
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100337# LD = armlink
Varun Wadekar4d034c52019-01-11 14:47:48 -0800338ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100339 TF_LDFLAGS += --diag_error=warning --lto_level=O1
340 TF_LDFLAGS += --remove --info=unused,unusedsymbols
341 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100342
343# LD = gcc (used when GCC LTO is enabled)
zelalem-aweked5f45272019-11-12 16:20:17 -0600344else ifneq ($(findstring gcc,$(notdir $(LD))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100345 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000346 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100347 TF_LDFLAGS += -Wl,--fatal-warnings -O1
348 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000349
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100350 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
351 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300352 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000353
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100354 ifeq ($(ENABLE_LTO),1)
355 ifeq (${ARCH},aarch64)
356 TF_LDFLAGS += -flto -fuse-linker-plugin
357 endif
358 endif #(ENABLE_LTO)
359
zelalem-aweked5f45272019-11-12 16:20:17 -0600360# GCC automatically adds fix-cortex-a53-843419 flag when used to link
361# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100362 ifeq (${ARCH},aarch64)
363 ifneq (${ERRATA_A53_843419},1)
364 TF_LDFLAGS += -mno-fix-cortex-a53-843419
365 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100366 endif
367 TF_LDFLAGS += -nostdlib
368 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100369
370# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800371else
Marco Felsch24ad8402022-11-09 12:59:09 +0100372# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
373# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100374 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
375 TF_LDFLAGS += -O1
376 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000377
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100378 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
379 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300380 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000381
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100382# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000383# therefore don't add those in that case.
384# ld.lld reports section type mismatch warnings,
385# therefore don't add --fatal-warnings to it.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100386 ifeq ($(findstring ld.lld,$(notdir $(LD))),)
387 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
388 endif
389
390endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100391
392################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500393# Setup ARCH_MAJOR/MINOR before parsing arch_features.
394################################################################################
395ifeq (${ENABLE_RME},1)
396 ARM_ARCH_MAJOR := 8
397 ARM_ARCH_MINOR := 6
398endif
399
400################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100401# Common sources and include directories
402################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100403include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100404
405BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100406 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100407 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800408 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100409 lib/${ARCH}/cache_helpers.S \
410 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000411 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000412 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100413 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000414 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100415 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100416 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000417
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100418ifeq ($(notdir $(CC)),armclang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100419 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100420endif
421
Justin Chadwell83e04882019-08-20 11:01:52 +0100422ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100423 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100424endif
425
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200426INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000427 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000428 -Iinclude/lib/cpus/${ARCH} \
429 -Iinclude/lib/el3_runtime/${ARCH} \
430 ${PLAT_INCLUDES} \
431 ${SPD_INCLUDES}
432
Nishant Sharma331b5682022-08-15 16:37:07 +0100433DTC_FLAGS += -I dts -O dtb
434DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
435 -x assembler-with-cpp $(DEFINES)
436
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000437include common/backtrace/backtrace.mk
438
Juan Castilloa3487d12015-08-18 14:23:04 +0100439################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500440# Generic definitions
441################################################################################
442include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
443
444ifeq (${BUILD_BASE},)
445 BUILD_BASE := ./build
446endif
447BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
448
449SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
450
451# Platforms providing their own TBB makefile may override this value
452INCLUDE_TBBR_MK := 1
453
454################################################################################
455# Include SPD Makefile if one has been specified
456################################################################################
457
458ifneq (${SPD},none)
459 ifeq (${ARCH},aarch32)
460 $(error "Error: SPD is incompatible with AArch32.")
461 endif
462
463 ifdef EL3_PAYLOAD_BASE
464 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
465 $(warning "The SPD and its BL32 companion will be present but \
466 ignored.")
467 endif
468
469 ifeq (${SPD},spmd)
470 # SPMD is located in std_svc directory
471 SPD_DIR := std_svc
472
473 ifeq ($(SPMD_SPM_AT_SEL2),1)
474 CTX_INCLUDE_EL2_REGS := 1
475 ifeq ($(SPMC_AT_EL3),1)
476 $(error SPM cannot be enabled in both S-EL2 and EL3.)
477 endif
478 endif
479
480 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
481 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
482 endif
483
484 ifeq ($(TS_SP_FW_CONFIG),1)
485 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
486 endif
487
488 ifneq ($(ARM_BL2_SP_LIST_DTS),)
489 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
490 endif
491
492 ifneq ($(SP_LAYOUT_FILE),)
493 BL2_ENABLE_SP_LOAD := 1
494 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500495
496 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
497 ifneq ($(SPMC_AT_EL3),1)
498 $(error SEL0 SP cannot be enabled without SPMC at EL3)
499 endif
500 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500501 else
502 # All other SPDs in spd directory
503 SPD_DIR := spd
504 endif #(SPD)
505
506 # We expect to locate an spd.mk under the specified SPD directory
507 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
508
509 ifeq (${SPD_MAKE},)
510 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
511 endif
512 $(info Including ${SPD_MAKE})
513 include ${SPD_MAKE}
514
515 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
516 # Makefile would set NEED_BL32 to "yes". In this case, the build system
517 # supports two mutually exclusive options:
518 # * BL32 is built from source: then BL32_SOURCES must contain the list
519 # of source files to build BL32
520 # * BL32 is a prebuilt binary: then BL32 must point to the image file
521 # that will be included in the FIP
522 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
523 # over the sources.
524endif #(SPD=none)
525
526ifeq (${ENABLE_SPMD_LP}, 1)
527ifneq (${SPD},spmd)
528 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
529endif
530ifeq ($(SPMC_AT_EL3),1)
531 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
532endif
533endif
534
535################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500536# Process BRANCH_PROTECTION value and set
537# Pointer Authentication and Branch Target Identification flags
538################################################################################
539ifeq (${BRANCH_PROTECTION},0)
540 # Default value turns off all types of branch protection
541 BP_OPTION := none
542else ifneq (${ARCH},aarch64)
543 $(error BRANCH_PROTECTION requires AArch64)
544else ifeq (${BRANCH_PROTECTION},1)
545 # Enables all types of branch protection features
546 BP_OPTION := standard
547 ENABLE_BTI := 1
548 ENABLE_PAUTH := 1
549else ifeq (${BRANCH_PROTECTION},2)
550 # Return address signing to its standard level
551 BP_OPTION := pac-ret
552 ENABLE_PAUTH := 1
553else ifeq (${BRANCH_PROTECTION},3)
554 # Extend the signing to include leaf functions
555 BP_OPTION := pac-ret+leaf
556 ENABLE_PAUTH := 1
557else ifeq (${BRANCH_PROTECTION},4)
558 # Turn on branch target identification mechanism
559 BP_OPTION := bti
560 ENABLE_BTI := 1
561else
562 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
563endif #(BRANCH_PROTECTION)
564
565ifeq ($(ENABLE_PAUTH),1)
566 CTX_INCLUDE_PAUTH_REGS := 1
567endif
568ifneq (${BP_OPTION},none)
569 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
570endif #(BP_OPTION)
571
572# Pointer Authentication sources
573ifeq (${ENABLE_PAUTH}, 1)
574# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
575# Pauth support. As it's not secure, it must be reimplemented for real platforms
576 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
577endif
578
Govindraj Raja1a211292023-09-20 14:32:24 -0500579################################################################################
580# Include the platform specific Makefile after the SPD Makefile (the platform
581# makefile may use all previous definitions in this file)
582################################################################################
583include ${PLAT_MAKEFILE_FULL}
584
585################################################################################
586# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
587# platform.
588################################################################################
589include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
590
Govindraj Raja0386e312023-08-17 10:41:48 -0500591####################################################
592# Enable required options for Memory Stack Tagging.
593####################################################
594
595# Currently, these options are enabled only for clang and armclang compiler.
596ifeq (${SUPPORT_STACK_MEMTAG},yes)
597 ifdef mem_tag_arch_support
598 # Check for armclang and clang compilers
599 ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
600 # Add "memtag" architecture feature modifier if not specified
601 ifeq ( ,$(findstring memtag,$(arch-features)))
602 arch-features := $(arch-features)+memtag
603 endif # memtag
604 ifeq ($(notdir $(CC)),armclang)
605 TF_CFLAGS += -mmemtag-stack
606 else ifeq ($(notdir $(CC)),clang)
607 TF_CFLAGS += -fsanitize=memtag
608 endif # armclang
609 endif
610 else
611 $(error "Error: stack memory tagging is not supported for \
612 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
613 endif #(mem_tag_arch_support)
614endif #(SUPPORT_STACK_MEMTAG)
615
616################################################################################
617# RME dependent flags configuration, Enable optional features for RME.
618################################################################################
619# FEAT_RME
620ifeq (${ENABLE_RME},1)
Govindraj Raja60f52662023-10-12 16:57:46 -0500621 # RME doesn't support BRBE
622 ENABLE_BRBE_FOR_NS := 0
623
Govindraj Raja0386e312023-08-17 10:41:48 -0500624 # RME doesn't support PIE
625 ifneq (${ENABLE_PIE},0)
626 $(error ENABLE_RME does not support PIE)
627 endif
628
629 # RME doesn't support BRBE
630 ifneq (${ENABLE_BRBE_FOR_NS},0)
631 $(error ENABLE_RME does not support BRBE.)
632 endif
633
634 # RME requires AARCH64
635 ifneq (${ARCH},aarch64)
636 $(error ENABLE_RME requires AArch64)
637 endif
638
639 # RME requires el2 context to be saved for now.
640 CTX_INCLUDE_EL2_REGS := 1
641 CTX_INCLUDE_AARCH32_REGS := 0
642 CTX_INCLUDE_PAUTH_REGS := 1
643
644 # RME enables CSV2_2 extension by default.
645 ENABLE_FEAT_CSV2_2 = 1
646endif #(FEAT_RME)
647
648################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500649# Include rmmd Makefile if RME is enabled
650################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500651ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100652 ifneq (${ARCH},aarch64)
653 $(error ENABLE_RME requires AArch64)
654 endif
655 ifeq ($(SPMC_AT_EL3),1)
656 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
657 endif
658
659 ifneq (${SPD}, none)
660 ifneq (${SPD}, spmd)
661 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
662 endif
663 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500664include services/std_svc/rmmd/rmmd.mk
665$(warning "RME is an experimental feature")
666endif
667
Govindraj Raja1a211292023-09-20 14:32:24 -0500668ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
669 ifeq (${SPD},none)
670 ifeq (${ENABLE_RME},0)
671 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
672 or RME is enabled)
673 endif
674 endif
675endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000676
Govindraj Raja69096412023-06-01 16:29:16 -0500677################################################################################
678# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
679# up with appropriate march values for compiler.
680################################################################################
681include ${MAKE_HELPERS_DIRECTORY}march.mk
682
683TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600684ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500685
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600686# This internal flag is common option which is set to 1 for scenarios
687# when the BL2 is running in EL3 level. This occurs in two scenarios -
688# 4 world system running BL2 at EL3 and two world system without BL1 running
689# BL2 in EL3
690
691ifeq (${RESET_TO_BL2},1)
692 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100693 ifeq (${ENABLE_RME},1)
694 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
695 supported at the moment.)
696 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600697else ifeq (${ENABLE_RME},1)
698 BL2_RUNS_AT_EL3 := 1
699else
700 BL2_RUNS_AT_EL3 := 0
701endif
702
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100703# This internal flag is set to 1 when Firmware First handling of External aborts
704# is required by lowe ELs. Currently only NS requires this support.
705ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
706 FFH_SUPPORT := 1
707else
708 FFH_SUPPORT := 0
709endif
710
Masahiro Yamadae2395b42017-11-04 03:12:28 +0900711$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
712
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100713ifeq (${ARM_ARCH_MAJOR},7)
714include make_helpers/armv7-a-cpus.mk
715endif
716
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900717PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
718ifneq ($(PIE_FOUND),)
719 TF_CFLAGS += -fno-PIE
Samuel Holland9286c022022-04-08 21:56:02 -0500720ifneq ($(findstring gcc,$(notdir $(LD))),)
721 TF_LDFLAGS += -no-pie
722endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100723endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900724
725ifneq ($(findstring gcc,$(notdir $(LD))),)
726 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100727else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900728 PIE_LDFLAGS += -pie --no-dynamic-linker
729endif
730
731ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100732 ifeq ($(RESET_TO_BL2),1)
733 ifneq ($(BL2_IN_XIP_MEM),1)
734 BL2_CPPFLAGS += -fpie
735 BL2_CFLAGS += -fpie
736 BL2_LDFLAGS += $(PIE_LDFLAGS)
737 endif #(BL2_IN_XIP_MEM)
738 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000739 BL31_CPPFLAGS += -fpie
740 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900741 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000742
743 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900744 BL32_CFLAGS += -fpie
745 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100746endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100747
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000748BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
749BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
750BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
751
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900752BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600753ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100754 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900755else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100756 BL2_CPPFLAGS += -DIMAGE_AT_EL1
757endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000758
759ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100760 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
761 BL31_CPPFLAGS += -DIMAGE_AT_EL3
762 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000763else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100764 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900765endif
766
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000767# Include the CPU specific operations makefile, which provides default
768# values for all CPU errata workarounds and CPU specific optimisations.
769# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100770include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100771
dp-armcdd03cb2017-02-15 11:07:55 +0000772################################################################################
773# Build `AARCH32_SP` as BL32 image for AArch32
774################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100775ifeq (${ARCH},aarch32)
776 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000777
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100778 ifneq (${AARCH32_SP},none)
779 # We expect to locate an sp.mk under the specified AARCH32_SP directory
780 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000781
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100782 ifeq (${AARCH32_SP_MAKE},)
783 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
784 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500785 $(info Including ${AARCH32_SP_MAKE})
786 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100787 endif
788endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800789
790################################################################################
791# Include libc if not overridden
792################################################################################
793ifeq (${OVERRIDE_LIBC},0)
794include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000795endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100796
797################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100798# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000799################################################################################
800
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100801# USE_DEBUGFS experimental feature recommended only in debug builds
802ifeq (${USE_DEBUGFS},1)
803 ifeq (${DEBUG},1)
804 $(warning DEBUGFS experimental feature is enabled.)
805 else
806 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800807 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100808endif #(USE_DEBUGFS)
809
810# USE_SPINLOCK_CAS requires AArch64 build
811ifeq (${USE_SPINLOCK_CAS},1)
812 ifneq (${ARCH},aarch64)
813 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800814 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100815endif #(USE_SPINLOCK_CAS)
816
817# The cert_create tool cannot generate certificates individually, so we use the
818# target 'certificates' to create them all
819ifneq (${GENERATE_COT},0)
820 FIP_DEPS += certificates
821 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000822endif
823
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100824ifneq (${DECRYPTION_SUPPORT},none)
825 ENC_ARGS += -f ${FW_ENC_STATUS}
826 ENC_ARGS += -k ${ENC_KEY}
827 ENC_ARGS += -n ${ENC_NONCE}
828 FIP_DEPS += enctool
829 FWU_FIP_DEPS += enctool
830endif #(DECRYPTION_SUPPORT)
831
832ifdef EL3_PAYLOAD_BASE
833 ifdef PRELOADED_BL33_BASE
834 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
835 incompatible build options. EL3_PAYLOAD_BASE has priority.")
836 endif
837 ifneq (${GENERATE_COT},0)
838 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
839 build options.")
840 endif
841 ifneq (${TRUSTED_BOARD_BOOT},0)
842 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
843 incompatible \ build options.")
844 endif
845endif #(EL3_PAYLOAD_BASE)
846
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000847ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100848 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000849 $(warning "BL33 image is not needed when option \
850 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100851 endif
852 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100853 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100854 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
855 endif
856endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000857
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000858# When building for systems with hardware-assisted coherency, there's no need to
859# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
860ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100861 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000862endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100863
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600864#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
865ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100866 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000867endif
868
Manish Pandeyd419e222023-02-13 12:39:17 +0000869# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100870ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100871 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100872 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000873endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100874
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100875
Manish Pandeyd419e222023-02-13 12:39:17 +0000876# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000877ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100878 ifeq ($(ENABLE_FEAT_RAS),0)
879 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
880 endif
881endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000882
Roberto Vargas025946a2018-09-24 17:20:48 +0100883# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100884ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100885 ifeq (${TRUSTED_BOARD_BOOT}, 0)
886 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
887 to be set.")
888 endif
889endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100890
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100891ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
892# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100893 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100894else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
895# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100896 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100897else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
898# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100899 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100900else ifeq (${TRUSTED_BOARD_BOOT},1)
901# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100902 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000903else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100904 CRYPTO_SUPPORT := 0
905endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000906
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100907# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
908ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100909 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100910endif
911
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000912# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100913# registers associated to it are also saved and restored.
914# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000915ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100916 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
917 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
918 endif
919endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100920
921ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100922 ifneq (${ARCH},aarch64)
923 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
924 endif
925endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000926
Manish V Badarkhe99575e42021-06-25 23:28:59 +0100927ifeq ($(PSA_FWU_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100928 $(info PSA_FWU_SUPPORT is an experimental feature)
929endif #(PSA_FWU_SUPPORT)
Manish V Badarkhe99575e42021-06-25 23:28:59 +0100930
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000931ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100932 $(info FEATURE_DETECTION is an experimental feature)
933endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000934
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000935ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100936 ifeq (${ENABLE_SME_FOR_NS}, 0)
937 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
938 to be set")
939 $(warning "Forced ENABLE_SME_FOR_NS=1")
940 override ENABLE_SME_FOR_NS := 1
941 endif
942endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000943
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000944ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100945 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
946 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
947 library v2")
948 endif
949endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000950
Sumit Garg392e4df2019-11-15 10:43:00 +0530951ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100952 ifeq (${TRUSTED_BOARD_BOOT}, 0)
953 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
954 to be set)
955 endif
956endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530957
johpow0181865962022-01-28 17:06:20 -0600958# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500959ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600960
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100961 # SME/SVE only supported on AArch64
962 ifneq (${ENABLE_SME_FOR_NS},0)
963 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
964 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000965
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100966 ifeq (${ENABLE_SVE_FOR_NS},1)
967 # Warning instead of error due to CI dependency on this
968 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
969 endif
johpow0181865962022-01-28 17:06:20 -0600970
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100971 # BRBE is not supported in AArch32
972 ifeq (${ENABLE_BRBE_FOR_NS},1)
973 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
974 endif
johpow0181865962022-01-28 17:06:20 -0600975
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100976 # FEAT_RNG_TRAP is not supported in AArch32
977 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
978 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
979 endif
980endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500981
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000982ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100983 ifeq (${ENABLE_SVE_FOR_NS},0)
984 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
985 endif
986endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000987
johpow019baade32021-07-08 14:14:00 -0500988# Secure SME/SVE requires the non-secure component as well
989ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100990 ifeq (${ENABLE_SME_FOR_NS},0)
991 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
992 endif
993 ifeq (${ENABLE_SVE_FOR_SWD},0)
994 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
995 endif
996endif #(ENABLE_SME_FOR_SWD)
997
johpow019baade32021-07-08 14:14:00 -0500998ifeq (${ENABLE_SVE_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100999 ifeq (${ENABLE_SVE_FOR_NS},0)
1000 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1001 endif
1002endif #(ENABLE_SVE_FOR_SWD)
johpow019baade32021-07-08 14:14:00 -05001003
1004# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
1005# its own context management including FPU registers.
1006ifeq (${CTX_INCLUDE_FPREGS},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001007 ifneq (${ENABLE_SME_FOR_NS},0)
1008 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1009 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +00001010
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001011 ifeq (${ENABLE_SVE_FOR_NS},1)
1012 # Warning instead of error due to CI dependency on this
1013 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1014 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1015 override ENABLE_SVE_FOR_NS := 0
1016 endif
1017endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001018
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001019ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001020 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001021endif
1022
Raymond Mao98983392023-07-25 07:53:35 -07001023ifeq (${TRANSFER_LIST},1)
1024 $(info TRANSFER_LIST is an experimental feature)
1025endif
1026
Chris Kayd02c2312022-09-29 16:21:24 +01001027ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001028 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1029 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1030 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001031endif
1032
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001033ifeq ($(PSA_CRYPTO),1)
1034 $(info PSA_CRYPTO is an experimental feature)
1035endif
1036
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001037################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001038# Process platform overrideable behaviour
1039################################################################################
1040
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001041ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001042 NEED_BL1 := yes
1043endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001044
Jon Medhurst66573cb2014-02-13 15:19:28 +00001045ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001046 NEED_BL2 := yes
1047
1048 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1049 # Certificate generation tools. This flag can be overridden by the platform.
1050 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001051 # If booting an EL3 payload there is no need for a BL33 image
1052 # in the FIP file.
1053 NEED_BL33 := no
1054 else
1055 ifdef PRELOADED_BL33_BASE
1056 # If booting a BL33 preloaded image there is no need of
1057 # another one in the FIP file.
1058 NEED_BL33 := no
1059 else
1060 NEED_BL33 ?= yes
1061 endif
1062 endif
1063endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001064
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001065ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001066 NEED_BL2U := yes
1067endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001068
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001069# If SCP_BL2 is given, we always want FIP to include it.
1070ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001071 NEED_SCP_BL2 := yes
1072endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001073
Soby Mathewbf169232017-11-14 14:10:10 +00001074# For AArch32, BL31 is not currently supported.
1075ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001076 ifdef BL31_SOURCES
1077 # When booting an EL3 payload, there is no need to compile the BL31
1078 # image nor put it in the FIP.
1079 ifndef EL3_PAYLOAD_BASE
1080 NEED_BL31 := yes
1081 endif
1082 endif
1083endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001084
Juan Castilloa3487d12015-08-18 14:23:04 +01001085# Process TBB related flags
1086ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001087 # Common cert_create options
1088 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001089 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001090 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001091 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001092 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001093 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001094 endif
1095 endif
1096 # Include TBBR makefile (unless the platform indicates otherwise)
1097 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001098 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001099 endif
1100endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001101
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001102ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001103 FIP_ARGS += --align ${FIP_ALIGN}
1104endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001105
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001106ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001107 NEED_FDT := yes
1108endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001109
Juan Castilloa3487d12015-08-18 14:23:04 +01001110################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001111# Include libraries' Makefile that are used in all BL
1112################################################################################
1113
1114include lib/stack_protector/stack_protector.mk
1115
1116################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001117# Include BL specific makefiles
1118################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001119
1120ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001121include bl1/bl1.mk
1122endif
1123
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001124ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001125include bl2/bl2.mk
1126endif
1127
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001128ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001129include bl2u/bl2u.mk
1130endif
1131
Soby Mathewbf169232017-11-14 14:10:10 +00001132ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001133include bl31/bl31.mk
1134endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001135
Soby Mathew574e01e2017-02-14 10:05:07 +00001136################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001137# Build options checks
1138################################################################################
1139
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001140# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001141$(eval $(call assert_booleans,\
1142 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001143 ALLOW_RO_XLAT_TABLES \
1144 BL2_ENABLE_SP_LOAD \
1145 COLD_BOOT_SINGLE_CPU \
1146 CREATE_KEYS \
1147 CTX_INCLUDE_AARCH32_REGS \
1148 CTX_INCLUDE_FPREGS \
1149 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001150 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001151 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001152 DYN_DISABLE_AUTH \
1153 EL3_EXCEPTION_HANDLING \
1154 ENABLE_AMU_AUXILIARY_COUNTERS \
1155 ENABLE_AMU_FCONF \
1156 AMU_RESTRICT_COUNTERS \
1157 ENABLE_ASSERTIONS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001158 ENABLE_PIE \
1159 ENABLE_PMF \
1160 ENABLE_PSCI_STAT \
1161 ENABLE_RUNTIME_INSTRUMENTATION \
1162 ENABLE_SME_FOR_SWD \
1163 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001164 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001165 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001166 ERROR_DEPRECATED \
1167 FAULT_INJECTION_SUPPORT \
1168 GENERATE_COT \
1169 GICV2_G0_FOR_EL3 \
1170 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001171 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001172 HW_ASSISTED_COHERENCY \
1173 MEASURED_BOOT \
1174 DRTM_SUPPORT \
1175 NS_TIMER_SWITCH \
1176 OVERRIDE_LIBC \
1177 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001178 PROGRAMMABLE_RESET_ADDRESS \
1179 PSCI_EXTENDED_STATE_ID \
1180 PSCI_OS_INIT_MODE \
1181 RESET_TO_BL31 \
1182 SAVE_KEYS \
1183 SEPARATE_CODE_AND_RODATA \
1184 SEPARATE_BL2_NOLOAD_REGION \
1185 SEPARATE_NOBITS_REGION \
1186 SPIN_ON_BL1_EXIT \
1187 SPM_MM \
1188 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001189 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001190 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001191 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001192 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001193 TRUSTED_BOARD_BOOT \
1194 USE_COHERENT_MEM \
1195 USE_DEBUGFS \
1196 ARM_IO_IN_DTB \
1197 SDEI_IN_FCONF \
1198 SEC_INT_DESC_IN_FCONF \
1199 USE_ROMLIB \
1200 USE_TBBR_DEFS \
1201 WARMBOOT_ENABLE_DCACHE_EARLY \
1202 RESET_TO_BL2 \
1203 BL2_IN_XIP_MEM \
1204 BL2_INV_DCACHE \
1205 USE_SPINLOCK_CAS \
1206 ENCRYPT_BL31 \
1207 ENCRYPT_BL32 \
1208 ERRATA_SPECULATIVE_AT \
1209 RAS_TRAP_NS_ERR_REC_ACCESS \
1210 COT_DESC_IN_DTB \
1211 USE_SP804_TIMER \
1212 PSA_FWU_SUPPORT \
1213 ENABLE_MPMM \
1214 ENABLE_MPMM_FCONF \
1215 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001216 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001217 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001218 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001219 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001220 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001221 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001222 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001223 PLATFORM_REPORT_CTX_MEM_USE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001224)))
Dan Handley81be1002015-03-27 17:44:35 +00001225
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001226# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001227$(eval $(call assert_numerics,\
1228 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001229 ARM_ARCH_MAJOR \
1230 ARM_ARCH_MINOR \
1231 BRANCH_PROTECTION \
1232 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001233 CTX_INCLUDE_NEVE_REGS \
1234 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001235 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001236 ENABLE_BRBE_FOR_NS \
1237 ENABLE_TRBE_FOR_NS \
1238 ENABLE_BTI \
1239 ENABLE_PAUTH \
1240 ENABLE_FEAT_AMU \
1241 ENABLE_FEAT_AMUv1p1 \
1242 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001243 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001244 ENABLE_FEAT_DIT \
1245 ENABLE_FEAT_ECV \
1246 ENABLE_FEAT_FGT \
1247 ENABLE_FEAT_HCX \
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06001248 ENABLE_FEAT_MTE \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001249 ENABLE_FEAT_MTE2 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001250 ENABLE_FEAT_PAN \
1251 ENABLE_FEAT_RNG \
1252 ENABLE_FEAT_RNG_TRAP \
1253 ENABLE_FEAT_SEL2 \
1254 ENABLE_FEAT_TCR2 \
Govindraj Rajac2dad572024-01-23 16:03:53 -06001255 ENABLE_FEAT_SB \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001256 ENABLE_FEAT_S2PIE \
1257 ENABLE_FEAT_S1PIE \
1258 ENABLE_FEAT_S2POE \
1259 ENABLE_FEAT_S1POE \
1260 ENABLE_FEAT_GCS \
1261 ENABLE_FEAT_VHE \
Maksims Svecovsdf4ad842023-03-24 13:05:09 +00001262 ENABLE_FEAT_MTE_PERM \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001263 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001264 ENABLE_RME \
1265 ENABLE_SPE_FOR_NS \
1266 ENABLE_SYS_REG_TRACE_FOR_NS \
1267 ENABLE_SME_FOR_NS \
1268 ENABLE_SME2_FOR_NS \
1269 ENABLE_SVE_FOR_NS \
1270 ENABLE_TRF_FOR_NS \
1271 FW_ENC_STATUS \
1272 NR_OF_FW_BANKS \
1273 NR_OF_IMAGES_IN_FW_BANK \
1274 TWED_DELAY \
1275 ENABLE_FEAT_TWED \
1276 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001277 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001278)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001279
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001280ifdef KEY_SIZE
1281 $(eval $(call assert_numeric,KEY_SIZE))
1282endif
1283
Justin Chadwell83e04882019-08-20 11:01:52 +01001284ifeq ($(filter $(SANITIZE_UB), on off trap),)
1285 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1286endif
1287
Juan Castilloa3487d12015-08-18 14:23:04 +01001288################################################################################
1289# Add definitions to the cpp preprocessor based on the current build options.
1290# This is done after including the platform specific makefile to allow the
1291# platform to overwrite the default options
1292################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001293
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001294$(eval $(call add_defines,\
1295 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001296 ALLOW_RO_XLAT_TABLES \
1297 ARM_ARCH_MAJOR \
1298 ARM_ARCH_MINOR \
1299 BL2_ENABLE_SP_LOAD \
1300 COLD_BOOT_SINGLE_CPU \
1301 CTX_INCLUDE_AARCH32_REGS \
1302 CTX_INCLUDE_FPREGS \
1303 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001304 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001305 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001306 CTX_INCLUDE_EL2_REGS \
1307 CTX_INCLUDE_NEVE_REGS \
1308 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1309 DISABLE_MTPMU \
1310 ENABLE_FEAT_AMU \
1311 ENABLE_AMU_AUXILIARY_COUNTERS \
1312 ENABLE_AMU_FCONF \
1313 AMU_RESTRICT_COUNTERS \
1314 ENABLE_ASSERTIONS \
1315 ENABLE_BTI \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001316 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001317 ENABLE_PAUTH \
1318 ENABLE_PIE \
1319 ENABLE_PMF \
1320 ENABLE_PSCI_STAT \
1321 ENABLE_RME \
1322 ENABLE_RUNTIME_INSTRUMENTATION \
1323 ENABLE_SME_FOR_NS \
1324 ENABLE_SME2_FOR_NS \
1325 ENABLE_SME_FOR_SWD \
1326 ENABLE_SPE_FOR_NS \
1327 ENABLE_SVE_FOR_NS \
1328 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001329 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001330 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001331 ENCRYPT_BL31 \
1332 ENCRYPT_BL32 \
1333 ERROR_DEPRECATED \
1334 FAULT_INJECTION_SUPPORT \
1335 GICV2_G0_FOR_EL3 \
1336 HANDLE_EA_EL3_FIRST_NS \
1337 HW_ASSISTED_COHERENCY \
1338 LOG_LEVEL \
1339 MEASURED_BOOT \
1340 DRTM_SUPPORT \
1341 NS_TIMER_SWITCH \
1342 PL011_GENERIC_UART \
1343 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001344 PROGRAMMABLE_RESET_ADDRESS \
1345 PSCI_EXTENDED_STATE_ID \
1346 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001347 RESET_TO_BL31 \
1348 SEPARATE_CODE_AND_RODATA \
1349 SEPARATE_BL2_NOLOAD_REGION \
1350 SEPARATE_NOBITS_REGION \
1351 RECLAIM_INIT_CODE \
1352 SPD_${SPD} \
1353 SPIN_ON_BL1_EXIT \
1354 SPM_MM \
1355 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001356 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001357 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001358 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001359 TRUSTED_BOARD_BOOT \
1360 CRYPTO_SUPPORT \
1361 TRNG_SUPPORT \
1362 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001363 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001364 USE_COHERENT_MEM \
1365 USE_DEBUGFS \
1366 ARM_IO_IN_DTB \
1367 SDEI_IN_FCONF \
1368 SEC_INT_DESC_IN_FCONF \
1369 USE_ROMLIB \
1370 USE_TBBR_DEFS \
1371 WARMBOOT_ENABLE_DCACHE_EARLY \
1372 RESET_TO_BL2 \
1373 BL2_RUNS_AT_EL3 \
1374 BL2_IN_XIP_MEM \
1375 BL2_INV_DCACHE \
1376 USE_SPINLOCK_CAS \
1377 ERRATA_SPECULATIVE_AT \
1378 RAS_TRAP_NS_ERR_REC_ACCESS \
1379 COT_DESC_IN_DTB \
1380 USE_SP804_TIMER \
1381 ENABLE_FEAT_RNG \
1382 ENABLE_FEAT_RNG_TRAP \
1383 ENABLE_FEAT_SB \
1384 ENABLE_FEAT_DIT \
1385 NR_OF_FW_BANKS \
1386 NR_OF_IMAGES_IN_FW_BANK \
1387 PSA_FWU_SUPPORT \
1388 ENABLE_BRBE_FOR_NS \
1389 ENABLE_TRBE_FOR_NS \
1390 ENABLE_SYS_REG_TRACE_FOR_NS \
1391 ENABLE_TRF_FOR_NS \
1392 ENABLE_FEAT_HCX \
1393 ENABLE_MPMM \
1394 ENABLE_MPMM_FCONF \
1395 ENABLE_FEAT_FGT \
1396 ENABLE_FEAT_ECV \
1397 ENABLE_FEAT_AMUv1p1 \
1398 ENABLE_FEAT_SEL2 \
1399 ENABLE_FEAT_VHE \
1400 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001401 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001402 ENABLE_FEAT_PAN \
1403 ENABLE_FEAT_TCR2 \
1404 ENABLE_FEAT_S2PIE \
1405 ENABLE_FEAT_S1PIE \
1406 ENABLE_FEAT_S2POE \
1407 ENABLE_FEAT_S1POE \
1408 ENABLE_FEAT_GCS \
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06001409 ENABLE_FEAT_MTE \
Govindraj Rajad7b63ac2024-01-26 10:08:37 -06001410 ENABLE_FEAT_MTE2 \
Maksims Svecovsdf4ad842023-03-24 13:05:09 +00001411 ENABLE_FEAT_MTE_PERM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001412 FEATURE_DETECTION \
1413 TWED_DELAY \
1414 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001415 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001416 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001417 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001418 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001419 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001420 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001421 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001422 PLATFORM_REPORT_CTX_MEM_USE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001423)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001424
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001425ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1426ifeq (${DEBUG}, 0)
1427 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1428 override PLATFORM_REPORT_CTX_MEM_USE := 0
1429endif
1430endif
1431
Justin Chadwell83e04882019-08-20 11:01:52 +01001432ifeq (${SANITIZE_UB},trap)
1433 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001434endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001435
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001436# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1437ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001438 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1439else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001440# Define the PRELOADED_BL33_BASE flag only if it is provided and
1441# EL3_PAYLOAD_BASE is not defined, as it has priority.
1442 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001443 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001444 endif
1445endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001446
Soby Mathew9fe88042018-03-26 12:43:37 +01001447# Define the DYN_DISABLE_AUTH flag only if set.
1448ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001449 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001450endif
1451
Varun Wadekar4d034c52019-01-11 14:47:48 -08001452ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001453 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001454endif
1455
Manish Pandey3f90ad72020-01-14 11:52:05 +00001456# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001457ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001458ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001459 -include $(BUILD_PLAT)/sp_gen.mk
1460 FIP_DEPS += sp
1461 CRT_DEPS += sp
1462 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001463else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001464 ifeq (${SPMD_SPM_AT_SEL2},1)
1465 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1466 endif
1467endif #(SP_LAYOUT_FILE)
1468endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001469
Juan Castilloa3487d12015-08-18 14:23:04 +01001470################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001471# Build targets
1472################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001473
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301474.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
Juan Castilloa3487d12015-08-18 14:23:04 +01001475.SUFFIXES:
Achin Gupta4f6ad662013-10-25 09:08:21 +01001476
Juan Castilloa3487d12015-08-18 14:23:04 +01001477all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001478
Juan Castilloa3487d12015-08-18 14:23:04 +01001479msg_start:
1480 @echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001481
Soby Mathew18a62042015-10-26 14:29:21 +00001482ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001483# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekar4d034c52019-01-11 14:47:48 -08001484ifneq ($(findstring clang,$(notdir $(CC))),)
1485 CPPFLAGS += -Wno-error=deprecated-declarations
1486else
Dan Handley6fa89a22018-02-27 16:03:58 +00001487 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001488endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001489endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001490
Roberto Vargase92111a2018-05-22 16:05:42 +01001491$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001492$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001493
Juan Castilloa3487d12015-08-18 14:23:04 +01001494# Expand build macros for the different images
1495ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001496BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001497$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001498endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001499
Juan Castilloa3487d12015-08-18 14:23:04 +01001500ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001501
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001502ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001503FIP_BL2_ARGS := tb-fw
1504endif
1505
Chris Kayfb3b0512021-09-28 15:44:37 +01001506BL2_SOURCES := $(sort ${BL2_SOURCES})
1507
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001508$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001509 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001510
1511endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001512
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001513ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001514$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001515endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001516
Juan Castilloa3487d12015-08-18 14:23:04 +01001517ifeq (${NEED_BL31},yes)
1518BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001519# Sort BL31 source files to remove duplicates
1520BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301521ifneq (${DECRYPTION_SUPPORT},none)
1522$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001523 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301524else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001525$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001526 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001527endif #(DECRYPTION_SUPPORT)
1528endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001529
Juan Castillo671b8db2015-11-12 10:59:26 +00001530# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001531# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001532# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001533ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001534# Sort BL32 source files to remove duplicates
1535BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001536BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1537
Sumit Gargeec52442019-11-14 16:33:45 +05301538ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001539$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301540 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1541else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001542$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001543 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001544endif #(DECRYPTION_SUPPORT)
1545endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001546
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001547# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1548# needs to be built from RMM_SOURCES.
1549ifeq (${NEED_RMM},yes)
1550# Sort RMM source files to remove duplicates
1551RMM_SOURCES := $(sort ${RMM_SOURCES})
1552BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1553
1554$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001555 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1556endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001557
Juan Castilloa3487d12015-08-18 14:23:04 +01001558# Add the BL33 image if required by the platform
1559ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001560$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001561endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001562
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001563ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001564$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001565 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001566endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001567
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001568# Expand build macros for the different images
1569ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001570 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001571endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001572
Manish Pandey3f90ad72020-01-14 11:52:05 +00001573# Add Secure Partition packages
1574ifeq (${NEED_SP_PKG},yes)
Olivier Deprezf5033072024-01-26 12:05:36 +01001575$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1576 @${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001577sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001578 @${ECHO_BLANK_LINE}
1579 @echo "Built SP Images successfully"
1580 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001581endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001582
Ian Spray36eaaf32014-01-30 17:25:28 +00001583locate-checkpatch:
1584ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001585 $(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 +00001586else
1587ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001588 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001589endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001590endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001591
Achin Gupta4f6ad662013-10-25 09:08:21 +01001592clean:
Juan Castilloa3487d12015-08-18 14:23:04 +01001593 @echo " CLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001594 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001595ifdef UNIX_MK
Juan Castilloa3487d12015-08-18 14:23:04 +01001596 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001597else
1598# Clear the MAKEFLAGS as we do not want
1599# to pass the gnumake flags to nmake.
1600 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001601endif #(UNIX_MK)
Juan Castilloa3487d12015-08-18 14:23:04 +01001602 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301603 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargase92111a2018-05-22 16:05:42 +01001604 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001605
James Morrisseyeaaeece2013-11-01 13:56:59 +00001606realclean distclean:
Juan Castilloa3487d12015-08-18 14:23:04 +01001607 @echo " REALCLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001608 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1609 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001610ifdef UNIX_MK
Juan Castilloa3487d12015-08-18 14:23:04 +01001611 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001612else
1613# Clear the MAKEFLAGS as we do not want
1614# to pass the gnumake flags to nmake.
1615 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001616endif #(UNIX_MK)
Nicolas Boulenguezdf612a52021-03-31 12:22:45 +02001617 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301618 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargase92111a2018-05-22 16:05:42 +01001619 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001620
Ian Spray36eaaf32014-01-30 17:25:28 +00001621checkcodebase: locate-checkpatch
Juan Castilloa3487d12015-08-18 14:23:04 +01001622 @echo " CHECKING STYLE"
Dan Handley3a355712016-06-02 18:21:02 +01001623 @if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001624 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001625 while read GIT_FILE ; \
1626 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1627 done ; \
1628 else \
1629 find . -type f -not -iwholename "*.git*" \
1630 -not -iwholename "*build*" \
1631 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001632 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001633 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001634 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001635 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1636 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001637
1638checkpatch: locate-checkpatch
Juan Castilloa3487d12015-08-18 14:23:04 +01001639 @echo " CHECKING STYLE"
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001640 @if test -n "${CHECKPATCH_OPTS}"; then \
1641 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1642 fi
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001643 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001644 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1645 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001646 printf "\n[*] Checking style of '$$commit'\n\n"; \
1647 git log --format=email "$$commit~..$$commit" \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001648 -- ${CHECK_PATHS} | \
1649 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001650 git diff --format=email "$$commit~..$$commit" \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001651 -- ${CHECK_PATHS} | \
1652 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001653 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001654
1655certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001656
Pali Rohár54ff2132020-11-24 15:38:08 +01001657${CRTTOOL}: FORCE
Lionel Debieve730bde82022-11-14 11:05:09 +01001658 ${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 Lloyd26c6cb42015-12-02 18:33:55 +00001659 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001660 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001661 @${ECHO_BLANK_LINE}
Jon Medhurst407a95c2014-02-12 15:54:48 +00001662
Juan Castillo11abdcd2014-10-21 11:30:42 +01001663ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001664certificates: ${CRT_DEPS} ${CRTTOOL}
1665 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001666 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001667 @echo "Built $@ successfully"
1668 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001669 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001670endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001671
Juan Castilloa3487d12015-08-18 14:23:04 +01001672${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001673 $(eval ${CHECK_FIP_CMD})
dp-arm4972ec52016-05-25 16:20:20 +01001674 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1675 ${Q}${FIPTOOL} info $@
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001676 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001677 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001678 @${ECHO_BLANK_LINE}
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001679
Yatharth Kochard1a93432015-10-12 12:33:47 +01001680ifneq (${GENERATE_COT},0)
1681fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1682 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001683 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001684 @echo "Built $@ successfully"
1685 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001686 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001687endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001688
1689${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001690 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm4972ec52016-05-25 16:20:20 +01001691 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1692 ${Q}${FIPTOOL} info $@
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001693 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001694 @echo "Built $@ successfully"
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001695 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001696
Juan Castilloa3487d12015-08-18 14:23:04 +01001697fiptool: ${FIPTOOL}
1698fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001699fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001700
Pali Rohár54ff2132020-11-24 15:38:08 +01001701${FIPTOOL}: FORCE
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001702ifdef UNIX_MK
Lionel Debieve730bde82022-11-14 11:05:09 +01001703 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001704else
1705# Clear the MAKEFLAGS as we do not want
1706# to pass the gnumake flags to nmake.
1707 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001708endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001709
Pali Rohár54ff2132020-11-24 15:38:08 +01001710romlib.bin: libraries FORCE
John Tsichritzisf6ea99b2019-05-21 15:47:37 +01001711 ${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 Vargase92111a2018-05-22 16:05:42 +01001712
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001713memmap: all
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001714ifdef UNIX_MK
1715 ${Q}PYTHONPATH=${CURDIR}/tools/memory \
1716 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1717else
1718 ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
1719 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1720endif
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001721
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001722doc:
1723 @echo " BUILD DOCUMENTATION"
1724 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1725
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301726enctool: ${ENCTOOL}
1727
Pali Rohár54ff2132020-11-24 15:38:08 +01001728${ENCTOOL}: FORCE
Lionel Debieve730bde82022-11-14 11:05:09 +01001729 ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301730 @${ECHO_BLANK_LINE}
1731 @echo "Built $@ successfully"
1732 @${ECHO_BLANK_LINE}
1733
Joakim Bech35fab8c2014-01-23 14:51:49 +01001734cscope:
1735 @echo " CSCOPE"
1736 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1737 ${Q}cscope -b -q -k
1738
Ryan Harkin72ee3312014-01-15 16:55:07 +00001739help:
John Tsichritzis0c4dded2019-05-21 15:57:31 +01001740 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001741 @echo ""
1742 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleuxa08588a2014-03-21 13:16:35 +00001743 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001744 @echo ""
John Tsichritzis0c4dded2019-05-21 15:57:31 +01001745 @echo "platform = ${PLATFORM_LIST}"
1746 @echo ""
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001747 @echo "Please refer to the User Guide for a list of all supported options."
1748 @echo "Note that the build system doesn't track dependencies for build "
1749 @echo "options. Therefore, if any of the build options are changed "
1750 @echo "from a previous build, a clean build must be performed."
1751 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001752 @echo "Supported Targets:"
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001753 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001754 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001755 @echo " bl2 Build the BL2 binary"
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001756 @echo " bl2u Build the BL2U binary"
Juan Castillo7d199412015-12-14 09:35:25 +00001757 @echo " bl31 Build the BL31 binary"
Soby Mathewa1941252016-05-05 14:33:33 +01001758 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1759 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castilloa3487d12015-08-18 14:23:04 +01001760 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001761 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochard1a93432015-10-12 12:33:47 +01001762 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001763 @echo " checkcodebase Check the coding style of the entire source tree"
1764 @echo " checkpatch Check the coding style on changes in the current"
1765 @echo " branch against BASE_COMMIT (default origin/master)"
1766 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001767 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001768 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001769 @echo " certtool Build the Certificate generation tool"
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301770 @echo " enctool Build the Firmware encryption tool"
Andreas Färberec82cfb2016-10-10 05:18:49 +02001771 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandey3f90ad72020-01-14 11:52:05 +00001772 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaza830a4d2018-11-27 14:58:04 +00001773 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathewab4181d2017-12-14 17:44:56 +00001774 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001775 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001776 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001777 @echo ""
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001778 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001779 @echo ""
1780 @echo "example: build all targets for the FVP platform:"
1781 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001782
1783.PHONY: FORCE
1784FORCE:;