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