xref: /rk3399_ARM-atf/Makefile (revision 93271a1e5781e1840f4c29d2fb3ec9a128f0e4be)
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
3788154678SJuan Castillo# Default goal is build all images
3888154678SJuan Castillo.DEFAULT_GOAL			:= all
3988154678SJuan Castillo
4073c99d4eSJuan Castilloinclude make_helpers/build_macros.mk
4173c99d4eSJuan Castillo
4273c99d4eSJuan Castillo################################################################################
43e35c4045SJeenu Viswambharan# Default values for build configurations
4473c99d4eSJuan Castillo################################################################################
45e35c4045SJeenu Viswambharan
46e35c4045SJeenu Viswambharan# Build verbosity
47e35c4045SJeenu ViswambharanV				:= 0
48e35c4045SJeenu Viswambharan# Debug build
49e35c4045SJeenu ViswambharanDEBUG				:= 0
50e35c4045SJeenu Viswambharan# Build platform
51e35c4045SJeenu ViswambharanDEFAULT_PLAT			:= fvp
52e35c4045SJeenu ViswambharanPLAT				:= ${DEFAULT_PLAT}
53e35c4045SJeenu Viswambharan# SPD choice
54e35c4045SJeenu ViswambharanSPD				:= none
55e35c4045SJeenu Viswambharan# Base commit to perform code check on
56e35c4045SJeenu ViswambharanBASE_COMMIT			:= origin/master
572da8d8bfSJeenu Viswambharan# NS timer register save and restore
582da8d8bfSJeenu ViswambharanNS_TIMER_SWITCH			:= 0
59dbad1bacSVikram Kanigiri# By default, Bl1 acts as the reset handler, not BL31
60dbad1bacSVikram KanigiriRESET_TO_BL31			:= 0
610f21c547SJuan Castillo# Include FP registers in cpu context
620f21c547SJuan CastilloCTX_INCLUDE_FPREGS		:= 0
632b98e789SSandrine Bailleux# Determine the version of ARM GIC architecture to use for interrupt management
642b98e789SSandrine Bailleux# in EL3. The platform port can change this value if needed.
652b98e789SSandrine BailleuxARM_GIC_ARCH			:= 2
6623e47edeSVikram Kanigiri# Determine the version of ARM CCI product used in the platform. The platform
6723e47edeSVikram Kanigiri# port can change this value if needed.
6823e47edeSVikram KanigiriARM_CCI_PRODUCT_ID		:= 400
69bc920128SSoby Mathew# Flag used to indicate if ASM_ASSERTION should be enabled for the build.
70bc920128SSoby Mathew# This defaults to being present in DEBUG builds only.
71bc920128SSoby MathewASM_ASSERTION			:= ${DEBUG}
728c5fe0b5SSoby Mathew# Build option to choose whether Trusted firmware uses Coherent memory or not.
738c5fe0b5SSoby MathewUSE_COHERENT_MEM		:= 1
748ee24980SSoby Mathew# Flag used to choose the power state format viz Extended State-ID or the Original
758ee24980SSoby Mathew# format.
768ee24980SSoby MathewPSCI_EXTENDED_STATE_ID		:= 0
777f48fab9SJuan Castillo# Default FIP file name
787f48fab9SJuan CastilloFIP_NAME			:= fip.bin
79db6071c9SJuan Castillo# By default, use the -pedantic option in the gcc command line
80db6071c9SJuan CastilloDISABLE_PEDANTIC		:= 0
816f971622SJuan Castillo# Flags to generate the Chain of Trust
826f971622SJuan CastilloGENERATE_COT			:= 0
836f971622SJuan CastilloCREATE_KEYS			:= 1
84fd34e7baSJuan CastilloSAVE_KEYS			:= 0
856eadf762SJuan Castillo# Flags to build TF with Trusted Boot support
866eadf762SJuan CastilloTRUSTED_BOARD_BOOT		:= 0
87bf031bbaSSandrine Bailleux# By default, consider that the platform's reset address is not programmable.
88bf031bbaSSandrine Bailleux# The platform Makefile is free to override this value.
89bf031bbaSSandrine BailleuxPROGRAMMABLE_RESET_ADDRESS	:= 0
905c8babcdSSoby Mathew# Build flag to warn about usage of deprecated platform and framework APIs
915c8babcdSSoby MathewWARN_DEPRECATED			:= 0
924f6ad66aSAchin Gupta
9373c99d4eSJuan Castillo
9473c99d4eSJuan Castillo################################################################################
9573c99d4eSJuan Castillo# Checkpatch script options
9673c99d4eSJuan Castillo################################################################################
9773c99d4eSJuan Castillo
9873c99d4eSJuan CastilloCHECK_IGNORE		:=	--ignore COMPLEX_MACRO \
999b4ee6b3SJuan Castillo				--ignore GERRIT_CHANGE_ID \
1009b4ee6b3SJuan Castillo				--ignore GIT_COMMIT_ID
10173c99d4eSJuan CastilloCHECKPATCH_ARGS		:=	--no-tree --no-signoff ${CHECK_IGNORE}
10273c99d4eSJuan CastilloCHECKCODE_ARGS		:=	--no-patch --no-tree --no-signoff ${CHECK_IGNORE}
10395d5353cSSandrine Bailleux# Do not check the coding style on C library files
10473c99d4eSJuan CastilloCHECK_PATHS		:=	$(shell ls -I include -I lib) \
105662109a5SSandrine Bailleux				$(addprefix include/,$(shell ls -I stdlib include)) \
106662109a5SSandrine Bailleux				$(addprefix lib/,$(shell ls -I stdlib lib))
10736eaaf37SIan Spray
10873c99d4eSJuan Castillo
10973c99d4eSJuan Castillo################################################################################
11073c99d4eSJuan Castillo# Process build options
11173c99d4eSJuan Castillo################################################################################
11273c99d4eSJuan Castillo
11373c99d4eSJuan Castillo# Verbose flag
114e35c4045SJeenu Viswambharanifeq (${V},0)
1154f6ad66aSAchin Gupta        Q=@
11636eaaf37SIan Spray        CHECKCODE_ARGS	+=	--no-summary --terse
1174f6ad66aSAchin Guptaelse
1184f6ad66aSAchin Gupta        Q=
1194f6ad66aSAchin Guptaendif
1202f2cef46SJeenu Viswambharanexport Q
1212f2cef46SJeenu Viswambharan
12273c99d4eSJuan Castillo# Process Debug flag
12373c99d4eSJuan Castillo$(eval $(call add_define,DEBUG))
124eaaeece2SJames Morrisseyifneq (${DEBUG}, 0)
125eaaeece2SJames Morrissey        BUILD_TYPE	:=	debug
12673c99d4eSJuan Castillo        CFLAGS		+= 	-g
12773c99d4eSJuan Castillo        ASFLAGS		+= 	-g -Wa,--gdwarf-2
128289c28a8SDan Handley        # Use LOG_LEVEL_INFO by default for debug builds
129289c28a8SDan Handley        LOG_LEVEL	:=	40
130eaaeece2SJames Morrisseyelse
131eaaeece2SJames Morrissey        BUILD_TYPE	:=	release
13273c99d4eSJuan Castillo        $(eval $(call add_define,NDEBUG))
133289c28a8SDan Handley        # Use LOG_LEVEL_NOTICE by default for release builds
134289c28a8SDan Handley        LOG_LEVEL	:=	20
135eaaeece2SJames Morrisseyendif
136eaaeece2SJames Morrissey
137aaa3e722SJuan Castillo# Default build string (git branch and commit)
138aaa3e722SJuan Castilloifeq (${BUILD_STRING},)
139aaa3e722SJuan Castillo        BUILD_STRING	:=	$(shell git log -n 1 --pretty=format:"%h")
140aaa3e722SJuan Castilloendif
141aaa3e722SJuan CastilloVERSION_STRING		:=	v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
142aaa3e722SJuan Castillo
14373c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the
14473c99d4eSJuan Castillo# target 'certificates' to create them all
14573c99d4eSJuan Castilloifneq (${GENERATE_COT},0)
14673c99d4eSJuan Castillo        FIP_DEPS += certificates
14773c99d4eSJuan Castilloendif
14873c99d4eSJuan Castillo
14973c99d4eSJuan Castillo
15073c99d4eSJuan Castillo################################################################################
15173c99d4eSJuan Castillo# Toolchain
15273c99d4eSJuan Castillo################################################################################
15373c99d4eSJuan Castillo
15473c99d4eSJuan CastilloCC			:=	${CROSS_COMPILE}gcc
15573c99d4eSJuan CastilloCPP			:=	${CROSS_COMPILE}cpp
15673c99d4eSJuan CastilloAS			:=	${CROSS_COMPILE}gcc
15773c99d4eSJuan CastilloAR			:=	${CROSS_COMPILE}ar
15873c99d4eSJuan CastilloLD			:=	${CROSS_COMPILE}ld
15973c99d4eSJuan CastilloOC			:=	${CROSS_COMPILE}objcopy
16073c99d4eSJuan CastilloOD			:=	${CROSS_COMPILE}objdump
16173c99d4eSJuan CastilloNM			:=	${CROSS_COMPILE}nm
16273c99d4eSJuan CastilloPP			:=	${CROSS_COMPILE}gcc -E
16373c99d4eSJuan Castillo
16473c99d4eSJuan CastilloASFLAGS			+= 	-nostdinc -ffreestanding -Wa,--fatal-warnings	\
16573c99d4eSJuan Castillo				-Werror -Wmissing-include-dirs			\
16673c99d4eSJuan Castillo				-mgeneral-regs-only -D__ASSEMBLY__		\
16773c99d4eSJuan Castillo				${DEFINES} ${INCLUDES}
16873c99d4eSJuan CastilloCFLAGS			+= 	-nostdinc -ffreestanding -Wall			\
16973c99d4eSJuan Castillo				-Werror -Wmissing-include-dirs			\
17073c99d4eSJuan Castillo				-mgeneral-regs-only -std=c99 -c -Os		\
17173c99d4eSJuan Castillo				${DEFINES} ${INCLUDES}
17273c99d4eSJuan CastilloCFLAGS			+=	-ffunction-sections -fdata-sections
17373c99d4eSJuan Castillo
17473c99d4eSJuan CastilloLDFLAGS			+=	--fatal-warnings -O1
17573c99d4eSJuan CastilloLDFLAGS			+=	--gc-sections
17673c99d4eSJuan Castillo
17773c99d4eSJuan Castillo
17873c99d4eSJuan Castillo################################################################################
17973c99d4eSJuan Castillo# Common sources and include directories
18073c99d4eSJuan Castillo################################################################################
18173c99d4eSJuan Castillo
18273c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
183b79af934SSoby Mathew				common/tf_printf.c			\
184626ed510SSoby Mathew				common/aarch64/debug.S			\
185bee82417SDan Handley				lib/aarch64/cache_helpers.S		\
186bee82417SDan Handley				lib/aarch64/misc_helpers.S		\
187bee82417SDan Handley				lib/aarch64/xlat_helpers.c		\
188bee82417SDan Handley				lib/stdlib/std.c			\
189bee82417SDan Handley				plat/common/aarch64/platform_helpers.S
190d7a6b0f8SRyan Harkin
191a0df63efSSandrine BailleuxINCLUDES		+=	-Iinclude/bl31			\
1924ecca339SDan Handley				-Iinclude/bl31/services		\
1934ecca339SDan Handley				-Iinclude/common		\
1944ecca339SDan Handley				-Iinclude/drivers		\
1954ecca339SDan Handley				-Iinclude/drivers/arm		\
1961779ba6bSJuan Castillo				-Iinclude/drivers/auth		\
197935db693SDan Handley				-Iinclude/drivers/io		\
198c13b2e32SVarun Wadekar				-Iinclude/drivers/ti/uart	\
1994ecca339SDan Handley				-Iinclude/lib			\
2004ecca339SDan Handley				-Iinclude/lib/aarch64		\
201add40351SSoby Mathew				-Iinclude/lib/cpus/aarch64	\
2025f0cdb05SDan Handley				-Iinclude/plat/common		\
203d7a6b0f8SRyan Harkin				-Iinclude/stdlib		\
204d7a6b0f8SRyan Harkin				-Iinclude/stdlib/sys		\
205375f538aSAchin Gupta				${PLAT_INCLUDES}		\
206375f538aSAchin Gupta				${SPD_INCLUDES}
2074f6ad66aSAchin Gupta
20873c99d4eSJuan Castillo
20973c99d4eSJuan Castillo################################################################################
21073c99d4eSJuan Castillo# Generic definitions
21173c99d4eSJuan Castillo################################################################################
21273c99d4eSJuan Castillo
21373c99d4eSJuan CastilloBUILD_BASE		:=	./build
21473c99d4eSJuan CastilloBUILD_PLAT		:=	${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
21573c99d4eSJuan Castillo
21673c99d4eSJuan CastilloPLAT_MAKEFILE		:=	platform.mk
21773c99d4eSJuan Castillo# Generate the platforms list by recursively searching for all directories
21873c99d4eSJuan Castillo# under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
21973c99d4eSJuan Castillo# char and strip out the final '|'.
22073c99d4eSJuan CastilloPLATFORMS		:=	$(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 |			\
22173c99d4eSJuan Castillo					sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' |	\
22273c99d4eSJuan Castillo					sed -r 's/\|$$//')
22373c99d4eSJuan CastilloSPDS			:=	$(shell ls -I none services/spd)
22473c99d4eSJuan Castillo
22573c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
22673c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
22773c99d4eSJuan Castillo
22873c99d4eSJuan Castillo
22973c99d4eSJuan Castillo################################################################################
23073c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
23173c99d4eSJuan Castillo################################################################################
23273c99d4eSJuan Castillo
23373c99d4eSJuan Castilloifneq (${SPD},none)
23473c99d4eSJuan Castillo        # We expect to locate an spd.mk under the specified SPD directory
23573c99d4eSJuan Castillo        SPD_MAKE	:=	$(shell m="services/spd/${SPD}/${SPD}.mk"; [ -f "$$m" ] && echo "$$m")
23673c99d4eSJuan Castillo
23773c99d4eSJuan Castillo        ifeq (${SPD_MAKE},)
23873c99d4eSJuan Castillo                $(error Error: No services/spd/${SPD}/${SPD}.mk located)
23973c99d4eSJuan Castillo        endif
24073c99d4eSJuan Castillo        $(info Including ${SPD_MAKE})
24173c99d4eSJuan Castillo        include ${SPD_MAKE}
24273c99d4eSJuan Castillo
24373c99d4eSJuan Castillo        # If there's BL3-2 companion for the chosen SPD, and the SPD wants to build the
24473c99d4eSJuan Castillo        # BL3-2 from source, we expect that the SPD's Makefile would set NEED_BL32
24573c99d4eSJuan Castillo        # variable to "yes". In case the BL3-2 is a binary which needs to be included in
24673c99d4eSJuan Castillo        # fip, then the NEED_BL32 needs to be set and BL3-2 would need to point to the bin.
247e35c4045SJeenu Viswambharanendif
248e35c4045SJeenu Viswambharan
249c04d2606SDan Handley
25073c99d4eSJuan Castillo################################################################################
25173c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
25273c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
25373c99d4eSJuan Castillo################################################################################
2542da8d8bfSJeenu Viswambharan
25573c99d4eSJuan Castilloifeq (${PLAT},)
25673c99d4eSJuan Castillo        $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
25773c99d4eSJuan Castilloendif
25873c99d4eSJuan CastilloPLAT_MAKEFILE_FULL	:=	$(shell find plat/ -wholename '*/${PLAT}/${PLAT_MAKEFILE}')
25973c99d4eSJuan Castilloifeq ($(PLAT_MAKEFILE_FULL),)
26073c99d4eSJuan Castillo        $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
26173c99d4eSJuan Castilloendif
262dbad1bacSVikram Kanigiri
26373c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
2640f21c547SJuan Castillo
265*93271a1eSAchin Gupta# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default
266*93271a1eSAchin Guptaifndef ENABLE_PLAT_COMPAT
267*93271a1eSAchin GuptaENABLE_PLAT_COMPAT := 1
268*93271a1eSAchin Guptaendif
269*93271a1eSAchin Gupta
270*93271a1eSAchin Gupta# Include the platform compatibility helpers for PSCI
271*93271a1eSAchin Guptaifneq (${ENABLE_PLAT_COMPAT}, 0)
272*93271a1eSAchin Guptainclude plat/compat/plat_compat.mk
273*93271a1eSAchin Guptaendif
274*93271a1eSAchin Gupta
27573c99d4eSJuan Castillo# Include the CPU specific operations makefile. By default all CPU errata
27673c99d4eSJuan Castillo# workarounds and CPU specifc optimisations are disabled. This can be
27773c99d4eSJuan Castillo# overridden by the platform.
27873c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
2794f6ad66aSAchin Gupta
2804f6ad66aSAchin Gupta
28173c99d4eSJuan Castillo################################################################################
28273c99d4eSJuan Castillo# Process platform overrideable behaviour
28373c99d4eSJuan Castillo################################################################################
2844f6ad66aSAchin Gupta
28573c99d4eSJuan Castillo# Check if -pedantic option should be used
28673c99d4eSJuan Castilloifeq (${DISABLE_PEDANTIC},0)
28773c99d4eSJuan Castillo        CFLAGS		+= 	-pedantic
28873c99d4eSJuan Castilloendif
289f58ad36fSHarry Liebel
29073c99d4eSJuan Castillo# Using the ARM Trusted Firmware BL2 implies that a BL3-3 image also need to be
29173c99d4eSJuan Castillo# supplied for the FIP and Certificate generation tools. This flag can be
29273c99d4eSJuan Castillo# overridden by the platform.
29373c99d4eSJuan Castilloifdef BL2_SOURCES
29473c99d4eSJuan CastilloNEED_BL33		?=	yes
29573c99d4eSJuan Castilloendif
2966f971622SJuan Castillo
29773c99d4eSJuan Castillo# Process TBB related flags
2986f971622SJuan Castilloifneq (${GENERATE_COT},0)
29973c99d4eSJuan Castillo        # Common cert_create options
3006f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
3016f971622SJuan Castillo                $(eval CRT_ARGS += -n)
302fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
303fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
304fd34e7baSJuan Castillo                endif
3056f971622SJuan Castillo        endif
30673c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
30773c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
30873c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
30973c99d4eSJuan Castillo        endif
3106f971622SJuan Castilloendif
3116f971622SJuan Castillo
31273c99d4eSJuan Castillo
31373c99d4eSJuan Castillo################################################################################
31473c99d4eSJuan Castillo# Auxiliary tools (fip_create, cert_create, etc)
31573c99d4eSJuan Castillo################################################################################
31673c99d4eSJuan Castillo
31773c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
31873c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
31973c99d4eSJuan CastilloCRTTOOL			?=	${CRTTOOLPATH}/cert_create
32073c99d4eSJuan Castillo
32173c99d4eSJuan Castillo# Variables for use with Firmware Image Package
32273c99d4eSJuan CastilloFIPTOOLPATH		?=	tools/fip_create
32373c99d4eSJuan CastilloFIPTOOL			?=	${FIPTOOLPATH}/fip_create
32473c99d4eSJuan Castillo
32573c99d4eSJuan Castillo
32673c99d4eSJuan Castillo################################################################################
32773c99d4eSJuan Castillo# Build options checks
32873c99d4eSJuan Castillo################################################################################
32973c99d4eSJuan Castillo
33073c99d4eSJuan Castillo$(eval $(call assert_boolean,DEBUG))
33173c99d4eSJuan Castillo$(eval $(call assert_boolean,NS_TIMER_SWITCH))
33273c99d4eSJuan Castillo$(eval $(call assert_boolean,RESET_TO_BL31))
33373c99d4eSJuan Castillo$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
33473c99d4eSJuan Castillo$(eval $(call assert_boolean,ASM_ASSERTION))
33573c99d4eSJuan Castillo$(eval $(call assert_boolean,USE_COHERENT_MEM))
33673c99d4eSJuan Castillo$(eval $(call assert_boolean,DISABLE_PEDANTIC))
33773c99d4eSJuan Castillo$(eval $(call assert_boolean,GENERATE_COT))
33873c99d4eSJuan Castillo$(eval $(call assert_boolean,CREATE_KEYS))
33973c99d4eSJuan Castillo$(eval $(call assert_boolean,SAVE_KEYS))
34073c99d4eSJuan Castillo$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
34173c99d4eSJuan Castillo$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS))
34273c99d4eSJuan Castillo$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID))
34373c99d4eSJuan Castillo$(eval $(call assert_boolean,WARN_DEPRECATED))
344*93271a1eSAchin Gupta$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
34573c99d4eSJuan Castillo
34673c99d4eSJuan Castillo
34773c99d4eSJuan Castillo################################################################################
34873c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
34973c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
35073c99d4eSJuan Castillo# platform to overwrite the default options
35173c99d4eSJuan Castillo################################################################################
35273c99d4eSJuan Castillo
35373c99d4eSJuan Castillo$(eval $(call add_define,PLAT_${PLAT}))
35473c99d4eSJuan Castillo$(eval $(call add_define,NS_TIMER_SWITCH))
35573c99d4eSJuan Castillo$(eval $(call add_define,RESET_TO_BL31))
35673c99d4eSJuan Castillo$(eval $(call add_define,CTX_INCLUDE_FPREGS))
35773c99d4eSJuan Castillo$(eval $(call add_define,ARM_GIC_ARCH))
35873c99d4eSJuan Castillo$(eval $(call add_define,ARM_CCI_PRODUCT_ID))
35973c99d4eSJuan Castillo$(eval $(call add_define,ASM_ASSERTION))
36073c99d4eSJuan Castillo$(eval $(call add_define,LOG_LEVEL))
36173c99d4eSJuan Castillo$(eval $(call add_define,USE_COHERENT_MEM))
36273c99d4eSJuan Castillo$(eval $(call add_define,TRUSTED_BOARD_BOOT))
36373c99d4eSJuan Castillo$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS))
36473c99d4eSJuan Castillo$(eval $(call add_define,PSCI_EXTENDED_STATE_ID))
36573c99d4eSJuan Castillo$(eval $(call add_define,WARN_DEPRECATED))
366*93271a1eSAchin Gupta$(eval $(call add_define,ENABLE_PLAT_COMPAT))
36773c99d4eSJuan Castillo
36873c99d4eSJuan Castillo
36973c99d4eSJuan Castillo################################################################################
37073c99d4eSJuan Castillo# Include BL specific makefiles
37173c99d4eSJuan Castillo################################################################################
37273c99d4eSJuan Castillo
37373c99d4eSJuan Castilloifdef BL1_SOURCES
37473c99d4eSJuan CastilloNEED_BL1 := yes
37573c99d4eSJuan Castilloinclude bl1/bl1.mk
37673c99d4eSJuan Castilloendif
37773c99d4eSJuan Castillo
37873c99d4eSJuan Castilloifdef BL2_SOURCES
37973c99d4eSJuan CastilloNEED_BL2 := yes
38073c99d4eSJuan Castilloinclude bl2/bl2.mk
38173c99d4eSJuan Castilloendif
38273c99d4eSJuan Castillo
38373c99d4eSJuan Castilloifdef BL31_SOURCES
38473c99d4eSJuan CastilloNEED_BL31 := yes
38573c99d4eSJuan Castilloinclude bl31/bl31.mk
38673c99d4eSJuan Castilloendif
38773c99d4eSJuan Castillo
38873c99d4eSJuan Castillo
38973c99d4eSJuan Castillo################################################################################
39073c99d4eSJuan Castillo# Build targets
39173c99d4eSJuan Castillo################################################################################
39273c99d4eSJuan Castillo
39373c99d4eSJuan Castillo.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip certtool
39473c99d4eSJuan Castillo.SUFFIXES:
39573c99d4eSJuan Castillo
39673c99d4eSJuan Castilloall: msg_start
39773c99d4eSJuan Castillo
39873c99d4eSJuan Castillomsg_start:
39973c99d4eSJuan Castillo	@echo "Building ${PLAT}"
40073c99d4eSJuan Castillo
40173c99d4eSJuan Castillo# Expand build macros for the different images
40273c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
40373c99d4eSJuan Castillo$(eval $(call MAKE_BL,1))
40473c99d4eSJuan Castilloendif
40573c99d4eSJuan Castillo
40673c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
40773c99d4eSJuan Castillo$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},in_fip)),\
40873c99d4eSJuan Castillo	$(eval $(call MAKE_BL,2,in_fip)))
40973c99d4eSJuan Castilloendif
41073c99d4eSJuan Castillo
41173c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
41273c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
41373c99d4eSJuan Castillo$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},in_fip)),\
41473c99d4eSJuan Castillo	$(eval $(call MAKE_BL,31,in_fip)))
41573c99d4eSJuan Castilloendif
41673c99d4eSJuan Castillo
41773c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
41873c99d4eSJuan Castillo$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},in_fip)),\
41973c99d4eSJuan Castillo	$(eval $(call MAKE_BL,32,in_fip)))
42073c99d4eSJuan Castilloendif
42173c99d4eSJuan Castillo
42273c99d4eSJuan Castillo# Add the BL33 image if required by the platform
42373c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
42473c99d4eSJuan Castillo$(eval $(call FIP_ADD_IMG,BL33,--bl33))
425db6071c9SJuan Castilloendif
426db6071c9SJuan Castillo
42736eaaf37SIan Spraylocate-checkpatch:
42836eaaf37SIan Sprayifndef CHECKPATCH
42936eaaf37SIan Spray	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
43036eaaf37SIan Sprayelse
43136eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
43236eaaf37SIan Spray	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
43336eaaf37SIan Sprayendif
43436eaaf37SIan Sprayendif
43536eaaf37SIan Spray
4364f6ad66aSAchin Guptaclean:
4374f6ad66aSAchin Gupta	@echo "  CLEAN"
43825cff83eSRyan Harkin	${Q}rm -rf ${BUILD_PLAT}
4392f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
4406f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
4414f6ad66aSAchin Gupta
442eaaeece2SJames Morrisseyrealclean distclean:
443eaaeece2SJames Morrissey	@echo "  REALCLEAN"
444eaaeece2SJames Morrissey	${Q}rm -rf ${BUILD_BASE}
44535fab8c9SJoakim Bech	${Q}rm -f ${CURDIR}/cscope.*
4462f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
4476f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
4484f6ad66aSAchin Gupta
44936eaaf37SIan Spraycheckcodebase:		locate-checkpatch
45036eaaf37SIan Spray	@echo "  CHECKING STYLE"
45136eaaf37SIan Spray	@if test -d .git ; then	\
4524f2104ffSJuan Castillo		git ls-files | grep -v stdlib | while read GIT_FILE ; do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; done ;	\
45336eaaf37SIan Spray	 else			\
4544f2104ffSJuan Castillo		 find . -type f -not -iwholename "*.git*" -not -iwholename "*build*" -not -iwholename "*stdlib*" -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
45536eaaf37SIan Spray	 fi
45636eaaf37SIan Spray
45736eaaf37SIan Spraycheckpatch:		locate-checkpatch
45836eaaf37SIan Spray	@echo "  CHECKING STYLE"
459662109a5SSandrine Bailleux	${Q}git log -p ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} ${CHECKPATCH_ARGS} - || true
46036eaaf37SIan Spray
46173c99d4eSJuan Castillocerttool: ${CRTTOOL}
46273c99d4eSJuan Castillo
4636f971622SJuan Castillo.PHONY: ${CRTTOOL}
4646f971622SJuan Castillo${CRTTOOL}:
4656f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH}
4666f971622SJuan Castillo	@echo
4676f971622SJuan Castillo	@echo "Built $@ successfully"
4686f971622SJuan Castillo	@echo
4696f971622SJuan Castillo
4706f971622SJuan Castilloifneq (${GENERATE_COT},0)
47173c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
4726f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
4736f971622SJuan Castillo	@echo
4746f971622SJuan Castillo	@echo "Built $@ successfully"
4756f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
4766f971622SJuan Castillo	@echo
47773c99d4eSJuan Castilloendif
47827713fb4SSoby Mathew
47973c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
48073c99d4eSJuan Castillo	${Q}${FIPTOOL} --dump ${FIP_ARGS} $@
481f58ad36fSHarry Liebel	@echo
4822f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
4832f2cef46SJeenu Viswambharan	@echo
484f58ad36fSHarry Liebel
48573c99d4eSJuan Castillofiptool: ${FIPTOOL}
48673c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
48773c99d4eSJuan Castillo
48873c99d4eSJuan Castillo.PHONY: ${FIPTOOL}
48973c99d4eSJuan Castillo${FIPTOOL}:
49073c99d4eSJuan Castillo	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH}
491f58ad36fSHarry Liebel
49235fab8c9SJoakim Bechcscope:
49335fab8c9SJoakim Bech	@echo "  CSCOPE"
49435fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
49535fab8c9SJoakim Bech	${Q}cscope -b -q -k
49635fab8c9SJoakim Bech
49772ee3314SRyan Harkinhelp:
498c04d2606SDan Handley	@echo "usage: ${MAKE} PLAT=<${PLATFORMS}> [OPTIONS] [TARGET]"
49972ee3314SRyan Harkin	@echo ""
50072ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
50108c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
50272ee3314SRyan Harkin	@echo ""
5031b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
5041b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
5051b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
5061b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
5071b578596SSandrine Bailleux	@echo ""
50872ee3314SRyan Harkin	@echo "Supported Targets:"
5091b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
51036eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
5118aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
5121b578596SSandrine Bailleux	@echo "  bl31           Build the BL3-1 binary"
5131b578596SSandrine Bailleux	@echo "  bl32           Build the BL3-2 binary"
51473c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
5151b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
51636eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
51736eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
51836eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
51972ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
52035fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
52172ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
5226f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
523f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package(FIP) creation tool"
52472ee3314SRyan Harkin	@echo ""
5251b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
52672ee3314SRyan Harkin	@echo ""
52772ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
52872ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
529