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