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