Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 1 | # |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 2 | # Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 5 | # |
| 6 | |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 7 | PLAT := none |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 8 | V ?= 0 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 9 | DEBUG := 0 |
Manish V Badarkhe | b9adb52 | 2020-09-05 04:40:41 +0100 | [diff] [blame] | 10 | CRTTOOL ?= cert_create${BIN_EXT} |
Manish V Badarkhe | 635482e | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 11 | BINARY := $(notdir ${CRTTOOL}) |
Juan Castillo | f9f39c3 | 2015-06-01 16:34:23 +0100 | [diff] [blame] | 12 | OPENSSL_DIR := /usr |
Sandrine Bailleux | 2f7f144 | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 13 | COT := tbbr |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 14 | |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 15 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 16 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 17 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
| 18 | |
Pankaj Gupta | dd906e6 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 19 | ifneq (${PLAT},none) |
| 20 | TF_PLATFORM_ROOT := ../../plat/ |
| 21 | include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
| 22 | PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk |
| 23 | endif |
| 24 | |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 25 | # Common source files. |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 26 | OBJECTS := src/cert.o \ |
Juan Castillo | 1218dd5 | 2015-07-03 16:23:16 +0100 | [diff] [blame] | 27 | src/cmd_opt.o \ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 28 | src/ext.o \ |
| 29 | src/key.o \ |
| 30 | src/main.o \ |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 31 | src/sha.o |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 32 | |
Sandrine Bailleux | 2f7f144 | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 33 | # Chain of trust. |
| 34 | ifeq (${COT},tbbr) |
| 35 | include src/tbbr/tbbr.mk |
Sandrine Bailleux | 5d50508 | 2020-01-10 14:32:30 +0100 | [diff] [blame] | 36 | else ifeq (${COT},dualroot) |
| 37 | include src/dualroot/cot.mk |
laurenw-arm | 1c7c576 | 2022-04-21 16:21:53 -0500 | [diff] [blame^] | 38 | else ifeq (${COT},cca) |
| 39 | include src/cca/cot.mk |
Sandrine Bailleux | 2f7f144 | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 40 | else |
| 41 | $(error Unknown chain of trust ${COT}) |
| 42 | endif |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 43 | |
Pankaj Gupta | dd906e6 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 44 | ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK})) |
| 45 | include ${PLAT_CERT_CREATE_HELPER_MK} |
| 46 | endif |
| 47 | |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 48 | HOSTCCFLAGS := -Wall -std=c99 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 49 | |
| 50 | ifeq (${DEBUG},1) |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 51 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 52 | else |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 53 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 54 | endif |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 55 | |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 56 | ifeq (${V},0) |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 57 | Q := @ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 58 | else |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 59 | Q := |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 60 | endif |
| 61 | |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 62 | HOSTCCFLAGS += ${DEFINES} |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 63 | |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 64 | # Make soft links and include from local directory otherwise wrong headers |
| 65 | # could get pulled in from firmware tree. |
Pankaj Gupta | dd906e6 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 66 | INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 67 | |
| 68 | # Include library directories where OpenSSL library files are located. |
| 69 | # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 70 | # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 71 | # directory. However, for a local build of OpenSSL, the built binaries are |
| 72 | # located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 73 | # ${OPENSSL_DIR}/lib/). |
| 74 | LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 75 | LIB := -lssl -lcrypto |
| 76 | |
dp-arm | e95aaa6 | 2017-05-02 11:09:11 +0100 | [diff] [blame] | 77 | HOSTCC ?= gcc |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 78 | |
Evan Lloyd | c0f970d | 2015-12-02 18:22:22 +0000 | [diff] [blame] | 79 | .PHONY: all clean realclean |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 80 | |
Ross Burton | 7d7916d | 2021-01-13 12:47:25 +0000 | [diff] [blame] | 81 | all: ${BINARY} |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 82 | |
| 83 | ${BINARY}: ${OBJECTS} Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 84 | @echo " HOSTLD $@" |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 85 | @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \ |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 86 | const char platform_msg[] = "${PLAT_MSG}";' | \ |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 87 | ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o |
dp-arm | e95aaa6 | 2017-05-02 11:09:11 +0100 | [diff] [blame] | 88 | ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 89 | |
| 90 | %.o: %.c |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 91 | @echo " HOSTCC $<" |
| 92 | ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 93 | |
| 94 | clean: |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 95 | $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS}) |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 96 | |
| 97 | realclean: clean |
Jonathan Wright | 69da5f2 | 2018-04-30 15:04:02 +0100 | [diff] [blame] | 98 | $(call SHELL_DELETE,${BINARY}) |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 99 | |