Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | # |
Alexei Fedorov | b61cc15 | 2020-01-08 14:02:18 +0000 | [diff] [blame] | 2 | # Copyright (c) 2018-2020, Arm Limited. All rights reserved. |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
| 7 | # TFTF Version |
| 8 | VERSION_MAJOR := 2 |
Madhukar Pappireddy | f5b5474 | 2020-04-19 23:58:39 -0500 | [diff] [blame] | 9 | VERSION_MINOR := 3 |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 10 | |
Leonardo Sandoval | e1693b4 | 2020-09-11 12:50:19 -0500 | [diff] [blame^] | 11 | MAKE_HELPERS_DIRECTORY := make_helpers/ |
| 12 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 13 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 14 | ################################################################################ |
| 15 | # Default values for build configurations, and their dependencies |
| 16 | ################################################################################ |
| 17 | |
Leonardo Sandoval | e1693b4 | 2020-09-11 12:50:19 -0500 | [diff] [blame^] | 18 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 19 | |
| 20 | PLAT := ${DEFAULT_PLAT} |
| 21 | |
| 22 | # Assertions enabled for DEBUG builds by default |
| 23 | ENABLE_ASSERTIONS := ${DEBUG} |
| 24 | |
| 25 | ################################################################################ |
| 26 | # Checkpatch script options |
| 27 | ################################################################################ |
| 28 | |
| 29 | CHECKCODE_ARGS := --no-patch |
| 30 | # Do not check the coding style on imported library files or documentation files |
| 31 | INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 32 | include/lib/libc, \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 33 | $(wildcard include/lib/*))) |
| 34 | LIB_DIRS_TO_CHECK := $(sort $(filter-out \ |
| 35 | lib/compiler-rt \ |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 36 | lib/libc, \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 37 | $(wildcard lib/*))) |
| 38 | ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ |
| 39 | lib \ |
| 40 | include \ |
| 41 | docs \ |
| 42 | %.md \ |
| 43 | %.rst, \ |
| 44 | $(wildcard *))) |
| 45 | CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ |
| 46 | ${INC_LIB_DIRS_TO_CHECK} \ |
| 47 | ${LIB_DIRS_TO_CHECK} |
| 48 | |
| 49 | ifeq (${V},0) |
| 50 | Q=@ |
| 51 | else |
| 52 | Q= |
| 53 | endif |
| 54 | export Q |
| 55 | |
| 56 | ifneq (${DEBUG}, 0) |
| 57 | BUILD_TYPE := debug |
| 58 | # Use LOG_LEVEL_INFO by default for debug builds |
| 59 | LOG_LEVEL := 40 |
| 60 | else |
| 61 | BUILD_TYPE := release |
| 62 | # Use LOG_LEVEL_ERROR by default for release builds |
| 63 | LOG_LEVEL := 20 |
| 64 | endif |
| 65 | |
| 66 | # Default build string (git branch and commit) |
| 67 | ifeq (${BUILD_STRING},) |
| 68 | BUILD_STRING := $(shell git log -n 1 --pretty=format:"%h") |
| 69 | endif |
| 70 | |
| 71 | VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${PLAT},${BUILD_TYPE}):${BUILD_STRING} |
| 72 | |
| 73 | BUILD_BASE := ./build |
| 74 | BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE} |
| 75 | |
| 76 | PLAT_MAKEFILE := platform.mk |
| 77 | # Generate the platforms list by recursively searching for all directories |
| 78 | # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|` |
| 79 | # char and strip out the final '|'. |
| 80 | PLATFORMS := $(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 | \ |
| 81 | sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' | \ |
| 82 | sed -r 's/\|$$//') |
| 83 | |
Sandrine Bailleux | 7fb2e0a | 2020-04-21 14:45:00 +0200 | [diff] [blame] | 84 | DOCS_PATH := docs |
| 85 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 86 | ifeq (${PLAT},) |
| 87 | $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform") |
| 88 | endif |
| 89 | PLAT_PATH := $(shell find plat/ -wholename '*/${PLAT}') |
| 90 | PLAT_MAKEFILE_FULL := ${PLAT_PATH}/${PLAT_MAKEFILE} |
| 91 | ifeq ($(wildcard ${PLAT_MAKEFILE_FULL}),) |
| 92 | $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}") |
| 93 | endif |
| 94 | |
| 95 | .PHONY: all |
| 96 | all: msg_start |
| 97 | |
| 98 | .PHONY: msg_start |
| 99 | msg_start: |
| 100 | @echo "Building ${PLAT}" |
Sandrine Bailleux | 043d536 | 2018-10-03 17:05:59 +0200 | [diff] [blame] | 101 | @echo "Selected set of tests: ${TESTS}" |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 102 | |
| 103 | # Include test images makefiles. |
| 104 | include tftf/framework/framework.mk |
| 105 | include tftf/tests/tests.mk |
| 106 | include fwu/ns_bl1u/ns_bl1u.mk |
| 107 | include fwu/ns_bl2u/ns_bl2u.mk |
Antonio Nino Diaz | 9d7726c | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 108 | include spm/cactus_mm/cactus_mm.mk |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 109 | include spm/cactus/cactus.mk |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 110 | include spm/ivy/ivy.mk |
Antonio Nino Diaz | fee6e7e | 2019-03-28 13:16:04 +0000 | [diff] [blame] | 111 | include spm/quark/quark.mk |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 112 | |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 113 | ################################################################################ |
| 114 | # Include libc |
| 115 | ################################################################################ |
| 116 | include lib/libc/libc.mk |
| 117 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 118 | # Include platform specific makefile last because: |
| 119 | # - the platform makefile may use all previous definitions in this file. |
| 120 | # - the platform makefile may wish overwriting some of them. |
| 121 | include ${PLAT_MAKEFILE_FULL} |
| 122 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 123 | .SUFFIXES: |
| 124 | |
| 125 | ################################################################################ |
| 126 | # Build options checks |
| 127 | ################################################################################ |
| 128 | $(eval $(call assert_boolean,DEBUG)) |
| 129 | $(eval $(call assert_boolean,ENABLE_ASSERTIONS)) |
| 130 | $(eval $(call assert_boolean,FIRMWARE_UPDATE)) |
| 131 | $(eval $(call assert_boolean,FWU_BL_TEST)) |
| 132 | $(eval $(call assert_boolean,NEW_TEST_SESSION)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 133 | $(eval $(call assert_boolean,USE_NVM)) |
| 134 | |
| 135 | ################################################################################ |
Alexei Fedorov | f45484f | 2020-06-19 14:25:43 +0100 | [diff] [blame] | 136 | # Process build options |
| 137 | ################################################################################ |
| 138 | |
| 139 | # Process BRANCH_PROTECTION value and set |
| 140 | # Pointer Authentication and Branch Target Identification flags |
| 141 | include branch_protection.mk |
| 142 | |
| 143 | ################################################################################ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 144 | # Add definitions to the cpp preprocessor based on the current build options. |
| 145 | # This is done after including the platform specific makefile to allow the |
| 146 | # platform to overwrite the default options |
| 147 | ################################################################################ |
| 148 | $(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MAJOR)) |
| 149 | $(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MINOR)) |
| 150 | $(eval $(call add_define,TFTF_DEFINES,DEBUG)) |
| 151 | $(eval $(call add_define,TFTF_DEFINES,ENABLE_ASSERTIONS)) |
Alexei Fedorov | f45484f | 2020-06-19 14:25:43 +0100 | [diff] [blame] | 152 | $(eval $(call add_define,TFTF_DEFINES,ENABLE_BTI)) |
Antonio Nino Diaz | 2f13f42 | 2019-03-13 13:57:39 +0000 | [diff] [blame] | 153 | $(eval $(call add_define,TFTF_DEFINES,ENABLE_PAUTH)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 154 | $(eval $(call add_define,TFTF_DEFINES,LOG_LEVEL)) |
| 155 | $(eval $(call add_define,TFTF_DEFINES,NEW_TEST_SESSION)) |
| 156 | $(eval $(call add_define,TFTF_DEFINES,PLAT_${PLAT})) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 157 | $(eval $(call add_define,TFTF_DEFINES,USE_NVM)) |
| 158 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 159 | ################################################################################ |
| 160 | |
| 161 | # Assembler, compiler and linker flags shared across all test images. |
| 162 | COMMON_ASFLAGS := |
| 163 | COMMON_CFLAGS := |
| 164 | COMMON_LDFLAGS := |
| 165 | |
| 166 | ifeq (${DEBUG},1) |
| 167 | COMMON_CFLAGS += -g |
| 168 | COMMON_ASFLAGS += -g -Wa,--gdwarf-2 |
| 169 | endif |
| 170 | |
Joel Hutton | 8753024 | 2019-04-08 15:46:36 +0100 | [diff] [blame] | 171 | # Set the compiler's target architecture profile based on ARM_ARCH_MINOR option |
| 172 | ifeq (${ARM_ARCH_MINOR},0) |
| 173 | march32-directive = -march=armv8-a |
| 174 | march64-directive = -march=armv8-a |
| 175 | else |
| 176 | march32-directive = -march=armv8.${ARM_ARCH_MINOR}-a |
| 177 | march64-directive = -march=armv8.${ARM_ARCH_MINOR}-a |
| 178 | endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 179 | |
Joel Hutton | 8753024 | 2019-04-08 15:46:36 +0100 | [diff] [blame] | 180 | COMMON_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive} |
| 181 | COMMON_CFLAGS_aarch64 := -mgeneral-regs-only -mstrict-align ${march64-directive} |
| 182 | |
| 183 | COMMON_ASFLAGS_aarch32 := ${march32-directive} |
| 184 | COMMON_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 185 | |
| 186 | COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ |
| 187 | -Werror -Wmissing-include-dirs \ |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 188 | -D__ASSEMBLY__ $(COMMON_ASFLAGS_$(ARCH)) \ |
| 189 | ${INCLUDES} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 190 | COMMON_CFLAGS += -nostdinc -ffreestanding -Wall -Werror \ |
| 191 | -Wmissing-include-dirs $(COMMON_CFLAGS_$(ARCH)) \ |
| 192 | -std=gnu99 -Os |
| 193 | COMMON_CFLAGS += -ffunction-sections -fdata-sections |
| 194 | |
| 195 | # Get the content of CFLAGS user defined value last so they are appended after |
| 196 | # the options defined in the Makefile |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 197 | COMMON_CFLAGS += ${CFLAGS} ${INCLUDES} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 198 | |
| 199 | COMMON_LDFLAGS += --fatal-warnings -O1 --gc-sections --build-id=none |
| 200 | |
| 201 | CC := ${CROSS_COMPILE}gcc |
| 202 | CPP := ${CROSS_COMPILE}cpp |
| 203 | AS := ${CROSS_COMPILE}gcc |
| 204 | AR := ${CROSS_COMPILE}ar |
| 205 | LD := ${CROSS_COMPILE}ld |
| 206 | OC := ${CROSS_COMPILE}objcopy |
| 207 | OD := ${CROSS_COMPILE}objdump |
| 208 | NM := ${CROSS_COMPILE}nm |
| 209 | PP := ${CROSS_COMPILE}gcc |
| 210 | |
| 211 | ################################################################################ |
| 212 | |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 213 | TFTF_SOURCES := ${FRAMEWORK_SOURCES} ${TESTS_SOURCES} ${PLAT_SOURCES} ${LIBC_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 214 | TFTF_INCLUDES += ${PLAT_INCLUDES} |
| 215 | TFTF_CFLAGS += ${COMMON_CFLAGS} |
| 216 | TFTF_ASFLAGS += ${COMMON_ASFLAGS} |
| 217 | TFTF_LDFLAGS += ${COMMON_LDFLAGS} |
| 218 | |
Alexei Fedorov | f45484f | 2020-06-19 14:25:43 +0100 | [diff] [blame] | 219 | ifneq (${BP_OPTION},none) |
| 220 | TFTF_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 221 | NS_BL1U_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 222 | NS_BL2U_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 223 | CACTUS_MM_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 224 | CACTUS_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 225 | IVY_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 226 | QUARK_CFLAGS += -mbranch-protection=${BP_OPTION} |
Antonio Nino Diaz | 2f13f42 | 2019-03-13 13:57:39 +0000 | [diff] [blame] | 227 | endif |
| 228 | |
Olivier Deprez | db70c45 | 2020-02-03 11:27:01 +0100 | [diff] [blame] | 229 | ##################################################################################### |
| 230 | ifneq ($(findstring gcc,$(notdir $(LD))),) |
| 231 | PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker |
| 232 | else |
| 233 | PIE_LDFLAGS += -pie --no-dynamic-linker |
| 234 | endif |
| 235 | |
| 236 | ##################################################################################### |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 237 | NS_BL1U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 238 | NS_BL1U_INCLUDES += ${PLAT_INCLUDES} |
| 239 | NS_BL1U_CFLAGS += ${COMMON_CFLAGS} |
| 240 | NS_BL1U_ASFLAGS += ${COMMON_ASFLAGS} |
| 241 | NS_BL1U_LDFLAGS += ${COMMON_LDFLAGS} |
| 242 | |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 243 | NS_BL2U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 244 | NS_BL2U_INCLUDES += ${PLAT_INCLUDES} |
| 245 | NS_BL2U_CFLAGS += ${COMMON_CFLAGS} |
| 246 | NS_BL2U_ASFLAGS += ${COMMON_ASFLAGS} |
| 247 | NS_BL2U_LDFLAGS += ${COMMON_LDFLAGS} |
| 248 | |
Antonio Nino Diaz | 9d7726c | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 249 | CACTUS_MM_SOURCES += ${LIBC_SRCS} |
| 250 | CACTUS_MM_INCLUDES += ${PLAT_INCLUDES} |
| 251 | CACTUS_MM_CFLAGS += ${COMMON_CFLAGS} |
| 252 | CACTUS_MM_ASFLAGS += ${COMMON_ASFLAGS} |
| 253 | CACTUS_MM_LDFLAGS += ${COMMON_LDFLAGS} |
| 254 | |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 255 | CACTUS_SOURCES += ${LIBC_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 256 | CACTUS_INCLUDES += ${PLAT_INCLUDES} |
Olivier Deprez | db70c45 | 2020-02-03 11:27:01 +0100 | [diff] [blame] | 257 | CACTUS_CFLAGS += ${COMMON_CFLAGS} -fpie |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 258 | CACTUS_ASFLAGS += ${COMMON_ASFLAGS} |
Olivier Deprez | db70c45 | 2020-02-03 11:27:01 +0100 | [diff] [blame] | 259 | CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 260 | |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 261 | IVY_SOURCES += ${LIBC_SRCS} |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 262 | IVY_INCLUDES += ${PLAT_INCLUDES} |
| 263 | IVY_CFLAGS += ${COMMON_CFLAGS} |
| 264 | IVY_ASFLAGS += ${COMMON_ASFLAGS} |
| 265 | IVY_LDFLAGS += ${COMMON_LDFLAGS} |
| 266 | |
Antonio Nino Diaz | fee6e7e | 2019-03-28 13:16:04 +0000 | [diff] [blame] | 267 | QUARK_SOURCES += ${LIBC_SRCS} |
| 268 | QUARK_INCLUDES += ${PLAT_INCLUDES} |
| 269 | QUARK_CFLAGS += ${COMMON_CFLAGS} |
| 270 | QUARK_ASFLAGS += ${COMMON_ASFLAGS} |
| 271 | QUARK_LDFLAGS += ${COMMON_LDFLAGS} |
| 272 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 273 | .PHONY: locate-checkpatch |
| 274 | locate-checkpatch: |
| 275 | ifndef CHECKPATCH |
| 276 | $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl") |
| 277 | else |
| 278 | ifeq (,$(wildcard ${CHECKPATCH})) |
| 279 | $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl") |
| 280 | endif |
| 281 | endif |
| 282 | |
| 283 | .PHONY: clean |
| 284 | clean: |
| 285 | @echo " CLEAN" |
| 286 | ${Q}rm -rf ${BUILD_PLAT} |
| 287 | ${MAKE} -C el3_payload clean |
| 288 | |
| 289 | .PHONY: realclean distclean |
| 290 | realclean distclean: |
| 291 | @echo " REALCLEAN" |
| 292 | ${Q}rm -rf ${BUILD_BASE} |
| 293 | ${Q}rm -f ${CURDIR}/cscope.* |
| 294 | ${MAKE} -C el3_payload distclean |
| 295 | |
| 296 | .PHONY: checkcodebase |
| 297 | checkcodebase: locate-checkpatch |
| 298 | @echo " CHECKING STYLE" |
| 299 | @if test -d .git ; then \ |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 300 | git ls-files | grep -E -v 'libc|docs|\.md|\.rst' | \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 301 | while read GIT_FILE ; \ |
| 302 | do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ |
| 303 | done ; \ |
| 304 | else \ |
| 305 | find . -type f -not -iwholename "*.git*" \ |
| 306 | -not -iwholename "*build*" \ |
Ambroise Vincent | a2ede62 | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 307 | -not -iwholename "*libc*" \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 308 | -not -iwholename "*docs*" \ |
| 309 | -not -iwholename "*.md" \ |
| 310 | -not -iwholename "*.rst" \ |
| 311 | -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ |
| 312 | fi |
| 313 | |
| 314 | .PHONY: checkpatch |
| 315 | checkpatch: locate-checkpatch |
| 316 | @echo " CHECKING STYLE" |
| 317 | ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ |
| 318 | for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \ |
| 319 | printf "\n[*] Checking style of '$$commit'\n\n"; \ |
| 320 | git log --format=email "$$commit~..$$commit" \ |
| 321 | -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \ |
| 322 | git diff --format=email "$$commit~..$$commit" \ |
| 323 | -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \ |
| 324 | done |
| 325 | |
| 326 | ifneq (${FIRMWARE_UPDATE},1) |
| 327 | .PHONY: ns_bl1u ns_bl2u |
| 328 | ns_bl1u ns_bl2u: |
| 329 | @echo "ERROR: Can't build $@ because Firmware Update is not supported \ |
| 330 | on this platform." |
| 331 | @exit 1 |
| 332 | endif |
| 333 | |
| 334 | ifneq (${ARCH}-${PLAT},aarch64-fvp) |
Antonio Nino Diaz | 9d7726c | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 335 | .PHONY: cactus_mm |
| 336 | cactus_mm: |
| 337 | @echo "ERROR: $@ is supported only on AArch64 FVP." |
| 338 | @exit 1 |
| 339 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 340 | .PHONY: cactus |
| 341 | cactus: |
| 342 | @echo "ERROR: $@ is supported only on AArch64 FVP." |
| 343 | @exit 1 |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 344 | |
| 345 | .PHONY: ivy |
| 346 | ivy: |
| 347 | @echo "ERROR: $@ is supported only on AArch64 FVP." |
| 348 | @exit 1 |
Antonio Nino Diaz | fee6e7e | 2019-03-28 13:16:04 +0000 | [diff] [blame] | 349 | |
| 350 | .PHONY: quark |
| 351 | quark: |
| 352 | @echo "ERROR: $@ is supported only on AArch64 FVP." |
| 353 | @exit 1 |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 354 | endif |
| 355 | |
| 356 | MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ |
| 357 | |
| 358 | define MAKE_C |
| 359 | |
| 360 | $(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) |
| 361 | $(eval DEP := $(patsubst %.o,%.d,$(OBJ))) |
| 362 | |
Bence Szépkúti | 25671c2 | 2019-11-29 18:23:56 +0100 | [diff] [blame] | 363 | $(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 364 | @echo " CC $$<" |
| 365 | $$(Q)$$(CC) $$($(3)_CFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@ |
| 366 | |
| 367 | -include $(DEP) |
| 368 | endef |
| 369 | |
| 370 | |
| 371 | define MAKE_S |
| 372 | |
| 373 | $(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) |
| 374 | $(eval DEP := $(patsubst %.o,%.d,$(OBJ))) |
| 375 | |
Bence Szépkúti | 25671c2 | 2019-11-29 18:23:56 +0100 | [diff] [blame] | 376 | $(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 377 | @echo " AS $$<" |
| 378 | $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@ |
| 379 | |
| 380 | -include $(DEP) |
| 381 | endef |
| 382 | |
| 383 | |
| 384 | define MAKE_LD |
| 385 | |
| 386 | $(eval DEP := $(1).d) |
| 387 | |
Bence Szépkúti | 25671c2 | 2019-11-29 18:23:56 +0100 | [diff] [blame] | 388 | $(1) : $(2) | $(AUTOGEN_DIR)/tests_list.h |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 389 | @echo " PP $$<" |
| 390 | $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -P -E $(MAKE_DEP) -o $$@ $$< |
| 391 | |
| 392 | -include $(DEP) |
| 393 | endef |
| 394 | |
| 395 | |
| 396 | define MAKE_OBJS |
| 397 | $(eval C_OBJS := $(filter %.c,$(2))) |
| 398 | $(eval REMAIN := $(filter-out %.c,$(2))) |
| 399 | $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3)))) |
| 400 | |
| 401 | $(eval S_OBJS := $(filter %.S,$(REMAIN))) |
| 402 | $(eval REMAIN := $(filter-out %.S,$(REMAIN))) |
| 403 | $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3)))) |
| 404 | |
| 405 | $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN))) |
| 406 | endef |
| 407 | |
| 408 | |
| 409 | # NOTE: The line continuation '\' is required in the next define otherwise we |
| 410 | # end up with a line-feed characer at the end of the last c filename. |
| 411 | # Also bare this issue in mind if extending the list of supported filetypes. |
| 412 | define SOURCES_TO_OBJS |
| 413 | $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \ |
| 414 | $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1)))) |
| 415 | endef |
| 416 | |
| 417 | define uppercase |
| 418 | $(shell echo $(1) | tr '[:lower:]' '[:upper:]') |
| 419 | endef |
| 420 | |
| 421 | define MAKE_IMG |
| 422 | $(eval IMG_PREFIX := $(call uppercase, $(1))) |
| 423 | $(eval BUILD_DIR := ${BUILD_PLAT}/$(1)) |
| 424 | $(eval SOURCES := $(${IMG_PREFIX}_SOURCES)) |
| 425 | $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES)))) |
| 426 | $(eval LINKERFILE := $(BUILD_DIR)/$(1).ld) |
| 427 | $(eval MAPFILE := $(BUILD_DIR)/$(1).map) |
| 428 | $(eval ELF := $(BUILD_DIR)/$(1).elf) |
| 429 | $(eval DUMP := $(BUILD_DIR)/$(1).dump) |
| 430 | $(eval BIN := $(BUILD_PLAT)/$(1).bin) |
| 431 | |
| 432 | $(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),${IMG_PREFIX})) |
| 433 | $(eval $(call MAKE_LD,$(LINKERFILE),$(${IMG_PREFIX}_LINKERFILE),${IMG_PREFIX})) |
| 434 | |
| 435 | $(BUILD_DIR) : |
| 436 | $$(Q)mkdir -p "$$@" |
| 437 | |
| 438 | $(ELF) : $(OBJS) $(LINKERFILE) |
| 439 | @echo " LD $$@" |
| 440 | @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \ |
| 441 | const char version_string[] = "${VERSION_STRING}";' | \ |
| 442 | $$(CC) $$(${IMG_PREFIX}_CFLAGS) ${${IMG_PREFIX}_INCLUDES} ${${IMG_PREFIX}_DEFINES} -c -xc - -o $(BUILD_DIR)/build_message.o |
| 443 | $$(Q)$$(LD) -o $$@ $$(${IMG_PREFIX}_LDFLAGS) -Map=$(MAPFILE) \ |
| 444 | -T $(LINKERFILE) $(BUILD_DIR)/build_message.o $(OBJS) |
| 445 | |
| 446 | $(DUMP) : $(ELF) |
| 447 | @echo " OD $$@" |
| 448 | $${Q}$${OD} -dx $$< > $$@ |
| 449 | |
| 450 | $(BIN) : $(ELF) |
| 451 | @echo " BIN $$@" |
| 452 | $$(Q)$$(OC) -O binary $$< $$@ |
| 453 | @echo |
| 454 | @echo "Built $$@ successfully" |
| 455 | @echo |
| 456 | |
| 457 | .PHONY : $(1) |
| 458 | $(1) : $(BUILD_DIR) $(BIN) $(DUMP) |
| 459 | |
| 460 | all : $(1) |
| 461 | |
| 462 | endef |
| 463 | |
| 464 | $(AUTOGEN_DIR): |
| 465 | $(Q)mkdir -p "$@" |
| 466 | |
| 467 | $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h: $(AUTOGEN_DIR) ${TESTS_FILE} ${PLAT_TESTS_SKIP_LIST} |
| 468 | @echo " AUTOGEN $@" |
| 469 | tools/generate_test_list/generate_test_list.pl $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h ${TESTS_FILE} $(PLAT_TESTS_SKIP_LIST) |
| 470 | |
| 471 | $(eval $(call MAKE_IMG,tftf)) |
| 472 | |
| 473 | ifeq ($(FIRMWARE_UPDATE), 1) |
| 474 | $(eval $(call MAKE_IMG,ns_bl1u)) |
| 475 | $(eval $(call MAKE_IMG,ns_bl2u)) |
| 476 | endif |
| 477 | |
| 478 | ifeq (${ARCH}-${PLAT},aarch64-fvp) |
Antonio Nino Diaz | 9d7726c | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 479 | $(eval $(call MAKE_IMG,cactus_mm)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 480 | $(eval $(call MAKE_IMG,cactus)) |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 481 | $(eval $(call MAKE_IMG,ivy)) |
Antonio Nino Diaz | fee6e7e | 2019-03-28 13:16:04 +0000 | [diff] [blame] | 482 | $(eval $(call MAKE_IMG,quark)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 483 | endif |
| 484 | |
| 485 | # The EL3 test payload is only supported in AArch64. It has an independent build |
| 486 | # system. |
| 487 | .PHONY: el3_payload |
| 488 | ifneq (${ARCH},aarch32) |
| 489 | el3_payload: $(BUILD_DIR) |
| 490 | ${Q}${MAKE} -C el3_payload PLAT=${PLAT} |
| 491 | ${Q}find "el3_payload/build/${PLAT}" -name '*.bin' -exec cp {} "${BUILD_PLAT}" \; |
| 492 | |
| 493 | all: el3_payload |
| 494 | endif |
| 495 | |
Sandrine Bailleux | 7fb2e0a | 2020-04-21 14:45:00 +0200 | [diff] [blame] | 496 | doc: |
| 497 | @echo " BUILD DOCUMENTATION" |
| 498 | ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html |
| 499 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 500 | .PHONY: cscope |
| 501 | cscope: |
| 502 | @echo " CSCOPE" |
| 503 | ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files |
| 504 | ${Q}cscope -b -q -k |
| 505 | |
| 506 | .PHONY: help |
Leonardo Sandoval | 2d039ad | 2020-09-11 14:44:40 -0500 | [diff] [blame] | 507 | .SILENT: help |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 508 | help: |
Leonardo Sandoval | 2d039ad | 2020-09-11 14:44:40 -0500 | [diff] [blame] | 509 | echo "usage: ${MAKE} PLAT=<${PLATFORMS}> \ |
Leonardo Sandoval | 5c882ba | 2020-07-14 11:00:31 -0500 | [diff] [blame] | 510 | <all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|quark|el3_payload|distclean|clean|checkcodebase|checkpatch|help_tests>" |
Leonardo Sandoval | 2d039ad | 2020-09-11 14:44:40 -0500 | [diff] [blame] | 511 | echo "" |
| 512 | echo "PLAT is used to specify which platform you wish to build." |
| 513 | echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" |
| 514 | echo "" |
| 515 | echo "Supported Targets:" |
| 516 | echo " all Build all supported binaries for this platform" |
| 517 | echo " (i.e. TFTF and FWU images)" |
| 518 | echo " tftf Build the TFTF image" |
| 519 | echo " ns_bl1u Build the NS_BL1U image" |
| 520 | echo " ns_bl2u Build the NS_BL2U image" |
| 521 | echo " cactus Build the Cactus image (Test S-EL0 payload) and resource description." |
| 522 | echo " cactus_mm Build the Cactus-MM image (Test S-EL0 payload)." |
| 523 | echo " ivy Build the Ivy image (Test S-EL0 payload) and resource description." |
| 524 | echo " quark Build the Quark image (Test S-EL0 payload) and resource description." |
| 525 | echo " el3_payload Build the EL3 test payload" |
| 526 | echo " checkcodebase Check the coding style of the entire source tree" |
| 527 | echo " checkpatch Check the coding style on changes in the current" |
| 528 | echo " branch against BASE_COMMIT (default origin/master)" |
| 529 | echo " doc Build html based documentation using Sphinx tool" |
| 530 | echo " clean Clean the build for the selected platform" |
| 531 | echo " cscope Generate cscope index" |
| 532 | echo " distclean Remove all build artifacts for all platforms" |
| 533 | echo " help_tests List all possible sets of tests" |
| 534 | echo "" |
| 535 | echo "note: most build targets require PLAT to be set to a specific platform." |
| 536 | echo "" |
| 537 | echo "example: build all targets for the FVP platform:" |
| 538 | echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" |