blob: dc6092ff1b59caa7da47c95ade4ddf66fd1efa97 [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 Pappireddy954b2032019-10-15 11:13:41 -05009VERSION_MINOR := 2
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
81# Convenience function for adding build definitions
82# $(eval $(call add_define,BAR_DEFINES,FOO)) will have:
83# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
84# inside the BAR_DEFINES variable.
85define add_define
86$(1) += -D$(2)$(if $(value $(2)),=$(value $(2)),)
87endef
88
89# Convenience function for verifying option has a boolean value
90# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1
91define assert_boolean
92$(and $(patsubst 0,,$(value $(1))),$(patsubst 1,,$(value $(1))),$(error $(1) must be boolean))
93endef
94
95ifeq (${PLAT},)
96 $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform")
97endif
98PLAT_PATH := $(shell find plat/ -wholename '*/${PLAT}')
99PLAT_MAKEFILE_FULL := ${PLAT_PATH}/${PLAT_MAKEFILE}
100ifeq ($(wildcard ${PLAT_MAKEFILE_FULL}),)
101 $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
102endif
103
104.PHONY: all
105all: msg_start
106
107.PHONY: msg_start
108msg_start:
109 @echo "Building ${PLAT}"
Sandrine Bailleux043d5362018-10-03 17:05:59 +0200110 @echo "Selected set of tests: ${TESTS}"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200111
112# Include test images makefiles.
113include tftf/framework/framework.mk
114include tftf/tests/tests.mk
115include fwu/ns_bl1u/ns_bl1u.mk
116include fwu/ns_bl2u/ns_bl2u.mk
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000117include spm/cactus_mm/cactus_mm.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200118include spm/cactus/cactus.mk
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000119include spm/ivy/ivy.mk
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000120include spm/quark/quark.mk
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200121
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000122################################################################################
123# Include libc
124################################################################################
125include lib/libc/libc.mk
126
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200127# Include platform specific makefile last because:
128# - the platform makefile may use all previous definitions in this file.
129# - the platform makefile may wish overwriting some of them.
130include ${PLAT_MAKEFILE_FULL}
131
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200132.SUFFIXES:
133
134################################################################################
135# Build options checks
136################################################################################
137$(eval $(call assert_boolean,DEBUG))
138$(eval $(call assert_boolean,ENABLE_ASSERTIONS))
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000139$(eval $(call assert_boolean,ENABLE_PAUTH))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200140$(eval $(call assert_boolean,FIRMWARE_UPDATE))
141$(eval $(call assert_boolean,FWU_BL_TEST))
142$(eval $(call assert_boolean,NEW_TEST_SESSION))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200143$(eval $(call assert_boolean,USE_NVM))
144
145################################################################################
146# Add definitions to the cpp preprocessor based on the current build options.
147# This is done after including the platform specific makefile to allow the
148# platform to overwrite the default options
149################################################################################
150$(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MAJOR))
151$(eval $(call add_define,TFTF_DEFINES,ARM_ARCH_MINOR))
152$(eval $(call add_define,TFTF_DEFINES,DEBUG))
153$(eval $(call add_define,TFTF_DEFINES,ENABLE_ASSERTIONS))
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000154$(eval $(call add_define,TFTF_DEFINES,ENABLE_PAUTH))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200155$(eval $(call add_define,TFTF_DEFINES,LOG_LEVEL))
156$(eval $(call add_define,TFTF_DEFINES,NEW_TEST_SESSION))
157$(eval $(call add_define,TFTF_DEFINES,PLAT_${PLAT}))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200158$(eval $(call add_define,TFTF_DEFINES,USE_NVM))
159
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200160################################################################################
161
162# Assembler, compiler and linker flags shared across all test images.
163COMMON_ASFLAGS :=
164COMMON_CFLAGS :=
165COMMON_LDFLAGS :=
166
167ifeq (${DEBUG},1)
168COMMON_CFLAGS += -g
169COMMON_ASFLAGS += -g -Wa,--gdwarf-2
170endif
171
Joel Hutton87530242019-04-08 15:46:36 +0100172# Set the compiler's target architecture profile based on ARM_ARCH_MINOR option
173ifeq (${ARM_ARCH_MINOR},0)
174march32-directive = -march=armv8-a
175march64-directive = -march=armv8-a
176else
177march32-directive = -march=armv8.${ARM_ARCH_MINOR}-a
178march64-directive = -march=armv8.${ARM_ARCH_MINOR}-a
179endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200180
Joel Hutton87530242019-04-08 15:46:36 +0100181COMMON_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive}
182COMMON_CFLAGS_aarch64 := -mgeneral-regs-only -mstrict-align ${march64-directive}
183
184COMMON_ASFLAGS_aarch32 := ${march32-directive}
185COMMON_CFLAGS_aarch32 := ${march32-directive} -mno-unaligned-access
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200186
187COMMON_ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
188 -Werror -Wmissing-include-dirs \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000189 -D__ASSEMBLY__ $(COMMON_ASFLAGS_$(ARCH)) \
190 ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200191COMMON_CFLAGS += -nostdinc -ffreestanding -Wall -Werror \
192 -Wmissing-include-dirs $(COMMON_CFLAGS_$(ARCH)) \
193 -std=gnu99 -Os
194COMMON_CFLAGS += -ffunction-sections -fdata-sections
195
196# Get the content of CFLAGS user defined value last so they are appended after
197# the options defined in the Makefile
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000198COMMON_CFLAGS += ${CFLAGS} ${INCLUDES}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200199
200COMMON_LDFLAGS += --fatal-warnings -O1 --gc-sections --build-id=none
201
202CC := ${CROSS_COMPILE}gcc
203CPP := ${CROSS_COMPILE}cpp
204AS := ${CROSS_COMPILE}gcc
205AR := ${CROSS_COMPILE}ar
206LD := ${CROSS_COMPILE}ld
207OC := ${CROSS_COMPILE}objcopy
208OD := ${CROSS_COMPILE}objdump
209NM := ${CROSS_COMPILE}nm
210PP := ${CROSS_COMPILE}gcc
211
212################################################################################
213
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000214TFTF_SOURCES := ${FRAMEWORK_SOURCES} ${TESTS_SOURCES} ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200215TFTF_INCLUDES += ${PLAT_INCLUDES}
216TFTF_CFLAGS += ${COMMON_CFLAGS}
217TFTF_ASFLAGS += ${COMMON_ASFLAGS}
218TFTF_LDFLAGS += ${COMMON_LDFLAGS}
219
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000220ifeq (${ENABLE_PAUTH},1)
Alexei Fedorove72ce612019-10-03 10:57:53 +0100221TFTF_CFLAGS += -mbranch-protection=pac-ret
Alexei Fedorovb61cc152020-01-08 14:02:18 +0000222NS_BL1U_CFLAGS += -mbranch-protection=pac-ret
223NS_BL2U_CFLAGS += -mbranch-protection=pac-ret
Antonio Nino Diaz2f13f422019-03-13 13:57:39 +0000224endif
225
Olivier Deprezdb70c452020-02-03 11:27:01 +0100226#####################################################################################
227ifneq ($(findstring gcc,$(notdir $(LD))),)
228 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
229else
230 PIE_LDFLAGS += -pie --no-dynamic-linker
231endif
232
233#####################################################################################
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000234NS_BL1U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200235NS_BL1U_INCLUDES += ${PLAT_INCLUDES}
236NS_BL1U_CFLAGS += ${COMMON_CFLAGS}
237NS_BL1U_ASFLAGS += ${COMMON_ASFLAGS}
238NS_BL1U_LDFLAGS += ${COMMON_LDFLAGS}
239
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000240NS_BL2U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200241NS_BL2U_INCLUDES += ${PLAT_INCLUDES}
242NS_BL2U_CFLAGS += ${COMMON_CFLAGS}
243NS_BL2U_ASFLAGS += ${COMMON_ASFLAGS}
244NS_BL2U_LDFLAGS += ${COMMON_LDFLAGS}
245
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000246CACTUS_MM_SOURCES += ${LIBC_SRCS}
247CACTUS_MM_INCLUDES += ${PLAT_INCLUDES}
248CACTUS_MM_CFLAGS += ${COMMON_CFLAGS}
249CACTUS_MM_ASFLAGS += ${COMMON_ASFLAGS}
250CACTUS_MM_LDFLAGS += ${COMMON_LDFLAGS}
251
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000252CACTUS_SOURCES += ${LIBC_SRCS}
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200253CACTUS_INCLUDES += ${PLAT_INCLUDES}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100254CACTUS_CFLAGS += ${COMMON_CFLAGS} -fpie
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200255CACTUS_ASFLAGS += ${COMMON_ASFLAGS}
Olivier Deprezdb70c452020-02-03 11:27:01 +0100256CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200257
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000258IVY_SOURCES += ${LIBC_SRCS}
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000259IVY_INCLUDES += ${PLAT_INCLUDES}
260IVY_CFLAGS += ${COMMON_CFLAGS}
261IVY_ASFLAGS += ${COMMON_ASFLAGS}
262IVY_LDFLAGS += ${COMMON_LDFLAGS}
263
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000264QUARK_SOURCES += ${LIBC_SRCS}
265QUARK_INCLUDES += ${PLAT_INCLUDES}
266QUARK_CFLAGS += ${COMMON_CFLAGS}
267QUARK_ASFLAGS += ${COMMON_ASFLAGS}
268QUARK_LDFLAGS += ${COMMON_LDFLAGS}
269
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200270.PHONY: locate-checkpatch
271locate-checkpatch:
272ifndef CHECKPATCH
273 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
274else
275ifeq (,$(wildcard ${CHECKPATCH}))
276 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
277endif
278endif
279
280.PHONY: clean
281clean:
282 @echo " CLEAN"
283 ${Q}rm -rf ${BUILD_PLAT}
284 ${MAKE} -C el3_payload clean
285
286.PHONY: realclean distclean
287realclean distclean:
288 @echo " REALCLEAN"
289 ${Q}rm -rf ${BUILD_BASE}
290 ${Q}rm -f ${CURDIR}/cscope.*
291 ${MAKE} -C el3_payload distclean
292
293.PHONY: checkcodebase
294checkcodebase: locate-checkpatch
295 @echo " CHECKING STYLE"
296 @if test -d .git ; then \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000297 git ls-files | grep -E -v 'libc|docs|\.md|\.rst' | \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200298 while read GIT_FILE ; \
299 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
300 done ; \
301 else \
302 find . -type f -not -iwholename "*.git*" \
303 -not -iwholename "*build*" \
Ambroise Vincenta2ede622019-02-11 14:34:26 +0000304 -not -iwholename "*libc*" \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200305 -not -iwholename "*docs*" \
306 -not -iwholename "*.md" \
307 -not -iwholename "*.rst" \
308 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
309 fi
310
311.PHONY: checkpatch
312checkpatch: locate-checkpatch
313 @echo " CHECKING STYLE"
314 ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
315 for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \
316 printf "\n[*] Checking style of '$$commit'\n\n"; \
317 git log --format=email "$$commit~..$$commit" \
318 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \
319 git diff --format=email "$$commit~..$$commit" \
320 -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \
321 done
322
323ifneq (${FIRMWARE_UPDATE},1)
324.PHONY: ns_bl1u ns_bl2u
325ns_bl1u ns_bl2u:
326 @echo "ERROR: Can't build $@ because Firmware Update is not supported \
327 on this platform."
328 @exit 1
329endif
330
331ifneq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000332.PHONY: cactus_mm
333cactus_mm:
334 @echo "ERROR: $@ is supported only on AArch64 FVP."
335 @exit 1
336
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200337.PHONY: cactus
338cactus:
339 @echo "ERROR: $@ is supported only on AArch64 FVP."
340 @exit 1
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000341
342.PHONY: ivy
343ivy:
344 @echo "ERROR: $@ is supported only on AArch64 FVP."
345 @exit 1
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000346
347.PHONY: quark
348quark:
349 @echo "ERROR: $@ is supported only on AArch64 FVP."
350 @exit 1
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200351endif
352
353MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@
354
355define MAKE_C
356
357$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
358$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
359
Bence Szépkúti25671c22019-11-29 18:23:56 +0100360$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200361 @echo " CC $$<"
362 $$(Q)$$(CC) $$($(3)_CFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
363
364-include $(DEP)
365endef
366
367
368define MAKE_S
369
370$(eval OBJ := $(1)/$(patsubst %.S,%.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 " AS $$<"
375 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
376
377-include $(DEP)
378endef
379
380
381define MAKE_LD
382
383$(eval DEP := $(1).d)
384
Bence Szépkúti25671c22019-11-29 18:23:56 +0100385$(1) : $(2) | $(AUTOGEN_DIR)/tests_list.h
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200386 @echo " PP $$<"
387 $$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -P -E $(MAKE_DEP) -o $$@ $$<
388
389-include $(DEP)
390endef
391
392
393define MAKE_OBJS
394 $(eval C_OBJS := $(filter %.c,$(2)))
395 $(eval REMAIN := $(filter-out %.c,$(2)))
396 $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj),$(3))))
397
398 $(eval S_OBJS := $(filter %.S,$(REMAIN)))
399 $(eval REMAIN := $(filter-out %.S,$(REMAIN)))
400 $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj),$(3))))
401
402 $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
403endef
404
405
406# NOTE: The line continuation '\' is required in the next define otherwise we
407# end up with a line-feed characer at the end of the last c filename.
408# Also bare this issue in mind if extending the list of supported filetypes.
409define SOURCES_TO_OBJS
410 $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \
411 $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1))))
412endef
413
414define uppercase
415$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
416endef
417
418define MAKE_IMG
419 $(eval IMG_PREFIX := $(call uppercase, $(1)))
420 $(eval BUILD_DIR := ${BUILD_PLAT}/$(1))
421 $(eval SOURCES := $(${IMG_PREFIX}_SOURCES))
422 $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
423 $(eval LINKERFILE := $(BUILD_DIR)/$(1).ld)
424 $(eval MAPFILE := $(BUILD_DIR)/$(1).map)
425 $(eval ELF := $(BUILD_DIR)/$(1).elf)
426 $(eval DUMP := $(BUILD_DIR)/$(1).dump)
427 $(eval BIN := $(BUILD_PLAT)/$(1).bin)
428
429 $(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),${IMG_PREFIX}))
430 $(eval $(call MAKE_LD,$(LINKERFILE),$(${IMG_PREFIX}_LINKERFILE),${IMG_PREFIX}))
431
432$(BUILD_DIR) :
433 $$(Q)mkdir -p "$$@"
434
435$(ELF) : $(OBJS) $(LINKERFILE)
436 @echo " LD $$@"
437 @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \
438 const char version_string[] = "${VERSION_STRING}";' | \
439 $$(CC) $$(${IMG_PREFIX}_CFLAGS) ${${IMG_PREFIX}_INCLUDES} ${${IMG_PREFIX}_DEFINES} -c -xc - -o $(BUILD_DIR)/build_message.o
440 $$(Q)$$(LD) -o $$@ $$(${IMG_PREFIX}_LDFLAGS) -Map=$(MAPFILE) \
441 -T $(LINKERFILE) $(BUILD_DIR)/build_message.o $(OBJS)
442
443$(DUMP) : $(ELF)
444 @echo " OD $$@"
445 $${Q}$${OD} -dx $$< > $$@
446
447$(BIN) : $(ELF)
448 @echo " BIN $$@"
449 $$(Q)$$(OC) -O binary $$< $$@
450 @echo
451 @echo "Built $$@ successfully"
452 @echo
453
454.PHONY : $(1)
455$(1) : $(BUILD_DIR) $(BIN) $(DUMP)
456
457all : $(1)
458
459endef
460
461$(AUTOGEN_DIR):
462 $(Q)mkdir -p "$@"
463
464$(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h: $(AUTOGEN_DIR) ${TESTS_FILE} ${PLAT_TESTS_SKIP_LIST}
465 @echo " AUTOGEN $@"
466 tools/generate_test_list/generate_test_list.pl $(AUTOGEN_DIR)/tests_list.c $(AUTOGEN_DIR)/tests_list.h ${TESTS_FILE} $(PLAT_TESTS_SKIP_LIST)
467
468$(eval $(call MAKE_IMG,tftf))
469
470ifeq ($(FIRMWARE_UPDATE), 1)
471 $(eval $(call MAKE_IMG,ns_bl1u))
472 $(eval $(call MAKE_IMG,ns_bl2u))
473endif
474
475ifeq (${ARCH}-${PLAT},aarch64-fvp)
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000476 $(eval $(call MAKE_IMG,cactus_mm))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200477 $(eval $(call MAKE_IMG,cactus))
Antonio Nino Diaz0b1ab402018-12-05 15:38:39 +0000478 $(eval $(call MAKE_IMG,ivy))
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000479 $(eval $(call MAKE_IMG,quark))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200480endif
481
482# The EL3 test payload is only supported in AArch64. It has an independent build
483# system.
484.PHONY: el3_payload
485ifneq (${ARCH},aarch32)
486el3_payload: $(BUILD_DIR)
487 ${Q}${MAKE} -C el3_payload PLAT=${PLAT}
488 ${Q}find "el3_payload/build/${PLAT}" -name '*.bin' -exec cp {} "${BUILD_PLAT}" \;
489
490all: el3_payload
491endif
492
493.PHONY: cscope
494cscope:
495 @echo " CSCOPE"
496 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
497 ${Q}cscope -b -q -k
498
499.PHONY: help
500help:
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000501 @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 +0200502 @echo ""
503 @echo "PLAT is used to specify which platform you wish to build."
504 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
505 @echo ""
506 @echo "Supported Targets:"
507 @echo " all Build all supported binaries for this platform"
508 @echo " (i.e. TFTF and FWU images)"
509 @echo " tftf Build the TFTF image"
510 @echo " ns_bl1u Build the NS_BL1U image"
511 @echo " ns_bl2u Build the NS_BL2U image"
Antonio Nino Diaz0c697f92018-11-30 10:51:26 +0000512 @echo " cactus Build the Cactus image (Test S-EL0 payload) and resource description."
Antonio Nino Diaz9d7726c2019-03-19 10:59:11 +0000513 @echo " cactus_mm Build the Cactus-MM image (Test S-EL0 payload)."
Antonio Nino Diaz0c697f92018-11-30 10:51:26 +0000514 @echo " ivy Build the Ivy image (Test S-EL0 payload) and resource description."
Antonio Nino Diazfee6e7e2019-03-28 13:16:04 +0000515 @echo " quark Build the Quark image (Test S-EL0 payload) and resource description."
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200516 @echo " el3_payload Build the EL3 test payload"
517 @echo " checkcodebase Check the coding style of the entire source tree"
518 @echo " checkpatch Check the coding style on changes in the current"
519 @echo " branch against BASE_COMMIT (default origin/master)"
520 @echo " clean Clean the build for the selected platform"
521 @echo " cscope Generate cscope index"
522 @echo " distclean Remove all build artifacts for all platforms"
523 @echo ""
524 @echo "note: most build targets require PLAT to be set to a specific platform."
525 @echo ""
526 @echo "example: build all targets for the FVP platform:"
527 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"