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 ENABLE_ASSERTIONS \ 899 ENABLE_MPAM_FOR_LOWER_ELS \ 900 ENABLE_PIE \ 901 ENABLE_PMF \ 902 ENABLE_PSCI_STAT \ 903 ENABLE_RUNTIME_INSTRUMENTATION \ 904 ENABLE_SPE_FOR_LOWER_ELS \ 905 ENABLE_SVE_FOR_NS \ 906 ERROR_DEPRECATED \ 907 FAULT_INJECTION_SUPPORT \ 908 GENERATE_COT \ 909 GICV2_G0_FOR_EL3 \ 910 HANDLE_EA_EL3_FIRST \ 911 HW_ASSISTED_COHERENCY \ 912 INVERTED_MEMMAP \ 913 MEASURED_BOOT \ 914 NS_TIMER_SWITCH \ 915 OVERRIDE_LIBC \ 916 PL011_GENERIC_UART \ 917 PROGRAMMABLE_RESET_ADDRESS \ 918 PSCI_EXTENDED_STATE_ID \ 919 RAS_EXTENSION \ 920 RESET_TO_BL31 \ 921 SAVE_KEYS \ 922 SEPARATE_CODE_AND_RODATA \ 923 SEPARATE_NOBITS_REGION \ 924 SPIN_ON_BL1_EXIT \ 925 SPM_MM \ 926 SPMD_SPM_AT_SEL2 \ 927 TRUSTED_BOARD_BOOT \ 928 USE_COHERENT_MEM \ 929 USE_DEBUGFS \ 930 ARM_IO_IN_DTB \ 931 SDEI_IN_FCONF \ 932 SEC_INT_DESC_IN_FCONF \ 933 USE_ROMLIB \ 934 USE_TBBR_DEFS \ 935 WARMBOOT_ENABLE_DCACHE_EARLY \ 936 BL2_AT_EL3 \ 937 BL2_IN_XIP_MEM \ 938 BL2_INV_DCACHE \ 939 USE_SPINLOCK_CAS \ 940 ENCRYPT_BL31 \ 941 ENCRYPT_BL32 \ 942 ERRATA_SPECULATIVE_AT \ 943 RAS_TRAP_LOWER_EL_ERR_ACCESS \ 944 COT_DESC_IN_DTB \ 945 USE_SP804_TIMER \ 946 ENABLE_FEAT_RNG \ 947))) 948 949$(eval $(call assert_numerics,\ 950 $(sort \ 951 ARM_ARCH_MAJOR \ 952 ARM_ARCH_MINOR \ 953 BRANCH_PROTECTION \ 954 FW_ENC_STATUS \ 955))) 956 957ifdef KEY_SIZE 958 $(eval $(call assert_numeric,KEY_SIZE)) 959endif 960 961ifeq ($(filter $(SANITIZE_UB), on off trap),) 962 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 963endif 964 965################################################################################ 966# Add definitions to the cpp preprocessor based on the current build options. 967# This is done after including the platform specific makefile to allow the 968# platform to overwrite the default options 969################################################################################ 970 971$(eval $(call add_defines,\ 972 $(sort \ 973 ALLOW_RO_XLAT_TABLES \ 974 ARM_ARCH_MAJOR \ 975 ARM_ARCH_MINOR \ 976 COLD_BOOT_SINGLE_CPU \ 977 CTX_INCLUDE_AARCH32_REGS \ 978 CTX_INCLUDE_FPREGS \ 979 CTX_INCLUDE_PAUTH_REGS \ 980 EL3_EXCEPTION_HANDLING \ 981 CTX_INCLUDE_MTE_REGS \ 982 CTX_INCLUDE_EL2_REGS \ 983 CTX_INCLUDE_NEVE_REGS \ 984 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 985 DISABLE_MTPMU \ 986 ENABLE_AMU \ 987 ENABLE_ASSERTIONS \ 988 ENABLE_BTI \ 989 ENABLE_MPAM_FOR_LOWER_ELS \ 990 ENABLE_PAUTH \ 991 ENABLE_PIE \ 992 ENABLE_PMF \ 993 ENABLE_PSCI_STAT \ 994 ENABLE_RUNTIME_INSTRUMENTATION \ 995 ENABLE_SPE_FOR_LOWER_ELS \ 996 ENABLE_SVE_FOR_NS \ 997 ENCRYPT_BL31 \ 998 ENCRYPT_BL32 \ 999 ERROR_DEPRECATED \ 1000 FAULT_INJECTION_SUPPORT \ 1001 GICV2_G0_FOR_EL3 \ 1002 HANDLE_EA_EL3_FIRST \ 1003 HW_ASSISTED_COHERENCY \ 1004 LOG_LEVEL \ 1005 MEASURED_BOOT \ 1006 NS_TIMER_SWITCH \ 1007 PL011_GENERIC_UART \ 1008 PLAT_${PLAT} \ 1009 PROGRAMMABLE_RESET_ADDRESS \ 1010 PSCI_EXTENDED_STATE_ID \ 1011 RAS_EXTENSION \ 1012 RESET_TO_BL31 \ 1013 SEPARATE_CODE_AND_RODATA \ 1014 SEPARATE_NOBITS_REGION \ 1015 RECLAIM_INIT_CODE \ 1016 SPD_${SPD} \ 1017 SPIN_ON_BL1_EXIT \ 1018 SPM_MM \ 1019 SPMD_SPM_AT_SEL2 \ 1020 TRUSTED_BOARD_BOOT \ 1021 TRNG_SUPPORT \ 1022 USE_COHERENT_MEM \ 1023 USE_DEBUGFS \ 1024 ARM_IO_IN_DTB \ 1025 SDEI_IN_FCONF \ 1026 SEC_INT_DESC_IN_FCONF \ 1027 USE_ROMLIB \ 1028 USE_TBBR_DEFS \ 1029 WARMBOOT_ENABLE_DCACHE_EARLY \ 1030 BL2_AT_EL3 \ 1031 BL2_IN_XIP_MEM \ 1032 BL2_INV_DCACHE \ 1033 USE_SPINLOCK_CAS \ 1034 ERRATA_SPECULATIVE_AT \ 1035 RAS_TRAP_LOWER_EL_ERR_ACCESS \ 1036 COT_DESC_IN_DTB \ 1037 USE_SP804_TIMER \ 1038 ENABLE_FEAT_RNG \ 1039))) 1040 1041ifeq (${SANITIZE_UB},trap) 1042 $(eval $(call add_define,MONITOR_TRAPS)) 1043endif 1044 1045# Define the EL3_PAYLOAD_BASE flag only if it is provided. 1046ifdef EL3_PAYLOAD_BASE 1047 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1048else 1049 # Define the PRELOADED_BL33_BASE flag only if it is provided and 1050 # EL3_PAYLOAD_BASE is not defined, as it has priority. 1051 ifdef PRELOADED_BL33_BASE 1052 $(eval $(call add_define,PRELOADED_BL33_BASE)) 1053 endif 1054endif 1055 1056# Define the DYN_DISABLE_AUTH flag only if set. 1057ifeq (${DYN_DISABLE_AUTH},1) 1058$(eval $(call add_define,DYN_DISABLE_AUTH)) 1059endif 1060 1061ifneq ($(findstring armlink,$(notdir $(LD))),) 1062$(eval $(call add_define,USE_ARM_LINK)) 1063endif 1064 1065# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1066ifeq (${SPD},spmd) 1067ifdef SP_LAYOUT_FILE 1068 ifeq (${SPMD_SPM_AT_SEL2},0) 1069 $(error "SPMD with SPM at S-EL1 does not require SP_LAYOUT_FILE") 1070 endif 1071 -include $(BUILD_PLAT)/sp_gen.mk 1072 FIP_DEPS += sp 1073 CRT_DEPS += sp 1074 NEED_SP_PKG := yes 1075else 1076 ifeq (${SPMD_SPM_AT_SEL2},1) 1077 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1078 endif 1079endif 1080endif 1081 1082################################################################################ 1083# Build targets 1084################################################################################ 1085 1086.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 1087.SUFFIXES: 1088 1089all: msg_start 1090 1091msg_start: 1092 @echo "Building ${PLAT}" 1093 1094ifeq (${ERROR_DEPRECATED},0) 1095# Check if deprecated declarations and cpp warnings should be treated as error or not. 1096ifneq ($(findstring clang,$(notdir $(CC))),) 1097 CPPFLAGS += -Wno-error=deprecated-declarations 1098else 1099 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 1100endif 1101endif # !ERROR_DEPRECATED 1102 1103$(eval $(call MAKE_LIB_DIRS)) 1104$(eval $(call MAKE_LIB,c)) 1105 1106# Expand build macros for the different images 1107ifeq (${NEED_BL1},yes) 1108$(eval $(call MAKE_BL,1)) 1109endif 1110 1111ifeq (${NEED_BL2},yes) 1112ifeq (${BL2_AT_EL3}, 0) 1113FIP_BL2_ARGS := tb-fw 1114endif 1115 1116$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1117 $(eval $(call MAKE_BL,2,${FIP_BL2_ARGS}))) 1118endif 1119 1120ifeq (${NEED_SCP_BL2},yes) 1121$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1122endif 1123 1124ifeq (${NEED_BL31},yes) 1125BL31_SOURCES += ${SPD_SOURCES} 1126# Sort BL31 source files to remove duplicates 1127BL31_SOURCES := $(sort ${BL31_SOURCES}) 1128ifneq (${DECRYPTION_SUPPORT},none) 1129$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1130 $(eval $(call MAKE_BL,31,soc-fw,,$(ENCRYPT_BL31)))) 1131else 1132$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1133 $(eval $(call MAKE_BL,31,soc-fw))) 1134endif 1135endif 1136 1137# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1138# build system will call TOOL_ADD_IMG to print a warning message and abort the 1139# process. Note that the dependency on BL32 applies to the FIP only. 1140ifeq (${NEED_BL32},yes) 1141# Sort BL32 source files to remove duplicates 1142BL32_SOURCES := $(sort ${BL32_SOURCES}) 1143BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 1144 1145ifneq (${DECRYPTION_SUPPORT},none) 1146$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw,,$(ENCRYPT_BL32))),\ 1147 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1148else 1149$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,32,tos-fw)),\ 1150 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1151endif 1152endif 1153 1154# Add the BL33 image if required by the platform 1155ifeq (${NEED_BL33},yes) 1156$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1157endif 1158 1159ifeq (${NEED_BL2U},yes) 1160$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1161 $(eval $(call MAKE_BL,2u,ap-fwu-cfg,FWU_))) 1162endif 1163 1164# Expand build macros for the different images 1165ifeq (${NEED_FDT},yes) 1166 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1167endif 1168 1169# Add Secure Partition packages 1170ifeq (${NEED_SP_PKG},yes) 1171$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 1172 ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1173sp: $(SPTOOL) $(DTBS) $(BUILD_PLAT)/sp_gen.mk 1174 ${Q}$(SPTOOL) $(SPTOOL_ARGS) 1175 @${ECHO_BLANK_LINE} 1176 @echo "Built SP Images successfully" 1177 @${ECHO_BLANK_LINE} 1178endif 1179 1180locate-checkpatch: 1181ifndef CHECKPATCH 1182 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1183else 1184ifeq (,$(wildcard ${CHECKPATCH})) 1185 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1186endif 1187endif 1188 1189clean: 1190 @echo " CLEAN" 1191 $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 1192ifdef UNIX_MK 1193 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1194else 1195# Clear the MAKEFLAGS as we do not want 1196# to pass the gnumake flags to nmake. 1197 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1198endif 1199 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1200 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1201 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1202 1203realclean distclean: 1204 @echo " REALCLEAN" 1205 $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1206 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 1207ifdef UNIX_MK 1208 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1209else 1210# Clear the MAKEFLAGS as we do not want 1211# to pass the gnumake flags to nmake. 1212 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1213endif 1214 ${Q}${MAKE} --no-print-directory -C ${SPTOOLPATH} clean 1215 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1216 ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 1217 ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1218 1219checkcodebase: locate-checkpatch 1220 @echo " CHECKING STYLE" 1221 @if test -d .git ; then \ 1222 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 1223 while read GIT_FILE ; \ 1224 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 1225 done ; \ 1226 else \ 1227 find . -type f -not -iwholename "*.git*" \ 1228 -not -iwholename "*build*" \ 1229 -not -iwholename "*libfdt*" \ 1230 -not -iwholename "*libc*" \ 1231 -not -iwholename "*docs*" \ 1232 -not -iwholename "*.rst" \ 1233 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 1234 fi 1235 1236checkpatch: locate-checkpatch 1237 @echo " CHECKING STYLE" 1238 @if test -n "${CHECKPATCH_OPTS}"; then \ 1239 echo " with ${CHECKPATCH_OPTS} option(s)"; \ 1240 fi 1241 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1242 for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \ 1243 printf "\n[*] Checking style of '$$commit'\n\n"; \ 1244 git log --format=email "$$commit~..$$commit" \ 1245 -- ${CHECK_PATHS} | \ 1246 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1247 git diff --format=email "$$commit~..$$commit" \ 1248 -- ${CHECK_PATHS} | \ 1249 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1250 done 1251 1252certtool: ${CRTTOOL} 1253 1254${CRTTOOL}: FORCE 1255 ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} --no-print-directory -C ${CRTTOOLPATH} 1256 @${ECHO_BLANK_LINE} 1257 @echo "Built $@ successfully" 1258 @${ECHO_BLANK_LINE} 1259 1260ifneq (${GENERATE_COT},0) 1261certificates: ${CRT_DEPS} ${CRTTOOL} 1262 ${Q}${CRTTOOL} ${CRT_ARGS} 1263 @${ECHO_BLANK_LINE} 1264 @echo "Built $@ successfully" 1265 @echo "Certificates can be found in ${BUILD_PLAT}" 1266 @${ECHO_BLANK_LINE} 1267endif 1268 1269${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 1270 $(eval ${CHECK_FIP_CMD}) 1271 ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1272 ${Q}${FIPTOOL} info $@ 1273 @${ECHO_BLANK_LINE} 1274 @echo "Built $@ successfully" 1275 @${ECHO_BLANK_LINE} 1276 1277ifneq (${GENERATE_COT},0) 1278fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 1279 ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1280 @${ECHO_BLANK_LINE} 1281 @echo "Built $@ successfully" 1282 @echo "FWU certificates can be found in ${BUILD_PLAT}" 1283 @${ECHO_BLANK_LINE} 1284endif 1285 1286${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 1287 $(eval ${CHECK_FWU_FIP_CMD}) 1288 ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1289 ${Q}${FIPTOOL} info $@ 1290 @${ECHO_BLANK_LINE} 1291 @echo "Built $@ successfully" 1292 @${ECHO_BLANK_LINE} 1293 1294fiptool: ${FIPTOOL} 1295fip: ${BUILD_PLAT}/${FIP_NAME} 1296fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 1297 1298${FIPTOOL}: FORCE 1299 @${ECHO_BLANK_LINE} 1300 @echo "Building $@" 1301ifdef UNIX_MK 1302 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} --no-print-directory -C ${FIPTOOLPATH} 1303else 1304# Clear the MAKEFLAGS as we do not want 1305# to pass the gnumake flags to nmake. 1306 ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1307endif 1308 @${ECHO_BLANK_LINE} 1309 1310sptool: ${SPTOOL} 1311${SPTOOL}: FORCE 1312 ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" SPTOOL=${SPTOOL} --no-print-directory -C ${SPTOOLPATH} 1313 1314romlib.bin: libraries FORCE 1315 ${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 1316 1317# Call print_memory_map tool 1318memmap: all 1319 ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1320 1321doc: 1322 @echo " BUILD DOCUMENTATION" 1323 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 1324 1325enctool: ${ENCTOOL} 1326 1327${ENCTOOL}: FORCE 1328 ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH} 1329 @${ECHO_BLANK_LINE} 1330 @echo "Built $@ successfully" 1331 @${ECHO_BLANK_LINE} 1332 1333cscope: 1334 @echo " CSCOPE" 1335 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 1336 ${Q}cscope -b -q -k 1337 1338help: 1339 @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 1340 @echo "" 1341 @echo "PLAT is used to specify which platform you wish to build." 1342 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 1343 @echo "" 1344 @echo "platform = ${PLATFORM_LIST}" 1345 @echo "" 1346 @echo "Please refer to the User Guide for a list of all supported options." 1347 @echo "Note that the build system doesn't track dependencies for build " 1348 @echo "options. Therefore, if any of the build options are changed " 1349 @echo "from a previous build, a clean build must be performed." 1350 @echo "" 1351 @echo "Supported Targets:" 1352 @echo " all Build all individual bootloader binaries" 1353 @echo " bl1 Build the BL1 binary" 1354 @echo " bl2 Build the BL2 binary" 1355 @echo " bl2u Build the BL2U binary" 1356 @echo " bl31 Build the BL31 binary" 1357 @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 1358 @echo " this builds secure payload specified by AARCH32_SP" 1359 @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 1360 @echo " fip Build the Firmware Image Package (FIP)" 1361 @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 1362 @echo " checkcodebase Check the coding style of the entire source tree" 1363 @echo " checkpatch Check the coding style on changes in the current" 1364 @echo " branch against BASE_COMMIT (default origin/master)" 1365 @echo " clean Clean the build for the selected platform" 1366 @echo " cscope Generate cscope index" 1367 @echo " distclean Remove all build artifacts for all platforms" 1368 @echo " certtool Build the Certificate generation tool" 1369 @echo " enctool Build the Firmware encryption tool" 1370 @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1371 @echo " sp Build the Secure Partition Packages" 1372 @echo " sptool Build the Secure Partition Package creation tool" 1373 @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1374 @echo " memmap Print the memory map of the built binaries" 1375 @echo " doc Build html based documentation using Sphinx tool" 1376 @echo "" 1377 @echo "Note: most build targets require PLAT to be set to a specific platform." 1378 @echo "" 1379 @echo "example: build all targets for the FVP platform:" 1380 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1381 1382.PHONY: FORCE 1383FORCE:; 1384