blob: b42e4ec25312b2ea61fed0fb0e93e8b127a8bbf4 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Manish V Badarkhe5181d602022-01-08 22:56:06 +00002# Copyright (c) 2013-2022, 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
Jayanth Dodderi Chidanandb16bc302022-05-19 11:03:07 +010011VERSION_MINOR := 7
laurenw-arme954f652022-07-12 10:12:05 -050012VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}
Juan Castillo04be3a52014-06-30 11:41:46 +010013
Juan Castillo396644b2015-10-22 11:34:44 +010014# Default goal is build all images
15.DEFAULT_GOAL := all
16
Douglas Raillard527cd902016-12-28 14:47:50 +000017# Avoid any implicit propagation of command line variable definitions to
18# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
19# usage. Other command line options like "-s" are still propagated as usual.
20MAKEOVERRIDES =
21
Evan Lloydf2697142015-12-02 18:17:37 +000022MAKE_HELPERS_DIRECTORY := make_helpers/
23include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000024include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Juan Castilloa3487d12015-08-18 14:23:04 +010025
26################################################################################
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010027# Default values for build configurations, and their dependencies
Juan Castilloa3487d12015-08-18 14:23:04 +010028################################################################################
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010029
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010030include ${MAKE_HELPERS_DIRECTORY}defaults.mk
dp-arm3cac7862016-09-19 11:18:44 +010031
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010032# Assertions enabled for DEBUG builds by default
Antonio Nino Diaz808c2292017-04-18 15:16:05 +010033ENABLE_ASSERTIONS := ${DEBUG}
Jeenu Viswambharan615ff392016-10-24 14:31:51 +010034ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
35PLAT := ${DEFAULT_PLAT}
Achin Gupta4f6ad662013-10-25 09:08:21 +010036
Juan Castilloa3487d12015-08-18 14:23:04 +010037################################################################################
38# Checkpatch script options
39################################################################################
40
Sandrine Bailleux0b5a1582016-06-02 11:19:59 +010041CHECKCODE_ARGS := --no-patch
Dan Handleyd7b59e42016-06-02 17:15:13 +010042# Do not check the coding style on imported library files or documentation files
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030043INC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \
44 include/drivers/arm/cryptocell, \
45 $(wildcard include/drivers/arm/*)))
46INC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h
47INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
48 include/drivers/arm, \
49 $(wildcard include/drivers/*)))
Dan Handleyd7b59e42016-06-02 17:15:13 +010050INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Dan Handley3a355712016-06-02 18:21:02 +010051 include/lib/libfdt \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010052 include/lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010053 $(wildcard include/lib/*)))
54INC_DIRS_TO_CHECK := $(sort $(filter-out \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030055 include/lib \
56 include/drivers, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010057 $(wildcard include/*)))
58LIB_DIRS_TO_CHECK := $(sort $(filter-out \
dp-arme3cc8382017-05-04 12:15:35 +010059 lib/compiler-rt \
Antonio Nino Diazd84f88e2017-01-16 17:20:45 +000060 lib/libfdt% \
Roberto Vargas0f8f9852018-05-08 10:27:10 +010061 lib/libc, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010062 $(wildcard lib/*)))
63ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
64 lib \
65 include \
66 docs \
Paul Beesleyadfab5b2019-03-07 16:42:31 +000067 %.rst, \
Dan Handleyd7b59e42016-06-02 17:15:13 +010068 $(wildcard *)))
69CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
70 ${INC_DIRS_TO_CHECK} \
71 ${INC_LIB_DIRS_TO_CHECK} \
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +030072 ${LIB_DIRS_TO_CHECK} \
73 ${INC_DRV_DIRS_TO_CHECK} \
74 ${INC_ARM_DIRS_TO_CHECK}
Ian Spray36eaaf32014-01-30 17:25:28 +000075
Juan Castilloa3487d12015-08-18 14:23:04 +010076
77################################################################################
78# Process build options
79################################################################################
80
81# Verbose flag
Jeenu Viswambharan19a0ace2014-05-15 14:40:58 +010082ifeq (${V},0)
Evan Lloydf4ba5ca2015-12-03 09:47:51 +000083 Q:=@
Andre Przywaracf2bb082018-09-27 10:56:05 +010084 ECHO:=@echo
Juan Castilloa3487d12015-08-18 14:23:04 +010085 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010086else
Evan Lloydf4ba5ca2015-12-03 09:47:51 +000087 Q:=
Antonio Nino Diazffd122b2018-10-19 15:44:30 +010088 ECHO:=$(ECHO_QUIET)
Andre Przywaracf2bb082018-09-27 10:56:05 +010089endif
90
91ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
92 Q:=@
Antonio Nino Diazffd122b2018-10-19 15:44:30 +010093 ECHO:=$(ECHO_QUIET)
Achin Gupta4f6ad662013-10-25 09:08:21 +010094endif
Andre Przywaracf2bb082018-09-27 10:56:05 +010095
96export Q ECHO
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000097
Juan Castilloa3487d12015-08-18 14:23:04 +010098# The cert_create tool cannot generate certificates individually, so we use the
99# target 'certificates' to create them all
100ifneq (${GENERATE_COT},0)
101 FIP_DEPS += certificates
Yatharth Kochard1a93432015-10-12 12:33:47 +0100102 FWU_FIP_DEPS += fwu_certificates
Juan Castilloa3487d12015-08-18 14:23:04 +0100103endif
104
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100105# Process BRANCH_PROTECTION value and set
106# Pointer Authentication and Branch Target Identification flags
107ifeq (${BRANCH_PROTECTION},0)
108 # Default value turns off all types of branch protection
109 BP_OPTION := none
110else ifneq (${ARCH},aarch64)
111 $(error BRANCH_PROTECTION requires AArch64)
112else ifeq (${BRANCH_PROTECTION},1)
113 # Enables all types of branch protection features
114 BP_OPTION := standard
115 ENABLE_BTI := 1
116 ENABLE_PAUTH := 1
117else ifeq (${BRANCH_PROTECTION},2)
118 # Return address signing to its standard level
119 BP_OPTION := pac-ret
120 ENABLE_PAUTH := 1
121else ifeq (${BRANCH_PROTECTION},3)
122 # Extend the signing to include leaf functions
123 BP_OPTION := pac-ret+leaf
124 ENABLE_PAUTH := 1
Alexei Fedorove039e482020-06-19 14:33:49 +0100125else ifeq (${BRANCH_PROTECTION},4)
126 # Turn on branch target identification mechanism
127 BP_OPTION := bti
128 ENABLE_BTI := 1
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100129else
130 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
131endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100132
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500133# FEAT_RME
134ifeq (${ENABLE_RME},1)
135# RME doesn't support PIE
136ifneq (${ENABLE_PIE},0)
137 $(error ENABLE_RME does not support PIE)
138endif
johpow0181865962022-01-28 17:06:20 -0600139# RME doesn't support BRBE
140ifneq (${ENABLE_BRBE_FOR_NS},0)
141 $(error ENABLE_RME does not support BRBE.)
142endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500143# RME requires AARCH64
144ifneq (${ARCH},aarch64)
145 $(error ENABLE_RME requires AArch64)
146endif
147# RME requires el2 context to be saved for now.
148CTX_INCLUDE_EL2_REGS := 1
149CTX_INCLUDE_AARCH32_REGS := 0
150ARM_ARCH_MAJOR := 8
Andre Przywara8432bcc2022-10-04 13:56:49 +0100151ARM_ARCH_MINOR := 5
152ENABLE_FEAT_ECV = 1
153ENABLE_FEAT_FGT = 1
154
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500155endif
156
Soby Mathewad042012019-09-25 14:03:41 +0100157# USE_SPINLOCK_CAS requires AArch64 build
158ifeq (${USE_SPINLOCK_CAS},1)
159ifneq (${ARCH},aarch64)
160 $(error USE_SPINLOCK_CAS requires AArch64)
Soby Mathewad042012019-09-25 14:03:41 +0100161endif
162endif
163
Olivier Deprezcb4c5622019-09-19 17:46:46 +0200164# USE_DEBUGFS experimental feature recommended only in debug builds
165ifeq (${USE_DEBUGFS},1)
166ifeq (${DEBUG},1)
167 $(warning DEBUGFS experimental feature is enabled.)
168else
169 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
170endif
171endif
172
Sumit Gargeec52442019-11-14 16:33:45 +0530173ifneq (${DECRYPTION_SUPPORT},none)
174ENC_ARGS += -f ${FW_ENC_STATUS}
175ENC_ARGS += -k ${ENC_KEY}
176ENC_ARGS += -n ${ENC_NONCE}
177FIP_DEPS += enctool
178FWU_FIP_DEPS += enctool
179endif
180
Juan Castilloa3487d12015-08-18 14:23:04 +0100181################################################################################
182# Toolchain
183################################################################################
184
dp-arme95aaa62017-05-02 11:09:11 +0100185HOSTCC := gcc
186export HOSTCC
187
Juan Castilloa3487d12015-08-18 14:23:04 +0100188CC := ${CROSS_COMPILE}gcc
189CPP := ${CROSS_COMPILE}cpp
190AS := ${CROSS_COMPILE}gcc
191AR := ${CROSS_COMPILE}ar
Roberto Vargas1fd0d1b2018-04-13 14:26:47 +0100192LINKER := ${CROSS_COMPILE}ld
Juan Castilloa3487d12015-08-18 14:23:04 +0100193OC := ${CROSS_COMPILE}objcopy
194OD := ${CROSS_COMPILE}objdump
195NM := ${CROSS_COMPILE}nm
196PP := ${CROSS_COMPILE}gcc -E
Soby Mathewab4181d2017-12-14 17:44:56 +0000197DTC := dtc
Juan Castilloa3487d12015-08-18 14:23:04 +0100198
Julius Wernerb1f64a72018-01-10 15:12:47 -0800199# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
200ifneq ($(strip $(wildcard ${LD}.bfd) \
Roberto Vargas1fd0d1b2018-04-13 14:26:47 +0100201 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
202LINKER := ${LINKER}.bfd
Julius Wernerb1f64a72018-01-10 15:12:47 -0800203endif
204
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100205ifeq (${ARM_ARCH_MAJOR},7)
206target32-directive = -target arm-none-eabi
207# Will set march32-directive from platform configuration
208else
209target32-directive = -target armv8a-none-eabi
Alexei Fedorovb567e5d2019-03-11 16:51:47 +0000210
Alexei Fedorov132e6652020-12-07 16:38:53 +0000211# Set the compiler's target architecture profile based on
212# ARM_ARCH_MAJOR ARM_ARCH_MINOR options
Alexei Fedorovb567e5d2019-03-11 16:51:47 +0000213ifeq (${ARM_ARCH_MINOR},0)
Alexei Fedorov132e6652020-12-07 16:38:53 +0000214march32-directive = -march=armv${ARM_ARCH_MAJOR}-a
215march64-directive = -march=armv${ARM_ARCH_MAJOR}-a
Alexei Fedorovb567e5d2019-03-11 16:51:47 +0000216else
Alexei Fedorov132e6652020-12-07 16:38:53 +0000217march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
218march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
Alexei Fedorovb567e5d2019-03-11 16:51:47 +0000219endif
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100220endif
221
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000222# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
223ifeq ($(ARCH), aarch64)
Sami Mujawar1bc7b0e2020-04-23 09:28:37 +0100224# Check if revision is greater than or equal to 8.5
225ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000226mem_tag_arch_support = yes
227endif
228endif
229
Alexei Fedorov132e6652020-12-07 16:38:53 +0000230# Get architecture feature modifiers
231arch-features = ${ARM_ARCH_FEATURE}
232
233# Enable required options for memory stack tagging.
234# Currently, these options are enabled only for clang and armclang compiler.
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000235ifeq (${SUPPORT_STACK_MEMTAG},yes)
236ifdef mem_tag_arch_support
Alexei Fedorov132e6652020-12-07 16:38:53 +0000237# Check for armclang and clang compilers
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000238ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
Alexei Fedorov132e6652020-12-07 16:38:53 +0000239# Add "memtag" architecture feature modifier if not specified
240ifeq ( ,$(findstring memtag,$(arch-features)))
241arch-features := $(arch-features)+memtag
242endif # memtag
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000243ifeq ($(notdir $(CC)),armclang)
244TF_CFLAGS += -mmemtag-stack
245else ifeq ($(notdir $(CC)),clang)
246TF_CFLAGS += -fsanitize=memtag
Alexei Fedorov132e6652020-12-07 16:38:53 +0000247endif # armclang
248endif # armclang clang
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000249else
250$(error "Error: stack memory tagging is not supported for architecture \
251 ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
Alexei Fedorov132e6652020-12-07 16:38:53 +0000252endif # mem_tag_arch_support
253endif # SUPPORT_STACK_MEMTAG
254
255# Set the compiler's architecture feature modifiers
256ifneq ($(arch-features), none)
257# Strip "none+" from arch-features
258arch-features := $(subst none+,,$(arch-features))
259ifeq ($(ARCH), aarch32)
260march32-directive := $(march32-directive)+$(arch-features)
261else
262march64-directive := $(march64-directive)+$(arch-features)
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000263endif
Alexei Fedorov132e6652020-12-07 16:38:53 +0000264# Print features
265$(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
266endif # arch-features
Manish V Badarkhe75c972a2020-03-22 05:06:38 +0000267
Tomas Pilarde164b02020-10-29 13:01:16 +0000268# Determine if FEAT_RNG is supported
269ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0)
270
Chris Kay08fec332021-03-09 13:34:35 +0000271# Determine if FEAT_SB is supported
272ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0)
273
originfba80d82022-01-19 16:30:14 +0000274ifneq ($(findstring clang,$(notdir $(CC))),)
275 ifneq ($(findstring armclang,$(notdir $(CC))),)
276 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march32-directive)
277 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march64-directive)
278 LD := $(LINKER)
279 else
280 TF_CFLAGS_aarch32 := $(target32-directive) $(march32-directive)
281 TF_CFLAGS_aarch64 := -target aarch64-elf $(march64-directive)
282 LD := $(shell $(CC) --print-prog-name ld.lld)
283
284 AR := $(shell $(CC) --print-prog-name llvm-ar)
285 OD := $(shell $(CC) --print-prog-name llvm-objdump)
286 OC := $(shell $(CC) --print-prog-name llvm-objcopy)
287 endif
288
289 CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
290 PP := $(CC) -E $(TF_CFLAGS_$(ARCH))
291 AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
zelalem-aweked5f45272019-11-12 16:20:17 -0600292else ifneq ($(findstring gcc,$(notdir $(CC))),)
293TF_CFLAGS_aarch32 = $(march32-directive)
294TF_CFLAGS_aarch64 = $(march64-directive)
295ifeq ($(ENABLE_LTO),1)
296 # Enable LTO only for aarch64
297 ifeq (${ARCH},aarch64)
298 LTO_CFLAGS = -flto
299 # Use gcc as a wrapper for the ld, recommended for LTO
300 LINKER := ${CROSS_COMPILE}gcc
301 endif
302endif
303LD = $(LINKER)
dp-arm320e8442017-05-02 12:00:08 +0100304else
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100305TF_CFLAGS_aarch32 = $(march32-directive)
Alexei Fedorovb567e5d2019-03-11 16:51:47 +0000306TF_CFLAGS_aarch64 = $(march64-directive)
Roberto Vargas1fd0d1b2018-04-13 14:26:47 +0100307LD = $(LINKER)
dp-arm320e8442017-05-02 12:00:08 +0100308endif
309
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100310# Process Debug flag
311$(eval $(call add_define,DEBUG))
312ifneq (${DEBUG}, 0)
313 BUILD_TYPE := debug
Daniel Boulbydf83a832022-05-03 16:46:16 +0100314 TF_CFLAGS += -g -gdwarf-4
315 ASFLAGS += -g -Wa,-gdwarf-4
Ahmad Fatoum2633cbb2020-02-25 11:25:08 +0100316
317 # Use LOG_LEVEL_INFO by default for debug builds
318 LOG_LEVEL := 40
319else
320 BUILD_TYPE := release
321 # Use LOG_LEVEL_NOTICE by default for release builds
322 LOG_LEVEL := 20
323endif
324
Peiyuan Song44f8f472020-04-25 16:53:43 +0800325# Default build string (git branch and commit)
326ifeq (${BUILD_STRING},)
327 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
328endif
laurenw-arme954f652022-07-12 10:12:05 -0500329VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
Peiyuan Song44f8f472020-04-25 16:53:43 +0800330
Antonio Nino Diaz80914a82018-08-08 16:28:43 +0100331ifeq (${AARCH32_INSTRUCTION_SET},A32)
332TF_CFLAGS_aarch32 += -marm
333else ifeq (${AARCH32_INSTRUCTION_SET},T32)
334TF_CFLAGS_aarch32 += -mthumb
335else
336$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
337endif
338
Sandrine Bailleux1aa72ec2018-07-03 09:14:45 +0200339TF_CFLAGS_aarch32 += -mno-unaligned-access
dp-arm320e8442017-05-02 12:00:08 +0100340TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
Soby Mathewa1941252016-05-05 14:33:33 +0100341
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100342ifneq (${BP_OPTION},none)
343TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
344endif
345
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100346ASFLAGS_aarch32 = $(march32-directive)
Alexei Fedorovb567e5d2019-03-11 16:51:47 +0000347ASFLAGS_aarch64 = $(march64-directive)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000348
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100349# General warnings
350WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
Yann Gautier94a40b62021-05-20 13:18:14 +0200351 -Wdisabled-optimization -Wvla -Wshadow \
Madhukar Pappireddyfc9b4112019-12-23 14:49:52 -0600352 -Wno-unused-parameter -Wredundant-decls
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100353
354# Additional warnings
355# Level 1
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100356WARNING1 := -Wextra
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100357WARNING1 += -Wmissing-format-attribute
358WARNING1 += -Wmissing-prototypes
359WARNING1 += -Wold-style-definition
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100360
Justin Chadwell7d0e3ba2019-09-17 15:21:50 +0100361# Level 2
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100362WARNING2 := -Waggregate-return
363WARNING2 += -Wcast-align
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100364WARNING2 += -Wnested-externs
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100365
366WARNING3 := -Wbad-function-cast
367WARNING3 += -Wcast-qual
368WARNING3 += -Wconversion
369WARNING3 += -Wpacked
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100370WARNING3 += -Wpointer-arith
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100371WARNING3 += -Wswitch-default
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100372
373ifeq (${W},1)
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100374WARNINGS += $(WARNING1)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100375else ifeq (${W},2)
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100376WARNINGS += $(WARNING1) $(WARNING2)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100377else ifeq (${W},3)
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100378WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
Yann Gautier82b2f8c2018-12-10 18:00:26 +0100379endif
380
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100381# Compiler specific warnings
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100382ifeq ($(findstring clang,$(notdir $(CC))),)
Justin Chadwell7a914232019-07-03 14:15:56 +0100383# not using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100384WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
385 -Wpacked-bitfield-compat -Wshift-overflow=2 \
386 -Wlogical-op
Justin Chadwell7a914232019-07-03 14:15:56 +0100387else
388# using clang
Justin Chadwell42d18ca2019-09-18 14:13:42 +0100389WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
390 -Wlogical-op-parentheses
Ambroise Vincent067e4d92019-05-24 12:47:43 +0100391endif
392
Yann Gautier957c3532018-12-10 18:08:53 +0100393ifneq (${E},0)
394ERRORS := -Werror
395endif
396
Justin Chadwelle72a1eb2019-07-31 11:36:41 +0100397CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
398 $(ERRORS) $(WARNINGS)
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900399ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
Julius Werner53456fc2019-07-09 13:49:11 -0700400 -ffreestanding -Wa,--fatal-warnings
Masahiro Yamada0dec9fa2016-12-22 12:51:53 +0900401TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
Samuel Holland23f5e542019-10-20 16:11:25 -0500402 -ffunction-sections -fdata-sections \
403 -ffreestanding -fno-builtin -fno-common \
404 -Os -std=gnu99
Juan Castilloa3487d12015-08-18 14:23:04 +0100405
Mark Brown64869972022-04-20 18:14:32 +0100406$(eval $(call add_define,SVE_VECTOR_LEN))
407
Justin Chadwell83e04882019-08-20 11:01:52 +0100408ifeq (${SANITIZE_UB},on)
409TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
410endif
411ifeq (${SANITIZE_UB},trap)
412TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
413 -fsanitize-undefined-trap-on-error
414endif
415
david cunado34ab6092017-11-30 21:58:01 +0000416GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
david cunado34ab6092017-11-30 21:58:01 +0000417
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100418# LD = armlink
Varun Wadekar4d034c52019-01-11 14:47:48 -0800419ifneq ($(findstring armlink,$(notdir $(LD))),)
420TF_LDFLAGS += --diag_error=warning --lto_level=O1
421TF_LDFLAGS += --remove --info=unused,unusedsymbols
zelalem-aweked5f45272019-11-12 16:20:17 -0600422TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100423
424# LD = gcc (used when GCC LTO is enabled)
zelalem-aweked5f45272019-11-12 16:20:17 -0600425else ifneq ($(findstring gcc,$(notdir $(LD))),)
426# Pass ld options with Wl or Xlinker switches
427TF_LDFLAGS += -Wl,--fatal-warnings -O1
428TF_LDFLAGS += -Wl,--gc-sections
429ifeq ($(ENABLE_LTO),1)
430 ifeq (${ARCH},aarch64)
431 TF_LDFLAGS += -flto -fuse-linker-plugin
432 endif
433endif
434# GCC automatically adds fix-cortex-a53-843419 flag when used to link
435# which breaks some builds, so disable if errata fix is not explicitly enabled
436ifneq (${ERRATA_A53_843419},1)
437 TF_LDFLAGS += -mno-fix-cortex-a53-843419
438endif
439TF_LDFLAGS += -nostdlib
440TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100441
442# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
Varun Wadekar4d034c52019-01-11 14:47:48 -0800443else
Douglas Raillardd0c82732017-06-22 14:44:48 +0100444TF_LDFLAGS += --fatal-warnings -O1
445TF_LDFLAGS += --gc-sections
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100446# ld.lld doesn't recognize the errata flags,
447# therefore don't add those in that case
448ifeq ($(findstring ld.lld,$(notdir $(LD))),)
Douglas Raillardd0c82732017-06-22 14:44:48 +0100449TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
zelalem-aweked5f45272019-11-12 16:20:17 -0600450endif
Ambroise Vincent05c07c52019-07-17 11:08:38 +0100451endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100452
Nishanth Menon4ac02ba2016-10-14 01:13:57 +0000453DTC_FLAGS += -I dts -O dtb
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000454DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \
455 -x assembler-with-cpp $(DEFINES)
Nishanth Menon4ac02ba2016-10-14 01:13:57 +0000456
Juan Castilloa3487d12015-08-18 14:23:04 +0100457################################################################################
458# Common sources and include directories
459################################################################################
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000460include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
dp-arme3cc8382017-05-04 12:15:35 +0100461include lib/compiler-rt/compiler-rt.mk
Juan Castilloa3487d12015-08-18 14:23:04 +0100462
463BL_COMMON_SOURCES += common/bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100464 common/tf_log.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100465 common/${ARCH}/debug.S \
Julius Werner03020da2018-11-27 22:10:56 -0800466 drivers/console/multi_console.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100467 lib/${ARCH}/cache_helpers.S \
468 lib/${ARCH}/misc_helpers.S \
Soby Mathew2f38ce32018-02-08 17:45:12 +0000469 plat/common/plat_bl_common.c \
Soby Mathewaaf15f52017-09-04 11:49:29 +0100470 plat/common/plat_log_common.c \
dp-arm230011c2017-03-07 11:02:47 +0000471 plat/common/${ARCH}/plat_common.c \
Soby Mathewa1941252016-05-05 14:33:33 +0100472 plat/common/${ARCH}/platform_helpers.S \
Roberto Vargas0f8f9852018-05-08 10:27:10 +0100473 ${COMPILER_RT_SRCS}
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000474
Antonio Nino Diazeea20fc2018-08-16 15:42:44 +0100475ifeq ($(notdir $(CC)),armclang)
476BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
477endif
478
Justin Chadwell83e04882019-08-20 11:01:52 +0100479ifeq (${SANITIZE_UB},on)
480BL_COMMON_SOURCES += plat/common/ubsan.c
481endif
482
Yann Gautier2cf1dbc2018-06-18 16:00:23 +0200483INCLUDES += -Iinclude \
Antonio Nino Diaz8d1ade62018-12-17 17:20:57 +0000484 -Iinclude/arch/${ARCH} \
Antonio Nino Diaze0f90632018-12-14 00:18:21 +0000485 -Iinclude/lib/cpus/${ARCH} \
486 -Iinclude/lib/el3_runtime/${ARCH} \
487 ${PLAT_INCLUDES} \
488 ${SPD_INCLUDES}
489
Antonio Nino Diazc3a2cf22018-11-19 11:48:30 +0000490include common/backtrace/backtrace.mk
491
Juan Castilloa3487d12015-08-18 14:23:04 +0100492################################################################################
493# Generic definitions
494################################################################################
495
Evan Lloydf2697142015-12-02 18:17:37 +0000496include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
497
Grant Likely388248a2020-07-30 08:50:10 +0100498ifeq (${BUILD_BASE},)
499 BUILD_BASE := ./build
500endif
501BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100502
Evan Lloydf2697142015-12-02 18:17:37 +0000503SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
Ryan Harkin72ee3312014-01-15 16:55:07 +0000504
Juan Castilloa3487d12015-08-18 14:23:04 +0100505# Platforms providing their own TBB makefile may override this value
506INCLUDE_TBBR_MK := 1
507
Jeenu Viswambharane5c39fd2014-05-16 11:38:10 +0100508
Juan Castilloa3487d12015-08-18 14:23:04 +0100509################################################################################
510# Include SPD Makefile if one has been specified
511################################################################################
512
513ifneq (${SPD},none)
Max Shvetsovbdf502d2020-02-25 13:56:19 +0000514 ifeq (${ARCH},aarch32)
Sandrine Bailleux247e3392018-10-03 14:56:38 +0200515 $(error "Error: SPD is incompatible with AArch32.")
Max Shvetsovbdf502d2020-02-25 13:56:19 +0000516 endif
517
518 ifdef EL3_PAYLOAD_BASE
Sandrine Bailleux03897bb2015-11-26 16:31:34 +0000519 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
520 $(warning "The SPD and its BL32 companion will be present but ignored.")
Max Shvetsovbdf502d2020-02-25 13:56:19 +0000521 endif
Achin Gupta60b7b8a2019-10-11 15:50:43 +0100522
Max Shvetsovbdf502d2020-02-25 13:56:19 +0000523 ifeq (${SPD},spmd)
524 # SPMD is located in std_svc directory
525 SPD_DIR := std_svc
Juan Castilloa3487d12015-08-18 14:23:04 +0100526
Max Shvetsove7fd80e2020-02-25 13:55:00 +0000527 ifeq ($(SPMD_SPM_AT_SEL2),1)
528 ifeq ($(CTX_INCLUDE_EL2_REGS),0)
529 $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option)
530 endif
Marc Bonniciabaac162021-12-01 18:00:40 +0000531 ifeq ($(SPMC_AT_EL3),1)
532 $(error SPM cannot be enabled in both S-EL2 and EL3.)
533 endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100534 endif
Olivier Deprezbcaa0682020-04-01 21:28:26 +0200535
536 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
537 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
538 endif
Davidson K9a949142021-03-10 12:07:15 +0530539
540 ifeq ($(TS_SP_FW_CONFIG),1)
541 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
542 endif
Balint Dobszay9f689762021-03-26 15:19:11 +0100543
544 ifneq ($(ARM_BL2_SP_LIST_DTS),)
545 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
546 endif
Balint Dobszay719ba9c2021-03-26 16:23:18 +0100547
548 ifneq ($(SP_LAYOUT_FILE),)
549 BL2_ENABLE_SP_LOAD := 1
550 endif
Max Shvetsovbdf502d2020-02-25 13:56:19 +0000551 else
552 # All other SPDs in spd directory
553 SPD_DIR := spd
554 endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100555
Max Shvetsovbdf502d2020-02-25 13:56:19 +0000556 # We expect to locate an spd.mk under the specified SPD directory
557 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
558
559 ifeq (${SPD_MAKE},)
560 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
561 endif
562 $(info Including ${SPD_MAKE})
563 include ${SPD_MAKE}
564
565 # If there's BL32 companion for the chosen SPD, we expect that the SPD's
566 # Makefile would set NEED_BL32 to "yes". In this case, the build system
567 # supports two mutually exclusive options:
568 # * BL32 is built from source: then BL32_SOURCES must contain the list
569 # of source files to build BL32
570 # * BL32 is a prebuilt binary: then BL32 must point to the image file
571 # that will be included in the FIP
572 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
573 # over the sources.
Juan Castilloa3487d12015-08-18 14:23:04 +0100574endif
575
Douglas Raillard306593d2017-02-24 18:14:15 +0000576################################################################################
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500577# Include rmmd Makefile if RME is enabled
578################################################################################
579
580ifneq (${ENABLE_RME},0)
581ifneq (${ARCH},aarch64)
582 $(error ENABLE_RME requires AArch64)
583endif
Marc Bonniciabaac162021-12-01 18:00:40 +0000584ifeq ($(SPMC_AT_EL3),1)
585 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
586endif
Zelalem Aweke4d37db82021-07-11 18:33:20 -0500587include services/std_svc/rmmd/rmmd.mk
588$(warning "RME is an experimental feature")
589endif
590
591################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100592# Include the platform specific Makefile after the SPD Makefile (the platform
593# makefile may use all previous definitions in this file)
594################################################################################
Jeenu Viswambharane5c39fd2014-05-16 11:38:10 +0100595
Dan Handley81be1002015-03-27 17:44:35 +0000596include ${PLAT_MAKEFILE_FULL}
Jon Medhurst66573cb2014-02-13 15:19:28 +0000597
Masahiro Yamadae2395b42017-11-04 03:12:28 +0900598$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
599
Etienne Carriere1374fcb2017-11-08 13:48:40 +0100600ifeq (${ARM_ARCH_MAJOR},7)
601include make_helpers/armv7-a-cpus.mk
602endif
603
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900604PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
605ifneq ($(PIE_FOUND),)
606 TF_CFLAGS += -fno-PIE
Samuel Holland9286c022022-04-08 21:56:02 -0500607ifneq ($(findstring gcc,$(notdir $(LD))),)
608 TF_LDFLAGS += -no-pie
609endif
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900610endif
611
612ifneq ($(findstring gcc,$(notdir $(LD))),)
613 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
Soby Mathew078f1a42018-08-28 11:13:55 +0100614else
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900615 PIE_LDFLAGS += -pie --no-dynamic-linker
616endif
617
618ifeq ($(ENABLE_PIE),1)
Masahiro Yamada65d699d2020-01-17 13:45:02 +0900619ifeq ($(BL2_AT_EL3),1)
620ifneq ($(BL2_IN_XIP_MEM),1)
621 BL2_CFLAGS += -fpie
622 BL2_LDFLAGS += $(PIE_LDFLAGS)
623endif
624endif
Masahiro Yamadac3ca8812020-01-17 13:44:37 +0900625 BL31_CFLAGS += -fpie
626 BL31_LDFLAGS += $(PIE_LDFLAGS)
Masahiro Yamadade634f82020-01-17 13:45:14 +0900627 BL32_CFLAGS += -fpie
628 BL32_LDFLAGS += $(PIE_LDFLAGS)
629endif
Soby Mathew078f1a42018-08-28 11:13:55 +0100630
Masahiro Yamada003dd762020-03-26 13:18:48 +0900631ifeq (${ARCH},aarch64)
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900632BL1_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900633ifeq ($(BL2_AT_EL3),1)
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900634BL2_CPPFLAGS += -DIMAGE_AT_EL3
Masahiro Yamada003dd762020-03-26 13:18:48 +0900635else
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900636BL2_CPPFLAGS += -DIMAGE_AT_EL1
Masahiro Yamada003dd762020-03-26 13:18:48 +0900637endif
Masahiro Yamadaf1441572020-04-01 14:20:58 +0900638BL2U_CPPFLAGS += -DIMAGE_AT_EL1
639BL31_CPPFLAGS += -DIMAGE_AT_EL3
640BL32_CPPFLAGS += -DIMAGE_AT_EL1
Masahiro Yamada003dd762020-03-26 13:18:48 +0900641endif
642
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000643# Include the CPU specific operations makefile, which provides default
644# values for all CPU errata workarounds and CPU specific optimisations.
645# This can be overridden by the platform.
Soby Mathew937488b2014-09-22 14:13:34 +0100646include lib/cpus/cpu-ops.mk
Soby Mathew802f8652014-08-14 16:19:29 +0100647
dp-armcdd03cb2017-02-15 11:07:55 +0000648ifeq (${ARCH},aarch32)
649NEED_BL32 := yes
650
651################################################################################
652# Build `AARCH32_SP` as BL32 image for AArch32
653################################################################################
654ifneq (${AARCH32_SP},none)
655# We expect to locate an sp.mk under the specified AARCH32_SP directory
656AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
657
658ifeq (${AARCH32_SP_MAKE},)
659 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
660endif
661
662$(info Including ${AARCH32_SP_MAKE})
663include ${AARCH32_SP_MAKE}
664endif
665
Varun Wadekar3f9002c2019-01-31 09:22:30 -0800666endif
667
668################################################################################
669# Include libc if not overridden
670################################################################################
671ifeq (${OVERRIDE_LIBC},0)
672include lib/libc/libc.mk
dp-armcdd03cb2017-02-15 11:07:55 +0000673endif
Juan Castilloa3487d12015-08-18 14:23:04 +0100674
675################################################################################
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000676# Check incompatible options
677################################################################################
678
679ifdef EL3_PAYLOAD_BASE
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100680 ifdef PRELOADED_BL33_BASE
681 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
682 incompatible build options. EL3_PAYLOAD_BASE has priority.")
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000683 endif
Qixiang Xube9bd9d2017-08-24 11:03:23 +0800684 ifneq (${GENERATE_COT},0)
685 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
686 endif
687 ifneq (${TRUSTED_BOARD_BOOT},0)
688 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
689 endif
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000690endif
691
692ifeq (${NEED_BL33},yes)
693 ifdef EL3_PAYLOAD_BASE
694 $(warning "BL33 image is not needed when option \
695 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
696 endif
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100697 ifdef PRELOADED_BL33_BASE
698 $(warning "BL33 image is not needed when option \
699 PRELOADED_BL33_BASE is used and won't be added to the FIP \
700 file.")
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000701 endif
702endif
703
Jeenu Viswambharan7ed2cbc2017-01-06 16:14:42 +0000704# When building for systems with hardware-assisted coherency, there's no need to
705# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
706ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
707$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
708endif
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100709
Jiafei Pan43a7bf42018-03-21 07:20:09 +0000710#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1.
711ifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1)
712$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled")
713endif
714
Jeenu Viswambharan9a7ce2f2018-04-04 16:07:11 +0100715# For RAS_EXTENSION, require that EAs are handled in EL3 first
716ifeq ($(RAS_EXTENSION),1)
717 ifneq ($(HANDLE_EA_EL3_FIRST),1)
718 $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1)
719 endif
720endif
721
Jeenu Viswambharanf00da742017-12-08 12:13:51 +0000722# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
723ifeq ($(FAULT_INJECTION_SUPPORT),1)
724 ifneq ($(RAS_EXTENSION),1)
725 $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
726 endif
727endif
728
Roberto Vargas025946a2018-09-24 17:20:48 +0100729# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
Soby Mathew9fe88042018-03-26 12:43:37 +0100730ifeq ($(DYN_DISABLE_AUTH), 1)
731 ifeq (${TRUSTED_BOARD_BOOT}, 0)
732 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
733 endif
Soby Mathew9fe88042018-03-26 12:43:37 +0100734endif
735
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +0100736ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
737# Support authentication verification and hash calculation
738 CRYPTO_SUPPORT := 3
739else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
740# Support authentication verification and hash calculation
741 CRYPTO_SUPPORT := 3
742else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
743# Support hash calculation only
744 CRYPTO_SUPPORT := 2
745else ifeq (${TRUSTED_BOARD_BOOT},1)
746# Support authentication verification only
Manish V Badarkhe5181d602022-01-08 22:56:06 +0000747 CRYPTO_SUPPORT := 1
748else
749 CRYPTO_SUPPORT := 0
750endif
751
Balint Dobszayd0dbd5e2019-12-18 15:28:00 +0100752# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
753ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
Manish Pandey34a305e2021-10-21 21:53:49 +0100754$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
Manish V Badarkhead339892020-06-29 10:32:53 +0100755endif
756
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000757# If pointer authentication is used in the firmware, make sure that all the
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100758# registers associated to it are also saved and restored.
759# 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 +0000760ifeq ($(ENABLE_PAUTH),1)
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100761 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
762 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
Alexei Fedorov2831d582019-03-13 11:05:07 +0000763 endif
Alexei Fedorov90f2e882019-05-24 12:17:09 +0100764endif
765
766ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
767 ifneq (${ARCH},aarch64)
768 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +0000769 endif
770endif
771
Justin Chadwell1c7c13a2019-07-18 14:25:33 +0100772ifeq ($(CTX_INCLUDE_MTE_REGS),1)
773 ifneq (${ARCH},aarch64)
774 $(error CTX_INCLUDE_MTE_REGS requires AArch64)
Justin Chadwell1c7c13a2019-07-18 14:25:33 +0100775 endif
776endif
777
Manish V Badarkhe99575e42021-06-25 23:28:59 +0100778ifeq ($(PSA_FWU_SUPPORT),1)
779 $(info PSA_FWU_SUPPORT is an experimental feature)
780endif
781
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +0000782ifeq ($(FEATURE_DETECTION),1)
783 $(info FEATURE_DETECTION is an experimental feature)
784endif
785
Petre-Ionut Tudore5a6fef2019-11-07 15:18:03 +0000786ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
787 ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
788 $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
789 endif
790endif
791
Sumit Garg392e4df2019-11-15 10:43:00 +0530792ifneq (${DECRYPTION_SUPPORT},none)
793 ifeq (${TRUSTED_BOARD_BOOT}, 0)
794 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
Sumit Garg392e4df2019-11-15 10:43:00 +0530795 endif
796endif
797
johpow0181865962022-01-28 17:06:20 -0600798# Ensure that no Aarch64-only features are enabled in Aarch32 build
johpow019baade32021-07-08 14:14:00 -0500799ifeq (${ARCH},aarch32)
johpow0181865962022-01-28 17:06:20 -0600800
801 # SME/SVE only supported on AArch64
johpow019baade32021-07-08 14:14:00 -0500802 ifeq (${ENABLE_SME_FOR_NS},1)
803 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
804 endif
805 ifeq (${ENABLE_SVE_FOR_NS},1)
806 # Warning instead of error due to CI dependency on this
Yann Gautier7d917672021-11-19 11:35:46 +0100807 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
johpow019baade32021-07-08 14:14:00 -0500808 endif
johpow0181865962022-01-28 17:06:20 -0600809
Juan Pablo Conde42305f22022-07-12 16:40:29 -0400810 # BRBE is not supported in AArch32
johpow0181865962022-01-28 17:06:20 -0600811 ifeq (${ENABLE_BRBE_FOR_NS},1)
812 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
813 endif
814
Juan Pablo Conde42305f22022-07-12 16:40:29 -0400815 # FEAT_RNG_TRAP is not supported in AArch32
816 ifeq (${ENABLE_FEAT_RNG_TRAP},1)
817 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
818 endif
johpow019baade32021-07-08 14:14:00 -0500819endif
820
821# Ensure ENABLE_RME is not used with SME
822ifeq (${ENABLE_RME},1)
823 ifeq (${ENABLE_SME_FOR_NS},1)
824 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
825 endif
826endif
827
828# Secure SME/SVE requires the non-secure component as well
829ifeq (${ENABLE_SME_FOR_SWD},1)
830 ifeq (${ENABLE_SME_FOR_NS},0)
831 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
832 endif
833endif
834ifeq (${ENABLE_SVE_FOR_SWD},1)
835 ifeq (${ENABLE_SVE_FOR_NS},0)
836 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
837 endif
838endif
839
840# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
841# its own context management including FPU registers.
842ifeq (${CTX_INCLUDE_FPREGS},1)
843 ifeq (${ENABLE_SME_FOR_NS},1)
844 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
845 endif
846 ifeq (${ENABLE_SVE_FOR_NS},1)
847 # Warning instead of error due to CI dependency on this
848 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
849 $(warning "Forced ENABLE_SVE_FOR_NS=0")
850 override ENABLE_SVE_FOR_NS := 0
851 endif
852endif
853
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +0000854ifeq ($(DRTM_SUPPORT),1)
855 $(info DRTM_SUPPORT is an experimental feature)
856endif
857
Chris Kayd02c2312022-09-29 16:21:24 +0100858ifeq (${ENABLE_RME},1)
859 ifneq (${SEPARATE_CODE_AND_RODATA},1)
860 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
861 endif
862endif
863
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000864################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +0100865# Process platform overrideable behaviour
866################################################################################
867
Manish Pandeyb0e7efa2021-10-06 10:59:52 +0100868ifdef BL1_SOURCES
869NEED_BL1 := yes
870endif
871
Jon Medhurst66573cb2014-02-13 15:19:28 +0000872ifdef BL2_SOURCES
Manish Pandeyb0e7efa2021-10-06 10:59:52 +0100873 NEED_BL2 := yes
874
875 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
876 # Certificate generation tools. This flag can be overridden by the platform.
877 ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000878 # If booting an EL3 payload there is no need for a BL33 image
879 # in the FIP file.
880 NEED_BL33 := no
881 else
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +0100882 ifdef PRELOADED_BL33_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +0000883 # If booting a BL33 preloaded image there is no need of
884 # another one in the FIP file.
885 NEED_BL33 := no
886 else
887 NEED_BL33 ?= yes
888 endif
889 endif
Jon Medhurst66573cb2014-02-13 15:19:28 +0000890endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100891
Manish Pandeyb0e7efa2021-10-06 10:59:52 +0100892ifdef BL2U_SOURCES
893NEED_BL2U := yes
894endif
895
Masahiro Yamadae76b4f82017-04-05 19:11:41 +0900896# If SCP_BL2 is given, we always want FIP to include it.
897ifdef SCP_BL2
898 NEED_SCP_BL2 := yes
899endif
900
Soby Mathewbf169232017-11-14 14:10:10 +0000901# For AArch32, BL31 is not currently supported.
902ifneq (${ARCH},aarch32)
903 ifdef BL31_SOURCES
904 # When booting an EL3 payload, there is no need to compile the BL31 image nor
905 # put it in the FIP.
906 ifndef EL3_PAYLOAD_BASE
907 NEED_BL31 := yes
908 endif
909 endif
910endif
911
Juan Castilloa3487d12015-08-18 14:23:04 +0100912# Process TBB related flags
913ifneq (${GENERATE_COT},0)
914 # Common cert_create options
915 ifneq (${CREATE_KEYS},0)
916 $(eval CRT_ARGS += -n)
Yatharth Kochard1a93432015-10-12 12:33:47 +0100917 $(eval FWU_CRT_ARGS += -n)
Juan Castilloa3487d12015-08-18 14:23:04 +0100918 ifneq (${SAVE_KEYS},0)
919 $(eval CRT_ARGS += -k)
Yatharth Kochard1a93432015-10-12 12:33:47 +0100920 $(eval FWU_CRT_ARGS += -k)
Juan Castilloa3487d12015-08-18 14:23:04 +0100921 endif
922 endif
923 # Include TBBR makefile (unless the platform indicates otherwise)
924 ifeq (${INCLUDE_TBBR_MK},1)
925 include make_helpers/tbbr/tbbr_tools.mk
926 endif
Ryan Harkin25cff832014-01-13 12:37:03 +0000927endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100928
Masahiro Yamada4d87eb42016-12-25 13:52:22 +0900929ifneq (${FIP_ALIGN},0)
930FIP_ARGS += --align ${FIP_ALIGN}
931endif
932
Manish Pandeyb0e7efa2021-10-06 10:59:52 +0100933ifdef FDT_SOURCES
934NEED_FDT := yes
935endif
936
Juan Castilloa3487d12015-08-18 14:23:04 +0100937################################################################################
Michalis Pappas0f223c52018-03-20 13:01:27 +0800938# Include libraries' Makefile that are used in all BL
939################################################################################
940
941include lib/stack_protector/stack_protector.mk
942
943################################################################################
dp-arm4972ec52016-05-25 16:20:20 +0100944# Auxiliary tools (fiptool, cert_create, etc)
Juan Castilloa3487d12015-08-18 14:23:04 +0100945################################################################################
Achin Gupta375f5382014-02-18 18:12:48 +0000946
Juan Castilloa3487d12015-08-18 14:23:04 +0100947# Variables for use with Certificate Generation Tool
948CRTTOOLPATH ?= tools/cert_create
Evan Lloyd004c9a52015-12-03 11:35:40 +0000949CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
Achin Gupta375f5382014-02-18 18:12:48 +0000950
Sumit Gargb6c4b3c2019-11-11 18:46:36 +0530951# Variables for use with Firmware Encryption Tool
952ENCTOOLPATH ?= tools/encrypt_fw
953ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
954
Juan Castilloa3487d12015-08-18 14:23:04 +0100955# Variables for use with Firmware Image Package
dp-arm4972ec52016-05-25 16:20:20 +0100956FIPTOOLPATH ?= tools/fiptool
957FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
James Morrisseyeaaeece2013-11-01 13:56:59 +0000958
Antonio Nino Diaza830a4d2018-11-27 14:58:04 +0000959# Variables for use with sptool
960SPTOOLPATH ?= tools/sptool
J-Alvesef8e0982022-03-22 16:28:51 +0000961SPTOOL ?= ${SPTOOLPATH}/sptool.py
Manish Pandey3f90ad72020-01-14 11:52:05 +0000962SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
Antonio Nino Diaza830a4d2018-11-27 14:58:04 +0000963
Roberto Vargase92111a2018-05-22 16:05:42 +0100964# Variables for use with ROMLIB
965ROMLIBPATH ?= lib/romlib
966
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +0100967# Variable for use with Python
968PYTHON ?= python3
969
970# Variables for use with PRINT_MEMORY_MAP
971PRINT_MEMORY_MAP_PATH ?= tools/memory
972PRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
973
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -0600974# Variables for use with documentation build using Sphinx tool
975DOCS_PATH ?= docs
976
Abdul Halim, Muhammad Hadi Asyrafif3a5d022020-06-29 12:15:27 +0800977# Defination of SIMICS flag
978SIMICS_BUILD ?= 0
979
Soby Mathew574e01e2017-02-14 10:05:07 +0000980################################################################################
981# Include BL specific makefiles
982################################################################################
Manish Pandeyb0e7efa2021-10-06 10:59:52 +0100983
984ifeq (${NEED_BL1},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +0000985include bl1/bl1.mk
986endif
987
Manish Pandeyb0e7efa2021-10-06 10:59:52 +0100988ifeq (${NEED_BL2},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +0000989include bl2/bl2.mk
990endif
991
Manish Pandeyb0e7efa2021-10-06 10:59:52 +0100992ifeq (${NEED_BL2U},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +0000993include bl2u/bl2u.mk
994endif
995
Soby Mathewbf169232017-11-14 14:10:10 +0000996ifeq (${NEED_BL31},yes)
Soby Mathew574e01e2017-02-14 10:05:07 +0000997include bl31/bl31.mk
998endif
Nishanth Menon4ac02ba2016-10-14 01:13:57 +0000999
Soby Mathew574e01e2017-02-14 10:05:07 +00001000################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001001# Build options checks
1002################################################################################
1003
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001004$(eval $(call assert_booleans,\
1005 $(sort \
1006 ALLOW_RO_XLAT_TABLES \
Balint Dobszay719ba9c2021-03-26 16:23:18 +01001007 BL2_ENABLE_SP_LOAD \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001008 COLD_BOOT_SINGLE_CPU \
1009 CREATE_KEYS \
1010 CTX_INCLUDE_AARCH32_REGS \
1011 CTX_INCLUDE_FPREGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001012 CTX_INCLUDE_EL2_REGS \
1013 DEBUG \
Javier Almansa Sobrinof3a4c542020-11-23 18:38:15 +00001014 DISABLE_MTPMU \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001015 DYN_DISABLE_AUTH \
1016 EL3_EXCEPTION_HANDLING \
1017 ENABLE_AMU \
Chris Kay925fda42021-05-25 10:42:56 +01001018 ENABLE_AMU_AUXILIARY_COUNTERS \
Chris Kayf11909f2021-08-19 11:21:52 +01001019 ENABLE_AMU_FCONF \
johpow01fa59c6f2020-10-02 13:41:11 -05001020 AMU_RESTRICT_COUNTERS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001021 ENABLE_ASSERTIONS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001022 ENABLE_PIE \
1023 ENABLE_PMF \
1024 ENABLE_PSCI_STAT \
1025 ENABLE_RUNTIME_INSTRUMENTATION \
johpow019baade32021-07-08 14:14:00 -05001026 ENABLE_SME_FOR_NS \
1027 ENABLE_SME_FOR_SWD \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001028 ENABLE_SPE_FOR_LOWER_ELS \
1029 ENABLE_SVE_FOR_NS \
Max Shvetsovc4502772021-03-22 11:59:37 +00001030 ENABLE_SVE_FOR_SWD \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001031 ERROR_DEPRECATED \
1032 FAULT_INJECTION_SUPPORT \
1033 GENERATE_COT \
1034 GICV2_G0_FOR_EL3 \
1035 HANDLE_EA_EL3_FIRST \
1036 HW_ASSISTED_COHERENCY \
1037 INVERTED_MEMMAP \
1038 MEASURED_BOOT \
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001039 DRTM_SUPPORT \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001040 NS_TIMER_SWITCH \
1041 OVERRIDE_LIBC \
1042 PL011_GENERIC_UART \
Tamas Banc9ccc272022-01-18 16:20:47 +01001043 PLAT_RSS_NOT_SUPPORTED \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001044 PROGRAMMABLE_RESET_ADDRESS \
1045 PSCI_EXTENDED_STATE_ID \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001046 RESET_TO_BL31 \
Jorge Ramirez-Ortiz7538ef92022-04-15 11:46:47 +02001047 RESET_TO_BL31_WITH_PARAMS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001048 SAVE_KEYS \
1049 SEPARATE_CODE_AND_RODATA \
Jiafei Pan0824b452022-02-24 10:47:33 +08001050 SEPARATE_BL2_NOLOAD_REGION \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001051 SEPARATE_NOBITS_REGION \
1052 SPIN_ON_BL1_EXIT \
1053 SPM_MM \
Marc Bonniciabaac162021-12-01 18:00:40 +00001054 SPMC_AT_EL3 \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001055 SPMD_SPM_AT_SEL2 \
1056 TRUSTED_BOARD_BOOT \
1057 USE_COHERENT_MEM \
1058 USE_DEBUGFS \
1059 ARM_IO_IN_DTB \
1060 SDEI_IN_FCONF \
1061 SEC_INT_DESC_IN_FCONF \
1062 USE_ROMLIB \
1063 USE_TBBR_DEFS \
1064 WARMBOOT_ENABLE_DCACHE_EARLY \
1065 BL2_AT_EL3 \
1066 BL2_IN_XIP_MEM \
1067 BL2_INV_DCACHE \
1068 USE_SPINLOCK_CAS \
1069 ENCRYPT_BL31 \
1070 ENCRYPT_BL32 \
1071 ERRATA_SPECULATIVE_AT \
Manish Pandey7c6fcb42022-09-27 14:30:34 +01001072 RAS_TRAP_NS_ERR_REC_ACCESS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001073 COT_DESC_IN_DTB \
1074 USE_SP804_TIMER \
Manish V Badarkhe99575e42021-06-25 23:28:59 +01001075 PSA_FWU_SUPPORT \
Manish V Badarkhef356f7e2021-06-29 11:44:20 +01001076 ENABLE_SYS_REG_TRACE_FOR_NS \
Chris Kay03be39d2021-05-05 13:38:30 +01001077 ENABLE_MPMM \
1078 ENABLE_MPMM_FCONF \
Abdul Halim, Muhammad Hadi Asyrafif3a5d022020-06-29 12:15:27 +08001079 SIMICS_BUILD \
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +00001080 FEATURE_DETECTION \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001081)))
Dan Handley81be1002015-03-27 17:44:35 +00001082
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001083$(eval $(call assert_numerics,\
1084 $(sort \
1085 ARM_ARCH_MAJOR \
1086 ARM_ARCH_MINOR \
1087 BRANCH_PROTECTION \
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +00001088 CTX_INCLUDE_PAUTH_REGS \
1089 CTX_INCLUDE_MTE_REGS \
1090 CTX_INCLUDE_NEVE_REGS \
Manish V Badarkhec9fdaf62022-06-20 15:32:38 +01001091 CRYPTO_SUPPORT \
Jayanth Dodderi Chidanand69316752022-05-09 12:33:03 +01001092 ENABLE_BRBE_FOR_NS \
Jayanth Dodderi Chidananda793ccc2022-05-19 14:08:28 +01001093 ENABLE_TRBE_FOR_NS \
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +00001094 ENABLE_BTI \
1095 ENABLE_PAUTH \
1096 ENABLE_FEAT_AMUv1 \
1097 ENABLE_FEAT_AMUv1p1 \
1098 ENABLE_FEAT_CSV2_2 \
1099 ENABLE_FEAT_DIT \
1100 ENABLE_FEAT_ECV \
1101 ENABLE_FEAT_FGT \
1102 ENABLE_FEAT_HCX \
1103 ENABLE_FEAT_PAN \
1104 ENABLE_FEAT_RNG \
Juan Pablo Conde42305f22022-07-12 16:40:29 -04001105 ENABLE_FEAT_RNG_TRAP \
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +00001106 ENABLE_FEAT_SB \
1107 ENABLE_FEAT_SEL2 \
1108 ENABLE_FEAT_VHE \
1109 ENABLE_MPAM_FOR_LOWER_ELS \
1110 ENABLE_RME \
1111 ENABLE_TRF_FOR_NS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001112 FW_ENC_STATUS \
Manish V Badarkhe2bb45ff2021-03-16 10:01:27 +00001113 NR_OF_FW_BANKS \
1114 NR_OF_IMAGES_IN_FW_BANK \
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +00001115 RAS_EXTENSION \
Jayanth Dodderi Chidanand4b5489c2022-03-28 15:28:55 +01001116 TWED_DELAY \
1117 ENABLE_FEAT_TWED \
Mark Brown64869972022-04-20 18:14:32 +01001118 SVE_VECTOR_LEN \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001119)))
Jeenu Viswambharanfca76802017-01-16 16:52:35 +00001120
Justin Chadwellf9b32c12019-07-29 17:13:10 +01001121ifdef KEY_SIZE
1122 $(eval $(call assert_numeric,KEY_SIZE))
1123endif
1124
Justin Chadwell83e04882019-08-20 11:01:52 +01001125ifeq ($(filter $(SANITIZE_UB), on off trap),)
1126 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
1127endif
1128
Juan Castilloa3487d12015-08-18 14:23:04 +01001129################################################################################
1130# Add definitions to the cpp preprocessor based on the current build options.
1131# This is done after including the platform specific makefile to allow the
1132# platform to overwrite the default options
1133################################################################################
Jeenu Viswambharand1b60152014-05-12 15:28:47 +01001134
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001135$(eval $(call add_defines,\
1136 $(sort \
1137 ALLOW_RO_XLAT_TABLES \
1138 ARM_ARCH_MAJOR \
1139 ARM_ARCH_MINOR \
Balint Dobszay719ba9c2021-03-26 16:23:18 +01001140 BL2_ENABLE_SP_LOAD \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001141 COLD_BOOT_SINGLE_CPU \
1142 CTX_INCLUDE_AARCH32_REGS \
1143 CTX_INCLUDE_FPREGS \
1144 CTX_INCLUDE_PAUTH_REGS \
1145 EL3_EXCEPTION_HANDLING \
1146 CTX_INCLUDE_MTE_REGS \
1147 CTX_INCLUDE_EL2_REGS \
Arunachalam Ganapathydd3ec7e2020-05-28 11:57:09 +01001148 CTX_INCLUDE_NEVE_REGS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001149 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
Javier Almansa Sobrinof3a4c542020-11-23 18:38:15 +00001150 DISABLE_MTPMU \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001151 ENABLE_AMU \
Chris Kay925fda42021-05-25 10:42:56 +01001152 ENABLE_AMU_AUXILIARY_COUNTERS \
Chris Kayf11909f2021-08-19 11:21:52 +01001153 ENABLE_AMU_FCONF \
johpow01fa59c6f2020-10-02 13:41:11 -05001154 AMU_RESTRICT_COUNTERS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001155 ENABLE_ASSERTIONS \
1156 ENABLE_BTI \
1157 ENABLE_MPAM_FOR_LOWER_ELS \
1158 ENABLE_PAUTH \
1159 ENABLE_PIE \
1160 ENABLE_PMF \
1161 ENABLE_PSCI_STAT \
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001162 ENABLE_RME \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001163 ENABLE_RUNTIME_INSTRUMENTATION \
johpow019baade32021-07-08 14:14:00 -05001164 ENABLE_SME_FOR_NS \
1165 ENABLE_SME_FOR_SWD \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001166 ENABLE_SPE_FOR_LOWER_ELS \
1167 ENABLE_SVE_FOR_NS \
Max Shvetsovc4502772021-03-22 11:59:37 +00001168 ENABLE_SVE_FOR_SWD \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001169 ENCRYPT_BL31 \
1170 ENCRYPT_BL32 \
1171 ERROR_DEPRECATED \
1172 FAULT_INJECTION_SUPPORT \
1173 GICV2_G0_FOR_EL3 \
1174 HANDLE_EA_EL3_FIRST \
1175 HW_ASSISTED_COHERENCY \
1176 LOG_LEVEL \
1177 MEASURED_BOOT \
Manish V Badarkhe191a5fc2022-03-02 12:06:35 +00001178 DRTM_SUPPORT \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001179 NS_TIMER_SWITCH \
1180 PL011_GENERIC_UART \
1181 PLAT_${PLAT} \
Tamas Banc9ccc272022-01-18 16:20:47 +01001182 PLAT_RSS_NOT_SUPPORTED \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001183 PROGRAMMABLE_RESET_ADDRESS \
1184 PSCI_EXTENDED_STATE_ID \
1185 RAS_EXTENSION \
1186 RESET_TO_BL31 \
Jorge Ramirez-Ortiz7538ef92022-04-15 11:46:47 +02001187 RESET_TO_BL31_WITH_PARAMS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001188 SEPARATE_CODE_AND_RODATA \
Jiafei Pan0824b452022-02-24 10:47:33 +08001189 SEPARATE_BL2_NOLOAD_REGION \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001190 SEPARATE_NOBITS_REGION \
1191 RECLAIM_INIT_CODE \
1192 SPD_${SPD} \
1193 SPIN_ON_BL1_EXIT \
1194 SPM_MM \
Marc Bonniciabaac162021-12-01 18:00:40 +00001195 SPMC_AT_EL3 \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001196 SPMD_SPM_AT_SEL2 \
1197 TRUSTED_BOARD_BOOT \
Manish V Badarkhe5181d602022-01-08 22:56:06 +00001198 CRYPTO_SUPPORT \
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -05001199 TRNG_SUPPORT \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001200 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 BL2_AT_EL3 \
1209 BL2_IN_XIP_MEM \
1210 BL2_INV_DCACHE \
1211 USE_SPINLOCK_CAS \
1212 ERRATA_SPECULATIVE_AT \
Manish Pandey7c6fcb42022-09-27 14:30:34 +01001213 RAS_TRAP_NS_ERR_REC_ACCESS \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001214 COT_DESC_IN_DTB \
1215 USE_SP804_TIMER \
Tomas Pilarde164b02020-10-29 13:01:16 +00001216 ENABLE_FEAT_RNG \
Juan Pablo Conde42305f22022-07-12 16:40:29 -04001217 ENABLE_FEAT_RNG_TRAP \
Chris Kay08fec332021-03-09 13:34:35 +00001218 ENABLE_FEAT_SB \
Daniel Boulby928747f2021-05-25 18:09:34 +01001219 ENABLE_FEAT_DIT \
Manish V Badarkhe2bb45ff2021-03-16 10:01:27 +00001220 NR_OF_FW_BANKS \
1221 NR_OF_IMAGES_IN_FW_BANK \
Manish V Badarkhe99575e42021-06-25 23:28:59 +01001222 PSA_FWU_SUPPORT \
johpow0181865962022-01-28 17:06:20 -06001223 ENABLE_BRBE_FOR_NS \
Manish V Badarkhe20df29c2021-07-02 09:10:56 +01001224 ENABLE_TRBE_FOR_NS \
Manish V Badarkhef356f7e2021-06-29 11:44:20 +01001225 ENABLE_SYS_REG_TRACE_FOR_NS \
Manish V Badarkhe51a97112021-07-08 09:33:18 +01001226 ENABLE_TRF_FOR_NS \
johpow01f91e59f2021-08-04 19:38:18 -05001227 ENABLE_FEAT_HCX \
Chris Kay03be39d2021-05-05 13:38:30 +01001228 ENABLE_MPMM \
1229 ENABLE_MPMM_FCONF \
Jayanth Dodderi Chidanand13ae0f42021-11-25 14:59:30 +00001230 ENABLE_FEAT_FGT \
1231 ENABLE_FEAT_AMUv1 \
1232 ENABLE_FEAT_ECV \
Abdul Halim, Muhammad Hadi Asyrafif3a5d022020-06-29 12:15:27 +08001233 SIMICS_BUILD \
Jayanth Dodderi Chidanand9461a892022-01-17 18:57:17 +00001234 ENABLE_FEAT_AMUv1p1 \
1235 ENABLE_FEAT_SEL2 \
1236 ENABLE_FEAT_VHE \
1237 ENABLE_FEAT_CSV2_2 \
1238 ENABLE_FEAT_PAN \
1239 FEATURE_DETECTION \
Jayanth Dodderi Chidanand4b5489c2022-03-28 15:28:55 +01001240 TWED_DELAY \
1241 ENABLE_FEAT_TWED \
Leonardo Sandoval65fca7c2020-09-10 12:18:27 -05001242)))
Jeenu Viswambharan615ff392016-10-24 14:31:51 +01001243
Justin Chadwell83e04882019-08-20 11:01:52 +01001244ifeq (${SANITIZE_UB},trap)
1245 $(eval $(call add_define,MONITOR_TRAPS))
1246endif
1247
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001248# Define the EL3_PAYLOAD_BASE flag only if it is provided.
1249ifdef EL3_PAYLOAD_BASE
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001250 $(eval $(call add_define,EL3_PAYLOAD_BASE))
1251else
Antonio Nino Diaz2b8277b2016-04-06 17:31:57 +01001252 # Define the PRELOADED_BL33_BASE flag only if it is provided and
1253 # EL3_PAYLOAD_BASE is not defined, as it has priority.
1254 ifdef PRELOADED_BL33_BASE
1255 $(eval $(call add_define,PRELOADED_BL33_BASE))
Antonio Nino Diazfaf573a2016-02-15 14:53:10 +00001256 endif
Sandrine Bailleux03897bb2015-11-26 16:31:34 +00001257endif
Soby Mathew85dbf5a2015-04-07 12:16:56 +01001258
Soby Mathew9fe88042018-03-26 12:43:37 +01001259# Define the DYN_DISABLE_AUTH flag only if set.
1260ifeq (${DYN_DISABLE_AUTH},1)
1261$(eval $(call add_define,DYN_DISABLE_AUTH))
1262endif
1263
Varun Wadekar4d034c52019-01-11 14:47:48 -08001264ifneq ($(findstring armlink,$(notdir $(LD))),)
1265$(eval $(call add_define,USE_ARM_LINK))
1266endif
1267
Manish Pandey3f90ad72020-01-14 11:52:05 +00001268# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
Manish Pandey3f90ad72020-01-14 11:52:05 +00001269ifeq (${SPD},spmd)
Olivier Deprez042db532020-03-19 09:27:11 +01001270ifdef SP_LAYOUT_FILE
Manish Pandey3f90ad72020-01-14 11:52:05 +00001271 -include $(BUILD_PLAT)/sp_gen.mk
1272 FIP_DEPS += sp
Manish Pandeyaaaeb312020-05-26 23:59:36 +01001273 CRT_DEPS += sp
Manish Pandey3f90ad72020-01-14 11:52:05 +00001274 NEED_SP_PKG := yes
1275else
Olivier Deprez042db532020-03-19 09:27:11 +01001276 ifeq (${SPMD_SPM_AT_SEL2},1)
1277 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
1278 endif
Manish Pandey3f90ad72020-01-14 11:52:05 +00001279endif
1280endif
1281
Juan Castilloa3487d12015-08-18 14:23:04 +01001282################################################################################
Juan Castilloa3487d12015-08-18 14:23:04 +01001283# Build targets
1284################################################################################
Achin Gupta4f6ad662013-10-25 09:08:21 +01001285
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301286.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 +01001287.SUFFIXES:
Achin Gupta4f6ad662013-10-25 09:08:21 +01001288
Juan Castilloa3487d12015-08-18 14:23:04 +01001289all: msg_start
Harry Liebelf58ad362014-01-10 18:00:33 +00001290
Juan Castilloa3487d12015-08-18 14:23:04 +01001291msg_start:
1292 @echo "Building ${PLAT}"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001293
Soby Mathew18a62042015-10-26 14:29:21 +00001294ifeq (${ERROR_DEPRECATED},0)
Julius Werner53456fc2019-07-09 13:49:11 -07001295# Check if deprecated declarations and cpp warnings should be treated as error or not.
Varun Wadekar4d034c52019-01-11 14:47:48 -08001296ifneq ($(findstring clang,$(notdir $(CC))),)
1297 CPPFLAGS += -Wno-error=deprecated-declarations
1298else
Dan Handley6fa89a22018-02-27 16:03:58 +00001299 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
Soby Mathew18a62042015-10-26 14:29:21 +00001300endif
Julius Werner53456fc2019-07-09 13:49:11 -07001301endif # !ERROR_DEPRECATED
Soby Mathew18a62042015-10-26 14:29:21 +00001302
Roberto Vargase92111a2018-05-22 16:05:42 +01001303$(eval $(call MAKE_LIB_DIRS))
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001304$(eval $(call MAKE_LIB,c))
Roberto Vargas21360f32018-05-08 10:27:10 +01001305
Juan Castilloa3487d12015-08-18 14:23:04 +01001306# Expand build macros for the different images
1307ifeq (${NEED_BL1},yes)
Chris Kay0a542ec2021-09-28 15:44:19 +01001308BL1_SOURCES := $(sort ${BL1_SOURCES})
1309
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001310$(eval $(call MAKE_BL,bl1))
Juan Castilloa3487d12015-08-18 14:23:04 +01001311endif
Juan Castillo11abdcd2014-10-21 11:30:42 +01001312
Juan Castilloa3487d12015-08-18 14:23:04 +01001313ifeq (${NEED_BL2},yes)
Roberto Vargas53c052b2018-01-02 11:23:41 +00001314ifeq (${BL2_AT_EL3}, 0)
1315FIP_BL2_ARGS := tb-fw
1316endif
1317
Chris Kayfb3b0512021-09-28 15:44:37 +01001318BL2_SOURCES := $(sort ${BL2_SOURCES})
1319
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001320$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001321 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
Juan Castilloa3487d12015-08-18 14:23:04 +01001322endif
Juan Castillo11abdcd2014-10-21 11:30:42 +01001323
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001324ifeq (${NEED_SCP_BL2},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001325$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
Masahiro Yamadae76b4f82017-04-05 19:11:41 +09001326endif
1327
Juan Castilloa3487d12015-08-18 14:23:04 +01001328ifeq (${NEED_BL31},yes)
1329BL31_SOURCES += ${SPD_SOURCES}
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001330# Sort BL31 source files to remove duplicates
1331BL31_SOURCES := $(sort ${BL31_SOURCES})
Sumit Gargeec52442019-11-14 16:33:45 +05301332ifneq (${DECRYPTION_SUPPORT},none)
1333$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001334 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
Sumit Gargeec52442019-11-14 16:33:45 +05301335else
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001336$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001337 $(eval $(call MAKE_BL,bl31,soc-fw)))
Juan Castilloa3487d12015-08-18 14:23:04 +01001338endif
Sumit Gargeec52442019-11-14 16:33:45 +05301339endif
Juan Castillo379954c2014-11-04 17:36:40 +00001340
Juan Castillo671b8db2015-11-12 10:59:26 +00001341# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
Masahiro Yamada4d156802018-01-26 11:42:01 +09001342# build system will call TOOL_ADD_IMG to print a warning message and abort the
Juan Castillo671b8db2015-11-12 10:59:26 +00001343# process. Note that the dependency on BL32 applies to the FIP only.
Juan Castilloa3487d12015-08-18 14:23:04 +01001344ifeq (${NEED_BL32},yes)
Madhukar Pappireddyae9677b2020-01-27 13:37:51 -06001345# Sort BL32 source files to remove duplicates
1346BL32_SOURCES := $(sort ${BL32_SOURCES})
Masahiro Yamada6ced1b22018-01-26 11:42:01 +09001347BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
1348
Sumit Gargeec52442019-11-14 16:33:45 +05301349ifneq (${DECRYPTION_SUPPORT},none)
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001350$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
Sumit Gargeec52442019-11-14 16:33:45 +05301351 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
1352else
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001353$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001354 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
Juan Castillo11abdcd2014-10-21 11:30:42 +01001355endif
Sumit Gargeec52442019-11-14 16:33:45 +05301356endif
Juan Castillo11abdcd2014-10-21 11:30:42 +01001357
Zelalem Aweke4d37db82021-07-11 18:33:20 -05001358# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
1359# needs to be built from RMM_SOURCES.
1360ifeq (${NEED_RMM},yes)
1361# Sort RMM source files to remove duplicates
1362RMM_SOURCES := $(sort ${RMM_SOURCES})
1363BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
1364
1365$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
1366 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
1367endif
1368
Juan Castilloa3487d12015-08-18 14:23:04 +01001369# Add the BL33 image if required by the platform
1370ifeq (${NEED_BL33},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001371$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
Juan Castillo9c25a402015-01-13 12:21:04 +00001372endif
1373
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001374ifeq (${NEED_BL2U},yes)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +09001375$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
Zelalem Awekeb44dec12021-07-11 17:25:48 -05001376 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001377endif
1378
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001379# Expand build macros for the different images
1380ifeq (${NEED_FDT},yes)
Soby Mathewab4181d2017-12-14 17:44:56 +00001381 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
Nishanth Menon4ac02ba2016-10-14 01:13:57 +00001382endif
1383
Manish Pandey3f90ad72020-01-14 11:52:05 +00001384# Add Secure Partition packages
1385ifeq (${NEED_SP_PKG},yes)
1386$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
Ruari Phipps571ed6b2020-07-24 16:20:57 +01001387 ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
J-Alvesef8e0982022-03-22 16:28:51 +00001388sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
Manish Pandey3f90ad72020-01-14 11:52:05 +00001389 @${ECHO_BLANK_LINE}
1390 @echo "Built SP Images successfully"
1391 @${ECHO_BLANK_LINE}
1392endif
1393
Ian Spray36eaaf32014-01-30 17:25:28 +00001394locate-checkpatch:
1395ifndef CHECKPATCH
Etienne Carrieref5657572017-08-23 15:44:01 +02001396 $(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 +00001397else
1398ifeq (,$(wildcard ${CHECKPATCH}))
Etienne Carrieref5657572017-08-23 15:44:01 +02001399 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
Ian Spray36eaaf32014-01-30 17:25:28 +00001400endif
1401endif
1402
Achin Gupta4f6ad662013-10-25 09:08:21 +01001403clean:
Juan Castilloa3487d12015-08-18 14:23:04 +01001404 @echo " CLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001405 $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001406ifdef UNIX_MK
Juan Castilloa3487d12015-08-18 14:23:04 +01001407 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001408else
1409# Clear the MAKEFLAGS as we do not want
1410# to pass the gnumake flags to nmake.
1411 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
1412endif
Juan Castilloa3487d12015-08-18 14:23:04 +01001413 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301414 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
Roberto Vargase92111a2018-05-22 16:05:42 +01001415 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001416
James Morrisseyeaaeece2013-11-01 13:56:59 +00001417realclean distclean:
Juan Castilloa3487d12015-08-18 14:23:04 +01001418 @echo " REALCLEAN"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001419 $(call SHELL_REMOVE_DIR,${BUILD_BASE})
1420 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001421ifdef UNIX_MK
Juan Castilloa3487d12015-08-18 14:23:04 +01001422 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001423else
1424# Clear the MAKEFLAGS as we do not want
1425# to pass the gnumake flags to nmake.
1426 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
1427endif
Nicolas Boulenguezdf612a52021-03-31 12:22:45 +02001428 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301429 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
Roberto Vargase92111a2018-05-22 16:05:42 +01001430 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +01001431
Ian Spray36eaaf32014-01-30 17:25:28 +00001432checkcodebase: locate-checkpatch
Juan Castilloa3487d12015-08-18 14:23:04 +01001433 @echo " CHECKING STYLE"
Dan Handley3a355712016-06-02 18:21:02 +01001434 @if test -d .git ; then \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001435 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
Dan Handley3a355712016-06-02 18:21:02 +01001436 while read GIT_FILE ; \
1437 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
1438 done ; \
1439 else \
1440 find . -type f -not -iwholename "*.git*" \
1441 -not -iwholename "*build*" \
1442 -not -iwholename "*libfdt*" \
Roberto Vargas0f8f9852018-05-08 10:27:10 +01001443 -not -iwholename "*libc*" \
Dan Handley3a355712016-06-02 18:21:02 +01001444 -not -iwholename "*docs*" \
Paul Beesleyadfab5b2019-03-07 16:42:31 +00001445 -not -iwholename "*.rst" \
Dan Handley3a355712016-06-02 18:21:02 +01001446 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
1447 fi
Ian Spray36eaaf32014-01-30 17:25:28 +00001448
1449checkpatch: locate-checkpatch
Juan Castilloa3487d12015-08-18 14:23:04 +01001450 @echo " CHECKING STYLE"
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001451 @if test -n "${CHECKPATCH_OPTS}"; then \
1452 echo " with ${CHECKPATCH_OPTS} option(s)"; \
1453 fi
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001454 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
Yann Gautiera10a6852021-11-02 18:03:31 +01001455 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
1456 do \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001457 printf "\n[*] Checking style of '$$commit'\n\n"; \
1458 git log --format=email "$$commit~..$$commit" \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001459 -- ${CHECK_PATHS} | \
1460 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001461 git diff --format=email "$$commit~..$$commit" \
Yann Gautier0c26a2a2019-03-08 15:44:00 +01001462 -- ${CHECK_PATHS} | \
1463 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
Antonio Nino Diaz2cd4b582018-01-29 12:00:31 +00001464 done
Juan Castilloa3487d12015-08-18 14:23:04 +01001465
1466certtool: ${CRTTOOL}
Ian Spray36eaaf32014-01-30 17:25:28 +00001467
Pali Rohár54ff2132020-11-24 15:38:08 +01001468${CRTTOOL}: FORCE
Manish V Badarkhe635482e2020-08-13 05:56:33 +01001469 ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} --no-print-directory -C ${CRTTOOLPATH}
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001470 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001471 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001472 @${ECHO_BLANK_LINE}
Jon Medhurst407a95c2014-02-12 15:54:48 +00001473
Juan Castillo11abdcd2014-10-21 11:30:42 +01001474ifneq (${GENERATE_COT},0)
Juan Castilloa3487d12015-08-18 14:23:04 +01001475certificates: ${CRT_DEPS} ${CRTTOOL}
1476 ${Q}${CRTTOOL} ${CRT_ARGS}
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001477 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001478 @echo "Built $@ successfully"
1479 @echo "Certificates can be found in ${BUILD_PLAT}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001480 @${ECHO_BLANK_LINE}
Juan Castillo11abdcd2014-10-21 11:30:42 +01001481endif
1482
Juan Castilloa3487d12015-08-18 14:23:04 +01001483${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001484 $(eval ${CHECK_FIP_CMD})
dp-arm4972ec52016-05-25 16:20:20 +01001485 ${Q}${FIPTOOL} create ${FIP_ARGS} $@
1486 ${Q}${FIPTOOL} info $@
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001487 @${ECHO_BLANK_LINE}
Juan Castilloa3487d12015-08-18 14:23:04 +01001488 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001489 @${ECHO_BLANK_LINE}
Soby Mathewdbee7fc2014-09-08 17:51:01 +01001490
Yatharth Kochard1a93432015-10-12 12:33:47 +01001491ifneq (${GENERATE_COT},0)
1492fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
1493 ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001494 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001495 @echo "Built $@ successfully"
1496 @echo "FWU certificates can be found in ${BUILD_PLAT}"
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001497 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001498endif
1499
1500${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
Pali Rohára5416ab2020-11-24 16:53:04 +01001501 $(eval ${CHECK_FWU_FIP_CMD})
dp-arm4972ec52016-05-25 16:20:20 +01001502 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
1503 ${Q}${FIPTOOL} info $@
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001504 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001505 @echo "Built $@ successfully"
Evan Lloyd1c5f3602017-04-11 16:52:00 +01001506 @${ECHO_BLANK_LINE}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001507
Juan Castilloa3487d12015-08-18 14:23:04 +01001508fiptool: ${FIPTOOL}
1509fip: ${BUILD_PLAT}/${FIP_NAME}
Yatharth Kochard1a93432015-10-12 12:33:47 +01001510fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
Harry Liebelf58ad362014-01-10 18:00:33 +00001511
Pali Rohár54ff2132020-11-24 15:38:08 +01001512${FIPTOOL}: FORCE
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001513ifdef UNIX_MK
Ross Burtonfdce8af2021-10-25 12:27:59 +01001514 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} --no-print-directory -C ${FIPTOOLPATH}
Sami Mujaware7cdc3f2020-04-30 12:41:57 +01001515else
1516# Clear the MAKEFLAGS as we do not want
1517# to pass the gnumake flags to nmake.
1518 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
1519endif
Harry Liebelf58ad362014-01-10 18:00:33 +00001520
Pali Rohár54ff2132020-11-24 15:38:08 +01001521romlib.bin: libraries FORCE
John Tsichritzisf6ea99b2019-05-21 15:47:37 +01001522 ${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 +01001523
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001524# Call print_memory_map tool
1525memmap: all
Louis Mayencourtc1c2bf72020-02-13 08:21:34 +00001526 ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001527
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001528doc:
1529 @echo " BUILD DOCUMENTATION"
1530 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
1531
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301532enctool: ${ENCTOOL}
1533
Pali Rohár54ff2132020-11-24 15:38:08 +01001534${ENCTOOL}: FORCE
Manish V Badarkhe635482e2020-08-13 05:56:33 +01001535 ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH}
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301536 @${ECHO_BLANK_LINE}
1537 @echo "Built $@ successfully"
1538 @${ECHO_BLANK_LINE}
1539
Joakim Bech35fab8c2014-01-23 14:51:49 +01001540cscope:
1541 @echo " CSCOPE"
1542 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
1543 ${Q}cscope -b -q -k
1544
Ryan Harkin72ee3312014-01-15 16:55:07 +00001545help:
John Tsichritzis0c4dded2019-05-21 15:57:31 +01001546 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001547 @echo ""
1548 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleuxa08588a2014-03-21 13:16:35 +00001549 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001550 @echo ""
John Tsichritzis0c4dded2019-05-21 15:57:31 +01001551 @echo "platform = ${PLATFORM_LIST}"
1552 @echo ""
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001553 @echo "Please refer to the User Guide for a list of all supported options."
1554 @echo "Note that the build system doesn't track dependencies for build "
1555 @echo "options. Therefore, if any of the build options are changed "
1556 @echo "from a previous build, a clean build must be performed."
1557 @echo ""
Ryan Harkin72ee3312014-01-15 16:55:07 +00001558 @echo "Supported Targets:"
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001559 @echo " all Build all individual bootloader binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +00001560 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +00001561 @echo " bl2 Build the BL2 binary"
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001562 @echo " bl2u Build the BL2U binary"
Juan Castillo7d199412015-12-14 09:35:25 +00001563 @echo " bl31 Build the BL31 binary"
Soby Mathewa1941252016-05-05 14:33:33 +01001564 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
1565 @echo " this builds secure payload specified by AARCH32_SP"
Juan Castilloa3487d12015-08-18 14:23:04 +01001566 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001567 @echo " fip Build the Firmware Image Package (FIP)"
Yatharth Kochard1a93432015-10-12 12:33:47 +01001568 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
Ian Spray36eaaf32014-01-30 17:25:28 +00001569 @echo " checkcodebase Check the coding style of the entire source tree"
1570 @echo " checkpatch Check the coding style on changes in the current"
1571 @echo " branch against BASE_COMMIT (default origin/master)"
1572 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +00001573 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +00001574 @echo " distclean Remove all build artifacts for all platforms"
Juan Castillo11abdcd2014-10-21 11:30:42 +01001575 @echo " certtool Build the Certificate generation tool"
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301576 @echo " enctool Build the Firmware encryption tool"
Andreas Färberec82cfb2016-10-10 05:18:49 +02001577 @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
Manish Pandey3f90ad72020-01-14 11:52:05 +00001578 @echo " sp Build the Secure Partition Packages"
Antonio Nino Diaza830a4d2018-11-27 14:58:04 +00001579 @echo " sptool Build the Secure Partition Package creation tool"
Soby Mathewab4181d2017-12-14 17:44:56 +00001580 @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
Louis Mayencourtcc3e8b82019-10-16 14:30:51 +01001581 @echo " memmap Print the memory map of the built binaries"
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -06001582 @echo " doc Build html based documentation using Sphinx tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +00001583 @echo ""
Sandrine Bailleuxcf8afbd2015-02-18 16:18:00 +00001584 @echo "Note: most build targets require PLAT to be set to a specific platform."
Ryan Harkin72ee3312014-01-15 16:55:07 +00001585 @echo ""
1586 @echo "example: build all targets for the FVP platform:"
1587 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
Pali Rohár54ff2132020-11-24 15:38:08 +01001588
1589.PHONY: FORCE
1590FORCE:;