xref: /rk3399_ARM-atf/Makefile (revision bcbe19afaa7a19083164dd1be80c741d23ee9caf)
1#
2# Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# Redistributions of source code must retain the above copyright notice, this
8# list of conditions and the following disclaimer.
9#
10# Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13#
14# Neither the name of ARM nor the names of its contributors may be used
15# to endorse or promote products derived from this software without specific
16# prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30
31#
32# Trusted Firmware Version
33#
34VERSION_MAJOR			:= 1
35VERSION_MINOR			:= 2
36
37# Default goal is build all images
38.DEFAULT_GOAL			:= all
39
40MAKE_HELPERS_DIRECTORY := make_helpers/
41include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
42include ${MAKE_HELPERS_DIRECTORY}build_env.mk
43
44################################################################################
45# Default values for build configurations
46################################################################################
47
48# Build verbosity
49V				:= 0
50# Debug build
51DEBUG				:= 0
52# Build platform
53DEFAULT_PLAT			:= fvp
54PLAT				:= ${DEFAULT_PLAT}
55# SPD choice
56SPD				:= none
57# Base commit to perform code check on
58BASE_COMMIT			:= origin/master
59# NS timer register save and restore
60NS_TIMER_SWITCH			:= 0
61# By default, BL1 acts as the reset handler, not BL31
62RESET_TO_BL31			:= 0
63# Include FP registers in cpu context
64CTX_INCLUDE_FPREGS		:= 0
65# Build flag to include AArch32 registers in cpu context save and restore
66# during world switch. This flag must be set to 0 for AArch64-only platforms.
67CTX_INCLUDE_AARCH32_REGS	:= 1
68# Determine the version of ARM GIC architecture to use for interrupt management
69# in EL3. The platform port can change this value if needed.
70ARM_GIC_ARCH			:= 2
71# Determine the version of ARM CCI product used in the platform. The platform
72# port can change this value if needed.
73ARM_CCI_PRODUCT_ID		:= 400
74# Flag used to indicate if ASM_ASSERTION should be enabled for the build.
75# This defaults to being present in DEBUG builds only.
76ASM_ASSERTION			:= ${DEBUG}
77# Build option to choose whether Trusted firmware uses Coherent memory or not.
78USE_COHERENT_MEM		:= 1
79# Flag used to choose the power state format viz Extended State-ID or the Original
80# format.
81PSCI_EXTENDED_STATE_ID		:= 0
82# Default FIP file name
83FIP_NAME			:= fip.bin
84# Default FWU_FIP file name
85FWU_FIP_NAME			:= fwu_fip.bin
86# By default, use the -pedantic option in the gcc command line
87DISABLE_PEDANTIC		:= 0
88# Flags to generate the Chain of Trust
89GENERATE_COT			:= 0
90CREATE_KEYS			:= 1
91SAVE_KEYS			:= 0
92# Flags to build TF with Trusted Boot support
93TRUSTED_BOARD_BOOT		:= 0
94# By default, consider that the platform's reset address is not programmable.
95# The platform Makefile is free to override this value.
96PROGRAMMABLE_RESET_ADDRESS	:= 0
97# Build flag to treat usage of deprecated platform and framework APIs as error.
98ERROR_DEPRECATED		:= 0
99# By default, consider that the platform may release several CPUs out of reset.
100# The platform Makefile is free to override this value.
101COLD_BOOT_SINGLE_CPU		:= 0
102# Flag to introduce an infinite loop in BL1 just before it exits into the next
103# image. This is meant to help debugging the post-BL2 phase.
104SPIN_ON_BL1_EXIT		:= 0
105# Build PL011 UART driver in minimal generic UART mode
106PL011_GENERIC_UART		:= 0
107# Flag to enable Performance Measurement Framework
108ENABLE_PMF			:= 0
109# Flag to enable PSCI STATs functionality
110ENABLE_PSCI_STAT	:= 0
111
112################################################################################
113# Checkpatch script options
114################################################################################
115
116CHECKCODE_ARGS		:=	--no-patch
117# Do not check the coding style on imported library files or documentation files
118INC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
119					include/lib/libfdt		\
120					include/lib/stdlib,		\
121					$(wildcard include/lib/*)))
122INC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
123					include/lib,			\
124					$(wildcard include/*)))
125LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
126					lib/libfdt			\
127					lib/stdlib,			\
128					$(wildcard lib/*)))
129ROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
130					lib				\
131					include				\
132					docs				\
133					%.md,				\
134					$(wildcard *)))
135CHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
136				${INC_DIRS_TO_CHECK}			\
137				${INC_LIB_DIRS_TO_CHECK}		\
138				${LIB_DIRS_TO_CHECK}
139
140
141################################################################################
142# Process build options
143################################################################################
144
145# Verbose flag
146ifeq (${V},0)
147        Q:=@
148        CHECKCODE_ARGS	+=	--no-summary --terse
149else
150        Q:=
151endif
152export Q
153
154# Process Debug flag
155$(eval $(call add_define,DEBUG))
156ifneq (${DEBUG}, 0)
157        BUILD_TYPE	:=	debug
158        TF_CFLAGS	+= 	-g
159        ASFLAGS		+= 	-g -Wa,--gdwarf-2
160        # Use LOG_LEVEL_INFO by default for debug builds
161        LOG_LEVEL	:=	40
162else
163        BUILD_TYPE	:=	release
164        $(eval $(call add_define,NDEBUG))
165        # Use LOG_LEVEL_NOTICE by default for release builds
166        LOG_LEVEL	:=	20
167endif
168
169# Default build string (git branch and commit)
170ifeq (${BUILD_STRING},)
171        BUILD_STRING	:=	$(shell git log -n 1 --pretty=format:"%h")
172endif
173VERSION_STRING		:=	v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
174
175# The cert_create tool cannot generate certificates individually, so we use the
176# target 'certificates' to create them all
177ifneq (${GENERATE_COT},0)
178        FIP_DEPS += certificates
179        FWU_FIP_DEPS += fwu_certificates
180endif
181
182
183################################################################################
184# Toolchain
185################################################################################
186
187CC			:=	${CROSS_COMPILE}gcc
188CPP			:=	${CROSS_COMPILE}cpp
189AS			:=	${CROSS_COMPILE}gcc
190AR			:=	${CROSS_COMPILE}ar
191LD			:=	${CROSS_COMPILE}ld
192OC			:=	${CROSS_COMPILE}objcopy
193OD			:=	${CROSS_COMPILE}objdump
194NM			:=	${CROSS_COMPILE}nm
195PP			:=	${CROSS_COMPILE}gcc -E
196
197ASFLAGS			+= 	-nostdinc -ffreestanding -Wa,--fatal-warnings	\
198				-Werror -Wmissing-include-dirs			\
199				-mgeneral-regs-only -D__ASSEMBLY__		\
200				${DEFINES} ${INCLUDES}
201TF_CFLAGS		+= 	-nostdinc -ffreestanding -Wall			\
202				-Werror -Wmissing-include-dirs			\
203				-mgeneral-regs-only -mstrict-align		\
204				-std=c99 -c -Os					\
205				${DEFINES} ${INCLUDES}
206TF_CFLAGS		+=	-ffunction-sections -fdata-sections
207
208LDFLAGS			+=	--fatal-warnings -O1
209LDFLAGS			+=	--gc-sections
210
211
212################################################################################
213# Common sources and include directories
214################################################################################
215include lib/stdlib/stdlib.mk
216
217BL_COMMON_SOURCES	+=	common/bl_common.c			\
218				common/tf_printf.c			\
219				common/aarch64/debug.S			\
220				lib/aarch64/cache_helpers.S		\
221				lib/aarch64/misc_helpers.S		\
222				plat/common/aarch64/platform_helpers.S	\
223				${STDLIB_SRCS}
224
225INCLUDES		+=	-Iinclude/bl1			\
226				-Iinclude/bl31			\
227				-Iinclude/bl31/services		\
228				-Iinclude/common		\
229				-Iinclude/drivers		\
230				-Iinclude/drivers/arm		\
231				-Iinclude/drivers/auth		\
232				-Iinclude/drivers/io		\
233				-Iinclude/drivers/ti/uart	\
234				-Iinclude/lib			\
235				-Iinclude/lib/aarch64		\
236				-Iinclude/lib/cpus/aarch64	\
237				-Iinclude/plat/common		\
238				${PLAT_INCLUDES}		\
239				${SPD_INCLUDES}
240
241
242################################################################################
243# Generic definitions
244################################################################################
245
246include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
247
248BUILD_BASE		:=	./build
249BUILD_PLAT		:=	${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
250
251SPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
252
253# Platforms providing their own TBB makefile may override this value
254INCLUDE_TBBR_MK		:=	1
255
256
257################################################################################
258# Include SPD Makefile if one has been specified
259################################################################################
260
261ifneq (${SPD},none)
262ifdef EL3_PAYLOAD_BASE
263        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
264        $(warning "The SPD and its BL32 companion will be present but ignored.")
265endif
266        # We expect to locate an spd.mk under the specified SPD directory
267        SPD_MAKE	:=	$(wildcard services/spd/${SPD}/${SPD}.mk)
268
269        ifeq (${SPD_MAKE},)
270                $(error Error: No services/spd/${SPD}/${SPD}.mk located)
271        endif
272        $(info Including ${SPD_MAKE})
273        include ${SPD_MAKE}
274
275        # If there's BL32 companion for the chosen SPD, we expect that the SPD's
276        # Makefile would set NEED_BL32 to "yes". In this case, the build system
277        # supports two mutually exclusive options:
278        # * BL32 is built from source: then BL32_SOURCES must contain the list
279        #   of source files to build BL32
280        # * BL32 is a prebuilt binary: then BL32 must point to the image file
281        #   that will be included in the FIP
282        # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
283        # over the sources.
284endif
285
286
287################################################################################
288# Include the platform specific Makefile after the SPD Makefile (the platform
289# makefile may use all previous definitions in this file)
290################################################################################
291
292include ${PLAT_MAKEFILE_FULL}
293
294# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default
295ifndef ENABLE_PLAT_COMPAT
296ENABLE_PLAT_COMPAT := 1
297endif
298
299# Include the platform compatibility helpers for PSCI
300ifneq (${ENABLE_PLAT_COMPAT}, 0)
301include plat/compat/plat_compat.mk
302endif
303
304# Include the CPU specific operations makefile, which provides default
305# values for all CPU errata workarounds and CPU specific optimisations.
306# This can be overridden by the platform.
307include lib/cpus/cpu-ops.mk
308
309
310################################################################################
311# Check incompatible options
312################################################################################
313
314ifdef EL3_PAYLOAD_BASE
315        ifdef PRELOADED_BL33_BASE
316                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
317                incompatible build options. EL3_PAYLOAD_BASE has priority.")
318        endif
319endif
320
321ifeq (${NEED_BL33},yes)
322        ifdef EL3_PAYLOAD_BASE
323                $(warning "BL33 image is not needed when option \
324                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
325        endif
326        ifdef PRELOADED_BL33_BASE
327                $(warning "BL33 image is not needed when option \
328                PRELOADED_BL33_BASE is used and won't be added to the FIP \
329                file.")
330        endif
331endif
332
333
334################################################################################
335# Process platform overrideable behaviour
336################################################################################
337
338# Check if -pedantic option should be used
339ifeq (${DISABLE_PEDANTIC},0)
340        TF_CFLAGS	+= 	-pedantic
341endif
342
343# Using the ARM Trusted Firmware BL2 implies that a BL33 image also needs to be
344# supplied for the FIP and Certificate generation tools. This flag can be
345# overridden by the platform.
346ifdef BL2_SOURCES
347        ifdef EL3_PAYLOAD_BASE
348                # If booting an EL3 payload there is no need for a BL33 image
349                # in the FIP file.
350                NEED_BL33		:=	no
351        else
352                ifdef PRELOADED_BL33_BASE
353                        # If booting a BL33 preloaded image there is no need of
354                        # another one in the FIP file.
355                        NEED_BL33		:=	no
356                else
357                        NEED_BL33		?=	yes
358                endif
359        endif
360endif
361
362# Process TBB related flags
363ifneq (${GENERATE_COT},0)
364        # Common cert_create options
365        ifneq (${CREATE_KEYS},0)
366                $(eval CRT_ARGS += -n)
367                $(eval FWU_CRT_ARGS += -n)
368                ifneq (${SAVE_KEYS},0)
369                        $(eval CRT_ARGS += -k)
370                        $(eval FWU_CRT_ARGS += -k)
371                endif
372        endif
373        # Include TBBR makefile (unless the platform indicates otherwise)
374        ifeq (${INCLUDE_TBBR_MK},1)
375                include make_helpers/tbbr/tbbr_tools.mk
376        endif
377endif
378
379# Make sure PMF is enabled if PSCI STAT is enabled.
380ifeq (${ENABLE_PSCI_STAT},1)
381ENABLE_PMF			:= 1
382endif
383
384################################################################################
385# Auxiliary tools (fip_create, cert_create, etc)
386################################################################################
387
388# Variables for use with Certificate Generation Tool
389CRTTOOLPATH		?=	tools/cert_create
390CRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
391
392# Variables for use with Firmware Image Package
393FIPTOOLPATH		?=	tools/fip_create
394FIPTOOL			?=	${FIPTOOLPATH}/fip_create${BIN_EXT}
395
396
397################################################################################
398# Build options checks
399################################################################################
400
401$(eval $(call assert_boolean,DEBUG))
402$(eval $(call assert_boolean,NS_TIMER_SWITCH))
403$(eval $(call assert_boolean,RESET_TO_BL31))
404$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
405$(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS))
406$(eval $(call assert_boolean,ASM_ASSERTION))
407$(eval $(call assert_boolean,USE_COHERENT_MEM))
408$(eval $(call assert_boolean,DISABLE_PEDANTIC))
409$(eval $(call assert_boolean,GENERATE_COT))
410$(eval $(call assert_boolean,CREATE_KEYS))
411$(eval $(call assert_boolean,SAVE_KEYS))
412$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
413$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS))
414$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU))
415$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID))
416$(eval $(call assert_boolean,ERROR_DEPRECATED))
417$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
418$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT))
419$(eval $(call assert_boolean,PL011_GENERIC_UART))
420$(eval $(call assert_boolean,ENABLE_PMF))
421$(eval $(call assert_boolean,ENABLE_PSCI_STAT))
422
423
424################################################################################
425# Add definitions to the cpp preprocessor based on the current build options.
426# This is done after including the platform specific makefile to allow the
427# platform to overwrite the default options
428################################################################################
429
430$(eval $(call add_define,PLAT_${PLAT}))
431$(eval $(call add_define,SPD_${SPD}))
432$(eval $(call add_define,NS_TIMER_SWITCH))
433$(eval $(call add_define,RESET_TO_BL31))
434$(eval $(call add_define,CTX_INCLUDE_FPREGS))
435$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS))
436$(eval $(call add_define,ARM_GIC_ARCH))
437$(eval $(call add_define,ARM_CCI_PRODUCT_ID))
438$(eval $(call add_define,ASM_ASSERTION))
439$(eval $(call add_define,LOG_LEVEL))
440$(eval $(call add_define,USE_COHERENT_MEM))
441$(eval $(call add_define,TRUSTED_BOARD_BOOT))
442$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS))
443$(eval $(call add_define,COLD_BOOT_SINGLE_CPU))
444$(eval $(call add_define,PSCI_EXTENDED_STATE_ID))
445$(eval $(call add_define,ERROR_DEPRECATED))
446$(eval $(call add_define,ENABLE_PLAT_COMPAT))
447$(eval $(call add_define,SPIN_ON_BL1_EXIT))
448$(eval $(call add_define,PL011_GENERIC_UART))
449$(eval $(call add_define,ENABLE_PMF))
450$(eval $(call add_define,ENABLE_PSCI_STAT))
451# Define the EL3_PAYLOAD_BASE flag only if it is provided.
452ifdef EL3_PAYLOAD_BASE
453        $(eval $(call add_define,EL3_PAYLOAD_BASE))
454else
455        # Define the PRELOADED_BL33_BASE flag only if it is provided and
456        # EL3_PAYLOAD_BASE is not defined, as it has priority.
457        ifdef PRELOADED_BL33_BASE
458                $(eval $(call add_define,PRELOADED_BL33_BASE))
459        endif
460endif
461
462################################################################################
463# Include BL specific makefiles
464################################################################################
465
466ifdef BL1_SOURCES
467NEED_BL1 := yes
468include bl1/bl1.mk
469endif
470
471ifdef BL2_SOURCES
472NEED_BL2 := yes
473include bl2/bl2.mk
474endif
475
476ifdef BL2U_SOURCES
477NEED_BL2U := yes
478include bl2u/bl2u.mk
479endif
480
481ifdef BL31_SOURCES
482# When booting an EL3 payload, there is no need to compile the BL31 image nor
483# put it in the FIP.
484ifndef EL3_PAYLOAD_BASE
485NEED_BL31 := yes
486include bl31/bl31.mk
487endif
488endif
489
490
491################################################################################
492# Build targets
493################################################################################
494
495.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool
496.SUFFIXES:
497
498all: msg_start
499
500msg_start:
501	@echo "Building ${PLAT}"
502
503# Check if deprecated declarations should be treated as error or not.
504ifeq (${ERROR_DEPRECATED},0)
505    TF_CFLAGS		+= 	-Wno-error=deprecated-declarations
506endif
507
508# Expand build macros for the different images
509ifeq (${NEED_BL1},yes)
510$(eval $(call MAKE_BL,1))
511endif
512
513ifeq (${NEED_BL2},yes)
514$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},tb-fw)),\
515	$(eval $(call MAKE_BL,2,tb-fw)))
516endif
517
518ifeq (${NEED_BL31},yes)
519BL31_SOURCES += ${SPD_SOURCES}
520$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},soc-fw)),\
521	$(eval $(call MAKE_BL,31,soc-fw)))
522endif
523
524# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
525# build system will call FIP_ADD_IMG to print a warning message and abort the
526# process. Note that the dependency on BL32 applies to the FIP only.
527ifeq (${NEED_BL32},yes)
528$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},tos-fw)),\
529	$(if ${BL32_SOURCES}, $(eval $(call MAKE_BL,32,tos-fw)),\
530		$(eval $(call FIP_ADD_IMG,BL32,--tos-fw))))
531endif
532
533# Add the BL33 image if required by the platform
534ifeq (${NEED_BL33},yes)
535$(eval $(call FIP_ADD_IMG,BL33,--nt-fw))
536endif
537
538ifeq (${NEED_BL2U},yes)
539BL2U_PATH	:= $(if ${BL2U},${BL2U},$(call IMG_BIN,2u))
540$(if ${BL2U}, ,$(eval $(call MAKE_BL,2u)))
541$(eval $(call FWU_FIP_ADD_PAYLOAD,${BL2U_PATH},--ap-fwu-cfg))
542endif
543
544locate-checkpatch:
545ifndef CHECKPATCH
546	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
547else
548ifeq (,$(wildcard ${CHECKPATCH}))
549	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
550endif
551endif
552
553clean:
554	@echo "  CLEAN"
555	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
556	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
557	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
558
559realclean distclean:
560	@echo "  REALCLEAN"
561	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
562	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
563	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
564	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
565
566checkcodebase:		locate-checkpatch
567	@echo "  CHECKING STYLE"
568	@if test -d .git ; then						\
569		git ls-files | grep -E -v libfdt\|stdlib\|docs\|\.md |	\
570		while read GIT_FILE ;					\
571		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
572		done ;							\
573	else								\
574		 find . -type f -not -iwholename "*.git*"		\
575		 -not -iwholename "*build*"				\
576		 -not -iwholename "*libfdt*"				\
577		 -not -iwholename "*stdlib*"				\
578		 -not -iwholename "*docs*"				\
579		 -not -iwholename "*.md"				\
580		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
581	fi
582
583checkpatch:		locate-checkpatch
584	@echo "  CHECKING STYLE"
585	${Q}git log -p ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} - || true
586
587certtool: ${CRTTOOL}
588
589.PHONY: ${CRTTOOL}
590${CRTTOOL}:
591	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH}
592	@${ECHO_BLANK_LINE}
593	@echo "Built $@ successfully"
594	@${ECHO_BLANK_LINE}
595
596ifneq (${GENERATE_COT},0)
597certificates: ${CRT_DEPS} ${CRTTOOL}
598	${Q}${CRTTOOL} ${CRT_ARGS}
599	@${ECHO_BLANK_LINE}
600	@echo "Built $@ successfully"
601	@echo "Certificates can be found in ${BUILD_PLAT}"
602	@${ECHO_BLANK_LINE}
603endif
604
605${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
606	${Q}${FIPTOOL} --dump ${FIP_ARGS} $@
607	@${ECHO_BLANK_LINE}
608	@echo "Built $@ successfully"
609	@${ECHO_BLANK_LINE}
610
611ifneq (${GENERATE_COT},0)
612fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
613	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
614	@echo
615	@echo "Built $@ successfully"
616	@echo "FWU certificates can be found in ${BUILD_PLAT}"
617	@echo
618endif
619
620${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
621	${Q}${FIPTOOL} --dump ${FWU_FIP_ARGS} $@
622	@echo
623	@echo "Built $@ successfully"
624	@echo
625
626fiptool: ${FIPTOOL}
627fip: ${BUILD_PLAT}/${FIP_NAME}
628fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
629
630.PHONY: ${FIPTOOL}
631${FIPTOOL}:
632	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH}
633
634cscope:
635	@echo "  CSCOPE"
636	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
637	${Q}cscope -b -q -k
638
639help:
640	@echo "usage: ${MAKE} PLAT=<${PLATFORM_LIST}> [OPTIONS] [TARGET]"
641	@echo ""
642	@echo "PLAT is used to specify which platform you wish to build."
643	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
644	@echo ""
645	@echo "Please refer to the User Guide for a list of all supported options."
646	@echo "Note that the build system doesn't track dependencies for build "
647	@echo "options. Therefore, if any of the build options are changed "
648	@echo "from a previous build, a clean build must be performed."
649	@echo ""
650	@echo "Supported Targets:"
651	@echo "  all            Build all individual bootloader binaries"
652	@echo "  bl1            Build the BL1 binary"
653	@echo "  bl2            Build the BL2 binary"
654	@echo "  bl2u           Build the BL2U binary"
655	@echo "  bl31           Build the BL31 binary"
656	@echo "  bl32           Build the BL32 binary"
657	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
658	@echo "  fip            Build the Firmware Image Package (FIP)"
659	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
660	@echo "  checkcodebase  Check the coding style of the entire source tree"
661	@echo "  checkpatch     Check the coding style on changes in the current"
662	@echo "                 branch against BASE_COMMIT (default origin/master)"
663	@echo "  clean          Clean the build for the selected platform"
664	@echo "  cscope         Generate cscope index"
665	@echo "  distclean      Remove all build artifacts for all platforms"
666	@echo "  certtool       Build the Certificate generation tool"
667	@echo "  fiptool        Build the Firmware Image Package(FIP) creation tool"
668	@echo ""
669	@echo "Note: most build targets require PLAT to be set to a specific platform."
670	@echo ""
671	@echo "example: build all targets for the FVP platform:"
672	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
673