1# 2# Copyright (c) 2013-2020, 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 := 2 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 29include ${MAKE_HELPERS_DIRECTORY}defaults.mk 30 31# Assertions enabled for DEBUG builds by default 32ENABLE_ASSERTIONS := ${DEBUG} 33ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 34PLAT := ${DEFAULT_PLAT} 35 36################################################################################ 37# Checkpatch script options 38################################################################################ 39 40CHECKCODE_ARGS := --no-patch 41# Do not check the coding style on imported library files or documentation files 42INC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \ 43 include/drivers/arm/cryptocell, \ 44 $(wildcard include/drivers/arm/*))) 45INC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h 46INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 47 include/drivers/arm, \ 48 $(wildcard include/drivers/*))) 49INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 50 include/lib/libfdt \ 51 include/lib/libc, \ 52 $(wildcard include/lib/*))) 53INC_DIRS_TO_CHECK := $(sort $(filter-out \ 54 include/lib \ 55 include/drivers, \ 56 $(wildcard include/*))) 57LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 58 lib/compiler-rt \ 59 lib/libfdt% \ 60 lib/libc, \ 61 $(wildcard lib/*))) 62ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 63 lib \ 64 include \ 65 docs \ 66 %.rst, \ 67 $(wildcard *))) 68CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 69 ${INC_DIRS_TO_CHECK} \ 70 ${INC_LIB_DIRS_TO_CHECK} \ 71 ${LIB_DIRS_TO_CHECK} \ 72 ${INC_DRV_DIRS_TO_CHECK} \ 73 ${INC_ARM_DIRS_TO_CHECK} 74 75 76################################################################################ 77# Process build options 78################################################################################ 79 80# Verbose flag 81ifeq (${V},0) 82 Q:=@ 83 ECHO:=@echo 84 CHECKCODE_ARGS += --no-summary --terse 85else 86 Q:= 87 ECHO:=$(ECHO_QUIET) 88endif 89 90ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 91 Q:=@ 92 ECHO:=$(ECHO_QUIET) 93endif 94 95export Q ECHO 96 97# The cert_create tool cannot generate certificates individually, so we use the 98# target 'certificates' to create them all 99ifneq (${GENERATE_COT},0) 100 FIP_DEPS += certificates 101 FWU_FIP_DEPS += fwu_certificates 102endif 103 104# Process BRANCH_PROTECTION value and set 105# Pointer Authentication and Branch Target Identification flags 106ifeq (${BRANCH_PROTECTION},0) 107 # Default value turns off all types of branch protection 108 BP_OPTION := none 109else ifneq (${ARCH},aarch64) 110 $(error BRANCH_PROTECTION requires AArch64) 111else ifeq (${BRANCH_PROTECTION},1) 112 # Enables all types of branch protection features 113 BP_OPTION := standard 114 ENABLE_BTI := 1 115 ENABLE_PAUTH := 1 116else ifeq (${BRANCH_PROTECTION},2) 117 # Return address signing to its standard level 118 BP_OPTION := pac-ret 119 ENABLE_PAUTH := 1 120else ifeq (${BRANCH_PROTECTION},3) 121 # Extend the signing to include leaf functions 122 BP_OPTION := pac-ret+leaf 123 ENABLE_PAUTH := 1 124else ifeq (${BRANCH_PROTECTION},4) 125 # Turn on branch target identification mechanism 126 BP_OPTION := bti 127 ENABLE_BTI := 1 128else 129 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 130endif 131 132# USE_SPINLOCK_CAS requires AArch64 build 133ifeq (${USE_SPINLOCK_CAS},1) 134ifneq (${ARCH},aarch64) 135 $(error USE_SPINLOCK_CAS requires AArch64) 136else 137 $(info USE_SPINLOCK_CAS is an experimental feature) 138endif 139endif 140 141# USE_DEBUGFS experimental feature recommended only in debug builds 142ifeq (${USE_DEBUGFS},1) 143ifeq (${DEBUG},1) 144 $(warning DEBUGFS experimental feature is enabled.) 145else 146 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 147endif 148endif 149 150ifneq (${DECRYPTION_SUPPORT},none) 151ENC_ARGS += -f ${FW_ENC_STATUS} 152ENC_ARGS += -k ${ENC_KEY} 153ENC_ARGS += -n ${ENC_NONCE} 154FIP_DEPS += enctool 155FWU_FIP_DEPS += enctool 156endif 157 158################################################################################ 159# Toolchain 160################################################################################ 161 162HOSTCC := gcc 163export HOSTCC 164 165CC := ${CROSS_COMPILE}gcc 166CPP := ${CROSS_COMPILE}cpp 167AS := ${CROSS_COMPILE}gcc 168AR := ${CROSS_COMPILE}ar 169LINKER := ${CROSS_COMPILE}ld 170OC := ${CROSS_COMPILE}objcopy 171OD := ${CROSS_COMPILE}objdump 172NM := ${CROSS_COMPILE}nm 173PP := ${CROSS_COMPILE}gcc -E 174DTC := dtc 175 176# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 177ifneq ($(strip $(wildcard ${LD}.bfd) \ 178 $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 179LINKER := ${LINKER}.bfd 180endif 181 182ifeq (${ARM_ARCH_MAJOR},7) 183target32-directive = -target arm-none-eabi 184# Will set march32-directive from platform configuration 185else 186target32-directive = -target armv8a-none-eabi 187 188# Set the compiler's target architecture profile based on 189# ARM_ARCH_MAJOR ARM_ARCH_MINOR options 190ifeq (${ARM_ARCH_MINOR},0) 191march32-directive = -march=armv${ARM_ARCH_MAJOR}-a 192march64-directive = -march=armv${ARM_ARCH_MAJOR}-a 193else 194march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 195march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 196endif 197endif 198 199# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards 200ifeq ($(ARCH), aarch64) 201# Check if revision is greater than or equal to 8.5 202ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 203mem_tag_arch_support = yes 204endif 205endif 206 207# Get architecture feature modifiers 208arch-features = ${ARM_ARCH_FEATURE} 209 210# Enable required options for memory stack tagging. 211# Currently, these options are enabled only for clang and armclang compiler. 212ifeq (${SUPPORT_STACK_MEMTAG},yes) 213ifdef mem_tag_arch_support 214# Check for armclang and clang compilers 215ifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 216# Add "memtag" architecture feature modifier if not specified 217ifeq ( ,$(findstring memtag,$(arch-features))) 218arch-features := $(arch-features)+memtag 219endif # memtag 220ifeq ($(notdir $(CC)),armclang) 221TF_CFLAGS += -mmemtag-stack 222else ifeq ($(notdir $(CC)),clang) 223TF_CFLAGS += -fsanitize=memtag 224endif # armclang 225endif # armclang clang 226else 227$(error "Error: stack memory tagging is not supported for architecture \ 228 ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 229endif # mem_tag_arch_support 230endif # SUPPORT_STACK_MEMTAG 231 232# Set the compiler's architecture feature modifiers 233ifneq ($(arch-features), none) 234# Strip "none+" from arch-features 235arch-features := $(subst none+,,$(arch-features)) 236ifeq ($(ARCH), aarch32) 237march32-directive := $(march32-directive)+$(arch-features) 238else 239march64-directive := $(march64-directive)+$(arch-features) 240endif 241# Print features 242$(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 243endif # arch-features 244 245ifneq ($(findstring armclang,$(notdir $(CC))),) 246TF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive) 247TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi $(march64-directive) 248LD = $(LINKER) 249AS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 250CPP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 251PP = $(CC) -E $(TF_CFLAGS_$(ARCH)) 252else ifneq ($(findstring clang,$(notdir $(CC))),) 253CLANG_CCDIR = $(if $(filter-out ./,$(dir $(CC))),$(dir $(CC)),) 254TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) 255TF_CFLAGS_aarch64 = -target aarch64-elf $(march64-directive) 256LD = $(CLANG_CCDIR)ld.lld 257ifeq (, $(shell which $(LD))) 258$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker") 259endif 260AS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 261CPP = $(CC) -E 262PP = $(CC) -E 263else ifneq ($(findstring gcc,$(notdir $(CC))),) 264TF_CFLAGS_aarch32 = $(march32-directive) 265TF_CFLAGS_aarch64 = $(march64-directive) 266ifeq ($(ENABLE_LTO),1) 267 # Enable LTO only for aarch64 268 ifeq (${ARCH},aarch64) 269 LTO_CFLAGS = -flto 270 # Use gcc as a wrapper for the ld, recommended for LTO 271 LINKER := ${CROSS_COMPILE}gcc 272 endif 273endif 274LD = $(LINKER) 275else 276TF_CFLAGS_aarch32 = $(march32-directive) 277TF_CFLAGS_aarch64 = $(march64-directive) 278LD = $(LINKER) 279endif 280 281# Process Debug flag 282$(eval $(call add_define,DEBUG)) 283ifneq (${DEBUG}, 0) 284 BUILD_TYPE := debug 285 TF_CFLAGS += -g 286 287 ifneq ($(findstring clang,$(notdir $(CC))),) 288 ASFLAGS += -g 289 else 290 ASFLAGS += -g -Wa,--gdwarf-2 291 endif 292 293 # Use LOG_LEVEL_INFO by default for debug builds 294 LOG_LEVEL := 40 295else 296 BUILD_TYPE := release 297 # Use LOG_LEVEL_NOTICE by default for release builds 298 LOG_LEVEL := 20 299endif 300 301# Default build string (git branch and commit) 302ifeq (${BUILD_STRING},) 303 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 304endif 305VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING} 306 307ifeq (${AARCH32_INSTRUCTION_SET},A32) 308TF_CFLAGS_aarch32 += -marm 309else ifeq (${AARCH32_INSTRUCTION_SET},T32) 310TF_CFLAGS_aarch32 += -mthumb 311else 312$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 313endif 314 315TF_CFLAGS_aarch32 += -mno-unaligned-access 316TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 317 318ifneq (${BP_OPTION},none) 319TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 320endif 321 322ASFLAGS_aarch32 = $(march32-directive) 323ASFLAGS_aarch64 = $(march64-directive) 324 325# General warnings 326WARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 327 -Wdisabled-optimization -Wvla -Wshadow \ 328 -Wno-unused-parameter -Wredundant-decls 329 330# Additional warnings 331# Level 1 332WARNING1 := -Wextra 333WARNING1 += -Wmissing-format-attribute 334WARNING1 += -Wmissing-prototypes 335WARNING1 += -Wold-style-definition 336 337# Level 2 338WARNING2 := -Waggregate-return 339WARNING2 += -Wcast-align 340WARNING2 += -Wnested-externs 341 342WARNING3 := -Wbad-function-cast 343WARNING3 += -Wcast-qual 344WARNING3 += -Wconversion 345WARNING3 += -Wpacked 346WARNING3 += -Wpointer-arith 347WARNING3 += -Wswitch-default 348 349ifeq (${W},1) 350WARNINGS += $(WARNING1) 351else ifeq (${W},2) 352WARNINGS += $(WARNING1) $(WARNING2) 353else ifeq (${W},3) 354WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 355endif 356 357# Compiler specific warnings 358ifeq ($(findstring clang,$(notdir $(CC))),) 359# not using clang 360WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 361 -Wpacked-bitfield-compat -Wshift-overflow=2 \ 362 -Wlogical-op 363else 364# using clang 365WARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 366 -Wlogical-op-parentheses 367endif 368 369ifneq (${E},0) 370ERRORS := -Werror 371endif 372 373CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 374 $(ERRORS) $(WARNINGS) 375ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 376 -ffreestanding -Wa,--fatal-warnings 377TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 378 -ffunction-sections -fdata-sections \ 379 -ffreestanding -fno-builtin -fno-common \ 380 -Os -std=gnu99 381 382ifeq (${SANITIZE_UB},on) 383TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 384endif 385ifeq (${SANITIZE_UB},trap) 386TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 387 -fsanitize-undefined-trap-on-error 388endif 389 390GCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 391 392# LD = armlink 393ifneq ($(findstring armlink,$(notdir $(LD))),) 394TF_LDFLAGS += --diag_error=warning --lto_level=O1 395TF_LDFLAGS += --remove --info=unused,unusedsymbols 396TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 397 398# LD = gcc (used when GCC LTO is enabled) 399else ifneq ($(findstring gcc,$(notdir $(LD))),) 400# Pass ld options with Wl or Xlinker switches 401TF_LDFLAGS += -Wl,--fatal-warnings -O1 402TF_LDFLAGS += -Wl,--gc-sections 403ifeq ($(ENABLE_LTO),1) 404 ifeq (${ARCH},aarch64) 405 TF_LDFLAGS += -flto -fuse-linker-plugin 406 endif 407endif 408# GCC automatically adds fix-cortex-a53-843419 flag when used to link 409# which breaks some builds, so disable if errata fix is not explicitly enabled 410ifneq (${ERRATA_A53_843419},1) 411 TF_LDFLAGS += -mno-fix-cortex-a53-843419 412endif 413TF_LDFLAGS += -nostdlib 414TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 415 416# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 417else 418TF_LDFLAGS += --fatal-warnings -O1 419TF_LDFLAGS += --gc-sections 420# ld.lld doesn't recognize the errata flags, 421# therefore don't add those in that case 422ifeq ($(findstring ld.lld,$(notdir $(LD))),) 423TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 424endif 425endif 426 427DTC_FLAGS += -I dts -O dtb 428DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 429 -x assembler-with-cpp $(DEFINES) 430 431ifeq ($(MEASURED_BOOT),1) 432DTC_CPPFLAGS += -DMEASURED_BOOT -DBL2_HASH_SIZE=${TCG_DIGEST_SIZE} 433endif 434 435################################################################################ 436# Common sources and include directories 437################################################################################ 438include lib/compiler-rt/compiler-rt.mk 439 440BL_COMMON_SOURCES += common/bl_common.c \ 441 common/tf_log.c \ 442 common/${ARCH}/debug.S \ 443 drivers/console/multi_console.c \ 444 lib/${ARCH}/cache_helpers.S \ 445 lib/${ARCH}/misc_helpers.S \ 446 plat/common/plat_bl_common.c \ 447 plat/common/plat_log_common.c \ 448 plat/common/${ARCH}/plat_common.c \ 449 plat/common/${ARCH}/platform_helpers.S \ 450 ${COMPILER_RT_SRCS} 451 452ifeq ($(notdir $(CC)),armclang) 453BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 454endif 455 456ifeq (${SANITIZE_UB},on) 457BL_COMMON_SOURCES += plat/common/ubsan.c 458endif 459 460INCLUDES += -Iinclude \ 461 -Iinclude/arch/${ARCH} \ 462 -Iinclude/lib/cpus/${ARCH} \ 463 -Iinclude/lib/el3_runtime/${ARCH} \ 464 ${PLAT_INCLUDES} \ 465 ${SPD_INCLUDES} 466 467include common/backtrace/backtrace.mk 468 469################################################################################ 470# Generic definitions 471################################################################################ 472 473include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 474 475ifeq (${BUILD_BASE},) 476 BUILD_BASE := ./build 477endif 478BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 479 480SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 481 482# Platforms providing their own TBB makefile may override this value 483INCLUDE_TBBR_MK := 1 484 485 486################################################################################ 487# Include SPD Makefile if one has been specified 488################################################################################ 489 490ifneq (${SPD},none) 491 ifeq (${ARCH},aarch32) 492 $(error "Error: SPD is incompatible with AArch32.") 493 endif 494 495 ifdef EL3_PAYLOAD_BASE 496 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 497 $(warning "The SPD and its BL32 companion will be present but ignored.") 498 endif 499 500 ifeq (${SPD},spmd) 501 $(warning "SPMD is an experimental feature") 502 # SPMD is located in std_svc directory 503 SPD_DIR := std_svc 504 505 ifeq ($(SPMD_SPM_AT_SEL2),1) 506 ifeq ($(CTX_INCLUDE_EL2_REGS),0) 507 $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option) 508 endif 509 endif 510 511 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 512 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 513 endif 514 else 515 # All other SPDs in spd directory 516 SPD_DIR := spd 517 endif 518 519 # We expect to locate an spd.mk under the specified SPD directory 520 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 521 522 ifeq (${SPD_MAKE},) 523 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 524 endif 525 $(info Including ${SPD_MAKE}) 526 include ${SPD_MAKE} 527 528 # If there's BL32 companion for the chosen SPD, we expect that the SPD's 529 # Makefile would set NEED_BL32 to "yes". In this case, the build system 530 # supports two mutually exclusive options: 531 # * BL32 is built from source: then BL32_SOURCES must contain the list 532 # of source files to build BL32 533 # * BL32 is a prebuilt binary: then BL32 must point to the image file 534 # that will be included in the FIP 535 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 536 # over the sources. 537endif 538 539################################################################################ 540# Include the platform specific Makefile after the SPD Makefile (the platform 541# makefile may use all previous definitions in this file) 542################################################################################ 543 544include ${PLAT_MAKEFILE_FULL} 545 546$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 547 548ifeq (${ARM_ARCH_MAJOR},7) 549include make_helpers/armv7-a-cpus.mk 550endif 551 552PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 553ifneq ($(PIE_FOUND),) 554 TF_CFLAGS += -fno-PIE 555endif 556 557ifneq ($(findstring gcc,$(notdir $(LD))),) 558 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 559else 560 PIE_LDFLAGS += -pie --no-dynamic-linker 561endif 562 563ifeq ($(ENABLE_PIE),1) 564ifeq ($(BL2_AT_EL3),1) 565ifneq ($(BL2_IN_XIP_MEM),1) 566 BL2_CFLAGS += -fpie 567 BL2_LDFLAGS += $(PIE_LDFLAGS) 568endif 569endif 570 BL31_CFLAGS += -fpie 571 BL31_LDFLAGS += $(PIE_LDFLAGS) 572ifeq ($(ARCH),aarch64) 573 BL32_CFLAGS += -fpie 574 BL32_LDFLAGS += $(PIE_LDFLAGS) 575endif 576endif 577 578ifeq (${ARCH},aarch64) 579BL1_CPPFLAGS += -DIMAGE_AT_EL3 580ifeq ($(BL2_AT_EL3),1) 581BL2_CPPFLAGS += -DIMAGE_AT_EL3 582else 583BL2_CPPFLAGS += -DIMAGE_AT_EL1 584endif 585BL2U_CPPFLAGS += -DIMAGE_AT_EL1 586BL31_CPPFLAGS += -DIMAGE_AT_EL3 587BL32_CPPFLAGS += -DIMAGE_AT_EL1 588endif 589 590# Include the CPU specific operations makefile, which provides default 591# values for all CPU errata workarounds and CPU specific optimisations. 592# This can be overridden by the platform. 593include lib/cpus/cpu-ops.mk 594 595ifeq (${ARCH},aarch32) 596NEED_BL32 := yes 597 598################################################################################ 599# Build `AARCH32_SP` as BL32 image for AArch32 600################################################################################ 601ifneq (${AARCH32_SP},none) 602# We expect to locate an sp.mk under the specified AARCH32_SP directory 603AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 604 605ifeq (${AARCH32_SP_MAKE},) 606 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 607endif 608 609$(info Including ${AARCH32_SP_MAKE}) 610include ${AARCH32_SP_MAKE} 611endif 612 613endif 614 615################################################################################ 616# Include libc if not overridden 617################################################################################ 618ifeq (${OVERRIDE_LIBC},0) 619include lib/libc/libc.mk 620endif 621 622################################################################################ 623# Check incompatible options 624################################################################################ 625 626ifdef EL3_PAYLOAD_BASE 627 ifdef PRELOADED_BL33_BASE 628 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 629 incompatible build options. EL3_PAYLOAD_BASE has priority.") 630 endif 631 ifneq (${GENERATE_COT},0) 632 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 633 endif 634 ifneq (${TRUSTED_BOARD_BOOT},0) 635 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 636 endif 637endif 638 639ifeq (${NEED_BL33},yes) 640 ifdef EL3_PAYLOAD_BASE 641 $(warning "BL33 image is not needed when option \ 642 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 643 endif 644 ifdef PRELOADED_BL33_BASE 645 $(warning "BL33 image is not needed when option \ 646 PRELOADED_BL33_BASE is used and won't be added to the FIP \ 647 file.") 648 endif 649endif 650 651# When building for systems with hardware-assisted coherency, there's no need to 652# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 653ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 654$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 655endif 656 657#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1. 658ifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1) 659$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled") 660endif 661 662# For RAS_EXTENSION, require that EAs are handled in EL3 first 663ifeq ($(RAS_EXTENSION),1) 664 ifneq ($(HANDLE_EA_EL3_FIRST),1) 665 $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1) 666 endif 667endif 668 669# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled 670ifeq ($(FAULT_INJECTION_SUPPORT),1) 671 ifneq ($(RAS_EXTENSION),1) 672 $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) 673 endif 674endif 675 676# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 677ifeq ($(DYN_DISABLE_AUTH), 1) 678 ifeq (${TRUSTED_BOARD_BOOT}, 0) 679 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.") 680 endif 681endif 682 683# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 684ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 685$(error "SDEI_IN_FCONF is an experimental feature and is only supported when \ 686 SDEI_SUPPORT is enabled") 687endif 688 689ifeq ($(COT_DESC_IN_DTB),1) 690 $(info CoT in device tree is an experimental feature) 691endif 692 693# If pointer authentication is used in the firmware, make sure that all the 694# registers associated to it are also saved and restored. 695# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 696ifeq ($(ENABLE_PAUTH),1) 697 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 698 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 699 endif 700endif 701 702ifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 703 ifneq (${ARCH},aarch64) 704 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 705 else 706 $(info CTX_INCLUDE_PAUTH_REGS is an experimental feature) 707 endif 708endif 709 710ifeq ($(ENABLE_PAUTH),1) 711 $(info Pointer Authentication is an experimental feature) 712endif 713 714ifeq ($(ENABLE_BTI),1) 715 $(info Branch Protection is an experimental feature) 716endif 717 718ifeq ($(CTX_INCLUDE_MTE_REGS),1) 719 ifneq (${ARCH},aarch64) 720 $(error CTX_INCLUDE_MTE_REGS requires AArch64) 721 else 722 $(info CTX_INCLUDE_MTE_REGS is an experimental feature) 723 endif 724endif 725 726ifeq ($(MEASURED_BOOT),1) 727 ifneq (${TRUSTED_BOARD_BOOT},1) 728 $(error MEASURED_BOOT requires TRUSTED_BOARD_BOOT=1) 729 else 730 $(info MEASURED_BOOT is an experimental feature) 731 endif 732endif 733 734ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 735 ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 736 $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2") 737 endif 738endif 739 740ifneq (${DECRYPTION_SUPPORT},none) 741 ifeq (${TRUSTED_BOARD_BOOT}, 0) 742 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set) 743 else 744 $(info DECRYPTION_SUPPORT is an experimental feature) 745 endif 746endif 747 748################################################################################ 749# Process platform overrideable behaviour 750################################################################################ 751 752# Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 753# Certificate generation tools. This flag can be overridden by the platform. 754ifdef BL2_SOURCES 755 ifdef EL3_PAYLOAD_BASE 756 # If booting an EL3 payload there is no need for a BL33 image 757 # in the FIP file. 758 NEED_BL33 := no 759 else 760 ifdef PRELOADED_BL33_BASE 761 # If booting a BL33 preloaded image there is no need of 762 # another one in the FIP file. 763 NEED_BL33 := no 764 else 765 NEED_BL33 ?= yes 766 endif 767 endif 768endif 769 770# If SCP_BL2 is given, we always want FIP to include it. 771ifdef SCP_BL2 772 NEED_SCP_BL2 := yes 773endif 774 775# For AArch32, BL31 is not currently supported. 776ifneq (${ARCH},aarch32) 777 ifdef BL31_SOURCES 778 # When booting an EL3 payload, there is no need to compile the BL31 image nor 779 # put it in the FIP. 780 ifndef EL3_PAYLOAD_BASE 781 NEED_BL31 := yes 782 endif 783 endif 784endif 785 786# Process TBB related flags 787ifneq (${GENERATE_COT},0) 788 # Common cert_create options 789 ifneq (${CREATE_KEYS},0) 790 $(eval CRT_ARGS += -n) 791 $(eval FWU_CRT_ARGS += -n) 792 ifneq (${SAVE_KEYS},0) 793 $(eval CRT_ARGS += -k) 794 $(eval FWU_CRT_ARGS += -k) 795 endif 796 endif 797 # Include TBBR makefile (unless the platform indicates otherwise) 798 ifeq (${INCLUDE_TBBR_MK},1) 799 include make_helpers/tbbr/tbbr_tools.mk 800 endif 801endif 802 803ifneq (${FIP_ALIGN},0) 804FIP_ARGS += --align ${FIP_ALIGN} 805endif 806 807################################################################################ 808# Include libraries' Makefile that are used in all BL 809################################################################################ 810 811include lib/stack_protector/stack_protector.mk 812 813################################################################################ 814# Auxiliary tools (fiptool, cert_create, etc) 815################################################################################ 816 817# Variables for use with Certificate Generation Tool 818CRTTOOLPATH ?= tools/cert_create 819CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 820 821# Variables for use with Firmware Encryption Tool 822ENCTOOLPATH ?= tools/encrypt_fw 823ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 824 825# Variables for use with Firmware Image Package 826FIPTOOLPATH ?= tools/fiptool 827FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 828 829# Variables for use with sptool 830SPTOOLPATH ?= tools/sptool 831SPTOOL ?= ${SPTOOLPATH}/sptool${BIN_EXT} 832SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 833 834# Variables for use with ROMLIB 835ROMLIBPATH ?= lib/romlib 836 837# Variable for use with Python 838PYTHON ?= python3 839 840# Variables for use with PRINT_MEMORY_MAP 841PRINT_MEMORY_MAP_PATH ?= tools/memory 842PRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py 843 844# Variables for use with documentation build using Sphinx tool 845DOCS_PATH ?= docs 846 847################################################################################ 848# Include BL specific makefiles 849################################################################################ 850ifdef BL1_SOURCES 851NEED_BL1 := yes 852include bl1/bl1.mk 853endif 854 855ifdef BL2_SOURCES 856NEED_BL2 := yes 857include bl2/bl2.mk 858endif 859 860ifdef BL2U_SOURCES 861NEED_BL2U := yes 862include bl2u/bl2u.mk 863endif 864 865ifeq (${NEED_BL31},yes) 866ifdef BL31_SOURCES 867include bl31/bl31.mk 868endif 869endif 870 871ifdef FDT_SOURCES 872NEED_FDT := yes 873endif 874 875################################################################################ 876# Build options checks 877################################################################################ 878 879$(eval $(call assert_booleans,\ 880 $(sort \ 881 ALLOW_RO_XLAT_TABLES \ 882 COLD_BOOT_SINGLE_CPU \ 883 CREATE_KEYS \ 884 CTX_INCLUDE_AARCH32_REGS \ 885 CTX_INCLUDE_FPREGS \ 886 CTX_INCLUDE_PAUTH_REGS \ 887 CTX_INCLUDE_MTE_REGS \ 888 CTX_INCLUDE_EL2_REGS \ 889 CTX_INCLUDE_NEVE_REGS \ 890 DEBUG \ 891 DYN_DISABLE_AUTH \ 892 EL3_EXCEPTION_HANDLING \ 893 ENABLE_AMU \ 894 ENABLE_ASSERTIONS \ 895 ENABLE_MPAM_FOR_LOWER_ELS \ 896 ENABLE_PIE \ 897 ENABLE_PMF \ 898 ENABLE_PSCI_STAT \ 899 ENABLE_RUNTIME_INSTRUMENTATION \ 900 ENABLE_SPE_FOR_LOWER_ELS \ 901 ENABLE_SVE_FOR_NS \ 902 ERROR_DEPRECATED \ 903 FAULT_INJECTION_SUPPORT \ 904 GENERATE_COT \ 905 GICV2_G0_FOR_EL3 \ 906 HANDLE_EA_EL3_FIRST \ 907 HW_ASSISTED_COHERENCY \ 908 INVERTED_MEMMAP \ 909 MEASURED_BOOT \ 910 NS_TIMER_SWITCH \ 911 OVERRIDE_LIBC \ 912 PL011_GENERIC_UART \ 913 PROGRAMMABLE_RESET_ADDRESS \ 914 PSCI_EXTENDED_STATE_ID \ 915 RAS_EXTENSION \ 916 RESET_TO_BL31 \ 917 SAVE_KEYS \ 918 SEPARATE_CODE_AND_RODATA \ 919 SEPARATE_NOBITS_REGION \ 920 SPIN_ON_BL1_EXIT \ 921 SPM_MM \ 922 SPMD_SPM_AT_SEL2 \ 923 TRUSTED_BOARD_BOOT \ 924 USE_COHERENT_MEM \ 925 USE_DEBUGFS \ 926 ARM_IO_IN_DTB \ 927 SDEI_IN_FCONF \ 928 SEC_INT_DESC_IN_FCONF \ 929 USE_ROMLIB \ 930 USE_TBBR_DEFS \ 931 WARMBOOT_ENABLE_DCACHE_EARLY \ 932 BL2_AT_EL3 \ 933 BL2_IN_XIP_MEM \ 934 BL2_INV_DCACHE \ 935 USE_SPINLOCK_CAS \ 936 ENCRYPT_BL31 \ 937 ENCRYPT_BL32 \ 938 ERRATA_SPECULATIVE_AT \ 939 RAS_TRAP_LOWER_EL_ERR_ACCESS \ 940 COT_DESC_IN_DTB \ 941 USE_SP804_TIMER \ 942))) 943 944$(eval $(call assert_numerics,\ 945 $(sort \ 946 ARM_ARCH_MAJOR \ 947 ARM_ARCH_MINOR \ 948 BRANCH_PROTECTION \ 949 FW_ENC_STATUS \ 950))) 951 952ifdef KEY_SIZE 953 $(eval $(call assert_numeric,KEY_SIZE)) 954endif 955 956ifeq ($(filter $(SANITIZE_UB), on off trap),) 957 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 958endif 959 960################################################################################ 961# Add definitions to the cpp preprocessor based on the current build options. 962# This is done after including the platform specific makefile to allow the 963# platform to overwrite the default options 964################################################################################ 965 966$(eval $(call add_defines,\ 967 $(sort \ 968 ALLOW_RO_XLAT_TABLES \ 969 ARM_ARCH_MAJOR \ 970 ARM_ARCH_MINOR \ 971 COLD_BOOT_SINGLE_CPU \ 972 CTX_INCLUDE_AARCH32_REGS \ 973 CTX_INCLUDE_FPREGS \ 974 CTX_INCLUDE_PAUTH_REGS \ 975 EL3_EXCEPTION_HANDLING \ 976 CTX_INCLUDE_MTE_REGS \ 977 CTX_INCLUDE_EL2_REGS \ 978 CTX_INCLUDE_NEVE_REGS \ 979 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 980 ENABLE_AMU \ 981 ENABLE_ASSERTIONS \ 982 ENABLE_BTI \ 983 ENABLE_MPAM_FOR_LOWER_ELS \ 984 ENABLE_PAUTH \ 985 ENABLE_PIE \ 986 ENABLE_PMF \ 987 ENABLE_PSCI_STAT \ 988 ENABLE_RUNTIME_INSTRUMENTATION \ 989 ENABLE_SPE_FOR_LOWER_ELS \ 990 ENABLE_SVE_FOR_NS \ 991 ENCRYPT_BL31 \ 992 ENCRYPT_BL32 \ 993 ERROR_DEPRECATED \ 994 FAULT_INJECTION_SUPPORT \ 995 GICV2_G0_FOR_EL3 \ 996 HANDLE_EA_EL3_FIRST \ 997 HW_ASSISTED_COHERENCY \ 998 LOG_LEVEL \ 999 MEASURED_BOOT \ 1000 NS_TIMER_SWITCH \ 1001 PL011_GENERIC_UART \ 1002 PLAT_${PLAT} \ 1003 PROGRAMMABLE_RESET_ADDRESS \ 1004 PSCI_EXTENDED_STATE_ID \ 1005 RAS_EXTENSION \ 1006 RESET_TO_BL31 \ 1007 SEPARATE_CODE_AND_RODATA \ 1008 SEPARATE_NOBITS_REGION \ 1009 RECLAIM_INIT_CODE \ 1010 SPD_${SPD} \ 1011 SPIN_ON_BL1_EXIT \ 1012 SPM_MM \ 1013 SPMD_SPM_AT_SEL2 \ 1014 TRUSTED_BOARD_BOOT \ 1015 USE_COHERENT_MEM \ 1016 USE_DEBUGFS \ 1017 ARM_IO_IN_DTB \ 1018 SDEI_IN_FCONF \ 1019 SEC_INT_DESC_IN_FCONF \ 1020 USE_ROMLIB \ 1021 USE_TBBR_DEFS \ 1022 WARMBOOT_ENABLE_DCACHE_EARLY \ 1023 BL2_AT_EL3 \ 1024 BL2_IN_XIP_MEM \ 1025 BL2_INV_DCACHE \ 1026 USE_SPINLOCK_CAS \ 1027 ERRATA_SPECULATIVE_AT \ 1028 RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1029 COT_DESC_IN_DTB \ 1030 USE_SP804_TIMER \ 1031))) 1032 1033ifeq (${SANITIZE_UB},trap) 1034 $(eval $(call add_define,MONITOR_TRAPS)) 1035endif 1036 1037# Define the EL3_PAYLOAD_BASE flag only if it is provided. 1038ifdef EL3_PAYLOAD_BASE 1039 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1040else 1041 # Define the PRELOADED_BL33_BASE flag only if it is provided and 1042 # EL3_PAYLOAD_BASE is not defined, as it has priority. 1043 ifdef PRELOADED_BL33_BASE 1044 $(eval $(call add_define,PRELOADED_BL33_BASE)) 1045 endif 1046endif 1047 1048# Define the DYN_DISABLE_AUTH flag only if set. 1049ifeq (${DYN_DISABLE_AUTH},1) 1050$(eval $(call add_define,DYN_DISABLE_AUTH)) 1051endif 1052 1053ifneq ($(findstring armlink,$(notdir $(LD))),) 1054$(eval $(call add_define,USE_ARM_LINK)) 1055endif 1056 1057# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1058ifeq (${SPD},spmd) 1059ifdef SP_LAYOUT_FILE 1060 ifeq (${SPMD_SPM_AT_SEL2},0) 1061 $(error "SPMD with SPM at S-EL1 does not require SP_LAYOUT_FILE") 1062 endif 1063 -include $(BUILD_PLAT)/sp_gen.mk 1064 FIP_DEPS += sp 1065 CRT_DEPS += sp 1066 NEED_SP_PKG := yes 1067else 1068 ifeq (${SPMD_SPM_AT_SEL2},1) 1069 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1070 endif 1071endif 1072endif 1073 1074################################################################################ 1075# Build targets 1076################################################################################ 1077 1078.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 1079.SUFFIXES: 1080 1081all: msg_start 1082 1083msg_start: 1084 @echo "Building ${PLAT}" 1085 1086ifeq (${ERROR_DEPRECATED},0) 1087# Check if deprecated declarations and cpp warnings should be treated as error or not. 1088ifneq ($(findstring clang,$(notdir $(CC))),) 1089 CPPFLAGS += -Wno-error=deprecated-declarations 1090else 1091 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 1092endif 1093endif # !ERROR_DEPRECATED 1094 1095$(eval $(call MAKE_LIB_DIRS)) 1096$(eval $(call MAKE_LIB,c)) 1097 1098# Expand build macros for the different images 1099ifeq (${NEED_BL1},yes) 1100$(eval $(call MAKE_BL,1)) 1101endif 1102 1103ifeq (${NEED_BL2},yes) 1104ifeq (${BL2_AT_EL3}, 0) 1105FIP_BL2_ARGS := tb-fw 1106endif 1107 1108$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1109 $(eval $(call MAKE_BL,2,${FIP_BL2_ARGS}))) 1110endif 1111 1112ifeq (${NEED_SCP_BL2},yes) 1113$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1114endif 1115 1116ifeq (${NEED_BL31},yes) 1117BL31_SOURCES += ${SPD_SOURCES} 1118# Sort BL31 source files to remove duplicates 1119BL31_SOURCES := $(sort ${BL31_SOURCES}) 1120ifneq (${DECRYPTION_SUPPORT},none) 1121$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1122 $(eval $(call MAKE_BL,31,soc-fw,,$(ENCRYPT_BL31)))) 1123else 1124$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1125 $(eval $(call MAKE_BL,31,soc-fw))) 1126endif 1127endif 1128 1129# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1130# build system will call TOOL_ADD_IMG to print a warning message and abort the 1131# process. Note that the dependency on BL32 applies to the FIP only. 1132ifeq (${NEED_BL32},yes) 1133# Sort BL32 source files to remove duplicates 1134BL32_SOURCES := $(sort ${BL32_SOURCES}) 1135BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 1136 1137ifneq (${DECRYPTION_SUPPORT},none) 1138$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw,,$(ENCRYPT_BL32))),\ 1139 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1140else 1141$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\ 1142 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1143endif 1144endif 1145 1146# Add the BL33 image if required by the platform 1147ifeq (${NEED_BL33},yes) 1148$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1149endif 1150 1151ifeq (${NEED_BL2U},yes) 1152$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1153 $(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_))) 1154endif 1155 1156# Expand build macros for the different images 1157ifeq (${NEED_FDT},yes) 1158 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1159endif 1160 1161# Add Secure Partition packages 1162ifeq (${NEED_SP_PKG},yes) 1163$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 1164 ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1165sp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk 1166 ${Q}$(SPTOOL) $(SPTOOL_ARGS) 1167 @${ECHO_BLANK_LINE} 1168 @echo "Built SP Images successfully" 1169 @${ECHO_BLANK_LINE} 1170endif 1171 1172locate-checkpatch: 1173ifndef CHECKPATCH 1174 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1175else 1176ifeq (,$(wildcard ${CHECKPATCH})) 1177 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1178endif 1179endif 1180 1181clean: 1182 @echo " CLEAN" 1183 $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 1184ifdef UNIX_MK 1185 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1186else 1187# Clear the MAKEFLAGS as we do not want 1188# to pass the gnumake flags to nmake. 1189 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1190endif 1191 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1192 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1193 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1194 1195realclean distclean: 1196 @echo " REALCLEAN" 1197 $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1198 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 1199ifdef UNIX_MK 1200 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1201else 1202# Clear the MAKEFLAGS as we do not want 1203# to pass the gnumake flags to nmake. 1204 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1205endif 1206 ${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean 1207 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1208 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 1209 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1210 1211checkcodebase: locate-checkpatch 1212 @echo " CHECKING STYLE" 1213 @if test -d .git ; then \ 1214 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 1215 while read GIT_FILE ; \ 1216 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 1217 done ; \ 1218 else \ 1219 find . -type f -not -iwholename "*.git*" \ 1220 -not -iwholename "*build*" \ 1221 -not -iwholename "*libfdt*" \ 1222 -not -iwholename "*libc*" \ 1223 -not -iwholename "*docs*" \ 1224 -not -iwholename "*.rst" \ 1225 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 1226 fi 1227 1228checkpatch: locate-checkpatch 1229 @echo " CHECKING STYLE" 1230 @if test -n "${CHECKPATCH_OPTS}"; then \ 1231 echo " with ${CHECKPATCH_OPTS} option(s)"; \ 1232 fi 1233 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1234 for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \ 1235 printf "\n[*] Checking style of '$$commit'\n\n"; \ 1236 git log --format=email "$$commit~..$$commit" \ 1237 -- ${CHECK_PATHS} | \ 1238 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1239 git diff --format=email "$$commit~..$$commit" \ 1240 -- ${CHECK_PATHS} | \ 1241 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1242 done 1243 1244certtool: ${CRTTOOL} 1245 1246.PHONY: ${CRTTOOL} 1247${CRTTOOL}: 1248 ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} --no-print-directory -C ${CRTTOOLPATH} 1249 @${ECHO_BLANK_LINE} 1250 @echo "Built $@ successfully" 1251 @${ECHO_BLANK_LINE} 1252 1253ifneq (${GENERATE_COT},0) 1254certificates: ${CRT_DEPS} ${CRTTOOL} 1255 ${Q}${CRTTOOL} ${CRT_ARGS} 1256 @${ECHO_BLANK_LINE} 1257 @echo "Built $@ successfully" 1258 @echo "Certificates can be found in ${BUILD_PLAT}" 1259 @${ECHO_BLANK_LINE} 1260endif 1261 1262${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 1263 ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1264 ${Q}${FIPTOOL} info $@ 1265 @${ECHO_BLANK_LINE} 1266 @echo "Built $@ successfully" 1267 @${ECHO_BLANK_LINE} 1268 1269ifneq (${GENERATE_COT},0) 1270fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 1271 ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1272 @${ECHO_BLANK_LINE} 1273 @echo "Built $@ successfully" 1274 @echo "FWU certificates can be found in ${BUILD_PLAT}" 1275 @${ECHO_BLANK_LINE} 1276endif 1277 1278${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 1279 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1280 ${Q}${FIPTOOL} info $@ 1281 @${ECHO_BLANK_LINE} 1282 @echo "Built $@ successfully" 1283 @${ECHO_BLANK_LINE} 1284 1285fiptool: ${FIPTOOL} 1286fip: ${BUILD_PLAT}/${FIP_NAME} 1287fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 1288 1289.PHONY: ${FIPTOOL} 1290${FIPTOOL}: 1291 @${ECHO_BLANK_LINE} 1292 @echo "Building $@" 1293ifdef UNIX_MK 1294 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH} 1295else 1296# Clear the MAKEFLAGS as we do not want 1297# to pass the gnumake flags to nmake. 1298 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1299endif 1300 @${ECHO_BLANK_LINE} 1301 1302sptool: ${SPTOOL} 1303.PHONY: ${SPTOOL} 1304${SPTOOL}: 1305 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH} 1306 1307.PHONY: libraries 1308romlib.bin: libraries 1309 ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all 1310 1311# Call print_memory_map tool 1312memmap: all 1313 ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1314 1315doc: 1316 @echo " BUILD DOCUMENTATION" 1317 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 1318 1319enctool: ${ENCTOOL} 1320 1321.PHONY: ${ENCTOOL} 1322${ENCTOOL}: 1323 ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH} 1324 @${ECHO_BLANK_LINE} 1325 @echo "Built $@ successfully" 1326 @${ECHO_BLANK_LINE} 1327 1328cscope: 1329 @echo " CSCOPE" 1330 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 1331 ${Q}cscope -b -q -k 1332 1333help: 1334 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 1335 @echo "" 1336 @echo "PLAT is used to specify which platform you wish to build." 1337 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 1338 @echo "" 1339 @echo "platform = ${PLATFORM_LIST}" 1340 @echo "" 1341 @echo "Please refer to the User Guide for a list of all supported options." 1342 @echo "Note that the build system doesn't track dependencies for build " 1343 @echo "options. Therefore, if any of the build options are changed " 1344 @echo "from a previous build, a clean build must be performed." 1345 @echo "" 1346 @echo "Supported Targets:" 1347 @echo " all Build all individual bootloader binaries" 1348 @echo " bl1 Build the BL1 binary" 1349 @echo " bl2 Build the BL2 binary" 1350 @echo " bl2u Build the BL2U binary" 1351 @echo " bl31 Build the BL31 binary" 1352 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 1353 @echo " this builds secure payload specified by AARCH32_SP" 1354 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 1355 @echo " fip Build the Firmware Image Package (FIP)" 1356 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 1357 @echo " checkcodebase Check the coding style of the entire source tree" 1358 @echo " checkpatch Check the coding style on changes in the current" 1359 @echo " branch against BASE_COMMIT (default origin/master)" 1360 @echo " clean Clean the build for the selected platform" 1361 @echo " cscope Generate cscope index" 1362 @echo " distclean Remove all build artifacts for all platforms" 1363 @echo " certtool Build the Certificate generation tool" 1364 @echo " enctool Build the Firmware encryption tool" 1365 @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1366 @echo " sp Build the Secure Partition Packages" 1367 @echo " sptool Build the Secure Partition Package creation tool" 1368 @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1369 @echo " memmap Print the memory map of the built binaries" 1370 @echo " doc Build html based documentation using Sphinx tool" 1371 @echo "" 1372 @echo "Note: most build targets require PLAT to be set to a specific platform." 1373 @echo "" 1374 @echo "example: build all targets for the FVP platform:" 1375 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1376