xref: /rk3399_ARM-atf/Makefile (revision 9c94d3b326ad14f9a64ccdf2ec1edf0af2595d0b)
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/common			\
232				-Iinclude/common/aarch64		\
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/lib/el3_runtime		\
242				-Iinclude/lib/el3_runtime/aarch64	\
243				-Iinclude/lib/psci			\
244				-Iinclude/plat/common			\
245				-Iinclude/services			\
246				${PLAT_INCLUDES}			\
247				${SPD_INCLUDES}
248
249
250################################################################################
251# Generic definitions
252################################################################################
253
254include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
255
256BUILD_BASE		:=	./build
257BUILD_PLAT		:=	${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
258
259SPDS			:=	$(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
260
261# Platforms providing their own TBB makefile may override this value
262INCLUDE_TBBR_MK		:=	1
263
264
265################################################################################
266# Include SPD Makefile if one has been specified
267################################################################################
268
269ifneq (${SPD},none)
270ifdef EL3_PAYLOAD_BASE
271        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
272        $(warning "The SPD and its BL32 companion will be present but ignored.")
273endif
274        # We expect to locate an spd.mk under the specified SPD directory
275        SPD_MAKE	:=	$(wildcard services/spd/${SPD}/${SPD}.mk)
276
277        ifeq (${SPD_MAKE},)
278                $(error Error: No services/spd/${SPD}/${SPD}.mk located)
279        endif
280        $(info Including ${SPD_MAKE})
281        include ${SPD_MAKE}
282
283        # If there's BL32 companion for the chosen SPD, we expect that the SPD's
284        # Makefile would set NEED_BL32 to "yes". In this case, the build system
285        # supports two mutually exclusive options:
286        # * BL32 is built from source: then BL32_SOURCES must contain the list
287        #   of source files to build BL32
288        # * BL32 is a prebuilt binary: then BL32 must point to the image file
289        #   that will be included in the FIP
290        # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
291        # over the sources.
292endif
293
294
295################################################################################
296# Include the platform specific Makefile after the SPD Makefile (the platform
297# makefile may use all previous definitions in this file)
298################################################################################
299
300include ${PLAT_MAKEFILE_FULL}
301
302# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default
303ifndef ENABLE_PLAT_COMPAT
304ENABLE_PLAT_COMPAT := 1
305endif
306
307# Include the platform compatibility helpers for PSCI
308ifneq (${ENABLE_PLAT_COMPAT}, 0)
309include plat/compat/plat_compat.mk
310endif
311
312# Include the CPU specific operations makefile, which provides default
313# values for all CPU errata workarounds and CPU specific optimisations.
314# This can be overridden by the platform.
315include lib/cpus/cpu-ops.mk
316
317
318################################################################################
319# Check incompatible options
320################################################################################
321
322ifdef EL3_PAYLOAD_BASE
323        ifdef PRELOADED_BL33_BASE
324                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
325                incompatible build options. EL3_PAYLOAD_BASE has priority.")
326        endif
327endif
328
329ifeq (${NEED_BL33},yes)
330        ifdef EL3_PAYLOAD_BASE
331                $(warning "BL33 image is not needed when option \
332                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
333        endif
334        ifdef PRELOADED_BL33_BASE
335                $(warning "BL33 image is not needed when option \
336                PRELOADED_BL33_BASE is used and won't be added to the FIP \
337                file.")
338        endif
339endif
340
341
342################################################################################
343# Process platform overrideable behaviour
344################################################################################
345
346# Check if -pedantic option should be used
347ifeq (${DISABLE_PEDANTIC},0)
348        TF_CFLAGS	+= 	-pedantic
349endif
350
351# Using the ARM Trusted Firmware BL2 implies that a BL33 image also needs to be
352# supplied for the FIP and Certificate generation tools. This flag can be
353# overridden by the platform.
354ifdef BL2_SOURCES
355        ifdef EL3_PAYLOAD_BASE
356                # If booting an EL3 payload there is no need for a BL33 image
357                # in the FIP file.
358                NEED_BL33		:=	no
359        else
360                ifdef PRELOADED_BL33_BASE
361                        # If booting a BL33 preloaded image there is no need of
362                        # another one in the FIP file.
363                        NEED_BL33		:=	no
364                else
365                        NEED_BL33		?=	yes
366                endif
367        endif
368endif
369
370# Process TBB related flags
371ifneq (${GENERATE_COT},0)
372        # Common cert_create options
373        ifneq (${CREATE_KEYS},0)
374                $(eval CRT_ARGS += -n)
375                $(eval FWU_CRT_ARGS += -n)
376                ifneq (${SAVE_KEYS},0)
377                        $(eval CRT_ARGS += -k)
378                        $(eval FWU_CRT_ARGS += -k)
379                endif
380        endif
381        # Include TBBR makefile (unless the platform indicates otherwise)
382        ifeq (${INCLUDE_TBBR_MK},1)
383                include make_helpers/tbbr/tbbr_tools.mk
384        endif
385endif
386
387# Make sure PMF is enabled if PSCI STAT is enabled.
388ifeq (${ENABLE_PSCI_STAT},1)
389ENABLE_PMF			:= 1
390endif
391
392################################################################################
393# Auxiliary tools (fiptool, cert_create, etc)
394################################################################################
395
396# Variables for use with Certificate Generation Tool
397CRTTOOLPATH		?=	tools/cert_create
398CRTTOOL			?=	${CRTTOOLPATH}/cert_create${BIN_EXT}
399
400# Variables for use with Firmware Image Package
401FIPTOOLPATH		?=	tools/fiptool
402FIPTOOL			?=	${FIPTOOLPATH}/fiptool${BIN_EXT}
403
404
405################################################################################
406# Build options checks
407################################################################################
408
409$(eval $(call assert_boolean,DEBUG))
410$(eval $(call assert_boolean,NS_TIMER_SWITCH))
411$(eval $(call assert_boolean,RESET_TO_BL31))
412$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
413$(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS))
414$(eval $(call assert_boolean,ASM_ASSERTION))
415$(eval $(call assert_boolean,USE_COHERENT_MEM))
416$(eval $(call assert_boolean,DISABLE_PEDANTIC))
417$(eval $(call assert_boolean,GENERATE_COT))
418$(eval $(call assert_boolean,CREATE_KEYS))
419$(eval $(call assert_boolean,SAVE_KEYS))
420$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
421$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS))
422$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU))
423$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID))
424$(eval $(call assert_boolean,ERROR_DEPRECATED))
425$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
426$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT))
427$(eval $(call assert_boolean,PL011_GENERIC_UART))
428$(eval $(call assert_boolean,ENABLE_PMF))
429$(eval $(call assert_boolean,ENABLE_PSCI_STAT))
430$(eval $(call assert_boolean,SEPARATE_CODE_AND_RODATA))
431
432
433################################################################################
434# Add definitions to the cpp preprocessor based on the current build options.
435# This is done after including the platform specific makefile to allow the
436# platform to overwrite the default options
437################################################################################
438
439$(eval $(call add_define,PLAT_${PLAT}))
440$(eval $(call add_define,SPD_${SPD}))
441$(eval $(call add_define,NS_TIMER_SWITCH))
442$(eval $(call add_define,RESET_TO_BL31))
443$(eval $(call add_define,CTX_INCLUDE_FPREGS))
444$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS))
445$(eval $(call add_define,ARM_GIC_ARCH))
446$(eval $(call add_define,ARM_CCI_PRODUCT_ID))
447$(eval $(call add_define,ASM_ASSERTION))
448$(eval $(call add_define,LOG_LEVEL))
449$(eval $(call add_define,USE_COHERENT_MEM))
450$(eval $(call add_define,TRUSTED_BOARD_BOOT))
451$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS))
452$(eval $(call add_define,COLD_BOOT_SINGLE_CPU))
453$(eval $(call add_define,PSCI_EXTENDED_STATE_ID))
454$(eval $(call add_define,ERROR_DEPRECATED))
455$(eval $(call add_define,ENABLE_PLAT_COMPAT))
456$(eval $(call add_define,SPIN_ON_BL1_EXIT))
457$(eval $(call add_define,PL011_GENERIC_UART))
458$(eval $(call add_define,ENABLE_PMF))
459$(eval $(call add_define,ENABLE_PSCI_STAT))
460$(eval $(call add_define,SEPARATE_CODE_AND_RODATA))
461# Define the EL3_PAYLOAD_BASE flag only if it is provided.
462ifdef EL3_PAYLOAD_BASE
463        $(eval $(call add_define,EL3_PAYLOAD_BASE))
464else
465        # Define the PRELOADED_BL33_BASE flag only if it is provided and
466        # EL3_PAYLOAD_BASE is not defined, as it has priority.
467        ifdef PRELOADED_BL33_BASE
468                $(eval $(call add_define,PRELOADED_BL33_BASE))
469        endif
470endif
471
472################################################################################
473# Include BL specific makefiles
474################################################################################
475
476ifdef BL1_SOURCES
477NEED_BL1 := yes
478include bl1/bl1.mk
479endif
480
481ifdef BL2_SOURCES
482NEED_BL2 := yes
483include bl2/bl2.mk
484endif
485
486ifdef BL2U_SOURCES
487NEED_BL2U := yes
488include bl2u/bl2u.mk
489endif
490
491ifdef BL31_SOURCES
492# When booting an EL3 payload, there is no need to compile the BL31 image nor
493# put it in the FIP.
494ifndef EL3_PAYLOAD_BASE
495NEED_BL31 := yes
496include bl31/bl31.mk
497endif
498endif
499
500
501################################################################################
502# Build targets
503################################################################################
504
505.PHONY:	all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool
506.SUFFIXES:
507
508all: msg_start
509
510msg_start:
511	@echo "Building ${PLAT}"
512
513# Check if deprecated declarations should be treated as error or not.
514ifeq (${ERROR_DEPRECATED},0)
515    TF_CFLAGS		+= 	-Wno-error=deprecated-declarations
516endif
517
518# Expand build macros for the different images
519ifeq (${NEED_BL1},yes)
520$(eval $(call MAKE_BL,1))
521endif
522
523ifeq (${NEED_BL2},yes)
524$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},tb-fw)),\
525	$(eval $(call MAKE_BL,2,tb-fw)))
526endif
527
528ifeq (${NEED_BL31},yes)
529BL31_SOURCES += ${SPD_SOURCES}
530$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},soc-fw)),\
531	$(eval $(call MAKE_BL,31,soc-fw)))
532endif
533
534# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
535# build system will call FIP_ADD_IMG to print a warning message and abort the
536# process. Note that the dependency on BL32 applies to the FIP only.
537ifeq (${NEED_BL32},yes)
538$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},tos-fw)),\
539	$(if ${BL32_SOURCES}, $(eval $(call MAKE_BL,32,tos-fw)),\
540		$(eval $(call FIP_ADD_IMG,BL32,--tos-fw))))
541endif
542
543# Add the BL33 image if required by the platform
544ifeq (${NEED_BL33},yes)
545$(eval $(call FIP_ADD_IMG,BL33,--nt-fw))
546endif
547
548ifeq (${NEED_BL2U},yes)
549BL2U_PATH	:= $(if ${BL2U},${BL2U},$(call IMG_BIN,2u))
550$(if ${BL2U}, ,$(eval $(call MAKE_BL,2u)))
551$(eval $(call FWU_FIP_ADD_PAYLOAD,${BL2U_PATH},--ap-fwu-cfg))
552endif
553
554locate-checkpatch:
555ifndef CHECKPATCH
556	$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
557else
558ifeq (,$(wildcard ${CHECKPATCH}))
559	$(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
560endif
561endif
562
563clean:
564	@echo "  CLEAN"
565	$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
566	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
567	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
568
569realclean distclean:
570	@echo "  REALCLEAN"
571	$(call SHELL_REMOVE_DIR,${BUILD_BASE})
572	$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
573	${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
574	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
575
576checkcodebase:		locate-checkpatch
577	@echo "  CHECKING STYLE"
578	@if test -d .git ; then						\
579		git ls-files | grep -E -v libfdt\|stdlib\|docs\|\.md |	\
580		while read GIT_FILE ;					\
581		do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ;	\
582		done ;							\
583	else								\
584		 find . -type f -not -iwholename "*.git*"		\
585		 -not -iwholename "*build*"				\
586		 -not -iwholename "*libfdt*"				\
587		 -not -iwholename "*stdlib*"				\
588		 -not -iwholename "*docs*"				\
589		 -not -iwholename "*.md"				\
590		 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ;	\
591	fi
592
593checkpatch:		locate-checkpatch
594	@echo "  CHECKING STYLE"
595	${Q}git log -p ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} - || true
596
597certtool: ${CRTTOOL}
598
599.PHONY: ${CRTTOOL}
600${CRTTOOL}:
601	${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH}
602	@${ECHO_BLANK_LINE}
603	@echo "Built $@ successfully"
604	@${ECHO_BLANK_LINE}
605
606ifneq (${GENERATE_COT},0)
607certificates: ${CRT_DEPS} ${CRTTOOL}
608	${Q}${CRTTOOL} ${CRT_ARGS}
609	@${ECHO_BLANK_LINE}
610	@echo "Built $@ successfully"
611	@echo "Certificates can be found in ${BUILD_PLAT}"
612	@${ECHO_BLANK_LINE}
613endif
614
615${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
616	${Q}${FIPTOOL} create ${FIP_ARGS} $@
617	${Q}${FIPTOOL} info $@
618	@${ECHO_BLANK_LINE}
619	@echo "Built $@ successfully"
620	@${ECHO_BLANK_LINE}
621
622ifneq (${GENERATE_COT},0)
623fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
624	${Q}${CRTTOOL} ${FWU_CRT_ARGS}
625	@echo
626	@echo "Built $@ successfully"
627	@echo "FWU certificates can be found in ${BUILD_PLAT}"
628	@echo
629endif
630
631${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
632	${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
633	${Q}${FIPTOOL} info $@
634	@echo
635	@echo "Built $@ successfully"
636	@echo
637
638fiptool: ${FIPTOOL}
639fip: ${BUILD_PLAT}/${FIP_NAME}
640fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
641
642.PHONY: ${FIPTOOL}
643${FIPTOOL}:
644	${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${FIPTOOLPATH}
645
646cscope:
647	@echo "  CSCOPE"
648	${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
649	${Q}cscope -b -q -k
650
651help:
652	@echo "usage: ${MAKE} PLAT=<${PLATFORM_LIST}> [OPTIONS] [TARGET]"
653	@echo ""
654	@echo "PLAT is used to specify which platform you wish to build."
655	@echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
656	@echo ""
657	@echo "Please refer to the User Guide for a list of all supported options."
658	@echo "Note that the build system doesn't track dependencies for build "
659	@echo "options. Therefore, if any of the build options are changed "
660	@echo "from a previous build, a clean build must be performed."
661	@echo ""
662	@echo "Supported Targets:"
663	@echo "  all            Build all individual bootloader binaries"
664	@echo "  bl1            Build the BL1 binary"
665	@echo "  bl2            Build the BL2 binary"
666	@echo "  bl2u           Build the BL2U binary"
667	@echo "  bl31           Build the BL31 binary"
668	@echo "  bl32           Build the BL32 binary"
669	@echo "  certificates   Build the certificates (requires 'GENERATE_COT=1')"
670	@echo "  fip            Build the Firmware Image Package (FIP)"
671	@echo "  fwu_fip        Build the FWU Firmware Image Package (FIP)"
672	@echo "  checkcodebase  Check the coding style of the entire source tree"
673	@echo "  checkpatch     Check the coding style on changes in the current"
674	@echo "                 branch against BASE_COMMIT (default origin/master)"
675	@echo "  clean          Clean the build for the selected platform"
676	@echo "  cscope         Generate cscope index"
677	@echo "  distclean      Remove all build artifacts for all platforms"
678	@echo "  certtool       Build the Certificate generation tool"
679	@echo "  fiptool        Build the Firmware Image Package(FIP) creation tool"
680	@echo ""
681	@echo "Note: most build targets require PLAT to be set to a specific platform."
682	@echo ""
683	@echo "example: build all targets for the FVP platform:"
684	@echo "  CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
685