14f6ad66aSAchin Gupta# 22d51b55eSBalint Dobszay# Copyright (c) 2013-2020, 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 115edddf3aSManish V BadarkheVERSION_MINOR := 4 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 132c97cba4eSSoby Mathew# USE_SPINLOCK_CAS requires AArch64 build 133c97cba4eSSoby Mathewifeq (${USE_SPINLOCK_CAS},1) 134c97cba4eSSoby Mathewifneq (${ARCH},aarch64) 135c97cba4eSSoby Mathew $(error USE_SPINLOCK_CAS requires AArch64) 136c97cba4eSSoby Mathewelse 137c97cba4eSSoby Mathew $(info USE_SPINLOCK_CAS is an experimental feature) 138c97cba4eSSoby Mathewendif 139c97cba4eSSoby Mathewendif 140c97cba4eSSoby Mathew 1410ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds 1420ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1) 1430ca3913dSOlivier Deprezifeq (${DEBUG},1) 1440ca3913dSOlivier Deprez $(warning DEBUGFS experimental feature is enabled.) 1450ca3913dSOlivier Deprezelse 1460ca3913dSOlivier Deprez $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 1470ca3913dSOlivier Deprezendif 1480ca3913dSOlivier Deprezendif 1490ca3913dSOlivier Deprez 150c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 151c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS} 152c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY} 153c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE} 154c6ba9b45SSumit GargFIP_DEPS += enctool 155c6ba9b45SSumit GargFWU_FIP_DEPS += enctool 156c6ba9b45SSumit Gargendif 157c6ba9b45SSumit Garg 15873c99d4eSJuan Castillo################################################################################ 15973c99d4eSJuan Castillo# Toolchain 16073c99d4eSJuan Castillo################################################################################ 16173c99d4eSJuan Castillo 16272610c41Sdp-armHOSTCC := gcc 16372610c41Sdp-armexport HOSTCC 16472610c41Sdp-arm 16573c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 16673c99d4eSJuan CastilloCPP := ${CROSS_COMPILE}cpp 16773c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 16873c99d4eSJuan CastilloAR := ${CROSS_COMPILE}ar 1692adee763SRoberto VargasLINKER := ${CROSS_COMPILE}ld 17073c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 17173c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 17273c99d4eSJuan CastilloNM := ${CROSS_COMPILE}nm 17373c99d4eSJuan CastilloPP := ${CROSS_COMPILE}gcc -E 17438c14d88SSoby MathewDTC := dtc 17573c99d4eSJuan Castillo 176b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 177b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \ 1782adee763SRoberto Vargas $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 1792adee763SRoberto VargasLINKER := ${LINKER}.bfd 180b25a577fSJulius Wernerendif 181b25a577fSJulius Werner 18226e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 18326e63c44SEtienne Carrieretarget32-directive = -target arm-none-eabi 18426e63c44SEtienne Carriere# Will set march32-directive from platform configuration 18526e63c44SEtienne Carriereelse 18626e63c44SEtienne Carrieretarget32-directive = -target armv8a-none-eabi 187fa6f774bSAlexei Fedorov 188f1821790SAlexei Fedorov# Set the compiler's target architecture profile based on 189f1821790SAlexei Fedorov# ARM_ARCH_MAJOR ARM_ARCH_MINOR options 190fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0) 191f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}-a 192f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}-a 193fa6f774bSAlexei Fedorovelse 194f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 195f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 196fa6f774bSAlexei Fedorovendif 19726e63c44SEtienne Carriereendif 19826e63c44SEtienne Carriere 1997ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards 2007ff088d1SManish V Badarkheifeq ($(ARCH), aarch64) 2014a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5 2024a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 2037ff088d1SManish V Badarkhemem_tag_arch_support = yes 2047ff088d1SManish V Badarkheendif 2057ff088d1SManish V Badarkheendif 2067ff088d1SManish V Badarkhe 207f1821790SAlexei Fedorov# Get architecture feature modifiers 208f1821790SAlexei Fedorovarch-features = ${ARM_ARCH_FEATURE} 209f1821790SAlexei Fedorov 210f1821790SAlexei Fedorov# Enable required options for memory stack tagging. 211f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler. 2127ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes) 2137ff088d1SManish V Badarkheifdef mem_tag_arch_support 214f1821790SAlexei Fedorov# Check for armclang and clang compilers 2157ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 216f1821790SAlexei Fedorov# Add "memtag" architecture feature modifier if not specified 217f1821790SAlexei Fedorovifeq ( ,$(findstring memtag,$(arch-features))) 218f1821790SAlexei Fedorovarch-features := $(arch-features)+memtag 219f1821790SAlexei Fedorovendif # memtag 2207ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang) 2217ff088d1SManish V BadarkheTF_CFLAGS += -mmemtag-stack 2227ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang) 2237ff088d1SManish V BadarkheTF_CFLAGS += -fsanitize=memtag 224f1821790SAlexei Fedorovendif # armclang 225f1821790SAlexei Fedorovendif # armclang clang 2267ff088d1SManish V Badarkheelse 2277ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \ 2287ff088d1SManish V Badarkhe ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 229f1821790SAlexei Fedorovendif # mem_tag_arch_support 230f1821790SAlexei Fedorovendif # SUPPORT_STACK_MEMTAG 231f1821790SAlexei Fedorov 232f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers 233f1821790SAlexei Fedorovifneq ($(arch-features), none) 234f1821790SAlexei Fedorov# Strip "none+" from arch-features 235f1821790SAlexei Fedorovarch-features := $(subst none+,,$(arch-features)) 236f1821790SAlexei Fedorovifeq ($(ARCH), aarch32) 237f1821790SAlexei Fedorovmarch32-directive := $(march32-directive)+$(arch-features) 238f1821790SAlexei Fedorovelse 239f1821790SAlexei Fedorovmarch64-directive := $(march64-directive)+$(arch-features) 2407ff088d1SManish V Badarkheendif 241f1821790SAlexei Fedorov# Print features 242f1821790SAlexei Fedorov$(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 243f1821790SAlexei Fedorovendif # arch-features 2447ff088d1SManish V Badarkhe 245fd18a8fcSVarun Wadekarifneq ($(findstring armclang,$(notdir $(CC))),) 24626e63c44SEtienne CarriereTF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive) 247fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi $(march64-directive) 2482adee763SRoberto VargasLD = $(LINKER) 2491684b873SRoberto VargasAS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 2507040155eSRoberto VargasCPP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 2517040155eSRoberto VargasPP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 2527559633bSdp-armelse ifneq ($(findstring clang,$(notdir $(CC))),) 253eff737c1SArve HjønnevågCLANG_CCDIR = $(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),) 254e2bfec0bSYann GautierTF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) 255fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = -target aarch64-elf $(march64-directive) 256eff737c1SArve HjønnevågLD = $(CLANG_CCDIR)ld.lld 257641f16e7SAmbroise Vincentifeq (, $(shell which $(LD))) 258641f16e7SAmbroise Vincent$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker") 259641f16e7SAmbroise Vincentendif 2601684b873SRoberto VargasAS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 2617040155eSRoberto VargasCPP = $(CC) -E 2627040155eSRoberto VargasPP = $(CC) -E 263edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),) 264edbce9aaSzelalem-awekeTF_CFLAGS_aarch32 = $(march32-directive) 265edbce9aaSzelalem-awekeTF_CFLAGS_aarch64 = $(march64-directive) 266edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 267edbce9aaSzelalem-aweke # Enable LTO only for aarch64 268edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 269edbce9aaSzelalem-aweke LTO_CFLAGS = -flto 270edbce9aaSzelalem-aweke # Use gcc as a wrapper for the ld, recommended for LTO 271edbce9aaSzelalem-aweke LINKER := ${CROSS_COMPILE}gcc 272edbce9aaSzelalem-aweke endif 273edbce9aaSzelalem-awekeendif 274edbce9aaSzelalem-awekeLD = $(LINKER) 275d5461857Sdp-armelse 27626e63c44SEtienne CarriereTF_CFLAGS_aarch32 = $(march32-directive) 277fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = $(march64-directive) 2782adee763SRoberto VargasLD = $(LINKER) 279d5461857Sdp-armendif 280d5461857Sdp-arm 28132b209bfSAhmad Fatoum# Process Debug flag 28232b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 28332b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 28432b209bfSAhmad Fatoum BUILD_TYPE := debug 28532b209bfSAhmad Fatoum TF_CFLAGS += -g 28632b209bfSAhmad Fatoum 28732b209bfSAhmad Fatoum ifneq ($(findstring clang,$(notdir $(CC))),) 28832b209bfSAhmad Fatoum ASFLAGS += -g 28932b209bfSAhmad Fatoum else 29032b209bfSAhmad Fatoum ASFLAGS += -g -Wa,--gdwarf-2 29132b209bfSAhmad Fatoum endif 29232b209bfSAhmad Fatoum 29332b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 29432b209bfSAhmad Fatoum LOG_LEVEL := 40 29532b209bfSAhmad Fatoumelse 29632b209bfSAhmad Fatoum BUILD_TYPE := release 29732b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 29832b209bfSAhmad Fatoum LOG_LEVEL := 20 29932b209bfSAhmad Fatoumendif 30032b209bfSAhmad Fatoum 301f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 302f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 303f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 304f1de4c8fSPeiyuan Songendif 305f1de4c8fSPeiyuan SongVERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING} 306f1de4c8fSPeiyuan Song 3078fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 3088fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -marm 3098fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 3108fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -mthumb 3118fd9d4d5SAntonio Nino Diazelse 3128fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 3138fd9d4d5SAntonio Nino Diazendif 3148fd9d4d5SAntonio Nino Diaz 315a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 316d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 3179d29c227SSoby Mathew 3189fc59639SAlexei Fedorovifneq (${BP_OPTION},none) 3199fc59639SAlexei FedorovTF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 3209fc59639SAlexei Fedorovendif 3219fc59639SAlexei Fedorov 32226e63c44SEtienne CarriereASFLAGS_aarch32 = $(march32-directive) 323fa6f774bSAlexei FedorovASFLAGS_aarch64 = $(march64-directive) 324b86048c4SAntonio Nino Diaz 3259ab81b5eSJustin Chadwell# General warnings 3269ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 327b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 328ca661a00SMadhukar Pappireddy -Wno-unused-parameter -Wredundant-decls 3299ab81b5eSJustin Chadwell 3309ab81b5eSJustin Chadwell# Additional warnings 3319ab81b5eSJustin Chadwell# Level 1 332e7c645b5SYann GautierWARNING1 := -Wextra 333e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute 334e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes 335e7c645b5SYann GautierWARNING1 += -Wold-style-definition 336e7c645b5SYann Gautier 337b7f6525dSJustin Chadwell# Level 2 338e7c645b5SYann GautierWARNING2 := -Waggregate-return 339e7c645b5SYann GautierWARNING2 += -Wcast-align 340e7c645b5SYann GautierWARNING2 += -Wnested-externs 341e7c645b5SYann Gautier 342e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 343e7c645b5SYann GautierWARNING3 += -Wcast-qual 344e7c645b5SYann GautierWARNING3 += -Wconversion 345e7c645b5SYann GautierWARNING3 += -Wpacked 346e7c645b5SYann GautierWARNING3 += -Wpointer-arith 347e7c645b5SYann GautierWARNING3 += -Wswitch-default 348e7c645b5SYann Gautier 349e7c645b5SYann Gautierifeq (${W},1) 3509ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) 351e7c645b5SYann Gautierelse ifeq (${W},2) 3529ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) 353e7c645b5SYann Gautierelse ifeq (${W},3) 3549ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 355e7c645b5SYann Gautierendif 356e7c645b5SYann Gautier 3579ab81b5eSJustin Chadwell# Compiler specific warnings 35800296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),) 35993c690ebSJustin Chadwell# not using clang 360d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 361d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 362d7b4cd41SJustin Chadwell -Wlogical-op 36393c690ebSJustin Chadwellelse 36493c690ebSJustin Chadwell# using clang 365d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 366d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 36700296576SAmbroise Vincentendif 36800296576SAmbroise Vincent 3696336b07aSYann Gautierifneq (${E},0) 3706336b07aSYann GautierERRORS := -Werror 3716336b07aSYann Gautierendif 3726336b07aSYann Gautier 373ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 3749ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 37559de5096SMasahiro YamadaASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 376d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 37759de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 378ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 379ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 380ebd6efaeSSamuel Holland -Os -std=gnu99 38173c99d4eSJuan Castillo 3821f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 3831f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 3841f461979SJustin Chadwellendif 3851f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 3861f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 3871f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 3881f461979SJustin Chadwellendif 3891f461979SJustin Chadwell 390f7ec31dbSdavid cunadoGCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 391f7ec31dbSdavid cunado 392641f16e7SAmbroise Vincent# LD = armlink 393c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 394c2ad38ceSVarun WadekarTF_LDFLAGS += --diag_error=warning --lto_level=O1 395c2ad38ceSVarun WadekarTF_LDFLAGS += --remove --info=unused,unusedsymbols 396edbce9aaSzelalem-awekeTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 397641f16e7SAmbroise Vincent 398641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 399edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 400edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches 401edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--fatal-warnings -O1 402edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--gc-sections 403edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 404edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 405edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 406edbce9aaSzelalem-aweke endif 407edbce9aaSzelalem-awekeendif 408edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 409edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 410edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1) 411edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 412edbce9aaSzelalem-awekeendif 413edbce9aaSzelalem-awekeTF_LDFLAGS += -nostdlib 414edbce9aaSzelalem-awekeTF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 415641f16e7SAmbroise Vincent 416641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 417c2ad38ceSVarun Wadekarelse 418c2b8806fSDouglas RaillardTF_LDFLAGS += --fatal-warnings -O1 419c2b8806fSDouglas RaillardTF_LDFLAGS += --gc-sections 420641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 421641f16e7SAmbroise Vincent# therefore don't add those in that case 422641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),) 423c2b8806fSDouglas RaillardTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 424edbce9aaSzelalem-awekeendif 425641f16e7SAmbroise Vincentendif 42673c99d4eSJuan Castillo 42703b397a8SNishanth MenonDTC_FLAGS += -I dts -O dtb 428a6de824fSLouis MayencourtDTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 429a6de824fSLouis Mayencourt -x assembler-with-cpp $(DEFINES) 43003b397a8SNishanth Menon 4310ab49645SAlexei Fedorovifeq ($(MEASURED_BOOT),1) 4320ab49645SAlexei FedorovDTC_CPPFLAGS += -DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE} 4330ab49645SAlexei Fedorovendif 4340ab49645SAlexei Fedorov 43573c99d4eSJuan Castillo################################################################################ 43673c99d4eSJuan Castillo# Common sources and include directories 43773c99d4eSJuan Castillo################################################################################ 438d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 43973c99d4eSJuan Castillo 44073c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 4417f56e9a3SSoby Mathew common/tf_log.c \ 4429d29c227SSoby Mathew common/${ARCH}/debug.S \ 44391b48c9fSJulius Werner drivers/console/multi_console.c \ 4449d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 4459d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 446566034fcSSoby Mathew plat/common/plat_bl_common.c \ 4477f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 44875311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 4499d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 45061f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 451d7a6b0f8SRyan Harkin 4528422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang) 4538422a840SAntonio Nino DiazBL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 4548422a840SAntonio Nino Diazendif 4558422a840SAntonio Nino Diaz 4561f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4571f461979SJustin ChadwellBL_COMMON_SOURCES += plat/common/ubsan.c 4581f461979SJustin Chadwellendif 4591f461979SJustin Chadwell 46001d237cbSYann GautierINCLUDES += -Iinclude \ 461f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 46209d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 46309d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 46409d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 46509d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 46609d40e0eSAntonio Nino Diaz 4679c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 4689c6d1c50SAntonio Nino Diaz 46973c99d4eSJuan Castillo################################################################################ 47073c99d4eSJuan Castillo# Generic definitions 47173c99d4eSJuan Castillo################################################################################ 47273c99d4eSJuan Castillo 473231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 474231c1470SEvan Lloyd 47529214e95SGrant Likelyifeq (${BUILD_BASE},) 47673c99d4eSJuan Castillo BUILD_BASE := ./build 47729214e95SGrant Likelyendif 47829214e95SGrant LikelyBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 47973c99d4eSJuan Castillo 480231c1470SEvan LloydSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 48173c99d4eSJuan Castillo 48273c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value 48373c99d4eSJuan CastilloINCLUDE_TBBR_MK := 1 48473c99d4eSJuan Castillo 48573c99d4eSJuan Castillo 48673c99d4eSJuan Castillo################################################################################ 48773c99d4eSJuan Castillo# Include SPD Makefile if one has been specified 48873c99d4eSJuan Castillo################################################################################ 48973c99d4eSJuan Castillo 49073c99d4eSJuan Castilloifneq (${SPD},none) 4919d29c227SSoby Mathew ifeq (${ARCH},aarch32) 4929d29c227SSoby Mathew $(error "Error: SPD is incompatible with AArch32.") 4939d29c227SSoby Mathew endif 49428f39f02SMax Shvetsov 4954c117f6cSSandrine Bailleux ifdef EL3_PAYLOAD_BASE 4964c117f6cSSandrine Bailleux $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 4974c117f6cSSandrine Bailleux $(warning "The SPD and its BL32 companion will be present but ignored.") 4984c117f6cSSandrine Bailleux endif 49928f39f02SMax Shvetsov 500c3fb00d9SAchin Gupta ifeq (${SPD},spmd) 501033039f8SMax Shvetsov $(warning "SPMD is an experimental feature") 502c3fb00d9SAchin Gupta # SPMD is located in std_svc directory 503c3fb00d9SAchin Gupta SPD_DIR := std_svc 50428f39f02SMax Shvetsov 505033039f8SMax Shvetsov ifeq ($(SPMD_SPM_AT_SEL2),1) 50628f39f02SMax Shvetsov ifeq ($(CTX_INCLUDE_EL2_REGS),0) 507033039f8SMax Shvetsov $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option) 508033039f8SMax Shvetsov endif 50928f39f02SMax Shvetsov endif 510db1ef41aSOlivier Deprez 511db1ef41aSOlivier Deprez ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 512db1ef41aSOlivier Deprez DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 513db1ef41aSOlivier Deprez endif 514c3fb00d9SAchin Gupta else 515c3fb00d9SAchin Gupta # All other SPDs in spd directory 516c3fb00d9SAchin Gupta SPD_DIR := spd 517c3fb00d9SAchin Gupta endif 518c3fb00d9SAchin Gupta 51973c99d4eSJuan Castillo # We expect to locate an spd.mk under the specified SPD directory 520c3fb00d9SAchin Gupta SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 521c3fb00d9SAchin Gupta 52273c99d4eSJuan Castillo ifeq (${SPD_MAKE},) 523c3fb00d9SAchin Gupta $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 52473c99d4eSJuan Castillo endif 52573c99d4eSJuan Castillo $(info Including ${SPD_MAKE}) 52673c99d4eSJuan Castillo include ${SPD_MAKE} 52773c99d4eSJuan Castillo 52870d1fc53SJuan Castillo # If there's BL32 companion for the chosen SPD, we expect that the SPD's 52970d1fc53SJuan Castillo # Makefile would set NEED_BL32 to "yes". In this case, the build system 53070d1fc53SJuan Castillo # supports two mutually exclusive options: 53170d1fc53SJuan Castillo # * BL32 is built from source: then BL32_SOURCES must contain the list 53270d1fc53SJuan Castillo # of source files to build BL32 53370d1fc53SJuan Castillo # * BL32 is a prebuilt binary: then BL32 must point to the image file 53470d1fc53SJuan Castillo # that will be included in the FIP 53570d1fc53SJuan Castillo # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 53670d1fc53SJuan Castillo # over the sources. 537e35c4045SJeenu Viswambharanendif 538e35c4045SJeenu Viswambharan 53951faada7SDouglas Raillard################################################################################ 54073c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform 54173c99d4eSJuan Castillo# makefile may use all previous definitions in this file) 54273c99d4eSJuan Castillo################################################################################ 5432da8d8bfSJeenu Viswambharan 54473c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL} 5450f21c547SJuan Castillo 5468012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 5478012cc5cSMasahiro Yamada 54826e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 54926e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 55026e63c44SEtienne Carriereendif 55126e63c44SEtienne Carriere 5523bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 5533bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 5543bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 5553bd17c0fSSoby Mathewendif 556320920c1SMasahiro Yamada 557320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),) 558320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 559320920c1SMasahiro Yamadaelse 560320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 561320920c1SMasahiro Yamadaendif 562320920c1SMasahiro Yamada 563320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 56469af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 56569af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1) 56669af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 56769af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 56869af7fcfSMasahiro Yamadaendif 56969af7fcfSMasahiro Yamadaendif 570320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 571320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 572d974301dSMasahiro Yamadaifeq ($(ARCH),aarch64) 573d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 574d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 575d974301dSMasahiro Yamadaendif 5763bd17c0fSSoby Mathewendif 5773bd17c0fSSoby Mathew 578d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64) 5799cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 580d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 5819cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3 582d5e97a1dSMasahiro Yamadaelse 5839cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1 584d5e97a1dSMasahiro Yamadaendif 5859cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1 5869cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3 5879cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1 588d5e97a1dSMasahiro Yamadaendif 589d5e97a1dSMasahiro Yamada 59054035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 59154035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 59254035fc4SSandrine Bailleux# This can be overridden by the platform. 59373c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 5944f6ad66aSAchin Gupta 595a4409008Sdp-armifeq (${ARCH},aarch32) 596a4409008Sdp-armNEED_BL32 := yes 597a4409008Sdp-arm 598a4409008Sdp-arm################################################################################ 599a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 600a4409008Sdp-arm################################################################################ 601a4409008Sdp-armifneq (${AARCH32_SP},none) 602a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory 603a4409008Sdp-armAARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 604a4409008Sdp-arm 605a4409008Sdp-armifeq (${AARCH32_SP_MAKE},) 606a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 607a4409008Sdp-armendif 608a4409008Sdp-arm 609a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE}) 610a4409008Sdp-arminclude ${AARCH32_SP_MAKE} 611a4409008Sdp-armendif 612a4409008Sdp-arm 613a4409008Sdp-armendif 6144f6ad66aSAchin Gupta 61573c99d4eSJuan Castillo################################################################################ 61677f1f7a1SVarun Wadekar# Include libc if not overridden 61777f1f7a1SVarun Wadekar################################################################################ 61877f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 61977f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 62077f1f7a1SVarun Wadekarendif 62177f1f7a1SVarun Wadekar 62277f1f7a1SVarun Wadekar################################################################################ 623cf2c8a33SAntonio Nino Diaz# Check incompatible options 624cf2c8a33SAntonio Nino Diaz################################################################################ 625cf2c8a33SAntonio Nino Diaz 626cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 62768450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 62868450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 62968450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 630cf2c8a33SAntonio Nino Diaz endif 63176580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 63276580f3dSQixiang Xu $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 63376580f3dSQixiang Xu endif 63476580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 63576580f3dSQixiang Xu $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 63676580f3dSQixiang Xu endif 637cf2c8a33SAntonio Nino Diazendif 638cf2c8a33SAntonio Nino Diaz 639cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 640cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 641cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 642cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 643cf2c8a33SAntonio Nino Diaz endif 64468450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 64568450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 64668450a6dSAntonio Nino Diaz PRELOADED_BL33_BASE is used and won't be added to the FIP \ 64768450a6dSAntonio Nino Diaz file.") 648cf2c8a33SAntonio Nino Diaz endif 649cf2c8a33SAntonio Nino Diazendif 650cf2c8a33SAntonio Nino Diaz 651d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 652d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 653d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 654d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 655d4593e47SJeenu Viswambharanendif 6561a0a3f06SYatharth Kochar 6577d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1. 6587d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1) 6597d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled") 6607d173fc5SJiafei Panendif 6617d173fc5SJiafei Pan 66214c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first 66314c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 66414c6016aSJeenu Viswambharan ifneq ($(HANDLE_EA_EL3_FIRST),1) 66514c6016aSJeenu Viswambharan $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1) 66614c6016aSJeenu Viswambharan endif 66714c6016aSJeenu Viswambharanendif 66814c6016aSJeenu Viswambharan 6691a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled 6701a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 6711a7c1cfeSJeenu Viswambharan ifneq ($(RAS_EXTENSION),1) 6721a7c1cfeSJeenu Viswambharan $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) 6731a7c1cfeSJeenu Viswambharan endif 6741a7c1cfeSJeenu Viswambharanendif 6751a7c1cfeSJeenu Viswambharan 676ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 677209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 678209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 679209a60ccSSoby Mathew $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.") 680209a60ccSSoby Mathew endif 681209a60ccSSoby Mathewendif 682209a60ccSSoby Mathew 683cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 684cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 685cbf9e84aSBalint Dobszay$(error "SDEI_IN_FCONF is an experimental feature and is only supported when \ 686cbf9e84aSBalint Dobszay SDEI_SUPPORT is enabled") 687cbf9e84aSBalint Dobszayendif 688cbf9e84aSBalint Dobszay 68984ef9cd8SManish V Badarkheifeq ($(COT_DESC_IN_DTB),1) 69084ef9cd8SManish V Badarkhe $(info CoT in device tree is an experimental feature) 69184ef9cd8SManish V Badarkheendif 69284ef9cd8SManish V Badarkhe 693b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 6949fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 6959fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 696b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 6979fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 6989fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 69906715f85SAlexei Fedorov endif 7009fc59639SAlexei Fedorovendif 7019fc59639SAlexei Fedorov 70206715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 7039fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 7049fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 705dfc66a17SJohn Tsichritzis else 70606715f85SAlexei Fedorov $(info CTX_INCLUDE_PAUTH_REGS is an experimental feature) 707b86048c4SAntonio Nino Diaz endif 708b86048c4SAntonio Nino Diazendif 7099fc59639SAlexei Fedorov 7109fc59639SAlexei Fedorovifeq ($(ENABLE_PAUTH),1) 7119fc59639SAlexei Fedorov $(info Pointer Authentication is an experimental feature) 7129fc59639SAlexei Fedorovendif 7139fc59639SAlexei Fedorov 7149fc59639SAlexei Fedorovifeq ($(ENABLE_BTI),1) 7159fc59639SAlexei Fedorov $(info Branch Protection is an experimental feature) 716dfc66a17SJohn Tsichritzisendif 717b86048c4SAntonio Nino Diaz 7189dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1) 7199dd94382SJustin Chadwell ifneq (${ARCH},aarch64) 7209dd94382SJustin Chadwell $(error CTX_INCLUDE_MTE_REGS requires AArch64) 7219dd94382SJustin Chadwell else 7229dd94382SJustin Chadwell $(info CTX_INCLUDE_MTE_REGS is an experimental feature) 7239dd94382SJustin Chadwell endif 7249dd94382SJustin Chadwellendif 7259dd94382SJustin Chadwell 7268c105290SAlexei Fedorovifeq ($(MEASURED_BOOT),1) 7278c105290SAlexei Fedorov ifneq (${TRUSTED_BOARD_BOOT},1) 7287cda17bbSSumit Garg $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1) 7298c105290SAlexei Fedorov else 7308c105290SAlexei Fedorov $(info MEASURED_BOOT is an experimental feature) 7318c105290SAlexei Fedorov endif 7328c105290SAlexei Fedorovendif 7338c105290SAlexei Fedorov 73460e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 73560e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 73660e8f3cfSPetre-Ionut Tudor $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2") 73760e8f3cfSPetre-Ionut Tudor endif 73860e8f3cfSPetre-Ionut Tudorendif 73960e8f3cfSPetre-Ionut Tudor 7407cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 7417cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 7427cda17bbSSumit Garg $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set) 7437cda17bbSSumit Garg else 7447cda17bbSSumit Garg $(info DECRYPTION_SUPPORT is an experimental feature) 7457cda17bbSSumit Garg endif 7467cda17bbSSumit Gargendif 7477cda17bbSSumit Garg 748cf2c8a33SAntonio Nino Diaz################################################################################ 74973c99d4eSJuan Castillo# Process platform overrideable behaviour 75073c99d4eSJuan Castillo################################################################################ 7514f6ad66aSAchin Gupta 752bd97f83aSJohn Tsichritzis# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 753bd97f83aSJohn Tsichritzis# Certificate generation tools. This flag can be overridden by the platform. 75473c99d4eSJuan Castilloifdef BL2_SOURCES 755cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 756cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 757cf2c8a33SAntonio Nino Diaz # in the FIP file. 7584c117f6cSSandrine Bailleux NEED_BL33 := no 759cf2c8a33SAntonio Nino Diaz else 76068450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 761cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 762cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 763cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 764cf2c8a33SAntonio Nino Diaz else 765cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 766cf2c8a33SAntonio Nino Diaz endif 7674c117f6cSSandrine Bailleux endif 76873c99d4eSJuan Castilloendif 7696f971622SJuan Castillo 7704d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 7714d045d0eSMasahiro Yamadaifdef SCP_BL2 7724d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 7734d045d0eSMasahiro Yamadaendif 7744d045d0eSMasahiro Yamada 7755744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 7765744e874SSoby Mathewifneq (${ARCH},aarch32) 7775744e874SSoby Mathew ifdef BL31_SOURCES 7785744e874SSoby Mathew # When booting an EL3 payload, there is no need to compile the BL31 image nor 7795744e874SSoby Mathew # put it in the FIP. 7805744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 7815744e874SSoby Mathew NEED_BL31 := yes 7825744e874SSoby Mathew endif 7835744e874SSoby Mathew endif 7845744e874SSoby Mathewendif 7855744e874SSoby Mathew 78673c99d4eSJuan Castillo# Process TBB related flags 7876f971622SJuan Castilloifneq (${GENERATE_COT},0) 78873c99d4eSJuan Castillo # Common cert_create options 7896f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 7906f971622SJuan Castillo $(eval CRT_ARGS += -n) 7910191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 792fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 793fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 7940191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 795fd34e7baSJuan Castillo endif 7966f971622SJuan Castillo endif 79773c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 79873c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 79973c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 80073c99d4eSJuan Castillo endif 8016f971622SJuan Castilloendif 8026f971622SJuan Castillo 8031c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 8041c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN} 8051c75d5dfSMasahiro Yamadaendif 8061c75d5dfSMasahiro Yamada 80773c99d4eSJuan Castillo################################################################################ 80846e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 80946e5e035SMichalis Pappas################################################################################ 81046e5e035SMichalis Pappas 81146e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 81246e5e035SMichalis Pappas 81346e5e035SMichalis Pappas################################################################################ 814819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc) 81573c99d4eSJuan Castillo################################################################################ 81673c99d4eSJuan Castillo 81773c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool 81873c99d4eSJuan CastilloCRTTOOLPATH ?= tools/cert_create 81942a45b51SEvan LloydCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 82073c99d4eSJuan Castillo 82190aa901fSSumit Garg# Variables for use with Firmware Encryption Tool 82290aa901fSSumit GargENCTOOLPATH ?= tools/encrypt_fw 82390aa901fSSumit GargENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 82490aa901fSSumit Garg 82573c99d4eSJuan Castillo# Variables for use with Firmware Image Package 826819281eeSdp-armFIPTOOLPATH ?= tools/fiptool 827819281eeSdp-armFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 82873c99d4eSJuan Castillo 82926010da1SAntonio Nino Diaz# Variables for use with sptool 83026010da1SAntonio Nino DiazSPTOOLPATH ?= tools/sptool 83126010da1SAntonio Nino DiazSPTOOL ?= ${SPTOOLPATH}/sptool${BIN_EXT} 832ce2b1ec6SManish PandeySP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 83326010da1SAntonio Nino Diaz 8345accce5bSRoberto Vargas# Variables for use with ROMLIB 8355accce5bSRoberto VargasROMLIBPATH ?= lib/romlib 8365accce5bSRoberto Vargas 837cfe83910SLouis Mayencourt# Variable for use with Python 838cfe83910SLouis MayencourtPYTHON ?= python3 839cfe83910SLouis Mayencourt 840cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP 841cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH ?= tools/memory 842cfe83910SLouis MayencourtPRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py 843cfe83910SLouis Mayencourt 8446de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool 8456de32378SMadhukar PappireddyDOCS_PATH ?= docs 8466de32378SMadhukar Pappireddy 8478a86052dSSoby Mathew################################################################################ 8488a86052dSSoby Mathew# Include BL specific makefiles 8498a86052dSSoby Mathew################################################################################ 8508a86052dSSoby Mathewifdef BL1_SOURCES 8518a86052dSSoby MathewNEED_BL1 := yes 8528a86052dSSoby Mathewinclude bl1/bl1.mk 8538a86052dSSoby Mathewendif 8548a86052dSSoby Mathew 8558a86052dSSoby Mathewifdef BL2_SOURCES 8568a86052dSSoby MathewNEED_BL2 := yes 8578a86052dSSoby Mathewinclude bl2/bl2.mk 8588a86052dSSoby Mathewendif 8598a86052dSSoby Mathew 8608a86052dSSoby Mathewifdef BL2U_SOURCES 8618a86052dSSoby MathewNEED_BL2U := yes 8628a86052dSSoby Mathewinclude bl2u/bl2u.mk 8638a86052dSSoby Mathewendif 8648a86052dSSoby Mathew 8655744e874SSoby Mathewifeq (${NEED_BL31},yes) 8668a86052dSSoby Mathewifdef BL31_SOURCES 8678a86052dSSoby Mathewinclude bl31/bl31.mk 8688a86052dSSoby Mathewendif 8698a86052dSSoby Mathewendif 8708a86052dSSoby Mathew 87103b397a8SNishanth Menonifdef FDT_SOURCES 87203b397a8SNishanth MenonNEED_FDT := yes 87303b397a8SNishanth Menonendif 87403b397a8SNishanth Menon 87573c99d4eSJuan Castillo################################################################################ 87673c99d4eSJuan Castillo# Build options checks 87773c99d4eSJuan Castillo################################################################################ 87873c99d4eSJuan Castillo 879327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 880327131c4SLeonardo Sandoval $(sort \ 881327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 882327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 883327131c4SLeonardo Sandoval CREATE_KEYS \ 884327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 885327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 886327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 887327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 888327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 889062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 890327131c4SLeonardo Sandoval DEBUG \ 8910063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 892327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 893327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 894327131c4SLeonardo Sandoval ENABLE_AMU \ 895327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 896327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 897327131c4SLeonardo Sandoval ENABLE_PIE \ 898327131c4SLeonardo Sandoval ENABLE_PMF \ 899327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 900327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 901327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 902327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 903327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 904327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 905327131c4SLeonardo Sandoval GENERATE_COT \ 906327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 907327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 908327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 909327131c4SLeonardo Sandoval INVERTED_MEMMAP \ 910327131c4SLeonardo Sandoval MEASURED_BOOT \ 911327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 912327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 913327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 914327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 915327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 916327131c4SLeonardo Sandoval RAS_EXTENSION \ 917327131c4SLeonardo Sandoval RESET_TO_BL31 \ 918327131c4SLeonardo Sandoval SAVE_KEYS \ 919327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 920327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 921327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 922327131c4SLeonardo Sandoval SPM_MM \ 923327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 924327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 925327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 926327131c4SLeonardo Sandoval USE_DEBUGFS \ 927327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 928327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 929327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 930327131c4SLeonardo Sandoval USE_ROMLIB \ 931327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 932327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 933327131c4SLeonardo Sandoval BL2_AT_EL3 \ 934327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 935327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 936327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 937327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 938327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 939327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 940327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 941327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 942327131c4SLeonardo Sandoval USE_SP804_TIMER \ 943327131c4SLeonardo Sandoval))) 94473c99d4eSJuan Castillo 945327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 946327131c4SLeonardo Sandoval $(sort \ 947327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 948327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 949327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 950327131c4SLeonardo Sandoval FW_ENC_STATUS \ 951327131c4SLeonardo Sandoval))) 952c877b414SJeenu Viswambharan 953aacff749SJustin Chadwellifdef KEY_SIZE 954aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 955aacff749SJustin Chadwellendif 956aacff749SJustin Chadwell 9571f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 9581f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 9591f461979SJustin Chadwellendif 9601f461979SJustin Chadwell 96173c99d4eSJuan Castillo################################################################################ 96273c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 96373c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 96473c99d4eSJuan Castillo# platform to overwrite the default options 96573c99d4eSJuan Castillo################################################################################ 96673c99d4eSJuan Castillo 967327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 968327131c4SLeonardo Sandoval $(sort \ 969327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 970327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 971327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 972327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 973327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 974327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 975327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 976327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 977327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 978327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 979062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 980327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 9810063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 982327131c4SLeonardo Sandoval ENABLE_AMU \ 983327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 984327131c4SLeonardo Sandoval ENABLE_BTI \ 985327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 986327131c4SLeonardo Sandoval ENABLE_PAUTH \ 987327131c4SLeonardo Sandoval ENABLE_PIE \ 988327131c4SLeonardo Sandoval ENABLE_PMF \ 989327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 990327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 991327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 992327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 993327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 994327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 995327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 996327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 997327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 998327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 999327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1000327131c4SLeonardo Sandoval LOG_LEVEL \ 1001327131c4SLeonardo Sandoval MEASURED_BOOT \ 1002327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1003327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1004327131c4SLeonardo Sandoval PLAT_${PLAT} \ 1005327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1006327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 1007327131c4SLeonardo Sandoval RAS_EXTENSION \ 1008327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1009327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 1010327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1011327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1012327131c4SLeonardo Sandoval SPD_${SPD} \ 1013327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1014327131c4SLeonardo Sandoval SPM_MM \ 1015327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1016327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1017327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1018327131c4SLeonardo Sandoval USE_DEBUGFS \ 1019327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1020327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1021327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1022327131c4SLeonardo Sandoval USE_ROMLIB \ 1023327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1024327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1025327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1026327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1027327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1028327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1029327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 1030327131c4SLeonardo Sandoval RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1031327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1032327131c4SLeonardo Sandoval USE_SP804_TIMER \ 1033327131c4SLeonardo Sandoval))) 10342fae4b1eSJeenu Viswambharan 10351f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 10361f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 10371f461979SJustin Chadwellendif 10381f461979SJustin Chadwell 10394c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 10404c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 10414c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1042cf2c8a33SAntonio Nino Diazelse 104368450a6dSAntonio Nino Diaz # Define the PRELOADED_BL33_BASE flag only if it is provided and 104468450a6dSAntonio Nino Diaz # EL3_PAYLOAD_BASE is not defined, as it has priority. 104568450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 104668450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 10474c117f6cSSandrine Bailleux endif 1048cf2c8a33SAntonio Nino Diazendif 104973c99d4eSJuan Castillo 1050209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1051209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1052209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH)) 1053209a60ccSSoby Mathewendif 1054209a60ccSSoby Mathew 1055c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1056c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK)) 1057c2ad38ceSVarun Wadekarendif 1058c2ad38ceSVarun Wadekar 1059ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1060ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1061c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1062c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},0) 1063c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL1 does not require SP_LAYOUT_FILE") 1064c33ff198SOlivier Deprez endif 1065ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1066ce2b1ec6SManish Pandey FIP_DEPS += sp 106707c44475SManish Pandey CRT_DEPS += sp 1068ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1069ce2b1ec6SManish Pandeyelse 1070c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1071c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1072c33ff198SOlivier Deprez endif 1073ce2b1ec6SManish Pandeyendif 1074ce2b1ec6SManish Pandeyendif 1075ce2b1ec6SManish Pandey 107673c99d4eSJuan Castillo################################################################################ 107773c99d4eSJuan Castillo# Build targets 107873c99d4eSJuan Castillo################################################################################ 107973c99d4eSJuan Castillo 108090aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 108173c99d4eSJuan Castillo.SUFFIXES: 108273c99d4eSJuan Castillo 108373c99d4eSJuan Castilloall: msg_start 108473c99d4eSJuan Castillo 108573c99d4eSJuan Castillomsg_start: 108673c99d4eSJuan Castillo @echo "Building ${PLAT}" 108773c99d4eSJuan Castillo 10887a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1089d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1090c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1091c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1092c2ad38ceSVarun Wadekarelse 1093bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 10947a24cba5SSoby Mathewendif 1095d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED 10967a24cba5SSoby Mathew 10975accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 109861f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 10995fee0287SRoberto Vargas 110073c99d4eSJuan Castillo# Expand build macros for the different images 110173c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 110273c99d4eSJuan Castillo$(eval $(call MAKE_BL,1)) 110373c99d4eSJuan Castilloendif 110473c99d4eSJuan Castillo 110573c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1106c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0) 1107c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1108c9b31ae8SRoberto Vargasendif 1109c9b31ae8SRoberto Vargas 111033950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1111c9b31ae8SRoberto Vargas $(eval $(call MAKE_BL,2,${FIP_BL2_ARGS}))) 111273c99d4eSJuan Castilloendif 111373c99d4eSJuan Castillo 11144d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 111533950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 11164d045d0eSMasahiro Yamadaendif 11174d045d0eSMasahiro Yamada 111873c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 111973c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 112026d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 112126d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1122c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1123c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1124c6ba9b45SSumit Garg $(eval $(call MAKE_BL,31,soc-fw,,$(ENCRYPT_BL31)))) 1125c6ba9b45SSumit Gargelse 112633950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 11278f0617efSJuan Castillo $(eval $(call MAKE_BL,31,soc-fw))) 112873c99d4eSJuan Castilloendif 1129c6ba9b45SSumit Gargendif 113073c99d4eSJuan Castillo 113170d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1132c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 113370d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 113473c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 113526d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 113626d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 11379cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 11389cd15239SMasahiro Yamada 1139c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1140c6ba9b45SSumit Garg$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw,,$(ENCRYPT_BL32))),\ 1141c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1142c6ba9b45SSumit Gargelse 11439cd15239SMasahiro Yamada$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\ 114433950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 114573c99d4eSJuan Castilloendif 1146c6ba9b45SSumit Gargendif 114773c99d4eSJuan Castillo 114873c99d4eSJuan Castillo# Add the BL33 image if required by the platform 114973c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 115033950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1151db6071c9SJuan Castilloendif 1152db6071c9SJuan Castillo 11539003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 115433950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 11551dc0714fSMasahiro Yamada $(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_))) 11569003fa0bSYatharth Kocharendif 11579003fa0bSYatharth Kochar 115803b397a8SNishanth Menon# Expand build macros for the different images 115903b397a8SNishanth Menonifeq (${NEED_FDT},yes) 116003b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 116103b397a8SNishanth Menonendif 116203b397a8SNishanth Menon 1163ce2b1ec6SManish Pandey# Add Secure Partition packages 1164ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1165ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 11661e7528ecSRuari Phipps ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1167ce2b1ec6SManish Pandeysp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk 1168ce2b1ec6SManish Pandey ${Q}$(SPTOOL) $(SPTOOL_ARGS) 1169ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1170ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1171ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1172ce2b1ec6SManish Pandeyendif 1173ce2b1ec6SManish Pandey 117436eaaf37SIan Spraylocate-checkpatch: 117536eaaf37SIan Sprayifndef CHECKPATCH 117666079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 117736eaaf37SIan Sprayelse 117836eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 117966079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 118036eaaf37SIan Sprayendif 118136eaaf37SIan Sprayendif 118236eaaf37SIan Spray 11834f6ad66aSAchin Guptaclean: 11844f6ad66aSAchin Gupta @echo " CLEAN" 1185f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 118688a1cf1eSSami Mujawarifdef UNIX_MK 11872f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 118888a1cf1eSSami Mujawarelse 118988a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 119088a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 119188a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 119288a1cf1eSSami Mujawarendif 11936f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 119490aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 11955accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 11964f6ad66aSAchin Gupta 1197eaaeece2SJames Morrisseyrealclean distclean: 1198eaaeece2SJames Morrissey @echo " REALCLEAN" 1199f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1200f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 120188a1cf1eSSami Mujawarifdef UNIX_MK 12022f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 120388a1cf1eSSami Mujawarelse 120488a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 120588a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 120688a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 120788a1cf1eSSami Mujawarendif 120826010da1SAntonio Nino Diaz ${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean 12096f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 121090aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 12115accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 12124f6ad66aSAchin Gupta 121336eaaf37SIan Spraycheckcodebase: locate-checkpatch 121436eaaf37SIan Spray @echo " CHECKING STYLE" 121536eaaf37SIan Spray @if test -d .git ; then \ 12161ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 12171a41e8c1SDan Handley while read GIT_FILE ; \ 12181a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 12191a41e8c1SDan Handley done ; \ 122036eaaf37SIan Spray else \ 12211a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 12221a41e8c1SDan Handley -not -iwholename "*build*" \ 12231a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 122461f72a34SRoberto Vargas -not -iwholename "*libc*" \ 12251a41e8c1SDan Handley -not -iwholename "*docs*" \ 12261ef35512SPaul Beesley -not -iwholename "*.rst" \ 12271a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 122836eaaf37SIan Spray fi 122936eaaf37SIan Spray 123036eaaf37SIan Spraycheckpatch: locate-checkpatch 123136eaaf37SIan Spray @echo " CHECKING STYLE" 123202a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 123302a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 123402a76d5fSYann Gautier fi 123551d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 123651d28937SAntonio Nino Diaz for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \ 123751d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 123851d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 123902a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 124002a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 124151d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 124202a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 124302a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 124451d28937SAntonio Nino Diaz done 124536eaaf37SIan Spray 124673c99d4eSJuan Castillocerttool: ${CRTTOOL} 124773c99d4eSJuan Castillo 1248a9812206SPali Rohár${CRTTOOL}: FORCE 1249fafd3ec9SManish 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} 1250f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 12516f971622SJuan Castillo @echo "Built $@ successfully" 1252f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 12536f971622SJuan Castillo 12546f971622SJuan Castilloifneq (${GENERATE_COT},0) 125573c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 12566f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1257f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 12586f971622SJuan Castillo @echo "Built $@ successfully" 12596f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1260f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 126173c99d4eSJuan Castilloendif 126227713fb4SSoby Mathew 126373c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 1264*4727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1265819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1266819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1267f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 12682f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1269f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1270f58ad36fSHarry Liebel 12710191262dSYatharth Kocharifneq (${GENERATE_COT},0) 12720191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 12730191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1274052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 12750191262dSYatharth Kochar @echo "Built $@ successfully" 12760191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1277052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 12780191262dSYatharth Kocharendif 12790191262dSYatharth Kochar 12800191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 1281*4727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1282819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1283819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1284052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 12850191262dSYatharth Kochar @echo "Built $@ successfully" 1286052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 12870191262dSYatharth Kochar 128873c99d4eSJuan Castillofiptool: ${FIPTOOL} 128973c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 12900191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 129173c99d4eSJuan Castillo 1292a9812206SPali Rohár${FIPTOOL}: FORCE 129388a1cf1eSSami Mujawar @${ECHO_BLANK_LINE} 129488a1cf1eSSami Mujawar @echo "Building $@" 129588a1cf1eSSami Mujawarifdef UNIX_MK 1296fafd3ec9SManish V Badarkhe ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH} 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)) 130188a1cf1eSSami Mujawarendif 130288a1cf1eSSami Mujawar @${ECHO_BLANK_LINE} 1303f58ad36fSHarry Liebel 130426010da1SAntonio Nino Diazsptool: ${SPTOOL} 1305a9812206SPali Rohár${SPTOOL}: FORCE 1306fafd3ec9SManish V Badarkhe ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH} 130726010da1SAntonio Nino Diaz 1308a9812206SPali Rohárromlib.bin: libraries FORCE 1309bbb24f61SJohn 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 13105accce5bSRoberto Vargas 1311cfe83910SLouis Mayencourt# Call print_memory_map tool 1312cfe83910SLouis Mayencourtmemmap: all 1313b890b36dSLouis Mayencourt ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1314cfe83910SLouis Mayencourt 13156de32378SMadhukar Pappireddydoc: 13166de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 13176de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 13186de32378SMadhukar Pappireddy 131990aa901fSSumit Gargenctool: ${ENCTOOL} 132090aa901fSSumit Garg 1321a9812206SPali Rohár${ENCTOOL}: FORCE 1322fafd3ec9SManish V Badarkhe ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH} 132390aa901fSSumit Garg @${ECHO_BLANK_LINE} 132490aa901fSSumit Garg @echo "Built $@ successfully" 132590aa901fSSumit Garg @${ECHO_BLANK_LINE} 132690aa901fSSumit Garg 132735fab8c9SJoakim Bechcscope: 132835fab8c9SJoakim Bech @echo " CSCOPE" 132935fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 133035fab8c9SJoakim Bech ${Q}cscope -b -q -k 133135fab8c9SJoakim Bech 133272ee3314SRyan Harkinhelp: 13337c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 133472ee3314SRyan Harkin @echo "" 133572ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 133608c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 133772ee3314SRyan Harkin @echo "" 13387c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 13397c23126cSJohn Tsichritzis @echo "" 13401b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 13411b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 13421b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 13431b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 13441b578596SSandrine Bailleux @echo "" 134572ee3314SRyan Harkin @echo "Supported Targets:" 13461b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 134736eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 13488aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 13499003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1350d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 13519d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 13529d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 135373c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 13541b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 13550191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 135636eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 135736eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 135836eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 135972ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 136035fab8c9SJoakim Bech @echo " cscope Generate cscope index" 136172ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 13626f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 136390aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1364f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1365ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 136626010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 136738c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1368cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 13696de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 137072ee3314SRyan Harkin @echo "" 13711b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 137272ee3314SRyan Harkin @echo "" 137372ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 137472ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1375a9812206SPali Rohár 1376a9812206SPali Rohár.PHONY: FORCE 1377a9812206SPali RohárFORCE:; 1378