blob: fea13dba9bc0beea8e00f3d605aa2b4a70284e21 [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
Alexei Fedorov266c77e2020-06-02 16:35:36 +010097# CREATE_SEQ is a recursive function to create sequence of numbers from 1 to
98# $(2) and assign the sequence to $(1)
99define CREATE_SEQ
100$(if $(word $(2), $($(1))),\
101 $(eval $(1) += $(words $($(1))))\
102 $(eval $(1) := $(filter-out 0,$($(1)))),\
103 $(eval $(1) += $(words $($(1))))\
104 $(call CREATE_SEQ,$(1),$(2))\
105)
106endef
107
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200108ifeq (${PLAT},)
109 $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
110endif
111PLAT_PATH := $(shell find plat/ -wholename '*/${PLAT}')
112PLAT_MAKEFILE_FULL := ${PLAT_PATH}/${PLAT_MAKEFILE}
113ifeq ($(wildcard ${PLAT_MAKEFILE_FULL}),)
114 $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
115endif
116
117.PHONY: all
118all: msg_start
119
120.PHONY: msg_start
121msg_start:
122 @echo "Building ${PLAT}"
Sandrine Bailleux043d5362018-10-03 17:05:59 +0200123 @echo "Selected set of tests: ${TESTS}"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200124
125# Include test images makefiles.
126include tftf/framework/framework.mk
127include tftf/tests/tests.mk
128include fwu/ns_bl1u/ns_bl1u.mk
129include fwu/ns_bl2u/ns_bl2u.mk
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000130include spm/cactus_mm/cactus_mm.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200131include spm/cactus/cactus.mk
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000132include spm/ivy/ivy.mk
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000133include spm/quark/quark.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200134
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000135################################################################################
136# Include libc
137################################################################################
138include lib/libc/libc.mk
139
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200140# Include platform specific makefile last because:
141# - the platform makefile may use all previous definitions in this file.
142# - the platform makefile may wish overwriting some of them.
143include ${PLAT_MAKEFILE_FULL}
144
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200145.SUFFIXES:
146
147################################################################################
148# Build options checks
149################################################################################
150$(eval $(call assert_boolean,DEBUG))
151$(eval $(call assert_boolean,ENABLE_ASSERTIONS))
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000152$(eval $(call assert_boolean,ENABLE_PAUTH))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200153$(eval $(call assert_boolean,FIRMWARE_UPDATE))
154$(eval $(call assert_boolean,FWU_BL_TEST))
155$(eval $(call assert_boolean,NEW_TEST_SESSION))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200156$(eval $(call assert_boolean,USE_NVM))
157
158################################################################################
159# Add definitions to the cpp preprocessor based on the current build options.
160# This is done after including the platform specific makefile to allow the
161# platform to overwrite the default options
162################################################################################
163$(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MAJOR))
164$(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MINOR))
165$(eval $(call add_define,TFTF_DEFINES,DEBUG))
166$(eval $(call add_define,TFTF_DEFINES,ENABLE_ASSERTIONS))
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000167$(eval $(call add_define,TFTF_DEFINES,ENABLE_PAUTH))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200168$(eval $(call add_define,TFTF_DEFINES,LOG_LEVEL))
169$(eval $(call add_define,TFTF_DEFINES,NEW_TEST_SESSION))
170$(eval $(call add_define,TFTF_DEFINES,PLAT_${PLAT}))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200171$(eval $(call add_define,TFTF_DEFINES,USE_NVM))
172
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200173################################################################################
174
175# Assembler, compiler and linker flags shared across all test images.
176COMMON_ASFLAGS :=
177COMMON_CFLAGS :=
178COMMON_LDFLAGS :=
179
180ifeq (${DEBUG},1)
181COMMON_CFLAGS += -g
182COMMON_ASFLAGS += -g -Wa,--gdwarf-2
183endif
184
Joel Hutton87530242019-04-08 15:46:36 +0100185# Set the compiler's target architecture profile based on ARM_ARCH_MINOR option
186ifeq (${ARM_ARCH_MINOR},0)
187march32-directive = -march=armv8-a
188march64-directive = -march=armv8-a
189else
190march32-directive = -march=armv8.${ARM_ARCH_MINOR}-a
191march64-directive = -march=armv8.${ARM_ARCH_MINOR}-a
192endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200193
Joel Hutton87530242019-04-08 15:46:36 +0100194COMMON_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive}
195COMMON_CFLAGS_aarch64 := -mgeneral-regs-only -mstrict-align ${march64-directive}
196
197COMMON_ASFLAGS_aarch32 := ${march32-directive}
198COMMON_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200199
200COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
201 -Werror -Wmissing-include-dirs \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000202 -D__ASSEMBLY__ $(COMMON_ASFLAGS_$(ARCH)) \
203 ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200204COMMON_CFLAGS += -nostdinc -ffreestanding -Wall -Werror \
205 -Wmissing-include-dirs $(COMMON_CFLAGS_$(ARCH)) \
206 -std=gnu99 -Os
207COMMON_CFLAGS += -ffunction-sections -fdata-sections
208
209# Get the content of CFLAGS user defined value last so they are appended after
210# the options defined in the Makefile
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000211COMMON_CFLAGS += ${CFLAGS} ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200212
213COMMON_LDFLAGS += --fatal-warnings -O1 --gc-sections --build-id=none
214
215CC := ${CROSS_COMPILE}gcc
216CPP := ${CROSS_COMPILE}cpp
217AS := ${CROSS_COMPILE}gcc
218AR := ${CROSS_COMPILE}ar
219LD := ${CROSS_COMPILE}ld
220OC := ${CROSS_COMPILE}objcopy
221OD := ${CROSS_COMPILE}objdump
222NM := ${CROSS_COMPILE}nm
223PP := ${CROSS_COMPILE}gcc
224
225################################################################################
226
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000227TFTF_SOURCES := ${FRAMEWORK_SOURCES} ${TESTS_SOURCES} ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200228TFTF_INCLUDES += ${PLAT_INCLUDES}
229TFTF_CFLAGS += ${COMMON_CFLAGS}
230TFTF_ASFLAGS += ${COMMON_ASFLAGS}
231TFTF_LDFLAGS += ${COMMON_LDFLAGS}
232
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000233ifeq (${ENABLE_PAUTH},1)
Alexei Fedorove72ce612019-10-03 10:57:53 +0100234TFTF_CFLAGS += -mbranch-protection=pac-ret
Alexei Fedorovb61cc152020-01-08 14:02:18 +0000235NS_BL1U_CFLAGS += -mbranch-protection=pac-ret
236NS_BL2U_CFLAGS += -mbranch-protection=pac-ret
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000237endif
238
Olivier Deprezdb70c452020-02-03 11:27:01 +0100239#####################################################################################
240ifneq ($(findstring gcc,$(notdir $(LD))),)
241 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
242else
243 PIE_LDFLAGS += -pie --no-dynamic-linker
244endif
245
246#####################################################################################
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000247NS_BL1U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200248NS_BL1U_INCLUDES += ${PLAT_INCLUDES}
249NS_BL1U_CFLAGS += ${COMMON_CFLAGS}
250NS_BL1U_ASFLAGS += ${COMMON_ASFLAGS}
251NS_BL1U_LDFLAGS += ${COMMON_LDFLAGS}
252
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000253NS_BL2U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200254NS_BL2U_INCLUDES += ${PLAT_INCLUDES}
255NS_BL2U_CFLAGS += ${COMMON_CFLAGS}
256NS_BL2U_ASFLAGS += ${COMMON_ASFLAGS}
257NS_BL2U_LDFLAGS += ${COMMON_LDFLAGS}
258
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000259CACTUS_MM_SOURCES += ${LIBC_SRCS}
260CACTUS_MM_INCLUDES += ${PLAT_INCLUDES}
261CACTUS_MM_CFLAGS += ${COMMON_CFLAGS}
262CACTUS_MM_ASFLAGS += ${COMMON_ASFLAGS}
263CACTUS_MM_LDFLAGS += ${COMMON_LDFLAGS}
264
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000265CACTUS_SOURCES += ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200266CACTUS_INCLUDES += ${PLAT_INCLUDES}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100267CACTUS_CFLAGS += ${COMMON_CFLAGS} -fpie
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200268CACTUS_ASFLAGS += ${COMMON_ASFLAGS}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100269CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200270
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000271IVY_SOURCES += ${LIBC_SRCS}
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000272IVY_INCLUDES += ${PLAT_INCLUDES}
273IVY_CFLAGS += ${COMMON_CFLAGS}
274IVY_ASFLAGS += ${COMMON_ASFLAGS}
275IVY_LDFLAGS += ${COMMON_LDFLAGS}
276
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000277QUARK_SOURCES += ${LIBC_SRCS}
278QUARK_INCLUDES += ${PLAT_INCLUDES}
279QUARK_CFLAGS += ${COMMON_CFLAGS}
280QUARK_ASFLAGS += ${COMMON_ASFLAGS}
281QUARK_LDFLAGS += ${COMMON_LDFLAGS}
282
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200283.PHONY: locate-checkpatch
284locate-checkpatch:
285ifndef CHECKPATCH
286 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
287else
288ifeq (,$(wildcard ${CHECKPATCH}))
289 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
290endif
291endif
292
293.PHONY: clean
294clean:
295 @echo " CLEAN"
296 ${Q}rm -rf ${BUILD_PLAT}
297 ${MAKE} -C el3_payload clean
298
299.PHONY: realclean distclean
300realclean distclean:
301 @echo " REALCLEAN"
302 ${Q}rm -rf ${BUILD_BASE}
303 ${Q}rm -f ${CURDIR}/cscope.*
304 ${MAKE} -C el3_payload distclean
305
306.PHONY: checkcodebase
307checkcodebase: locate-checkpatch
308 @echo " CHECKING STYLE"
309 @if test -d .git ; then \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000310 git ls-files | grep -E -v 'libc|docs|\.md|\.rst' | \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200311 while read GIT_FILE ; \
312 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
313 done ; \
314 else \
315 find . -type f -not -iwholename "*.git*" \
316 -not -iwholename "*build*" \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000317 -not -iwholename "*libc*" \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200318 -not -iwholename "*docs*" \
319 -not -iwholename "*.md" \
320 -not -iwholename "*.rst" \
321 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
322 fi
323
324.PHONY: checkpatch
325checkpatch: locate-checkpatch
326 @echo " CHECKING STYLE"
327 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
328 for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \
329 printf "\n[*] Checking style of '$$commit'\n\n"; \
330 git log --format=email "$$commit~..$$commit" \
331 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \
332 git diff --format=email "$$commit~..$$commit" \
333 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \
334 done
335
336ifneq (${FIRMWARE_UPDATE},1)
337.PHONY: ns_bl1u ns_bl2u
338ns_bl1u ns_bl2u:
339 @echo "ERROR: Can't build $@ because Firmware Update is not supported \
340 on this platform."
341 @exit 1
342endif
343
344ifneq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000345.PHONY: cactus_mm
346cactus_mm:
347 @echo "ERROR: $@ is supported only on AArch64 FVP."
348 @exit 1
349
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200350.PHONY: cactus
351cactus:
352 @echo "ERROR: $@ is supported only on AArch64 FVP."
353 @exit 1
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000354
355.PHONY: ivy
356ivy:
357 @echo "ERROR: $@ is supported only on AArch64 FVP."
358 @exit 1
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000359
360.PHONY: quark
361quark:
362 @echo "ERROR: $@ is supported only on AArch64 FVP."
363 @exit 1
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200364endif
365
366MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@
367
368define MAKE_C
369
370$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
371$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
372
Bence Szépkúti25671c22019-11-29 18:23:56 +0100373$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200374 @echo " CC $$<"
375 $$(Q)$$(CC) $$($(3)_CFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
376
377-include $(DEP)
378endef
379
380
381define MAKE_S
382
383$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
384$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
385
Bence Szépkúti25671c22019-11-29 18:23:56 +0100386$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200387 @echo " AS $$<"
388 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
389
390-include $(DEP)
391endef
392
393
394define MAKE_LD
395
396$(eval DEP := $(1).d)
397
Bence Szépkúti25671c22019-11-29 18:23:56 +0100398$(1) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200399 @echo " PP $$<"
400 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -P -E $(MAKE_DEP) -o $$@ $$<
401
402-include $(DEP)
403endef
404
405
406define MAKE_OBJS
407 $(eval C_OBJS := $(filter %.c,$(2)))
408 $(eval REMAIN := $(filter-out %.c,$(2)))
409 $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3))))
410
411 $(eval S_OBJS := $(filter %.S,$(REMAIN)))
412 $(eval REMAIN := $(filter-out %.S,$(REMAIN)))
413 $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3))))
414
415 $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
416endef
417
418
419# NOTE: The line continuation '\' is required in the next define otherwise we
420# end up with a line-feed characer at the end of the last c filename.
421# Also bare this issue in mind if extending the list of supported filetypes.
422define SOURCES_TO_OBJS
423 $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \
424 $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1))))
425endef
426
427define uppercase
428$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
429endef
430
431define MAKE_IMG
432 $(eval IMG_PREFIX := $(call uppercase, $(1)))
433 $(eval BUILD_DIR := ${BUILD_PLAT}/$(1))
434 $(eval SOURCES := $(${IMG_PREFIX}_SOURCES))
435 $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
436 $(eval LINKERFILE := $(BUILD_DIR)/$(1).ld)
437 $(eval MAPFILE := $(BUILD_DIR)/$(1).map)
438 $(eval ELF := $(BUILD_DIR)/$(1).elf)
439 $(eval DUMP := $(BUILD_DIR)/$(1).dump)
440 $(eval BIN := $(BUILD_PLAT)/$(1).bin)
441
442 $(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),${IMG_PREFIX}))
443 $(eval $(call MAKE_LD,$(LINKERFILE),$(${IMG_PREFIX}_LINKERFILE),${IMG_PREFIX}))
444
445$(BUILD_DIR) :
446 $$(Q)mkdir -p "$$@"
447
448$(ELF) : $(OBJS) $(LINKERFILE)
449 @echo " LD $$@"
450 @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \
451 const char version_string[] = "${VERSION_STRING}";' | \
452 $$(CC) $$(${IMG_PREFIX}_CFLAGS) ${${IMG_PREFIX}_INCLUDES} ${${IMG_PREFIX}_DEFINES} -c -xc - -o $(BUILD_DIR)/build_message.o
453 $$(Q)$$(LD) -o $$@ $$(${IMG_PREFIX}_LDFLAGS) -Map=$(MAPFILE) \
454 -T $(LINKERFILE) $(BUILD_DIR)/build_message.o $(OBJS)
455
456$(DUMP) : $(ELF)
457 @echo " OD $$@"
458 $${Q}$${OD} -dx $$< > $$@
459
460$(BIN) : $(ELF)
461 @echo " BIN $$@"
462 $$(Q)$$(OC) -O binary $$< $$@
463 @echo
464 @echo "Built $$@ successfully"
465 @echo
466
467.PHONY : $(1)
468$(1) : $(BUILD_DIR) $(BIN) $(DUMP)
469
470all : $(1)
471
472endef
473
474$(AUTOGEN_DIR):
475 $(Q)mkdir -p "$@"
476
477$(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h: $(AUTOGEN_DIR) ${TESTS_FILE} ${PLAT_TESTS_SKIP_LIST}
478 @echo " AUTOGEN $@"
479 tools/generate_test_list/generate_test_list.pl $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h ${TESTS_FILE} $(PLAT_TESTS_SKIP_LIST)
480
481$(eval $(call MAKE_IMG,tftf))
482
483ifeq ($(FIRMWARE_UPDATE), 1)
484 $(eval $(call MAKE_IMG,ns_bl1u))
485 $(eval $(call MAKE_IMG,ns_bl2u))
486endif
487
488ifeq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000489 $(eval $(call MAKE_IMG,cactus_mm))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200490 $(eval $(call MAKE_IMG,cactus))
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000491 $(eval $(call MAKE_IMG,ivy))
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000492 $(eval $(call MAKE_IMG,quark))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200493endif
494
495# The EL3 test payload is only supported in AArch64. It has an independent build
496# system.
497.PHONY: el3_payload
498ifneq (${ARCH},aarch32)
499el3_payload: $(BUILD_DIR)
500 ${Q}${MAKE} -C el3_payload PLAT=${PLAT}
501 ${Q}find "el3_payload/build/${PLAT}" -name '*.bin' -exec cp {} "${BUILD_PLAT}" \;
502
503all: el3_payload
504endif
505
Sandrine Bailleux7fb2e0a2020-04-21 14:45:00 +0200506doc:
507 @echo " BUILD DOCUMENTATION"
508 ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
509
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200510.PHONY: cscope
511cscope:
512 @echo " CSCOPE"
513 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
514 ${Q}cscope -b -q -k
515
516.PHONY: help
517help:
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000518 @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 +0200519 @echo ""
520 @echo "PLAT is used to specify which platform you wish to build."
521 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
522 @echo ""
523 @echo "Supported Targets:"
524 @echo " all Build all supported binaries for this platform"
525 @echo " (i.e. TFTF and FWU images)"
526 @echo " tftf Build the TFTF image"
527 @echo " ns_bl1u Build the NS_BL1U image"
528 @echo " ns_bl2u Build the NS_BL2U image"
Antonio Nino Diaz0c697f92018-11-30 10:51:26 +0000529 @echo " cactus Build the Cactus image (Test S-EL0 payload) and resource description."
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000530 @echo " cactus_mm Build the Cactus-MM image (Test S-EL0 payload)."
Antonio Nino Diaz0c697f92018-11-30 10:51:26 +0000531 @echo " ivy Build the Ivy image (Test S-EL0 payload) and resource description."
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000532 @echo " quark Build the Quark image (Test S-EL0 payload) and resource description."
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200533 @echo " el3_payload Build the EL3 test payload"
534 @echo " checkcodebase Check the coding style of the entire source tree"
535 @echo " checkpatch Check the coding style on changes in the current"
536 @echo " branch against BASE_COMMIT (default origin/master)"
Sandrine Bailleux7fb2e0a2020-04-21 14:45:00 +0200537 @echo " doc Build html based documentation using Sphinx tool"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200538 @echo " clean Clean the build for the selected platform"
539 @echo " cscope Generate cscope index"
540 @echo " distclean Remove all build artifacts for all platforms"
541 @echo ""
542 @echo "note: most build targets require PLAT to be set to a specific platform."
543 @echo ""
544 @echo "example: build all targets for the FVP platform:"
545 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"