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 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 780cf2c8a33SAntonio Nino Diaz################################################################################ 78173c99d4eSJuan Castillo# Process platform overrideable behaviour 78273c99d4eSJuan Castillo################################################################################ 7834f6ad66aSAchin Gupta 7845f24ce96SManish Pandeyifdef BL1_SOURCES 7855f24ce96SManish PandeyNEED_BL1 := yes 7865f24ce96SManish Pandeyendif 7875f24ce96SManish Pandey 7885f24ce96SManish Pandeyifdef BL2_SOURCES 7895f24ce96SManish Pandey NEED_BL2 := yes 7905f24ce96SManish Pandey 791bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 792bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 793cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 794cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 795cf2c8a33SAntonio Nino Diaz # in the FIP file. 7964c117f6cSSandrine Bailleux NEED_BL33 := no 797cf2c8a33SAntonio Nino Diaz else 79868450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 799cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 800cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 801cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 802cf2c8a33SAntonio Nino Diaz else 803cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 804cf2c8a33SAntonio Nino Diaz endif 8054c117f6cSSandrine Bailleux endif 80673c99d4eSJuan Castilloendif 8076f971622SJuan Castillo 8085f24ce96SManish Pandeyifdef BL2U_SOURCES 8095f24ce96SManish PandeyNEED_BL2U := yes 8105f24ce96SManish Pandeyendif 8115f24ce96SManish Pandey 8124d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 8134d045d0eSMasahiro Yamadaifdef SCP_BL2 8144d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 8154d045d0eSMasahiro Yamadaendif 8164d045d0eSMasahiro Yamada 8175744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 8185744e874SSoby Mathewifneq (${ARCH},aarch32) 8195744e874SSoby Mathew ifdef BL31_SOURCES 8205744e874SSoby Mathew # When booting an EL3 payload, there is no need to compile the BL31 image nor 8215744e874SSoby Mathew # put it in the FIP. 8225744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 8235744e874SSoby Mathew NEED_BL31 := yes 8245744e874SSoby Mathew endif 8255744e874SSoby Mathew endif 8265744e874SSoby Mathewendif 8275744e874SSoby Mathew 82873c99d4eSJuan Castillo# Process TBB related flags 8296f971622SJuan Castilloifneq (${GENERATE_COT},0) 83073c99d4eSJuan Castillo # Common cert_create options 8316f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 8326f971622SJuan Castillo $(eval CRT_ARGS += -n) 8330191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 834fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 835fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 8360191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 837fd34e7baSJuan Castillo endif 8386f971622SJuan Castillo endif 83973c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 84073c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 84173c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 84273c99d4eSJuan Castillo endif 8436f971622SJuan Castilloendif 8446f971622SJuan Castillo 8451c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 8461c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN} 8471c75d5dfSMasahiro Yamadaendif 8481c75d5dfSMasahiro Yamada 8495f24ce96SManish Pandeyifdef FDT_SOURCES 8505f24ce96SManish PandeyNEED_FDT := yes 8515f24ce96SManish Pandeyendif 8525f24ce96SManish Pandey 85373c99d4eSJuan Castillo################################################################################ 85446e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 85546e5e035SMichalis Pappas################################################################################ 85646e5e035SMichalis Pappas 85746e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 85846e5e035SMichalis Pappas 85946e5e035SMichalis Pappas################################################################################ 860819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc) 86173c99d4eSJuan Castillo################################################################################ 86273c99d4eSJuan Castillo 86373c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool 86473c99d4eSJuan CastilloCRTTOOLPATH ?= tools/cert_create 86542a45b51SEvan LloydCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 86673c99d4eSJuan Castillo 86790aa901fSSumit Garg# Variables for use with Firmware Encryption Tool 86890aa901fSSumit GargENCTOOLPATH ?= tools/encrypt_fw 86990aa901fSSumit GargENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 87090aa901fSSumit Garg 87173c99d4eSJuan Castillo# Variables for use with Firmware Image Package 872819281eeSdp-armFIPTOOLPATH ?= tools/fiptool 873819281eeSdp-armFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 87473c99d4eSJuan Castillo 87526010da1SAntonio Nino Diaz# Variables for use with sptool 87626010da1SAntonio Nino DiazSPTOOLPATH ?= tools/sptool 87726010da1SAntonio Nino DiazSPTOOL ?= ${SPTOOLPATH}/sptool${BIN_EXT} 878ce2b1ec6SManish PandeySP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 87926010da1SAntonio Nino Diaz 8805accce5bSRoberto Vargas# Variables for use with ROMLIB 8815accce5bSRoberto VargasROMLIBPATH ?= lib/romlib 8825accce5bSRoberto Vargas 883cfe83910SLouis Mayencourt# Variable for use with Python 884cfe83910SLouis MayencourtPYTHON ?= python3 885cfe83910SLouis Mayencourt 886cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP 887cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH ?= tools/memory 888cfe83910SLouis MayencourtPRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py 889cfe83910SLouis Mayencourt 8906de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool 8916de32378SMadhukar PappireddyDOCS_PATH ?= docs 8926de32378SMadhukar Pappireddy 8938a86052dSSoby Mathew################################################################################ 8948a86052dSSoby Mathew# Include BL specific makefiles 8958a86052dSSoby Mathew################################################################################ 8965f24ce96SManish Pandey 8975f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 8988a86052dSSoby Mathewinclude bl1/bl1.mk 8998a86052dSSoby Mathewendif 9008a86052dSSoby Mathew 9015f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 9028a86052dSSoby Mathewinclude bl2/bl2.mk 9038a86052dSSoby Mathewendif 9048a86052dSSoby Mathew 9055f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 9068a86052dSSoby Mathewinclude bl2u/bl2u.mk 9078a86052dSSoby Mathewendif 9088a86052dSSoby Mathew 9095744e874SSoby Mathewifeq (${NEED_BL31},yes) 9108a86052dSSoby Mathewinclude bl31/bl31.mk 9118a86052dSSoby Mathewendif 91203b397a8SNishanth Menon 91373c99d4eSJuan Castillo################################################################################ 91473c99d4eSJuan Castillo# Build options checks 91573c99d4eSJuan Castillo################################################################################ 91673c99d4eSJuan Castillo 917327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 918327131c4SLeonardo Sandoval $(sort \ 919327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 92046789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 921327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 922327131c4SLeonardo Sandoval CREATE_KEYS \ 923327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 924327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 925327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 926327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 927327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 928062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 929327131c4SLeonardo Sandoval DEBUG \ 9300063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 931327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 932327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 933327131c4SLeonardo Sandoval ENABLE_AMU \ 9341fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 935742ca230SChris Kay ENABLE_AMU_FCONF \ 936873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 937327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 938327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 939327131c4SLeonardo Sandoval ENABLE_PIE \ 940327131c4SLeonardo Sandoval ENABLE_PMF \ 941327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 9425b18de09SZelalem Aweke ENABLE_RME \ 943327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 944327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 945327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 9460c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 947327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 948327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 949327131c4SLeonardo Sandoval GENERATE_COT \ 950327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 951327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 952327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 953327131c4SLeonardo Sandoval INVERTED_MEMMAP \ 954327131c4SLeonardo Sandoval MEASURED_BOOT \ 955327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 956327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 957327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 958327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 959327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 960327131c4SLeonardo Sandoval RAS_EXTENSION \ 961327131c4SLeonardo Sandoval RESET_TO_BL31 \ 962327131c4SLeonardo Sandoval SAVE_KEYS \ 963327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 964327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 965327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 966327131c4SLeonardo Sandoval SPM_MM \ 967327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 968327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 969327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 970327131c4SLeonardo Sandoval USE_DEBUGFS \ 971327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 972327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 973327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 974327131c4SLeonardo Sandoval USE_ROMLIB \ 975327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 976327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 977327131c4SLeonardo Sandoval BL2_AT_EL3 \ 978327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 979327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 980327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 981327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 982327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 983327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 984327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 985327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 986327131c4SLeonardo Sandoval USE_SP804_TIMER \ 98712cd65e0STomas Pilar ENABLE_FEAT_RNG \ 9884e04478aSChris Kay ENABLE_FEAT_SB \ 989396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 990813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 991d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 9928fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 993cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 99468120783SChris Kay ENABLE_MPMM \ 99568120783SChris Kay ENABLE_MPMM_FCONF \ 996327131c4SLeonardo Sandoval))) 99773c99d4eSJuan Castillo 998327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 999327131c4SLeonardo Sandoval $(sort \ 1000327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1001327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1002327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 1003327131c4SLeonardo Sandoval FW_ENC_STATUS \ 10045357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 10055357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1006327131c4SLeonardo Sandoval))) 1007c877b414SJeenu Viswambharan 1008aacff749SJustin Chadwellifdef KEY_SIZE 1009aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1010aacff749SJustin Chadwellendif 1011aacff749SJustin Chadwell 10121f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 10131f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 10141f461979SJustin Chadwellendif 10151f461979SJustin Chadwell 101673c99d4eSJuan Castillo################################################################################ 101773c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 101873c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 101973c99d4eSJuan Castillo# platform to overwrite the default options 102073c99d4eSJuan Castillo################################################################################ 102173c99d4eSJuan Castillo 1022327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1023327131c4SLeonardo Sandoval $(sort \ 1024327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1025327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1026327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 102746789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1028327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1029327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1030327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1031327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 1032327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1033327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 1034327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1035062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1036327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 10370063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1038327131c4SLeonardo Sandoval ENABLE_AMU \ 10391fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1040742ca230SChris Kay ENABLE_AMU_FCONF \ 1041873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1042327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1043327131c4SLeonardo Sandoval ENABLE_BTI \ 1044327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 1045327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1046327131c4SLeonardo Sandoval ENABLE_PIE \ 1047327131c4SLeonardo Sandoval ENABLE_PMF \ 1048327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 10495b18de09SZelalem Aweke ENABLE_RME \ 1050327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1051327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 1052327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 10530c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1054327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1055327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1056327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1057327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1058327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 1059327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 1060327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1061327131c4SLeonardo Sandoval LOG_LEVEL \ 1062327131c4SLeonardo Sandoval MEASURED_BOOT \ 1063327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1064327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1065327131c4SLeonardo Sandoval PLAT_${PLAT} \ 1066327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1067327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 1068327131c4SLeonardo Sandoval RAS_EXTENSION \ 1069327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1070327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 1071327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1072327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1073327131c4SLeonardo Sandoval SPD_${SPD} \ 1074327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1075327131c4SLeonardo Sandoval SPM_MM \ 1076327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1077327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 10787dfb9911SJimmy Brisson TRNG_SUPPORT \ 1079327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1080327131c4SLeonardo Sandoval USE_DEBUGFS \ 1081327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1082327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1083327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1084327131c4SLeonardo Sandoval USE_ROMLIB \ 1085327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1086327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1087327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1088327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1089327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1090327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1091327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 1092327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1093327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1094327131c4SLeonardo Sandoval USE_SP804_TIMER \ 109512cd65e0STomas Pilar ENABLE_FEAT_RNG \ 10964e04478aSChris Kay ENABLE_FEAT_SB \ 10975357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 10985357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1099396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1100813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1101d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 11028fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1103cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 110468120783SChris Kay ENABLE_MPMM \ 110568120783SChris Kay ENABLE_MPMM_FCONF \ 1106327131c4SLeonardo Sandoval))) 11072fae4b1eSJeenu Viswambharan 11081f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 11091f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 11101f461979SJustin Chadwellendif 11111f461979SJustin Chadwell 11124c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 11134c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 11144c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1115cf2c8a33SAntonio Nino Diazelse 111668450a6dSAntonio Nino Diaz # Define the PRELOADED_BL33_BASE flag only if it is provided and 111768450a6dSAntonio Nino Diaz # EL3_PAYLOAD_BASE is not defined, as it has priority. 111868450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 111968450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 11204c117f6cSSandrine Bailleux endif 1121cf2c8a33SAntonio Nino Diazendif 112273c99d4eSJuan Castillo 1123209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1124209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1125209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH)) 1126209a60ccSSoby Mathewendif 1127209a60ccSSoby Mathew 1128c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1129c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK)) 1130c2ad38ceSVarun Wadekarendif 1131c2ad38ceSVarun Wadekar 1132ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1133ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1134c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1135ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1136ce2b1ec6SManish Pandey FIP_DEPS += sp 113707c44475SManish Pandey CRT_DEPS += sp 1138ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1139ce2b1ec6SManish Pandeyelse 1140c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1141c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1142c33ff198SOlivier Deprez endif 1143ce2b1ec6SManish Pandeyendif 1144ce2b1ec6SManish Pandeyendif 1145ce2b1ec6SManish Pandey 114673c99d4eSJuan Castillo################################################################################ 114773c99d4eSJuan Castillo# Build targets 114873c99d4eSJuan Castillo################################################################################ 114973c99d4eSJuan Castillo 115090aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 115173c99d4eSJuan Castillo.SUFFIXES: 115273c99d4eSJuan Castillo 115373c99d4eSJuan Castilloall: msg_start 115473c99d4eSJuan Castillo 115573c99d4eSJuan Castillomsg_start: 115673c99d4eSJuan Castillo @echo "Building ${PLAT}" 115773c99d4eSJuan Castillo 11587a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1159d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1160c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1161c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1162c2ad38ceSVarun Wadekarelse 1163bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 11647a24cba5SSoby Mathewendif 1165d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED 11667a24cba5SSoby Mathew 11675accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 116861f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 11695fee0287SRoberto Vargas 117073c99d4eSJuan Castillo# Expand build macros for the different images 117173c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1172b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1173b34635a0SChris Kay 1174434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 117573c99d4eSJuan Castilloendif 117673c99d4eSJuan Castillo 117773c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1178c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0) 1179c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1180c9b31ae8SRoberto Vargasendif 1181c9b31ae8SRoberto Vargas 1182eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1183eb1acfb6SChris Kay 118433950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1185434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 118673c99d4eSJuan Castilloendif 118773c99d4eSJuan Castillo 11884d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 118933950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 11904d045d0eSMasahiro Yamadaendif 11914d045d0eSMasahiro Yamada 119273c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 119373c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 119426d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 119526d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1196c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1197c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1198434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1199c6ba9b45SSumit Gargelse 120033950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1201434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 120273c99d4eSJuan Castilloendif 1203c6ba9b45SSumit Gargendif 120473c99d4eSJuan Castillo 120570d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1206c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 120770d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 120873c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 120926d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 121026d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 12119cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 12129cd15239SMasahiro Yamada 1213c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1214434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1215c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1216c6ba9b45SSumit Gargelse 1217434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 121833950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 121973c99d4eSJuan Castilloendif 1220c6ba9b45SSumit Gargendif 122173c99d4eSJuan Castillo 12225b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 12235b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 12245b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 12255b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 12265b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 12275b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 12285b18de09SZelalem Aweke 12295b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 12305b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 12315b18de09SZelalem Awekeendif 12325b18de09SZelalem Aweke 123373c99d4eSJuan Castillo# Add the BL33 image if required by the platform 123473c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 123533950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1236db6071c9SJuan Castilloendif 1237db6071c9SJuan Castillo 12389003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 123933950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1240434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 12419003fa0bSYatharth Kocharendif 12429003fa0bSYatharth Kochar 124303b397a8SNishanth Menon# Expand build macros for the different images 124403b397a8SNishanth Menonifeq (${NEED_FDT},yes) 124503b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 124603b397a8SNishanth Menonendif 124703b397a8SNishanth Menon 1248ce2b1ec6SManish Pandey# Add Secure Partition packages 1249ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1250ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 12511e7528ecSRuari Phipps ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1252ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk 1253ce2b1ec6SManish Pandey ${Q}$(SPTOOL) $(SPTOOL_ARGS) 1254ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1255ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1256ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1257ce2b1ec6SManish Pandeyendif 1258ce2b1ec6SManish Pandey 125936eaaf37SIan Spraylocate-checkpatch: 126036eaaf37SIan Sprayifndef CHECKPATCH 126166079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 126236eaaf37SIan Sprayelse 126336eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 126466079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 126536eaaf37SIan Sprayendif 126636eaaf37SIan Sprayendif 126736eaaf37SIan Spray 12684f6ad66aSAchin Guptaclean: 12694f6ad66aSAchin Gupta @echo " CLEAN" 1270f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 127188a1cf1eSSami Mujawarifdef UNIX_MK 12722f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 127388a1cf1eSSami Mujawarelse 127488a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 127588a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 127688a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 127788a1cf1eSSami Mujawarendif 12786f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 127990aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 12805accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 12814f6ad66aSAchin Gupta 1282eaaeece2SJames Morrisseyrealclean distclean: 1283eaaeece2SJames Morrissey @echo " REALCLEAN" 1284f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1285f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 128688a1cf1eSSami Mujawarifdef UNIX_MK 12872f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 128888a1cf1eSSami Mujawarelse 128988a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 129088a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 129188a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 129288a1cf1eSSami Mujawarendif 129326010da1SAntonio Nino Diaz ${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean 12946f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 129590aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 12965accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 12974f6ad66aSAchin Gupta 129836eaaf37SIan Spraycheckcodebase: locate-checkpatch 129936eaaf37SIan Spray @echo " CHECKING STYLE" 130036eaaf37SIan Spray @if test -d .git ; then \ 13011ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 13021a41e8c1SDan Handley while read GIT_FILE ; \ 13031a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 13041a41e8c1SDan Handley done ; \ 130536eaaf37SIan Spray else \ 13061a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 13071a41e8c1SDan Handley -not -iwholename "*build*" \ 13081a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 130961f72a34SRoberto Vargas -not -iwholename "*libc*" \ 13101a41e8c1SDan Handley -not -iwholename "*docs*" \ 13111ef35512SPaul Beesley -not -iwholename "*.rst" \ 13121a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 131336eaaf37SIan Spray fi 131436eaaf37SIan Spray 131536eaaf37SIan Spraycheckpatch: locate-checkpatch 131636eaaf37SIan Spray @echo " CHECKING STYLE" 131702a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 131802a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 131902a76d5fSYann Gautier fi 132051d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1321*77a0a7f1SYann Gautier for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 1322*77a0a7f1SYann Gautier do \ 132351d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 132451d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 132502a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 132602a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 132751d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 132802a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 132902a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 133051d28937SAntonio Nino Diaz done 133136eaaf37SIan Spray 133273c99d4eSJuan Castillocerttool: ${CRTTOOL} 133373c99d4eSJuan Castillo 1334a9812206SPali Rohár${CRTTOOL}: FORCE 1335fafd3ec9SManish 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} 1336f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13376f971622SJuan Castillo @echo "Built $@ successfully" 1338f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13396f971622SJuan Castillo 13406f971622SJuan Castilloifneq (${GENERATE_COT},0) 134173c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 13426f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1343f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13446f971622SJuan Castillo @echo "Built $@ successfully" 13456f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1346f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 134773c99d4eSJuan Castilloendif 134827713fb4SSoby Mathew 134973c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 13504727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1351819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1352819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1353f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 13542f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1355f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1356f58ad36fSHarry Liebel 13570191262dSYatharth Kocharifneq (${GENERATE_COT},0) 13580191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 13590191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1360052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13610191262dSYatharth Kochar @echo "Built $@ successfully" 13620191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1363052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13640191262dSYatharth Kocharendif 13650191262dSYatharth Kochar 13660191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 13674727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1368819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1369819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1370052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13710191262dSYatharth Kochar @echo "Built $@ successfully" 1372052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 13730191262dSYatharth Kochar 137473c99d4eSJuan Castillofiptool: ${FIPTOOL} 137573c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 13760191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 137773c99d4eSJuan Castillo 1378a9812206SPali Rohár${FIPTOOL}: FORCE 137988a1cf1eSSami Mujawarifdef UNIX_MK 1380fafd3ec9SManish V Badarkhe ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH} 138188a1cf1eSSami Mujawarelse 138288a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 138388a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 138488a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 138588a1cf1eSSami Mujawarendif 1386f58ad36fSHarry Liebel 138726010da1SAntonio Nino Diazsptool: ${SPTOOL} 1388a9812206SPali Rohár${SPTOOL}: FORCE 1389fafd3ec9SManish V Badarkhe ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH} 139026010da1SAntonio Nino Diaz 1391a9812206SPali Rohárromlib.bin: libraries FORCE 1392bbb24f61SJohn 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 13935accce5bSRoberto Vargas 1394cfe83910SLouis Mayencourt# Call print_memory_map tool 1395cfe83910SLouis Mayencourtmemmap: all 1396b890b36dSLouis Mayencourt ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1397cfe83910SLouis Mayencourt 13986de32378SMadhukar Pappireddydoc: 13996de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 14006de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 14016de32378SMadhukar Pappireddy 140290aa901fSSumit Gargenctool: ${ENCTOOL} 140390aa901fSSumit Garg 1404a9812206SPali Rohár${ENCTOOL}: FORCE 1405fafd3ec9SManish V Badarkhe ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH} 140690aa901fSSumit Garg @${ECHO_BLANK_LINE} 140790aa901fSSumit Garg @echo "Built $@ successfully" 140890aa901fSSumit Garg @${ECHO_BLANK_LINE} 140990aa901fSSumit Garg 141035fab8c9SJoakim Bechcscope: 141135fab8c9SJoakim Bech @echo " CSCOPE" 141235fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 141335fab8c9SJoakim Bech ${Q}cscope -b -q -k 141435fab8c9SJoakim Bech 141572ee3314SRyan Harkinhelp: 14167c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 141772ee3314SRyan Harkin @echo "" 141872ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 141908c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 142072ee3314SRyan Harkin @echo "" 14217c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 14227c23126cSJohn Tsichritzis @echo "" 14231b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 14241b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 14251b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 14261b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 14271b578596SSandrine Bailleux @echo "" 142872ee3314SRyan Harkin @echo "Supported Targets:" 14291b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 143036eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 14318aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 14329003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1433d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 14349d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 14359d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 143673c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 14371b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 14380191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 143936eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 144036eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 144136eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 144272ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 144335fab8c9SJoakim Bech @echo " cscope Generate cscope index" 144472ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 14456f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 144690aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1447f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1448ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 144926010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 145038c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1451cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 14526de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 145372ee3314SRyan Harkin @echo "" 14541b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 145572ee3314SRyan Harkin @echo "" 145672ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 145772ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1458a9812206SPali Rohár 1459a9812206SPali Rohár.PHONY: FORCE 1460a9812206SPali RohárFORCE:; 1461