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 11ff2da9e3SMadhukar PappireddyVERSION_MINOR := 5 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 Mathewelse 154c97cba4eSSoby Mathew $(info USE_SPINLOCK_CAS is an experimental feature) 155c97cba4eSSoby Mathewendif 156c97cba4eSSoby Mathewendif 157c97cba4eSSoby Mathew 1580ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds 1590ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1) 1600ca3913dSOlivier Deprezifeq (${DEBUG},1) 1610ca3913dSOlivier Deprez $(warning DEBUGFS experimental feature is enabled.) 1620ca3913dSOlivier Deprezelse 1630ca3913dSOlivier Deprez $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 1640ca3913dSOlivier Deprezendif 1650ca3913dSOlivier Deprezendif 1660ca3913dSOlivier Deprez 167c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 168c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS} 169c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY} 170c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE} 171c6ba9b45SSumit GargFIP_DEPS += enctool 172c6ba9b45SSumit GargFWU_FIP_DEPS += enctool 173c6ba9b45SSumit Gargendif 174c6ba9b45SSumit Garg 17573c99d4eSJuan Castillo################################################################################ 17673c99d4eSJuan Castillo# Toolchain 17773c99d4eSJuan Castillo################################################################################ 17873c99d4eSJuan Castillo 17972610c41Sdp-armHOSTCC := gcc 18072610c41Sdp-armexport HOSTCC 18172610c41Sdp-arm 18273c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 18373c99d4eSJuan CastilloCPP := ${CROSS_COMPILE}cpp 18473c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 18573c99d4eSJuan CastilloAR := ${CROSS_COMPILE}ar 1862adee763SRoberto VargasLINKER := ${CROSS_COMPILE}ld 18773c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 18873c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 18973c99d4eSJuan CastilloNM := ${CROSS_COMPILE}nm 19073c99d4eSJuan CastilloPP := ${CROSS_COMPILE}gcc -E 19138c14d88SSoby MathewDTC := dtc 19273c99d4eSJuan Castillo 193b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 194b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \ 1952adee763SRoberto Vargas $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 1962adee763SRoberto VargasLINKER := ${LINKER}.bfd 197b25a577fSJulius Wernerendif 198b25a577fSJulius Werner 19926e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 20026e63c44SEtienne Carrieretarget32-directive = -target arm-none-eabi 20126e63c44SEtienne Carriere# Will set march32-directive from platform configuration 20226e63c44SEtienne Carriereelse 20326e63c44SEtienne Carrieretarget32-directive = -target armv8a-none-eabi 204fa6f774bSAlexei Fedorov 205f1821790SAlexei Fedorov# Set the compiler's target architecture profile based on 206f1821790SAlexei Fedorov# ARM_ARCH_MAJOR ARM_ARCH_MINOR options 207fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0) 208f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}-a 209f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}-a 210fa6f774bSAlexei Fedorovelse 211f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 212f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 213fa6f774bSAlexei Fedorovendif 21426e63c44SEtienne Carriereendif 21526e63c44SEtienne Carriere 2167ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards 2177ff088d1SManish V Badarkheifeq ($(ARCH), aarch64) 2184a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5 2194a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 2207ff088d1SManish V Badarkhemem_tag_arch_support = yes 2217ff088d1SManish V Badarkheendif 2227ff088d1SManish V Badarkheendif 2237ff088d1SManish V Badarkhe 224f1821790SAlexei Fedorov# Get architecture feature modifiers 225f1821790SAlexei Fedorovarch-features = ${ARM_ARCH_FEATURE} 226f1821790SAlexei Fedorov 227f1821790SAlexei Fedorov# Enable required options for memory stack tagging. 228f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler. 2297ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes) 2307ff088d1SManish V Badarkheifdef mem_tag_arch_support 231f1821790SAlexei Fedorov# Check for armclang and clang compilers 2327ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 233f1821790SAlexei Fedorov# Add "memtag" architecture feature modifier if not specified 234f1821790SAlexei Fedorovifeq ( ,$(findstring memtag,$(arch-features))) 235f1821790SAlexei Fedorovarch-features := $(arch-features)+memtag 236f1821790SAlexei Fedorovendif # memtag 2377ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang) 2387ff088d1SManish V BadarkheTF_CFLAGS += -mmemtag-stack 2397ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang) 2407ff088d1SManish V BadarkheTF_CFLAGS += -fsanitize=memtag 241f1821790SAlexei Fedorovendif # armclang 242f1821790SAlexei Fedorovendif # armclang clang 2437ff088d1SManish V Badarkheelse 2447ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \ 2457ff088d1SManish V Badarkhe ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 246f1821790SAlexei Fedorovendif # mem_tag_arch_support 247f1821790SAlexei Fedorovendif # SUPPORT_STACK_MEMTAG 248f1821790SAlexei Fedorov 249f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers 250f1821790SAlexei Fedorovifneq ($(arch-features), none) 251f1821790SAlexei Fedorov# Strip "none+" from arch-features 252f1821790SAlexei Fedorovarch-features := $(subst none+,,$(arch-features)) 253f1821790SAlexei Fedorovifeq ($(ARCH), aarch32) 254f1821790SAlexei Fedorovmarch32-directive := $(march32-directive)+$(arch-features) 255f1821790SAlexei Fedorovelse 256f1821790SAlexei Fedorovmarch64-directive := $(march64-directive)+$(arch-features) 2577ff088d1SManish V Badarkheendif 258f1821790SAlexei Fedorov# Print features 259f1821790SAlexei Fedorov$(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 260f1821790SAlexei Fedorovendif # arch-features 2617ff088d1SManish V Badarkhe 26212cd65e0STomas Pilar# Determine if FEAT_RNG is supported 26312cd65e0STomas PilarENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) 26412cd65e0STomas Pilar 2654e04478aSChris Kay# Determine if FEAT_SB is supported 2664e04478aSChris KayENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) 2674e04478aSChris Kay 2684e04478aSChris Kayifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 2694e04478aSChris KayENABLE_FEAT_SB = 1 2704e04478aSChris Kayendif 2714e04478aSChris Kay 272fd18a8fcSVarun Wadekarifneq ($(findstring armclang,$(notdir $(CC))),) 27326e63c44SEtienne CarriereTF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive) 274fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi $(march64-directive) 2752adee763SRoberto VargasLD = $(LINKER) 2761684b873SRoberto VargasAS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 2777040155eSRoberto VargasCPP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 2787040155eSRoberto VargasPP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 2797559633bSdp-armelse ifneq ($(findstring clang,$(notdir $(CC))),) 280eff737c1SArve HjønnevågCLANG_CCDIR = $(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),) 281e2bfec0bSYann GautierTF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) 282fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = -target aarch64-elf $(march64-directive) 283eff737c1SArve HjønnevågLD = $(CLANG_CCDIR)ld.lld 284641f16e7SAmbroise Vincentifeq (, $(shell which $(LD))) 285641f16e7SAmbroise Vincent$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker") 286641f16e7SAmbroise Vincentendif 2871684b873SRoberto VargasAS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 2887040155eSRoberto VargasCPP = $(CC) -E 2897040155eSRoberto VargasPP = $(CC) -E 290edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),) 291edbce9aaSzelalem-awekeTF_CFLAGS_aarch32 = $(march32-directive) 292edbce9aaSzelalem-awekeTF_CFLAGS_aarch64 = $(march64-directive) 293edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 294edbce9aaSzelalem-aweke # Enable LTO only for aarch64 295edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 296edbce9aaSzelalem-aweke LTO_CFLAGS = -flto 297edbce9aaSzelalem-aweke # Use gcc as a wrapper for the ld, recommended for LTO 298edbce9aaSzelalem-aweke LINKER := ${CROSS_COMPILE}gcc 299edbce9aaSzelalem-aweke endif 300edbce9aaSzelalem-awekeendif 301edbce9aaSzelalem-awekeLD = $(LINKER) 302d5461857Sdp-armelse 30326e63c44SEtienne CarriereTF_CFLAGS_aarch32 = $(march32-directive) 304fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = $(march64-directive) 3052adee763SRoberto VargasLD = $(LINKER) 306d5461857Sdp-armendif 307d5461857Sdp-arm 30832b209bfSAhmad Fatoum# Process Debug flag 30932b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 31032b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 31132b209bfSAhmad Fatoum BUILD_TYPE := debug 31232b209bfSAhmad Fatoum TF_CFLAGS += -g 31332b209bfSAhmad Fatoum 31432b209bfSAhmad Fatoum ifneq ($(findstring clang,$(notdir $(CC))),) 31532b209bfSAhmad Fatoum ASFLAGS += -g 31632b209bfSAhmad Fatoum else 31732b209bfSAhmad Fatoum ASFLAGS += -g -Wa,--gdwarf-2 31832b209bfSAhmad Fatoum endif 31932b209bfSAhmad Fatoum 32032b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 32132b209bfSAhmad Fatoum LOG_LEVEL := 40 32232b209bfSAhmad Fatoumelse 32332b209bfSAhmad Fatoum BUILD_TYPE := release 32432b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 32532b209bfSAhmad Fatoum LOG_LEVEL := 20 32632b209bfSAhmad Fatoumendif 32732b209bfSAhmad Fatoum 328f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 329f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 330f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 331f1de4c8fSPeiyuan Songendif 332f1de4c8fSPeiyuan SongVERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING} 333f1de4c8fSPeiyuan Song 3348fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 3358fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -marm 3368fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 3378fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -mthumb 3388fd9d4d5SAntonio Nino Diazelse 3398fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 3408fd9d4d5SAntonio Nino Diazendif 3418fd9d4d5SAntonio Nino Diaz 342a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 343d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 3449d29c227SSoby Mathew 3459fc59639SAlexei Fedorovifneq (${BP_OPTION},none) 3469fc59639SAlexei FedorovTF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 3479fc59639SAlexei Fedorovendif 3489fc59639SAlexei Fedorov 34926e63c44SEtienne CarriereASFLAGS_aarch32 = $(march32-directive) 350fa6f774bSAlexei FedorovASFLAGS_aarch64 = $(march64-directive) 351b86048c4SAntonio Nino Diaz 3529ab81b5eSJustin Chadwell# General warnings 3539ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 354b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 355ca661a00SMadhukar Pappireddy -Wno-unused-parameter -Wredundant-decls 3569ab81b5eSJustin Chadwell 3579ab81b5eSJustin Chadwell# Additional warnings 3589ab81b5eSJustin Chadwell# Level 1 359e7c645b5SYann GautierWARNING1 := -Wextra 360e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute 361e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes 362e7c645b5SYann GautierWARNING1 += -Wold-style-definition 363e7c645b5SYann Gautier 364b7f6525dSJustin Chadwell# Level 2 365e7c645b5SYann GautierWARNING2 := -Waggregate-return 366e7c645b5SYann GautierWARNING2 += -Wcast-align 367e7c645b5SYann GautierWARNING2 += -Wnested-externs 368e7c645b5SYann Gautier 369e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 370e7c645b5SYann GautierWARNING3 += -Wcast-qual 371e7c645b5SYann GautierWARNING3 += -Wconversion 372e7c645b5SYann GautierWARNING3 += -Wpacked 373e7c645b5SYann GautierWARNING3 += -Wpointer-arith 374e7c645b5SYann GautierWARNING3 += -Wswitch-default 375e7c645b5SYann Gautier 376e7c645b5SYann Gautierifeq (${W},1) 3779ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) 378e7c645b5SYann Gautierelse ifeq (${W},2) 3799ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) 380e7c645b5SYann Gautierelse ifeq (${W},3) 3819ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 382e7c645b5SYann Gautierendif 383e7c645b5SYann Gautier 3849ab81b5eSJustin Chadwell# Compiler specific warnings 38500296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),) 38693c690ebSJustin Chadwell# not using clang 387d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 388d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 389d7b4cd41SJustin Chadwell -Wlogical-op 39093c690ebSJustin Chadwellelse 39193c690ebSJustin Chadwell# using clang 392d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 393d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 39400296576SAmbroise Vincentendif 39500296576SAmbroise Vincent 3966336b07aSYann Gautierifneq (${E},0) 3976336b07aSYann GautierERRORS := -Werror 3986336b07aSYann Gautierendif 3996336b07aSYann Gautier 400ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 4019ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 40259de5096SMasahiro YamadaASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 403d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 40459de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 405ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 406ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 407ebd6efaeSSamuel Holland -Os -std=gnu99 40873c99d4eSJuan Castillo 4091f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4101f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 4111f461979SJustin Chadwellendif 4121f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 4131f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 4141f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 4151f461979SJustin Chadwellendif 4161f461979SJustin Chadwell 417f7ec31dbSdavid cunadoGCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 418f7ec31dbSdavid cunado 419641f16e7SAmbroise Vincent# LD = armlink 420c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 421c2ad38ceSVarun WadekarTF_LDFLAGS += --diag_error=warning --lto_level=O1 422c2ad38ceSVarun WadekarTF_LDFLAGS += --remove --info=unused,unusedsymbols 423edbce9aaSzelalem-awekeTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 424641f16e7SAmbroise Vincent 425641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 426edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 427edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches 428edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--fatal-warnings -O1 429edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--gc-sections 430edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 431edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 432edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 433edbce9aaSzelalem-aweke endif 434edbce9aaSzelalem-awekeendif 435edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 436edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 437edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1) 438edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 439edbce9aaSzelalem-awekeendif 440edbce9aaSzelalem-awekeTF_LDFLAGS += -nostdlib 441edbce9aaSzelalem-awekeTF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 442641f16e7SAmbroise Vincent 443641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 444c2ad38ceSVarun Wadekarelse 445c2b8806fSDouglas RaillardTF_LDFLAGS += --fatal-warnings -O1 446c2b8806fSDouglas RaillardTF_LDFLAGS += --gc-sections 447641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 448641f16e7SAmbroise Vincent# therefore don't add those in that case 449641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),) 450c2b8806fSDouglas RaillardTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 451edbce9aaSzelalem-awekeendif 452641f16e7SAmbroise Vincentendif 45373c99d4eSJuan Castillo 45403b397a8SNishanth MenonDTC_FLAGS += -I dts -O dtb 455a6de824fSLouis MayencourtDTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 456a6de824fSLouis Mayencourt -x assembler-with-cpp $(DEFINES) 45703b397a8SNishanth Menon 4580ab49645SAlexei Fedorovifeq ($(MEASURED_BOOT),1) 4590ab49645SAlexei FedorovDTC_CPPFLAGS += -DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE} 4600ab49645SAlexei Fedorovendif 4610ab49645SAlexei Fedorov 46273c99d4eSJuan Castillo################################################################################ 46373c99d4eSJuan Castillo# Common sources and include directories 46473c99d4eSJuan Castillo################################################################################ 465d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 46673c99d4eSJuan Castillo 46773c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 4687f56e9a3SSoby Mathew common/tf_log.c \ 4699d29c227SSoby Mathew common/${ARCH}/debug.S \ 47091b48c9fSJulius Werner drivers/console/multi_console.c \ 4719d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 4729d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 473566034fcSSoby Mathew plat/common/plat_bl_common.c \ 4747f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 47575311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 4769d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 47761f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 478d7a6b0f8SRyan Harkin 4798422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang) 4808422a840SAntonio Nino DiazBL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 4818422a840SAntonio Nino Diazendif 4828422a840SAntonio Nino Diaz 4831f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4841f461979SJustin ChadwellBL_COMMON_SOURCES += plat/common/ubsan.c 4851f461979SJustin Chadwellendif 4861f461979SJustin Chadwell 48701d237cbSYann GautierINCLUDES += -Iinclude \ 488f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 48909d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 49009d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 49109d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 49209d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 49309d40e0eSAntonio Nino Diaz 4949c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 4959c6d1c50SAntonio Nino Diaz 49673c99d4eSJuan Castillo################################################################################ 49773c99d4eSJuan Castillo# Generic definitions 49873c99d4eSJuan Castillo################################################################################ 49973c99d4eSJuan Castillo 500231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 501231c1470SEvan Lloyd 50229214e95SGrant Likelyifeq (${BUILD_BASE},) 50373c99d4eSJuan Castillo BUILD_BASE := ./build 50429214e95SGrant Likelyendif 50529214e95SGrant LikelyBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 50673c99d4eSJuan Castillo 507231c1470SEvan LloydSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 50873c99d4eSJuan Castillo 50973c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value 51073c99d4eSJuan CastilloINCLUDE_TBBR_MK := 1 51173c99d4eSJuan Castillo 51273c99d4eSJuan Castillo 51373c99d4eSJuan Castillo################################################################################ 51473c99d4eSJuan Castillo# Include SPD Makefile if one has been specified 51573c99d4eSJuan Castillo################################################################################ 51673c99d4eSJuan Castillo 51773c99d4eSJuan Castilloifneq (${SPD},none) 5189d29c227SSoby Mathew ifeq (${ARCH},aarch32) 5199d29c227SSoby Mathew $(error "Error: SPD is incompatible with AArch32.") 5209d29c227SSoby Mathew endif 52128f39f02SMax Shvetsov 5224c117f6cSSandrine Bailleux ifdef EL3_PAYLOAD_BASE 5234c117f6cSSandrine Bailleux $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 5244c117f6cSSandrine Bailleux $(warning "The SPD and its BL32 companion will be present but ignored.") 5254c117f6cSSandrine Bailleux endif 52628f39f02SMax Shvetsov 527c3fb00d9SAchin Gupta ifeq (${SPD},spmd) 528033039f8SMax Shvetsov $(warning "SPMD is an experimental feature") 529c3fb00d9SAchin Gupta # SPMD is located in std_svc directory 530c3fb00d9SAchin Gupta SPD_DIR := std_svc 53128f39f02SMax Shvetsov 532033039f8SMax Shvetsov ifeq ($(SPMD_SPM_AT_SEL2),1) 53328f39f02SMax Shvetsov ifeq ($(CTX_INCLUDE_EL2_REGS),0) 534033039f8SMax Shvetsov $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option) 535033039f8SMax Shvetsov endif 53628f39f02SMax Shvetsov endif 537db1ef41aSOlivier Deprez 538db1ef41aSOlivier Deprez ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 539db1ef41aSOlivier Deprez DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 540db1ef41aSOlivier Deprez endif 541ca932481SDavidson K 542ca932481SDavidson K ifeq ($(TS_SP_FW_CONFIG),1) 543ca932481SDavidson K DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 544ca932481SDavidson K endif 54533993a37SBalint Dobszay 54633993a37SBalint Dobszay ifneq ($(ARM_BL2_SP_LIST_DTS),) 54733993a37SBalint Dobszay DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 54833993a37SBalint Dobszay endif 54946789a7cSBalint Dobszay 55046789a7cSBalint Dobszay ifneq ($(SP_LAYOUT_FILE),) 55146789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD := 1 55246789a7cSBalint Dobszay endif 553c3fb00d9SAchin Gupta else 554c3fb00d9SAchin Gupta # All other SPDs in spd directory 555c3fb00d9SAchin Gupta SPD_DIR := spd 556c3fb00d9SAchin Gupta endif 557c3fb00d9SAchin Gupta 55873c99d4eSJuan Castillo # We expect to locate an spd.mk under the specified SPD directory 559c3fb00d9SAchin Gupta SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 560c3fb00d9SAchin Gupta 56173c99d4eSJuan Castillo ifeq (${SPD_MAKE},) 562c3fb00d9SAchin Gupta $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 56373c99d4eSJuan Castillo endif 56473c99d4eSJuan Castillo $(info Including ${SPD_MAKE}) 56573c99d4eSJuan Castillo include ${SPD_MAKE} 56673c99d4eSJuan Castillo 56770d1fc53SJuan Castillo # If there's BL32 companion for the chosen SPD, we expect that the SPD's 56870d1fc53SJuan Castillo # Makefile would set NEED_BL32 to "yes". In this case, the build system 56970d1fc53SJuan Castillo # supports two mutually exclusive options: 57070d1fc53SJuan Castillo # * BL32 is built from source: then BL32_SOURCES must contain the list 57170d1fc53SJuan Castillo # of source files to build BL32 57270d1fc53SJuan Castillo # * BL32 is a prebuilt binary: then BL32 must point to the image file 57370d1fc53SJuan Castillo # that will be included in the FIP 57470d1fc53SJuan Castillo # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 57570d1fc53SJuan Castillo # over the sources. 576e35c4045SJeenu Viswambharanendif 577e35c4045SJeenu Viswambharan 57851faada7SDouglas Raillard################################################################################ 5795b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled 5805b18de09SZelalem Aweke################################################################################ 5815b18de09SZelalem Aweke 5825b18de09SZelalem Awekeifneq (${ENABLE_RME},0) 5835b18de09SZelalem Awekeifneq (${ARCH},aarch64) 5845b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 5855b18de09SZelalem Awekeendif 5865b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk 5875b18de09SZelalem Aweke$(warning "RME is an experimental feature") 5885b18de09SZelalem Awekeendif 5895b18de09SZelalem Aweke 5905b18de09SZelalem Aweke################################################################################ 59173c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform 59273c99d4eSJuan Castillo# makefile may use all previous definitions in this file) 59373c99d4eSJuan Castillo################################################################################ 5942da8d8bfSJeenu Viswambharan 59573c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL} 5960f21c547SJuan Castillo 5978012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 5988012cc5cSMasahiro Yamada 59926e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 60026e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 60126e63c44SEtienne Carriereendif 60226e63c44SEtienne Carriere 6033bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 6043bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 6053bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 6063bd17c0fSSoby Mathewendif 607320920c1SMasahiro Yamada 608320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),) 609320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 610320920c1SMasahiro Yamadaelse 611320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 612320920c1SMasahiro Yamadaendif 613320920c1SMasahiro Yamada 614320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 61569af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 61669af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1) 61769af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 61869af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 61969af7fcfSMasahiro Yamadaendif 62069af7fcfSMasahiro Yamadaendif 621320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 622320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 623d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 624d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 625d974301dSMasahiro Yamadaendif 6263bd17c0fSSoby Mathew 627d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64) 6289cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 629d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 6309cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3 631d5e97a1dSMasahiro Yamadaelse 6329cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1 633d5e97a1dSMasahiro Yamadaendif 6349cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1 6359cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3 6369cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1 637d5e97a1dSMasahiro Yamadaendif 638d5e97a1dSMasahiro Yamada 63954035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 64054035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 64154035fc4SSandrine Bailleux# This can be overridden by the platform. 64273c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 6434f6ad66aSAchin Gupta 644a4409008Sdp-armifeq (${ARCH},aarch32) 645a4409008Sdp-armNEED_BL32 := yes 646a4409008Sdp-arm 647a4409008Sdp-arm################################################################################ 648a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 649a4409008Sdp-arm################################################################################ 650a4409008Sdp-armifneq (${AARCH32_SP},none) 651a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory 652a4409008Sdp-armAARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 653a4409008Sdp-arm 654a4409008Sdp-armifeq (${AARCH32_SP_MAKE},) 655a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 656a4409008Sdp-armendif 657a4409008Sdp-arm 658a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE}) 659a4409008Sdp-arminclude ${AARCH32_SP_MAKE} 660a4409008Sdp-armendif 661a4409008Sdp-arm 662a4409008Sdp-armendif 6634f6ad66aSAchin Gupta 66473c99d4eSJuan Castillo################################################################################ 66577f1f7a1SVarun Wadekar# Include libc if not overridden 66677f1f7a1SVarun Wadekar################################################################################ 66777f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 66877f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 66977f1f7a1SVarun Wadekarendif 67077f1f7a1SVarun Wadekar 67177f1f7a1SVarun Wadekar################################################################################ 672cf2c8a33SAntonio Nino Diaz# Check incompatible options 673cf2c8a33SAntonio Nino Diaz################################################################################ 674cf2c8a33SAntonio Nino Diaz 675cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 67668450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 67768450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 67868450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 679cf2c8a33SAntonio Nino Diaz endif 68076580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 68176580f3dSQixiang Xu $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 68276580f3dSQixiang Xu endif 68376580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 68476580f3dSQixiang Xu $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 68576580f3dSQixiang Xu endif 686cf2c8a33SAntonio Nino Diazendif 687cf2c8a33SAntonio Nino Diaz 688cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 689cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 690cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 691cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 692cf2c8a33SAntonio Nino Diaz endif 69368450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 69468450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 69568450a6dSAntonio Nino Diaz PRELOADED_BL33_BASE is used and won't be added to the FIP \ 69668450a6dSAntonio Nino Diaz file.") 697cf2c8a33SAntonio Nino Diaz endif 698cf2c8a33SAntonio Nino Diazendif 699cf2c8a33SAntonio Nino Diaz 700d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 701d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 702d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 703d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 704d4593e47SJeenu Viswambharanendif 7051a0a3f06SYatharth Kochar 7067d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1. 7077d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1) 7087d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled") 7097d173fc5SJiafei Panendif 7107d173fc5SJiafei Pan 71114c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first 71214c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 71314c6016aSJeenu Viswambharan ifneq ($(HANDLE_EA_EL3_FIRST),1) 71414c6016aSJeenu Viswambharan $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1) 71514c6016aSJeenu Viswambharan endif 71614c6016aSJeenu Viswambharanendif 71714c6016aSJeenu Viswambharan 7181a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled 7191a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 7201a7c1cfeSJeenu Viswambharan ifneq ($(RAS_EXTENSION),1) 7211a7c1cfeSJeenu Viswambharan $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) 7221a7c1cfeSJeenu Viswambharan endif 7231a7c1cfeSJeenu Viswambharanendif 7241a7c1cfeSJeenu Viswambharan 725ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 726209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 727209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 728209a60ccSSoby Mathew $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.") 729209a60ccSSoby Mathew endif 730209a60ccSSoby Mathewendif 731209a60ccSSoby Mathew 732cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 733cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 734cbf9e84aSBalint Dobszay$(error "SDEI_IN_FCONF is an experimental feature and is only supported when \ 735cbf9e84aSBalint Dobszay SDEI_SUPPORT is enabled") 736cbf9e84aSBalint Dobszayendif 737cbf9e84aSBalint Dobszay 73884ef9cd8SManish V Badarkheifeq ($(COT_DESC_IN_DTB),1) 73984ef9cd8SManish V Badarkhe $(info CoT in device tree is an experimental feature) 74084ef9cd8SManish V Badarkheendif 74184ef9cd8SManish V Badarkhe 742b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 7439fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 7449fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 745b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 7469fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 7479fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 74806715f85SAlexei Fedorov endif 7499fc59639SAlexei Fedorovendif 7509fc59639SAlexei Fedorov 75106715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 7529fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 7539fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 754dfc66a17SJohn Tsichritzis else 75506715f85SAlexei Fedorov $(info CTX_INCLUDE_PAUTH_REGS is an experimental feature) 756b86048c4SAntonio Nino Diaz endif 757b86048c4SAntonio Nino Diazendif 7589fc59639SAlexei Fedorov 7599fc59639SAlexei Fedorovifeq ($(ENABLE_PAUTH),1) 7609fc59639SAlexei Fedorov $(info Pointer Authentication is an experimental feature) 7619fc59639SAlexei Fedorovendif 7629fc59639SAlexei Fedorov 7639fc59639SAlexei Fedorovifeq ($(ENABLE_BTI),1) 7649fc59639SAlexei Fedorov $(info Branch Protection is an experimental feature) 765dfc66a17SJohn Tsichritzisendif 766b86048c4SAntonio Nino Diaz 7679dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1) 7689dd94382SJustin Chadwell ifneq (${ARCH},aarch64) 7699dd94382SJustin Chadwell $(error CTX_INCLUDE_MTE_REGS requires AArch64) 7709dd94382SJustin Chadwell else 7719dd94382SJustin Chadwell $(info CTX_INCLUDE_MTE_REGS is an experimental feature) 7729dd94382SJustin Chadwell endif 7739dd94382SJustin Chadwellendif 7749dd94382SJustin Chadwell 775cc255b9fSSandrine Bailleux# Trusted Boot is a prerequisite for Measured Boot. It provides trust that the 776cc255b9fSSandrine Bailleux# code taking the measurements and recording them has not been tampered 777cc255b9fSSandrine Bailleux# with. This is referred to as the Root of Trust for Measurement. 7788c105290SAlexei Fedorovifeq ($(MEASURED_BOOT),1) 7798c105290SAlexei Fedorov ifneq (${TRUSTED_BOARD_BOOT},1) 7807cda17bbSSumit Garg $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1) 7818c105290SAlexei Fedorov else 7828c105290SAlexei Fedorov $(info MEASURED_BOOT is an experimental feature) 7838c105290SAlexei Fedorov endif 7848c105290SAlexei Fedorovendif 7858c105290SAlexei Fedorov 786396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1) 787396b339dSManish V Badarkhe $(info PSA_FWU_SUPPORT is an experimental feature) 788396b339dSManish V Badarkheendif 789396b339dSManish V Badarkhe 79060e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 79160e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 79260e8f3cfSPetre-Ionut Tudor $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2") 79360e8f3cfSPetre-Ionut Tudor endif 79460e8f3cfSPetre-Ionut Tudorendif 79560e8f3cfSPetre-Ionut Tudor 7967cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 7977cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 7987cda17bbSSumit Garg $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set) 7997cda17bbSSumit Garg else 8007cda17bbSSumit Garg $(info DECRYPTION_SUPPORT is an experimental feature) 8017cda17bbSSumit Garg endif 8027cda17bbSSumit Gargendif 8037cda17bbSSumit Garg 804cf2c8a33SAntonio Nino Diaz################################################################################ 80573c99d4eSJuan Castillo# Process platform overrideable behaviour 80673c99d4eSJuan Castillo################################################################################ 8074f6ad66aSAchin Gupta 8085f24ce96SManish Pandeyifdef BL1_SOURCES 8095f24ce96SManish PandeyNEED_BL1 := yes 8105f24ce96SManish Pandeyendif 8115f24ce96SManish Pandey 8125f24ce96SManish Pandeyifdef BL2_SOURCES 8135f24ce96SManish Pandey NEED_BL2 := yes 8145f24ce96SManish Pandey 815bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 816bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 817cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 818cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 819cf2c8a33SAntonio Nino Diaz # in the FIP file. 8204c117f6cSSandrine Bailleux NEED_BL33 := no 821cf2c8a33SAntonio Nino Diaz else 82268450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 823cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 824cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 825cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 826cf2c8a33SAntonio Nino Diaz else 827cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 828cf2c8a33SAntonio Nino Diaz endif 8294c117f6cSSandrine Bailleux endif 83073c99d4eSJuan Castilloendif 8316f971622SJuan Castillo 8325f24ce96SManish Pandeyifdef BL2U_SOURCES 8335f24ce96SManish PandeyNEED_BL2U := yes 8345f24ce96SManish Pandeyendif 8355f24ce96SManish Pandey 8364d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 8374d045d0eSMasahiro Yamadaifdef SCP_BL2 8384d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 8394d045d0eSMasahiro Yamadaendif 8404d045d0eSMasahiro Yamada 8415744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 8425744e874SSoby Mathewifneq (${ARCH},aarch32) 8435744e874SSoby Mathew ifdef BL31_SOURCES 8445744e874SSoby Mathew # When booting an EL3 payload, there is no need to compile the BL31 image nor 8455744e874SSoby Mathew # put it in the FIP. 8465744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 8475744e874SSoby Mathew NEED_BL31 := yes 8485744e874SSoby Mathew endif 8495744e874SSoby Mathew endif 8505744e874SSoby Mathewendif 8515744e874SSoby Mathew 85273c99d4eSJuan Castillo# Process TBB related flags 8536f971622SJuan Castilloifneq (${GENERATE_COT},0) 85473c99d4eSJuan Castillo # Common cert_create options 8556f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 8566f971622SJuan Castillo $(eval CRT_ARGS += -n) 8570191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 858fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 859fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 8600191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 861fd34e7baSJuan Castillo endif 8626f971622SJuan Castillo endif 86373c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 86473c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 86573c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 86673c99d4eSJuan Castillo endif 8676f971622SJuan Castilloendif 8686f971622SJuan Castillo 8691c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 8701c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN} 8711c75d5dfSMasahiro Yamadaendif 8721c75d5dfSMasahiro Yamada 8735f24ce96SManish Pandeyifdef FDT_SOURCES 8745f24ce96SManish PandeyNEED_FDT := yes 8755f24ce96SManish Pandeyendif 8765f24ce96SManish Pandey 87773c99d4eSJuan Castillo################################################################################ 87846e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 87946e5e035SMichalis Pappas################################################################################ 88046e5e035SMichalis Pappas 88146e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 88246e5e035SMichalis Pappas 88346e5e035SMichalis Pappas################################################################################ 884819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc) 88573c99d4eSJuan Castillo################################################################################ 88673c99d4eSJuan Castillo 88773c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool 88873c99d4eSJuan CastilloCRTTOOLPATH ?= tools/cert_create 88942a45b51SEvan LloydCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 89073c99d4eSJuan Castillo 89190aa901fSSumit Garg# Variables for use with Firmware Encryption Tool 89290aa901fSSumit GargENCTOOLPATH ?= tools/encrypt_fw 89390aa901fSSumit GargENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 89490aa901fSSumit Garg 89573c99d4eSJuan Castillo# Variables for use with Firmware Image Package 896819281eeSdp-armFIPTOOLPATH ?= tools/fiptool 897819281eeSdp-armFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 89873c99d4eSJuan Castillo 89926010da1SAntonio Nino Diaz# Variables for use with sptool 90026010da1SAntonio Nino DiazSPTOOLPATH ?= tools/sptool 90126010da1SAntonio Nino DiazSPTOOL ?= ${SPTOOLPATH}/sptool${BIN_EXT} 902ce2b1ec6SManish PandeySP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 90326010da1SAntonio Nino Diaz 9045accce5bSRoberto Vargas# Variables for use with ROMLIB 9055accce5bSRoberto VargasROMLIBPATH ?= lib/romlib 9065accce5bSRoberto Vargas 907cfe83910SLouis Mayencourt# Variable for use with Python 908cfe83910SLouis MayencourtPYTHON ?= python3 909cfe83910SLouis Mayencourt 910cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP 911cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH ?= tools/memory 912cfe83910SLouis MayencourtPRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py 913cfe83910SLouis Mayencourt 9146de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool 9156de32378SMadhukar PappireddyDOCS_PATH ?= docs 9166de32378SMadhukar Pappireddy 9178a86052dSSoby Mathew################################################################################ 9188a86052dSSoby Mathew# Include BL specific makefiles 9198a86052dSSoby Mathew################################################################################ 9205f24ce96SManish Pandey 9215f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 9228a86052dSSoby Mathewinclude bl1/bl1.mk 9238a86052dSSoby Mathewendif 9248a86052dSSoby Mathew 9255f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 9268a86052dSSoby Mathewinclude bl2/bl2.mk 9278a86052dSSoby Mathewendif 9288a86052dSSoby Mathew 9295f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 9308a86052dSSoby Mathewinclude bl2u/bl2u.mk 9318a86052dSSoby Mathewendif 9328a86052dSSoby Mathew 9335744e874SSoby Mathewifeq (${NEED_BL31},yes) 9348a86052dSSoby Mathewinclude bl31/bl31.mk 9358a86052dSSoby Mathewendif 93603b397a8SNishanth Menon 93773c99d4eSJuan Castillo################################################################################ 93873c99d4eSJuan Castillo# Build options checks 93973c99d4eSJuan Castillo################################################################################ 94073c99d4eSJuan Castillo 941327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 942327131c4SLeonardo Sandoval $(sort \ 943327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 94446789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 945327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 946327131c4SLeonardo Sandoval CREATE_KEYS \ 947327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 948327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 949327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 950327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 951327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 952062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 953327131c4SLeonardo Sandoval DEBUG \ 9540063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 955327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 956327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 957327131c4SLeonardo Sandoval ENABLE_AMU \ 9581fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 959742ca230SChris Kay ENABLE_AMU_FCONF \ 960873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 961327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 962327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 963327131c4SLeonardo Sandoval ENABLE_PIE \ 964327131c4SLeonardo Sandoval ENABLE_PMF \ 965327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 9665b18de09SZelalem Aweke ENABLE_RME \ 967327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 968327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 969327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 9700c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 971327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 972327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 973327131c4SLeonardo Sandoval GENERATE_COT \ 974327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 975327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 976327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 977327131c4SLeonardo Sandoval INVERTED_MEMMAP \ 978327131c4SLeonardo Sandoval MEASURED_BOOT \ 979327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 980327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 981327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 982327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 983327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 984327131c4SLeonardo Sandoval RAS_EXTENSION \ 985327131c4SLeonardo Sandoval RESET_TO_BL31 \ 986327131c4SLeonardo Sandoval SAVE_KEYS \ 987327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 988327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 989327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 990327131c4SLeonardo Sandoval SPM_MM \ 991327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 992327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 993327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 994327131c4SLeonardo Sandoval USE_DEBUGFS \ 995327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 996327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 997327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 998327131c4SLeonardo Sandoval USE_ROMLIB \ 999327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1000327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1001327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1002327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1003327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1004327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1005327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1006327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1007327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 1008327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1009327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1010327131c4SLeonardo Sandoval USE_SP804_TIMER \ 101112cd65e0STomas Pilar ENABLE_FEAT_RNG \ 10124e04478aSChris Kay ENABLE_FEAT_SB \ 1013396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1014813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1015d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 10168fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1017cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 1018*68120783SChris Kay ENABLE_MPMM \ 1019*68120783SChris Kay ENABLE_MPMM_FCONF \ 1020327131c4SLeonardo Sandoval))) 102173c99d4eSJuan Castillo 1022327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 1023327131c4SLeonardo Sandoval $(sort \ 1024327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1025327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1026327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 1027327131c4SLeonardo Sandoval FW_ENC_STATUS \ 10285357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 10295357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1030327131c4SLeonardo Sandoval))) 1031c877b414SJeenu Viswambharan 1032aacff749SJustin Chadwellifdef KEY_SIZE 1033aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1034aacff749SJustin Chadwellendif 1035aacff749SJustin Chadwell 10361f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 10371f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 10381f461979SJustin Chadwellendif 10391f461979SJustin Chadwell 104073c99d4eSJuan Castillo################################################################################ 104173c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 104273c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 104373c99d4eSJuan Castillo# platform to overwrite the default options 104473c99d4eSJuan Castillo################################################################################ 104573c99d4eSJuan Castillo 1046327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1047327131c4SLeonardo Sandoval $(sort \ 1048327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1049327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1050327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 105146789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1052327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1053327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1054327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1055327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 1056327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1057327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 1058327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1059062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1060327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 10610063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1062327131c4SLeonardo Sandoval ENABLE_AMU \ 10631fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1064742ca230SChris Kay ENABLE_AMU_FCONF \ 1065873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1066327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1067327131c4SLeonardo Sandoval ENABLE_BTI \ 1068327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 1069327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1070327131c4SLeonardo Sandoval ENABLE_PIE \ 1071327131c4SLeonardo Sandoval ENABLE_PMF \ 1072327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 10735b18de09SZelalem Aweke ENABLE_RME \ 1074327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1075327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 1076327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 10770c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1078327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1079327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1080327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1081327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1082327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 1083327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 1084327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1085327131c4SLeonardo Sandoval LOG_LEVEL \ 1086327131c4SLeonardo Sandoval MEASURED_BOOT \ 1087327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1088327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1089327131c4SLeonardo Sandoval PLAT_${PLAT} \ 1090327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1091327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 1092327131c4SLeonardo Sandoval RAS_EXTENSION \ 1093327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1094327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 1095327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1096327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1097327131c4SLeonardo Sandoval SPD_${SPD} \ 1098327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1099327131c4SLeonardo Sandoval SPM_MM \ 1100327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1101327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 11027dfb9911SJimmy Brisson TRNG_SUPPORT \ 1103327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1104327131c4SLeonardo Sandoval USE_DEBUGFS \ 1105327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1106327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1107327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1108327131c4SLeonardo Sandoval USE_ROMLIB \ 1109327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1110327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1111327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1112327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1113327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1114327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1115327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 1116327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1117327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1118327131c4SLeonardo Sandoval USE_SP804_TIMER \ 111912cd65e0STomas Pilar ENABLE_FEAT_RNG \ 11204e04478aSChris Kay ENABLE_FEAT_SB \ 11215357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 11225357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1123396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1124813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1125d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 11268fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1127cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 1128*68120783SChris Kay ENABLE_MPMM \ 1129*68120783SChris Kay ENABLE_MPMM_FCONF \ 1130327131c4SLeonardo Sandoval))) 11312fae4b1eSJeenu Viswambharan 11321f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 11331f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 11341f461979SJustin Chadwellendif 11351f461979SJustin Chadwell 11364c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 11374c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 11384c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1139cf2c8a33SAntonio Nino Diazelse 114068450a6dSAntonio Nino Diaz # Define the PRELOADED_BL33_BASE flag only if it is provided and 114168450a6dSAntonio Nino Diaz # EL3_PAYLOAD_BASE is not defined, as it has priority. 114268450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 114368450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 11444c117f6cSSandrine Bailleux endif 1145cf2c8a33SAntonio Nino Diazendif 114673c99d4eSJuan Castillo 1147209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1148209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1149209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH)) 1150209a60ccSSoby Mathewendif 1151209a60ccSSoby Mathew 1152c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1153c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK)) 1154c2ad38ceSVarun Wadekarendif 1155c2ad38ceSVarun Wadekar 1156ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1157ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1158c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1159ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1160ce2b1ec6SManish Pandey FIP_DEPS += sp 116107c44475SManish Pandey CRT_DEPS += sp 1162ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1163ce2b1ec6SManish Pandeyelse 1164c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1165c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1166c33ff198SOlivier Deprez endif 1167ce2b1ec6SManish Pandeyendif 1168ce2b1ec6SManish Pandeyendif 1169ce2b1ec6SManish Pandey 117073c99d4eSJuan Castillo################################################################################ 117173c99d4eSJuan Castillo# Build targets 117273c99d4eSJuan Castillo################################################################################ 117373c99d4eSJuan Castillo 117490aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 117573c99d4eSJuan Castillo.SUFFIXES: 117673c99d4eSJuan Castillo 117773c99d4eSJuan Castilloall: msg_start 117873c99d4eSJuan Castillo 117973c99d4eSJuan Castillomsg_start: 118073c99d4eSJuan Castillo @echo "Building ${PLAT}" 118173c99d4eSJuan Castillo 11827a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1183d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1184c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1185c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1186c2ad38ceSVarun Wadekarelse 1187bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 11887a24cba5SSoby Mathewendif 1189d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED 11907a24cba5SSoby Mathew 11915accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 119261f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 11935fee0287SRoberto Vargas 119473c99d4eSJuan Castillo# Expand build macros for the different images 119573c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1196b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1197b34635a0SChris Kay 1198434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 119973c99d4eSJuan Castilloendif 120073c99d4eSJuan Castillo 120173c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1202c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0) 1203c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1204c9b31ae8SRoberto Vargasendif 1205c9b31ae8SRoberto Vargas 1206eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1207eb1acfb6SChris Kay 120833950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1209434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 121073c99d4eSJuan Castilloendif 121173c99d4eSJuan Castillo 12124d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 121333950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 12144d045d0eSMasahiro Yamadaendif 12154d045d0eSMasahiro Yamada 121673c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 121773c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 121826d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 121926d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1220c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1221c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1222434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1223c6ba9b45SSumit Gargelse 122433950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1225434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 122673c99d4eSJuan Castilloendif 1227c6ba9b45SSumit Gargendif 122873c99d4eSJuan Castillo 122970d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1230c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 123170d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 123273c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 123326d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 123426d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 12359cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 12369cd15239SMasahiro Yamada 1237c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1238434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1239c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1240c6ba9b45SSumit Gargelse 1241434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 124233950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 124373c99d4eSJuan Castilloendif 1244c6ba9b45SSumit Gargendif 124573c99d4eSJuan Castillo 12465b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 12475b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 12485b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 12495b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 12505b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 12515b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 12525b18de09SZelalem Aweke 12535b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 12545b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 12555b18de09SZelalem Awekeendif 12565b18de09SZelalem Aweke 125773c99d4eSJuan Castillo# Add the BL33 image if required by the platform 125873c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 125933950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1260db6071c9SJuan Castilloendif 1261db6071c9SJuan Castillo 12629003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 126333950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1264434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 12659003fa0bSYatharth Kocharendif 12669003fa0bSYatharth Kochar 126703b397a8SNishanth Menon# Expand build macros for the different images 126803b397a8SNishanth Menonifeq (${NEED_FDT},yes) 126903b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 127003b397a8SNishanth Menonendif 127103b397a8SNishanth Menon 1272ce2b1ec6SManish Pandey# Add Secure Partition packages 1273ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1274ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 12751e7528ecSRuari Phipps ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1276ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk 1277ce2b1ec6SManish Pandey ${Q}$(SPTOOL) $(SPTOOL_ARGS) 1278ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1279ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1280ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1281ce2b1ec6SManish Pandeyendif 1282ce2b1ec6SManish Pandey 128336eaaf37SIan Spraylocate-checkpatch: 128436eaaf37SIan Sprayifndef CHECKPATCH 128566079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 128636eaaf37SIan Sprayelse 128736eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 128866079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 128936eaaf37SIan Sprayendif 129036eaaf37SIan Sprayendif 129136eaaf37SIan Spray 12924f6ad66aSAchin Guptaclean: 12934f6ad66aSAchin Gupta @echo " CLEAN" 1294f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 129588a1cf1eSSami Mujawarifdef UNIX_MK 12962f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 129788a1cf1eSSami Mujawarelse 129888a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 129988a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 130088a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 130188a1cf1eSSami Mujawarendif 13026f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 130390aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 13045accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 13054f6ad66aSAchin Gupta 1306eaaeece2SJames Morrisseyrealclean distclean: 1307eaaeece2SJames Morrissey @echo " REALCLEAN" 1308f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1309f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 131088a1cf1eSSami Mujawarifdef UNIX_MK 13112f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 131288a1cf1eSSami Mujawarelse 131388a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 131488a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 131588a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 131688a1cf1eSSami Mujawarendif 131726010da1SAntonio Nino Diaz ${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean 13186f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 131990aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 13205accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 13214f6ad66aSAchin Gupta 132236eaaf37SIan Spraycheckcodebase: locate-checkpatch 132336eaaf37SIan Spray @echo " CHECKING STYLE" 132436eaaf37SIan Spray @if test -d .git ; then \ 13251ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 13261a41e8c1SDan Handley while read GIT_FILE ; \ 13271a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 13281a41e8c1SDan Handley done ; \ 132936eaaf37SIan Spray else \ 13301a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 13311a41e8c1SDan Handley -not -iwholename "*build*" \ 13321a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 133361f72a34SRoberto Vargas -not -iwholename "*libc*" \ 13341a41e8c1SDan Handley -not -iwholename "*docs*" \ 13351ef35512SPaul Beesley -not -iwholename "*.rst" \ 13361a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 133736eaaf37SIan Spray fi 133836eaaf37SIan Spray 133936eaaf37SIan Spraycheckpatch: locate-checkpatch 134036eaaf37SIan Spray @echo " CHECKING STYLE" 134102a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 134202a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 134302a76d5fSYann Gautier fi 134451d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 134551d28937SAntonio Nino Diaz for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \ 134651d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 134751d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 134802a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 134902a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 135051d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 135102a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 135202a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 135351d28937SAntonio Nino Diaz done 135436eaaf37SIan Spray 135573c99d4eSJuan Castillocerttool: ${CRTTOOL} 135673c99d4eSJuan Castillo 1357a9812206SPali Rohár${CRTTOOL}: FORCE 1358fafd3ec9SManish 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} 1359f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13606f971622SJuan Castillo @echo "Built $@ successfully" 1361f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13626f971622SJuan Castillo 13636f971622SJuan Castilloifneq (${GENERATE_COT},0) 136473c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 13656f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1366f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13676f971622SJuan Castillo @echo "Built $@ successfully" 13686f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1369f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 137073c99d4eSJuan Castilloendif 137127713fb4SSoby Mathew 137273c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 13734727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1374819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1375819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1376f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13772f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1378f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1379f58ad36fSHarry Liebel 13800191262dSYatharth Kocharifneq (${GENERATE_COT},0) 13810191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 13820191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1383052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13840191262dSYatharth Kochar @echo "Built $@ successfully" 13850191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1386052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13870191262dSYatharth Kocharendif 13880191262dSYatharth Kochar 13890191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 13904727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1391819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1392819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1393052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13940191262dSYatharth Kochar @echo "Built $@ successfully" 1395052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13960191262dSYatharth Kochar 139773c99d4eSJuan Castillofiptool: ${FIPTOOL} 139873c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 13990191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 140073c99d4eSJuan Castillo 1401a9812206SPali Rohár${FIPTOOL}: FORCE 140288a1cf1eSSami Mujawarifdef UNIX_MK 1403fafd3ec9SManish V Badarkhe ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH} 140488a1cf1eSSami Mujawarelse 140588a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 140688a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 140788a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 140888a1cf1eSSami Mujawarendif 1409f58ad36fSHarry Liebel 141026010da1SAntonio Nino Diazsptool: ${SPTOOL} 1411a9812206SPali Rohár${SPTOOL}: FORCE 1412fafd3ec9SManish V Badarkhe ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH} 141326010da1SAntonio Nino Diaz 1414a9812206SPali Rohárromlib.bin: libraries FORCE 1415bbb24f61SJohn 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 14165accce5bSRoberto Vargas 1417cfe83910SLouis Mayencourt# Call print_memory_map tool 1418cfe83910SLouis Mayencourtmemmap: all 1419b890b36dSLouis Mayencourt ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1420cfe83910SLouis Mayencourt 14216de32378SMadhukar Pappireddydoc: 14226de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 14236de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 14246de32378SMadhukar Pappireddy 142590aa901fSSumit Gargenctool: ${ENCTOOL} 142690aa901fSSumit Garg 1427a9812206SPali Rohár${ENCTOOL}: FORCE 1428fafd3ec9SManish V Badarkhe ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH} 142990aa901fSSumit Garg @${ECHO_BLANK_LINE} 143090aa901fSSumit Garg @echo "Built $@ successfully" 143190aa901fSSumit Garg @${ECHO_BLANK_LINE} 143290aa901fSSumit Garg 143335fab8c9SJoakim Bechcscope: 143435fab8c9SJoakim Bech @echo " CSCOPE" 143535fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 143635fab8c9SJoakim Bech ${Q}cscope -b -q -k 143735fab8c9SJoakim Bech 143872ee3314SRyan Harkinhelp: 14397c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 144072ee3314SRyan Harkin @echo "" 144172ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 144208c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 144372ee3314SRyan Harkin @echo "" 14447c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 14457c23126cSJohn Tsichritzis @echo "" 14461b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 14471b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 14481b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 14491b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 14501b578596SSandrine Bailleux @echo "" 145172ee3314SRyan Harkin @echo "Supported Targets:" 14521b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 145336eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 14548aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 14559003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1456d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 14579d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 14589d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 145973c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 14601b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 14610191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 146236eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 146336eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 146436eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 146572ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 146635fab8c9SJoakim Bech @echo " cscope Generate cscope index" 146772ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 14686f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 146990aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1470f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1471ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 147226010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 147338c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1474cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 14756de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 147672ee3314SRyan Harkin @echo "" 14771b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 147872ee3314SRyan Harkin @echo "" 147972ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 148072ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1481a9812206SPali Rohár 1482a9812206SPali Rohár.PHONY: FORCE 1483a9812206SPali RohárFORCE:; 1484