xref: /rk3399_ARM-atf/Makefile (revision 191a008865993e4f778e165fe9df4f2e1f9dd8cb)
14f6ad66aSAchin Gupta#
254035fc4SSandrine Bailleux# Copyright (c) 2013-2016, 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
356791f52eSDan HandleyVERSION_MINOR			:= 2
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
591645d3eeSSandrine Bailleux# 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
790191262dSYatharth Kochar# Default FWU_FIP file name
800191262dSYatharth KocharFWU_FIP_NAME			:= fwu_fip.bin
81db6071c9SJuan Castillo# By default, use the -pedantic option in the gcc command line
82db6071c9SJuan CastilloDISABLE_PEDANTIC		:= 0
836f971622SJuan Castillo# Flags to generate the Chain of Trust
846f971622SJuan CastilloGENERATE_COT			:= 0
856f971622SJuan CastilloCREATE_KEYS			:= 1
86fd34e7baSJuan CastilloSAVE_KEYS			:= 0
876eadf762SJuan Castillo# Flags to build TF with Trusted Boot support
886eadf762SJuan CastilloTRUSTED_BOARD_BOOT		:= 0
89bf031bbaSSandrine Bailleux# By default, consider that the platform's reset address is not programmable.
90bf031bbaSSandrine Bailleux# The platform Makefile is free to override this value.
91bf031bbaSSandrine BailleuxPROGRAMMABLE_RESET_ADDRESS	:= 0
927a24cba5SSoby Mathew# Build flag to treat usage of deprecated platform and framework APIs as error.
937a24cba5SSoby MathewERROR_DEPRECATED		:= 0
94a9bec67dSSandrine Bailleux# By default, consider that the platform may release several CPUs out of reset.
95a9bec67dSSandrine Bailleux# The platform Makefile is free to override this value.
96a9bec67dSSandrine BailleuxCOLD_BOOT_SINGLE_CPU		:= 0
9735e8c766SSandrine Bailleux# Flag to introduce an infinite loop in BL1 just before it exits into the next
9835e8c766SSandrine Bailleux# image. This is meant to help debugging the post-BL2 phase.
9935e8c766SSandrine BailleuxSPIN_ON_BL1_EXIT		:= 0
10012f654b6SJuan Castillo# Build PL011 UART driver in minimal generic UART mode
10112f654b6SJuan CastilloPL011_GENERIC_UART		:= 0
1024f6ad66aSAchin Gupta
10373c99d4eSJuan Castillo
10473c99d4eSJuan Castillo################################################################################
10573c99d4eSJuan Castillo# Checkpatch script options
10673c99d4eSJuan Castillo################################################################################
10773c99d4eSJuan Castillo
10873c99d4eSJuan CastilloCHECK_IGNORE		:=	--ignore COMPLEX_MACRO \
1099b4ee6b3SJuan Castillo				--ignore GERRIT_CHANGE_ID \
1109b4ee6b3SJuan Castillo				--ignore GIT_COMMIT_ID
11173c99d4eSJuan CastilloCHECKPATCH_ARGS		:=	--no-tree --no-signoff ${CHECK_IGNORE}
11273c99d4eSJuan CastilloCHECKCODE_ARGS		:=	--no-patch --no-tree --no-signoff ${CHECK_IGNORE}
11395d5353cSSandrine Bailleux# Do not check the coding style on C library files
11473c99d4eSJuan CastilloCHECK_PATHS		:=	$(shell ls -I include -I lib) \
115662109a5SSandrine Bailleux				$(addprefix include/,$(shell ls -I stdlib include)) \
116662109a5SSandrine Bailleux				$(addprefix lib/,$(shell ls -I stdlib lib))
11736eaaf37SIan Spray
11873c99d4eSJuan Castillo
11973c99d4eSJuan Castillo################################################################################
12073c99d4eSJuan Castillo# Process build options
12173c99d4eSJuan Castillo################################################################################
12273c99d4eSJuan Castillo
12373c99d4eSJuan Castillo# Verbose flag
124e35c4045SJeenu Viswambharanifeq (${V},0)
1254f6ad66aSAchin Gupta        Q=@
12636eaaf37SIan Spray        CHECKCODE_ARGS	+=	--no-summary --terse
1274f6ad66aSAchin Guptaelse
1284f6ad66aSAchin Gupta        Q=
1294f6ad66aSAchin Guptaendif
1302f2cef46SJeenu Viswambharanexport Q
1312f2cef46SJeenu Viswambharan
13273c99d4eSJuan Castillo# Process Debug flag
13373c99d4eSJuan Castillo$(eval $(call add_define,DEBUG))
134eaaeece2SJames Morrisseyifneq (${DEBUG}, 0)
135eaaeece2SJames Morrissey        BUILD_TYPE	:=	debug
13673c99d4eSJuan Castillo        CFLAGS		+= 	-g
13773c99d4eSJuan Castillo        ASFLAGS		+= 	-g -Wa,--gdwarf-2
138289c28a8SDan Handley        # Use LOG_LEVEL_INFO by default for debug builds
139289c28a8SDan Handley        LOG_LEVEL	:=	40
140eaaeece2SJames Morrisseyelse
141eaaeece2SJames Morrissey        BUILD_TYPE	:=	release
14273c99d4eSJuan Castillo        $(eval $(call add_define,NDEBUG))
143289c28a8SDan Handley        # Use LOG_LEVEL_NOTICE by default for release builds
144289c28a8SDan Handley        LOG_LEVEL	:=	20
145eaaeece2SJames Morrisseyendif
146eaaeece2SJames Morrissey
147aaa3e722SJuan Castillo# Default build string (git branch and commit)
148aaa3e722SJuan Castilloifeq (${BUILD_STRING},)
149aaa3e722SJuan Castillo        BUILD_STRING	:=	$(shell git log -n 1 --pretty=format:"%h")
150aaa3e722SJuan Castilloendif
151aaa3e722SJuan CastilloVERSION_STRING		:=	v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
152aaa3e722SJuan Castillo
15373c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the
15473c99d4eSJuan Castillo# target 'certificates' to create them all
15573c99d4eSJuan Castilloifneq (${GENERATE_COT},0)
15673c99d4eSJuan Castillo        FIP_DEPS += certificates
1570191262dSYatharth Kochar        FWU_FIP_DEPS += fwu_certificates
15873c99d4eSJuan Castilloendif
15973c99d4eSJuan Castillo
16073c99d4eSJuan Castillo
16173c99d4eSJuan Castillo################################################################################
16273c99d4eSJuan Castillo# Toolchain
16373c99d4eSJuan Castillo################################################################################
16473c99d4eSJuan Castillo
16573c99d4eSJuan CastilloCC			:=	${CROSS_COMPILE}gcc
16673c99d4eSJuan CastilloCPP			:=	${CROSS_COMPILE}cpp
16773c99d4eSJuan CastilloAS			:=	${CROSS_COMPILE}gcc
16873c99d4eSJuan CastilloAR			:=	${CROSS_COMPILE}ar
16973c99d4eSJuan CastilloLD			:=	${CROSS_COMPILE}ld
17073c99d4eSJuan CastilloOC			:=	${CROSS_COMPILE}objcopy
17173c99d4eSJuan CastilloOD			:=	${CROSS_COMPILE}objdump
17273c99d4eSJuan CastilloNM			:=	${CROSS_COMPILE}nm
17373c99d4eSJuan CastilloPP			:=	${CROSS_COMPILE}gcc -E
17473c99d4eSJuan Castillo
17573c99d4eSJuan CastilloASFLAGS			+= 	-nostdinc -ffreestanding -Wa,--fatal-warnings	\
17673c99d4eSJuan Castillo				-Werror -Wmissing-include-dirs			\
17773c99d4eSJuan Castillo				-mgeneral-regs-only -D__ASSEMBLY__		\
17873c99d4eSJuan Castillo				${DEFINES} ${INCLUDES}
17973c99d4eSJuan CastilloCFLAGS			+= 	-nostdinc -ffreestanding -Wall			\
18073c99d4eSJuan Castillo				-Werror -Wmissing-include-dirs			\
181fa1d3712SJuan Castillo				-mgeneral-regs-only -mstrict-align		\
182fa1d3712SJuan Castillo				-std=c99 -c -Os					\
18373c99d4eSJuan Castillo				${DEFINES} ${INCLUDES}
18473c99d4eSJuan CastilloCFLAGS			+=	-ffunction-sections -fdata-sections
18573c99d4eSJuan Castillo
18673c99d4eSJuan CastilloLDFLAGS			+=	--fatal-warnings -O1
18773c99d4eSJuan CastilloLDFLAGS			+=	--gc-sections
18873c99d4eSJuan Castillo
18973c99d4eSJuan Castillo
19073c99d4eSJuan Castillo################################################################################
19173c99d4eSJuan Castillo# Common sources and include directories
19273c99d4eSJuan Castillo################################################################################
19373c99d4eSJuan Castillo
19473c99d4eSJuan CastilloBL_COMMON_SOURCES	+=	common/bl_common.c			\
195b79af934SSoby Mathew				common/tf_printf.c			\
196626ed510SSoby Mathew				common/aarch64/debug.S			\
197bee82417SDan Handley				lib/aarch64/cache_helpers.S		\
198bee82417SDan Handley				lib/aarch64/misc_helpers.S		\
199bee82417SDan Handley				lib/aarch64/xlat_helpers.c		\
200*191a0088SAntonio Nino Diaz				lib/stdlib/abort.c			\
201*191a0088SAntonio Nino Diaz				lib/stdlib/assert.c			\
202*191a0088SAntonio Nino Diaz				lib/stdlib/exit.c			\
203*191a0088SAntonio Nino Diaz				lib/stdlib/mem.c			\
204*191a0088SAntonio Nino Diaz				lib/stdlib/printf.c			\
205*191a0088SAntonio Nino Diaz				lib/stdlib/putchar.c			\
206*191a0088SAntonio Nino Diaz				lib/stdlib/puts.c			\
207*191a0088SAntonio Nino Diaz				lib/stdlib/sscanf.c			\
208*191a0088SAntonio Nino Diaz				lib/stdlib/strchr.c			\
209*191a0088SAntonio Nino Diaz				lib/stdlib/strcmp.c			\
210*191a0088SAntonio Nino Diaz				lib/stdlib/strlen.c			\
211*191a0088SAntonio Nino Diaz				lib/stdlib/strncmp.c			\
212*191a0088SAntonio Nino Diaz				lib/stdlib/subr_prf.c			\
213bee82417SDan Handley				plat/common/aarch64/platform_helpers.S
214d7a6b0f8SRyan Harkin
21548bfb88eSYatharth KocharINCLUDES		+=	-Iinclude/bl1			\
21648bfb88eSYatharth Kochar				-Iinclude/bl31			\
2174ecca339SDan Handley				-Iinclude/bl31/services		\
2184ecca339SDan Handley				-Iinclude/common		\
2194ecca339SDan Handley				-Iinclude/drivers		\
2204ecca339SDan Handley				-Iinclude/drivers/arm		\
2211779ba6bSJuan Castillo				-Iinclude/drivers/auth		\
222935db693SDan Handley				-Iinclude/drivers/io		\
223c13b2e32SVarun Wadekar				-Iinclude/drivers/ti/uart	\
2244ecca339SDan Handley				-Iinclude/lib			\
2254ecca339SDan Handley				-Iinclude/lib/aarch64		\
226add40351SSoby Mathew				-Iinclude/lib/cpus/aarch64	\
2275f0cdb05SDan Handley				-Iinclude/plat/common		\
228d7a6b0f8SRyan Harkin				-Iinclude/stdlib		\
229d7a6b0f8SRyan Harkin				-Iinclude/stdlib/sys		\
230375f538aSAchin Gupta				${PLAT_INCLUDES}		\
231375f538aSAchin Gupta				${SPD_INCLUDES}
2324f6ad66aSAchin Gupta
23373c99d4eSJuan Castillo
23473c99d4eSJuan Castillo################################################################################
23573c99d4eSJuan Castillo# Generic definitions
23673c99d4eSJuan Castillo################################################################################
23773c99d4eSJuan Castillo
23873c99d4eSJuan CastilloBUILD_BASE		:=	./build
23973c99d4eSJuan CastilloBUILD_PLAT		:=	${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
24073c99d4eSJuan Castillo
24173c99d4eSJuan CastilloPLAT_MAKEFILE		:=	platform.mk
24273c99d4eSJuan Castillo# Generate the platforms list by recursively searching for all directories
24373c99d4eSJuan Castillo# under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
24473c99d4eSJuan Castillo# char and strip out the final '|'.
24573c99d4eSJuan CastilloPLATFORMS		:=	$(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 |			\
24673c99d4eSJuan Castillo					sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' |	\
24773c99d4eSJuan Castillo					sed -r 's/\|$$//')
24873c99d4eSJuan CastilloSPDS			:=	$(shell ls -I none services/spd)
24973c99d4eSJuan Castillo
25073c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value
25173c99d4eSJuan CastilloINCLUDE_TBBR_MK		:=	1
25273c99d4eSJuan Castillo
25373c99d4eSJuan Castillo
25473c99d4eSJuan Castillo################################################################################
25573c99d4eSJuan Castillo# Include SPD Makefile if one has been specified
25673c99d4eSJuan Castillo################################################################################
25773c99d4eSJuan Castillo
25873c99d4eSJuan Castilloifneq (${SPD},none)
2594c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
2604c117f6cSSandrine Bailleux        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
2614c117f6cSSandrine Bailleux        $(warning "The SPD and its BL32 companion will be present but ignored.")
2624c117f6cSSandrine Bailleuxendif
26373c99d4eSJuan Castillo        # We expect to locate an spd.mk under the specified SPD directory
26473c99d4eSJuan Castillo        SPD_MAKE	:=	$(shell m="services/spd/${SPD}/${SPD}.mk"; [ -f "$$m" ] && echo "$$m")
26573c99d4eSJuan Castillo
26673c99d4eSJuan Castillo        ifeq (${SPD_MAKE},)
26773c99d4eSJuan Castillo                $(error Error: No services/spd/${SPD}/${SPD}.mk located)
26873c99d4eSJuan Castillo        endif
26973c99d4eSJuan Castillo        $(info Including ${SPD_MAKE})
27073c99d4eSJuan Castillo        include ${SPD_MAKE}
27173c99d4eSJuan Castillo
27270d1fc53SJuan Castillo        # If there's BL32 companion for the chosen SPD, we expect that the SPD's
27370d1fc53SJuan Castillo        # Makefile would set NEED_BL32 to "yes". In this case, the build system
27470d1fc53SJuan Castillo        # supports two mutually exclusive options:
27570d1fc53SJuan Castillo        # * BL32 is built from source: then BL32_SOURCES must contain the list
27670d1fc53SJuan Castillo        #   of source files to build BL32
27770d1fc53SJuan Castillo        # * BL32 is a prebuilt binary: then BL32 must point to the image file
27870d1fc53SJuan Castillo        #   that will be included in the FIP
27970d1fc53SJuan Castillo        # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
28070d1fc53SJuan Castillo        # over the sources.
281e35c4045SJeenu Viswambharanendif
282e35c4045SJeenu Viswambharan
283c04d2606SDan Handley
28473c99d4eSJuan Castillo################################################################################
28573c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform
28673c99d4eSJuan Castillo# makefile may use all previous definitions in this file)
28773c99d4eSJuan Castillo################################################################################
2882da8d8bfSJeenu Viswambharan
28973c99d4eSJuan Castilloifeq (${PLAT},)
29073c99d4eSJuan Castillo        $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
29173c99d4eSJuan Castilloendif
29273c99d4eSJuan CastilloPLAT_MAKEFILE_FULL	:=	$(shell find plat/ -wholename '*/${PLAT}/${PLAT_MAKEFILE}')
29373c99d4eSJuan Castilloifeq ($(PLAT_MAKEFILE_FULL),)
29473c99d4eSJuan Castillo        $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
29573c99d4eSJuan Castilloendif
296dbad1bacSVikram Kanigiri
29773c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL}
2980f21c547SJuan Castillo
29993271a1eSAchin Gupta# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default
30093271a1eSAchin Guptaifndef ENABLE_PLAT_COMPAT
30193271a1eSAchin GuptaENABLE_PLAT_COMPAT := 1
30293271a1eSAchin Guptaendif
30393271a1eSAchin Gupta
30493271a1eSAchin Gupta# Include the platform compatibility helpers for PSCI
30593271a1eSAchin Guptaifneq (${ENABLE_PLAT_COMPAT}, 0)
30693271a1eSAchin Guptainclude plat/compat/plat_compat.mk
30793271a1eSAchin Guptaendif
30893271a1eSAchin Gupta
30954035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default
31054035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations.
31154035fc4SSandrine Bailleux# This can be overridden by the platform.
31273c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk
3134f6ad66aSAchin Gupta
3144f6ad66aSAchin Gupta
31573c99d4eSJuan Castillo################################################################################
31673c99d4eSJuan Castillo# Process platform overrideable behaviour
31773c99d4eSJuan Castillo################################################################################
3184f6ad66aSAchin Gupta
31973c99d4eSJuan Castillo# Check if -pedantic option should be used
32073c99d4eSJuan Castilloifeq (${DISABLE_PEDANTIC},0)
32173c99d4eSJuan Castillo        CFLAGS		+= 	-pedantic
32273c99d4eSJuan Castilloendif
323f58ad36fSHarry Liebel
3241645d3eeSSandrine Bailleux# Using the ARM Trusted Firmware BL2 implies that a BL33 image also needs to be
32573c99d4eSJuan Castillo# supplied for the FIP and Certificate generation tools. This flag can be
32673c99d4eSJuan Castillo# overridden by the platform.
32773c99d4eSJuan Castilloifdef BL2_SOURCES
3284c117f6cSSandrine Bailleuxifndef EL3_PAYLOAD_BASE
32973c99d4eSJuan CastilloNEED_BL33		?=	yes
3304c117f6cSSandrine Bailleuxelse
3314c117f6cSSandrine Bailleux# The BL33 image is not needed when booting an EL3 payload.
3324c117f6cSSandrine BailleuxNEED_BL33		:=	no
3334c117f6cSSandrine Bailleuxendif
33473c99d4eSJuan Castilloendif
3356f971622SJuan Castillo
33673c99d4eSJuan Castillo# Process TBB related flags
3376f971622SJuan Castilloifneq (${GENERATE_COT},0)
33873c99d4eSJuan Castillo        # Common cert_create options
3396f971622SJuan Castillo        ifneq (${CREATE_KEYS},0)
3406f971622SJuan Castillo                $(eval CRT_ARGS += -n)
3410191262dSYatharth Kochar                $(eval FWU_CRT_ARGS += -n)
342fd34e7baSJuan Castillo                ifneq (${SAVE_KEYS},0)
343fd34e7baSJuan Castillo                        $(eval CRT_ARGS += -k)
3440191262dSYatharth Kochar                        $(eval FWU_CRT_ARGS += -k)
345fd34e7baSJuan Castillo                endif
3466f971622SJuan Castillo        endif
34773c99d4eSJuan Castillo        # Include TBBR makefile (unless the platform indicates otherwise)
34873c99d4eSJuan Castillo        ifeq (${INCLUDE_TBBR_MK},1)
34973c99d4eSJuan Castillo                include make_helpers/tbbr/tbbr_tools.mk
35073c99d4eSJuan Castillo        endif
3516f971622SJuan Castilloendif
3526f971622SJuan Castillo
35373c99d4eSJuan Castillo
35473c99d4eSJuan Castillo################################################################################
35573c99d4eSJuan Castillo# Auxiliary tools (fip_create, cert_create, etc)
35673c99d4eSJuan Castillo################################################################################
35773c99d4eSJuan Castillo
35873c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool
35973c99d4eSJuan CastilloCRTTOOLPATH		?=	tools/cert_create
36073c99d4eSJuan CastilloCRTTOOL			?=	${CRTTOOLPATH}/cert_create
36173c99d4eSJuan Castillo
36273c99d4eSJuan Castillo# Variables for use with Firmware Image Package
36373c99d4eSJuan CastilloFIPTOOLPATH		?=	tools/fip_create
36473c99d4eSJuan CastilloFIPTOOL			?=	${FIPTOOLPATH}/fip_create
36573c99d4eSJuan Castillo
36673c99d4eSJuan Castillo
36773c99d4eSJuan Castillo################################################################################
36873c99d4eSJuan Castillo# Build options checks
36973c99d4eSJuan Castillo################################################################################
37073c99d4eSJuan Castillo
37173c99d4eSJuan Castillo$(eval $(call assert_boolean,DEBUG))
37273c99d4eSJuan Castillo$(eval $(call assert_boolean,NS_TIMER_SWITCH))
37373c99d4eSJuan Castillo$(eval $(call assert_boolean,RESET_TO_BL31))
37473c99d4eSJuan Castillo$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
37573c99d4eSJuan Castillo$(eval $(call assert_boolean,ASM_ASSERTION))
37673c99d4eSJuan Castillo$(eval $(call assert_boolean,USE_COHERENT_MEM))
37773c99d4eSJuan Castillo$(eval $(call assert_boolean,DISABLE_PEDANTIC))
37873c99d4eSJuan Castillo$(eval $(call assert_boolean,GENERATE_COT))
37973c99d4eSJuan Castillo$(eval $(call assert_boolean,CREATE_KEYS))
38073c99d4eSJuan Castillo$(eval $(call assert_boolean,SAVE_KEYS))
38173c99d4eSJuan Castillo$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
38273c99d4eSJuan Castillo$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS))
383a9bec67dSSandrine Bailleux$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU))
38473c99d4eSJuan Castillo$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID))
3857a24cba5SSoby Mathew$(eval $(call assert_boolean,ERROR_DEPRECATED))
38693271a1eSAchin Gupta$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
38735e8c766SSandrine Bailleux$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT))
38812f654b6SJuan Castillo$(eval $(call assert_boolean,PL011_GENERIC_UART))
38973c99d4eSJuan Castillo
39073c99d4eSJuan Castillo
39173c99d4eSJuan Castillo################################################################################
39273c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options.
39373c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the
39473c99d4eSJuan Castillo# platform to overwrite the default options
39573c99d4eSJuan Castillo################################################################################
39673c99d4eSJuan Castillo
39773c99d4eSJuan Castillo$(eval $(call add_define,PLAT_${PLAT}))
39873c99d4eSJuan Castillo$(eval $(call add_define,NS_TIMER_SWITCH))
39973c99d4eSJuan Castillo$(eval $(call add_define,RESET_TO_BL31))
40073c99d4eSJuan Castillo$(eval $(call add_define,CTX_INCLUDE_FPREGS))
40173c99d4eSJuan Castillo$(eval $(call add_define,ARM_GIC_ARCH))
40273c99d4eSJuan Castillo$(eval $(call add_define,ARM_CCI_PRODUCT_ID))
40373c99d4eSJuan Castillo$(eval $(call add_define,ASM_ASSERTION))
40473c99d4eSJuan Castillo$(eval $(call add_define,LOG_LEVEL))
40573c99d4eSJuan Castillo$(eval $(call add_define,USE_COHERENT_MEM))
40673c99d4eSJuan Castillo$(eval $(call add_define,TRUSTED_BOARD_BOOT))
40773c99d4eSJuan Castillo$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS))
408a9bec67dSSandrine Bailleux$(eval $(call add_define,COLD_BOOT_SINGLE_CPU))
40973c99d4eSJuan Castillo$(eval $(call add_define,PSCI_EXTENDED_STATE_ID))
4107a24cba5SSoby Mathew$(eval $(call add_define,ERROR_DEPRECATED))
41193271a1eSAchin Gupta$(eval $(call add_define,ENABLE_PLAT_COMPAT))
41235e8c766SSandrine Bailleux$(eval $(call add_define,SPIN_ON_BL1_EXIT))
4134c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided.
4144c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE
4154c117f6cSSandrine Bailleux$(eval $(call add_define,EL3_PAYLOAD_BASE))
4164c117f6cSSandrine Bailleuxendif
41712f654b6SJuan Castillo$(eval $(call add_define,PL011_GENERIC_UART))
41873c99d4eSJuan Castillo
41973c99d4eSJuan Castillo
42073c99d4eSJuan Castillo################################################################################
42173c99d4eSJuan Castillo# Include BL specific makefiles
42273c99d4eSJuan Castillo################################################################################
42373c99d4eSJuan Castillo
42473c99d4eSJuan Castilloifdef BL1_SOURCES
42573c99d4eSJuan CastilloNEED_BL1 := yes
42673c99d4eSJuan Castilloinclude bl1/bl1.mk
42773c99d4eSJuan Castilloendif
42873c99d4eSJuan Castillo
42973c99d4eSJuan Castilloifdef BL2_SOURCES
43073c99d4eSJuan CastilloNEED_BL2 := yes
43173c99d4eSJuan Castilloinclude bl2/bl2.mk
43273c99d4eSJuan Castilloendif
43373c99d4eSJuan Castillo
4349003fa0bSYatharth Kocharifdef BL2U_SOURCES
4359003fa0bSYatharth KocharNEED_BL2U := yes
4369003fa0bSYatharth Kocharinclude bl2u/bl2u.mk
4379003fa0bSYatharth Kocharendif
4389003fa0bSYatharth Kochar
43973c99d4eSJuan Castilloifdef BL31_SOURCES
4404c117f6cSSandrine Bailleux# When booting an EL3 payload, there is no need to compile the BL31 image nor
4414c117f6cSSandrine Bailleux# put it in the FIP.
4424c117f6cSSandrine Bailleuxifndef EL3_PAYLOAD_BASE
44373c99d4eSJuan CastilloNEED_BL31 := yes
44473c99d4eSJuan Castilloinclude bl31/bl31.mk
44573c99d4eSJuan Castilloendif
4464c117f6cSSandrine Bailleuxendif
44773c99d4eSJuan Castillo
44873c99d4eSJuan Castillo
44973c99d4eSJuan Castillo################################################################################
45073c99d4eSJuan Castillo# Build targets
45173c99d4eSJuan Castillo################################################################################
45273c99d4eSJuan Castillo
4530191262dSYatharth Kochar.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool
45473c99d4eSJuan Castillo.SUFFIXES:
45573c99d4eSJuan Castillo
45673c99d4eSJuan Castilloall: msg_start
45773c99d4eSJuan Castillo
45873c99d4eSJuan Castillomsg_start:
45973c99d4eSJuan Castillo	@echo "Building ${PLAT}"
46073c99d4eSJuan Castillo
4617a24cba5SSoby Mathew# Check if deprecated declarations should be treated as error or not.
4627a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0)
4637a24cba5SSoby Mathew    CFLAGS		+= 	-Wno-error=deprecated-declarations
4647a24cba5SSoby Mathewendif
4657a24cba5SSoby Mathew
46673c99d4eSJuan Castillo# Expand build macros for the different images
46773c99d4eSJuan Castilloifeq (${NEED_BL1},yes)
46873c99d4eSJuan Castillo$(eval $(call MAKE_BL,1))
46973c99d4eSJuan Castilloendif
47073c99d4eSJuan Castillo
47173c99d4eSJuan Castilloifeq (${NEED_BL2},yes)
4728f0617efSJuan Castillo$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},tb-fw)),\
4738f0617efSJuan Castillo	$(eval $(call MAKE_BL,2,tb-fw)))
47473c99d4eSJuan Castilloendif
47573c99d4eSJuan Castillo
47673c99d4eSJuan Castilloifeq (${NEED_BL31},yes)
47773c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES}
4788f0617efSJuan Castillo$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},soc-fw)),\
4798f0617efSJuan Castillo	$(eval $(call MAKE_BL,31,soc-fw)))
48073c99d4eSJuan Castilloendif
48173c99d4eSJuan Castillo
48270d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
48370d1fc53SJuan Castillo# build system will call FIP_ADD_IMG to print a warning message and abort the
48470d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only.
48573c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
4868f0617efSJuan Castillo$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},tos-fw)),\
4878f0617efSJuan Castillo	$(if ${BL32_SOURCES}, $(eval $(call MAKE_BL,32,tos-fw)),\
4888f0617efSJuan Castillo		$(eval $(call FIP_ADD_IMG,BL32,--tos-fw))))
48973c99d4eSJuan Castilloendif
49073c99d4eSJuan Castillo
49173c99d4eSJuan Castillo# Add the BL33 image if required by the platform
49273c99d4eSJuan Castilloifeq (${NEED_BL33},yes)
4938f0617efSJuan Castillo$(eval $(call FIP_ADD_IMG,BL33,--nt-fw))
494db6071c9SJuan Castilloendif
495db6071c9SJuan Castillo
4969003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes)
4979003fa0bSYatharth KocharBL2U_PATH	:= $(if ${BL2U},${BL2U},$(call IMG_BIN,2u))
4989003fa0bSYatharth Kochar$(if ${BL2U}, ,$(eval $(call MAKE_BL,2u)))
4998f0617efSJuan Castillo$(eval $(call FWU_FIP_ADD_PAYLOAD,${BL2U_PATH},--ap-fwu-cfg))
5009003fa0bSYatharth Kocharendif
5019003fa0bSYatharth Kochar
50236eaaf37SIan Spraylocate-checkpatch:
50336eaaf37SIan Sprayifndef CHECKPATCH
50436eaaf37SIan Spray	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
50536eaaf37SIan Sprayelse
50636eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
50736eaaf37SIan Spray	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
50836eaaf37SIan Sprayendif
50936eaaf37SIan Sprayendif
51036eaaf37SIan Spray
5114f6ad66aSAchin Guptaclean:
5124f6ad66aSAchin Gupta	@echo "  CLEAN"
51325cff83eSRyan Harkin	${Q}rm -rf ${BUILD_PLAT}
5142f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
5156f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
5164f6ad66aSAchin Gupta
517eaaeece2SJames Morrisseyrealclean distclean:
518eaaeece2SJames Morrissey	@echo "  REALCLEAN"
519eaaeece2SJames Morrissey	${Q}rm -rf ${BUILD_BASE}
52035fab8c9SJoakim Bech	${Q}rm -f ${CURDIR}/cscope.*
5212f2cef46SJeenu Viswambharan	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
5226f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
5234f6ad66aSAchin Gupta
52436eaaf37SIan Spraycheckcodebase:		locate-checkpatch
52536eaaf37SIan Spray	@echo "  CHECKING STYLE"
52636eaaf37SIan Spray	@if test -d .git ; then	\
5274f2104ffSJuan Castillo		git ls-files | grep -v stdlib | while read GIT_FILE ; do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; done ;	\
52836eaaf37SIan Spray	 else			\
5294f2104ffSJuan Castillo		 find . -type f -not -iwholename "*.git*" -not -iwholename "*build*" -not -iwholename "*stdlib*" -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
53036eaaf37SIan Spray	 fi
53136eaaf37SIan Spray
53236eaaf37SIan Spraycheckpatch:		locate-checkpatch
53336eaaf37SIan Spray	@echo "  CHECKING STYLE"
534662109a5SSandrine Bailleux	${Q}git log -p ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} ${CHECKPATCH_ARGS} - || true
53536eaaf37SIan Spray
53673c99d4eSJuan Castillocerttool: ${CRTTOOL}
53773c99d4eSJuan Castillo
5386f971622SJuan Castillo.PHONY: ${CRTTOOL}
5396f971622SJuan Castillo${CRTTOOL}:
5406f971622SJuan Castillo	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH}
5416f971622SJuan Castillo	@echo
5426f971622SJuan Castillo	@echo "Built $@ successfully"
5436f971622SJuan Castillo	@echo
5446f971622SJuan Castillo
5456f971622SJuan Castilloifneq (${GENERATE_COT},0)
54673c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL}
5476f971622SJuan Castillo	${Q}${CRTTOOL} ${CRT_ARGS}
5486f971622SJuan Castillo	@echo
5496f971622SJuan Castillo	@echo "Built $@ successfully"
5506f971622SJuan Castillo	@echo "Certificates can be found in ${BUILD_PLAT}"
5516f971622SJuan Castillo	@echo
55273c99d4eSJuan Castilloendif
55327713fb4SSoby Mathew
55473c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
55573c99d4eSJuan Castillo	${Q}${FIPTOOL} --dump ${FIP_ARGS} $@
556f58ad36fSHarry Liebel	@echo
5572f2cef46SJeenu Viswambharan	@echo "Built $@ successfully"
5582f2cef46SJeenu Viswambharan	@echo
559f58ad36fSHarry Liebel
5600191262dSYatharth Kocharifneq (${GENERATE_COT},0)
5610191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
5620191262dSYatharth Kochar	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
5630191262dSYatharth Kochar	@echo
5640191262dSYatharth Kochar	@echo "Built $@ successfully"
5650191262dSYatharth Kochar	@echo "FWU certificates can be found in ${BUILD_PLAT}"
5660191262dSYatharth Kochar	@echo
5670191262dSYatharth Kocharendif
5680191262dSYatharth Kochar
5690191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
5700191262dSYatharth Kochar	${Q}${FIPTOOL} --dump ${FWU_FIP_ARGS} $@
5710191262dSYatharth Kochar	@echo
5720191262dSYatharth Kochar	@echo "Built $@ successfully"
5730191262dSYatharth Kochar	@echo
5740191262dSYatharth Kochar
57573c99d4eSJuan Castillofiptool: ${FIPTOOL}
57673c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME}
5770191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
57873c99d4eSJuan Castillo
57973c99d4eSJuan Castillo.PHONY: ${FIPTOOL}
58073c99d4eSJuan Castillo${FIPTOOL}:
58173c99d4eSJuan Castillo	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH}
582f58ad36fSHarry Liebel
58335fab8c9SJoakim Bechcscope:
58435fab8c9SJoakim Bech	@echo "  CSCOPE"
58535fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
58635fab8c9SJoakim Bech	${Q}cscope -b -q -k
58735fab8c9SJoakim Bech
58872ee3314SRyan Harkinhelp:
589c04d2606SDan Handley	@echo "usage: ${MAKE} PLAT=<${PLATFORMS}> [OPTIONS] [TARGET]"
59072ee3314SRyan Harkin	@echo ""
59172ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
59208c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
59372ee3314SRyan Harkin	@echo ""
5941b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
5951b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
5961b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
5971b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
5981b578596SSandrine Bailleux	@echo ""
59972ee3314SRyan Harkin	@echo "Supported Targets:"
6001b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
60136eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
6028aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
6039003fa0bSYatharth Kochar	@echo "  bl2u           Build the BL2U binary"
604d178637dSJuan Castillo	@echo "  bl31           Build the BL31 binary"
605d178637dSJuan Castillo	@echo "  bl32           Build the BL32 binary"
60673c99d4eSJuan Castillo	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
6071b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
6080191262dSYatharth Kochar	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
60936eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
61036eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
61136eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
61272ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
61335fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
61472ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
6156f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
616f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package(FIP) creation tool"
61772ee3314SRyan Harkin	@echo ""
6181b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
61972ee3314SRyan Harkin	@echo ""
62072ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
62172ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
622