blob: 77b89faed59843ec333fd309ea7d8ccde6f4bb32 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001#
Alexei Fedorovb61cc152020-01-08 14:02:18 +00002# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7# TFTF Version
8VERSION_MAJOR := 2
Madhukar Pappireddyf5b54742020-04-19 23:58:39 -05009VERSION_MINOR := 3
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020010
Leonardo Sandovale1693b42020-09-11 12:50:19 -050011MAKE_HELPERS_DIRECTORY := make_helpers/
12include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
13
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020014################################################################################
15# Default values for build configurations, and their dependencies
16################################################################################
17
Leonardo Sandovale1693b42020-09-11 12:50:19 -050018include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020019
20PLAT := ${DEFAULT_PLAT}
21
22# Assertions enabled for DEBUG builds by default
23ENABLE_ASSERTIONS := ${DEBUG}
24
25################################################################################
26# Checkpatch script options
27################################################################################
28
29CHECKCODE_ARGS := --no-patch
30# Do not check the coding style on imported library files or documentation files
31INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Ambroise Vincenta2ede622019-02-11 14:34:26 +000032 include/lib/libc, \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020033 $(wildcard include/lib/*)))
34LIB_DIRS_TO_CHECK := $(sort $(filter-out \
35 lib/compiler-rt \
Ambroise Vincenta2ede622019-02-11 14:34:26 +000036 lib/libc, \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020037 $(wildcard lib/*)))
38ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
39 lib \
40 include \
41 docs \
42 %.md \
43 %.rst, \
44 $(wildcard *)))
45CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
46 ${INC_LIB_DIRS_TO_CHECK} \
47 ${LIB_DIRS_TO_CHECK}
48
49ifeq (${V},0)
50 Q=@
51else
52 Q=
53endif
54export Q
55
56ifneq (${DEBUG}, 0)
57 BUILD_TYPE := debug
58 # Use LOG_LEVEL_INFO by default for debug builds
59 LOG_LEVEL := 40
60else
61 BUILD_TYPE := release
62 # Use LOG_LEVEL_ERROR by default for release builds
63 LOG_LEVEL := 20
64endif
65
66# Default build string (git branch and commit)
67ifeq (${BUILD_STRING},)
68 BUILD_STRING := $(shell git log -n 1 --pretty=format:"%h")
69endif
70
71VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${PLAT},${BUILD_TYPE}):${BUILD_STRING}
72
73BUILD_BASE := ./build
74BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
75
76PLAT_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 '|'.
80PLATFORMS := $(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 | \
81 sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' | \
82 sed -r 's/\|$$//')
83
Sandrine Bailleux7fb2e0a2020-04-21 14:45:00 +020084DOCS_PATH := docs
85
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020086ifeq (${PLAT},)
87 $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
88endif
89PLAT_PATH := $(shell find plat/ -wholename '*/${PLAT}')
90PLAT_MAKEFILE_FULL := ${PLAT_PATH}/${PLAT_MAKEFILE}
91ifeq ($(wildcard ${PLAT_MAKEFILE_FULL}),)
92 $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
93endif
94
95.PHONY: all
96all: msg_start
97
98.PHONY: msg_start
99msg_start:
100 @echo "Building ${PLAT}"
Sandrine Bailleux043d5362018-10-03 17:05:59 +0200101 @echo "Selected set of tests: ${TESTS}"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200102
103# Include test images makefiles.
104include tftf/framework/framework.mk
105include tftf/tests/tests.mk
106include fwu/ns_bl1u/ns_bl1u.mk
107include fwu/ns_bl2u/ns_bl2u.mk
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000108include spm/cactus_mm/cactus_mm.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200109include spm/cactus/cactus.mk
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000110include spm/ivy/ivy.mk
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000111include spm/quark/quark.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200112
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000113################################################################################
114# Include libc
115################################################################################
116include lib/libc/libc.mk
117
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200118# 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.
121include ${PLAT_MAKEFILE_FULL}
122
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200123.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 Bailleux3cd87d72018-10-09 11:12:55 +0200133$(eval $(call assert_boolean,USE_NVM))
134
135################################################################################
Alexei Fedorovf45484f2020-06-19 14:25:43 +0100136# Process build options
137################################################################################
138
139# Process BRANCH_PROTECTION value and set
140# Pointer Authentication and Branch Target Identification flags
141include branch_protection.mk
142
143################################################################################
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200144# 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 Fedorovf45484f2020-06-19 14:25:43 +0100152$(eval $(call add_define,TFTF_DEFINES,ENABLE_BTI))
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000153$(eval $(call add_define,TFTF_DEFINES,ENABLE_PAUTH))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200154$(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 Bailleux3cd87d72018-10-09 11:12:55 +0200157$(eval $(call add_define,TFTF_DEFINES,USE_NVM))
158
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200159################################################################################
160
161# Assembler, compiler and linker flags shared across all test images.
162COMMON_ASFLAGS :=
163COMMON_CFLAGS :=
164COMMON_LDFLAGS :=
165
166ifeq (${DEBUG},1)
167COMMON_CFLAGS += -g
168COMMON_ASFLAGS += -g -Wa,--gdwarf-2
169endif
170
Joel Hutton87530242019-04-08 15:46:36 +0100171# Set the compiler's target architecture profile based on ARM_ARCH_MINOR option
172ifeq (${ARM_ARCH_MINOR},0)
173march32-directive = -march=armv8-a
174march64-directive = -march=armv8-a
175else
176march32-directive = -march=armv8.${ARM_ARCH_MINOR}-a
177march64-directive = -march=armv8.${ARM_ARCH_MINOR}-a
178endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200179
Joel Hutton87530242019-04-08 15:46:36 +0100180COMMON_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive}
181COMMON_CFLAGS_aarch64 := -mgeneral-regs-only -mstrict-align ${march64-directive}
182
183COMMON_ASFLAGS_aarch32 := ${march32-directive}
184COMMON_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200185
186COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
187 -Werror -Wmissing-include-dirs \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000188 -D__ASSEMBLY__ $(COMMON_ASFLAGS_$(ARCH)) \
189 ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200190COMMON_CFLAGS += -nostdinc -ffreestanding -Wall -Werror \
191 -Wmissing-include-dirs $(COMMON_CFLAGS_$(ARCH)) \
192 -std=gnu99 -Os
193COMMON_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 Vincenta2ede622019-02-11 14:34:26 +0000197COMMON_CFLAGS += ${CFLAGS} ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200198
199COMMON_LDFLAGS += --fatal-warnings -O1 --gc-sections --build-id=none
200
201CC := ${CROSS_COMPILE}gcc
202CPP := ${CROSS_COMPILE}cpp
203AS := ${CROSS_COMPILE}gcc
204AR := ${CROSS_COMPILE}ar
205LD := ${CROSS_COMPILE}ld
206OC := ${CROSS_COMPILE}objcopy
207OD := ${CROSS_COMPILE}objdump
208NM := ${CROSS_COMPILE}nm
209PP := ${CROSS_COMPILE}gcc
210
211################################################################################
212
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000213TFTF_SOURCES := ${FRAMEWORK_SOURCES} ${TESTS_SOURCES} ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200214TFTF_INCLUDES += ${PLAT_INCLUDES}
215TFTF_CFLAGS += ${COMMON_CFLAGS}
216TFTF_ASFLAGS += ${COMMON_ASFLAGS}
217TFTF_LDFLAGS += ${COMMON_LDFLAGS}
218
Alexei Fedorovf45484f2020-06-19 14:25:43 +0100219ifneq (${BP_OPTION},none)
220TFTF_CFLAGS += -mbranch-protection=${BP_OPTION}
221NS_BL1U_CFLAGS += -mbranch-protection=${BP_OPTION}
222NS_BL2U_CFLAGS += -mbranch-protection=${BP_OPTION}
223CACTUS_MM_CFLAGS += -mbranch-protection=${BP_OPTION}
224CACTUS_CFLAGS += -mbranch-protection=${BP_OPTION}
225IVY_CFLAGS += -mbranch-protection=${BP_OPTION}
226QUARK_CFLAGS += -mbranch-protection=${BP_OPTION}
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000227endif
228
Olivier Deprezdb70c452020-02-03 11:27:01 +0100229#####################################################################################
230ifneq ($(findstring gcc,$(notdir $(LD))),)
231 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
232else
233 PIE_LDFLAGS += -pie --no-dynamic-linker
234endif
235
236#####################################################################################
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000237NS_BL1U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200238NS_BL1U_INCLUDES += ${PLAT_INCLUDES}
239NS_BL1U_CFLAGS += ${COMMON_CFLAGS}
240NS_BL1U_ASFLAGS += ${COMMON_ASFLAGS}
241NS_BL1U_LDFLAGS += ${COMMON_LDFLAGS}
242
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000243NS_BL2U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200244NS_BL2U_INCLUDES += ${PLAT_INCLUDES}
245NS_BL2U_CFLAGS += ${COMMON_CFLAGS}
246NS_BL2U_ASFLAGS += ${COMMON_ASFLAGS}
247NS_BL2U_LDFLAGS += ${COMMON_LDFLAGS}
248
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000249CACTUS_MM_SOURCES += ${LIBC_SRCS}
250CACTUS_MM_INCLUDES += ${PLAT_INCLUDES}
251CACTUS_MM_CFLAGS += ${COMMON_CFLAGS}
252CACTUS_MM_ASFLAGS += ${COMMON_ASFLAGS}
253CACTUS_MM_LDFLAGS += ${COMMON_LDFLAGS}
254
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000255CACTUS_SOURCES += ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200256CACTUS_INCLUDES += ${PLAT_INCLUDES}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100257CACTUS_CFLAGS += ${COMMON_CFLAGS} -fpie
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200258CACTUS_ASFLAGS += ${COMMON_ASFLAGS}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100259CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200260
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000261IVY_SOURCES += ${LIBC_SRCS}
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000262IVY_INCLUDES += ${PLAT_INCLUDES}
263IVY_CFLAGS += ${COMMON_CFLAGS}
264IVY_ASFLAGS += ${COMMON_ASFLAGS}
265IVY_LDFLAGS += ${COMMON_LDFLAGS}
266
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000267QUARK_SOURCES += ${LIBC_SRCS}
268QUARK_INCLUDES += ${PLAT_INCLUDES}
269QUARK_CFLAGS += ${COMMON_CFLAGS}
270QUARK_ASFLAGS += ${COMMON_ASFLAGS}
271QUARK_LDFLAGS += ${COMMON_LDFLAGS}
272
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200273.PHONY: locate-checkpatch
274locate-checkpatch:
275ifndef CHECKPATCH
276 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
277else
278ifeq (,$(wildcard ${CHECKPATCH}))
279 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
280endif
281endif
282
283.PHONY: clean
284clean:
285 @echo " CLEAN"
286 ${Q}rm -rf ${BUILD_PLAT}
287 ${MAKE} -C el3_payload clean
288
289.PHONY: realclean distclean
290realclean 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
297checkcodebase: locate-checkpatch
298 @echo " CHECKING STYLE"
299 @if test -d .git ; then \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000300 git ls-files | grep -E -v 'libc|docs|\.md|\.rst' | \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200301 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 Vincenta2ede622019-02-11 14:34:26 +0000307 -not -iwholename "*libc*" \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200308 -not -iwholename "*docs*" \
309 -not -iwholename "*.md" \
310 -not -iwholename "*.rst" \
311 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
312 fi
313
314.PHONY: checkpatch
315checkpatch: 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
326ifneq (${FIRMWARE_UPDATE},1)
327.PHONY: ns_bl1u ns_bl2u
328ns_bl1u ns_bl2u:
329 @echo "ERROR: Can't build $@ because Firmware Update is not supported \
330 on this platform."
331 @exit 1
332endif
333
334ifneq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000335.PHONY: cactus_mm
336cactus_mm:
337 @echo "ERROR: $@ is supported only on AArch64 FVP."
338 @exit 1
339
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200340.PHONY: cactus
341cactus:
342 @echo "ERROR: $@ is supported only on AArch64 FVP."
343 @exit 1
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000344
345.PHONY: ivy
346ivy:
347 @echo "ERROR: $@ is supported only on AArch64 FVP."
348 @exit 1
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000349
350.PHONY: quark
351quark:
352 @echo "ERROR: $@ is supported only on AArch64 FVP."
353 @exit 1
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200354endif
355
356MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@
357
358define MAKE_C
359
360$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
361$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
362
Bence Szépkúti25671c22019-11-29 18:23:56 +0100363$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200364 @echo " CC $$<"
365 $$(Q)$$(CC) $$($(3)_CFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
366
367-include $(DEP)
368endef
369
370
371define MAKE_S
372
373$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
374$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
375
Bence Szépkúti25671c22019-11-29 18:23:56 +0100376$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200377 @echo " AS $$<"
378 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
379
380-include $(DEP)
381endef
382
383
384define MAKE_LD
385
386$(eval DEP := $(1).d)
387
Bence Szépkúti25671c22019-11-29 18:23:56 +0100388$(1) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200389 @echo " PP $$<"
390 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -P -E $(MAKE_DEP) -o $$@ $$<
391
392-include $(DEP)
393endef
394
395
396define 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)))
406endef
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.
412define SOURCES_TO_OBJS
413 $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \
414 $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1))))
415endef
416
417define uppercase
418$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
419endef
420
421define 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
460all : $(1)
461
462endef
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
473ifeq ($(FIRMWARE_UPDATE), 1)
474 $(eval $(call MAKE_IMG,ns_bl1u))
475 $(eval $(call MAKE_IMG,ns_bl2u))
476endif
477
478ifeq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000479 $(eval $(call MAKE_IMG,cactus_mm))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200480 $(eval $(call MAKE_IMG,cactus))
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000481 $(eval $(call MAKE_IMG,ivy))
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000482 $(eval $(call MAKE_IMG,quark))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200483endif
484
485# The EL3 test payload is only supported in AArch64. It has an independent build
486# system.
487.PHONY: el3_payload
488ifneq (${ARCH},aarch32)
489el3_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
493all: el3_payload
494endif
495
Sandrine Bailleux7fb2e0a2020-04-21 14:45:00 +0200496doc:
497 @echo " BUILD DOCUMENTATION"
498 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
499
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200500.PHONY: cscope
501cscope:
502 @echo " CSCOPE"
503 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
504 ${Q}cscope -b -q -k
505
506.PHONY: help
Leonardo Sandoval2d039ad2020-09-11 14:44:40 -0500507.SILENT: help
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200508help:
Leonardo Sandoval2d039ad2020-09-11 14:44:40 -0500509 echo "usage: ${MAKE} PLAT=<${PLATFORMS}> \
Leonardo Sandoval5c882ba2020-07-14 11:00:31 -0500510<all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|quark|el3_payload|distclean|clean|checkcodebase|checkpatch|help_tests>"
Leonardo Sandoval2d039ad2020-09-11 14:44:40 -0500511 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"