xref: /rk3399_ARM-atf/Makefile (revision 5c8babcd70149db57734a38be432fe6625f3888f)
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
37aaa3e722SJuan Castillo#
38e35c4045SJeenu Viswambharan# Default values for build configurations
39e35c4045SJeenu Viswambharan#
40e35c4045SJeenu Viswambharan
41e35c4045SJeenu Viswambharan# Build verbosity
42e35c4045SJeenu ViswambharanV			:= 0
43e35c4045SJeenu Viswambharan# Debug build
44e35c4045SJeenu ViswambharanDEBUG			:= 0
45e35c4045SJeenu Viswambharan# Build platform
46e35c4045SJeenu ViswambharanDEFAULT_PLAT		:= fvp
47e35c4045SJeenu ViswambharanPLAT			:= ${DEFAULT_PLAT}
48e35c4045SJeenu Viswambharan# SPD choice
49e35c4045SJeenu ViswambharanSPD			:= none
50e35c4045SJeenu Viswambharan# Base commit to perform code check on
51e35c4045SJeenu ViswambharanBASE_COMMIT		:= origin/master
522da8d8bfSJeenu Viswambharan# NS timer register save and restore
532da8d8bfSJeenu ViswambharanNS_TIMER_SWITCH		:= 0
54dbad1bacSVikram Kanigiri# By default, Bl1 acts as the reset handler, not BL31
55dbad1bacSVikram KanigiriRESET_TO_BL31		:= 0
560f21c547SJuan Castillo# Include FP registers in cpu context
570f21c547SJuan CastilloCTX_INCLUDE_FPREGS		:= 0
582b98e789SSandrine Bailleux# Determine the version of ARM GIC architecture to use for interrupt management
592b98e789SSandrine Bailleux# in EL3. The platform port can change this value if needed.
602b98e789SSandrine BailleuxARM_GIC_ARCH		:=	2
6123e47edeSVikram Kanigiri# Determine the version of ARM CCI product used in the platform. The platform
6223e47edeSVikram Kanigiri# port can change this value if needed.
6323e47edeSVikram KanigiriARM_CCI_PRODUCT_ID	:=	400
64bc920128SSoby Mathew# Flag used to indicate if ASM_ASSERTION should be enabled for the build.
65bc920128SSoby Mathew# This defaults to being present in DEBUG builds only.
66bc920128SSoby MathewASM_ASSERTION		:=	${DEBUG}
678c5fe0b5SSoby Mathew# Build option to choose whether Trusted firmware uses Coherent memory or not.
688c5fe0b5SSoby MathewUSE_COHERENT_MEM	:=	1
698ee24980SSoby Mathew# Flag used to choose the power state format viz Extended State-ID or the Original
708ee24980SSoby Mathew# format.
718ee24980SSoby MathewPSCI_EXTENDED_STATE_ID	:=	0
727f48fab9SJuan Castillo# Default FIP file name
737f48fab9SJuan CastilloFIP_NAME		:= fip.bin
74db6071c9SJuan Castillo# By default, use the -pedantic option in the gcc command line
75db6071c9SJuan CastilloDISABLE_PEDANTIC	:= 0
766f971622SJuan Castillo# Flags to generate the Chain of Trust
776f971622SJuan CastilloGENERATE_COT		:= 0
786f971622SJuan CastilloCREATE_KEYS		:= 1
79fd34e7baSJuan CastilloSAVE_KEYS		:= 0
806eadf762SJuan Castillo# Flags to build TF with Trusted Boot support
816eadf762SJuan CastilloTRUSTED_BOARD_BOOT	:= 0
82bf031bbaSSandrine Bailleux# By default, consider that the platform's reset address is not programmable.
83bf031bbaSSandrine Bailleux# The platform Makefile is free to override this value.
84bf031bbaSSandrine BailleuxPROGRAMMABLE_RESET_ADDRESS	:= 0
85*5c8babcdSSoby Mathew# Build flag to warn about usage of deprecated platform and framework APIs
86*5c8babcdSSoby MathewWARN_DEPRECATED	:= 0
874f6ad66aSAchin Gupta
887421b465SAchin Gupta# Checkpatch ignores
899b4ee6b3SJuan CastilloCHECK_IGNORE		=	--ignore COMPLEX_MACRO \
909b4ee6b3SJuan Castillo				--ignore GERRIT_CHANGE_ID \
919b4ee6b3SJuan Castillo				--ignore GIT_COMMIT_ID
927421b465SAchin Gupta
937421b465SAchin GuptaCHECKPATCH_ARGS		=	--no-tree --no-signoff ${CHECK_IGNORE}
947421b465SAchin GuptaCHECKCODE_ARGS		=	--no-patch --no-tree --no-signoff ${CHECK_IGNORE}
9595d5353cSSandrine Bailleux# Do not check the coding style on C library files
96662109a5SSandrine BailleuxCHECK_PATHS		=	$(shell ls -I include -I lib) \
97662109a5SSandrine Bailleux				$(addprefix include/,$(shell ls -I stdlib include)) \
98662109a5SSandrine Bailleux				$(addprefix lib/,$(shell ls -I stdlib lib))
9936eaaf37SIan Spray
100e35c4045SJeenu Viswambharanifeq (${V},0)
1014f6ad66aSAchin Gupta	Q=@
10236eaaf37SIan Spray	CHECKCODE_ARGS	+=	--no-summary --terse
1034f6ad66aSAchin Guptaelse
1044f6ad66aSAchin Gupta	Q=
1054f6ad66aSAchin Guptaendif
1062f2cef46SJeenu Viswambharanexport Q
1072f2cef46SJeenu Viswambharan
108eaaeece2SJames Morrisseyifneq (${DEBUG}, 0)
109eaaeece2SJames Morrissey	BUILD_TYPE	:=	debug
110289c28a8SDan Handley	# Use LOG_LEVEL_INFO by default for debug builds
111289c28a8SDan Handley	LOG_LEVEL	:=	40
112eaaeece2SJames Morrisseyelse
113eaaeece2SJames Morrissey	BUILD_TYPE	:=	release
114289c28a8SDan Handley	# Use LOG_LEVEL_NOTICE by default for release builds
115289c28a8SDan Handley	LOG_LEVEL	:=	20
116eaaeece2SJames Morrisseyendif
117eaaeece2SJames Morrissey
118aaa3e722SJuan Castillo# Default build string (git branch and commit)
119aaa3e722SJuan Castilloifeq (${BUILD_STRING},)
120aaa3e722SJuan Castillo	BUILD_STRING	:=	$(shell git log -n 1 --pretty=format:"%h")
121aaa3e722SJuan Castilloendif
122aaa3e722SJuan Castillo
123aaa3e722SJuan CastilloVERSION_STRING		:=	v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
124aaa3e722SJuan Castillo
125bee82417SDan HandleyBL_COMMON_SOURCES	:=	common/bl_common.c			\
126b79af934SSoby Mathew				common/tf_printf.c			\
127626ed510SSoby Mathew				common/aarch64/debug.S			\
128bee82417SDan Handley				lib/aarch64/cache_helpers.S		\
129bee82417SDan Handley				lib/aarch64/misc_helpers.S		\
130bee82417SDan Handley				lib/aarch64/xlat_helpers.c		\
131bee82417SDan Handley				lib/stdlib/std.c			\
132bee82417SDan Handley				plat/common/aarch64/platform_helpers.S
133d7a6b0f8SRyan Harkin
134eaaeece2SJames MorrisseyBUILD_BASE		:=	./build
13525cff83eSRyan HarkinBUILD_PLAT		:=	${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
1364f6ad66aSAchin Gupta
137c04d2606SDan HandleyPLAT_MAKEFILE		:=	platform.mk
138c04d2606SDan Handley# Generate the platforms list by recursively searching for all directories
139c04d2606SDan Handley# under /plat containing a PLAT_MAKEFILE. Append each platform with a `|`
140c04d2606SDan Handley# char and strip out the final '|'.
141c04d2606SDan HandleyPLATFORMS		:=	$(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 |			\
142c04d2606SDan Handley					sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' |	\
143c04d2606SDan Handley					sed -r 's/\|$$//')
144375f538aSAchin GuptaSPDS			:=	$(shell ls -I none services/spd)
14572ee3314SRyan Harkin
146289e0dadSJeenu Viswambharan# Convenience function for adding build definitions
147289e0dadSJeenu Viswambharan# $(eval $(call add_define,FOO)) will have:
148289e0dadSJeenu Viswambharan# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
149289e0dadSJeenu Viswambharandefine add_define
150289e0dadSJeenu ViswambharanDEFINES			+=	-D$(1)$(if $(value $(1)),=$(value $(1)),)
151289e0dadSJeenu Viswambharanendef
152289e0dadSJeenu Viswambharan
153289e0dadSJeenu Viswambharan# Convenience function for verifying option has a boolean value
154289e0dadSJeenu Viswambharan# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1
155289e0dadSJeenu Viswambharandefine assert_boolean
156289e0dadSJeenu Viswambharan$(and $(patsubst 0,,$(value $(1))),$(patsubst 1,,$(value $(1))),$(error $(1) must be boolean))
157289e0dadSJeenu Viswambharanendef
158289e0dadSJeenu Viswambharan
15925cff83eSRyan Harkinifeq (${PLAT},)
160c04d2606SDan Handley  $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
16125cff83eSRyan Harkinendif
162c04d2606SDan HandleyPLAT_MAKEFILE_FULL	:=	$(shell find plat/ -wholename '*/${PLAT}/${PLAT_MAKEFILE}')
163c04d2606SDan Handleyifeq ($(PLAT_MAKEFILE_FULL),)
16425cff83eSRyan Harkin  $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
16525cff83eSRyan Harkinendif
1664f6ad66aSAchin Gupta
1674bfc2d21SJon Medhurstall: msg_start
16825cff83eSRyan Harkin
16925cff83eSRyan Harkinmsg_start:
17025cff83eSRyan Harkin	@echo "Building ${PLAT}"
17125cff83eSRyan Harkin
172c04d2606SDan Handleyinclude ${PLAT_MAKEFILE_FULL}
1734bfc2d21SJon Medhurst
17432bc85f2SSoby Mathew# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default
17532bc85f2SSoby Mathewifndef ENABLE_PLAT_COMPAT
17632bc85f2SSoby MathewENABLE_PLAT_COMPAT := 1
17732bc85f2SSoby Mathewendif
17832bc85f2SSoby Mathew
17932bc85f2SSoby Mathew# Include the platform compatibility helpers for PSCI
18032bc85f2SSoby Mathewifneq (${ENABLE_PLAT_COMPAT}, 0)
18132bc85f2SSoby Mathewinclude plat/compat/plat_compat.mk
18232bc85f2SSoby Mathewendif
18332bc85f2SSoby Mathew
1845541bb3fSSoby Mathew# Include the CPU specific operations makefile. By default all CPU errata
1855541bb3fSSoby Mathew# workarounds and CPU specifc optimisations are disabled. This can be
186d9bdaf2dSSoby Mathew# overridden by the platform.
1875541bb3fSSoby Mathewinclude lib/cpus/cpu-ops.mk
188d9bdaf2dSSoby Mathew
1894bfc2d21SJon Medhurstifdef BL1_SOURCES
1904bfc2d21SJon MedhurstNEED_BL1 := yes
1914f6ad66aSAchin Guptainclude bl1/bl1.mk
1924bfc2d21SJon Medhurstendif
1934bfc2d21SJon Medhurst
1944bfc2d21SJon Medhurstifdef BL2_SOURCES
1954bfc2d21SJon MedhurstNEED_BL2 := yes
1964f6ad66aSAchin Guptainclude bl2/bl2.mk
19727713fb4SSoby Mathew# Using the ARM Trusted Firmware BL2 implies that a BL3-3 image also need to be supplied for the FIP.
19827713fb4SSoby Mathew# This flag can be overridden by the platform.
19927713fb4SSoby MathewNEED_BL33 ?= yes
2004bfc2d21SJon Medhurstendif
2014bfc2d21SJon Medhurst
2024bfc2d21SJon Medhurstifdef BL31_SOURCES
2034bfc2d21SJon MedhurstNEED_BL31 := yes
2044f6ad66aSAchin Guptainclude bl31/bl31.mk
20525cff83eSRyan Harkinendif
2064f6ad66aSAchin Gupta
207375f538aSAchin Gupta# Include SPD Makefile if one has been specified
208375f538aSAchin Guptaifneq (${SPD},none)
209375f538aSAchin Gupta  # We expect to locate an spd.mk under the specified SPD directory
210375f538aSAchin Gupta  SPD_MAKE		:=	$(shell m="services/spd/${SPD}/${SPD}.mk"; [ -f "$$m" ] && echo "$$m")
211375f538aSAchin Gupta
212375f538aSAchin Gupta  ifeq (${SPD_MAKE},)
213375f538aSAchin Gupta    $(error Error: No services/spd/${SPD}/${SPD}.mk located)
214375f538aSAchin Gupta  endif
215375f538aSAchin Gupta  $(info Including ${SPD_MAKE})
216375f538aSAchin Gupta  include ${SPD_MAKE}
217375f538aSAchin Gupta
21827713fb4SSoby Mathew  # If there's BL3-2 companion for the chosen SPD, and the SPD wants to build the
21927713fb4SSoby Mathew  # BL3-2 from source, we expect that the SPD's Makefile would set NEED_BL32
22027713fb4SSoby Mathew  # variable to "yes". In case the BL3-2 is a binary which needs to be included in
22127713fb4SSoby Mathew  # fip, then the NEED_BL32 needs to be set and BL3-2 would need to point to the bin.
222375f538aSAchin Guptaendif
223375f538aSAchin Gupta
2246f971622SJuan Castillo.PHONY:			all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip certtool
225eaaeece2SJames Morrissey.SUFFIXES:
226eaaeece2SJames Morrissey
227a0df63efSSandrine BailleuxINCLUDES		+=	-Iinclude/bl31			\
2284ecca339SDan Handley				-Iinclude/bl31/services		\
2294ecca339SDan Handley				-Iinclude/common		\
2304ecca339SDan Handley				-Iinclude/drivers		\
2314ecca339SDan Handley				-Iinclude/drivers/arm		\
2321779ba6bSJuan Castillo				-Iinclude/drivers/auth		\
233935db693SDan Handley				-Iinclude/drivers/io		\
234c13b2e32SVarun Wadekar				-Iinclude/drivers/ti/uart	\
2354ecca339SDan Handley				-Iinclude/lib			\
2364ecca339SDan Handley				-Iinclude/lib/aarch64		\
237add40351SSoby Mathew				-Iinclude/lib/cpus/aarch64	\
2385f0cdb05SDan Handley				-Iinclude/plat/common		\
239d7a6b0f8SRyan Harkin				-Iinclude/stdlib		\
240d7a6b0f8SRyan Harkin				-Iinclude/stdlib/sys		\
241375f538aSAchin Gupta				${PLAT_INCLUDES}		\
242375f538aSAchin Gupta				${SPD_INCLUDES}
2434f6ad66aSAchin Gupta
244e35c4045SJeenu Viswambharan# Process DEBUG flag
245e35c4045SJeenu Viswambharan$(eval $(call assert_boolean,DEBUG))
246e35c4045SJeenu Viswambharan$(eval $(call add_define,DEBUG))
247e35c4045SJeenu Viswambharanifeq (${DEBUG},0)
248e35c4045SJeenu Viswambharan  $(eval $(call add_define,NDEBUG))
249e35c4045SJeenu Viswambharanelse
250e35c4045SJeenu ViswambharanCFLAGS			+= 	-g
251e35c4045SJeenu ViswambharanASFLAGS			+= 	-g -Wa,--gdwarf-2
252e35c4045SJeenu Viswambharanendif
253e35c4045SJeenu Viswambharan
254c04d2606SDan Handley# Process PLAT flag
255c04d2606SDan Handley$(eval $(call add_define,PLAT_${PLAT}))
256c04d2606SDan Handley
2572da8d8bfSJeenu Viswambharan# Process NS_TIMER_SWITCH flag
2582da8d8bfSJeenu Viswambharan$(eval $(call assert_boolean,NS_TIMER_SWITCH))
2592da8d8bfSJeenu Viswambharan$(eval $(call add_define,NS_TIMER_SWITCH))
2602da8d8bfSJeenu Viswambharan
261dbad1bacSVikram Kanigiri# Process RESET_TO_BL31 flag
262dbad1bacSVikram Kanigiri$(eval $(call assert_boolean,RESET_TO_BL31))
263dbad1bacSVikram Kanigiri$(eval $(call add_define,RESET_TO_BL31))
264dbad1bacSVikram Kanigiri
2650f21c547SJuan Castillo# Process CTX_INCLUDE_FPREGS flag
2660f21c547SJuan Castillo$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
2670f21c547SJuan Castillo$(eval $(call add_define,CTX_INCLUDE_FPREGS))
2680f21c547SJuan Castillo
2692b98e789SSandrine Bailleux# Process ARM_GIC_ARCH flag
2702b98e789SSandrine Bailleux$(eval $(call add_define,ARM_GIC_ARCH))
2712b98e789SSandrine Bailleux
27223e47edeSVikram Kanigiri# Process ARM_CCI_PRODUCT_ID flag
27323e47edeSVikram Kanigiri$(eval $(call add_define,ARM_CCI_PRODUCT_ID))
27423e47edeSVikram Kanigiri
275bc920128SSoby Mathew# Process ASM_ASSERTION flag
276bc920128SSoby Mathew$(eval $(call assert_boolean,ASM_ASSERTION))
277bc920128SSoby Mathew$(eval $(call add_define,ASM_ASSERTION))
2782b98e789SSandrine Bailleux
279289c28a8SDan Handley# Process LOG_LEVEL flag
280289c28a8SDan Handley$(eval $(call add_define,LOG_LEVEL))
281289c28a8SDan Handley
2828c5fe0b5SSoby Mathew# Process USE_COHERENT_MEM flag
2838c5fe0b5SSoby Mathew$(eval $(call assert_boolean,USE_COHERENT_MEM))
2848c5fe0b5SSoby Mathew$(eval $(call add_define,USE_COHERENT_MEM))
2858c5fe0b5SSoby Mathew
2868ee24980SSoby Mathew# Process PSCI_EXTENDED_STATE_ID flag
2878ee24980SSoby Mathew$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID))
2888ee24980SSoby Mathew$(eval $(call add_define,PSCI_EXTENDED_STATE_ID))
2898ee24980SSoby Mathew
2906f971622SJuan Castillo# Process Generate CoT flags
2916f971622SJuan Castillo$(eval $(call assert_boolean,GENERATE_COT))
2926f971622SJuan Castillo$(eval $(call assert_boolean,CREATE_KEYS))
293fd34e7baSJuan Castillo$(eval $(call assert_boolean,SAVE_KEYS))
2946f971622SJuan Castillo
2956eadf762SJuan Castillo# Process TRUSTED_BOARD_BOOT flag
2966eadf762SJuan Castillo$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
2976eadf762SJuan Castillo$(eval $(call add_define,TRUSTED_BOARD_BOOT))
2986eadf762SJuan Castillo
299bf031bbaSSandrine Bailleux# Process PROGRAMMABLE_RESET_ADDRESS flag
300bf031bbaSSandrine Bailleux$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS))
301bf031bbaSSandrine Bailleux$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS))
302bf031bbaSSandrine Bailleux
30332bc85f2SSoby Mathew# Process ENABLE_PLAT_COMPAT flag
30432bc85f2SSoby Mathew$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
30532bc85f2SSoby Mathew$(eval $(call add_define,ENABLE_PLAT_COMPAT))
30632bc85f2SSoby Mathew
307*5c8babcdSSoby Mathew# Process WARN_DEPRECATED flag
308*5c8babcdSSoby Mathew$(eval $(call assert_boolean,WARN_DEPRECATED))
309*5c8babcdSSoby Mathew$(eval $(call add_define,WARN_DEPRECATED))
310*5c8babcdSSoby Mathew
3110af6d64dSHarry LiebelASFLAGS			+= 	-nostdinc -ffreestanding -Wa,--fatal-warnings	\
312a0df63efSSandrine Bailleux				-Werror -Wmissing-include-dirs			\
313e35c4045SJeenu Viswambharan				-mgeneral-regs-only -D__ASSEMBLY__		\
314e35c4045SJeenu Viswambharan				${DEFINES} ${INCLUDES}
315db6071c9SJuan CastilloCFLAGS			+= 	-nostdinc -ffreestanding -Wall			\
316a0df63efSSandrine Bailleux				-Werror -Wmissing-include-dirs			\
317a0df63efSSandrine Bailleux				-mgeneral-regs-only -std=c99 -c -Os		\
318e35c4045SJeenu Viswambharan				${DEFINES} ${INCLUDES}
319dccc537aSAndrew ThoelkeCFLAGS			+=	-ffunction-sections -fdata-sections
3204f6ad66aSAchin Gupta
3213e850a84SSandrine BailleuxLDFLAGS			+=	--fatal-warnings -O1
322dccc537aSAndrew ThoelkeLDFLAGS			+=	--gc-sections
3234f6ad66aSAchin Gupta
3244f6ad66aSAchin Gupta
325eaaeece2SJames MorrisseyCC			:=	${CROSS_COMPILE}gcc
326eaaeece2SJames MorrisseyCPP			:=	${CROSS_COMPILE}cpp
327eaaeece2SJames MorrisseyAS			:=	${CROSS_COMPILE}gcc
328eaaeece2SJames MorrisseyAR			:=	${CROSS_COMPILE}ar
329eaaeece2SJames MorrisseyLD			:=	${CROSS_COMPILE}ld
330eaaeece2SJames MorrisseyOC			:=	${CROSS_COMPILE}objcopy
331eaaeece2SJames MorrisseyOD			:=	${CROSS_COMPILE}objdump
332eaaeece2SJames MorrisseyNM			:=	${CROSS_COMPILE}nm
333eaaeece2SJames MorrisseyPP			:=	${CROSS_COMPILE}gcc -E ${CFLAGS}
3344f6ad66aSAchin Gupta
335f58ad36fSHarry Liebel# Variables for use with Firmware Image Package
336f58ad36fSHarry LiebelFIPTOOLPATH		?=	tools/fip_create
337f58ad36fSHarry LiebelFIPTOOL			?=	${FIPTOOLPATH}/fip_create
338f58ad36fSHarry Liebelfiptool:		${FIPTOOL}
3397f48fab9SJuan Castillofip:			${BUILD_PLAT}/${FIP_NAME}
340f58ad36fSHarry Liebel
3416f971622SJuan Castillo# Variables for use with Certificate Generation Tool
3426f971622SJuan CastilloCRTTOOLPATH		?=	tools/cert_create
3436f971622SJuan CastilloCRTTOOL			?=	${CRTTOOLPATH}/cert_create
3446f971622SJuan Castillocerttool:		${CRTTOOL}
3456f971622SJuan Castillo
3466f971622SJuan Castillo# CoT generation tool default parameters
3476f971622SJuan CastilloTRUSTED_KEY_CERT	:=	${BUILD_PLAT}/trusted_key.crt
3486f971622SJuan Castillo
3496f971622SJuan Castillo# Pass the private keys to the CoT generation tool in the command line
3506f971622SJuan Castillo# If CREATE_KEYS is set, the '-n' option will be added, indicating the tool to create new keys
3516f971622SJuan Castilloifneq (${GENERATE_COT},0)
3526f971622SJuan Castillo    $(eval CERTS := yes)
3536f971622SJuan Castillo
354b7124ea7SJuan Castillo    $(eval FIP_DEPS += certificates)
355b7124ea7SJuan Castillo    $(eval FIP_ARGS += --trusted-key-cert ${TRUSTED_KEY_CERT})
356b7124ea7SJuan Castillo
3576f971622SJuan Castillo    ifneq (${CREATE_KEYS},0)
3586f971622SJuan Castillo        $(eval CRT_ARGS += -n)
359fd34e7baSJuan Castillo        ifneq (${SAVE_KEYS},0)
360fd34e7baSJuan Castillo            $(eval CRT_ARGS += -k)
361fd34e7baSJuan Castillo        endif
3626f971622SJuan Castillo    endif
3636f971622SJuan Castillo    $(eval CRT_ARGS += $(if ${ROT_KEY}, --rot-key ${ROT_KEY}))
3646f971622SJuan Castillo    $(eval CRT_ARGS += $(if ${TRUSTED_WORLD_KEY}, --trusted-world-key ${TRUSTED_WORLD_KEY}))
3656f971622SJuan Castillo    $(eval CRT_ARGS += $(if ${NON_TRUSTED_WORLD_KEY}, --non-trusted-world-key ${NON_TRUSTED_WORLD_KEY}))
3666f971622SJuan Castillo    $(eval CRT_ARGS += --trusted-key-cert ${TRUSTED_KEY_CERT})
367ccbf890eSJuan Castillo    $(eval CRT_ARGS += $(if ${KEY_ALG}, --key-alg ${KEY_ALG}))
3686f971622SJuan Castilloendif
3696f971622SJuan Castillo
370db6071c9SJuan Castillo# Check if -pedantic option should be used
371db6071c9SJuan Castilloifeq (${DISABLE_PEDANTIC},0)
372db6071c9SJuan Castillo    CFLAGS		+= 	-pedantic
373db6071c9SJuan Castilloendif
374db6071c9SJuan Castillo
37536eaaf37SIan Spraylocate-checkpatch:
37636eaaf37SIan Sprayifndef CHECKPATCH
37736eaaf37SIan Spray	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
37836eaaf37SIan Sprayelse
37936eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH}))
38036eaaf37SIan Spray	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
38136eaaf37SIan Sprayendif
38236eaaf37SIan Sprayendif
38336eaaf37SIan Spray
3844f6ad66aSAchin Guptaclean:
3854f6ad66aSAchin Gupta			@echo "  CLEAN"
38625cff83eSRyan Harkin			${Q}rm -rf ${BUILD_PLAT}
3872f2cef46SJeenu Viswambharan			${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
3886f971622SJuan Castillo			${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
3894f6ad66aSAchin Gupta
390eaaeece2SJames Morrisseyrealclean distclean:
391eaaeece2SJames Morrissey			@echo "  REALCLEAN"
392eaaeece2SJames Morrissey			${Q}rm -rf ${BUILD_BASE}
39335fab8c9SJoakim Bech			${Q}rm -f ${CURDIR}/cscope.*
3942f2cef46SJeenu Viswambharan			${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
3956f971622SJuan Castillo			${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
3964f6ad66aSAchin Gupta
39736eaaf37SIan Spraycheckcodebase:		locate-checkpatch
39836eaaf37SIan Spray			@echo "  CHECKING STYLE"
39936eaaf37SIan Spray			@if test -d .git ; then	\
4004f2104ffSJuan Castillo				git ls-files | grep -v stdlib | while read GIT_FILE ; do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; done ;	\
40136eaaf37SIan Spray			 else			\
4024f2104ffSJuan Castillo				 find . -type f -not -iwholename "*.git*" -not -iwholename "*build*" -not -iwholename "*stdlib*" -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
40336eaaf37SIan Spray			 fi
40436eaaf37SIan Spray
40536eaaf37SIan Spraycheckpatch:		locate-checkpatch
40636eaaf37SIan Spray			@echo "  CHECKING STYLE"
407662109a5SSandrine Bailleux			${Q}git log -p ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} ${CHECKPATCH_ARGS} - || true
40836eaaf37SIan Spray
4096f971622SJuan Castillo.PHONY: ${CRTTOOL}
4106f971622SJuan Castillo${CRTTOOL}:
4116f971622SJuan Castillo			${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH}
4126f971622SJuan Castillo			@echo
4136f971622SJuan Castillo			@echo "Built $@ successfully"
4146f971622SJuan Castillo			@echo
4156f971622SJuan Castillo
41607deed40SSandrine Bailleux.PHONY: ${FIPTOOL}
417f58ad36fSHarry Liebel${FIPTOOL}:
4182f2cef46SJeenu Viswambharan			${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH}
419f58ad36fSHarry Liebel
4206d55d109SJon Medhurstdefine match_goals
4216d55d109SJon Medhurst$(strip $(foreach goal,$(1),$(filter $(goal),$(MAKECMDGOALS))))
4226d55d109SJon Medhurstendef
423eaaeece2SJames Morrissey
4248d2296f3SSandrine Bailleux# List of rules that involve building things
4258d2296f3SSandrine BailleuxBUILD_TARGETS := all bl1 bl2 bl31 bl32 fip
426eaaeece2SJames Morrissey
4278d2296f3SSandrine Bailleux# Does the list of goals specified on the command line include a build target?
4288d2296f3SSandrine Bailleuxifneq ($(call match_goals,${BUILD_TARGETS}),)
4298d2296f3SSandrine BailleuxIS_ANYTHING_TO_BUILD := 1
4308d2296f3SSandrine Bailleuxendif
4314f6ad66aSAchin Gupta
4326d55d109SJon Medhurstdefine MAKE_C
433eaaeece2SJames Morrissey
4346d55d109SJon Medhurst$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
4356d55d109SJon Medhurst$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ)))
436eaaeece2SJames Morrissey
4376d55d109SJon Medhurst$(OBJ) : $(2)
4386d55d109SJon Medhurst	@echo "  CC      $$<"
43927905d0aSSoby Mathew	$$(Q)$$(CC) $$(CFLAGS) -DIMAGE_BL$(3) -c $$< -o $$@
440eaaeece2SJames Morrissey
4416d55d109SJon Medhurst
4426d55d109SJon Medhurst$(PREREQUISITES) : $(2)
4436d55d109SJon Medhurst	@echo "  DEPS    $$@"
4446d55d109SJon Medhurst	@mkdir -p $(1)
4456d55d109SJon Medhurst	$$(Q)$$(CC) $$(CFLAGS) -M -MT $(OBJ) -MF $$@ $$<
4466d55d109SJon Medhurst
4478d2296f3SSandrine Bailleuxifdef IS_ANYTHING_TO_BUILD
4486d55d109SJon Medhurst-include $(PREREQUISITES)
4496d55d109SJon Medhurstendif
4506d55d109SJon Medhurst
4516d55d109SJon Medhurstendef
4526d55d109SJon Medhurst
4536d55d109SJon Medhurst
4546d55d109SJon Medhurstdefine MAKE_S
4556d55d109SJon Medhurst
4566d55d109SJon Medhurst$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
4576d55d109SJon Medhurst$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ)))
4586d55d109SJon Medhurst
4596d55d109SJon Medhurst$(OBJ) : $(2)
4606d55d109SJon Medhurst	@echo "  AS      $$<"
46127905d0aSSoby Mathew	$$(Q)$$(AS) $$(ASFLAGS) -DIMAGE_BL$(3) -c $$< -o $$@
4626d55d109SJon Medhurst
4636d55d109SJon Medhurst$(PREREQUISITES) : $(2)
4646d55d109SJon Medhurst	@echo "  DEPS    $$@"
4656d55d109SJon Medhurst	@mkdir -p $(1)
4666d55d109SJon Medhurst	$$(Q)$$(AS) $$(ASFLAGS) -M -MT $(OBJ) -MF $$@ $$<
4676d55d109SJon Medhurst
4688d2296f3SSandrine Bailleuxifdef IS_ANYTHING_TO_BUILD
4696d55d109SJon Medhurst-include $(PREREQUISITES)
4706d55d109SJon Medhurstendif
4716d55d109SJon Medhurst
4726d55d109SJon Medhurstendef
4736d55d109SJon Medhurst
4746d55d109SJon Medhurst
4756d55d109SJon Medhurstdefine MAKE_LD
4766d55d109SJon Medhurst
4776d55d109SJon Medhurst$(eval PREREQUISITES := $(1).d)
4786d55d109SJon Medhurst
4796d55d109SJon Medhurst$(1) : $(2)
4806d55d109SJon Medhurst	@echo "  PP      $$<"
481513dd3a0SJuan Castillo	$$(Q)$$(AS) $$(ASFLAGS) -P -E -D__LINKER__ -o $$@ $$<
4826d55d109SJon Medhurst
4836d55d109SJon Medhurst$(PREREQUISITES) : $(2)
4846d55d109SJon Medhurst	@echo "  DEPS    $$@"
4856d55d109SJon Medhurst	@mkdir -p $$(dir $$@)
4866d55d109SJon Medhurst	$$(Q)$$(AS) $$(ASFLAGS) -M -MT $(1) -MF $$@ $$<
4876d55d109SJon Medhurst
4888d2296f3SSandrine Bailleuxifdef IS_ANYTHING_TO_BUILD
4896d55d109SJon Medhurst-include $(PREREQUISITES)
4906d55d109SJon Medhurstendif
4916d55d109SJon Medhurst
4926d55d109SJon Medhurstendef
4936d55d109SJon Medhurst
4946d55d109SJon Medhurst
4956d55d109SJon Medhurstdefine MAKE_OBJS
4966d55d109SJon Medhurst	$(eval C_OBJS := $(filter %.c,$(2)))
4976d55d109SJon Medhurst	$(eval REMAIN := $(filter-out %.c,$(2)))
49827905d0aSSoby Mathew	$(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3))))
4996d55d109SJon Medhurst
5006d55d109SJon Medhurst	$(eval S_OBJS := $(filter %.S,$(REMAIN)))
5016d55d109SJon Medhurst	$(eval REMAIN := $(filter-out %.S,$(REMAIN)))
50227905d0aSSoby Mathew	$(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3))))
5036d55d109SJon Medhurst
5046d55d109SJon Medhurst	$(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
5056d55d109SJon Medhurstendef
5066d55d109SJon Medhurst
5076d55d109SJon Medhurst
5086d55d109SJon Medhurst# NOTE: The line continuation '\' is required in the next define otherwise we
5096d55d109SJon Medhurst# end up with a line-feed characer at the end of the last c filename.
5106d55d109SJon Medhurst# Also bare this issue in mind if extending the list of supported filetypes.
5116d55d109SJon Medhurstdefine SOURCES_TO_OBJS
5126d55d109SJon Medhurst	$(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \
5136d55d109SJon Medhurst	$(notdir $(patsubst %.S,%.o,$(filter %.S,$(1))))
5146d55d109SJon Medhurstendef
5156d55d109SJon Medhurst
5166f971622SJuan Castillo
5176f971622SJuan Castillo# MAKE_TOOL_ARGS macro defines the command line arguments for the FIP and CRT
5186f971622SJuan Castillo# tools at each BL stage. Arguments:
5196f971622SJuan Castillo#   $(1) = BL stage (2, 30, 31, 32, 33)
5206f971622SJuan Castillo#   $(2) = Binary file
5216f971622SJuan Castillo#   $(3) = In FIP (false if empty)
5226f971622SJuan Castillo#   $(4) = Create certificates (false if empty)
5236f971622SJuan Castillo#   $(5) = Create key certificate (false if empty)
5246f971622SJuan Castillo#   $(6) = Private key (optional)
5256f971622SJuan Castillodefine MAKE_TOOL_ARGS
5266f971622SJuan Castillo
5276f971622SJuan Castillo$(eval FIP_DEPS += $(if $3,$(2),))
5286f971622SJuan Castillo$(eval FIP_ARGS += $(if $3,--bl$(1) $(2),))
529b7124ea7SJuan Castillo$(eval FIP_ARGS += $(if $4,--bl$(1)-cert $(BUILD_PLAT)/bl$(1).crt))
530b7124ea7SJuan Castillo$(eval FIP_ARGS += $(if $4,$(if $5,--bl$(1)-key-cert $(BUILD_PLAT)/bl$(1)_key.crt)))
5316f971622SJuan Castillo
5326f971622SJuan Castillo$(eval CRT_DEPS += $(if $4,$(2),))
5336f971622SJuan Castillo$(eval CRT_ARGS += $(if $4,--bl$(1) $(2)))
5346f971622SJuan Castillo$(eval CRT_ARGS += $(if $4,$(if $6,--bl$(1)-key $(6))))
5356f971622SJuan Castillo$(eval CRT_ARGS += $(if $4,--bl$(1)-cert $(BUILD_PLAT)/bl$(1).crt))
5366f971622SJuan Castillo$(eval CRT_ARGS += $(if $4,$(if $5,--bl$(1)-key-cert $(BUILD_PLAT)/bl$(1)_key.crt)))
5376f971622SJuan Castillo
5386f971622SJuan Castilloendef
5396f971622SJuan Castillo
5406f971622SJuan Castillo
5416f971622SJuan Castillo# MAKE_BL macro defines the targets and options to build each BL image.
5426f971622SJuan Castillo# Arguments:
5436f971622SJuan Castillo#   $(1) = BL stage (2, 30, 31, 32, 33)
5446f971622SJuan Castillo#   $(2) = In FIP (false if empty)
5456f971622SJuan Castillo#   $(3) = Create certificates (false if empty)
5466f971622SJuan Castillo#   $(4) = Create key certificate (false if empty)
5476f971622SJuan Castillo#   $(5) = Private key (optional)
5486d55d109SJon Medhurstdefine MAKE_BL
5496d55d109SJon Medhurst	$(eval BUILD_DIR  := ${BUILD_PLAT}/bl$(1))
5506d55d109SJon Medhurst	$(eval SOURCES    := $(BL$(1)_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES))
5516d55d109SJon Medhurst	$(eval OBJS       := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
5526d55d109SJon Medhurst	$(eval LINKERFILE := $(BUILD_DIR)/bl$(1).ld)
5536d55d109SJon Medhurst	$(eval MAPFILE    := $(BUILD_DIR)/bl$(1).map)
5546d55d109SJon Medhurst	$(eval ELF        := $(BUILD_DIR)/bl$(1).elf)
5556d55d109SJon Medhurst	$(eval DUMP       := $(BUILD_DIR)/bl$(1).dump)
5566d55d109SJon Medhurst	$(eval BIN        := $(BUILD_PLAT)/bl$(1).bin)
5576d55d109SJon Medhurst
55827905d0aSSoby Mathew	$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1)))
5596d55d109SJon Medhurst	$(eval $(call MAKE_LD,$(LINKERFILE),$(BL$(1)_LINKERFILE)))
5606d55d109SJon Medhurst
5616d55d109SJon Medhurst$(BUILD_DIR) :
5626d55d109SJon Medhurst	$$(Q)mkdir -p "$$@"
5636d55d109SJon Medhurst
5646d55d109SJon Medhurst$(ELF) : $(OBJS) $(LINKERFILE)
5656d55d109SJon Medhurst	@echo "  LD      $$@"
566aaa3e722SJuan Castillo	@echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \
567aaa3e722SJuan Castillo	       const char version_string[] = "${VERSION_STRING}";' | \
568fb052462SJon Medhurst		$$(CC) $$(CFLAGS) -xc - -o $(BUILD_DIR)/build_message.o
5696d55d109SJon Medhurst	$$(Q)$$(LD) -o $$@ $$(LDFLAGS) -Map=$(MAPFILE) --script $(LINKERFILE) \
5709f98aa1aSJeenu Viswambharan					$(BUILD_DIR)/build_message.o $(OBJS)
5716d55d109SJon Medhurst
5726d55d109SJon Medhurst$(DUMP) : $(ELF)
5736d55d109SJon Medhurst	@echo "  OD      $$@"
5746d55d109SJon Medhurst	$${Q}$${OD} -dx $$< > $$@
5756d55d109SJon Medhurst
5766d55d109SJon Medhurst$(BIN) : $(ELF)
5776d55d109SJon Medhurst	@echo "  BIN     $$@"
5786d55d109SJon Medhurst	$$(Q)$$(OC) -O binary $$< $$@
579eaaeece2SJames Morrissey	@echo
5806d55d109SJon Medhurst	@echo "Built $$@ successfully"
5814f6ad66aSAchin Gupta	@echo
5824f6ad66aSAchin Gupta
5836d55d109SJon Medhurst.PHONY : bl$(1)
5846d55d109SJon Medhurstbl$(1) : $(BUILD_DIR) $(BIN) $(DUMP)
5854f6ad66aSAchin Gupta
5866d55d109SJon Medhurstall : bl$(1)
5876d55d109SJon Medhurst
5886f971622SJuan Castillo$(eval $(call MAKE_TOOL_ARGS,$(1),$(BIN),$(2),$(3),$(4),$(5)))
5896d55d109SJon Medhurst
5906d55d109SJon Medhurstendef
5916d55d109SJon Medhurst
5926d55d109SJon Medhurst
5934bfc2d21SJon Medhurstifeq (${NEED_BL1},yes)
5946d55d109SJon Medhurst$(eval $(call MAKE_BL,1))
5954bfc2d21SJon Medhurstendif
5966d55d109SJon Medhurst
5974bfc2d21SJon Medhurstifeq (${NEED_BL2},yes)
5986f971622SJuan Castillo$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},in_fip,${CERTS})),\
5996f971622SJuan Castillo	$(eval $(call MAKE_BL,2,in_fip,${CERTS})))
6004bfc2d21SJon Medhurstendif
6016d55d109SJon Medhurst
6024bfc2d21SJon Medhurstifeq (${NEED_BL31},yes)
6036d55d109SJon MedhurstBL31_SOURCES += ${SPD_SOURCES}
6046f971622SJuan Castillo$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},in_fip,${CERTS},${CERTS},${BL31_KEY})),\
6056f971622SJuan Castillo	$(eval $(call MAKE_BL,31,in_fip,${CERTS},${CERTS},${BL31_KEY})))
6064bfc2d21SJon Medhurstendif
6076d55d109SJon Medhurst
6086d55d109SJon Medhurstifeq (${NEED_BL32},yes)
6096f971622SJuan Castillo$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},in_fip,${CERTS},${CERTS},${BL32_KEY})),\
6106f971622SJuan Castillo	$(eval $(call MAKE_BL,32,in_fip,${CERTS},${CERTS},${BL32_KEY})))
6116d55d109SJon Medhurstendif
61272ee3314SRyan Harkin
61393d81d64SSandrine Bailleuxifeq (${NEED_BL30},yes)
6146f971622SJuan Castillo$(if ${BL30}, $(eval $(call MAKE_TOOL_ARGS,30,${BL30},in_fip,${CERTS},${CERTS},${BL30_KEY})))
61593d81d64SSandrine Bailleux
61693d81d64SSandrine Bailleux# If BL3-0 is needed by the platform then 'BL30' variable must be defined.
61793d81d64SSandrine Bailleuxcheck_bl30:
61893d81d64SSandrine Bailleux	$(if ${BL30},,$(error "To build a FIP for platform ${PLAT}, please set BL30 to point to the SCP firmware"))
61993d81d64SSandrine Bailleuxelse
62027713fb4SSoby Mathew
62193d81d64SSandrine Bailleux# If BL3-0 is not needed by the platform but the user still specified the path
62293d81d64SSandrine Bailleux# to a BL3-0 image then warn him that it will be ignored.
62393d81d64SSandrine Bailleuxcheck_bl30:
62493d81d64SSandrine Bailleux	$(if ${BL30},$(warning "BL3-0 is not supported on platform ${PLAT}, it will just be ignored"),)
62593d81d64SSandrine Bailleuxendif
62693d81d64SSandrine Bailleux
62727713fb4SSoby Mathewifeq (${NEED_BL33},yes)
6286f971622SJuan Castillo$(if ${BL33}, $(eval $(call MAKE_TOOL_ARGS,33,${BL33},in_fip,${CERTS},${CERTS},${BL33_KEY})))
62927713fb4SSoby Mathew
63027713fb4SSoby Mathew# If BL3-3 is needed by the platform then 'BL33' variable must be defined.
63127713fb4SSoby Mathewcheck_bl33:
6324bfc2d21SJon Medhurst	$(if ${BL33},,$(error "To build a FIP, please set BL33 to point to the Normal World binary, eg: BL33=../uefi/FVP_AARCH64_EFI.fd"))
63327713fb4SSoby Mathewelse
63427713fb4SSoby Mathew
63527713fb4SSoby Mathew# If BL3-3 is not needed by the platform but the user still specified the path
63627713fb4SSoby Mathew# to a BL3-3 image then warn him that it will be ignored.
63727713fb4SSoby Mathewcheck_bl33:
63827713fb4SSoby Mathew	$(if ${BL33},$(warning "BL3-3 is not supported on platform ${PLAT}, it will just be ignored"),)
63927713fb4SSoby Mathewendif
64027713fb4SSoby Mathew
6416f971622SJuan Castillo# Add the dependency on the certificates
6426f971622SJuan Castilloifneq (${GENERATE_COT},0)
64385cdfdb2SJuan Castillo    fip: certificates
6446f971622SJuan Castilloendif
6456f971622SJuan Castillo
6466f971622SJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} check_bl30 check_bl33
6476f971622SJuan Castillo			${Q}${CRTTOOL} ${CRT_ARGS}
6486f971622SJuan Castillo			@echo
6496f971622SJuan Castillo			@echo "Built $@ successfully"
6506f971622SJuan Castillo			@echo "Certificates can be found in ${BUILD_PLAT}"
6516f971622SJuan Castillo			@echo
65227713fb4SSoby Mathew
6537f48fab9SJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} check_bl30 check_bl33
654f58ad36fSHarry Liebel			${Q}${FIPTOOL} --dump \
655375f538aSAchin Gupta				${FIP_ARGS} \
656f58ad36fSHarry Liebel				$@
657f58ad36fSHarry Liebel			@echo
6582f2cef46SJeenu Viswambharan			@echo "Built $@ successfully"
6592f2cef46SJeenu Viswambharan			@echo
660f58ad36fSHarry Liebel
661f58ad36fSHarry Liebel
66235fab8c9SJoakim Bechcscope:
66335fab8c9SJoakim Bech	@echo "  CSCOPE"
66435fab8c9SJoakim Bech	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
66535fab8c9SJoakim Bech	${Q}cscope -b -q -k
66635fab8c9SJoakim Bech
66772ee3314SRyan Harkinhelp:
668c04d2606SDan Handley	@echo "usage: ${MAKE} PLAT=<${PLATFORMS}> [OPTIONS] [TARGET]"
66972ee3314SRyan Harkin	@echo ""
67072ee3314SRyan Harkin	@echo "PLAT is used to specify which platform you wish to build."
67108c7ed0fSSandrine Bailleux	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
67272ee3314SRyan Harkin	@echo ""
6731b578596SSandrine Bailleux	@echo "Please refer to the User Guide for a list of all supported options."
6741b578596SSandrine Bailleux	@echo "Note that the build system doesn't track dependencies for build "
6751b578596SSandrine Bailleux	@echo "options. Therefore, if any of the build options are changed "
6761b578596SSandrine Bailleux	@echo "from a previous build, a clean build must be performed."
6771b578596SSandrine Bailleux	@echo ""
67872ee3314SRyan Harkin	@echo "Supported Targets:"
6791b578596SSandrine Bailleux	@echo "  all            Build all individual bootloader binaries"
68036eaaf37SIan Spray	@echo "  bl1            Build the BL1 binary"
6818aa559c0SJeenu Viswambharan	@echo "  bl2            Build the BL2 binary"
6821b578596SSandrine Bailleux	@echo "  bl31           Build the BL3-1 binary"
6831b578596SSandrine Bailleux	@echo "  bl32           Build the BL3-2 binary"
6841b578596SSandrine Bailleux	@echo "  fip            Build the Firmware Image Package (FIP)"
68536eaaf37SIan Spray	@echo "  checkcodebase  Check the coding style of the entire source tree"
68636eaaf37SIan Spray	@echo "  checkpatch     Check the coding style on changes in the current"
68736eaaf37SIan Spray	@echo "                 branch against BASE_COMMIT (default origin/master)"
68872ee3314SRyan Harkin	@echo "  clean          Clean the build for the selected platform"
68935fab8c9SJoakim Bech	@echo "  cscope         Generate cscope index"
69072ee3314SRyan Harkin	@echo "  distclean      Remove all build artifacts for all platforms"
6916f971622SJuan Castillo	@echo "  certtool       Build the Certificate generation tool"
692f58ad36fSHarry Liebel	@echo "  fiptool        Build the Firmware Image Package(FIP) creation tool"
69372ee3314SRyan Harkin	@echo ""
6941b578596SSandrine Bailleux	@echo "Note: most build targets require PLAT to be set to a specific platform."
69572ee3314SRyan Harkin	@echo ""
69672ee3314SRyan Harkin	@echo "example: build all targets for the FVP platform:"
69772ee3314SRyan Harkin	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
698