blob: 2967195c31f479f59309c7b8a4433716335a4610 [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 Gautier9a17e242023-10-04 18:59:44 +020012VERSION_PATCH := 0 # Only used for LTS releases
Yann Gautier57078a92023-10-03 11:09:07 +020013VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
Juan Castillo04be3a52014-06-30 11:41:46 +010014
Juan Castillo396644b2015-10-22 11:34:44 +010015# Default goal is build all images
16.DEFAULT_GOAL := all
17
Douglas Raillard527cd902016-12-28 14:47:50 +000018# Avoid any implicit propagation of command line variable definitions to
19# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
20# usage. Other command line options like "-s" are still propagated as usual.
21MAKEOVERRIDES =
22
Evan Lloydf2697142015-12-02 18:17:37 +000023MAKE_HELPERS_DIRECTORY := make_helpers/
24include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000025include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010026
27################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010028# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010029################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010030
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010031include ${MAKE_HELPERS_DIRECTORY}defaults.mk
dp-arm3cac7862016-09-19 11:18:44 +010032
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010033# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010034ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010035ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
36PLAT := ${DEFAULT_PLAT}
Achin Gupta4f6ad662013-10-25 09:08:21 +010037
Juan Castilloa3487d12015-08-18 14:23:04 +010038################################################################################
39# Checkpatch script options
40################################################################################
41
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010042CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010043# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030044INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
45 include/drivers/arm, \
46 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010047INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010048 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010049 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010050 $(wildcard include/lib/*)))
51INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030052 include/lib \
53 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010054 $(wildcard include/*)))
55LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010056 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000057 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010058 lib/libc, \
Daniel Boulby958f1dd2022-10-05 11:05:22 +010059 lib/zlib \
Dan Handleyd7b59e42016-06-02 17:15:13 +010060 $(wildcard lib/*)))
61ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
62 lib \
63 include \
64 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000065 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010066 $(wildcard *)))
67CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
68 ${INC_DIRS_TO_CHECK} \
69 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030070 ${LIB_DIRS_TO_CHECK} \
71 ${INC_DRV_DIRS_TO_CHECK} \
72 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000073
Juan Castilloa3487d12015-08-18 14:23:04 +010074################################################################################
75# Process build options
76################################################################################
77
78# Verbose flag
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010079ifeq (${V},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010080 Q:=@
81 ECHO:=@echo
82 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010083else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010084 Q:=
85 ECHO:=$(ECHO_QUIET)
Andre Przywaracf2bb082018-09-27 10:56:05 +010086endif
87
88ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010089 Q:=@
90 ECHO:=$(ECHO_QUIET)
Achin Gupta4f6ad662013-10-25 09:08:21 +010091endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010092
93export Q ECHO
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000094
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +010095################################################################################
96# Toolchain
97################################################################################
98
99HOSTCC := gcc
100export HOSTCC
101
102CC := ${CROSS_COMPILE}gcc
Chris Kayc7ea3472024-01-15 18:45:07 +0000103CPP := ${CROSS_COMPILE}gcc -E
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100104AS := ${CROSS_COMPILE}gcc
Chris Kayfdb6f422024-01-15 19:55:11 +0000105AR := ${CROSS_COMPILE}gcc-ar
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100106LINKER := ${CROSS_COMPILE}ld
107OC := ${CROSS_COMPILE}objcopy
108OD := ${CROSS_COMPILE}objdump
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100109DTC := dtc
110
111# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
112ifneq ($(strip $(wildcard ${LD}.bfd) \
113 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
114LINKER := ${LINKER}.bfd
Juan Castilloa3487d12015-08-18 14:23:04 +0100115endif
116
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100117################################################################################
118# Auxiliary tools (fiptool, cert_create, etc)
119################################################################################
120
121# Variables for use with Certificate Generation Tool
122CRTTOOLPATH ?= tools/cert_create
123CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
124
125# Variables for use with Firmware Encryption Tool
126ENCTOOLPATH ?= tools/encrypt_fw
127ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
128
129# Variables for use with Firmware Image Package
130FIPTOOLPATH ?= tools/fiptool
131FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
132
133# Variables for use with sptool
134SPTOOLPATH ?= tools/sptool
135SPTOOL ?= ${SPTOOLPATH}/sptool.py
136SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Karl Meakinaba46182023-02-14 11:56:02 +0000137SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100138
139# Variables for use with ROMLIB
140ROMLIBPATH ?= lib/romlib
141
142# Variable for use with Python
143PYTHON ?= python3
144
145# Variables for use with documentation build using Sphinx tool
146DOCS_PATH ?= docs
147
148################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100149# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags
Juan Castilloa3487d12015-08-18 14:23:04 +0100150################################################################################
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100151ifeq (${ARM_ARCH_MAJOR},7)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100152 target32-directive = -target arm-none-eabi
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500153# Will set march-directive from platform configuration
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100154else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100155 target32-directive = -target armv8a-none-eabi
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100156endif #(ARM_ARCH_MAJOR)
157
158################################################################################
159# Get Architecture Feature Modifiers
160################################################################################
161arch-features = ${ARM_ARCH_FEATURE}
162
originfba80d82022-01-19 16:30:14 +0000163ifneq ($(findstring clang,$(notdir $(CC))),)
164 ifneq ($(findstring armclang,$(notdir $(CC))),)
Govindraj Raja69096412023-06-01 16:29:16 -0500165 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi
166 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi
originfba80d82022-01-19 16:30:14 +0000167 LD := $(LINKER)
168 else
Govindraj Raja69096412023-06-01 16:29:16 -0500169 TF_CFLAGS_aarch32 = $(target32-directive)
170 TF_CFLAGS_aarch64 := -target aarch64-elf
originfba80d82022-01-19 16:30:14 +0000171 LD := $(shell $(CC) --print-prog-name ld.lld)
172
173 AR := $(shell $(CC) --print-prog-name llvm-ar)
174 OD := $(shell $(CC) --print-prog-name llvm-objdump)
175 OC := $(shell $(CC) --print-prog-name llvm-objcopy)
176 endif
177
178 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
originfba80d82022-01-19 16:30:14 +0000179 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
zelalem-aweked5f45272019-11-12 16:20:17 -0600180else ifneq ($(findstring gcc,$(notdir $(CC))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100181 ifeq ($(ENABLE_LTO),1)
182 # Enable LTO only for aarch64
183 ifeq (${ARCH},aarch64)
184 LTO_CFLAGS = -flto
185 # Use gcc as a wrapper for the ld, recommended for LTO
186 LINKER := ${CROSS_COMPILE}gcc
187 endif
zelalem-aweked5f45272019-11-12 16:20:17 -0600188 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100189 LD = $(LINKER)
dp-arm320e8442017-05-02 12:00:08 +0100190else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100191 LD = $(LINKER)
192endif #(clang)
dp-arm320e8442017-05-02 12:00:08 +0100193
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100194# Process Debug flag
195$(eval $(call add_define,DEBUG))
196ifneq (${DEBUG}, 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100197 BUILD_TYPE := debug
198 TF_CFLAGS += -g -gdwarf-4
199 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100200
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100201 # Use LOG_LEVEL_INFO by default for debug builds
202 LOG_LEVEL := 40
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100203else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100204 BUILD_TYPE := release
205 # Use LOG_LEVEL_NOTICE by default for release builds
206 LOG_LEVEL := 20
207endif #(Debug)
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100208
Peiyuan Song44f8f472020-04-25 16:53:43 +0800209# Default build string (git branch and commit)
210ifeq (${BUILD_STRING},)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100211 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
Peiyuan Song44f8f472020-04-25 16:53:43 +0800212endif
laurenw-arme954f652022-07-12 10:12:05 -0500213VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800214
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100215ifeq (${AARCH32_INSTRUCTION_SET},A32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100216 TF_CFLAGS_aarch32 += -marm
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100217else ifeq (${AARCH32_INSTRUCTION_SET},T32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100218 TF_CFLAGS_aarch32 += -mthumb
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100219else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100220 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
221endif #(AARCH32_INSTRUCTION_SET)
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100222
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200223TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100224TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100225
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100226##############################################################################
227# WARNINGS Configuration
228###############################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100229# General warnings
230WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200231 -Wdisabled-optimization -Wvla -Wshadow \
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000232 -Wredundant-decls
233# stricter warnings
234WARNINGS += -Wextra -Wno-trigraphs
235# too verbose for generic build
236WARNINGS += -Wno-missing-field-initializers \
237 -Wno-type-limits -Wno-sign-compare \
238# on clang this flag gets reset if -Wextra is set after it. No difference on gcc
239WARNINGS += -Wno-unused-parameter
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100240
241# Additional warnings
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000242# Level 1 - infrequent warnings we should have none of
243# full -Wextra
244WARNING1 += -Wsign-compare
245WARNING1 += -Wtype-limits
246WARNING1 += -Wmissing-field-initializers
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100247
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000248# Level 2 - problematic warnings that we want
249# zlib, compiler-rt, coreboot, and mbdedtls blow up with these
250# TODO: disable just for them and move into default build
251WARNING2 += -Wold-style-definition
252WARNING2 += -Wmissing-prototypes
253WARNING2 += -Wmissing-format-attribute
254# TF-A aims to comply with this eventually. Effort too large at present
255WARNING2 += -Wundef
Boyan Karatotev9c6ba592022-11-21 14:49:05 +0000256# currently very involved and many platforms set this off
257WARNING2 += -Wunused-const-variable=2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100258
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000259# Level 3 - very pedantic, frequently ignored
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100260WARNING3 := -Wbad-function-cast
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000261WARNING3 += -Waggregate-return
262WARNING3 += -Wnested-externs
263WARNING3 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100264WARNING3 += -Wcast-qual
265WARNING3 += -Wconversion
266WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100267WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100268WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100269
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000270# Setting W is quite verbose and most warnings will be pre-existing issues
271# outside of the contributor's control. Don't fail the build on them so warnings
272# can be seen and hopefully addressed
273ifdef W
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100274 ifneq (${W},0)
275 E ?= 0
276 endif
Boyan Karatotevde4240f2022-11-21 14:16:43 +0000277endif
278
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100279ifeq (${W},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100280 WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100281else ifeq (${W},2)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100282 WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100283else ifeq (${W},3)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100284 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
285endif #(W)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100286
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100287# Compiler specific warnings
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100288ifeq ($(findstring clang,$(notdir $(CC))),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100289# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100290WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
291 -Wpacked-bitfield-compat -Wshift-overflow=2 \
292 -Wlogical-op
Govindraj Rajaaa8ef3f2023-05-05 09:09:36 -0500293
294# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
295TF_CFLAGS += $(call cc_option, --param=min-pagesize=0)
296
Bipin Ravie53e6ae2023-09-28 13:17:24 -0500297ifeq ($(HARDEN_SLS), 1)
298 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all)
299endif
300
Justin Chadwell7a914232019-07-03 14:15:56 +0100301else
302# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100303WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
304 -Wlogical-op-parentheses
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100305endif #(Clang Warning)
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100306
Yann Gautier957c3532018-12-10 18:08:53 +0100307ifneq (${E},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100308 ERRORS := -Werror
309endif #(E)
Yann Gautier957c3532018-12-10 18:08:53 +0100310
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100311################################################################################
312# Compiler and Linker Directives
313################################################################################
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100314CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
315 $(ERRORS) $(WARNINGS)
Govindraj Rajacd10c6e2023-05-30 16:52:15 -0500316ASFLAGS += $(CPPFLAGS) \
Julius Werner53456fc2019-07-09 13:49:11 -0700317 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900318TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500319 -ffunction-sections -fdata-sections \
320 -ffreestanding -fno-builtin -fno-common \
321 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100322
Justin Chadwell83e04882019-08-20 11:01:52 +0100323ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100324 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
325endif #(${SANITIZE_UB},on)
326
Justin Chadwell83e04882019-08-20 11:01:52 +0100327ifeq (${SANITIZE_UB},trap)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100328 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
Justin Chadwell83e04882019-08-20 11:01:52 +0100329 -fsanitize-undefined-trap-on-error
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100330endif #(${SANITIZE_UB},trap)
Justin Chadwell83e04882019-08-20 11:01:52 +0100331
david cunado34ab6092017-11-30 21:58:01 +0000332GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
david cunado34ab6092017-11-30 21:58:01 +0000333
Marco Felsch24ad8402022-11-09 12:59:09 +0100334TF_LDFLAGS += -z noexecstack
335
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100336# LD = armlink
Varun Wadekar4d034c52019-01-11 14:47:48 -0800337ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100338 TF_LDFLAGS += --diag_error=warning --lto_level=O1
339 TF_LDFLAGS += --remove --info=unused,unusedsymbols
340 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100341
342# LD = gcc (used when GCC LTO is enabled)
zelalem-aweked5f45272019-11-12 16:20:17 -0600343else ifneq ($(findstring gcc,$(notdir $(LD))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100344 # Pass ld options with Wl or Xlinker switches
Chris Kayb0fe96f2024-01-16 11:53:35 +0000345 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100346 TF_LDFLAGS += -Wl,--fatal-warnings -O1
347 TF_LDFLAGS += -Wl,--gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000348
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100349 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants
350 TF_LDFLAGS += -Wl,-z,max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300351 TF_LDFLAGS += -Wl,--build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000352
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100353 ifeq ($(ENABLE_LTO),1)
354 ifeq (${ARCH},aarch64)
355 TF_LDFLAGS += -flto -fuse-linker-plugin
356 endif
357 endif #(ENABLE_LTO)
358
zelalem-aweked5f45272019-11-12 16:20:17 -0600359# GCC automatically adds fix-cortex-a53-843419 flag when used to link
360# which breaks some builds, so disable if errata fix is not explicitly enabled
Yann Gautier3d73d162023-03-15 16:18:16 +0100361 ifeq (${ARCH},aarch64)
362 ifneq (${ERRATA_A53_843419},1)
363 TF_LDFLAGS += -mno-fix-cortex-a53-843419
364 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100365 endif
366 TF_LDFLAGS += -nostdlib
367 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100368
369# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800370else
Marco Felsch24ad8402022-11-09 12:59:09 +0100371# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we
372# are not loaded by a elf loader.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100373 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
374 TF_LDFLAGS += -O1
375 TF_LDFLAGS += --gc-sections
Chris Kay73b1f402022-12-22 13:26:37 +0000376
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100377 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
378 TF_LDFLAGS += -z max-page-size=4096
Andrey Skvortsove2ebb722023-09-05 23:06:29 +0300379 TF_LDFLAGS += --build-id=none
Chris Kay73b1f402022-12-22 13:26:37 +0000380
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100381# ld.lld doesn't recognize the errata flags,
Yabin Cuied7dc512023-01-19 20:06:04 +0000382# therefore don't add those in that case.
383# ld.lld reports section type mismatch warnings,
384# therefore don't add --fatal-warnings to it.
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100385 ifeq ($(findstring ld.lld,$(notdir $(LD))),)
386 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
387 endif
388
389endif #(LD = armlink)
Juan Castilloa3487d12015-08-18 14:23:04 +0100390
391################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500392# Setup ARCH_MAJOR/MINOR before parsing arch_features.
393################################################################################
394ifeq (${ENABLE_RME},1)
395 ARM_ARCH_MAJOR := 8
396 ARM_ARCH_MINOR := 6
397endif
398
399################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100400# Common sources and include directories
401################################################################################
dp-arme3cc8382017-05-04 12:15:35 +0100402include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100403
404BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100405 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100406 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800407 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100408 lib/${ARCH}/cache_helpers.S \
409 lib/${ARCH}/misc_helpers.S \
Boyan Karatotev05504ba2023-02-15 13:21:50 +0000410 lib/extensions/pmuv3/${ARCH}/pmuv3.c \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000411 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100412 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000413 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100414 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100415 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000416
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100417ifeq ($(notdir $(CC)),armclang)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100418 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100419endif
420
Justin Chadwell83e04882019-08-20 11:01:52 +0100421ifeq (${SANITIZE_UB},on)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100422 BL_COMMON_SOURCES += plat/common/ubsan.c
Justin Chadwell83e04882019-08-20 11:01:52 +0100423endif
424
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200425INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000426 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000427 -Iinclude/lib/cpus/${ARCH} \
428 -Iinclude/lib/el3_runtime/${ARCH} \
429 ${PLAT_INCLUDES} \
430 ${SPD_INCLUDES}
431
Nishant Sharma331b5682022-08-15 16:37:07 +0100432DTC_FLAGS += -I dts -O dtb
433DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \
434 -x assembler-with-cpp $(DEFINES)
435
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000436include common/backtrace/backtrace.mk
437
Juan Castilloa3487d12015-08-18 14:23:04 +0100438################################################################################
Govindraj Raja1a211292023-09-20 14:32:24 -0500439# Generic definitions
440################################################################################
441include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
442
443ifeq (${BUILD_BASE},)
444 BUILD_BASE := ./build
445endif
446BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
447
448SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
449
450# Platforms providing their own TBB makefile may override this value
451INCLUDE_TBBR_MK := 1
452
453################################################################################
454# Include SPD Makefile if one has been specified
455################################################################################
456
457ifneq (${SPD},none)
458 ifeq (${ARCH},aarch32)
459 $(error "Error: SPD is incompatible with AArch32.")
460 endif
461
462 ifdef EL3_PAYLOAD_BASE
463 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
464 $(warning "The SPD and its BL32 companion will be present but \
465 ignored.")
466 endif
467
468 ifeq (${SPD},spmd)
469 # SPMD is located in std_svc directory
470 SPD_DIR := std_svc
471
472 ifeq ($(SPMD_SPM_AT_SEL2),1)
473 CTX_INCLUDE_EL2_REGS := 1
474 ifeq ($(SPMC_AT_EL3),1)
475 $(error SPM cannot be enabled in both S-EL2 and EL3.)
476 endif
477 endif
478
479 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
480 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
481 endif
482
483 ifeq ($(TS_SP_FW_CONFIG),1)
484 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
485 endif
486
487 ifneq ($(ARM_BL2_SP_LIST_DTS),)
488 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
489 endif
490
491 ifneq ($(SP_LAYOUT_FILE),)
492 BL2_ENABLE_SP_LOAD := 1
493 endif
Govindraj Rajabad835a2023-10-31 14:48:11 -0500494
495 ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
496 ifneq ($(SPMC_AT_EL3),1)
497 $(error SEL0 SP cannot be enabled without SPMC at EL3)
498 endif
499 endif
Govindraj Raja1a211292023-09-20 14:32:24 -0500500 else
501 # All other SPDs in spd directory
502 SPD_DIR := spd
503 endif #(SPD)
504
505 # We expect to locate an spd.mk under the specified SPD directory
506 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
507
508 ifeq (${SPD_MAKE},)
509 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
510 endif
511 $(info Including ${SPD_MAKE})
512 include ${SPD_MAKE}
513
514 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
515 # Makefile would set NEED_BL32 to "yes". In this case, the build system
516 # supports two mutually exclusive options:
517 # * BL32 is built from source: then BL32_SOURCES must contain the list
518 # of source files to build BL32
519 # * BL32 is a prebuilt binary: then BL32 must point to the image file
520 # that will be included in the FIP
521 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
522 # over the sources.
523endif #(SPD=none)
524
525ifeq (${ENABLE_SPMD_LP}, 1)
526ifneq (${SPD},spmd)
527 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
528endif
529ifeq ($(SPMC_AT_EL3),1)
530 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
531endif
532endif
533
534################################################################################
Govindraj Raja0386e312023-08-17 10:41:48 -0500535# Process BRANCH_PROTECTION value and set
536# Pointer Authentication and Branch Target Identification flags
537################################################################################
538ifeq (${BRANCH_PROTECTION},0)
539 # Default value turns off all types of branch protection
540 BP_OPTION := none
541else ifneq (${ARCH},aarch64)
542 $(error BRANCH_PROTECTION requires AArch64)
543else ifeq (${BRANCH_PROTECTION},1)
544 # Enables all types of branch protection features
545 BP_OPTION := standard
546 ENABLE_BTI := 1
547 ENABLE_PAUTH := 1
548else ifeq (${BRANCH_PROTECTION},2)
549 # Return address signing to its standard level
550 BP_OPTION := pac-ret
551 ENABLE_PAUTH := 1
552else ifeq (${BRANCH_PROTECTION},3)
553 # Extend the signing to include leaf functions
554 BP_OPTION := pac-ret+leaf
555 ENABLE_PAUTH := 1
556else ifeq (${BRANCH_PROTECTION},4)
557 # Turn on branch target identification mechanism
558 BP_OPTION := bti
559 ENABLE_BTI := 1
560else
561 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
562endif #(BRANCH_PROTECTION)
563
564ifeq ($(ENABLE_PAUTH),1)
565 CTX_INCLUDE_PAUTH_REGS := 1
566endif
567ifneq (${BP_OPTION},none)
568 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
569endif #(BP_OPTION)
570
571# Pointer Authentication sources
572ifeq (${ENABLE_PAUTH}, 1)
573# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the
574# Pauth support. As it's not secure, it must be reimplemented for real platforms
575 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S
576endif
577
Govindraj Raja1a211292023-09-20 14:32:24 -0500578################################################################################
579# Include the platform specific Makefile after the SPD Makefile (the platform
580# makefile may use all previous definitions in this file)
581################################################################################
582include ${PLAT_MAKEFILE_FULL}
583
584################################################################################
585# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from
586# platform.
587################################################################################
588include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
589
Govindraj Raja0386e312023-08-17 10:41:48 -0500590####################################################
591# Enable required options for Memory Stack Tagging.
592####################################################
593
594# Currently, these options are enabled only for clang and armclang compiler.
595ifeq (${SUPPORT_STACK_MEMTAG},yes)
596 ifdef mem_tag_arch_support
597 # Check for armclang and clang compilers
598 ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
599 # Add "memtag" architecture feature modifier if not specified
600 ifeq ( ,$(findstring memtag,$(arch-features)))
601 arch-features := $(arch-features)+memtag
602 endif # memtag
603 ifeq ($(notdir $(CC)),armclang)
604 TF_CFLAGS += -mmemtag-stack
605 else ifeq ($(notdir $(CC)),clang)
606 TF_CFLAGS += -fsanitize=memtag
607 endif # armclang
608 endif
609 else
610 $(error "Error: stack memory tagging is not supported for \
611 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
612 endif #(mem_tag_arch_support)
613endif #(SUPPORT_STACK_MEMTAG)
614
615################################################################################
616# RME dependent flags configuration, Enable optional features for RME.
617################################################################################
618# FEAT_RME
619ifeq (${ENABLE_RME},1)
Govindraj Raja60f52662023-10-12 16:57:46 -0500620 # RME doesn't support BRBE
621 ENABLE_BRBE_FOR_NS := 0
622
Govindraj Raja0386e312023-08-17 10:41:48 -0500623 # RME doesn't support PIE
624 ifneq (${ENABLE_PIE},0)
625 $(error ENABLE_RME does not support PIE)
626 endif
627
628 # RME doesn't support BRBE
629 ifneq (${ENABLE_BRBE_FOR_NS},0)
630 $(error ENABLE_RME does not support BRBE.)
631 endif
632
633 # RME requires AARCH64
634 ifneq (${ARCH},aarch64)
635 $(error ENABLE_RME requires AArch64)
636 endif
637
638 # RME requires el2 context to be saved for now.
639 CTX_INCLUDE_EL2_REGS := 1
640 CTX_INCLUDE_AARCH32_REGS := 0
641 CTX_INCLUDE_PAUTH_REGS := 1
642
643 # RME enables CSV2_2 extension by default.
644 ENABLE_FEAT_CSV2_2 = 1
645endif #(FEAT_RME)
646
647################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500648# Include rmmd Makefile if RME is enabled
649################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500650ifneq (${ENABLE_RME},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100651 ifneq (${ARCH},aarch64)
652 $(error ENABLE_RME requires AArch64)
653 endif
654 ifeq ($(SPMC_AT_EL3),1)
655 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
656 endif
657
658 ifneq (${SPD}, none)
659 ifneq (${SPD}, spmd)
660 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
661 endif
662 endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500663include services/std_svc/rmmd/rmmd.mk
664$(warning "RME is an experimental feature")
665endif
666
Govindraj Raja1a211292023-09-20 14:32:24 -0500667ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
668 ifeq (${SPD},none)
669 ifeq (${ENABLE_RME},0)
670 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
671 or RME is enabled)
672 endif
673 endif
674endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000675
Govindraj Raja69096412023-06-01 16:29:16 -0500676################################################################################
677# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come
678# up with appropriate march values for compiler.
679################################################################################
680include ${MAKE_HELPERS_DIRECTORY}march.mk
681
682TF_CFLAGS += $(march-directive)
Govindraj Raja0c572472024-01-23 16:00:19 -0600683ASFLAGS += $(march-directive)
Govindraj Raja69096412023-06-01 16:29:16 -0500684
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600685# This internal flag is common option which is set to 1 for scenarios
686# when the BL2 is running in EL3 level. This occurs in two scenarios -
687# 4 world system running BL2 at EL3 and two world system without BL1 running
688# BL2 in EL3
689
690ifeq (${RESET_TO_BL2},1)
691 BL2_RUNS_AT_EL3 := 1
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100692 ifeq (${ENABLE_RME},1)
693 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \
694 supported at the moment.)
695 endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600696else ifeq (${ENABLE_RME},1)
697 BL2_RUNS_AT_EL3 := 1
698else
699 BL2_RUNS_AT_EL3 := 0
700endif
701
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100702# This internal flag is set to 1 when Firmware First handling of External aborts
703# is required by lowe ELs. Currently only NS requires this support.
704ifeq ($(HANDLE_EA_EL3_FIRST_NS),1)
705 FFH_SUPPORT := 1
706else
707 FFH_SUPPORT := 0
708endif
709
Masahiro Yamadae2395b42017-11-04 03:12:28 +0900710$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
711
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100712ifeq (${ARM_ARCH_MAJOR},7)
713include make_helpers/armv7-a-cpus.mk
714endif
715
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900716PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
717ifneq ($(PIE_FOUND),)
718 TF_CFLAGS += -fno-PIE
Samuel Holland9286c022022-04-08 21:56:02 -0500719ifneq ($(findstring gcc,$(notdir $(LD))),)
720 TF_LDFLAGS += -no-pie
721endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100722endif #(PIE_FOUND)
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900723
724ifneq ($(findstring gcc,$(notdir $(LD))),)
725 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100726else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900727 PIE_LDFLAGS += -pie --no-dynamic-linker
728endif
729
730ifeq ($(ENABLE_PIE),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100731 ifeq ($(RESET_TO_BL2),1)
732 ifneq ($(BL2_IN_XIP_MEM),1)
733 BL2_CPPFLAGS += -fpie
734 BL2_CFLAGS += -fpie
735 BL2_LDFLAGS += $(PIE_LDFLAGS)
736 endif #(BL2_IN_XIP_MEM)
737 endif #(RESET_TO_BL2)
Chris Kay13886c82023-02-02 14:39:03 +0000738 BL31_CPPFLAGS += -fpie
739 BL31_CFLAGS += -fpie
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900740 BL31_LDFLAGS += $(PIE_LDFLAGS)
Chris Kay13886c82023-02-02 14:39:03 +0000741
742 BL32_CPPFLAGS += -fpie
Masahiro Yamadade634f82020-01-17 13:45:14 +0900743 BL32_CFLAGS += -fpie
744 BL32_LDFLAGS += $(PIE_LDFLAGS)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100745endif #(ENABLE_PIE)
Soby Mathew078f1a42018-08-28 11:13:55 +0100746
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000747BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
748BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
749BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG}
750
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900751BL1_CPPFLAGS += -DIMAGE_AT_EL3
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600752ifeq ($(RESET_TO_BL2),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100753 BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900754else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100755 BL2_CPPFLAGS += -DIMAGE_AT_EL1
756endif #(RESET_TO_BL2)
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000757
758ifeq (${ARCH},aarch64)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100759 BL2U_CPPFLAGS += -DIMAGE_AT_EL1
760 BL31_CPPFLAGS += -DIMAGE_AT_EL3
761 BL32_CPPFLAGS += -DIMAGE_AT_EL1
Boyan Karatoteve7d7c272023-01-25 16:55:18 +0000762else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100763 BL32_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900764endif
765
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000766# Include the CPU specific operations makefile, which provides default
767# values for all CPU errata workarounds and CPU specific optimisations.
768# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100769include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100770
dp-armcdd03cb2017-02-15 11:07:55 +0000771################################################################################
772# Build `AARCH32_SP` as BL32 image for AArch32
773################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100774ifeq (${ARCH},aarch32)
775 NEED_BL32 := yes
dp-armcdd03cb2017-02-15 11:07:55 +0000776
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100777 ifneq (${AARCH32_SP},none)
778 # We expect to locate an sp.mk under the specified AARCH32_SP directory
779 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
dp-armcdd03cb2017-02-15 11:07:55 +0000780
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100781 ifeq (${AARCH32_SP_MAKE},)
782 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
783 endif
Juan Pablo Conde6aba3b12023-08-09 13:19:21 -0500784 $(info Including ${AARCH32_SP_MAKE})
785 include ${AARCH32_SP_MAKE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100786 endif
787endif #(ARCH=aarch32)
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800788
789################################################################################
790# Include libc if not overridden
791################################################################################
792ifeq (${OVERRIDE_LIBC},0)
793include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000794endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100795
796################################################################################
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100797# Check incompatible options and dependencies
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000798################################################################################
799
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100800# USE_DEBUGFS experimental feature recommended only in debug builds
801ifeq (${USE_DEBUGFS},1)
802 ifeq (${DEBUG},1)
803 $(warning DEBUGFS experimental feature is enabled.)
804 else
805 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800806 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100807endif #(USE_DEBUGFS)
808
809# USE_SPINLOCK_CAS requires AArch64 build
810ifeq (${USE_SPINLOCK_CAS},1)
811 ifneq (${ARCH},aarch64)
812 $(error USE_SPINLOCK_CAS requires AArch64)
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800813 endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100814endif #(USE_SPINLOCK_CAS)
815
816# The cert_create tool cannot generate certificates individually, so we use the
817# target 'certificates' to create them all
818ifneq (${GENERATE_COT},0)
819 FIP_DEPS += certificates
820 FWU_FIP_DEPS += fwu_certificates
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000821endif
822
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100823ifneq (${DECRYPTION_SUPPORT},none)
824 ENC_ARGS += -f ${FW_ENC_STATUS}
825 ENC_ARGS += -k ${ENC_KEY}
826 ENC_ARGS += -n ${ENC_NONCE}
827 FIP_DEPS += enctool
828 FWU_FIP_DEPS += enctool
829endif #(DECRYPTION_SUPPORT)
830
831ifdef EL3_PAYLOAD_BASE
832 ifdef PRELOADED_BL33_BASE
833 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
834 incompatible build options. EL3_PAYLOAD_BASE has priority.")
835 endif
836 ifneq (${GENERATE_COT},0)
837 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
838 build options.")
839 endif
840 ifneq (${TRUSTED_BOARD_BOOT},0)
841 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
842 incompatible \ build options.")
843 endif
844endif #(EL3_PAYLOAD_BASE)
845
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000846ifeq (${NEED_BL33},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100847 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000848 $(warning "BL33 image is not needed when option \
849 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100850 endif
851 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100852 $(warning "BL33 image is not needed when option \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100853 PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
854 endif
855endif #(NEED_BL33)
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000856
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000857# When building for systems with hardware-assisted coherency, there's no need to
858# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
859ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100860 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000861endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100862
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600863#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
864ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100865 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000866endif
867
Manish Pandeyd419e222023-02-13 12:39:17 +0000868# RAS_EXTENSION is deprecated, provide alternate build options
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100869ifeq ($(RAS_EXTENSION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100870 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +0100871 and HANDLE_EA_EL3_FIRST_NS instead")
Manish Pandeyd419e222023-02-13 12:39:17 +0000872endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100873
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100874
Manish Pandeyd419e222023-02-13 12:39:17 +0000875# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000876ifeq ($(FAULT_INJECTION_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100877 ifeq ($(ENABLE_FEAT_RAS),0)
878 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
879 endif
880endif #(FAULT_INJECTION_SUPPORT)
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000881
Roberto Vargas025946a2018-09-24 17:20:48 +0100882# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100883ifeq ($(DYN_DISABLE_AUTH), 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100884 ifeq (${TRUSTED_BOARD_BOOT}, 0)
885 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
886 to be set.")
887 endif
888endif #(DYN_DISABLE_AUTH)
Soby Mathew9fe88042018-03-26 12:43:37 +0100889
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100890ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
891# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100892 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100893else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
894# Support authentication verification and hash calculation
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100895 CRYPTO_SUPPORT := 3
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100896else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
897# Support hash calculation only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100898 CRYPTO_SUPPORT := 2
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100899else ifeq (${TRUSTED_BOARD_BOOT},1)
900# Support authentication verification only
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100901 CRYPTO_SUPPORT := 1
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000902else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100903 CRYPTO_SUPPORT := 0
904endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT))
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000905
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100906# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
907ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100908 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100909endif
910
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000911# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100912# registers associated to it are also saved and restored.
913# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000914ifeq ($(ENABLE_PAUTH),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100915 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
916 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
917 endif
918endif #(ENABLE_PAUTH)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100919
920ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100921 ifneq (${ARCH},aarch64)
922 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
923 endif
924endif #(CTX_INCLUDE_PAUTH_REGS)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000925
Manish V Badarkhe99575e42021-06-25 23:28:59 +0100926ifeq ($(PSA_FWU_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100927 $(info PSA_FWU_SUPPORT is an experimental feature)
928endif #(PSA_FWU_SUPPORT)
Manish V Badarkhe99575e42021-06-25 23:28:59 +0100929
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000930ifeq ($(FEATURE_DETECTION),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100931 $(info FEATURE_DETECTION is an experimental feature)
932endif #(FEATURE_DETECTION)
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000933
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000934ifneq ($(ENABLE_SME2_FOR_NS), 0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100935 ifeq (${ENABLE_SME_FOR_NS}, 0)
936 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
937 to be set")
938 $(warning "Forced ENABLE_SME_FOR_NS=1")
939 override ENABLE_SME_FOR_NS := 1
940 endif
941endif #(ENABLE_SME2_FOR_NS)
Jayanth Dodderi Chidanand605419a2023-03-06 23:56:14 +0000942
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000943ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100944 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
945 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
946 library v2")
947 endif
948endif #(ARM_XLAT_TABLES_LIB_V1)
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000949
Sumit Garg392e4df2019-11-15 10:43:00 +0530950ifneq (${DECRYPTION_SUPPORT},none)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100951 ifeq (${TRUSTED_BOARD_BOOT}, 0)
952 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
953 to be set)
954 endif
955endif #(DECRYPTION_SUPPORT)
Sumit Garg392e4df2019-11-15 10:43:00 +0530956
johpow0181865962022-01-28 17:06:20 -0600957# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500958ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600959
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100960 # SME/SVE only supported on AArch64
961 ifneq (${ENABLE_SME_FOR_NS},0)
962 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
963 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +0000964
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100965 ifeq (${ENABLE_SVE_FOR_NS},1)
966 # Warning instead of error due to CI dependency on this
967 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
968 endif
johpow0181865962022-01-28 17:06:20 -0600969
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100970 # BRBE is not supported in AArch32
971 ifeq (${ENABLE_BRBE_FOR_NS},1)
972 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
973 endif
johpow0181865962022-01-28 17:06:20 -0600974
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100975 # FEAT_RNG_TRAP is not supported in AArch32
976 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
977 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
978 endif
979endif #(ARCH=aarch32)
johpow019baade32021-07-08 14:14:00 -0500980
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000981ifneq (${ENABLE_SME_FOR_NS},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100982 ifeq (${ENABLE_SVE_FOR_NS},0)
983 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
984 endif
985endif #(ENABLE_SME_FOR_NS)
Boyan Karatotev7f5dcc72023-03-08 16:29:26 +0000986
johpow019baade32021-07-08 14:14:00 -0500987# Secure SME/SVE requires the non-secure component as well
988ifeq (${ENABLE_SME_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100989 ifeq (${ENABLE_SME_FOR_NS},0)
990 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
991 endif
992 ifeq (${ENABLE_SVE_FOR_SWD},0)
993 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
994 endif
995endif #(ENABLE_SME_FOR_SWD)
996
johpow019baade32021-07-08 14:14:00 -0500997ifeq (${ENABLE_SVE_FOR_SWD},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +0100998 ifeq (${ENABLE_SVE_FOR_NS},0)
999 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
1000 endif
1001endif #(ENABLE_SVE_FOR_SWD)
johpow019baade32021-07-08 14:14:00 -05001002
1003# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
1004# its own context management including FPU registers.
1005ifeq (${CTX_INCLUDE_FPREGS},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001006 ifneq (${ENABLE_SME_FOR_NS},0)
1007 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1008 endif
Jayanth Dodderi Chidanandcfe053a2022-11-08 10:31:07 +00001009
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001010 ifeq (${ENABLE_SVE_FOR_NS},1)
1011 # Warning instead of error due to CI dependency on this
1012 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
1013 $(warning "Forced ENABLE_SVE_FOR_NS=0")
1014 override ENABLE_SVE_FOR_NS := 0
1015 endif
1016endif #(CTX_INCLUDE_FPREGS)
johpow019baade32021-07-08 14:14:00 -05001017
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001018ifeq ($(DRTM_SUPPORT),1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001019 $(info DRTM_SUPPORT is an experimental feature)
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001020endif
1021
Raymond Mao98983392023-07-25 07:53:35 -07001022ifeq (${TRANSFER_LIST},1)
1023 $(info TRANSFER_LIST is an experimental feature)
1024endif
1025
Chris Kayd02c2312022-09-29 16:21:24 +01001026ifeq (${ENABLE_RME},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001027 ifneq (${SEPARATE_CODE_AND_RODATA},1)
1028 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
1029 endif
Chris Kayd02c2312022-09-29 16:21:24 +01001030endif
1031
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001032# Determine if FEAT_RNG is supported
1033ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0)
1034
1035# Determine if FEAT_SB is supported
1036ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0)
1037
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001038ifeq ($(PSA_CRYPTO),1)
1039 $(info PSA_CRYPTO is an experimental feature)
1040endif
1041
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001042################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001043# Process platform overrideable behaviour
1044################################################################################
1045
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001046ifdef BL1_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001047 NEED_BL1 := yes
1048endif #(BL1_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001049
Jon Medhurst66573cb2014-02-13 15:19:28 +00001050ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001051 NEED_BL2 := yes
1052
1053 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
1054 # Certificate generation tools. This flag can be overridden by the platform.
1055 ifdef EL3_PAYLOAD_BASE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001056 # If booting an EL3 payload there is no need for a BL33 image
1057 # in the FIP file.
1058 NEED_BL33 := no
1059 else
1060 ifdef PRELOADED_BL33_BASE
1061 # If booting a BL33 preloaded image there is no need of
1062 # another one in the FIP file.
1063 NEED_BL33 := no
1064 else
1065 NEED_BL33 ?= yes
1066 endif
1067 endif
1068endif #(BL2_SOURCES)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001069
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001070ifdef BL2U_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001071 NEED_BL2U := yes
1072endif #(BL2U_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001073
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001074# If SCP_BL2 is given, we always want FIP to include it.
1075ifdef SCP_BL2
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001076 NEED_SCP_BL2 := yes
1077endif #(SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001078
Soby Mathewbf169232017-11-14 14:10:10 +00001079# For AArch32, BL31 is not currently supported.
1080ifneq (${ARCH},aarch32)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001081 ifdef BL31_SOURCES
1082 # When booting an EL3 payload, there is no need to compile the BL31
1083 # image nor put it in the FIP.
1084 ifndef EL3_PAYLOAD_BASE
1085 NEED_BL31 := yes
1086 endif
1087 endif
1088endif #(ARCH=aarch64)
Soby Mathewbf169232017-11-14 14:10:10 +00001089
Juan Castilloa3487d12015-08-18 14:23:04 +01001090# Process TBB related flags
1091ifneq (${GENERATE_COT},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001092 # Common cert_create options
1093 ifneq (${CREATE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001094 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001095 $(eval FWU_CRT_ARGS += -n)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001096 ifneq (${SAVE_KEYS},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001097 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001098 $(eval FWU_CRT_ARGS += -k)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001099 endif
1100 endif
1101 # Include TBBR makefile (unless the platform indicates otherwise)
1102 ifeq (${INCLUDE_TBBR_MK},1)
Juan Castilloa3487d12015-08-18 14:23:04 +01001103 include make_helpers/tbbr/tbbr_tools.mk
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001104 endif
1105endif #(GENERATE_COT)
Achin Gupta4f6ad662013-10-25 09:08:21 +01001106
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001107ifneq (${FIP_ALIGN},0)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001108 FIP_ARGS += --align ${FIP_ALIGN}
1109endif #(FIP_ALIGN)
Masahiro Yamada4d87eb42016-12-25 13:52:22 +09001110
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001111ifdef FDT_SOURCES
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001112 NEED_FDT := yes
1113endif #(FDT_SOURCES)
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001114
Juan Castilloa3487d12015-08-18 14:23:04 +01001115################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +08001116# Include libraries' Makefile that are used in all BL
1117################################################################################
1118
1119include lib/stack_protector/stack_protector.mk
1120
1121################################################################################
Soby Mathew574e01e2017-02-14 10:05:07 +00001122# Include BL specific makefiles
1123################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001124
1125ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001126include bl1/bl1.mk
1127endif
1128
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001129ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001130include bl2/bl2.mk
1131endif
1132
Manish Pandeyb0e7efa2021-10-06 10:59:52 +01001133ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001134include bl2u/bl2u.mk
1135endif
1136
Soby Mathewbf169232017-11-14 14:10:10 +00001137ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +00001138include bl31/bl31.mk
1139endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001140
Soby Mathew574e01e2017-02-14 10:05:07 +00001141################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001142# Build options checks
1143################################################################################
1144
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001145# Boolean_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001146$(eval $(call assert_booleans,\
1147 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001148 ALLOW_RO_XLAT_TABLES \
1149 BL2_ENABLE_SP_LOAD \
1150 COLD_BOOT_SINGLE_CPU \
1151 CREATE_KEYS \
1152 CTX_INCLUDE_AARCH32_REGS \
1153 CTX_INCLUDE_FPREGS \
1154 CTX_INCLUDE_EL2_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001155 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001156 DEBUG \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001157 DYN_DISABLE_AUTH \
1158 EL3_EXCEPTION_HANDLING \
1159 ENABLE_AMU_AUXILIARY_COUNTERS \
1160 ENABLE_AMU_FCONF \
1161 AMU_RESTRICT_COUNTERS \
1162 ENABLE_ASSERTIONS \
1163 ENABLE_FEAT_SB \
1164 ENABLE_PIE \
1165 ENABLE_PMF \
1166 ENABLE_PSCI_STAT \
1167 ENABLE_RUNTIME_INSTRUMENTATION \
1168 ENABLE_SME_FOR_SWD \
1169 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001170 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001171 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001172 ERROR_DEPRECATED \
1173 FAULT_INJECTION_SUPPORT \
1174 GENERATE_COT \
1175 GICV2_G0_FOR_EL3 \
1176 HANDLE_EA_EL3_FIRST_NS \
Bipin Ravie53e6ae2023-09-28 13:17:24 -05001177 HARDEN_SLS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001178 HW_ASSISTED_COHERENCY \
1179 MEASURED_BOOT \
1180 DRTM_SUPPORT \
1181 NS_TIMER_SWITCH \
1182 OVERRIDE_LIBC \
1183 PL011_GENERIC_UART \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001184 PROGRAMMABLE_RESET_ADDRESS \
1185 PSCI_EXTENDED_STATE_ID \
1186 PSCI_OS_INIT_MODE \
1187 RESET_TO_BL31 \
1188 SAVE_KEYS \
1189 SEPARATE_CODE_AND_RODATA \
1190 SEPARATE_BL2_NOLOAD_REGION \
1191 SEPARATE_NOBITS_REGION \
1192 SPIN_ON_BL1_EXIT \
1193 SPM_MM \
1194 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001195 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001196 SPMD_SPM_AT_SEL2 \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001197 ENABLE_SPMD_LP \
Raymond Mao98983392023-07-25 07:53:35 -07001198 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001199 TRUSTED_BOARD_BOOT \
1200 USE_COHERENT_MEM \
1201 USE_DEBUGFS \
1202 ARM_IO_IN_DTB \
1203 SDEI_IN_FCONF \
1204 SEC_INT_DESC_IN_FCONF \
1205 USE_ROMLIB \
1206 USE_TBBR_DEFS \
1207 WARMBOOT_ENABLE_DCACHE_EARLY \
1208 RESET_TO_BL2 \
1209 BL2_IN_XIP_MEM \
1210 BL2_INV_DCACHE \
1211 USE_SPINLOCK_CAS \
1212 ENCRYPT_BL31 \
1213 ENCRYPT_BL32 \
1214 ERRATA_SPECULATIVE_AT \
1215 RAS_TRAP_NS_ERR_REC_ACCESS \
1216 COT_DESC_IN_DTB \
1217 USE_SP804_TIMER \
1218 PSA_FWU_SUPPORT \
1219 ENABLE_MPMM \
1220 ENABLE_MPMM_FCONF \
1221 FEATURE_DETECTION \
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01001222 TRNG_SUPPORT \
Sona Mathew7fe03522022-11-18 18:05:38 -06001223 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001224 ERRATA_NON_ARM_INTERCONNECT \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001225 CONDITIONAL_CMO \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001226 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001227 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001228 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001229 PLATFORM_REPORT_CTX_MEM_USE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001230)))
Dan Handley81be1002015-03-27 17:44:35 +00001231
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001232# Numeric_Flags
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001233$(eval $(call assert_numerics,\
1234 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001235 ARM_ARCH_MAJOR \
1236 ARM_ARCH_MINOR \
1237 BRANCH_PROTECTION \
1238 CTX_INCLUDE_PAUTH_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001239 CTX_INCLUDE_NEVE_REGS \
1240 CRYPTO_SUPPORT \
Boyan Karatotev677ed8a2023-02-16 09:45:29 +00001241 DISABLE_MTPMU \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001242 ENABLE_BRBE_FOR_NS \
1243 ENABLE_TRBE_FOR_NS \
1244 ENABLE_BTI \
1245 ENABLE_PAUTH \
1246 ENABLE_FEAT_AMU \
1247 ENABLE_FEAT_AMUv1p1 \
1248 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001249 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001250 ENABLE_FEAT_DIT \
1251 ENABLE_FEAT_ECV \
1252 ENABLE_FEAT_FGT \
1253 ENABLE_FEAT_HCX \
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06001254 ENABLE_FEAT_MTE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001255 ENABLE_FEAT_PAN \
1256 ENABLE_FEAT_RNG \
1257 ENABLE_FEAT_RNG_TRAP \
1258 ENABLE_FEAT_SEL2 \
1259 ENABLE_FEAT_TCR2 \
1260 ENABLE_FEAT_S2PIE \
1261 ENABLE_FEAT_S1PIE \
1262 ENABLE_FEAT_S2POE \
1263 ENABLE_FEAT_S1POE \
1264 ENABLE_FEAT_GCS \
1265 ENABLE_FEAT_VHE \
Maksims Svecovsdf4ad842023-03-24 13:05:09 +00001266 ENABLE_FEAT_MTE_PERM \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001267 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001268 ENABLE_RME \
1269 ENABLE_SPE_FOR_NS \
1270 ENABLE_SYS_REG_TRACE_FOR_NS \
1271 ENABLE_SME_FOR_NS \
1272 ENABLE_SME2_FOR_NS \
1273 ENABLE_SVE_FOR_NS \
1274 ENABLE_TRF_FOR_NS \
1275 FW_ENC_STATUS \
1276 NR_OF_FW_BANKS \
1277 NR_OF_IMAGES_IN_FW_BANK \
1278 TWED_DELAY \
1279 ENABLE_FEAT_TWED \
1280 SVE_VECTOR_LEN \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001281 IMPDEF_SYSREG_TRAP \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001282)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001283
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001284ifdef KEY_SIZE
1285 $(eval $(call assert_numeric,KEY_SIZE))
1286endif
1287
Justin Chadwell83e04882019-08-20 11:01:52 +01001288ifeq ($(filter $(SANITIZE_UB), on off trap),)
1289 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1290endif
1291
Juan Castilloa3487d12015-08-18 14:23:04 +01001292################################################################################
1293# Add definitions to the cpp preprocessor based on the current build options.
1294# This is done after including the platform specific makefile to allow the
1295# platform to overwrite the default options
1296################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001297
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001298$(eval $(call add_defines,\
1299 $(sort \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001300 ALLOW_RO_XLAT_TABLES \
1301 ARM_ARCH_MAJOR \
1302 ARM_ARCH_MINOR \
1303 BL2_ENABLE_SP_LOAD \
1304 COLD_BOOT_SINGLE_CPU \
1305 CTX_INCLUDE_AARCH32_REGS \
1306 CTX_INCLUDE_FPREGS \
1307 CTX_INCLUDE_PAUTH_REGS \
Arvind Ram Prakash4851b492023-10-06 14:35:21 -05001308 CTX_INCLUDE_MPAM_REGS \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001309 EL3_EXCEPTION_HANDLING \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001310 CTX_INCLUDE_EL2_REGS \
1311 CTX_INCLUDE_NEVE_REGS \
1312 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
1313 DISABLE_MTPMU \
1314 ENABLE_FEAT_AMU \
1315 ENABLE_AMU_AUXILIARY_COUNTERS \
1316 ENABLE_AMU_FCONF \
1317 AMU_RESTRICT_COUNTERS \
1318 ENABLE_ASSERTIONS \
1319 ENABLE_BTI \
Arvind Ram Prakashab28d4b2023-10-11 12:10:56 -05001320 ENABLE_FEAT_MPAM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001321 ENABLE_PAUTH \
1322 ENABLE_PIE \
1323 ENABLE_PMF \
1324 ENABLE_PSCI_STAT \
1325 ENABLE_RME \
1326 ENABLE_RUNTIME_INSTRUMENTATION \
1327 ENABLE_SME_FOR_NS \
1328 ENABLE_SME2_FOR_NS \
1329 ENABLE_SME_FOR_SWD \
1330 ENABLE_SPE_FOR_NS \
1331 ENABLE_SVE_FOR_NS \
1332 ENABLE_SVE_FOR_SWD \
Manish Pandey514a3012023-10-10 13:53:25 +01001333 ENABLE_FEAT_RAS \
Manish Pandeyf90a73c2023-10-10 15:42:19 +01001334 FFH_SUPPORT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001335 ENCRYPT_BL31 \
1336 ENCRYPT_BL32 \
1337 ERROR_DEPRECATED \
1338 FAULT_INJECTION_SUPPORT \
1339 GICV2_G0_FOR_EL3 \
1340 HANDLE_EA_EL3_FIRST_NS \
1341 HW_ASSISTED_COHERENCY \
1342 LOG_LEVEL \
1343 MEASURED_BOOT \
1344 DRTM_SUPPORT \
1345 NS_TIMER_SWITCH \
1346 PL011_GENERIC_UART \
1347 PLAT_${PLAT} \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001348 PROGRAMMABLE_RESET_ADDRESS \
1349 PSCI_EXTENDED_STATE_ID \
1350 PSCI_OS_INIT_MODE \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001351 RESET_TO_BL31 \
1352 SEPARATE_CODE_AND_RODATA \
1353 SEPARATE_BL2_NOLOAD_REGION \
1354 SEPARATE_NOBITS_REGION \
1355 RECLAIM_INIT_CODE \
1356 SPD_${SPD} \
1357 SPIN_ON_BL1_EXIT \
1358 SPM_MM \
1359 SPMC_AT_EL3 \
Nishant Sharma9e719112023-06-27 00:36:01 +01001360 SPMC_AT_EL3_SEL0_SP \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001361 SPMD_SPM_AT_SEL2 \
Raymond Mao98983392023-07-25 07:53:35 -07001362 TRANSFER_LIST \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001363 TRUSTED_BOARD_BOOT \
1364 CRYPTO_SUPPORT \
1365 TRNG_SUPPORT \
1366 ERRATA_ABI_SUPPORT \
Sona Mathew5a4c9fc2023-03-14 14:02:03 -05001367 ERRATA_NON_ARM_INTERCONNECT \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001368 USE_COHERENT_MEM \
1369 USE_DEBUGFS \
1370 ARM_IO_IN_DTB \
1371 SDEI_IN_FCONF \
1372 SEC_INT_DESC_IN_FCONF \
1373 USE_ROMLIB \
1374 USE_TBBR_DEFS \
1375 WARMBOOT_ENABLE_DCACHE_EARLY \
1376 RESET_TO_BL2 \
1377 BL2_RUNS_AT_EL3 \
1378 BL2_IN_XIP_MEM \
1379 BL2_INV_DCACHE \
1380 USE_SPINLOCK_CAS \
1381 ERRATA_SPECULATIVE_AT \
1382 RAS_TRAP_NS_ERR_REC_ACCESS \
1383 COT_DESC_IN_DTB \
1384 USE_SP804_TIMER \
1385 ENABLE_FEAT_RNG \
1386 ENABLE_FEAT_RNG_TRAP \
1387 ENABLE_FEAT_SB \
1388 ENABLE_FEAT_DIT \
1389 NR_OF_FW_BANKS \
1390 NR_OF_IMAGES_IN_FW_BANK \
1391 PSA_FWU_SUPPORT \
1392 ENABLE_BRBE_FOR_NS \
1393 ENABLE_TRBE_FOR_NS \
1394 ENABLE_SYS_REG_TRACE_FOR_NS \
1395 ENABLE_TRF_FOR_NS \
1396 ENABLE_FEAT_HCX \
1397 ENABLE_MPMM \
1398 ENABLE_MPMM_FCONF \
1399 ENABLE_FEAT_FGT \
1400 ENABLE_FEAT_ECV \
1401 ENABLE_FEAT_AMUv1p1 \
1402 ENABLE_FEAT_SEL2 \
1403 ENABLE_FEAT_VHE \
1404 ENABLE_FEAT_CSV2_2 \
Sona Mathew3b84c962023-10-25 16:48:19 -05001405 ENABLE_FEAT_CSV2_3 \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001406 ENABLE_FEAT_PAN \
1407 ENABLE_FEAT_TCR2 \
1408 ENABLE_FEAT_S2PIE \
1409 ENABLE_FEAT_S1PIE \
1410 ENABLE_FEAT_S2POE \
1411 ENABLE_FEAT_S1POE \
1412 ENABLE_FEAT_GCS \
Govindraj Raja24d3a4e2023-12-21 13:57:49 -06001413 ENABLE_FEAT_MTE \
Maksims Svecovsdf4ad842023-03-24 13:05:09 +00001414 ENABLE_FEAT_MTE_PERM \
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001415 FEATURE_DETECTION \
1416 TWED_DELAY \
1417 ENABLE_FEAT_TWED \
Okash Khawaja037b56e2022-11-04 12:38:01 +00001418 CONDITIONAL_CMO \
Varun Wadekar0a46eb12023-04-13 21:06:18 +01001419 IMPDEF_SYSREG_TRAP \
Jayanth Dodderi Chidanand23c2fe22023-04-26 15:57:30 +01001420 SVE_VECTOR_LEN \
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001421 ENABLE_SPMD_LP \
Manish V Badarkhe78e14f82023-09-06 09:08:28 +01001422 PSA_CRYPTO \
Sandrine Bailleuxf57e2032023-10-11 08:38:00 +02001423 ENABLE_CONSOLE_GETC \
Arvind Ram Prakash8bd27c92023-08-15 16:28:06 -05001424 INIT_UNUSED_NS_EL2 \
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001425 PLATFORM_REPORT_CTX_MEM_USE \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001426)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001427
Juan Pablo Condeb5ec1382023-11-08 16:14:28 -06001428ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
1429ifeq (${DEBUG}, 0)
1430 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only")
1431 override PLATFORM_REPORT_CTX_MEM_USE := 0
1432endif
1433endif
1434
Justin Chadwell83e04882019-08-20 11:01:52 +01001435ifeq (${SANITIZE_UB},trap)
1436 $(eval $(call add_define,MONITOR_TRAPS))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001437endif #(SANITIZE_UB)
Justin Chadwell83e04882019-08-20 11:01:52 +01001438
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001439# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1440ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001441 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1442else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001443# Define the PRELOADED_BL33_BASE flag only if it is provided and
1444# EL3_PAYLOAD_BASE is not defined, as it has priority.
1445 ifdef PRELOADED_BL33_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001446 $(eval $(call add_define,PRELOADED_BL33_BASE))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001447 endif
1448endif #(EL3_PAYLOAD_BASE)
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001449
Soby Mathew9fe88042018-03-26 12:43:37 +01001450# Define the DYN_DISABLE_AUTH flag only if set.
1451ifeq (${DYN_DISABLE_AUTH},1)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001452 $(eval $(call add_define,DYN_DISABLE_AUTH))
Soby Mathew9fe88042018-03-26 12:43:37 +01001453endif
1454
Varun Wadekar4d034c52019-01-11 14:47:48 -08001455ifneq ($(findstring armlink,$(notdir $(LD))),)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001456 $(eval $(call add_define,USE_ARM_LINK))
Varun Wadekar4d034c52019-01-11 14:47:48 -08001457endif
1458
Manish Pandey3f90ad72020-01-14 11:52:05 +00001459# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001460ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001461ifdef SP_LAYOUT_FILE
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001462 -include $(BUILD_PLAT)/sp_gen.mk
1463 FIP_DEPS += sp
1464 CRT_DEPS += sp
1465 NEED_SP_PKG := yes
Manish Pandey3f90ad72020-01-14 11:52:05 +00001466else
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001467 ifeq (${SPMD_SPM_AT_SEL2},1)
1468 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1469 endif
1470endif #(SP_LAYOUT_FILE)
1471endif #(SPD)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001472
Juan Castilloa3487d12015-08-18 14:23:04 +01001473################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001474# Build targets
1475################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001476
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301477.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 +01001478.SUFFIXES:
Achin Gupta4f6ad662013-10-25 09:08:21 +01001479
Juan Castilloa3487d12015-08-18 14:23:04 +01001480all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001481
Juan Castilloa3487d12015-08-18 14:23:04 +01001482msg_start:
1483 @echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001484
Soby Mathew18a62042015-10-26 14:29:21 +00001485ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001486# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekar4d034c52019-01-11 14:47:48 -08001487ifneq ($(findstring clang,$(notdir $(CC))),)
1488 CPPFLAGS += -Wno-error=deprecated-declarations
1489else
Dan Handley6fa89a22018-02-27 16:03:58 +00001490 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001491endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001492endif #(!ERROR_DEPRECATED)
Soby Mathew18a62042015-10-26 14:29:21 +00001493
Roberto Vargase92111a2018-05-22 16:05:42 +01001494$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001495$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001496
Juan Castilloa3487d12015-08-18 14:23:04 +01001497# Expand build macros for the different images
1498ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001499BL1_SOURCES := $(sort ${BL1_SOURCES})
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001500$(eval $(call MAKE_BL,bl1))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001501endif #(NEED_BL1)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001502
Juan Castilloa3487d12015-08-18 14:23:04 +01001503ifeq (${NEED_BL2},yes)
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001504
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06001505ifeq (${RESET_TO_BL2}, 0)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001506FIP_BL2_ARGS := tb-fw
1507endif
1508
Chris Kayfb3b0512021-09-28 15:44:37 +01001509BL2_SOURCES := $(sort ${BL2_SOURCES})
1510
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001511$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001512 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001513
1514endif #(NEED_BL2)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001515
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001516ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001517$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001518endif #(NEED_SCP_BL2)
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001519
Juan Castilloa3487d12015-08-18 14:23:04 +01001520ifeq (${NEED_BL31},yes)
1521BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001522# Sort BL31 source files to remove duplicates
1523BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301524ifneq (${DECRYPTION_SUPPORT},none)
1525$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001526 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301527else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001528$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001529 $(eval $(call MAKE_BL,bl31,soc-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001530endif #(DECRYPTION_SUPPORT)
1531endif #(NEED_BL31)
Juan Castillo379954c2014-11-04 17:36:40 +00001532
Juan Castillo671b8db2015-11-12 10:59:26 +00001533# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001534# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001535# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001536ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001537# Sort BL32 source files to remove duplicates
1538BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001539BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1540
Sumit Gargeec52442019-11-14 16:33:45 +05301541ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001542$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301543 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1544else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001545$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001546 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001547endif #(DECRYPTION_SUPPORT)
1548endif #(NEED_BL32)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001549
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001550# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1551# needs to be built from RMM_SOURCES.
1552ifeq (${NEED_RMM},yes)
1553# Sort RMM source files to remove duplicates
1554RMM_SOURCES := $(sort ${RMM_SOURCES})
1555BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1556
1557$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001558 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1559endif #(NEED_RMM)
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001560
Juan Castilloa3487d12015-08-18 14:23:04 +01001561# Add the BL33 image if required by the platform
1562ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001563$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001564endif #(NEED_BL33)
Juan Castillo9c25a402015-01-13 12:21:04 +00001565
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001566ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001567$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001568 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001569endif #(NEED_BL2U)
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001570
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001571# Expand build macros for the different images
1572ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001573 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001574endif #(NEED_FDT)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001575
Manish Pandey3f90ad72020-01-14 11:52:05 +00001576# Add Secure Partition packages
1577ifeq (${NEED_SP_PKG},yes)
Olivier Deprezf5033072024-01-26 12:05:36 +01001578$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
1579 @${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT}
J-Alvesef8e0982022-03-22 16:28:51 +00001580sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001581 @${ECHO_BLANK_LINE}
1582 @echo "Built SP Images successfully"
1583 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001584endif #(NEED_SP_PKG)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001585
Ian Spray36eaaf32014-01-30 17:25:28 +00001586locate-checkpatch:
1587ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001588 $(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 +00001589else
1590ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001591 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001592endif
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001593endif #(CHECKPATCH)
Ian Spray36eaaf32014-01-30 17:25:28 +00001594
Achin Gupta4f6ad662013-10-25 09:08:21 +01001595clean:
Juan Castilloa3487d12015-08-18 14:23:04 +01001596 @echo " CLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001597 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001598ifdef UNIX_MK
Juan Castilloa3487d12015-08-18 14:23:04 +01001599 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001600else
1601# Clear the MAKEFLAGS as we do not want
1602# to pass the gnumake flags to nmake.
1603 ${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 +01001604endif #(UNIX_MK)
Juan Castilloa3487d12015-08-18 14:23:04 +01001605 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301606 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargase92111a2018-05-22 16:05:42 +01001607 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001608
James Morrisseyeaaeece2013-11-01 13:56:59 +00001609realclean distclean:
Juan Castilloa3487d12015-08-18 14:23:04 +01001610 @echo " REALCLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001611 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1612 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001613ifdef UNIX_MK
Juan Castilloa3487d12015-08-18 14:23:04 +01001614 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001615else
1616# Clear the MAKEFLAGS as we do not want
1617# to pass the gnumake flags to nmake.
1618 ${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 +01001619endif #(UNIX_MK)
Nicolas Boulenguezdf612a52021-03-31 12:22:45 +02001620 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301621 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargase92111a2018-05-22 16:05:42 +01001622 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001623
Ian Spray36eaaf32014-01-30 17:25:28 +00001624checkcodebase: locate-checkpatch
Juan Castilloa3487d12015-08-18 14:23:04 +01001625 @echo " CHECKING STYLE"
Dan Handley3a355712016-06-02 18:21:02 +01001626 @if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001627 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001628 while read GIT_FILE ; \
1629 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1630 done ; \
1631 else \
1632 find . -type f -not -iwholename "*.git*" \
1633 -not -iwholename "*build*" \
1634 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001635 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001636 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001637 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001638 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1639 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001640
1641checkpatch: locate-checkpatch
Juan Castilloa3487d12015-08-18 14:23:04 +01001642 @echo " CHECKING STYLE"
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001643 @if test -n "${CHECKPATCH_OPTS}"; then \
1644 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1645 fi
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001646 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001647 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1648 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001649 printf "\n[*] Checking style of '$$commit'\n\n"; \
1650 git log --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 git diff --format=email "$$commit~..$$commit" \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001654 -- ${CHECK_PATHS} | \
1655 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001656 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001657
1658certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001659
Pali Rohár54ff2132020-11-24 15:38:08 +01001660${CRTTOOL}: FORCE
Lionel Debieve730bde82022-11-14 11:05:09 +01001661 ${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 +00001662 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001663 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001664 @${ECHO_BLANK_LINE}
Jon Medhurst407a95c2014-02-12 15:54:48 +00001665
Juan Castillo11abdcd2014-10-21 11:30:42 +01001666ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001667certificates: ${CRT_DEPS} ${CRTTOOL}
1668 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001669 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001670 @echo "Built $@ successfully"
1671 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001672 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001673endif #(GENERATE_COT)
Juan Castillo11abdcd2014-10-21 11:30:42 +01001674
Juan Castilloa3487d12015-08-18 14:23:04 +01001675${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001676 $(eval ${CHECK_FIP_CMD})
dp-arm4972ec52016-05-25 16:20:20 +01001677 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1678 ${Q}${FIPTOOL} info $@
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001679 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001680 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001681 @${ECHO_BLANK_LINE}
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001682
Yatharth Kochard1a93432015-10-12 12:33:47 +01001683ifneq (${GENERATE_COT},0)
1684fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1685 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001686 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001687 @echo "Built $@ successfully"
1688 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001689 @${ECHO_BLANK_LINE}
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001690endif #(GENERATE_COT)
Yatharth Kochard1a93432015-10-12 12:33:47 +01001691
1692${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001693 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm4972ec52016-05-25 16:20:20 +01001694 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1695 ${Q}${FIPTOOL} info $@
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001696 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001697 @echo "Built $@ successfully"
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001698 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001699
Juan Castilloa3487d12015-08-18 14:23:04 +01001700fiptool: ${FIPTOOL}
1701fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001702fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001703
Pali Rohár54ff2132020-11-24 15:38:08 +01001704${FIPTOOL}: FORCE
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001705ifdef UNIX_MK
Lionel Debieve730bde82022-11-14 11:05:09 +01001706 ${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 +01001707else
1708# Clear the MAKEFLAGS as we do not want
1709# to pass the gnumake flags to nmake.
1710 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
Jayanth Dodderi Chidanand2ee5d402023-04-24 15:57:05 +01001711endif #(UNIX_MK)
Harry Liebelf58ad362014-01-10 18:00:33 +00001712
Pali Rohár54ff2132020-11-24 15:38:08 +01001713romlib.bin: libraries FORCE
John Tsichritzisf6ea99b2019-05-21 15:47:37 +01001714 ${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 +01001715
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001716memmap: all
Harrison Mutaie9bc4882023-02-23 10:33:58 +00001717ifdef UNIX_MK
1718 ${Q}PYTHONPATH=${CURDIR}/tools/memory \
1719 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1720else
1721 ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
1722 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
1723endif
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001724
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001725doc:
1726 @echo " BUILD DOCUMENTATION"
1727 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1728
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301729enctool: ${ENCTOOL}
1730
Pali Rohár54ff2132020-11-24 15:38:08 +01001731${ENCTOOL}: FORCE
Lionel Debieve730bde82022-11-14 11:05:09 +01001732 ${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 +05301733 @${ECHO_BLANK_LINE}
1734 @echo "Built $@ successfully"
1735 @${ECHO_BLANK_LINE}
1736
Joakim Bech35fab8c2014-01-23 14:51:49 +01001737cscope:
1738 @echo " CSCOPE"
1739 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1740 ${Q}cscope -b -q -k
1741
Ryan Harkin72ee3312014-01-15 16:55:07 +00001742help:
John Tsichritzis0c4dded2019-05-21 15:57:31 +01001743 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001744 @echo ""
1745 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleuxa08588a2014-03-21 13:16:35 +00001746 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001747 @echo ""
John Tsichritzis0c4dded2019-05-21 15:57:31 +01001748 @echo "platform = ${PLATFORM_LIST}"
1749 @echo ""
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001750 @echo "Please refer to the User Guide for a list of all supported options."
1751 @echo "Note that the build system doesn't track dependencies for build "
1752 @echo "options. Therefore, if any of the build options are changed "
1753 @echo "from a previous build, a clean build must be performed."
1754 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001755 @echo "Supported Targets:"
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001756 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001757 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001758 @echo " bl2 Build the BL2 binary"
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001759 @echo " bl2u Build the BL2U binary"
Juan Castillo7d199412015-12-14 09:35:25 +00001760 @echo " bl31 Build the BL31 binary"
Soby Mathewa1941252016-05-05 14:33:33 +01001761 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1762 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castilloa3487d12015-08-18 14:23:04 +01001763 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001764 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochard1a93432015-10-12 12:33:47 +01001765 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001766 @echo " checkcodebase Check the coding style of the entire source tree"
1767 @echo " checkpatch Check the coding style on changes in the current"
1768 @echo " branch against BASE_COMMIT (default origin/master)"
1769 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001770 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001771 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001772 @echo " certtool Build the Certificate generation tool"
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301773 @echo " enctool Build the Firmware encryption tool"
Andreas Färberec82cfb2016-10-10 05:18:49 +02001774 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandey3f90ad72020-01-14 11:52:05 +00001775 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaza830a4d2018-11-27 14:58:04 +00001776 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathewab4181d2017-12-14 17:44:56 +00001777 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001778 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001779 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001780 @echo ""
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001781 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001782 @echo ""
1783 @echo "example: build all targets for the FVP platform:"
1784 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001785
1786.PHONY: FORCE
1787FORCE:;