1# 2# Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6 7# 8# Trusted Firmware Version 9# 10VERSION_MAJOR := 1 11VERSION_MINOR := 4 12 13# Default goal is build all images 14.DEFAULT_GOAL := all 15 16# Avoid any implicit propagation of command line variable definitions to 17# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 18# usage. Other command line options like "-s" are still propagated as usual. 19MAKEOVERRIDES = 20 21MAKE_HELPERS_DIRECTORY := make_helpers/ 22include ${MAKE_HELPERS_DIRECTORY}build_macros.mk 23include ${MAKE_HELPERS_DIRECTORY}build_env.mk 24 25################################################################################ 26# Default values for build configurations, and their dependencies 27################################################################################ 28 29ifdef ASM_ASSERTION 30 $(warning ASM_ASSERTION is removed, use ENABLE_ASSERTIONS instead.) 31endif 32 33include ${MAKE_HELPERS_DIRECTORY}defaults.mk 34 35# Assertions enabled for DEBUG builds by default 36ENABLE_ASSERTIONS := ${DEBUG} 37ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 38PLAT := ${DEFAULT_PLAT} 39 40################################################################################ 41# Checkpatch script options 42################################################################################ 43 44CHECKCODE_ARGS := --no-patch 45# Do not check the coding style on imported library files or documentation files 46INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 47 include/lib/libfdt \ 48 include/lib/stdlib, \ 49 $(wildcard include/lib/*))) 50INC_DIRS_TO_CHECK := $(sort $(filter-out \ 51 include/lib, \ 52 $(wildcard include/*))) 53LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 54 lib/compiler-rt \ 55 lib/libfdt% \ 56 lib/stdlib, \ 57 $(wildcard lib/*))) 58ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 59 lib \ 60 include \ 61 docs \ 62 %.md, \ 63 $(wildcard *))) 64CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 65 ${INC_DIRS_TO_CHECK} \ 66 ${INC_LIB_DIRS_TO_CHECK} \ 67 ${LIB_DIRS_TO_CHECK} 68 69 70################################################################################ 71# Process build options 72################################################################################ 73 74# Verbose flag 75ifeq (${V},0) 76 Q:=@ 77 CHECKCODE_ARGS += --no-summary --terse 78else 79 Q:= 80endif 81export Q 82 83# Process Debug flag 84$(eval $(call add_define,DEBUG)) 85ifneq (${DEBUG}, 0) 86 BUILD_TYPE := debug 87 TF_CFLAGS += -g 88 ASFLAGS += -g -Wa,--gdwarf-2 89 # Use LOG_LEVEL_INFO by default for debug builds 90 LOG_LEVEL := 40 91else 92 BUILD_TYPE := release 93 $(eval $(call add_define,NDEBUG)) 94 # Use LOG_LEVEL_NOTICE by default for release builds 95 LOG_LEVEL := 20 96endif 97 98# Default build string (git branch and commit) 99ifeq (${BUILD_STRING},) 100 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 101endif 102VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING} 103 104# The cert_create tool cannot generate certificates individually, so we use the 105# target 'certificates' to create them all 106ifneq (${GENERATE_COT},0) 107 FIP_DEPS += certificates 108 FWU_FIP_DEPS += fwu_certificates 109endif 110 111 112################################################################################ 113# Toolchain 114################################################################################ 115 116HOSTCC := gcc 117export HOSTCC 118 119CC := ${CROSS_COMPILE}gcc 120CPP := ${CROSS_COMPILE}cpp 121AS := ${CROSS_COMPILE}gcc 122AR := ${CROSS_COMPILE}ar 123LD := ${CROSS_COMPILE}ld 124OC := ${CROSS_COMPILE}objcopy 125OD := ${CROSS_COMPILE}objdump 126NM := ${CROSS_COMPILE}nm 127PP := ${CROSS_COMPILE}gcc -E 128DTC ?= dtc 129 130ifeq ($(notdir $(CC)),armclang) 131TF_CFLAGS_aarch32 = -target arm-arm-none-eabi -march=armv8-a 132TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi -march=armv8-a 133else ifneq ($(findstring clang,$(notdir $(CC))),) 134TF_CFLAGS_aarch32 = -target armv8a-none-eabi 135TF_CFLAGS_aarch64 = -target aarch64-elf 136else 137TF_CFLAGS_aarch32 = -march=armv8-a 138TF_CFLAGS_aarch64 = -march=armv8-a 139endif 140 141TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 142 143ASFLAGS_aarch32 = -march=armv8-a 144ASFLAGS_aarch64 = -march=armv8-a 145 146CPPFLAGS = ${DEFINES} ${INCLUDES} -nostdinc \ 147 -Wmissing-include-dirs -Werror 148ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 149 -D__ASSEMBLY__ -ffreestanding \ 150 -Wa,--fatal-warnings 151TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 152 -ffreestanding -fno-builtin -Wall -std=gnu99 \ 153 -Os -ffunction-sections -fdata-sections 154 155TF_LDFLAGS += --fatal-warnings -O1 156TF_LDFLAGS += --gc-sections 157TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 158 159DTC_FLAGS += -I dts -O dtb 160 161################################################################################ 162# Common sources and include directories 163################################################################################ 164include lib/compiler-rt/compiler-rt.mk 165include lib/stdlib/stdlib.mk 166 167BL_COMMON_SOURCES += common/bl_common.c \ 168 common/tf_log.c \ 169 common/tf_printf.c \ 170 common/tf_snprintf.c \ 171 common/${ARCH}/debug.S \ 172 lib/${ARCH}/cache_helpers.S \ 173 lib/${ARCH}/misc_helpers.S \ 174 plat/common/plat_log_common.c \ 175 plat/common/${ARCH}/plat_common.c \ 176 plat/common/${ARCH}/platform_helpers.S \ 177 ${COMPILER_RT_SRCS} \ 178 ${STDLIB_SRCS} 179 180INCLUDES += -Iinclude/bl1 \ 181 -Iinclude/bl31 \ 182 -Iinclude/common \ 183 -Iinclude/common/${ARCH} \ 184 -Iinclude/drivers \ 185 -Iinclude/drivers/arm \ 186 -Iinclude/drivers/auth \ 187 -Iinclude/drivers/io \ 188 -Iinclude/drivers/ti/uart \ 189 -Iinclude/lib \ 190 -Iinclude/lib/${ARCH} \ 191 -Iinclude/lib/cpus \ 192 -Iinclude/lib/cpus/${ARCH} \ 193 -Iinclude/lib/el3_runtime \ 194 -Iinclude/lib/el3_runtime/${ARCH} \ 195 -Iinclude/lib/pmf \ 196 -Iinclude/lib/psci \ 197 -Iinclude/lib/xlat_tables \ 198 -Iinclude/plat/common \ 199 -Iinclude/services \ 200 ${PLAT_INCLUDES} \ 201 ${SPD_INCLUDES} \ 202 -Iinclude/tools_share 203 204 205################################################################################ 206# Generic definitions 207################################################################################ 208 209include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 210 211BUILD_BASE := ./build 212BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE} 213 214SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 215 216# Platforms providing their own TBB makefile may override this value 217INCLUDE_TBBR_MK := 1 218 219 220################################################################################ 221# Include SPD Makefile if one has been specified 222################################################################################ 223 224ifneq (${SPD},none) 225ifeq (${ARCH},aarch32) 226 $(error "Error: SPD is incompatible with AArch32.") 227endif 228ifdef EL3_PAYLOAD_BASE 229 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 230 $(warning "The SPD and its BL32 companion will be present but ignored.") 231endif 232 # We expect to locate an spd.mk under the specified SPD directory 233 SPD_MAKE := $(wildcard services/spd/${SPD}/${SPD}.mk) 234 235 ifeq (${SPD_MAKE},) 236 $(error Error: No services/spd/${SPD}/${SPD}.mk located) 237 endif 238 $(info Including ${SPD_MAKE}) 239 include ${SPD_MAKE} 240 241 # If there's BL32 companion for the chosen SPD, we expect that the SPD's 242 # Makefile would set NEED_BL32 to "yes". In this case, the build system 243 # supports two mutually exclusive options: 244 # * BL32 is built from source: then BL32_SOURCES must contain the list 245 # of source files to build BL32 246 # * BL32 is a prebuilt binary: then BL32 must point to the image file 247 # that will be included in the FIP 248 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 249 # over the sources. 250endif 251 252################################################################################ 253# Include libraries' Makefile that are used in all BL 254################################################################################ 255 256include lib/stack_protector/stack_protector.mk 257 258 259################################################################################ 260# Include the platform specific Makefile after the SPD Makefile (the platform 261# makefile may use all previous definitions in this file) 262################################################################################ 263 264include ${PLAT_MAKEFILE_FULL} 265 266# Platform compatibility is not supported in AArch32 267ifneq (${ARCH},aarch32) 268# If the platform has not defined ENABLE_PLAT_COMPAT, then enable it by default 269ifndef ENABLE_PLAT_COMPAT 270ENABLE_PLAT_COMPAT := 1 271endif 272 273# Include the platform compatibility helpers for PSCI 274ifneq (${ENABLE_PLAT_COMPAT}, 0) 275include plat/compat/plat_compat.mk 276endif 277endif 278 279# Include the CPU specific operations makefile, which provides default 280# values for all CPU errata workarounds and CPU specific optimisations. 281# This can be overridden by the platform. 282include lib/cpus/cpu-ops.mk 283 284ifeq (${ARCH},aarch32) 285NEED_BL32 := yes 286 287################################################################################ 288# Build `AARCH32_SP` as BL32 image for AArch32 289################################################################################ 290ifneq (${AARCH32_SP},none) 291# We expect to locate an sp.mk under the specified AARCH32_SP directory 292AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 293 294ifeq (${AARCH32_SP_MAKE},) 295 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 296endif 297 298$(info Including ${AARCH32_SP_MAKE}) 299include ${AARCH32_SP_MAKE} 300endif 301 302endif 303 304################################################################################ 305# Check incompatible options 306################################################################################ 307 308ifdef EL3_PAYLOAD_BASE 309 ifdef PRELOADED_BL33_BASE 310 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 311 incompatible build options. EL3_PAYLOAD_BASE has priority.") 312 endif 313 ifneq (${GENERATE_COT},0) 314 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 315 endif 316 ifneq (${TRUSTED_BOARD_BOOT},0) 317 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 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# For AArch32, LOAD_IMAGE_V2 must be enabled. 334ifeq (${ARCH},aarch32) 335 ifeq (${LOAD_IMAGE_V2}, 0) 336 $(error "For AArch32, LOAD_IMAGE_V2 must be enabled.") 337 endif 338endif 339 340# When building for systems with hardware-assisted coherency, there's no need to 341# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 342ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 343$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 344endif 345 346################################################################################ 347# Process platform overrideable behaviour 348################################################################################ 349 350# Using the ARM Trusted Firmware BL2 implies that a BL33 image also needs to be 351# supplied for the FIP and Certificate generation tools. This flag can be 352# overridden by the platform. 353ifdef BL2_SOURCES 354 ifdef EL3_PAYLOAD_BASE 355 # If booting an EL3 payload there is no need for a BL33 image 356 # in the FIP file. 357 NEED_BL33 := no 358 else 359 ifdef PRELOADED_BL33_BASE 360 # If booting a BL33 preloaded image there is no need of 361 # another one in the FIP file. 362 NEED_BL33 := no 363 else 364 NEED_BL33 ?= yes 365 endif 366 endif 367endif 368 369# If SCP_BL2 is given, we always want FIP to include it. 370ifdef SCP_BL2 371 NEED_SCP_BL2 := yes 372endif 373 374# Process TBB related flags 375ifneq (${GENERATE_COT},0) 376 # Common cert_create options 377 ifneq (${CREATE_KEYS},0) 378 $(eval CRT_ARGS += -n) 379 $(eval FWU_CRT_ARGS += -n) 380 ifneq (${SAVE_KEYS},0) 381 $(eval CRT_ARGS += -k) 382 $(eval FWU_CRT_ARGS += -k) 383 endif 384 endif 385 # Include TBBR makefile (unless the platform indicates otherwise) 386 ifeq (${INCLUDE_TBBR_MK},1) 387 include make_helpers/tbbr/tbbr_tools.mk 388 endif 389endif 390 391ifneq (${FIP_ALIGN},0) 392FIP_ARGS += --align ${FIP_ALIGN} 393endif 394 395################################################################################ 396# Auxiliary tools (fiptool, cert_create, etc) 397################################################################################ 398 399# Variables for use with Certificate Generation Tool 400CRTTOOLPATH ?= tools/cert_create 401CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 402 403# Variables for use with Firmware Image Package 404FIPTOOLPATH ?= tools/fiptool 405FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 406 407################################################################################ 408# Include BL specific makefiles 409################################################################################ 410ifdef BL1_SOURCES 411NEED_BL1 := yes 412include bl1/bl1.mk 413endif 414 415ifdef BL2_SOURCES 416NEED_BL2 := yes 417include bl2/bl2.mk 418endif 419 420ifdef BL2U_SOURCES 421NEED_BL2U := yes 422include bl2u/bl2u.mk 423endif 424 425# For AArch32, BL31 is not currently supported. 426ifneq (${ARCH},aarch32) 427ifdef BL31_SOURCES 428# When booting an EL3 payload, there is no need to compile the BL31 image nor 429# put it in the FIP. 430ifndef EL3_PAYLOAD_BASE 431NEED_BL31 := yes 432include bl31/bl31.mk 433endif 434endif 435endif 436 437ifdef FDT_SOURCES 438NEED_FDT := yes 439endif 440 441################################################################################ 442# Build options checks 443################################################################################ 444 445$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU)) 446$(eval $(call assert_boolean,CREATE_KEYS)) 447$(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS)) 448$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS)) 449$(eval $(call assert_boolean,DEBUG)) 450$(eval $(call assert_boolean,DISABLE_PEDANTIC)) 451$(eval $(call assert_boolean,ENABLE_ASSERTIONS)) 452$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT)) 453$(eval $(call assert_boolean,ENABLE_PMF)) 454$(eval $(call assert_boolean,ENABLE_PSCI_STAT)) 455$(eval $(call assert_boolean,ENABLE_RUNTIME_INSTRUMENTATION)) 456$(eval $(call assert_boolean,ENABLE_SPE_FOR_LOWER_ELS)) 457$(eval $(call assert_boolean,ERROR_DEPRECATED)) 458$(eval $(call assert_boolean,GENERATE_COT)) 459$(eval $(call assert_boolean,HW_ASSISTED_COHERENCY)) 460$(eval $(call assert_boolean,LOAD_IMAGE_V2)) 461$(eval $(call assert_boolean,NS_TIMER_SWITCH)) 462$(eval $(call assert_boolean,PL011_GENERIC_UART)) 463$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS)) 464$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID)) 465$(eval $(call assert_boolean,RESET_TO_BL31)) 466$(eval $(call assert_boolean,SAVE_KEYS)) 467$(eval $(call assert_boolean,SEPARATE_CODE_AND_RODATA)) 468$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT)) 469$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT)) 470$(eval $(call assert_boolean,USE_COHERENT_MEM)) 471$(eval $(call assert_boolean,USE_TBBR_DEFS)) 472$(eval $(call assert_boolean,WARMBOOT_ENABLE_DCACHE_EARLY)) 473 474$(eval $(call assert_numeric,ARM_ARCH_MAJOR)) 475$(eval $(call assert_numeric,ARM_ARCH_MINOR)) 476 477################################################################################ 478# Add definitions to the cpp preprocessor based on the current build options. 479# This is done after including the platform specific makefile to allow the 480# platform to overwrite the default options 481################################################################################ 482 483$(eval $(call add_define,ARM_ARCH_MAJOR)) 484$(eval $(call add_define,ARM_ARCH_MINOR)) 485$(eval $(call add_define,ARM_GIC_ARCH)) 486$(eval $(call add_define,COLD_BOOT_SINGLE_CPU)) 487$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS)) 488$(eval $(call add_define,CTX_INCLUDE_FPREGS)) 489$(eval $(call add_define,ENABLE_ASSERTIONS)) 490$(eval $(call add_define,ENABLE_PLAT_COMPAT)) 491$(eval $(call add_define,ENABLE_PMF)) 492$(eval $(call add_define,ENABLE_PSCI_STAT)) 493$(eval $(call add_define,ENABLE_RUNTIME_INSTRUMENTATION)) 494$(eval $(call add_define,ENABLE_SPE_FOR_LOWER_ELS)) 495$(eval $(call add_define,ERROR_DEPRECATED)) 496$(eval $(call add_define,HW_ASSISTED_COHERENCY)) 497$(eval $(call add_define,LOAD_IMAGE_V2)) 498$(eval $(call add_define,LOG_LEVEL)) 499$(eval $(call add_define,NS_TIMER_SWITCH)) 500$(eval $(call add_define,PL011_GENERIC_UART)) 501$(eval $(call add_define,PLAT_${PLAT})) 502$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS)) 503$(eval $(call add_define,PSCI_EXTENDED_STATE_ID)) 504$(eval $(call add_define,RESET_TO_BL31)) 505$(eval $(call add_define,SEPARATE_CODE_AND_RODATA)) 506$(eval $(call add_define,SPD_${SPD})) 507$(eval $(call add_define,SPIN_ON_BL1_EXIT)) 508$(eval $(call add_define,TRUSTED_BOARD_BOOT)) 509$(eval $(call add_define,USE_COHERENT_MEM)) 510$(eval $(call add_define,USE_TBBR_DEFS)) 511$(eval $(call add_define,WARMBOOT_ENABLE_DCACHE_EARLY)) 512 513# Define the EL3_PAYLOAD_BASE flag only if it is provided. 514ifdef EL3_PAYLOAD_BASE 515 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 516else 517 # Define the PRELOADED_BL33_BASE flag only if it is provided and 518 # EL3_PAYLOAD_BASE is not defined, as it has priority. 519 ifdef PRELOADED_BL33_BASE 520 $(eval $(call add_define,PRELOADED_BL33_BASE)) 521 endif 522endif 523# Define the AARCH32/AARCH64 flag based on the ARCH flag 524ifeq (${ARCH},aarch32) 525 $(eval $(call add_define,AARCH32)) 526else 527 $(eval $(call add_define,AARCH64)) 528endif 529 530################################################################################ 531# Build targets 532################################################################################ 533 534.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool dtbs 535.SUFFIXES: 536 537all: msg_start 538 539msg_start: 540 @echo "Building ${PLAT}" 541 542# Check if deprecated declarations should be treated as error or not. 543ifeq (${ERROR_DEPRECATED},0) 544 TF_CFLAGS += -Wno-error=deprecated-declarations 545endif 546 547# Expand build macros for the different images 548ifeq (${NEED_BL1},yes) 549$(eval $(call MAKE_BL,1)) 550endif 551 552ifeq (${NEED_BL2},yes) 553$(if ${BL2}, $(eval $(call MAKE_TOOL_ARGS,2,${BL2},tb-fw)),\ 554 $(eval $(call MAKE_BL,2,tb-fw))) 555endif 556 557ifeq (${NEED_SCP_BL2},yes) 558$(eval $(call FIP_ADD_IMG,SCP_BL2,--scp-fw)) 559endif 560 561ifeq (${NEED_BL31},yes) 562BL31_SOURCES += ${SPD_SOURCES} 563$(if ${BL31}, $(eval $(call MAKE_TOOL_ARGS,31,${BL31},soc-fw)),\ 564 $(eval $(call MAKE_BL,31,soc-fw))) 565endif 566 567# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 568# build system will call FIP_ADD_IMG to print a warning message and abort the 569# process. Note that the dependency on BL32 applies to the FIP only. 570ifeq (${NEED_BL32},yes) 571$(if ${BL32}, $(eval $(call MAKE_TOOL_ARGS,32,${BL32},tos-fw)),\ 572 $(if ${BL32_SOURCES}, $(eval $(call MAKE_BL,32,tos-fw)),\ 573 $(eval $(call FIP_ADD_IMG,BL32,--tos-fw)))) 574endif 575 576# Add the BL33 image if required by the platform 577ifeq (${NEED_BL33},yes) 578$(eval $(call FIP_ADD_IMG,BL33,--nt-fw)) 579endif 580 581ifeq (${NEED_BL2U},yes) 582BL2U_PATH := $(if ${BL2U},${BL2U},$(call IMG_BIN,2u)) 583$(if ${BL2U}, ,$(eval $(call MAKE_BL,2u))) 584$(eval $(call FWU_FIP_ADD_PAYLOAD,${BL2U_PATH},--ap-fwu-cfg)) 585endif 586 587# Expand build macros for the different images 588ifeq (${NEED_FDT},yes) 589$(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 590$(eval $(call MAKE_FDT)) 591dtbs: $(DTBS) 592endif 593 594locate-checkpatch: 595ifndef CHECKPATCH 596 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 597else 598ifeq (,$(wildcard ${CHECKPATCH})) 599 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 600endif 601endif 602 603clean: 604 @echo " CLEAN" 605 $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 606 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 607 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 608 609realclean distclean: 610 @echo " REALCLEAN" 611 $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 612 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 613 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 614 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 615 616checkcodebase: locate-checkpatch 617 @echo " CHECKING STYLE" 618 @if test -d .git ; then \ 619 git ls-files | grep -E -v 'libfdt|stdlib|docs|\.md' | \ 620 while read GIT_FILE ; \ 621 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 622 done ; \ 623 else \ 624 find . -type f -not -iwholename "*.git*" \ 625 -not -iwholename "*build*" \ 626 -not -iwholename "*libfdt*" \ 627 -not -iwholename "*stdlib*" \ 628 -not -iwholename "*docs*" \ 629 -not -iwholename "*.md" \ 630 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 631 fi 632 633checkpatch: locate-checkpatch 634 @echo " CHECKING STYLE" 635 ${Q}git format-patch --stdout ${BASE_COMMIT}..HEAD -- ${CHECK_PATHS} | ${CHECKPATCH} - || true 636 637certtool: ${CRTTOOL} 638 639.PHONY: ${CRTTOOL} 640${CRTTOOL}: 641 ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} --no-print-directory -C ${CRTTOOLPATH} 642 @${ECHO_BLANK_LINE} 643 @echo "Built $@ successfully" 644 @${ECHO_BLANK_LINE} 645 646ifneq (${GENERATE_COT},0) 647certificates: ${CRT_DEPS} ${CRTTOOL} 648 ${Q}${CRTTOOL} ${CRT_ARGS} 649 @${ECHO_BLANK_LINE} 650 @echo "Built $@ successfully" 651 @echo "Certificates can be found in ${BUILD_PLAT}" 652 @${ECHO_BLANK_LINE} 653endif 654 655${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 656 ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 657 ${Q}${FIPTOOL} info $@ 658 @${ECHO_BLANK_LINE} 659 @echo "Built $@ successfully" 660 @${ECHO_BLANK_LINE} 661 662ifneq (${GENERATE_COT},0) 663fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 664 ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 665 @${ECHO_BLANK_LINE} 666 @echo "Built $@ successfully" 667 @echo "FWU certificates can be found in ${BUILD_PLAT}" 668 @${ECHO_BLANK_LINE} 669endif 670 671${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 672 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 673 ${Q}${FIPTOOL} info $@ 674 @${ECHO_BLANK_LINE} 675 @echo "Built $@ successfully" 676 @${ECHO_BLANK_LINE} 677 678fiptool: ${FIPTOOL} 679fip: ${BUILD_PLAT}/${FIP_NAME} 680fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 681 682.PHONY: ${FIPTOOL} 683${FIPTOOL}: 684 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${FIPTOOLPATH} 685 686cscope: 687 @echo " CSCOPE" 688 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 689 ${Q}cscope -b -q -k 690 691help: 692 @echo "usage: ${MAKE} PLAT=<${PLATFORM_LIST}> [OPTIONS] [TARGET]" 693 @echo "" 694 @echo "PLAT is used to specify which platform you wish to build." 695 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 696 @echo "" 697 @echo "Please refer to the User Guide for a list of all supported options." 698 @echo "Note that the build system doesn't track dependencies for build " 699 @echo "options. Therefore, if any of the build options are changed " 700 @echo "from a previous build, a clean build must be performed." 701 @echo "" 702 @echo "Supported Targets:" 703 @echo " all Build all individual bootloader binaries" 704 @echo " bl1 Build the BL1 binary" 705 @echo " bl2 Build the BL2 binary" 706 @echo " bl2u Build the BL2U binary" 707 @echo " bl31 Build the BL31 binary" 708 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 709 @echo " this builds secure payload specified by AARCH32_SP" 710 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 711 @echo " fip Build the Firmware Image Package (FIP)" 712 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 713 @echo " checkcodebase Check the coding style of the entire source tree" 714 @echo " checkpatch Check the coding style on changes in the current" 715 @echo " branch against BASE_COMMIT (default origin/master)" 716 @echo " clean Clean the build for the selected platform" 717 @echo " cscope Generate cscope index" 718 @echo " distclean Remove all build artifacts for all platforms" 719 @echo " certtool Build the Certificate generation tool" 720 @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 721 @echo " dtbs Build the Flattened device tree (if required for the platform)" 722 @echo "" 723 @echo "Note: most build targets require PLAT to be set to a specific platform." 724 @echo "" 725 @echo "example: build all targets for the FVP platform:" 726 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 727