blob: 1851775d73e14458a8d9547d9cd75f4b5f566583 [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
11################################################################################
12# Default values for build configurations, and their dependencies
13################################################################################
14
15include defaults.mk
16
17PLAT := ${DEFAULT_PLAT}
18
19# Assertions enabled for DEBUG builds by default
20ENABLE_ASSERTIONS := ${DEBUG}
21
22################################################################################
23# Checkpatch script options
24################################################################################
25
26CHECKCODE_ARGS := --no-patch
27# Do not check the coding style on imported library files or documentation files
28INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
Ambroise Vincenta2ede622019-02-11 14:34:26 +000029 include/lib/libc, \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020030 $(wildcard include/lib/*)))
31LIB_DIRS_TO_CHECK := $(sort $(filter-out \
32 lib/compiler-rt \
Ambroise Vincenta2ede622019-02-11 14:34:26 +000033 lib/libc, \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020034 $(wildcard lib/*)))
35ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
36 lib \
37 include \
38 docs \
39 %.md \
40 %.rst, \
41 $(wildcard *)))
42CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
43 ${INC_LIB_DIRS_TO_CHECK} \
44 ${LIB_DIRS_TO_CHECK}
45
46ifeq (${V},0)
47 Q=@
48else
49 Q=
50endif
51export Q
52
53ifneq (${DEBUG}, 0)
54 BUILD_TYPE := debug
55 # Use LOG_LEVEL_INFO by default for debug builds
56 LOG_LEVEL := 40
57else
58 BUILD_TYPE := release
59 # Use LOG_LEVEL_ERROR by default for release builds
60 LOG_LEVEL := 20
61endif
62
63# Default build string (git branch and commit)
64ifeq (${BUILD_STRING},)
65 BUILD_STRING := $(shell git log -n 1 --pretty=format:"%h")
66endif
67
68VERSION_STRING := v${VERSION_MAJOR}.${VERSION_MINOR}(${PLAT},${BUILD_TYPE}):${BUILD_STRING}
69
70BUILD_BASE := ./build
71BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
72
73PLAT_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 '|'.
77PLATFORMS := $(shell find plat/ -name '${PLAT_MAKEFILE}' -print0 | \
78 sed -r 's%[^\x00]*\/([^/]*)\/${PLAT_MAKEFILE}\x00%\1|%g' | \
79 sed -r 's/\|$$//')
80
Sandrine Bailleux7fb2e0a2020-04-21 14:45:00 +020081DOCS_PATH := docs
82
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020083# Convenience function for adding build definitions
84# $(eval $(call add_define,BAR_DEFINES,FOO)) will have:
85# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
86# inside the BAR_DEFINES variable.
87define add_define
88$(1) += -D$(2)$(if $(value $(2)),=$(value $(2)),)
89endef
90
91# Convenience function for verifying option has a boolean value
92# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1
93define assert_boolean
94$(and $(patsubst 0,,$(value $(1))),$(patsubst 1,,$(value $(1))),$(error $(1) must be boolean))
95endef
96
97ifeq (${PLAT},)
98 $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
99endif
100PLAT_PATH := $(shell find plat/ -wholename '*/${PLAT}')
101PLAT_MAKEFILE_FULL := ${PLAT_PATH}/${PLAT_MAKEFILE}
102ifeq ($(wildcard ${PLAT_MAKEFILE_FULL}),)
103 $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
104endif
105
106.PHONY: all
107all: msg_start
108
109.PHONY: msg_start
110msg_start:
111 @echo "Building ${PLAT}"
Sandrine Bailleux043d5362018-10-03 17:05:59 +0200112 @echo "Selected set of tests: ${TESTS}"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200113
114# Include test images makefiles.
115include tftf/framework/framework.mk
116include tftf/tests/tests.mk
117include fwu/ns_bl1u/ns_bl1u.mk
118include fwu/ns_bl2u/ns_bl2u.mk
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000119include spm/cactus_mm/cactus_mm.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200120include spm/cactus/cactus.mk
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000121include spm/ivy/ivy.mk
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000122include spm/quark/quark.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200123
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000124################################################################################
125# Include libc
126################################################################################
127include lib/libc/libc.mk
128
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200129# Include platform specific makefile last because:
130# - the platform makefile may use all previous definitions in this file.
131# - the platform makefile may wish overwriting some of them.
132include ${PLAT_MAKEFILE_FULL}
133
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200134.SUFFIXES:
135
136################################################################################
137# Build options checks
138################################################################################
139$(eval $(call assert_boolean,DEBUG))
140$(eval $(call assert_boolean,ENABLE_ASSERTIONS))
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000141$(eval $(call assert_boolean,ENABLE_PAUTH))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200142$(eval $(call assert_boolean,FIRMWARE_UPDATE))
143$(eval $(call assert_boolean,FWU_BL_TEST))
144$(eval $(call assert_boolean,NEW_TEST_SESSION))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200145$(eval $(call assert_boolean,USE_NVM))
146
147################################################################################
148# Add definitions to the cpp preprocessor based on the current build options.
149# This is done after including the platform specific makefile to allow the
150# platform to overwrite the default options
151################################################################################
152$(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MAJOR))
153$(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MINOR))
154$(eval $(call add_define,TFTF_DEFINES,DEBUG))
155$(eval $(call add_define,TFTF_DEFINES,ENABLE_ASSERTIONS))
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000156$(eval $(call add_define,TFTF_DEFINES,ENABLE_PAUTH))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200157$(eval $(call add_define,TFTF_DEFINES,LOG_LEVEL))
158$(eval $(call add_define,TFTF_DEFINES,NEW_TEST_SESSION))
159$(eval $(call add_define,TFTF_DEFINES,PLAT_${PLAT}))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200160$(eval $(call add_define,TFTF_DEFINES,USE_NVM))
161
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200162################################################################################
163
164# Assembler, compiler and linker flags shared across all test images.
165COMMON_ASFLAGS :=
166COMMON_CFLAGS :=
167COMMON_LDFLAGS :=
168
169ifeq (${DEBUG},1)
170COMMON_CFLAGS += -g
171COMMON_ASFLAGS += -g -Wa,--gdwarf-2
172endif
173
Joel Hutton87530242019-04-08 15:46:36 +0100174# Set the compiler's target architecture profile based on ARM_ARCH_MINOR option
175ifeq (${ARM_ARCH_MINOR},0)
176march32-directive = -march=armv8-a
177march64-directive = -march=armv8-a
178else
179march32-directive = -march=armv8.${ARM_ARCH_MINOR}-a
180march64-directive = -march=armv8.${ARM_ARCH_MINOR}-a
181endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200182
Joel Hutton87530242019-04-08 15:46:36 +0100183COMMON_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive}
184COMMON_CFLAGS_aarch64 := -mgeneral-regs-only -mstrict-align ${march64-directive}
185
186COMMON_ASFLAGS_aarch32 := ${march32-directive}
187COMMON_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200188
189COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
190 -Werror -Wmissing-include-dirs \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000191 -D__ASSEMBLY__ $(COMMON_ASFLAGS_$(ARCH)) \
192 ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200193COMMON_CFLAGS += -nostdinc -ffreestanding -Wall -Werror \
194 -Wmissing-include-dirs $(COMMON_CFLAGS_$(ARCH)) \
195 -std=gnu99 -Os
196COMMON_CFLAGS += -ffunction-sections -fdata-sections
197
198# Get the content of CFLAGS user defined value last so they are appended after
199# the options defined in the Makefile
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000200COMMON_CFLAGS += ${CFLAGS} ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200201
202COMMON_LDFLAGS += --fatal-warnings -O1 --gc-sections --build-id=none
203
204CC := ${CROSS_COMPILE}gcc
205CPP := ${CROSS_COMPILE}cpp
206AS := ${CROSS_COMPILE}gcc
207AR := ${CROSS_COMPILE}ar
208LD := ${CROSS_COMPILE}ld
209OC := ${CROSS_COMPILE}objcopy
210OD := ${CROSS_COMPILE}objdump
211NM := ${CROSS_COMPILE}nm
212PP := ${CROSS_COMPILE}gcc
213
214################################################################################
215
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000216TFTF_SOURCES := ${FRAMEWORK_SOURCES} ${TESTS_SOURCES} ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200217TFTF_INCLUDES += ${PLAT_INCLUDES}
218TFTF_CFLAGS += ${COMMON_CFLAGS}
219TFTF_ASFLAGS += ${COMMON_ASFLAGS}
220TFTF_LDFLAGS += ${COMMON_LDFLAGS}
221
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000222ifeq (${ENABLE_PAUTH},1)
Alexei Fedorove72ce612019-10-03 10:57:53 +0100223TFTF_CFLAGS += -mbranch-protection=pac-ret
Alexei Fedorovb61cc152020-01-08 14:02:18 +0000224NS_BL1U_CFLAGS += -mbranch-protection=pac-ret
225NS_BL2U_CFLAGS += -mbranch-protection=pac-ret
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000226endif
227
Olivier Deprezdb70c452020-02-03 11:27:01 +0100228#####################################################################################
229ifneq ($(findstring gcc,$(notdir $(LD))),)
230 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
231else
232 PIE_LDFLAGS += -pie --no-dynamic-linker
233endif
234
235#####################################################################################
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000236NS_BL1U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200237NS_BL1U_INCLUDES += ${PLAT_INCLUDES}
238NS_BL1U_CFLAGS += ${COMMON_CFLAGS}
239NS_BL1U_ASFLAGS += ${COMMON_ASFLAGS}
240NS_BL1U_LDFLAGS += ${COMMON_LDFLAGS}
241
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000242NS_BL2U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200243NS_BL2U_INCLUDES += ${PLAT_INCLUDES}
244NS_BL2U_CFLAGS += ${COMMON_CFLAGS}
245NS_BL2U_ASFLAGS += ${COMMON_ASFLAGS}
246NS_BL2U_LDFLAGS += ${COMMON_LDFLAGS}
247
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000248CACTUS_MM_SOURCES += ${LIBC_SRCS}
249CACTUS_MM_INCLUDES += ${PLAT_INCLUDES}
250CACTUS_MM_CFLAGS += ${COMMON_CFLAGS}
251CACTUS_MM_ASFLAGS += ${COMMON_ASFLAGS}
252CACTUS_MM_LDFLAGS += ${COMMON_LDFLAGS}
253
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000254CACTUS_SOURCES += ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200255CACTUS_INCLUDES += ${PLAT_INCLUDES}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100256CACTUS_CFLAGS += ${COMMON_CFLAGS} -fpie
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200257CACTUS_ASFLAGS += ${COMMON_ASFLAGS}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100258CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200259
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000260IVY_SOURCES += ${LIBC_SRCS}
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000261IVY_INCLUDES += ${PLAT_INCLUDES}
262IVY_CFLAGS += ${COMMON_CFLAGS}
263IVY_ASFLAGS += ${COMMON_ASFLAGS}
264IVY_LDFLAGS += ${COMMON_LDFLAGS}
265
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000266QUARK_SOURCES += ${LIBC_SRCS}
267QUARK_INCLUDES += ${PLAT_INCLUDES}
268QUARK_CFLAGS += ${COMMON_CFLAGS}
269QUARK_ASFLAGS += ${COMMON_ASFLAGS}
270QUARK_LDFLAGS += ${COMMON_LDFLAGS}
271
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200272.PHONY: locate-checkpatch
273locate-checkpatch:
274ifndef CHECKPATCH
275 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
276else
277ifeq (,$(wildcard ${CHECKPATCH}))
278 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
279endif
280endif
281
282.PHONY: clean
283clean:
284 @echo " CLEAN"
285 ${Q}rm -rf ${BUILD_PLAT}
286 ${MAKE} -C el3_payload clean
287
288.PHONY: realclean distclean
289realclean distclean:
290 @echo " REALCLEAN"
291 ${Q}rm -rf ${BUILD_BASE}
292 ${Q}rm -f ${CURDIR}/cscope.*
293 ${MAKE} -C el3_payload distclean
294
295.PHONY: checkcodebase
296checkcodebase: locate-checkpatch
297 @echo " CHECKING STYLE"
298 @if test -d .git ; then \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000299 git ls-files | grep -E -v 'libc|docs|\.md|\.rst' | \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200300 while read GIT_FILE ; \
301 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
302 done ; \
303 else \
304 find . -type f -not -iwholename "*.git*" \
305 -not -iwholename "*build*" \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000306 -not -iwholename "*libc*" \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200307 -not -iwholename "*docs*" \
308 -not -iwholename "*.md" \
309 -not -iwholename "*.rst" \
310 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
311 fi
312
313.PHONY: checkpatch
314checkpatch: locate-checkpatch
315 @echo " CHECKING STYLE"
316 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
317 for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \
318 printf "\n[*] Checking style of '$$commit'\n\n"; \
319 git log --format=email "$$commit~..$$commit" \
320 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \
321 git diff --format=email "$$commit~..$$commit" \
322 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \
323 done
324
325ifneq (${FIRMWARE_UPDATE},1)
326.PHONY: ns_bl1u ns_bl2u
327ns_bl1u ns_bl2u:
328 @echo "ERROR: Can't build $@ because Firmware Update is not supported \
329 on this platform."
330 @exit 1
331endif
332
333ifneq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000334.PHONY: cactus_mm
335cactus_mm:
336 @echo "ERROR: $@ is supported only on AArch64 FVP."
337 @exit 1
338
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200339.PHONY: cactus
340cactus:
341 @echo "ERROR: $@ is supported only on AArch64 FVP."
342 @exit 1
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000343
344.PHONY: ivy
345ivy:
346 @echo "ERROR: $@ is supported only on AArch64 FVP."
347 @exit 1
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000348
349.PHONY: quark
350quark:
351 @echo "ERROR: $@ is supported only on AArch64 FVP."
352 @exit 1
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200353endif
354
355MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@
356
357define MAKE_C
358
359$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
360$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
361
Bence Szépkúti25671c22019-11-29 18:23:56 +0100362$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200363 @echo " CC $$<"
364 $$(Q)$$(CC) $$($(3)_CFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
365
366-include $(DEP)
367endef
368
369
370define MAKE_S
371
372$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
373$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
374
Bence Szépkúti25671c22019-11-29 18:23:56 +0100375$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200376 @echo " AS $$<"
377 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
378
379-include $(DEP)
380endef
381
382
383define MAKE_LD
384
385$(eval DEP := $(1).d)
386
Bence Szépkúti25671c22019-11-29 18:23:56 +0100387$(1) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200388 @echo " PP $$<"
389 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -P -E $(MAKE_DEP) -o $$@ $$<
390
391-include $(DEP)
392endef
393
394
395define MAKE_OBJS
396 $(eval C_OBJS := $(filter %.c,$(2)))
397 $(eval REMAIN := $(filter-out %.c,$(2)))
398 $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3))))
399
400 $(eval S_OBJS := $(filter %.S,$(REMAIN)))
401 $(eval REMAIN := $(filter-out %.S,$(REMAIN)))
402 $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3))))
403
404 $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
405endef
406
407
408# NOTE: The line continuation '\' is required in the next define otherwise we
409# end up with a line-feed characer at the end of the last c filename.
410# Also bare this issue in mind if extending the list of supported filetypes.
411define SOURCES_TO_OBJS
412 $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \
413 $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1))))
414endef
415
416define uppercase
417$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
418endef
419
420define MAKE_IMG
421 $(eval IMG_PREFIX := $(call uppercase, $(1)))
422 $(eval BUILD_DIR := ${BUILD_PLAT}/$(1))
423 $(eval SOURCES := $(${IMG_PREFIX}_SOURCES))
424 $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
425 $(eval LINKERFILE := $(BUILD_DIR)/$(1).ld)
426 $(eval MAPFILE := $(BUILD_DIR)/$(1).map)
427 $(eval ELF := $(BUILD_DIR)/$(1).elf)
428 $(eval DUMP := $(BUILD_DIR)/$(1).dump)
429 $(eval BIN := $(BUILD_PLAT)/$(1).bin)
430
431 $(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),${IMG_PREFIX}))
432 $(eval $(call MAKE_LD,$(LINKERFILE),$(${IMG_PREFIX}_LINKERFILE),${IMG_PREFIX}))
433
434$(BUILD_DIR) :
435 $$(Q)mkdir -p "$$@"
436
437$(ELF) : $(OBJS) $(LINKERFILE)
438 @echo " LD $$@"
439 @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \
440 const char version_string[] = "${VERSION_STRING}";' | \
441 $$(CC) $$(${IMG_PREFIX}_CFLAGS) ${${IMG_PREFIX}_INCLUDES} ${${IMG_PREFIX}_DEFINES} -c -xc - -o $(BUILD_DIR)/build_message.o
442 $$(Q)$$(LD) -o $$@ $$(${IMG_PREFIX}_LDFLAGS) -Map=$(MAPFILE) \
443 -T $(LINKERFILE) $(BUILD_DIR)/build_message.o $(OBJS)
444
445$(DUMP) : $(ELF)
446 @echo " OD $$@"
447 $${Q}$${OD} -dx $$< > $$@
448
449$(BIN) : $(ELF)
450 @echo " BIN $$@"
451 $$(Q)$$(OC) -O binary $$< $$@
452 @echo
453 @echo "Built $$@ successfully"
454 @echo
455
456.PHONY : $(1)
457$(1) : $(BUILD_DIR) $(BIN) $(DUMP)
458
459all : $(1)
460
461endef
462
463$(AUTOGEN_DIR):
464 $(Q)mkdir -p "$@"
465
466$(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h: $(AUTOGEN_DIR) ${TESTS_FILE} ${PLAT_TESTS_SKIP_LIST}
467 @echo " AUTOGEN $@"
468 tools/generate_test_list/generate_test_list.pl $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h ${TESTS_FILE} $(PLAT_TESTS_SKIP_LIST)
469
470$(eval $(call MAKE_IMG,tftf))
471
472ifeq ($(FIRMWARE_UPDATE), 1)
473 $(eval $(call MAKE_IMG,ns_bl1u))
474 $(eval $(call MAKE_IMG,ns_bl2u))
475endif
476
477ifeq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000478 $(eval $(call MAKE_IMG,cactus_mm))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200479 $(eval $(call MAKE_IMG,cactus))
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000480 $(eval $(call MAKE_IMG,ivy))
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000481 $(eval $(call MAKE_IMG,quark))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200482endif
483
484# The EL3 test payload is only supported in AArch64. It has an independent build
485# system.
486.PHONY: el3_payload
487ifneq (${ARCH},aarch32)
488el3_payload: $(BUILD_DIR)
489 ${Q}${MAKE} -C el3_payload PLAT=${PLAT}
490 ${Q}find "el3_payload/build/${PLAT}" -name '*.bin' -exec cp {} "${BUILD_PLAT}" \;
491
492all: el3_payload
493endif
494
Sandrine Bailleux7fb2e0a2020-04-21 14:45:00 +0200495doc:
496 @echo " BUILD DOCUMENTATION"
497 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
498
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200499.PHONY: cscope
500cscope:
501 @echo " CSCOPE"
502 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
503 ${Q}cscope -b -q -k
504
505.PHONY: help
506help:
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000507 @echo "usage: ${MAKE} PLAT=<${PLATFORMS}> <all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|quark|el3_payload|distclean|clean|checkcodebase|checkpatch>"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200508 @echo ""
509 @echo "PLAT is used to specify which platform you wish to build."
510 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
511 @echo ""
512 @echo "Supported Targets:"
513 @echo " all Build all supported binaries for this platform"
514 @echo " (i.e. TFTF and FWU images)"
515 @echo " tftf Build the TFTF image"
516 @echo " ns_bl1u Build the NS_BL1U image"
517 @echo " ns_bl2u Build the NS_BL2U image"
Antonio Nino Diaz0c697f92018-11-30 10:51:26 +0000518 @echo " cactus Build the Cactus image (Test S-EL0 payload) and resource description."
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000519 @echo " cactus_mm Build the Cactus-MM image (Test S-EL0 payload)."
Antonio Nino Diaz0c697f92018-11-30 10:51:26 +0000520 @echo " ivy Build the Ivy image (Test S-EL0 payload) and resource description."
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000521 @echo " quark Build the Quark image (Test S-EL0 payload) and resource description."
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200522 @echo " el3_payload Build the EL3 test payload"
523 @echo " checkcodebase Check the coding style of the entire source tree"
524 @echo " checkpatch Check the coding style on changes in the current"
525 @echo " branch against BASE_COMMIT (default origin/master)"
Sandrine Bailleux7fb2e0a2020-04-21 14:45:00 +0200526 @echo " doc Build html based documentation using Sphinx tool"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200527 @echo " clean Clean the build for the selected platform"
528 @echo " cscope Generate cscope index"
529 @echo " distclean Remove all build artifacts for all platforms"
530 @echo ""
531 @echo "note: most build targets require PLAT to be set to a specific platform."
532 @echo ""
533 @echo "example: build all targets for the FVP platform:"
534 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"