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