Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | # |
Jerry Wang | d49873a | 2024-07-25 13:45:13 +0100 | [diff] [blame] | 2 | # Copyright (c) 2018-2024, 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 |
Harrison Mutai | cf898bb | 2024-11-15 09:43:11 +0000 | [diff] [blame] | 9 | VERSION_MINOR := 12 |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 10 | |
Leonardo Sandoval | 667fd72 | 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 | 667fd72 | 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 \ |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 32 | include/lib/libfdt \ |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 33 | include/lib/libc, \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 34 | $(wildcard include/lib/*))) |
| 35 | LIB_DIRS_TO_CHECK := $(sort $(filter-out \ |
| 36 | lib/compiler-rt \ |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 37 | lib/libfdt% \ |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 38 | lib/libc, \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 39 | $(wildcard lib/*))) |
| 40 | ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ |
| 41 | lib \ |
| 42 | include \ |
| 43 | docs \ |
| 44 | %.md \ |
| 45 | %.rst, \ |
| 46 | $(wildcard *))) |
| 47 | CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ |
| 48 | ${INC_LIB_DIRS_TO_CHECK} \ |
| 49 | ${LIB_DIRS_TO_CHECK} |
| 50 | |
| 51 | ifeq (${V},0) |
| 52 | Q=@ |
| 53 | else |
| 54 | Q= |
| 55 | endif |
| 56 | export Q |
| 57 | |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 58 | ################################################################################ |
| 59 | # Toolchain configs |
| 60 | ################################################################################ |
| 61 | CC := ${CROSS_COMPILE}gcc |
| 62 | CPP := ${CROSS_COMPILE}cpp |
| 63 | AS := ${CROSS_COMPILE}gcc |
| 64 | AR := ${CROSS_COMPILE}ar |
| 65 | LD := ${CROSS_COMPILE}ld |
| 66 | OC := ${CROSS_COMPILE}objcopy |
| 67 | OD := ${CROSS_COMPILE}objdump |
| 68 | NM := ${CROSS_COMPILE}nm |
| 69 | PP := ${CROSS_COMPILE}gcc |
| 70 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 71 | ifneq (${DEBUG}, 0) |
| 72 | BUILD_TYPE := debug |
| 73 | # Use LOG_LEVEL_INFO by default for debug builds |
| 74 | LOG_LEVEL := 40 |
| 75 | else |
| 76 | BUILD_TYPE := release |
| 77 | # Use LOG_LEVEL_ERROR by default for release builds |
| 78 | LOG_LEVEL := 20 |
| 79 | endif |
| 80 | |
| 81 | # Default build string (git branch and commit) |
| 82 | ifeq (${BUILD_STRING},) |
Manish V Badarkhe | ce14941 | 2022-05-24 22:54:45 +0100 | [diff] [blame] | 83 | BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 84 | endif |
| 85 | |
| 86 | VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${PLAT},${BUILD_TYPE}):${BUILD_STRING} |
| 87 | |
| 88 | BUILD_BASE := ./build |
| 89 | BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE} |
| 90 | |
| 91 | PLAT_MAKEFILE := platform.mk |
| 92 | # Generate the platforms list by recursively searching for all directories |
| 93 | # under /plat containing a PLAT_MAKEFILE. Append each platform with a `|` |
| 94 | # char and strip out the final '|'. |
| 95 | PLATFORMS := $(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 | \ |
| 96 | sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' | \ |
| 97 | sed -r 's/\|$$//') |
| 98 | |
Sandrine Bailleux | f8228af | 2020-04-21 14:45:00 +0200 | [diff] [blame] | 99 | DOCS_PATH := docs |
| 100 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 101 | ifeq (${PLAT},) |
| 102 | $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform") |
| 103 | endif |
| 104 | PLAT_PATH := $(shell find plat/ -wholename '*/${PLAT}') |
| 105 | PLAT_MAKEFILE_FULL := ${PLAT_PATH}/${PLAT_MAKEFILE} |
| 106 | ifeq ($(wildcard ${PLAT_MAKEFILE_FULL}),) |
| 107 | $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}") |
| 108 | endif |
| 109 | |
Arvind Ram Prakash | 2e1264d | 2022-05-20 12:27:40 -0500 | [diff] [blame] | 110 | |
| 111 | EL3_PAYLOAD_PLAT_PATH := $(shell find el3_payload/plat/ -wholename '*/${PLAT}') |
| 112 | EL3_PAYLOAD_PLAT_MAKEFILE_FULL := ${EL3_PAYLOAD_PLAT_PATH}/${PLAT_MAKEFILE} |
| 113 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 114 | .PHONY: all |
| 115 | all: msg_start |
| 116 | |
| 117 | .PHONY: msg_start |
| 118 | msg_start: |
| 119 | @echo "Building ${PLAT}" |
Sandrine Bailleux | 043d536 | 2018-10-03 17:05:59 +0200 | [diff] [blame] | 120 | @echo "Selected set of tests: ${TESTS}" |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 121 | |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 122 | # Set flags for Realm Payload Tests |
| 123 | ifeq (${ENABLE_REALM_PAYLOAD_TESTS},1) |
Shruti Gupta | 24597d1 | 2023-10-02 10:40:19 +0100 | [diff] [blame] | 124 | ARM_ARCH_MINOR := 5 |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 125 | BRANCH_PROTECTION := 2 |
| 126 | endif |
| 127 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 128 | # Include test images makefiles. |
| 129 | include tftf/framework/framework.mk |
| 130 | include tftf/tests/tests.mk |
| 131 | include fwu/ns_bl1u/ns_bl1u.mk |
| 132 | include fwu/ns_bl2u/ns_bl2u.mk |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 133 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 134 | # List of secure partitions present. |
| 135 | SECURE_PARTITIONS := |
| 136 | |
Jerry Wang | d49873a | 2024-07-25 13:45:13 +0100 | [diff] [blame] | 137 | # Only platform fvp and rdv3 supports cactus_mm |
| 138 | ifeq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-rdv3)) |
Antonio Nino Diaz | f2218e7 | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 139 | include spm/cactus_mm/cactus_mm.mk |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 140 | include realm/realm.mk |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 141 | endif |
| 142 | |
Daniel Boulby | c19215a | 2023-05-17 13:50:36 +0100 | [diff] [blame] | 143 | # cactus and ivy are supported on platforms: fvp, tc |
| 144 | ifeq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc)) |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 145 | include spm/cactus/cactus.mk |
Olivier Deprez | 2765ebf | 2020-12-16 15:46:14 +0100 | [diff] [blame] | 146 | include spm/ivy/ivy.mk |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 147 | endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 148 | |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 149 | ################################################################################ |
| 150 | # Include libc |
| 151 | ################################################################################ |
| 152 | include lib/libc/libc.mk |
| 153 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 154 | # Include platform specific makefile last because: |
| 155 | # - the platform makefile may use all previous definitions in this file. |
| 156 | # - the platform makefile may wish overwriting some of them. |
| 157 | include ${PLAT_MAKEFILE_FULL} |
| 158 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 159 | .SUFFIXES: |
| 160 | |
| 161 | ################################################################################ |
| 162 | # Build options checks |
| 163 | ################################################################################ |
| 164 | $(eval $(call assert_boolean,DEBUG)) |
| 165 | $(eval $(call assert_boolean,ENABLE_ASSERTIONS)) |
| 166 | $(eval $(call assert_boolean,FIRMWARE_UPDATE)) |
| 167 | $(eval $(call assert_boolean,FWU_BL_TEST)) |
| 168 | $(eval $(call assert_boolean,NEW_TEST_SESSION)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 169 | $(eval $(call assert_boolean,USE_NVM)) |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 170 | $(eval $(call assert_numeric,BRANCH_PROTECTION)) |
| 171 | $(eval $(call assert_boolean,ENABLE_REALM_PAYLOAD_TESTS)) |
Harrison Mutai | 6e01164 | 2023-09-22 17:17:35 +0100 | [diff] [blame] | 172 | $(eval $(call assert_boolean,TRANSFER_LIST)) |
Madhukar Pappireddy | 6f7344b | 2024-07-05 16:21:26 -0500 | [diff] [blame] | 173 | $(eval $(call assert_boolean,SPMC_AT_EL3)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 174 | |
| 175 | ################################################################################ |
Alexei Fedorov | 7fac162 | 2020-06-19 14:25:43 +0100 | [diff] [blame] | 176 | # Process build options |
| 177 | ################################################################################ |
| 178 | |
| 179 | # Process BRANCH_PROTECTION value and set |
| 180 | # Pointer Authentication and Branch Target Identification flags |
| 181 | include branch_protection.mk |
| 182 | |
| 183 | ################################################################################ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 184 | # Add definitions to the cpp preprocessor based on the current build options. |
| 185 | # This is done after including the platform specific makefile to allow the |
| 186 | # platform to overwrite the default options |
| 187 | ################################################################################ |
| 188 | $(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MAJOR)) |
| 189 | $(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MINOR)) |
| 190 | $(eval $(call add_define,TFTF_DEFINES,DEBUG)) |
| 191 | $(eval $(call add_define,TFTF_DEFINES,ENABLE_ASSERTIONS)) |
Alexei Fedorov | 7fac162 | 2020-06-19 14:25:43 +0100 | [diff] [blame] | 192 | $(eval $(call add_define,TFTF_DEFINES,ENABLE_BTI)) |
Antonio Nino Diaz | 9c9f92c | 2019-03-13 13:57:39 +0000 | [diff] [blame] | 193 | $(eval $(call add_define,TFTF_DEFINES,ENABLE_PAUTH)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 194 | $(eval $(call add_define,TFTF_DEFINES,LOG_LEVEL)) |
| 195 | $(eval $(call add_define,TFTF_DEFINES,NEW_TEST_SESSION)) |
| 196 | $(eval $(call add_define,TFTF_DEFINES,PLAT_${PLAT})) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 197 | $(eval $(call add_define,TFTF_DEFINES,USE_NVM)) |
Soby Mathew | 6e5c996 | 2023-10-06 16:38:13 +0100 | [diff] [blame] | 198 | $(eval $(call add_define,TFTF_DEFINES,ENABLE_REALM_PAYLOAD_TESTS)) |
Harrison Mutai | 6e01164 | 2023-09-22 17:17:35 +0100 | [diff] [blame] | 199 | $(eval $(call add_define,TFTF_DEFINES,TRANSFER_LIST)) |
Juan Pablo Conde | c3cf2da | 2024-04-01 13:57:19 -0500 | [diff] [blame] | 200 | $(eval $(call add_define,TFTF_DEFINES,PLAT_AMU_GROUP1_COUNTERS_MASK)) |
Madhukar Pappireddy | 6f7344b | 2024-07-05 16:21:26 -0500 | [diff] [blame] | 201 | $(eval $(call add_define,TFTF_DEFINES,SPMC_AT_EL3)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 202 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 203 | ################################################################################ |
| 204 | |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 205 | ################################################################################ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 206 | # Assembler, compiler and linker flags shared across all test images. |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 207 | ################################################################################ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 208 | COMMON_ASFLAGS := |
| 209 | COMMON_CFLAGS := |
| 210 | COMMON_LDFLAGS := |
| 211 | |
| 212 | ifeq (${DEBUG},1) |
Daniel Boulby | ed1f951 | 2022-05-03 16:36:51 +0100 | [diff] [blame] | 213 | COMMON_CFLAGS += -g -gdwarf-4 |
| 214 | COMMON_ASFLAGS += -g -Wa,--gdwarf-4 |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 215 | endif |
| 216 | |
Joel Hutton | 6a6f483 | 2019-04-08 15:46:36 +0100 | [diff] [blame] | 217 | # Set the compiler's target architecture profile based on ARM_ARCH_MINOR option |
| 218 | ifeq (${ARM_ARCH_MINOR},0) |
Alexei Fedorov | d92f4ce | 2020-12-07 18:13:28 +0000 | [diff] [blame] | 219 | march32-directive = -march=armv${ARM_ARCH_MAJOR}-a |
| 220 | march64-directive = -march=armv${ARM_ARCH_MAJOR}-a |
Joel Hutton | 6a6f483 | 2019-04-08 15:46:36 +0100 | [diff] [blame] | 221 | else |
Alexei Fedorov | d92f4ce | 2020-12-07 18:13:28 +0000 | [diff] [blame] | 222 | march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a |
| 223 | march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a |
Joel Hutton | 6a6f483 | 2019-04-08 15:46:36 +0100 | [diff] [blame] | 224 | endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 225 | |
Alexei Fedorov | d92f4ce | 2020-12-07 18:13:28 +0000 | [diff] [blame] | 226 | # Get architecture feature modifiers |
| 227 | arch-features = ${ARM_ARCH_FEATURE} |
| 228 | |
| 229 | # Set the compiler's architecture feature modifiers |
| 230 | ifneq ($(arch-features), none) |
| 231 | ifeq ($(ARCH), aarch32) |
| 232 | march32-directive := $(march32-directive)+$(arch-features) |
| 233 | else |
| 234 | march64-directive := $(march64-directive)+$(arch-features) |
| 235 | endif |
| 236 | # Print features |
| 237 | $(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) |
| 238 | endif # arch-features |
| 239 | |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 240 | ################################################################################ |
| 241 | # Compiler settings |
| 242 | ################################################################################ |
| 243 | ifneq ($(findstring clang,$(notdir $(CC))),) |
| 244 | CLANG_CFLAGS_aarch64 := -target aarch64-elf |
Joel Hutton | 6a6f483 | 2019-04-08 15:46:36 +0100 | [diff] [blame] | 245 | |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 246 | CPP := $(CC) -E $(COMMON_CFLAGS_$(ARCH)) |
| 247 | PP := $(CC) -E $(COMMON_CFLAGS_$(ARCH)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 248 | |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 249 | CLANG_WARNINGS += -nostdinc -ffreestanding -Wall \ |
| 250 | -Wmissing-include-dirs $(CLANG_CFLAGS_$(ARCH)) \ |
| 251 | -Wlogical-op-parentheses \ |
| 252 | -Wno-initializer-overrides \ |
| 253 | -Wno-sometimes-uninitialized \ |
| 254 | -Wno-unused-function \ |
| 255 | -Wno-unused-variable \ |
| 256 | -Wno-unused-parameter \ |
| 257 | -Wno-tautological-compare \ |
| 258 | -Wno-memset-transposed-args \ |
| 259 | -Wno-parentheses |
| 260 | |
| 261 | CLANG_CFLAGS += -Wno-error=deprecated-declarations \ |
| 262 | -Wno-error=cpp \ |
| 263 | $(CLANG_WARNINGS) |
| 264 | endif #(clang) |
| 265 | |
| 266 | ifneq ($(findstring gcc,$(notdir $(CC))),) |
| 267 | GCC_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access |
| 268 | GCC_CFLAGS_aarch64 := -mgeneral-regs-only |
| 269 | |
| 270 | GCC_ASFLAGS_aarch32 := ${march32-directive} |
| 271 | GCC_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive} |
| 272 | |
| 273 | GCC_WARNINGS += -nostdinc -ffreestanding -Wall -Werror \ |
| 274 | -Wmissing-include-dirs $(GCC_CFLAGS_$(ARCH)) \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 275 | -std=gnu99 -Os |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 276 | |
| 277 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 |
| 278 | GCC_CFLAGS += $(call cc_option, --param=min-pagesize=0) |
| 279 | GCC_CFLAGS += $(GCC_WARNINGS) |
| 280 | endif #(gcc) |
| 281 | |
| 282 | COMMON_CFLAGS_aarch64 += ${march64-directive} -mstrict-align \ |
| 283 | $(CLANG_CFLAGS_$(ARCH)) $(GCC_CFLAGS_$(ARCH)) |
| 284 | |
| 285 | COMMON_CFLAGS += $(COMMON_CFLAGS_$(ARCH)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 286 | COMMON_CFLAGS += -ffunction-sections -fdata-sections |
| 287 | |
| 288 | # Get the content of CFLAGS user defined value last so they are appended after |
| 289 | # the options defined in the Makefile |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 290 | COMMON_CFLAGS += ${CLANG_CFLAGS} ${GCC_CFLAGS} ${INCLUDES} |
| 291 | |
| 292 | COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ |
| 293 | -Werror -Wmissing-include-dirs \ |
| 294 | -D__ASSEMBLY__ $(GCC_ASFLAGS_$(ARCH)) \ |
| 295 | ${INCLUDES} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 296 | |
Karl Meakin | e69d128 | 2023-03-07 17:10:07 +0000 | [diff] [blame] | 297 | COMMON_LDFLAGS += ${LDFLAGS} --fatal-warnings -O1 --gc-sections --build-id=none |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 298 | |
Soby Mathew | 25d9e2f | 2023-05-05 10:51:57 +0100 | [diff] [blame] | 299 | # With ld.bfd version 2.39 and newer new warnings are added. Skip those since we |
| 300 | # are not loaded by a elf loader. |
| 301 | COMMON_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) |
| 302 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 303 | ################################################################################ |
| 304 | |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 305 | TFTF_SOURCES := ${FRAMEWORK_SOURCES} ${TESTS_SOURCES} ${PLAT_SOURCES} ${LIBC_SRCS} ${LIBFDT_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 306 | TFTF_INCLUDES += ${PLAT_INCLUDES} |
| 307 | TFTF_CFLAGS += ${COMMON_CFLAGS} |
| 308 | TFTF_ASFLAGS += ${COMMON_ASFLAGS} |
| 309 | TFTF_LDFLAGS += ${COMMON_LDFLAGS} |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 310 | TFTF_EXTRA_OBJS := |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 311 | |
Alexei Fedorov | 7fac162 | 2020-06-19 14:25:43 +0100 | [diff] [blame] | 312 | ifneq (${BP_OPTION},none) |
| 313 | TFTF_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 314 | NS_BL1U_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 315 | NS_BL2U_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 316 | CACTUS_MM_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 317 | CACTUS_CFLAGS += -mbranch-protection=${BP_OPTION} |
| 318 | IVY_CFLAGS += -mbranch-protection=${BP_OPTION} |
AlexeiFedorov | 193b356 | 2022-12-22 16:50:08 +0000 | [diff] [blame] | 319 | REALM_CFLAGS += -mbranch-protection=${BP_OPTION} |
Antonio Nino Diaz | 9c9f92c | 2019-03-13 13:57:39 +0000 | [diff] [blame] | 320 | endif |
| 321 | |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 322 | ifeq ($(SMC_FUZZING), 1) |
| 323 | TFTF_EXTRA_OBJS += ${BUILD_PLAT}/smcf/dtb.o |
| 324 | endif |
| 325 | |
Olivier Deprez | 231115d | 2020-02-03 11:27:01 +0100 | [diff] [blame] | 326 | ##################################################################################### |
| 327 | ifneq ($(findstring gcc,$(notdir $(LD))),) |
| 328 | PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker |
| 329 | else |
| 330 | PIE_LDFLAGS += -pie --no-dynamic-linker |
| 331 | endif |
| 332 | |
| 333 | ##################################################################################### |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 334 | NS_BL1U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 335 | NS_BL1U_INCLUDES += ${PLAT_INCLUDES} |
| 336 | NS_BL1U_CFLAGS += ${COMMON_CFLAGS} |
| 337 | NS_BL1U_ASFLAGS += ${COMMON_ASFLAGS} |
| 338 | NS_BL1U_LDFLAGS += ${COMMON_LDFLAGS} |
| 339 | |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 340 | NS_BL2U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 341 | NS_BL2U_INCLUDES += ${PLAT_INCLUDES} |
| 342 | NS_BL2U_CFLAGS += ${COMMON_CFLAGS} |
| 343 | NS_BL2U_ASFLAGS += ${COMMON_ASFLAGS} |
| 344 | NS_BL2U_LDFLAGS += ${COMMON_LDFLAGS} |
| 345 | |
Antonio Nino Diaz | f2218e7 | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 346 | CACTUS_MM_SOURCES += ${LIBC_SRCS} |
| 347 | CACTUS_MM_INCLUDES += ${PLAT_INCLUDES} |
| 348 | CACTUS_MM_CFLAGS += ${COMMON_CFLAGS} |
| 349 | CACTUS_MM_ASFLAGS += ${COMMON_ASFLAGS} |
| 350 | CACTUS_MM_LDFLAGS += ${COMMON_LDFLAGS} |
| 351 | |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 352 | CACTUS_SOURCES += ${LIBC_SRCS} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 353 | CACTUS_INCLUDES += ${PLAT_INCLUDES} |
Olivier Deprez | 231115d | 2020-02-03 11:27:01 +0100 | [diff] [blame] | 354 | CACTUS_CFLAGS += ${COMMON_CFLAGS} -fpie |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 355 | CACTUS_ASFLAGS += ${COMMON_ASFLAGS} |
Olivier Deprez | 231115d | 2020-02-03 11:27:01 +0100 | [diff] [blame] | 356 | CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 357 | |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 358 | IVY_SOURCES += ${LIBC_SRCS} |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 359 | IVY_INCLUDES += ${PLAT_INCLUDES} |
Ruari Phipps | 9f1952c | 2020-08-24 11:32:32 +0100 | [diff] [blame] | 360 | IVY_CFLAGS += ${COMMON_CFLAGS} -fpie |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 361 | IVY_ASFLAGS += ${COMMON_ASFLAGS} |
Ruari Phipps | 9f1952c | 2020-08-24 11:32:32 +0100 | [diff] [blame] | 362 | IVY_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS) |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 363 | |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 364 | REALM_SOURCES += ${LIBC_SRCS} |
| 365 | REALM_CFLAGS += ${COMMON_CFLAGS} -fpie |
| 366 | REALM_ASFLAGS += ${COMMON_ASFLAGS} |
| 367 | REALM_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS) |
| 368 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 369 | .PHONY: locate-checkpatch |
| 370 | locate-checkpatch: |
| 371 | ifndef CHECKPATCH |
| 372 | $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl") |
| 373 | else |
| 374 | ifeq (,$(wildcard ${CHECKPATCH})) |
| 375 | $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl") |
| 376 | endif |
| 377 | endif |
| 378 | |
| 379 | .PHONY: clean |
| 380 | clean: |
| 381 | @echo " CLEAN" |
| 382 | ${Q}rm -rf ${BUILD_PLAT} |
Shriram K | 8687985 | 2022-09-15 15:45:05 +0530 | [diff] [blame] | 383 | ifneq ($(wildcard ${EL3_PAYLOAD_PLAT_MAKEFILE_FULL}),) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 384 | ${MAKE} -C el3_payload clean |
Shriram K | 8687985 | 2022-09-15 15:45:05 +0530 | [diff] [blame] | 385 | endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 386 | |
| 387 | .PHONY: realclean distclean |
| 388 | realclean distclean: |
| 389 | @echo " REALCLEAN" |
| 390 | ${Q}rm -rf ${BUILD_BASE} |
| 391 | ${Q}rm -f ${CURDIR}/cscope.* |
Shriram K | 8687985 | 2022-09-15 15:45:05 +0530 | [diff] [blame] | 392 | ifneq ($(wildcard ${EL3_PAYLOAD_PLAT_MAKEFILE_FULL}),) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 393 | ${MAKE} -C el3_payload distclean |
Shriram K | 8687985 | 2022-09-15 15:45:05 +0530 | [diff] [blame] | 394 | endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 395 | |
| 396 | .PHONY: checkcodebase |
| 397 | checkcodebase: locate-checkpatch |
| 398 | @echo " CHECKING STYLE" |
| 399 | @if test -d .git ; then \ |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 400 | git ls-files | grep -E -v 'libfdt|libc|docs|\.md|\.rst' | \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 401 | while read GIT_FILE ; \ |
| 402 | do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ |
| 403 | done ; \ |
| 404 | else \ |
| 405 | find . -type f -not -iwholename "*.git*" \ |
| 406 | -not -iwholename "*build*" \ |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 407 | -not -iwholename "*libfdt*" \ |
Ambroise Vincent | d6e806d | 2019-02-11 14:34:26 +0000 | [diff] [blame] | 408 | -not -iwholename "*libc*" \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 409 | -not -iwholename "*docs*" \ |
| 410 | -not -iwholename "*.md" \ |
| 411 | -not -iwholename "*.rst" \ |
| 412 | -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ |
| 413 | fi |
| 414 | |
| 415 | .PHONY: checkpatch |
| 416 | checkpatch: locate-checkpatch |
| 417 | @echo " CHECKING STYLE" |
| 418 | ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ |
| 419 | for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \ |
| 420 | printf "\n[*] Checking style of '$$commit'\n\n"; \ |
| 421 | git log --format=email "$$commit~..$$commit" \ |
| 422 | -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \ |
| 423 | git diff --format=email "$$commit~..$$commit" \ |
| 424 | -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \ |
| 425 | done |
| 426 | |
| 427 | ifneq (${FIRMWARE_UPDATE},1) |
| 428 | .PHONY: ns_bl1u ns_bl2u |
| 429 | ns_bl1u ns_bl2u: |
| 430 | @echo "ERROR: Can't build $@ because Firmware Update is not supported \ |
| 431 | on this platform." |
| 432 | @exit 1 |
| 433 | endif |
| 434 | |
Jerry Wang | d49873a | 2024-07-25 13:45:13 +0100 | [diff] [blame] | 435 | ifneq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-rdv3)) |
Antonio Nino Diaz | f2218e7 | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 436 | .PHONY: cactus_mm |
| 437 | cactus_mm: |
| 438 | @echo "ERROR: $@ is supported only on AArch64 FVP." |
| 439 | @exit 1 |
| 440 | |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 441 | .PHONY: realm |
| 442 | realm: |
Jerry Wang | d49873a | 2024-07-25 13:45:13 +0100 | [diff] [blame] | 443 | @echo "ERROR: $@ is supported only on AArch64 FVP and RD-V3." |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 444 | @exit 1 |
| 445 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 446 | endif |
| 447 | |
Daniel Boulby | c19215a | 2023-05-17 13:50:36 +0100 | [diff] [blame] | 448 | ifneq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc)) |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 449 | .PHONY: cactus |
| 450 | cactus: |
Daniel Boulby | c19215a | 2023-05-17 13:50:36 +0100 | [diff] [blame] | 451 | @echo "ERROR: $@ is supported only on AArch64 FVP or TC." |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 452 | @exit 1 |
Olivier Deprez | 2765ebf | 2020-12-16 15:46:14 +0100 | [diff] [blame] | 453 | |
| 454 | .PHONY: ivy |
| 455 | ivy: |
Daniel Boulby | c19215a | 2023-05-17 13:50:36 +0100 | [diff] [blame] | 456 | @echo "ERROR: $@ is supported only on AArch64 FVP or TC." |
Olivier Deprez | 2765ebf | 2020-12-16 15:46:14 +0100 | [diff] [blame] | 457 | @exit 1 |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 458 | endif |
| 459 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 460 | MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ |
| 461 | |
| 462 | define MAKE_C |
| 463 | |
| 464 | $(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) |
| 465 | $(eval DEP := $(patsubst %.o,%.d,$(OBJ))) |
| 466 | |
Bence Szépkúti | 537b358 | 2019-11-29 18:23:56 +0100 | [diff] [blame] | 467 | $(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 468 | @echo " CC $$<" |
| 469 | $$(Q)$$(CC) $$($(3)_CFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@ |
| 470 | |
| 471 | -include $(DEP) |
| 472 | endef |
| 473 | |
| 474 | |
| 475 | define MAKE_S |
| 476 | |
| 477 | $(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) |
| 478 | $(eval DEP := $(patsubst %.o,%.d,$(OBJ))) |
| 479 | |
Bence Szépkúti | 537b358 | 2019-11-29 18:23:56 +0100 | [diff] [blame] | 480 | $(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 481 | @echo " AS $$<" |
| 482 | $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@ |
| 483 | |
| 484 | -include $(DEP) |
| 485 | endef |
| 486 | |
| 487 | |
| 488 | define MAKE_LD |
| 489 | |
| 490 | $(eval DEP := $(1).d) |
| 491 | |
Bence Szépkúti | 537b358 | 2019-11-29 18:23:56 +0100 | [diff] [blame] | 492 | $(1) : $(2) | $(AUTOGEN_DIR)/tests_list.h |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 493 | @echo " PP $$<" |
| 494 | $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -P -E $(MAKE_DEP) -o $$@ $$< |
| 495 | |
| 496 | -include $(DEP) |
| 497 | endef |
| 498 | |
| 499 | |
| 500 | define MAKE_OBJS |
| 501 | $(eval C_OBJS := $(filter %.c,$(2))) |
| 502 | $(eval REMAIN := $(filter-out %.c,$(2))) |
| 503 | $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3)))) |
| 504 | |
| 505 | $(eval S_OBJS := $(filter %.S,$(REMAIN))) |
| 506 | $(eval REMAIN := $(filter-out %.S,$(REMAIN))) |
| 507 | $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3)))) |
| 508 | |
| 509 | $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN))) |
| 510 | endef |
| 511 | |
Boyan Karatotev | 1122114 | 2024-10-21 10:11:29 +0100 | [diff] [blame] | 512 | ${BUILD_PLAT}: |
| 513 | $(Q)mkdir -p "$@" |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 514 | |
| 515 | # NOTE: The line continuation '\' is required in the next define otherwise we |
| 516 | # end up with a line-feed characer at the end of the last c filename. |
| 517 | # Also bare this issue in mind if extending the list of supported filetypes. |
| 518 | define SOURCES_TO_OBJS |
| 519 | $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \ |
| 520 | $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1)))) |
| 521 | endef |
| 522 | |
| 523 | define uppercase |
| 524 | $(shell echo $(1) | tr '[:lower:]' '[:upper:]') |
| 525 | endef |
| 526 | |
| 527 | define MAKE_IMG |
| 528 | $(eval IMG_PREFIX := $(call uppercase, $(1))) |
| 529 | $(eval BUILD_DIR := ${BUILD_PLAT}/$(1)) |
| 530 | $(eval SOURCES := $(${IMG_PREFIX}_SOURCES)) |
| 531 | $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES)))) |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 532 | $(eval OBJS += $(${IMG_PREFIX}_EXTRA_OBJS)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 533 | $(eval LINKERFILE := $(BUILD_DIR)/$(1).ld) |
| 534 | $(eval MAPFILE := $(BUILD_DIR)/$(1).map) |
| 535 | $(eval ELF := $(BUILD_DIR)/$(1).elf) |
| 536 | $(eval DUMP := $(BUILD_DIR)/$(1).dump) |
| 537 | $(eval BIN := $(BUILD_PLAT)/$(1).bin) |
| 538 | |
| 539 | $(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),${IMG_PREFIX})) |
| 540 | $(eval $(call MAKE_LD,$(LINKERFILE),$(${IMG_PREFIX}_LINKERFILE),${IMG_PREFIX})) |
| 541 | |
Boyan Karatotev | 1122114 | 2024-10-21 10:11:29 +0100 | [diff] [blame] | 542 | $(BUILD_DIR) : ${BUILD_PLAT} |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 543 | $$(Q)mkdir -p "$$@" |
| 544 | |
| 545 | $(ELF) : $(OBJS) $(LINKERFILE) |
| 546 | @echo " LD $$@" |
| 547 | @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \ |
| 548 | const char version_string[] = "${VERSION_STRING}";' | \ |
| 549 | $$(CC) $$(${IMG_PREFIX}_CFLAGS) ${${IMG_PREFIX}_INCLUDES} ${${IMG_PREFIX}_DEFINES} -c -xc - -o $(BUILD_DIR)/build_message.o |
| 550 | $$(Q)$$(LD) -o $$@ $$(${IMG_PREFIX}_LDFLAGS) -Map=$(MAPFILE) \ |
| 551 | -T $(LINKERFILE) $(BUILD_DIR)/build_message.o $(OBJS) |
| 552 | |
| 553 | $(DUMP) : $(ELF) |
| 554 | @echo " OD $$@" |
| 555 | $${Q}$${OD} -dx $$< > $$@ |
| 556 | |
| 557 | $(BIN) : $(ELF) |
| 558 | @echo " BIN $$@" |
| 559 | $$(Q)$$(OC) -O binary $$< $$@ |
| 560 | @echo |
| 561 | @echo "Built $$@ successfully" |
| 562 | @echo |
| 563 | |
| 564 | .PHONY : $(1) |
| 565 | $(1) : $(BUILD_DIR) $(BIN) $(DUMP) |
| 566 | |
| 567 | all : $(1) |
| 568 | |
| 569 | endef |
| 570 | |
Shruti Gupta | 2eb601b | 2023-03-29 21:35:17 +0100 | [diff] [blame] | 571 | ifeq (${ARCH},aarch32) |
| 572 | ARCH_TESTS_SKIP_LIST := tftf/tests/aarch32_tests_to_skip.txt |
| 573 | endif |
| 574 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 575 | $(AUTOGEN_DIR): |
| 576 | $(Q)mkdir -p "$@" |
| 577 | |
Boyan Karatotev | ada6a86 | 2024-10-21 10:06:50 +0100 | [diff] [blame] | 578 | $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h &: $(AUTOGEN_DIR) ${TESTS_FILE} ${PLAT_TESTS_SKIP_LIST} $(ARCH_TESTS_SKIP_LIST) |
| 579 | @echo " AUTOGEN $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h" |
Jim Ray | 7ba27bf | 2023-05-25 14:11:51 -0700 | [diff] [blame] | 580 | tools/generate_test_list/generate_test_list.py $(AUTOGEN_DIR)/tests_list.c \ |
| 581 | $(AUTOGEN_DIR)/tests_list.h ${TESTS_FILE} \ |
| 582 | --plat-skip-file=$(PLAT_TESTS_SKIP_LIST) \ |
| 583 | --arch-skip-file=$(ARCH_TESTS_SKIP_LIST) |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 584 | ifeq ($(SMC_FUZZING), 1) |
| 585 | $(Q)mkdir -p ${BUILD_PLAT}/smcf |
| 586 | dtc ${SMC_FUZZ_DTS} >> ${BUILD_PLAT}/smcf/dtb |
| 587 | $(OC) -I binary -O elf64-littleaarch64 -B aarch64 ${BUILD_PLAT}/smcf/dtb ${BUILD_PLAT}/smcf/dtb.o \ |
johpow01 | d5c79cc | 2021-06-23 16:10:22 -0500 | [diff] [blame] | 588 | --redefine-sym _binary___build_$(PLAT)_$(BUILD_TYPE)_smcf_dtb_start=_binary___dtb_start \ |
| 589 | --redefine-sym _binary___build_$(PLAT)_$(BUILD_TYPE)_smcf_dtb_end=_binary___dtb_end |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 590 | endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 591 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 592 | ifeq ($(FIRMWARE_UPDATE), 1) |
| 593 | $(eval $(call MAKE_IMG,ns_bl1u)) |
| 594 | $(eval $(call MAKE_IMG,ns_bl2u)) |
| 595 | endif |
| 596 | |
| 597 | ifeq (${ARCH}-${PLAT},aarch64-fvp) |
Antonio Nino Diaz | f2218e7 | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 598 | $(eval $(call MAKE_IMG,cactus_mm)) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 599 | $(eval $(call MAKE_IMG,cactus)) |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 600 | $(eval $(call MAKE_IMG,ivy)) |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 601 | endif |
| 602 | |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 603 | .PHONY : tftf |
| 604 | $(eval $(call MAKE_IMG,tftf)) |
| 605 | |
Arunachalam Ganapathy | 292a48a | 2023-10-27 16:46:36 +0100 | [diff] [blame] | 606 | # Build flag 'ENABLE_REALM_PAYLOAD_TESTS=1' builds and pack Realm Payload Tests |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 607 | ifeq (${ENABLE_REALM_PAYLOAD_TESTS},1) |
Arunachalam Ganapathy | 292a48a | 2023-10-27 16:46:36 +0100 | [diff] [blame] | 608 | $(eval $(call MAKE_IMG,realm)) |
| 609 | |
| 610 | # This forces to rebuild tftf.bin. For incremental build this re-creates tftf.bin |
| 611 | # and removes the old realm payload packed by the last build. |
| 612 | .PHONY : $(BUILD_PLAT)/tftf.bin |
| 613 | |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 614 | tftf: realm |
| 615 | @echo " PACK REALM PAYLOAD" |
| 616 | $(shell dd if=$(BUILD_PLAT)/realm.bin of=$(BUILD_PLAT)/tftf.bin obs=1 \ |
Soby Mathew | 6e5c996 | 2023-10-06 16:38:13 +0100 | [diff] [blame] | 617 | oflag=append conv=notrunc) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 618 | endif |
| 619 | |
Daniel Boulby | c19215a | 2023-05-17 13:50:36 +0100 | [diff] [blame] | 620 | ifeq (${ARCH}-${PLAT},aarch64-tc) |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 621 | $(eval $(call MAKE_IMG,cactus)) |
Olivier Deprez | 2765ebf | 2020-12-16 15:46:14 +0100 | [diff] [blame] | 622 | $(eval $(call MAKE_IMG,ivy)) |
Arunachalam Ganapathy | 1e51c2f | 2020-09-22 13:28:29 +0100 | [diff] [blame] | 623 | endif |
| 624 | |
Boyan Karatotev | 1122114 | 2024-10-21 10:11:29 +0100 | [diff] [blame] | 625 | SP_LAYOUT: ${BUILD_PLAT} |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 626 | ${Q}tools/generate_json/generate_json.sh \ |
| 627 | $(BUILD_PLAT) $(SECURE_PARTITIONS) |
| 628 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 629 | # The EL3 test payload is only supported in AArch64. It has an independent build |
| 630 | # system. |
| 631 | .PHONY: el3_payload |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 632 | # TODO: EL3 test payload currently is supported for GCC only. It has an independent |
| 633 | # build system and support for Clang to be added. |
| 634 | ifneq ($(findstring gcc,$(notdir $(CC))),) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 635 | ifneq (${ARCH},aarch32) |
Arvind Ram Prakash | 2e1264d | 2022-05-20 12:27:40 -0500 | [diff] [blame] | 636 | ifneq ($(wildcard ${EL3_PAYLOAD_PLAT_MAKEFILE_FULL}),) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 637 | el3_payload: $(BUILD_DIR) |
| 638 | ${Q}${MAKE} -C el3_payload PLAT=${PLAT} |
| 639 | ${Q}find "el3_payload/build/${PLAT}" -name '*.bin' -exec cp {} "${BUILD_PLAT}" \; |
| 640 | |
| 641 | all: el3_payload |
| 642 | endif |
Arvind Ram Prakash | 2e1264d | 2022-05-20 12:27:40 -0500 | [diff] [blame] | 643 | endif |
Jayanth Dodderi Chidanand | d2a6364 | 2023-06-06 09:03:53 +0100 | [diff] [blame] | 644 | endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 645 | |
Sandrine Bailleux | f8228af | 2020-04-21 14:45:00 +0200 | [diff] [blame] | 646 | doc: |
| 647 | @echo " BUILD DOCUMENTATION" |
| 648 | ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html |
| 649 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 650 | .PHONY: cscope |
| 651 | cscope: |
| 652 | @echo " CSCOPE" |
| 653 | ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files |
| 654 | ${Q}cscope -b -q -k |
| 655 | |
| 656 | .PHONY: help |
Leonardo Sandoval | 770b431 | 2020-09-11 14:44:40 -0500 | [diff] [blame] | 657 | .SILENT: help |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 658 | help: |
Leonardo Sandoval | 770b431 | 2020-09-11 14:44:40 -0500 | [diff] [blame] | 659 | echo "usage: ${MAKE} PLAT=<${PLATFORMS}> \ |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 660 | <all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|el3_payload|distclean|clean|checkcodebase|checkpatch|help_tests>" |
Leonardo Sandoval | 770b431 | 2020-09-11 14:44:40 -0500 | [diff] [blame] | 661 | echo "" |
| 662 | echo "PLAT is used to specify which platform you wish to build." |
| 663 | echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" |
| 664 | echo "" |
| 665 | echo "Supported Targets:" |
| 666 | echo " all Build all supported binaries for this platform" |
| 667 | echo " (i.e. TFTF and FWU images)" |
| 668 | echo " tftf Build the TFTF image" |
| 669 | echo " ns_bl1u Build the NS_BL1U image" |
| 670 | echo " ns_bl2u Build the NS_BL2U image" |
Olivier Deprez | 40777f8 | 2022-11-09 10:15:28 +0100 | [diff] [blame] | 671 | echo " cactus Build the Cactus image (FF-A S-EL1 test payload)." |
| 672 | echo " cactus_mm Build the Cactus-MM image (SPM-MM S-EL0 test payload)." |
| 673 | echo " ivy Build the Ivy image (FF-A S-EL0 test payload)." |
Leonardo Sandoval | 770b431 | 2020-09-11 14:44:40 -0500 | [diff] [blame] | 674 | echo " el3_payload Build the EL3 test payload" |
| 675 | echo " checkcodebase Check the coding style of the entire source tree" |
| 676 | echo " checkpatch Check the coding style on changes in the current" |
| 677 | echo " branch against BASE_COMMIT (default origin/master)" |
| 678 | echo " doc Build html based documentation using Sphinx tool" |
| 679 | echo " clean Clean the build for the selected platform" |
| 680 | echo " cscope Generate cscope index" |
| 681 | echo " distclean Remove all build artifacts for all platforms" |
| 682 | echo " help_tests List all possible sets of tests" |
| 683 | echo "" |
| 684 | echo "note: most build targets require PLAT to be set to a specific platform." |
| 685 | echo "" |
| 686 | echo "example: build all targets for the FVP platform:" |
| 687 | echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" |