14f6ad66aSAchin Gupta# 25b18de09SZelalem Aweke# Copyright (c) 2013-2021, Arm Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta# 482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause 54f6ad66aSAchin Gupta# 64f6ad66aSAchin Gupta 7e35c4045SJeenu Viswambharan# 8aaa3e722SJuan Castillo# Trusted Firmware Version 9aaa3e722SJuan Castillo# 101a0f1121SSoby MathewVERSION_MAJOR := 2 1163d2e960SManish V BadarkheVERSION_MINOR := 6 12aaa3e722SJuan Castillo 1388154678SJuan Castillo# Default goal is build all images 1488154678SJuan Castillo.DEFAULT_GOAL := all 1588154678SJuan Castillo 1672fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to 1772fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 1872fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual. 1972fc70edSDouglas RaillardMAKEOVERRIDES = 2072fc70edSDouglas Raillard 21231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/ 22231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk 23e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk 2473c99d4eSJuan Castillo 2573c99d4eSJuan Castillo################################################################################ 262fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies 2773c99d4eSJuan Castillo################################################################################ 28e35c4045SJeenu Viswambharan 292fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk 30872be88aSdp-arm 31cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default 32cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS := ${DEBUG} 332fae4b1eSJeenu ViswambharanENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 342fae4b1eSJeenu ViswambharanPLAT := ${DEFAULT_PLAT} 3573c99d4eSJuan Castillo 3673c99d4eSJuan Castillo################################################################################ 3773c99d4eSJuan Castillo# Checkpatch script options 3873c99d4eSJuan Castillo################################################################################ 3973c99d4eSJuan Castillo 40f607739cSSandrine BailleuxCHECKCODE_ARGS := --no-patch 41f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files 424501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \ 434501843fSGilad Ben-Yossef include/drivers/arm/cryptocell, \ 444501843fSGilad Ben-Yossef $(wildcard include/drivers/arm/*))) 454501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h 464501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 474501843fSGilad Ben-Yossef include/drivers/arm, \ 484501843fSGilad Ben-Yossef $(wildcard include/drivers/*))) 49f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 501a41e8c1SDan Handley include/lib/libfdt \ 5161f72a34SRoberto Vargas include/lib/libc, \ 52f0b489c1SDan Handley $(wildcard include/lib/*))) 53f0b489c1SDan HandleyINC_DIRS_TO_CHECK := $(sort $(filter-out \ 544501843fSGilad Ben-Yossef include/lib \ 554501843fSGilad Ben-Yossef include/drivers, \ 56f0b489c1SDan Handley $(wildcard include/*))) 57f0b489c1SDan HandleyLIB_DIRS_TO_CHECK := $(sort $(filter-out \ 58d801fbb0Sdp-arm lib/compiler-rt \ 5955cdcf75SAntonio Nino Diaz lib/libfdt% \ 6061f72a34SRoberto Vargas lib/libc, \ 61f0b489c1SDan Handley $(wildcard lib/*))) 62f0b489c1SDan HandleyROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 63f0b489c1SDan Handley lib \ 64f0b489c1SDan Handley include \ 65f0b489c1SDan Handley docs \ 661ef35512SPaul Beesley %.rst, \ 67f0b489c1SDan Handley $(wildcard *))) 68f0b489c1SDan HandleyCHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 69f0b489c1SDan Handley ${INC_DIRS_TO_CHECK} \ 70f0b489c1SDan Handley ${INC_LIB_DIRS_TO_CHECK} \ 714501843fSGilad Ben-Yossef ${LIB_DIRS_TO_CHECK} \ 724501843fSGilad Ben-Yossef ${INC_DRV_DIRS_TO_CHECK} \ 734501843fSGilad Ben-Yossef ${INC_ARM_DIRS_TO_CHECK} 7436eaaf37SIan Spray 7573c99d4eSJuan Castillo 7673c99d4eSJuan Castillo################################################################################ 7773c99d4eSJuan Castillo# Process build options 7873c99d4eSJuan Castillo################################################################################ 7973c99d4eSJuan Castillo 8073c99d4eSJuan Castillo# Verbose flag 81e35c4045SJeenu Viswambharanifeq (${V},0) 82b169f6a9SEvan Lloyd Q:=@ 83ee1ba6d4SAndre Przywara ECHO:=@echo 8436eaaf37SIan Spray CHECKCODE_ARGS += --no-summary --terse 854f6ad66aSAchin Guptaelse 86b169f6a9SEvan Lloyd Q:= 87b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 884f6ad66aSAchin Guptaendif 89ee1ba6d4SAndre Przywara 90ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 91ee1ba6d4SAndre Przywara Q:=@ 92b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 93ee1ba6d4SAndre Przywaraendif 94ee1ba6d4SAndre Przywara 95ee1ba6d4SAndre Przywaraexport Q ECHO 962f2cef46SJeenu Viswambharan 9773c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the 9873c99d4eSJuan Castillo# target 'certificates' to create them all 9973c99d4eSJuan Castilloifneq (${GENERATE_COT},0) 10073c99d4eSJuan Castillo FIP_DEPS += certificates 1010191262dSYatharth Kochar FWU_FIP_DEPS += fwu_certificates 10273c99d4eSJuan Castilloendif 10373c99d4eSJuan Castillo 1049fc59639SAlexei Fedorov# Process BRANCH_PROTECTION value and set 1059fc59639SAlexei Fedorov# Pointer Authentication and Branch Target Identification flags 1069fc59639SAlexei Fedorovifeq (${BRANCH_PROTECTION},0) 1079fc59639SAlexei Fedorov # Default value turns off all types of branch protection 1089fc59639SAlexei Fedorov BP_OPTION := none 1099fc59639SAlexei Fedorovelse ifneq (${ARCH},aarch64) 1109fc59639SAlexei Fedorov $(error BRANCH_PROTECTION requires AArch64) 1119fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},1) 1129fc59639SAlexei Fedorov # Enables all types of branch protection features 1139fc59639SAlexei Fedorov BP_OPTION := standard 1149fc59639SAlexei Fedorov ENABLE_BTI := 1 1159fc59639SAlexei Fedorov ENABLE_PAUTH := 1 1169fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},2) 1179fc59639SAlexei Fedorov # Return address signing to its standard level 1189fc59639SAlexei Fedorov BP_OPTION := pac-ret 1199fc59639SAlexei Fedorov ENABLE_PAUTH := 1 1209fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},3) 1219fc59639SAlexei Fedorov # Extend the signing to include leaf functions 1229fc59639SAlexei Fedorov BP_OPTION := pac-ret+leaf 1239fc59639SAlexei Fedorov ENABLE_PAUTH := 1 1243768fecfSAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},4) 1253768fecfSAlexei Fedorov # Turn on branch target identification mechanism 1263768fecfSAlexei Fedorov BP_OPTION := bti 1273768fecfSAlexei Fedorov ENABLE_BTI := 1 1289fc59639SAlexei Fedorovelse 1299fc59639SAlexei Fedorov $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 1309fc59639SAlexei Fedorovendif 13173c99d4eSJuan Castillo 1325b18de09SZelalem Aweke# FEAT_RME 1335b18de09SZelalem Awekeifeq (${ENABLE_RME},1) 1345b18de09SZelalem Aweke# RME doesn't support PIE 1355b18de09SZelalem Awekeifneq (${ENABLE_PIE},0) 1365b18de09SZelalem Aweke $(error ENABLE_RME does not support PIE) 1375b18de09SZelalem Awekeendif 1385b18de09SZelalem Aweke# RME requires AARCH64 1395b18de09SZelalem Awekeifneq (${ARCH},aarch64) 1405b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 1415b18de09SZelalem Awekeendif 1425b18de09SZelalem Aweke# RME requires el2 context to be saved for now. 1435b18de09SZelalem AwekeCTX_INCLUDE_EL2_REGS := 1 1445b18de09SZelalem AwekeCTX_INCLUDE_AARCH32_REGS := 0 1455b18de09SZelalem AwekeARM_ARCH_MAJOR := 8 1465b18de09SZelalem AwekeARM_ARCH_MINOR := 6 1475b18de09SZelalem Awekeendif 1485b18de09SZelalem Aweke 149c97cba4eSSoby Mathew# USE_SPINLOCK_CAS requires AArch64 build 150c97cba4eSSoby Mathewifeq (${USE_SPINLOCK_CAS},1) 151c97cba4eSSoby Mathewifneq (${ARCH},aarch64) 152c97cba4eSSoby Mathew $(error USE_SPINLOCK_CAS requires AArch64) 153c97cba4eSSoby Mathewendif 154c97cba4eSSoby Mathewendif 155c97cba4eSSoby Mathew 1560ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds 1570ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1) 1580ca3913dSOlivier Deprezifeq (${DEBUG},1) 1590ca3913dSOlivier Deprez $(warning DEBUGFS experimental feature is enabled.) 1600ca3913dSOlivier Deprezelse 1610ca3913dSOlivier Deprez $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 1620ca3913dSOlivier Deprezendif 1630ca3913dSOlivier Deprezendif 1640ca3913dSOlivier Deprez 165c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 166c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS} 167c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY} 168c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE} 169c6ba9b45SSumit GargFIP_DEPS += enctool 170c6ba9b45SSumit GargFWU_FIP_DEPS += enctool 171c6ba9b45SSumit Gargendif 172c6ba9b45SSumit Garg 17373c99d4eSJuan Castillo################################################################################ 17473c99d4eSJuan Castillo# Toolchain 17573c99d4eSJuan Castillo################################################################################ 17673c99d4eSJuan Castillo 17772610c41Sdp-armHOSTCC := gcc 17872610c41Sdp-armexport HOSTCC 17972610c41Sdp-arm 18073c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 18173c99d4eSJuan CastilloCPP := ${CROSS_COMPILE}cpp 18273c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 18373c99d4eSJuan CastilloAR := ${CROSS_COMPILE}ar 1842adee763SRoberto VargasLINKER := ${CROSS_COMPILE}ld 18573c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 18673c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 18773c99d4eSJuan CastilloNM := ${CROSS_COMPILE}nm 18873c99d4eSJuan CastilloPP := ${CROSS_COMPILE}gcc -E 18938c14d88SSoby MathewDTC := dtc 19073c99d4eSJuan Castillo 191b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 192b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \ 1932adee763SRoberto Vargas $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 1942adee763SRoberto VargasLINKER := ${LINKER}.bfd 195b25a577fSJulius Wernerendif 196b25a577fSJulius Werner 19726e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 19826e63c44SEtienne Carrieretarget32-directive = -target arm-none-eabi 19926e63c44SEtienne Carriere# Will set march32-directive from platform configuration 20026e63c44SEtienne Carriereelse 20126e63c44SEtienne Carrieretarget32-directive = -target armv8a-none-eabi 202fa6f774bSAlexei Fedorov 203f1821790SAlexei Fedorov# Set the compiler's target architecture profile based on 204f1821790SAlexei Fedorov# ARM_ARCH_MAJOR ARM_ARCH_MINOR options 205fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0) 206f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}-a 207f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}-a 208fa6f774bSAlexei Fedorovelse 209f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 210f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 211fa6f774bSAlexei Fedorovendif 21226e63c44SEtienne Carriereendif 21326e63c44SEtienne Carriere 2147ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards 2157ff088d1SManish V Badarkheifeq ($(ARCH), aarch64) 2164a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5 2174a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 2187ff088d1SManish V Badarkhemem_tag_arch_support = yes 2197ff088d1SManish V Badarkheendif 2207ff088d1SManish V Badarkheendif 2217ff088d1SManish V Badarkhe 222f1821790SAlexei Fedorov# Get architecture feature modifiers 223f1821790SAlexei Fedorovarch-features = ${ARM_ARCH_FEATURE} 224f1821790SAlexei Fedorov 225f1821790SAlexei Fedorov# Enable required options for memory stack tagging. 226f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler. 2277ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes) 2287ff088d1SManish V Badarkheifdef mem_tag_arch_support 229f1821790SAlexei Fedorov# Check for armclang and clang compilers 2307ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 231f1821790SAlexei Fedorov# Add "memtag" architecture feature modifier if not specified 232f1821790SAlexei Fedorovifeq ( ,$(findstring memtag,$(arch-features))) 233f1821790SAlexei Fedorovarch-features := $(arch-features)+memtag 234f1821790SAlexei Fedorovendif # memtag 2357ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang) 2367ff088d1SManish V BadarkheTF_CFLAGS += -mmemtag-stack 2377ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang) 2387ff088d1SManish V BadarkheTF_CFLAGS += -fsanitize=memtag 239f1821790SAlexei Fedorovendif # armclang 240f1821790SAlexei Fedorovendif # armclang clang 2417ff088d1SManish V Badarkheelse 2427ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \ 2437ff088d1SManish V Badarkhe ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 244f1821790SAlexei Fedorovendif # mem_tag_arch_support 245f1821790SAlexei Fedorovendif # SUPPORT_STACK_MEMTAG 246f1821790SAlexei Fedorov 247f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers 248f1821790SAlexei Fedorovifneq ($(arch-features), none) 249f1821790SAlexei Fedorov# Strip "none+" from arch-features 250f1821790SAlexei Fedorovarch-features := $(subst none+,,$(arch-features)) 251f1821790SAlexei Fedorovifeq ($(ARCH), aarch32) 252f1821790SAlexei Fedorovmarch32-directive := $(march32-directive)+$(arch-features) 253f1821790SAlexei Fedorovelse 254f1821790SAlexei Fedorovmarch64-directive := $(march64-directive)+$(arch-features) 2557ff088d1SManish V Badarkheendif 256f1821790SAlexei Fedorov# Print features 257f1821790SAlexei Fedorov$(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 258f1821790SAlexei Fedorovendif # arch-features 2597ff088d1SManish V Badarkhe 26012cd65e0STomas Pilar# Determine if FEAT_RNG is supported 26112cd65e0STomas PilarENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) 26212cd65e0STomas Pilar 2634e04478aSChris Kay# Determine if FEAT_SB is supported 2644e04478aSChris KayENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) 2654e04478aSChris Kay 2664e04478aSChris Kayifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 2674e04478aSChris KayENABLE_FEAT_SB = 1 2684e04478aSChris Kayendif 2694e04478aSChris Kay 270fd18a8fcSVarun Wadekarifneq ($(findstring armclang,$(notdir $(CC))),) 27126e63c44SEtienne CarriereTF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive) 272fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi $(march64-directive) 2732adee763SRoberto VargasLD = $(LINKER) 2741684b873SRoberto VargasAS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 2757040155eSRoberto VargasCPP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 2767040155eSRoberto VargasPP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 2777559633bSdp-armelse ifneq ($(findstring clang,$(notdir $(CC))),) 278eff737c1SArve HjønnevågCLANG_CCDIR = $(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),) 279e2bfec0bSYann GautierTF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) 280fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = -target aarch64-elf $(march64-directive) 281eff737c1SArve HjønnevågLD = $(CLANG_CCDIR)ld.lld 282641f16e7SAmbroise Vincentifeq (, $(shell which $(LD))) 283641f16e7SAmbroise Vincent$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker") 284641f16e7SAmbroise Vincentendif 2851684b873SRoberto VargasAS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 2867040155eSRoberto VargasCPP = $(CC) -E 2877040155eSRoberto VargasPP = $(CC) -E 288edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),) 289edbce9aaSzelalem-awekeTF_CFLAGS_aarch32 = $(march32-directive) 290edbce9aaSzelalem-awekeTF_CFLAGS_aarch64 = $(march64-directive) 291edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 292edbce9aaSzelalem-aweke # Enable LTO only for aarch64 293edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 294edbce9aaSzelalem-aweke LTO_CFLAGS = -flto 295edbce9aaSzelalem-aweke # Use gcc as a wrapper for the ld, recommended for LTO 296edbce9aaSzelalem-aweke LINKER := ${CROSS_COMPILE}gcc 297edbce9aaSzelalem-aweke endif 298edbce9aaSzelalem-awekeendif 299edbce9aaSzelalem-awekeLD = $(LINKER) 300d5461857Sdp-armelse 30126e63c44SEtienne CarriereTF_CFLAGS_aarch32 = $(march32-directive) 302fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = $(march64-directive) 3032adee763SRoberto VargasLD = $(LINKER) 304d5461857Sdp-armendif 305d5461857Sdp-arm 30632b209bfSAhmad Fatoum# Process Debug flag 30732b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 30832b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 30932b209bfSAhmad Fatoum BUILD_TYPE := debug 31032b209bfSAhmad Fatoum TF_CFLAGS += -g 31132b209bfSAhmad Fatoum 31232b209bfSAhmad Fatoum ifneq ($(findstring clang,$(notdir $(CC))),) 31332b209bfSAhmad Fatoum ASFLAGS += -g 31432b209bfSAhmad Fatoum else 31532b209bfSAhmad Fatoum ASFLAGS += -g -Wa,--gdwarf-2 31632b209bfSAhmad Fatoum endif 31732b209bfSAhmad Fatoum 31832b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 31932b209bfSAhmad Fatoum LOG_LEVEL := 40 32032b209bfSAhmad Fatoumelse 32132b209bfSAhmad Fatoum BUILD_TYPE := release 32232b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 32332b209bfSAhmad Fatoum LOG_LEVEL := 20 32432b209bfSAhmad Fatoumendif 32532b209bfSAhmad Fatoum 326f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 327f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 328f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 329f1de4c8fSPeiyuan Songendif 330f1de4c8fSPeiyuan SongVERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING} 331f1de4c8fSPeiyuan Song 3328fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 3338fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -marm 3348fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 3358fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -mthumb 3368fd9d4d5SAntonio Nino Diazelse 3378fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 3388fd9d4d5SAntonio Nino Diazendif 3398fd9d4d5SAntonio Nino Diaz 340a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 341d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 3429d29c227SSoby Mathew 3439fc59639SAlexei Fedorovifneq (${BP_OPTION},none) 3449fc59639SAlexei FedorovTF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 3459fc59639SAlexei Fedorovendif 3469fc59639SAlexei Fedorov 34726e63c44SEtienne CarriereASFLAGS_aarch32 = $(march32-directive) 348fa6f774bSAlexei FedorovASFLAGS_aarch64 = $(march64-directive) 349b86048c4SAntonio Nino Diaz 3509ab81b5eSJustin Chadwell# General warnings 3519ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 352b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 353ca661a00SMadhukar Pappireddy -Wno-unused-parameter -Wredundant-decls 3549ab81b5eSJustin Chadwell 3559ab81b5eSJustin Chadwell# Additional warnings 3569ab81b5eSJustin Chadwell# Level 1 357e7c645b5SYann GautierWARNING1 := -Wextra 358e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute 359e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes 360e7c645b5SYann GautierWARNING1 += -Wold-style-definition 361e7c645b5SYann Gautier 362b7f6525dSJustin Chadwell# Level 2 363e7c645b5SYann GautierWARNING2 := -Waggregate-return 364e7c645b5SYann GautierWARNING2 += -Wcast-align 365e7c645b5SYann GautierWARNING2 += -Wnested-externs 366e7c645b5SYann Gautier 367e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 368e7c645b5SYann GautierWARNING3 += -Wcast-qual 369e7c645b5SYann GautierWARNING3 += -Wconversion 370e7c645b5SYann GautierWARNING3 += -Wpacked 371e7c645b5SYann GautierWARNING3 += -Wpointer-arith 372e7c645b5SYann GautierWARNING3 += -Wswitch-default 373e7c645b5SYann Gautier 374e7c645b5SYann Gautierifeq (${W},1) 3759ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) 376e7c645b5SYann Gautierelse ifeq (${W},2) 3779ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) 378e7c645b5SYann Gautierelse ifeq (${W},3) 3799ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 380e7c645b5SYann Gautierendif 381e7c645b5SYann Gautier 3829ab81b5eSJustin Chadwell# Compiler specific warnings 38300296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),) 38493c690ebSJustin Chadwell# not using clang 385d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 386d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 387d7b4cd41SJustin Chadwell -Wlogical-op 38893c690ebSJustin Chadwellelse 38993c690ebSJustin Chadwell# using clang 390d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 391d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 39200296576SAmbroise Vincentendif 39300296576SAmbroise Vincent 3946336b07aSYann Gautierifneq (${E},0) 3956336b07aSYann GautierERRORS := -Werror 3966336b07aSYann Gautierendif 3976336b07aSYann Gautier 398ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 3999ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 40059de5096SMasahiro YamadaASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 401d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 40259de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 403ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 404ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 405ebd6efaeSSamuel Holland -Os -std=gnu99 40673c99d4eSJuan Castillo 4071f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4081f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 4091f461979SJustin Chadwellendif 4101f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 4111f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 4121f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 4131f461979SJustin Chadwellendif 4141f461979SJustin Chadwell 415f7ec31dbSdavid cunadoGCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 416f7ec31dbSdavid cunado 417641f16e7SAmbroise Vincent# LD = armlink 418c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 419c2ad38ceSVarun WadekarTF_LDFLAGS += --diag_error=warning --lto_level=O1 420c2ad38ceSVarun WadekarTF_LDFLAGS += --remove --info=unused,unusedsymbols 421edbce9aaSzelalem-awekeTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 422641f16e7SAmbroise Vincent 423641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 424edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 425edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches 426edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--fatal-warnings -O1 427edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--gc-sections 428edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 429edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 430edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 431edbce9aaSzelalem-aweke endif 432edbce9aaSzelalem-awekeendif 433edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 434edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 435edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1) 436edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 437edbce9aaSzelalem-awekeendif 438edbce9aaSzelalem-awekeTF_LDFLAGS += -nostdlib 439edbce9aaSzelalem-awekeTF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 440641f16e7SAmbroise Vincent 441641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 442c2ad38ceSVarun Wadekarelse 443c2b8806fSDouglas RaillardTF_LDFLAGS += --fatal-warnings -O1 444c2b8806fSDouglas RaillardTF_LDFLAGS += --gc-sections 445641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 446641f16e7SAmbroise Vincent# therefore don't add those in that case 447641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),) 448c2b8806fSDouglas RaillardTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 449edbce9aaSzelalem-awekeendif 450641f16e7SAmbroise Vincentendif 45173c99d4eSJuan Castillo 45203b397a8SNishanth MenonDTC_FLAGS += -I dts -O dtb 453a6de824fSLouis MayencourtDTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 454a6de824fSLouis Mayencourt -x assembler-with-cpp $(DEFINES) 45503b397a8SNishanth Menon 4560ab49645SAlexei Fedorovifeq ($(MEASURED_BOOT),1) 4570ab49645SAlexei FedorovDTC_CPPFLAGS += -DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE} 4580ab49645SAlexei Fedorovendif 4590ab49645SAlexei Fedorov 46073c99d4eSJuan Castillo################################################################################ 46173c99d4eSJuan Castillo# Common sources and include directories 46273c99d4eSJuan Castillo################################################################################ 463d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 46473c99d4eSJuan Castillo 46573c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 4667f56e9a3SSoby Mathew common/tf_log.c \ 4679d29c227SSoby Mathew common/${ARCH}/debug.S \ 46891b48c9fSJulius Werner drivers/console/multi_console.c \ 4699d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 4709d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 471566034fcSSoby Mathew plat/common/plat_bl_common.c \ 4727f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 47375311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 4749d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 47561f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 476d7a6b0f8SRyan Harkin 4778422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang) 4788422a840SAntonio Nino DiazBL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 4798422a840SAntonio Nino Diazendif 4808422a840SAntonio Nino Diaz 4811f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4821f461979SJustin ChadwellBL_COMMON_SOURCES += plat/common/ubsan.c 4831f461979SJustin Chadwellendif 4841f461979SJustin Chadwell 48501d237cbSYann GautierINCLUDES += -Iinclude \ 486f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 48709d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 48809d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 48909d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 49009d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 49109d40e0eSAntonio Nino Diaz 4929c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 4939c6d1c50SAntonio Nino Diaz 49473c99d4eSJuan Castillo################################################################################ 49573c99d4eSJuan Castillo# Generic definitions 49673c99d4eSJuan Castillo################################################################################ 49773c99d4eSJuan Castillo 498231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 499231c1470SEvan Lloyd 50029214e95SGrant Likelyifeq (${BUILD_BASE},) 50173c99d4eSJuan Castillo BUILD_BASE := ./build 50229214e95SGrant Likelyendif 50329214e95SGrant LikelyBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 50473c99d4eSJuan Castillo 505231c1470SEvan LloydSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 50673c99d4eSJuan Castillo 50773c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value 50873c99d4eSJuan CastilloINCLUDE_TBBR_MK := 1 50973c99d4eSJuan Castillo 51073c99d4eSJuan Castillo 51173c99d4eSJuan Castillo################################################################################ 51273c99d4eSJuan Castillo# Include SPD Makefile if one has been specified 51373c99d4eSJuan Castillo################################################################################ 51473c99d4eSJuan Castillo 51573c99d4eSJuan Castilloifneq (${SPD},none) 5169d29c227SSoby Mathew ifeq (${ARCH},aarch32) 5179d29c227SSoby Mathew $(error "Error: SPD is incompatible with AArch32.") 5189d29c227SSoby Mathew endif 51928f39f02SMax Shvetsov 5204c117f6cSSandrine Bailleux ifdef EL3_PAYLOAD_BASE 5214c117f6cSSandrine Bailleux $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 5224c117f6cSSandrine Bailleux $(warning "The SPD and its BL32 companion will be present but ignored.") 5234c117f6cSSandrine Bailleux endif 52428f39f02SMax Shvetsov 525c3fb00d9SAchin Gupta ifeq (${SPD},spmd) 526c3fb00d9SAchin Gupta # SPMD is located in std_svc directory 527c3fb00d9SAchin Gupta SPD_DIR := std_svc 52828f39f02SMax Shvetsov 529033039f8SMax Shvetsov ifeq ($(SPMD_SPM_AT_SEL2),1) 53028f39f02SMax Shvetsov ifeq ($(CTX_INCLUDE_EL2_REGS),0) 531033039f8SMax Shvetsov $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option) 532033039f8SMax Shvetsov endif 53328f39f02SMax Shvetsov endif 534db1ef41aSOlivier Deprez 535db1ef41aSOlivier Deprez ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 536db1ef41aSOlivier Deprez DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 537db1ef41aSOlivier Deprez endif 538ca932481SDavidson K 539ca932481SDavidson K ifeq ($(TS_SP_FW_CONFIG),1) 540ca932481SDavidson K DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 541ca932481SDavidson K endif 54233993a37SBalint Dobszay 54333993a37SBalint Dobszay ifneq ($(ARM_BL2_SP_LIST_DTS),) 54433993a37SBalint Dobszay DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 54533993a37SBalint Dobszay endif 54646789a7cSBalint Dobszay 54746789a7cSBalint Dobszay ifneq ($(SP_LAYOUT_FILE),) 54846789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD := 1 54946789a7cSBalint Dobszay endif 550c3fb00d9SAchin Gupta else 551c3fb00d9SAchin Gupta # All other SPDs in spd directory 552c3fb00d9SAchin Gupta SPD_DIR := spd 553c3fb00d9SAchin Gupta endif 554c3fb00d9SAchin Gupta 55573c99d4eSJuan Castillo # We expect to locate an spd.mk under the specified SPD directory 556c3fb00d9SAchin Gupta SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 557c3fb00d9SAchin Gupta 55873c99d4eSJuan Castillo ifeq (${SPD_MAKE},) 559c3fb00d9SAchin Gupta $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 56073c99d4eSJuan Castillo endif 56173c99d4eSJuan Castillo $(info Including ${SPD_MAKE}) 56273c99d4eSJuan Castillo include ${SPD_MAKE} 56373c99d4eSJuan Castillo 56470d1fc53SJuan Castillo # If there's BL32 companion for the chosen SPD, we expect that the SPD's 56570d1fc53SJuan Castillo # Makefile would set NEED_BL32 to "yes". In this case, the build system 56670d1fc53SJuan Castillo # supports two mutually exclusive options: 56770d1fc53SJuan Castillo # * BL32 is built from source: then BL32_SOURCES must contain the list 56870d1fc53SJuan Castillo # of source files to build BL32 56970d1fc53SJuan Castillo # * BL32 is a prebuilt binary: then BL32 must point to the image file 57070d1fc53SJuan Castillo # that will be included in the FIP 57170d1fc53SJuan Castillo # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 57270d1fc53SJuan Castillo # over the sources. 573e35c4045SJeenu Viswambharanendif 574e35c4045SJeenu Viswambharan 57551faada7SDouglas Raillard################################################################################ 5765b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled 5775b18de09SZelalem Aweke################################################################################ 5785b18de09SZelalem Aweke 5795b18de09SZelalem Awekeifneq (${ENABLE_RME},0) 5805b18de09SZelalem Awekeifneq (${ARCH},aarch64) 5815b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 5825b18de09SZelalem Awekeendif 5835b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk 5845b18de09SZelalem Aweke$(warning "RME is an experimental feature") 5855b18de09SZelalem Awekeendif 5865b18de09SZelalem Aweke 5875b18de09SZelalem Aweke################################################################################ 58873c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform 58973c99d4eSJuan Castillo# makefile may use all previous definitions in this file) 59073c99d4eSJuan Castillo################################################################################ 5912da8d8bfSJeenu Viswambharan 59273c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL} 5930f21c547SJuan Castillo 5948012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 5958012cc5cSMasahiro Yamada 59626e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 59726e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 59826e63c44SEtienne Carriereendif 59926e63c44SEtienne Carriere 6003bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 6013bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 6023bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 6033bd17c0fSSoby Mathewendif 604320920c1SMasahiro Yamada 605320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),) 606320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 607320920c1SMasahiro Yamadaelse 608320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 609320920c1SMasahiro Yamadaendif 610320920c1SMasahiro Yamada 611320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 61269af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 61369af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1) 61469af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 61569af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 61669af7fcfSMasahiro Yamadaendif 61769af7fcfSMasahiro Yamadaendif 618320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 619320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 620d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 621d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 622d974301dSMasahiro Yamadaendif 6233bd17c0fSSoby Mathew 624d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64) 6259cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 626d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 6279cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3 628d5e97a1dSMasahiro Yamadaelse 6299cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1 630d5e97a1dSMasahiro Yamadaendif 6319cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1 6329cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3 6339cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1 634d5e97a1dSMasahiro Yamadaendif 635d5e97a1dSMasahiro Yamada 63654035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 63754035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 63854035fc4SSandrine Bailleux# This can be overridden by the platform. 63973c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 6404f6ad66aSAchin Gupta 641a4409008Sdp-armifeq (${ARCH},aarch32) 642a4409008Sdp-armNEED_BL32 := yes 643a4409008Sdp-arm 644a4409008Sdp-arm################################################################################ 645a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 646a4409008Sdp-arm################################################################################ 647a4409008Sdp-armifneq (${AARCH32_SP},none) 648a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory 649a4409008Sdp-armAARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 650a4409008Sdp-arm 651a4409008Sdp-armifeq (${AARCH32_SP_MAKE},) 652a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 653a4409008Sdp-armendif 654a4409008Sdp-arm 655a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE}) 656a4409008Sdp-arminclude ${AARCH32_SP_MAKE} 657a4409008Sdp-armendif 658a4409008Sdp-arm 659a4409008Sdp-armendif 6604f6ad66aSAchin Gupta 66173c99d4eSJuan Castillo################################################################################ 66277f1f7a1SVarun Wadekar# Include libc if not overridden 66377f1f7a1SVarun Wadekar################################################################################ 66477f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 66577f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 66677f1f7a1SVarun Wadekarendif 66777f1f7a1SVarun Wadekar 66877f1f7a1SVarun Wadekar################################################################################ 669cf2c8a33SAntonio Nino Diaz# Check incompatible options 670cf2c8a33SAntonio Nino Diaz################################################################################ 671cf2c8a33SAntonio Nino Diaz 672cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 67368450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 67468450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 67568450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 676cf2c8a33SAntonio Nino Diaz endif 67776580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 67876580f3dSQixiang Xu $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 67976580f3dSQixiang Xu endif 68076580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 68176580f3dSQixiang Xu $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 68276580f3dSQixiang Xu endif 683cf2c8a33SAntonio Nino Diazendif 684cf2c8a33SAntonio Nino Diaz 685cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 686cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 687cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 688cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 689cf2c8a33SAntonio Nino Diaz endif 69068450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 69168450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 69268450a6dSAntonio Nino Diaz PRELOADED_BL33_BASE is used and won't be added to the FIP \ 69368450a6dSAntonio Nino Diaz file.") 694cf2c8a33SAntonio Nino Diaz endif 695cf2c8a33SAntonio Nino Diazendif 696cf2c8a33SAntonio Nino Diaz 697d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 698d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 699d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 700d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 701d4593e47SJeenu Viswambharanendif 7021a0a3f06SYatharth Kochar 7037d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1. 7047d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1) 7057d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled") 7067d173fc5SJiafei Panendif 7077d173fc5SJiafei Pan 70814c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first 70914c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 71014c6016aSJeenu Viswambharan ifneq ($(HANDLE_EA_EL3_FIRST),1) 71114c6016aSJeenu Viswambharan $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1) 71214c6016aSJeenu Viswambharan endif 71314c6016aSJeenu Viswambharanendif 71414c6016aSJeenu Viswambharan 7151a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled 7161a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 7171a7c1cfeSJeenu Viswambharan ifneq ($(RAS_EXTENSION),1) 7181a7c1cfeSJeenu Viswambharan $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) 7191a7c1cfeSJeenu Viswambharan endif 7201a7c1cfeSJeenu Viswambharanendif 7211a7c1cfeSJeenu Viswambharan 722ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 723209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 724209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 725209a60ccSSoby Mathew $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.") 726209a60ccSSoby Mathew endif 727209a60ccSSoby Mathewendif 728209a60ccSSoby Mathew 729cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 730cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 731700e7685SManish Pandey$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 73284ef9cd8SManish V Badarkheendif 73384ef9cd8SManish V Badarkhe 734b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 7359fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 7369fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 737b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 7389fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 7399fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 74006715f85SAlexei Fedorov endif 7419fc59639SAlexei Fedorovendif 7429fc59639SAlexei Fedorov 74306715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 7449fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 7459fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 746b86048c4SAntonio Nino Diaz endif 747b86048c4SAntonio Nino Diazendif 7489fc59639SAlexei Fedorov 7499dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1) 7509dd94382SJustin Chadwell ifneq (${ARCH},aarch64) 7519dd94382SJustin Chadwell $(error CTX_INCLUDE_MTE_REGS requires AArch64) 7529dd94382SJustin Chadwell endif 7539dd94382SJustin Chadwellendif 7549dd94382SJustin Chadwell 755cc255b9fSSandrine Bailleux# Trusted Boot is a prerequisite for Measured Boot. It provides trust that the 756cc255b9fSSandrine Bailleux# code taking the measurements and recording them has not been tampered 757cc255b9fSSandrine Bailleux# with. This is referred to as the Root of Trust for Measurement. 7588c105290SAlexei Fedorovifeq ($(MEASURED_BOOT),1) 7598c105290SAlexei Fedorov ifneq (${TRUSTED_BOARD_BOOT},1) 7607cda17bbSSumit Garg $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1) 7618c105290SAlexei Fedorov endif 7628c105290SAlexei Fedorovendif 7638c105290SAlexei Fedorov 764396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1) 765396b339dSManish V Badarkhe $(info PSA_FWU_SUPPORT is an experimental feature) 766396b339dSManish V Badarkheendif 767396b339dSManish V Badarkhe 76860e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 76960e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 77060e8f3cfSPetre-Ionut Tudor $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2") 77160e8f3cfSPetre-Ionut Tudor endif 77260e8f3cfSPetre-Ionut Tudorendif 77360e8f3cfSPetre-Ionut Tudor 7747cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 7757cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 7767cda17bbSSumit Garg $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set) 7777cda17bbSSumit Garg endif 7787cda17bbSSumit Gargendif 7797cda17bbSSumit Garg 780dc78e62dSjohpow01# SME/SVE only supported on AArch64 781dc78e62dSjohpow01ifeq (${ARCH},aarch32) 782dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},1) 783dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 784dc78e62dSjohpow01 endif 785dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 786dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 787dc78e62dSjohpow01 $(warning "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 788dc78e62dSjohpow01 $(warning "Forced ENABLE_SVE_FOR_NS=0") 789dc78e62dSjohpow01 override ENABLE_SVE_FOR_NS := 0 790dc78e62dSjohpow01 endif 791dc78e62dSjohpow01endif 792dc78e62dSjohpow01 793dc78e62dSjohpow01# Ensure ENABLE_RME is not used with SME 794dc78e62dSjohpow01ifeq (${ENABLE_RME},1) 795dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},1) 796dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME") 797dc78e62dSjohpow01 endif 798dc78e62dSjohpow01endif 799dc78e62dSjohpow01 800dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well 801dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1) 802dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},0) 803dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 804dc78e62dSjohpow01 endif 805dc78e62dSjohpow01endif 806dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1) 807dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},0) 808dc78e62dSjohpow01 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 809dc78e62dSjohpow01 endif 810dc78e62dSjohpow01endif 811dc78e62dSjohpow01 812dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does 813dc78e62dSjohpow01# its own context management including FPU registers. 814dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1) 815dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},1) 816dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 817dc78e62dSjohpow01 endif 818dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 819dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 820dc78e62dSjohpow01 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 821dc78e62dSjohpow01 $(warning "Forced ENABLE_SVE_FOR_NS=0") 822dc78e62dSjohpow01 override ENABLE_SVE_FOR_NS := 0 823dc78e62dSjohpow01 endif 824dc78e62dSjohpow01endif 825dc78e62dSjohpow01 826cf2c8a33SAntonio Nino Diaz################################################################################ 82773c99d4eSJuan Castillo# Process platform overrideable behaviour 82873c99d4eSJuan Castillo################################################################################ 8294f6ad66aSAchin Gupta 8305f24ce96SManish Pandeyifdef BL1_SOURCES 8315f24ce96SManish PandeyNEED_BL1 := yes 8325f24ce96SManish Pandeyendif 8335f24ce96SManish Pandey 8345f24ce96SManish Pandeyifdef BL2_SOURCES 8355f24ce96SManish Pandey NEED_BL2 := yes 8365f24ce96SManish Pandey 837bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 838bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 839cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 840cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 841cf2c8a33SAntonio Nino Diaz # in the FIP file. 8424c117f6cSSandrine Bailleux NEED_BL33 := no 843cf2c8a33SAntonio Nino Diaz else 84468450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 845cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 846cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 847cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 848cf2c8a33SAntonio Nino Diaz else 849cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 850cf2c8a33SAntonio Nino Diaz endif 8514c117f6cSSandrine Bailleux endif 85273c99d4eSJuan Castilloendif 8536f971622SJuan Castillo 8545f24ce96SManish Pandeyifdef BL2U_SOURCES 8555f24ce96SManish PandeyNEED_BL2U := yes 8565f24ce96SManish Pandeyendif 8575f24ce96SManish Pandey 8584d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 8594d045d0eSMasahiro Yamadaifdef SCP_BL2 8604d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 8614d045d0eSMasahiro Yamadaendif 8624d045d0eSMasahiro Yamada 8635744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 8645744e874SSoby Mathewifneq (${ARCH},aarch32) 8655744e874SSoby Mathew ifdef BL31_SOURCES 8665744e874SSoby Mathew # When booting an EL3 payload, there is no need to compile the BL31 image nor 8675744e874SSoby Mathew # put it in the FIP. 8685744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 8695744e874SSoby Mathew NEED_BL31 := yes 8705744e874SSoby Mathew endif 8715744e874SSoby Mathew endif 8725744e874SSoby Mathewendif 8735744e874SSoby Mathew 87473c99d4eSJuan Castillo# Process TBB related flags 8756f971622SJuan Castilloifneq (${GENERATE_COT},0) 87673c99d4eSJuan Castillo # Common cert_create options 8776f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 8786f971622SJuan Castillo $(eval CRT_ARGS += -n) 8790191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 880fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 881fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 8820191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 883fd34e7baSJuan Castillo endif 8846f971622SJuan Castillo endif 88573c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 88673c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 88773c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 88873c99d4eSJuan Castillo endif 8896f971622SJuan Castilloendif 8906f971622SJuan Castillo 8911c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 8921c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN} 8931c75d5dfSMasahiro Yamadaendif 8941c75d5dfSMasahiro Yamada 8955f24ce96SManish Pandeyifdef FDT_SOURCES 8965f24ce96SManish PandeyNEED_FDT := yes 8975f24ce96SManish Pandeyendif 8985f24ce96SManish Pandey 89973c99d4eSJuan Castillo################################################################################ 90046e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 90146e5e035SMichalis Pappas################################################################################ 90246e5e035SMichalis Pappas 90346e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 90446e5e035SMichalis Pappas 90546e5e035SMichalis Pappas################################################################################ 906819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc) 90773c99d4eSJuan Castillo################################################################################ 90873c99d4eSJuan Castillo 90973c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool 91073c99d4eSJuan CastilloCRTTOOLPATH ?= tools/cert_create 91142a45b51SEvan LloydCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 91273c99d4eSJuan Castillo 91390aa901fSSumit Garg# Variables for use with Firmware Encryption Tool 91490aa901fSSumit GargENCTOOLPATH ?= tools/encrypt_fw 91590aa901fSSumit GargENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 91690aa901fSSumit Garg 91773c99d4eSJuan Castillo# Variables for use with Firmware Image Package 918819281eeSdp-armFIPTOOLPATH ?= tools/fiptool 919819281eeSdp-armFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 92073c99d4eSJuan Castillo 92126010da1SAntonio Nino Diaz# Variables for use with sptool 92226010da1SAntonio Nino DiazSPTOOLPATH ?= tools/sptool 92326010da1SAntonio Nino DiazSPTOOL ?= ${SPTOOLPATH}/sptool${BIN_EXT} 924ce2b1ec6SManish PandeySP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 92526010da1SAntonio Nino Diaz 9265accce5bSRoberto Vargas# Variables for use with ROMLIB 9275accce5bSRoberto VargasROMLIBPATH ?= lib/romlib 9285accce5bSRoberto Vargas 929cfe83910SLouis Mayencourt# Variable for use with Python 930cfe83910SLouis MayencourtPYTHON ?= python3 931cfe83910SLouis Mayencourt 932cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP 933cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH ?= tools/memory 934cfe83910SLouis MayencourtPRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py 935cfe83910SLouis Mayencourt 9366de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool 9376de32378SMadhukar PappireddyDOCS_PATH ?= docs 9386de32378SMadhukar Pappireddy 9398a86052dSSoby Mathew################################################################################ 9408a86052dSSoby Mathew# Include BL specific makefiles 9418a86052dSSoby Mathew################################################################################ 9425f24ce96SManish Pandey 9435f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 9448a86052dSSoby Mathewinclude bl1/bl1.mk 9458a86052dSSoby Mathewendif 9468a86052dSSoby Mathew 9475f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 9488a86052dSSoby Mathewinclude bl2/bl2.mk 9498a86052dSSoby Mathewendif 9508a86052dSSoby Mathew 9515f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 9528a86052dSSoby Mathewinclude bl2u/bl2u.mk 9538a86052dSSoby Mathewendif 9548a86052dSSoby Mathew 9555744e874SSoby Mathewifeq (${NEED_BL31},yes) 9568a86052dSSoby Mathewinclude bl31/bl31.mk 9578a86052dSSoby Mathewendif 95803b397a8SNishanth Menon 95973c99d4eSJuan Castillo################################################################################ 96073c99d4eSJuan Castillo# Build options checks 96173c99d4eSJuan Castillo################################################################################ 96273c99d4eSJuan Castillo 963327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 964327131c4SLeonardo Sandoval $(sort \ 965327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 96646789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 967327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 968327131c4SLeonardo Sandoval CREATE_KEYS \ 969327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 970327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 971327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 972327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 973327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 974062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 975327131c4SLeonardo Sandoval DEBUG \ 9760063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 977327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 978327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 979327131c4SLeonardo Sandoval ENABLE_AMU \ 9801fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 981742ca230SChris Kay ENABLE_AMU_FCONF \ 982873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 983327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 984327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 985327131c4SLeonardo Sandoval ENABLE_PIE \ 986327131c4SLeonardo Sandoval ENABLE_PMF \ 987327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 9885b18de09SZelalem Aweke ENABLE_RME \ 989327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 990dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 991dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 992327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 993327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 9940c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 995327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 996327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 997327131c4SLeonardo Sandoval GENERATE_COT \ 998327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 999327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 1000327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1001327131c4SLeonardo Sandoval INVERTED_MEMMAP \ 1002327131c4SLeonardo Sandoval MEASURED_BOOT \ 1003327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1004327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 1005327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1006327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1007327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 1008327131c4SLeonardo Sandoval RAS_EXTENSION \ 1009327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1010327131c4SLeonardo Sandoval SAVE_KEYS \ 1011327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 1012327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1013327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1014327131c4SLeonardo Sandoval SPM_MM \ 1015327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1016327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1017327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1018327131c4SLeonardo Sandoval USE_DEBUGFS \ 1019327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1020327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1021327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1022327131c4SLeonardo Sandoval USE_ROMLIB \ 1023327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1024327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1025327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1026327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1027327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1028327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1029327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1030327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1031327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 1032327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1033327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1034327131c4SLeonardo Sandoval USE_SP804_TIMER \ 103512cd65e0STomas Pilar ENABLE_FEAT_RNG \ 10364e04478aSChris Kay ENABLE_FEAT_SB \ 1037396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1038813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1039d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 10408fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1041cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 104268120783SChris Kay ENABLE_MPMM \ 104368120783SChris Kay ENABLE_MPMM_FCONF \ 1044327131c4SLeonardo Sandoval))) 104573c99d4eSJuan Castillo 1046327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 1047327131c4SLeonardo Sandoval $(sort \ 1048327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1049327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1050327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 1051327131c4SLeonardo Sandoval FW_ENC_STATUS \ 10525357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 10535357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1054327131c4SLeonardo Sandoval))) 1055c877b414SJeenu Viswambharan 1056aacff749SJustin Chadwellifdef KEY_SIZE 1057aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1058aacff749SJustin Chadwellendif 1059aacff749SJustin Chadwell 10601f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 10611f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 10621f461979SJustin Chadwellendif 10631f461979SJustin Chadwell 106473c99d4eSJuan Castillo################################################################################ 106573c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 106673c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 106773c99d4eSJuan Castillo# platform to overwrite the default options 106873c99d4eSJuan Castillo################################################################################ 106973c99d4eSJuan Castillo 1070327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1071327131c4SLeonardo Sandoval $(sort \ 1072327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1073327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1074327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 107546789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1076327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1077327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1078327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1079327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 1080327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1081327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 1082327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1083062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1084327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 10850063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1086327131c4SLeonardo Sandoval ENABLE_AMU \ 10871fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1088742ca230SChris Kay ENABLE_AMU_FCONF \ 1089873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1090327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1091327131c4SLeonardo Sandoval ENABLE_BTI \ 1092327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 1093327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1094327131c4SLeonardo Sandoval ENABLE_PIE \ 1095327131c4SLeonardo Sandoval ENABLE_PMF \ 1096327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 10975b18de09SZelalem Aweke ENABLE_RME \ 1098327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1099dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 1100dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 1101327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 1102327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 11030c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1104327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1105327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1106327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1107327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1108327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 1109327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 1110327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1111327131c4SLeonardo Sandoval LOG_LEVEL \ 1112327131c4SLeonardo Sandoval MEASURED_BOOT \ 1113327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1114327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1115327131c4SLeonardo Sandoval PLAT_${PLAT} \ 1116327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1117327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 1118327131c4SLeonardo Sandoval RAS_EXTENSION \ 1119327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1120327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 1121327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1122327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1123327131c4SLeonardo Sandoval SPD_${SPD} \ 1124327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1125327131c4SLeonardo Sandoval SPM_MM \ 1126327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1127327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 11287dfb9911SJimmy Brisson TRNG_SUPPORT \ 1129327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1130327131c4SLeonardo Sandoval USE_DEBUGFS \ 1131327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1132327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1133327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1134327131c4SLeonardo Sandoval USE_ROMLIB \ 1135327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1136327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1137327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1138327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1139327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1140327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1141327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 1142327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1143327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1144327131c4SLeonardo Sandoval USE_SP804_TIMER \ 114512cd65e0STomas Pilar ENABLE_FEAT_RNG \ 11464e04478aSChris Kay ENABLE_FEAT_SB \ 11475357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 11485357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1149396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1150813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1151d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 11528fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1153cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 115468120783SChris Kay ENABLE_MPMM \ 115568120783SChris Kay ENABLE_MPMM_FCONF \ 1156327131c4SLeonardo Sandoval))) 11572fae4b1eSJeenu Viswambharan 11581f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 11591f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 11601f461979SJustin Chadwellendif 11611f461979SJustin Chadwell 11624c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 11634c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 11644c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1165cf2c8a33SAntonio Nino Diazelse 116668450a6dSAntonio Nino Diaz # Define the PRELOADED_BL33_BASE flag only if it is provided and 116768450a6dSAntonio Nino Diaz # EL3_PAYLOAD_BASE is not defined, as it has priority. 116868450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 116968450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 11704c117f6cSSandrine Bailleux endif 1171cf2c8a33SAntonio Nino Diazendif 117273c99d4eSJuan Castillo 1173209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1174209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1175209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH)) 1176209a60ccSSoby Mathewendif 1177209a60ccSSoby Mathew 1178c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1179c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK)) 1180c2ad38ceSVarun Wadekarendif 1181c2ad38ceSVarun Wadekar 1182ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1183ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1184c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1185ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1186ce2b1ec6SManish Pandey FIP_DEPS += sp 118707c44475SManish Pandey CRT_DEPS += sp 1188ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1189ce2b1ec6SManish Pandeyelse 1190c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1191c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1192c33ff198SOlivier Deprez endif 1193ce2b1ec6SManish Pandeyendif 1194ce2b1ec6SManish Pandeyendif 1195ce2b1ec6SManish Pandey 119673c99d4eSJuan Castillo################################################################################ 119773c99d4eSJuan Castillo# Build targets 119873c99d4eSJuan Castillo################################################################################ 119973c99d4eSJuan Castillo 120090aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 120173c99d4eSJuan Castillo.SUFFIXES: 120273c99d4eSJuan Castillo 120373c99d4eSJuan Castilloall: msg_start 120473c99d4eSJuan Castillo 120573c99d4eSJuan Castillomsg_start: 120673c99d4eSJuan Castillo @echo "Building ${PLAT}" 120773c99d4eSJuan Castillo 12087a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1209d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1210c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1211c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1212c2ad38ceSVarun Wadekarelse 1213bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 12147a24cba5SSoby Mathewendif 1215d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED 12167a24cba5SSoby Mathew 12175accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 121861f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 12195fee0287SRoberto Vargas 122073c99d4eSJuan Castillo# Expand build macros for the different images 122173c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1222b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1223b34635a0SChris Kay 1224434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 122573c99d4eSJuan Castilloendif 122673c99d4eSJuan Castillo 122773c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1228c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0) 1229c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1230c9b31ae8SRoberto Vargasendif 1231c9b31ae8SRoberto Vargas 1232eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1233eb1acfb6SChris Kay 123433950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1235434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 123673c99d4eSJuan Castilloendif 123773c99d4eSJuan Castillo 12384d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 123933950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 12404d045d0eSMasahiro Yamadaendif 12414d045d0eSMasahiro Yamada 124273c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 124373c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 124426d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 124526d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1246c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1247c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1248434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1249c6ba9b45SSumit Gargelse 125033950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1251434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 125273c99d4eSJuan Castilloendif 1253c6ba9b45SSumit Gargendif 125473c99d4eSJuan Castillo 125570d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1256c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 125770d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 125873c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 125926d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 126026d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 12619cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 12629cd15239SMasahiro Yamada 1263c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1264434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1265c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1266c6ba9b45SSumit Gargelse 1267434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 126833950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 126973c99d4eSJuan Castilloendif 1270c6ba9b45SSumit Gargendif 127173c99d4eSJuan Castillo 12725b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 12735b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 12745b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 12755b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 12765b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 12775b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 12785b18de09SZelalem Aweke 12795b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 12805b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 12815b18de09SZelalem Awekeendif 12825b18de09SZelalem Aweke 128373c99d4eSJuan Castillo# Add the BL33 image if required by the platform 128473c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 128533950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1286db6071c9SJuan Castilloendif 1287db6071c9SJuan Castillo 12889003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 128933950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1290434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 12919003fa0bSYatharth Kocharendif 12929003fa0bSYatharth Kochar 129303b397a8SNishanth Menon# Expand build macros for the different images 129403b397a8SNishanth Menonifeq (${NEED_FDT},yes) 129503b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 129603b397a8SNishanth Menonendif 129703b397a8SNishanth Menon 1298ce2b1ec6SManish Pandey# Add Secure Partition packages 1299ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1300ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 13011e7528ecSRuari Phipps ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1302ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk 1303ce2b1ec6SManish Pandey ${Q}$(SPTOOL) $(SPTOOL_ARGS) 1304ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1305ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1306ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1307ce2b1ec6SManish Pandeyendif 1308ce2b1ec6SManish Pandey 130936eaaf37SIan Spraylocate-checkpatch: 131036eaaf37SIan Sprayifndef CHECKPATCH 131166079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 131236eaaf37SIan Sprayelse 131336eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 131466079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 131536eaaf37SIan Sprayendif 131636eaaf37SIan Sprayendif 131736eaaf37SIan Spray 13184f6ad66aSAchin Guptaclean: 13194f6ad66aSAchin Gupta @echo " CLEAN" 1320f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 132188a1cf1eSSami Mujawarifdef UNIX_MK 13222f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 132388a1cf1eSSami Mujawarelse 132488a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 132588a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 132688a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 132788a1cf1eSSami Mujawarendif 13286f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 132990aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 13305accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 13314f6ad66aSAchin Gupta 1332eaaeece2SJames Morrisseyrealclean distclean: 1333eaaeece2SJames Morrissey @echo " REALCLEAN" 1334f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1335f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 133688a1cf1eSSami Mujawarifdef UNIX_MK 13372f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 133888a1cf1eSSami Mujawarelse 133988a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 134088a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 134188a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 134288a1cf1eSSami Mujawarendif 134326010da1SAntonio Nino Diaz ${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean 13446f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 134590aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 13465accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 13474f6ad66aSAchin Gupta 134836eaaf37SIan Spraycheckcodebase: locate-checkpatch 134936eaaf37SIan Spray @echo " CHECKING STYLE" 135036eaaf37SIan Spray @if test -d .git ; then \ 13511ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 13521a41e8c1SDan Handley while read GIT_FILE ; \ 13531a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 13541a41e8c1SDan Handley done ; \ 135536eaaf37SIan Spray else \ 13561a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 13571a41e8c1SDan Handley -not -iwholename "*build*" \ 13581a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 135961f72a34SRoberto Vargas -not -iwholename "*libc*" \ 13601a41e8c1SDan Handley -not -iwholename "*docs*" \ 13611ef35512SPaul Beesley -not -iwholename "*.rst" \ 13621a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 136336eaaf37SIan Spray fi 136436eaaf37SIan Spray 136536eaaf37SIan Spraycheckpatch: locate-checkpatch 136636eaaf37SIan Spray @echo " CHECKING STYLE" 136702a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 136802a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 136902a76d5fSYann Gautier fi 137051d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 137177a0a7f1SYann Gautier for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 137277a0a7f1SYann Gautier do \ 137351d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 137451d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 137502a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 137602a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 137751d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 137802a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 137902a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 138051d28937SAntonio Nino Diaz done 138136eaaf37SIan Spray 138273c99d4eSJuan Castillocerttool: ${CRTTOOL} 138373c99d4eSJuan Castillo 1384a9812206SPali Rohár${CRTTOOL}: FORCE 1385fafd3ec9SManish V Badarkhe ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} --no-print-directory -C ${CRTTOOLPATH} 1386f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13876f971622SJuan Castillo @echo "Built $@ successfully" 1388f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13896f971622SJuan Castillo 13906f971622SJuan Castilloifneq (${GENERATE_COT},0) 139173c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 13926f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1393f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13946f971622SJuan Castillo @echo "Built $@ successfully" 13956f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1396f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 139773c99d4eSJuan Castilloendif 139827713fb4SSoby Mathew 139973c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 14004727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1401819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1402819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1403f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 14042f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1405f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1406f58ad36fSHarry Liebel 14070191262dSYatharth Kocharifneq (${GENERATE_COT},0) 14080191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 14090191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1410052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14110191262dSYatharth Kochar @echo "Built $@ successfully" 14120191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1413052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14140191262dSYatharth Kocharendif 14150191262dSYatharth Kochar 14160191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 14174727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1418819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1419819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1420052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14210191262dSYatharth Kochar @echo "Built $@ successfully" 1422052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14230191262dSYatharth Kochar 142473c99d4eSJuan Castillofiptool: ${FIPTOOL} 142573c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 14260191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 142773c99d4eSJuan Castillo 1428a9812206SPali Rohár${FIPTOOL}: FORCE 142988a1cf1eSSami Mujawarifdef UNIX_MK 1430*0a956f81SRoss Burton ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} --no-print-directory -C ${FIPTOOLPATH} 143188a1cf1eSSami Mujawarelse 143288a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 143388a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 143488a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 143588a1cf1eSSami Mujawarendif 1436f58ad36fSHarry Liebel 143726010da1SAntonio Nino Diazsptool: ${SPTOOL} 1438a9812206SPali Rohár${SPTOOL}: FORCE 1439fafd3ec9SManish V Badarkhe ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH} 144026010da1SAntonio Nino Diaz 1441a9812206SPali Rohárromlib.bin: libraries FORCE 1442bbb24f61SJohn Tsichritzis ${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 14435accce5bSRoberto Vargas 1444cfe83910SLouis Mayencourt# Call print_memory_map tool 1445cfe83910SLouis Mayencourtmemmap: all 1446b890b36dSLouis Mayencourt ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1447cfe83910SLouis Mayencourt 14486de32378SMadhukar Pappireddydoc: 14496de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 14506de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 14516de32378SMadhukar Pappireddy 145290aa901fSSumit Gargenctool: ${ENCTOOL} 145390aa901fSSumit Garg 1454a9812206SPali Rohár${ENCTOOL}: FORCE 1455fafd3ec9SManish V Badarkhe ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH} 145690aa901fSSumit Garg @${ECHO_BLANK_LINE} 145790aa901fSSumit Garg @echo "Built $@ successfully" 145890aa901fSSumit Garg @${ECHO_BLANK_LINE} 145990aa901fSSumit Garg 146035fab8c9SJoakim Bechcscope: 146135fab8c9SJoakim Bech @echo " CSCOPE" 146235fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 146335fab8c9SJoakim Bech ${Q}cscope -b -q -k 146435fab8c9SJoakim Bech 146572ee3314SRyan Harkinhelp: 14667c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 146772ee3314SRyan Harkin @echo "" 146872ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 146908c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 147072ee3314SRyan Harkin @echo "" 14717c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 14727c23126cSJohn Tsichritzis @echo "" 14731b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 14741b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 14751b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 14761b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 14771b578596SSandrine Bailleux @echo "" 147872ee3314SRyan Harkin @echo "Supported Targets:" 14791b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 148036eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 14818aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 14829003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1483d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 14849d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 14859d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 148673c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 14871b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 14880191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 148936eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 149036eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 149136eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 149272ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 149335fab8c9SJoakim Bech @echo " cscope Generate cscope index" 149472ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 14956f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 149690aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1497f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1498ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 149926010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 150038c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1501cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 15026de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 150372ee3314SRyan Harkin @echo "" 15041b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 150572ee3314SRyan Harkin @echo "" 150672ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 150772ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1508a9812206SPali Rohár 1509a9812206SPali Rohár.PHONY: FORCE 1510a9812206SPali RohárFORCE:; 1511