14f6ad66aSAchin Gupta# 2c04d2606SDan Handley# Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta# 44f6ad66aSAchin Gupta# Redistribution and use in source and binary forms, with or without 54f6ad66aSAchin Gupta# modification, are permitted provided that the following conditions are met: 64f6ad66aSAchin Gupta# 74f6ad66aSAchin Gupta# Redistributions of source code must retain the above copyright notice, this 84f6ad66aSAchin Gupta# list of conditions and the following disclaimer. 94f6ad66aSAchin Gupta# 104f6ad66aSAchin Gupta# Redistributions in binary form must reproduce the above copyright notice, 114f6ad66aSAchin Gupta# this list of conditions and the following disclaimer in the documentation 124f6ad66aSAchin Gupta# and/or other materials provided with the distribution. 134f6ad66aSAchin Gupta# 144f6ad66aSAchin Gupta# Neither the name of ARM nor the names of its contributors may be used 154f6ad66aSAchin Gupta# to endorse or promote products derived from this software without specific 164f6ad66aSAchin Gupta# prior written permission. 174f6ad66aSAchin Gupta# 184f6ad66aSAchin Gupta# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 194f6ad66aSAchin Gupta# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 204f6ad66aSAchin Gupta# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 214f6ad66aSAchin Gupta# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 224f6ad66aSAchin Gupta# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 234f6ad66aSAchin Gupta# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 244f6ad66aSAchin Gupta# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 254f6ad66aSAchin Gupta# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 264f6ad66aSAchin Gupta# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 274f6ad66aSAchin Gupta# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 284f6ad66aSAchin Gupta# POSSIBILITY OF SUCH DAMAGE. 294f6ad66aSAchin Gupta# 304f6ad66aSAchin Gupta 31e35c4045SJeenu Viswambharan# 32aaa3e722SJuan Castillo# Trusted Firmware Version 33aaa3e722SJuan Castillo# 34c6249aaaSDan HandleyVERSION_MAJOR := 1 35130ed88dSAchin GuptaVERSION_MINOR := 1 36aaa3e722SJuan Castillo 37*73c99d4eSJuan Castilloinclude make_helpers/build_macros.mk 38*73c99d4eSJuan Castillo 39*73c99d4eSJuan Castillo################################################################################ 40e35c4045SJeenu Viswambharan# Default values for build configurations 41*73c99d4eSJuan Castillo################################################################################ 42e35c4045SJeenu Viswambharan 43e35c4045SJeenu Viswambharan# Build verbosity 44e35c4045SJeenu ViswambharanV := 0 45e35c4045SJeenu Viswambharan# Debug build 46e35c4045SJeenu ViswambharanDEBUG := 0 47e35c4045SJeenu Viswambharan# Build platform 48e35c4045SJeenu ViswambharanDEFAULT_PLAT := fvp 49e35c4045SJeenu ViswambharanPLAT := ${DEFAULT_PLAT} 50e35c4045SJeenu Viswambharan# SPD choice 51e35c4045SJeenu ViswambharanSPD := none 52e35c4045SJeenu Viswambharan# Base commit to perform code check on 53e35c4045SJeenu ViswambharanBASE_COMMIT := origin/master 542da8d8bfSJeenu Viswambharan# NS timer register save and restore 552da8d8bfSJeenu ViswambharanNS_TIMER_SWITCH := 0 56dbad1bacSVikram Kanigiri# By default, Bl1 acts as the reset handler, not BL31 57dbad1bacSVikram KanigiriRESET_TO_BL31 := 0 580f21c547SJuan Castillo# Include FP registers in cpu context 590f21c547SJuan CastilloCTX_INCLUDE_FPREGS := 0 602b98e789SSandrine Bailleux# Determine the version of ARM GIC architecture to use for interrupt management 612b98e789SSandrine Bailleux# in EL3. The platform port can change this value if needed. 622b98e789SSandrine BailleuxARM_GIC_ARCH := 2 6323e47edeSVikram Kanigiri# Determine the version of ARM CCI product used in the platform. The platform 6423e47edeSVikram Kanigiri# port can change this value if needed. 6523e47edeSVikram KanigiriARM_CCI_PRODUCT_ID := 400 66bc920128SSoby Mathew# Flag used to indicate if ASM_ASSERTION should be enabled for the build. 67bc920128SSoby Mathew# This defaults to being present in DEBUG builds only. 68bc920128SSoby MathewASM_ASSERTION := ${DEBUG} 698c5fe0b5SSoby Mathew# Build option to choose whether Trusted firmware uses Coherent memory or not. 708c5fe0b5SSoby MathewUSE_COHERENT_MEM := 1 718ee24980SSoby Mathew# Flag used to choose the power state format viz Extended State-ID or the Original 728ee24980SSoby Mathew# format. 738ee24980SSoby MathewPSCI_EXTENDED_STATE_ID := 0 747f48fab9SJuan Castillo# Default FIP file name 757f48fab9SJuan CastilloFIP_NAME := fip.bin 76db6071c9SJuan Castillo# By default, use the -pedantic option in the gcc command line 77db6071c9SJuan CastilloDISABLE_PEDANTIC := 0 786f971622SJuan Castillo# Flags to generate the Chain of Trust 796f971622SJuan CastilloGENERATE_COT := 0 806f971622SJuan CastilloCREATE_KEYS := 1 81fd34e7baSJuan CastilloSAVE_KEYS := 0 826eadf762SJuan Castillo# Flags to build TF with Trusted Boot support 836eadf762SJuan CastilloTRUSTED_BOARD_BOOT := 0 84bf031bbaSSandrine Bailleux# By default, consider that the platform's reset address is not programmable. 85bf031bbaSSandrine Bailleux# The platform Makefile is free to override this value. 86bf031bbaSSandrine BailleuxPROGRAMMABLE_RESET_ADDRESS := 0 875c8babcdSSoby Mathew# Build flag to warn about usage of deprecated platform and framework APIs 885c8babcdSSoby MathewWARN_DEPRECATED := 0 894f6ad66aSAchin Gupta 90*73c99d4eSJuan Castillo 91*73c99d4eSJuan Castillo################################################################################ 92*73c99d4eSJuan Castillo# Checkpatch script options 93*73c99d4eSJuan Castillo################################################################################ 94*73c99d4eSJuan Castillo 95*73c99d4eSJuan CastilloCHECK_IGNORE := --ignore COMPLEX_MACRO \ 969b4ee6b3SJuan Castillo --ignore GERRIT_CHANGE_ID \ 979b4ee6b3SJuan Castillo --ignore GIT_COMMIT_ID 98*73c99d4eSJuan CastilloCHECKPATCH_ARGS := --no-tree --no-signoff ${CHECK_IGNORE} 99*73c99d4eSJuan CastilloCHECKCODE_ARGS := --no-patch --no-tree --no-signoff ${CHECK_IGNORE} 10095d5353cSSandrine Bailleux# Do not check the coding style on C library files 101*73c99d4eSJuan CastilloCHECK_PATHS := $(shell ls -I include -I lib) \ 102662109a5SSandrine Bailleux $(addprefix include/,$(shell ls -I stdlib include)) \ 103662109a5SSandrine Bailleux $(addprefix lib/,$(shell ls -I stdlib lib)) 10436eaaf37SIan Spray 105*73c99d4eSJuan Castillo 106*73c99d4eSJuan Castillo################################################################################ 107*73c99d4eSJuan Castillo# Process build options 108*73c99d4eSJuan Castillo################################################################################ 109*73c99d4eSJuan Castillo 110*73c99d4eSJuan Castillo# Verbose flag 111e35c4045SJeenu Viswambharanifeq (${V},0) 1124f6ad66aSAchin Gupta Q=@ 11336eaaf37SIan Spray CHECKCODE_ARGS += --no-summary --terse 1144f6ad66aSAchin Guptaelse 1154f6ad66aSAchin Gupta Q= 1164f6ad66aSAchin Guptaendif 1172f2cef46SJeenu Viswambharanexport Q 1182f2cef46SJeenu Viswambharan 119*73c99d4eSJuan Castillo# Process Debug flag 120*73c99d4eSJuan Castillo$(eval $(call add_define,DEBUG)) 121eaaeece2SJames Morrisseyifneq (${DEBUG}, 0) 122eaaeece2SJames Morrissey BUILD_TYPE := debug 123*73c99d4eSJuan Castillo CFLAGS += -g 124*73c99d4eSJuan Castillo ASFLAGS += -g -Wa,--gdwarf-2 125289c28a8SDan Handley # Use LOG_LEVEL_INFO by default for debug builds 126289c28a8SDan Handley LOG_LEVEL := 40 127eaaeece2SJames Morrisseyelse 128eaaeece2SJames Morrissey BUILD_TYPE := release 129*73c99d4eSJuan Castillo $(eval $(call add_define,NDEBUG)) 130289c28a8SDan Handley # Use LOG_LEVEL_NOTICE by default for release builds 131289c28a8SDan Handley LOG_LEVEL := 20 132eaaeece2SJames Morrisseyendif 133eaaeece2SJames Morrissey 134aaa3e722SJuan Castillo# Default build string (git branch and commit) 135aaa3e722SJuan Castilloifeq (${BUILD_STRING},) 136aaa3e722SJuan Castillo BUILD_STRING := $(shell git log -n 1 --pretty=format:"%h") 137aaa3e722SJuan Castilloendif 138aaa3e722SJuan CastilloVERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING} 139aaa3e722SJuan Castillo 140*73c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the 141*73c99d4eSJuan Castillo# target 'certificates' to create them all 142*73c99d4eSJuan Castilloifneq (${GENERATE_COT},0) 143*73c99d4eSJuan Castillo FIP_DEPS += certificates 144*73c99d4eSJuan Castilloendif 145*73c99d4eSJuan Castillo 146*73c99d4eSJuan Castillo 147*73c99d4eSJuan Castillo################################################################################ 148*73c99d4eSJuan Castillo# Toolchain 149*73c99d4eSJuan Castillo################################################################################ 150*73c99d4eSJuan Castillo 151*73c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 152*73c99d4eSJuan CastilloCPP := ${CROSS_COMPILE}cpp 153*73c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 154*73c99d4eSJuan CastilloAR := ${CROSS_COMPILE}ar 155*73c99d4eSJuan CastilloLD := ${CROSS_COMPILE}ld 156*73c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 157*73c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 158*73c99d4eSJuan CastilloNM := ${CROSS_COMPILE}nm 159*73c99d4eSJuan CastilloPP := ${CROSS_COMPILE}gcc -E 160*73c99d4eSJuan Castillo 161*73c99d4eSJuan CastilloASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ 162*73c99d4eSJuan Castillo -Werror -Wmissing-include-dirs \ 163*73c99d4eSJuan Castillo -mgeneral-regs-only -D__ASSEMBLY__ \ 164*73c99d4eSJuan Castillo ${DEFINES} ${INCLUDES} 165*73c99d4eSJuan CastilloCFLAGS += -nostdinc -ffreestanding -Wall \ 166*73c99d4eSJuan Castillo -Werror -Wmissing-include-dirs \ 167*73c99d4eSJuan Castillo -mgeneral-regs-only -std=c99 -c -Os \ 168*73c99d4eSJuan Castillo ${DEFINES} ${INCLUDES} 169*73c99d4eSJuan CastilloCFLAGS += -ffunction-sections -fdata-sections 170*73c99d4eSJuan Castillo 171*73c99d4eSJuan CastilloLDFLAGS += --fatal-warnings -O1 172*73c99d4eSJuan CastilloLDFLAGS += --gc-sections 173*73c99d4eSJuan Castillo 174*73c99d4eSJuan Castillo 175*73c99d4eSJuan Castillo################################################################################ 176*73c99d4eSJuan Castillo# Common sources and include directories 177*73c99d4eSJuan Castillo################################################################################ 178*73c99d4eSJuan Castillo 179*73c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 180b79af934SSoby Mathew common/tf_printf.c \ 181626ed510SSoby Mathew common/aarch64/debug.S \ 182bee82417SDan Handley lib/aarch64/cache_helpers.S \ 183bee82417SDan Handley lib/aarch64/misc_helpers.S \ 184bee82417SDan Handley lib/aarch64/xlat_helpers.c \ 185bee82417SDan Handley lib/stdlib/std.c \ 186bee82417SDan Handley plat/common/aarch64/platform_helpers.S 187d7a6b0f8SRyan Harkin 188a0df63efSSandrine BailleuxINCLUDES += -Iinclude/bl31 \ 1894ecca339SDan Handley -Iinclude/bl31/services \ 1904ecca339SDan Handley -Iinclude/common \ 1914ecca339SDan Handley -Iinclude/drivers \ 1924ecca339SDan Handley -Iinclude/drivers/arm \ 1931779ba6bSJuan Castillo -Iinclude/drivers/auth \ 194935db693SDan Handley -Iinclude/drivers/io \ 195c13b2e32SVarun Wadekar -Iinclude/drivers/ti/uart \ 1964ecca339SDan Handley -Iinclude/lib \ 1974ecca339SDan Handley -Iinclude/lib/aarch64 \ 198add40351SSoby Mathew -Iinclude/lib/cpus/aarch64 \ 1995f0cdb05SDan Handley -Iinclude/plat/common \ 200d7a6b0f8SRyan Harkin -Iinclude/stdlib \ 201d7a6b0f8SRyan Harkin -Iinclude/stdlib/sys \ 202375f538aSAchin Gupta ${PLAT_INCLUDES} \ 203375f538aSAchin Gupta ${SPD_INCLUDES} 2044f6ad66aSAchin Gupta 205*73c99d4eSJuan Castillo 206*73c99d4eSJuan Castillo################################################################################ 207*73c99d4eSJuan Castillo# Generic definitions 208*73c99d4eSJuan Castillo################################################################################ 209*73c99d4eSJuan Castillo 210*73c99d4eSJuan CastilloBUILD_BASE := ./build 211*73c99d4eSJuan CastilloBUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE} 212*73c99d4eSJuan Castillo 213*73c99d4eSJuan CastilloPLAT_MAKEFILE := platform.mk 214*73c99d4eSJuan Castillo# Generate the platforms list by recursively searching for all directories 215*73c99d4eSJuan Castillo# under /plat containing a PLAT_MAKEFILE. Append each platform with a `|` 216*73c99d4eSJuan Castillo# char and strip out the final '|'. 217*73c99d4eSJuan CastilloPLATFORMS := $(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 | \ 218*73c99d4eSJuan Castillo sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' | \ 219*73c99d4eSJuan Castillo sed -r 's/\|$$//') 220*73c99d4eSJuan CastilloSPDS := $(shell ls -I none services/spd) 221*73c99d4eSJuan Castillo 222*73c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value 223*73c99d4eSJuan CastilloINCLUDE_TBBR_MK := 1 224*73c99d4eSJuan Castillo 225*73c99d4eSJuan Castillo 226*73c99d4eSJuan Castillo################################################################################ 227*73c99d4eSJuan Castillo# Include SPD Makefile if one has been specified 228*73c99d4eSJuan Castillo################################################################################ 229*73c99d4eSJuan Castillo 230*73c99d4eSJuan Castilloifneq (${SPD},none) 231*73c99d4eSJuan Castillo # We expect to locate an spd.mk under the specified SPD directory 232*73c99d4eSJuan Castillo SPD_MAKE := $(shell m="services/spd/${SPD}/${SPD}.mk"; [ -f "$$m" ] && echo "$$m") 233*73c99d4eSJuan Castillo 234*73c99d4eSJuan Castillo ifeq (${SPD_MAKE},) 235*73c99d4eSJuan Castillo $(error Error: No services/spd/${SPD}/${SPD}.mk located) 236*73c99d4eSJuan Castillo endif 237*73c99d4eSJuan Castillo $(info Including ${SPD_MAKE}) 238*73c99d4eSJuan Castillo include ${SPD_MAKE} 239*73c99d4eSJuan Castillo 240*73c99d4eSJuan Castillo # If there's BL3-2 companion for the chosen SPD, and the SPD wants to build the 241*73c99d4eSJuan Castillo # BL3-2 from source, we expect that the SPD's Makefile would set NEED_BL32 242*73c99d4eSJuan Castillo # variable to "yes". In case the BL3-2 is a binary which needs to be included in 243*73c99d4eSJuan Castillo # fip, then the NEED_BL32 needs to be set and BL3-2 would need to point to the bin. 244e35c4045SJeenu Viswambharanendif 245e35c4045SJeenu Viswambharan 246c04d2606SDan Handley 247*73c99d4eSJuan Castillo################################################################################ 248*73c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform 249*73c99d4eSJuan Castillo# makefile may use all previous definitions in this file) 250*73c99d4eSJuan Castillo################################################################################ 2512da8d8bfSJeenu Viswambharan 252*73c99d4eSJuan Castilloifeq (${PLAT},) 253*73c99d4eSJuan Castillo $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform") 254*73c99d4eSJuan Castilloendif 255*73c99d4eSJuan CastilloPLAT_MAKEFILE_FULL := $(shell find plat/ -wholename '*/${PLAT}/${PLAT_MAKEFILE}') 256*73c99d4eSJuan Castilloifeq ($(PLAT_MAKEFILE_FULL),) 257*73c99d4eSJuan Castillo $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}") 258*73c99d4eSJuan Castilloendif 259dbad1bacSVikram Kanigiri 260*73c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL} 2610f21c547SJuan Castillo 262*73c99d4eSJuan Castillo# Include the CPU specific operations makefile. By default all CPU errata 263*73c99d4eSJuan Castillo# workarounds and CPU specifc optimisations are disabled. This can be 264*73c99d4eSJuan Castillo# overridden by the platform. 265*73c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 2664f6ad66aSAchin Gupta 2674f6ad66aSAchin Gupta 268*73c99d4eSJuan Castillo################################################################################ 269*73c99d4eSJuan Castillo# Process platform overrideable behaviour 270*73c99d4eSJuan Castillo################################################################################ 2714f6ad66aSAchin Gupta 272*73c99d4eSJuan Castillo# Check if -pedantic option should be used 273*73c99d4eSJuan Castilloifeq (${DISABLE_PEDANTIC},0) 274*73c99d4eSJuan Castillo CFLAGS += -pedantic 275*73c99d4eSJuan Castilloendif 276f58ad36fSHarry Liebel 277*73c99d4eSJuan Castillo# Using the ARM Trusted Firmware BL2 implies that a BL3-3 image also need to be 278*73c99d4eSJuan Castillo# supplied for the FIP and Certificate generation tools. This flag can be 279*73c99d4eSJuan Castillo# overridden by the platform. 280*73c99d4eSJuan Castilloifdef BL2_SOURCES 281*73c99d4eSJuan CastilloNEED_BL33 ?= yes 282*73c99d4eSJuan Castilloendif 2836f971622SJuan Castillo 284*73c99d4eSJuan Castillo# Process TBB related flags 2856f971622SJuan Castilloifneq (${GENERATE_COT},0) 286*73c99d4eSJuan Castillo # Common cert_create options 2876f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 2886f971622SJuan Castillo $(eval CRT_ARGS += -n) 289fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 290fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 291fd34e7baSJuan Castillo endif 2926f971622SJuan Castillo endif 293*73c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 294*73c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 295*73c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 296*73c99d4eSJuan Castillo endif 2976f971622SJuan Castilloendif 2986f971622SJuan Castillo 299*73c99d4eSJuan Castillo 300*73c99d4eSJuan Castillo################################################################################ 301*73c99d4eSJuan Castillo# Auxiliary tools (fip_create, cert_create, etc) 302*73c99d4eSJuan Castillo################################################################################ 303*73c99d4eSJuan Castillo 304*73c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool 305*73c99d4eSJuan CastilloCRTTOOLPATH ?= tools/cert_create 306*73c99d4eSJuan CastilloCRTTOOL ?= ${CRTTOOLPATH}/cert_create 307*73c99d4eSJuan Castillo 308*73c99d4eSJuan Castillo# Variables for use with Firmware Image Package 309*73c99d4eSJuan CastilloFIPTOOLPATH ?= tools/fip_create 310*73c99d4eSJuan CastilloFIPTOOL ?= ${FIPTOOLPATH}/fip_create 311*73c99d4eSJuan Castillo 312*73c99d4eSJuan Castillo 313*73c99d4eSJuan Castillo################################################################################ 314*73c99d4eSJuan Castillo# Build options checks 315*73c99d4eSJuan Castillo################################################################################ 316*73c99d4eSJuan Castillo 317*73c99d4eSJuan Castillo$(eval $(call assert_boolean,DEBUG)) 318*73c99d4eSJuan Castillo$(eval $(call assert_boolean,NS_TIMER_SWITCH)) 319*73c99d4eSJuan Castillo$(eval $(call assert_boolean,RESET_TO_BL31)) 320*73c99d4eSJuan Castillo$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS)) 321*73c99d4eSJuan Castillo$(eval $(call assert_boolean,ASM_ASSERTION)) 322*73c99d4eSJuan Castillo$(eval $(call assert_boolean,USE_COHERENT_MEM)) 323*73c99d4eSJuan Castillo$(eval $(call assert_boolean,DISABLE_PEDANTIC)) 324*73c99d4eSJuan Castillo$(eval $(call assert_boolean,GENERATE_COT)) 325*73c99d4eSJuan Castillo$(eval $(call assert_boolean,CREATE_KEYS)) 326*73c99d4eSJuan Castillo$(eval $(call assert_boolean,SAVE_KEYS)) 327*73c99d4eSJuan Castillo$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT)) 328*73c99d4eSJuan Castillo$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS)) 329*73c99d4eSJuan Castillo$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID)) 330*73c99d4eSJuan Castillo$(eval $(call assert_boolean,WARN_DEPRECATED)) 331*73c99d4eSJuan Castillo 332*73c99d4eSJuan Castillo 333*73c99d4eSJuan Castillo################################################################################ 334*73c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 335*73c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 336*73c99d4eSJuan Castillo# platform to overwrite the default options 337*73c99d4eSJuan Castillo################################################################################ 338*73c99d4eSJuan Castillo 339*73c99d4eSJuan Castillo$(eval $(call add_define,PLAT_${PLAT})) 340*73c99d4eSJuan Castillo$(eval $(call add_define,NS_TIMER_SWITCH)) 341*73c99d4eSJuan Castillo$(eval $(call add_define,RESET_TO_BL31)) 342*73c99d4eSJuan Castillo$(eval $(call add_define,CTX_INCLUDE_FPREGS)) 343*73c99d4eSJuan Castillo$(eval $(call add_define,ARM_GIC_ARCH)) 344*73c99d4eSJuan Castillo$(eval $(call add_define,ARM_CCI_PRODUCT_ID)) 345*73c99d4eSJuan Castillo$(eval $(call add_define,ASM_ASSERTION)) 346*73c99d4eSJuan Castillo$(eval $(call add_define,LOG_LEVEL)) 347*73c99d4eSJuan Castillo$(eval $(call add_define,USE_COHERENT_MEM)) 348*73c99d4eSJuan Castillo$(eval $(call add_define,TRUSTED_BOARD_BOOT)) 349*73c99d4eSJuan Castillo$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS)) 350*73c99d4eSJuan Castillo$(eval $(call add_define,PSCI_EXTENDED_STATE_ID)) 351*73c99d4eSJuan Castillo$(eval $(call add_define,WARN_DEPRECATED)) 352*73c99d4eSJuan Castillo 353*73c99d4eSJuan Castillo 354*73c99d4eSJuan Castillo################################################################################ 355*73c99d4eSJuan Castillo# Include BL specific makefiles 356*73c99d4eSJuan Castillo################################################################################ 357*73c99d4eSJuan Castillo 358*73c99d4eSJuan Castilloifdef BL1_SOURCES 359*73c99d4eSJuan CastilloNEED_BL1 := yes 360*73c99d4eSJuan Castilloinclude bl1/bl1.mk 361*73c99d4eSJuan Castilloendif 362*73c99d4eSJuan Castillo 363*73c99d4eSJuan Castilloifdef BL2_SOURCES 364*73c99d4eSJuan CastilloNEED_BL2 := yes 365*73c99d4eSJuan Castilloinclude bl2/bl2.mk 366*73c99d4eSJuan Castilloendif 367*73c99d4eSJuan Castillo 368*73c99d4eSJuan Castilloifdef BL31_SOURCES 369*73c99d4eSJuan CastilloNEED_BL31 := yes 370*73c99d4eSJuan Castilloinclude bl31/bl31.mk 371*73c99d4eSJuan Castilloendif 372*73c99d4eSJuan Castillo 373*73c99d4eSJuan Castillo 374*73c99d4eSJuan Castillo################################################################################ 375*73c99d4eSJuan Castillo# Build targets 376*73c99d4eSJuan Castillo################################################################################ 377*73c99d4eSJuan Castillo 378*73c99d4eSJuan Castillo# Default target 379*73c99d4eSJuan Castillo.DEFAULT_GOAL := all 380*73c99d4eSJuan Castillo 381*73c99d4eSJuan Castillo.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip certtool 382*73c99d4eSJuan Castillo.SUFFIXES: 383*73c99d4eSJuan Castillo 384*73c99d4eSJuan Castilloall: msg_start 385*73c99d4eSJuan Castillo 386*73c99d4eSJuan Castillomsg_start: 387*73c99d4eSJuan Castillo @echo "Building ${PLAT}" 388*73c99d4eSJuan Castillo 389*73c99d4eSJuan Castillo# Expand build macros for the different images 390*73c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 391*73c99d4eSJuan Castillo$(eval $(call MAKE_BL,1)) 392*73c99d4eSJuan Castilloendif 393*73c99d4eSJuan Castillo 394*73c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 395*73c99d4eSJuan Castillo$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},in_fip)),\ 396*73c99d4eSJuan Castillo $(eval $(call MAKE_BL,2,in_fip))) 397*73c99d4eSJuan Castilloendif 398*73c99d4eSJuan Castillo 399*73c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 400*73c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 401*73c99d4eSJuan Castillo$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},in_fip)),\ 402*73c99d4eSJuan Castillo $(eval $(call MAKE_BL,31,in_fip))) 403*73c99d4eSJuan Castilloendif 404*73c99d4eSJuan Castillo 405*73c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 406*73c99d4eSJuan Castillo$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},in_fip)),\ 407*73c99d4eSJuan Castillo $(eval $(call MAKE_BL,32,in_fip))) 408*73c99d4eSJuan Castilloendif 409*73c99d4eSJuan Castillo 410*73c99d4eSJuan Castillo# Add the BL33 image if required by the platform 411*73c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 412*73c99d4eSJuan Castillo$(eval $(call FIP_ADD_IMG,BL33,--bl33)) 413db6071c9SJuan Castilloendif 414db6071c9SJuan Castillo 41536eaaf37SIan Spraylocate-checkpatch: 41636eaaf37SIan Sprayifndef CHECKPATCH 41736eaaf37SIan Spray $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl") 41836eaaf37SIan Sprayelse 41936eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 42036eaaf37SIan Spray $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl") 42136eaaf37SIan Sprayendif 42236eaaf37SIan Sprayendif 42336eaaf37SIan Spray 4244f6ad66aSAchin Guptaclean: 4254f6ad66aSAchin Gupta @echo " CLEAN" 42625cff83eSRyan Harkin ${Q}rm -rf ${BUILD_PLAT} 4272f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 4286f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 4294f6ad66aSAchin Gupta 430eaaeece2SJames Morrisseyrealclean distclean: 431eaaeece2SJames Morrissey @echo " REALCLEAN" 432eaaeece2SJames Morrissey ${Q}rm -rf ${BUILD_BASE} 43335fab8c9SJoakim Bech ${Q}rm -f ${CURDIR}/cscope.* 4342f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 4356f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 4364f6ad66aSAchin Gupta 43736eaaf37SIan Spraycheckcodebase: locate-checkpatch 43836eaaf37SIan Spray @echo " CHECKING STYLE" 43936eaaf37SIan Spray @if test -d .git ; then \ 4404f2104ffSJuan Castillo git ls-files | grep -v stdlib | while read GIT_FILE ; do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; done ; \ 44136eaaf37SIan Spray else \ 4424f2104ffSJuan Castillo find . -type f -not -iwholename "*.git*" -not -iwholename "*build*" -not -iwholename "*stdlib*" -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 44336eaaf37SIan Spray fi 44436eaaf37SIan Spray 44536eaaf37SIan Spraycheckpatch: locate-checkpatch 44636eaaf37SIan Spray @echo " CHECKING STYLE" 447662109a5SSandrine Bailleux ${Q}git log -p ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} ${CHECKPATCH_ARGS} - || true 44836eaaf37SIan Spray 449*73c99d4eSJuan Castillocerttool: ${CRTTOOL} 450*73c99d4eSJuan Castillo 4516f971622SJuan Castillo.PHONY: ${CRTTOOL} 4526f971622SJuan Castillo${CRTTOOL}: 4536f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} 4546f971622SJuan Castillo @echo 4556f971622SJuan Castillo @echo "Built $@ successfully" 4566f971622SJuan Castillo @echo 4576f971622SJuan Castillo 4586f971622SJuan Castilloifneq (${GENERATE_COT},0) 459*73c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 4606f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 4616f971622SJuan Castillo @echo 4626f971622SJuan Castillo @echo "Built $@ successfully" 4636f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 4646f971622SJuan Castillo @echo 465*73c99d4eSJuan Castilloendif 46627713fb4SSoby Mathew 467*73c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 468*73c99d4eSJuan Castillo ${Q}${FIPTOOL} --dump ${FIP_ARGS} $@ 469f58ad36fSHarry Liebel @echo 4702f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 4712f2cef46SJeenu Viswambharan @echo 472f58ad36fSHarry Liebel 473*73c99d4eSJuan Castillofiptool: ${FIPTOOL} 474*73c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 475*73c99d4eSJuan Castillo 476*73c99d4eSJuan Castillo.PHONY: ${FIPTOOL} 477*73c99d4eSJuan Castillo${FIPTOOL}: 478*73c99d4eSJuan Castillo ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} 479f58ad36fSHarry Liebel 48035fab8c9SJoakim Bechcscope: 48135fab8c9SJoakim Bech @echo " CSCOPE" 48235fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 48335fab8c9SJoakim Bech ${Q}cscope -b -q -k 48435fab8c9SJoakim Bech 48572ee3314SRyan Harkinhelp: 486c04d2606SDan Handley @echo "usage: ${MAKE} PLAT=<${PLATFORMS}> [OPTIONS] [TARGET]" 48772ee3314SRyan Harkin @echo "" 48872ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 48908c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 49072ee3314SRyan Harkin @echo "" 4911b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 4921b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 4931b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 4941b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 4951b578596SSandrine Bailleux @echo "" 49672ee3314SRyan Harkin @echo "Supported Targets:" 4971b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 49836eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 4998aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 5001b578596SSandrine Bailleux @echo " bl31 Build the BL3-1 binary" 5011b578596SSandrine Bailleux @echo " bl32 Build the BL3-2 binary" 502*73c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 5031b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 50436eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 50536eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 50636eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 50772ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 50835fab8c9SJoakim Bech @echo " cscope Generate cscope index" 50972ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 5106f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 511f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package(FIP) creation tool" 51272ee3314SRyan Harkin @echo "" 5131b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 51472ee3314SRyan Harkin @echo "" 51572ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 51672ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 517