xref: /rk3399_ARM-atf/Makefile (revision 0af559a833e9cb1be1e1295d00e22ecab1d3f5be)
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# Whether code and read-only data should be put on separate memory pages.
112# The platform Makefile is free to override this value.
113SEPARATE_CODE_AND_RODATA	:= 0
114
115
116################################################################################
117# Checkpatch script options
118################################################################################
119
120CHECKCODE_ARGS		:=	--no-patch
121# Do not check the coding style on imported library files or documentation files
122INC_LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
123					include/lib/libfdt		\
124					include/lib/stdlib,		\
125					$(wildcard include/lib/*)))
126INC_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
127					include/lib,			\
128					$(wildcard include/*)))
129LIB_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
130					lib/libfdt			\
131					lib/stdlib,			\
132					$(wildcard lib/*)))
133ROOT_DIRS_TO_CHECK	:=	$(sort $(filter-out			\
134					lib				\
135					include				\
136					docs				\
137					%.md,				\
138					$(wildcard *)))
139CHECK_PATHS		:=	${ROOT_DIRS_TO_CHECK}			\
140				${INC_DIRS_TO_CHECK}			\
141				${INC_LIB_DIRS_TO_CHECK}		\
142				${LIB_DIRS_TO_CHECK}
143
144
145################################################################################
146# Process build options
147################################################################################
148
149# Verbose flag
150ifeq (${V},0)
151        Q:=@
152        CHECKCODE_ARGS	+=	--no-summary --terse
153else
154        Q:=
155endif
156export Q
157
158# Process Debug flag
159$(eval $(call add_define,DEBUG))
160ifneq (${DEBUG}, 0)
161        BUILD_TYPE	:=	debug
162        TF_CFLAGS	+= 	-g
163        ASFLAGS		+= 	-g -Wa,--gdwarf-2
164        # Use LOG_LEVEL_INFO by default for debug builds
165        LOG_LEVEL	:=	40
166else
167        BUILD_TYPE	:=	release
168        $(eval $(call add_define,NDEBUG))
169        # Use LOG_LEVEL_NOTICE by default for release builds
170        LOG_LEVEL	:=	20
171endif
172
173# Default build string (git branch and commit)
174ifeq (${BUILD_STRING},)
175        BUILD_STRING	:=	$(shell git log -n 1 --pretty=format:"%h")
176endif
177VERSION_STRING		:=	v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
178
179# The cert_create tool cannot generate certificates individually, so we use the
180# target 'certificates' to create them all
181ifneq (${GENERATE_COT},0)
182        FIP_DEPS += certificates
183        FWU_FIP_DEPS += fwu_certificates
184endif
185
186
187################################################################################
188# Toolchain
189################################################################################
190
191CC			:=	${CROSS_COMPILE}gcc
192CPP			:=	${CROSS_COMPILE}cpp
193AS			:=	${CROSS_COMPILE}gcc
194AR			:=	${CROSS_COMPILE}ar
195LD			:=	${CROSS_COMPILE}ld
196OC			:=	${CROSS_COMPILE}objcopy
197OD			:=	${CROSS_COMPILE}objdump
198NM			:=	${CROSS_COMPILE}nm
199PP			:=	${CROSS_COMPILE}gcc -E
200
201ASFLAGS			+= 	-nostdinc -ffreestanding -Wa,--fatal-warnings	\
202				-Werror -Wmissing-include-dirs			\
203				-mgeneral-regs-only -D__ASSEMBLY__		\
204				${DEFINES} ${INCLUDES}
205TF_CFLAGS		+= 	-nostdinc -ffreestanding -Wall			\
206				-Werror -Wmissing-include-dirs			\
207				-mgeneral-regs-only -mstrict-align		\
208				-std=c99 -c -Os					\
209				${DEFINES} ${INCLUDES}
210TF_CFLAGS		+=	-ffunction-sections -fdata-sections
211
212LDFLAGS			+=	--fatal-warnings -O1
213LDFLAGS			+=	--gc-sections
214
215
216################################################################################
217# Common sources and include directories
218################################################################################
219include lib/stdlib/stdlib.mk
220
221BL_COMMON_SOURCES	+=	common/bl_common.c			\
222				common/tf_printf.c			\
223				common/aarch64/debug.S			\
224				lib/aarch64/cache_helpers.S		\
225				lib/aarch64/misc_helpers.S		\
226				plat/common/aarch64/platform_helpers.S	\
227				${STDLIB_SRCS}
228
229INCLUDES		+=	-Iinclude/bl1			\
230				-Iinclude/bl31			\
231				-Iinclude/bl31/services		\
232				-Iinclude/common		\
233				-Iinclude/drivers		\
234				-Iinclude/drivers/arm		\
235				-Iinclude/drivers/auth		\
236				-Iinclude/drivers/io		\
237				-Iinclude/drivers/ti/uart	\
238				-Iinclude/lib			\
239				-Iinclude/lib/aarch64		\
240				-Iinclude/lib/cpus/aarch64	\
241				-Iinclude/plat/common		\
242				${PLAT_INCLUDES}		\
243				${SPD_INCLUDES}
244
245
246################################################################################
247# Generic definitions
248################################################################################
249
250include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
251
252BUILD_BASE		:=	./build
253BUILD_PLAT		:=	${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
254
255SPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
256
257# Platforms providing their own TBB makefile may override this value
258INCLUDE_TBBR_MK		:=	1
259
260
261################################################################################
262# Include SPD Makefile if one has been specified
263################################################################################
264
265ifneq (${SPD},none)
266ifdef EL3_PAYLOAD_BASE
267        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
268        $(warning "The SPD and its BL32 companion will be present but ignored.")
269endif
270        # We expect to locate an spd.mk under the specified SPD directory
271        SPD_MAKE	:=	$(wildcard services/spd/${SPD}/${SPD}.mk)
272
273        ifeq (${SPD_MAKE},)
274                $(error Error: No services/spd/${SPD}/${SPD}.mk located)
275        endif
276        $(info Including ${SPD_MAKE})
277        include ${SPD_MAKE}
278
279        # If there's BL32 companion for the chosen SPD, we expect that the SPD's
280        # Makefile would set NEED_BL32 to "yes". In this case, the build system
281        # supports two mutually exclusive options:
282        # * BL32 is built from source: then BL32_SOURCES must contain the list
283        #   of source files to build BL32
284        # * BL32 is a prebuilt binary: then BL32 must point to the image file
285        #   that will be included in the FIP
286        # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
287        # over the sources.
288endif
289
290
291################################################################################
292# Include the platform specific Makefile after the SPD Makefile (the platform
293# makefile may use all previous definitions in this file)
294################################################################################
295
296include ${PLAT_MAKEFILE_FULL}
297
298# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default
299ifndef ENABLE_PLAT_COMPAT
300ENABLE_PLAT_COMPAT := 1
301endif
302
303# Include the platform compatibility helpers for PSCI
304ifneq (${ENABLE_PLAT_COMPAT}, 0)
305include plat/compat/plat_compat.mk
306endif
307
308# Include the CPU specific operations makefile, which provides default
309# values for all CPU errata workarounds and CPU specific optimisations.
310# This can be overridden by the platform.
311include lib/cpus/cpu-ops.mk
312
313
314################################################################################
315# Check incompatible options
316################################################################################
317
318ifdef EL3_PAYLOAD_BASE
319        ifdef PRELOADED_BL33_BASE
320                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
321                incompatible build options. EL3_PAYLOAD_BASE has priority.")
322        endif
323endif
324
325ifeq (${NEED_BL33},yes)
326        ifdef EL3_PAYLOAD_BASE
327                $(warning "BL33 image is not needed when option \
328                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
329        endif
330        ifdef PRELOADED_BL33_BASE
331                $(warning "BL33 image is not needed when option \
332                PRELOADED_BL33_BASE is used and won't be added to the FIP \
333                file.")
334        endif
335endif
336
337
338################################################################################
339# Process platform overrideable behaviour
340################################################################################
341
342# Check if -pedantic option should be used
343ifeq (${DISABLE_PEDANTIC},0)
344        TF_CFLAGS	+= 	-pedantic
345endif
346
347# Using the ARM Trusted Firmware BL2 implies that a BL33 image also needs to be
348# supplied for the FIP and Certificate generation tools. This flag can be
349# overridden by the platform.
350ifdef BL2_SOURCES
351        ifdef EL3_PAYLOAD_BASE
352                # If booting an EL3 payload there is no need for a BL33 image
353                # in the FIP file.
354                NEED_BL33		:=	no
355        else
356                ifdef PRELOADED_BL33_BASE
357                        # If booting a BL33 preloaded image there is no need of
358                        # another one in the FIP file.
359                        NEED_BL33		:=	no
360                else
361                        NEED_BL33		?=	yes
362                endif
363        endif
364endif
365
366# Process TBB related flags
367ifneq (${GENERATE_COT},0)
368        # Common cert_create options
369        ifneq (${CREATE_KEYS},0)
370                $(eval CRT_ARGS += -n)
371                $(eval FWU_CRT_ARGS += -n)
372                ifneq (${SAVE_KEYS},0)
373                        $(eval CRT_ARGS += -k)
374                        $(eval FWU_CRT_ARGS += -k)
375                endif
376        endif
377        # Include TBBR makefile (unless the platform indicates otherwise)
378        ifeq (${INCLUDE_TBBR_MK},1)
379                include make_helpers/tbbr/tbbr_tools.mk
380        endif
381endif
382
383# Make sure PMF is enabled if PSCI STAT is enabled.
384ifeq (${ENABLE_PSCI_STAT},1)
385ENABLE_PMF			:= 1
386endif
387
388################################################################################
389# Auxiliary tools (fip_create, cert_create, etc)
390################################################################################
391
392# Variables for use with Certificate Generation Tool
393CRTTOOLPATH		?=	tools/cert_create
394CRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
395
396# Variables for use with Firmware Image Package
397FIPTOOLPATH		?=	tools/fip_create
398FIPTOOL			?=	${FIPTOOLPATH}/fip_create${BIN_EXT}
399
400
401################################################################################
402# Build options checks
403################################################################################
404
405$(eval $(call assert_boolean,DEBUG))
406$(eval $(call assert_boolean,NS_TIMER_SWITCH))
407$(eval $(call assert_boolean,RESET_TO_BL31))
408$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
409$(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS))
410$(eval $(call assert_boolean,ASM_ASSERTION))
411$(eval $(call assert_boolean,USE_COHERENT_MEM))
412$(eval $(call assert_boolean,DISABLE_PEDANTIC))
413$(eval $(call assert_boolean,GENERATE_COT))
414$(eval $(call assert_boolean,CREATE_KEYS))
415$(eval $(call assert_boolean,SAVE_KEYS))
416$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
417$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS))
418$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU))
419$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID))
420$(eval $(call assert_boolean,ERROR_DEPRECATED))
421$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
422$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT))
423$(eval $(call assert_boolean,PL011_GENERIC_UART))
424$(eval $(call assert_boolean,ENABLE_PMF))
425$(eval $(call assert_boolean,ENABLE_PSCI_STAT))
426$(eval $(call assert_boolean,SEPARATE_CODE_AND_RODATA))
427
428
429################################################################################
430# Add definitions to the cpp preprocessor based on the current build options.
431# This is done after including the platform specific makefile to allow the
432# platform to overwrite the default options
433################################################################################
434
435$(eval $(call add_define,PLAT_${PLAT}))
436$(eval $(call add_define,SPD_${SPD}))
437$(eval $(call add_define,NS_TIMER_SWITCH))
438$(eval $(call add_define,RESET_TO_BL31))
439$(eval $(call add_define,CTX_INCLUDE_FPREGS))
440$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS))
441$(eval $(call add_define,ARM_GIC_ARCH))
442$(eval $(call add_define,ARM_CCI_PRODUCT_ID))
443$(eval $(call add_define,ASM_ASSERTION))
444$(eval $(call add_define,LOG_LEVEL))
445$(eval $(call add_define,USE_COHERENT_MEM))
446$(eval $(call add_define,TRUSTED_BOARD_BOOT))
447$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS))
448$(eval $(call add_define,COLD_BOOT_SINGLE_CPU))
449$(eval $(call add_define,PSCI_EXTENDED_STATE_ID))
450$(eval $(call add_define,ERROR_DEPRECATED))
451$(eval $(call add_define,ENABLE_PLAT_COMPAT))
452$(eval $(call add_define,SPIN_ON_BL1_EXIT))
453$(eval $(call add_define,PL011_GENERIC_UART))
454$(eval $(call add_define,ENABLE_PMF))
455$(eval $(call add_define,ENABLE_PSCI_STAT))
456$(eval $(call add_define,SEPARATE_CODE_AND_RODATA))
457# Define the EL3_PAYLOAD_BASE flag only if it is provided.
458ifdef EL3_PAYLOAD_BASE
459        $(eval $(call add_define,EL3_PAYLOAD_BASE))
460else
461        # Define the PRELOADED_BL33_BASE flag only if it is provided and
462        # EL3_PAYLOAD_BASE is not defined, as it has priority.
463        ifdef PRELOADED_BL33_BASE
464                $(eval $(call add_define,PRELOADED_BL33_BASE))
465        endif
466endif
467
468################################################################################
469# Include BL specific makefiles
470################################################################################
471
472ifdef BL1_SOURCES
473NEED_BL1 := yes
474include bl1/bl1.mk
475endif
476
477ifdef BL2_SOURCES
478NEED_BL2 := yes
479include bl2/bl2.mk
480endif
481
482ifdef BL2U_SOURCES
483NEED_BL2U := yes
484include bl2u/bl2u.mk
485endif
486
487ifdef BL31_SOURCES
488# When booting an EL3 payload, there is no need to compile the BL31 image nor
489# put it in the FIP.
490ifndef EL3_PAYLOAD_BASE
491NEED_BL31 := yes
492include bl31/bl31.mk
493endif
494endif
495
496
497################################################################################
498# Build targets
499################################################################################
500
501.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool
502.SUFFIXES:
503
504all: msg_start
505
506msg_start:
507	@echo "Building ${PLAT}"
508
509# Check if deprecated declarations should be treated as error or not.
510ifeq (${ERROR_DEPRECATED},0)
511    TF_CFLAGS		+= 	-Wno-error=deprecated-declarations
512endif
513
514# Expand build macros for the different images
515ifeq (${NEED_BL1},yes)
516$(eval $(call MAKE_BL,1))
517endif
518
519ifeq (${NEED_BL2},yes)
520$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},tb-fw)),\
521	$(eval $(call MAKE_BL,2,tb-fw)))
522endif
523
524ifeq (${NEED_BL31},yes)
525BL31_SOURCES += ${SPD_SOURCES}
526$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},soc-fw)),\
527	$(eval $(call MAKE_BL,31,soc-fw)))
528endif
529
530# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
531# build system will call FIP_ADD_IMG to print a warning message and abort the
532# process. Note that the dependency on BL32 applies to the FIP only.
533ifeq (${NEED_BL32},yes)
534$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},tos-fw)),\
535	$(if ${BL32_SOURCES}, $(eval $(call MAKE_BL,32,tos-fw)),\
536		$(eval $(call FIP_ADD_IMG,BL32,--tos-fw))))
537endif
538
539# Add the BL33 image if required by the platform
540ifeq (${NEED_BL33},yes)
541$(eval $(call FIP_ADD_IMG,BL33,--nt-fw))
542endif
543
544ifeq (${NEED_BL2U},yes)
545BL2U_PATH	:= $(if ${BL2U},${BL2U},$(call IMG_BIN,2u))
546$(if ${BL2U}, ,$(eval $(call MAKE_BL,2u)))
547$(eval $(call FWU_FIP_ADD_PAYLOAD,${BL2U_PATH},--ap-fwu-cfg))
548endif
549
550locate-checkpatch:
551ifndef CHECKPATCH
552	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
553else
554ifeq (,$(wildcard ${CHECKPATCH}))
555	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
556endif
557endif
558
559clean:
560	@echo "  CLEAN"
561	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
562	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
563	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
564
565realclean distclean:
566	@echo "  REALCLEAN"
567	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
568	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
569	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
570	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
571
572checkcodebase:		locate-checkpatch
573	@echo "  CHECKING STYLE"
574	@if test -d .git ; then						\
575		git ls-files | grep -E -v libfdt\|stdlib\|docs\|\.md |	\
576		while read GIT_FILE ;					\
577		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
578		done ;							\
579	else								\
580		 find . -type f -not -iwholename "*.git*"		\
581		 -not -iwholename "*build*"				\
582		 -not -iwholename "*libfdt*"				\
583		 -not -iwholename "*stdlib*"				\
584		 -not -iwholename "*docs*"				\
585		 -not -iwholename "*.md"				\
586		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
587	fi
588
589checkpatch:		locate-checkpatch
590	@echo "  CHECKING STYLE"
591	${Q}git log -p ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} - || true
592
593certtool: ${CRTTOOL}
594
595.PHONY: ${CRTTOOL}
596${CRTTOOL}:
597	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH}
598	@${ECHO_BLANK_LINE}
599	@echo "Built $@ successfully"
600	@${ECHO_BLANK_LINE}
601
602ifneq (${GENERATE_COT},0)
603certificates: ${CRT_DEPS} ${CRTTOOL}
604	${Q}${CRTTOOL} ${CRT_ARGS}
605	@${ECHO_BLANK_LINE}
606	@echo "Built $@ successfully"
607	@echo "Certificates can be found in ${BUILD_PLAT}"
608	@${ECHO_BLANK_LINE}
609endif
610
611${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
612	${Q}${FIPTOOL} --dump ${FIP_ARGS} $@
613	@${ECHO_BLANK_LINE}
614	@echo "Built $@ successfully"
615	@${ECHO_BLANK_LINE}
616
617ifneq (${GENERATE_COT},0)
618fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
619	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
620	@echo
621	@echo "Built $@ successfully"
622	@echo "FWU certificates can be found in ${BUILD_PLAT}"
623	@echo
624endif
625
626${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
627	${Q}${FIPTOOL} --dump ${FWU_FIP_ARGS} $@
628	@echo
629	@echo "Built $@ successfully"
630	@echo
631
632fiptool: ${FIPTOOL}
633fip: ${BUILD_PLAT}/${FIP_NAME}
634fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
635
636.PHONY: ${FIPTOOL}
637${FIPTOOL}:
638	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH}
639
640cscope:
641	@echo "  CSCOPE"
642	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
643	${Q}cscope -b -q -k
644
645help:
646	@echo "usage: ${MAKE} PLAT=<${PLATFORM_LIST}> [OPTIONS] [TARGET]"
647	@echo ""
648	@echo "PLAT is used to specify which platform you wish to build."
649	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
650	@echo ""
651	@echo "Please refer to the User Guide for a list of all supported options."
652	@echo "Note that the build system doesn't track dependencies for build "
653	@echo "options. Therefore, if any of the build options are changed "
654	@echo "from a previous build, a clean build must be performed."
655	@echo ""
656	@echo "Supported Targets:"
657	@echo "  all            Build all individual bootloader binaries"
658	@echo "  bl1            Build the BL1 binary"
659	@echo "  bl2            Build the BL2 binary"
660	@echo "  bl2u           Build the BL2U binary"
661	@echo "  bl31           Build the BL31 binary"
662	@echo "  bl32           Build the BL32 binary"
663	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
664	@echo "  fip            Build the Firmware Image Package (FIP)"
665	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
666	@echo "  checkcodebase  Check the coding style of the entire source tree"
667	@echo "  checkpatch     Check the coding style on changes in the current"
668	@echo "                 branch against BASE_COMMIT (default origin/master)"
669	@echo "  clean          Clean the build for the selected platform"
670	@echo "  cscope         Generate cscope index"
671	@echo "  distclean      Remove all build artifacts for all platforms"
672	@echo "  certtool       Build the Certificate generation tool"
673	@echo "  fiptool        Build the Firmware Image Package(FIP) creation tool"
674	@echo ""
675	@echo "Note: most build targets require PLAT to be set to a specific platform."
676	@echo ""
677	@echo "example: build all targets for the FVP platform:"
678	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
679