Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 1 | # |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 2 | # Copyright (c) 2015-2024, 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}) |
Sandrine Bailleux | 2f7f144 | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 12 | COT := tbbr |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 13 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 14 | toolchains := host |
| 15 | |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 16 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 17 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 18 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 19 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 20 | include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 21 | |
Pankaj Gupta | dd906e6 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 22 | ifneq (${PLAT},none) |
| 23 | TF_PLATFORM_ROOT := ../../plat/ |
| 24 | include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
| 25 | PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk |
| 26 | endif |
| 27 | |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 28 | # Common source files. |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 29 | OBJECTS := src/cert.o \ |
Juan Castillo | 1218dd5 | 2015-07-03 16:23:16 +0100 | [diff] [blame] | 30 | src/cmd_opt.o \ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 31 | src/ext.o \ |
| 32 | src/key.o \ |
| 33 | src/main.o \ |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 34 | src/sha.o |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 35 | |
Sandrine Bailleux | 2f7f144 | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 36 | # Chain of trust. |
| 37 | ifeq (${COT},tbbr) |
| 38 | include src/tbbr/tbbr.mk |
Sandrine Bailleux | 5d50508 | 2020-01-10 14:32:30 +0100 | [diff] [blame] | 39 | else ifeq (${COT},dualroot) |
| 40 | include src/dualroot/cot.mk |
laurenw-arm | 1c7c576 | 2022-04-21 16:21:53 -0500 | [diff] [blame] | 41 | else ifeq (${COT},cca) |
| 42 | include src/cca/cot.mk |
Sandrine Bailleux | 2f7f144 | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 43 | else |
| 44 | $(error Unknown chain of trust ${COT}) |
| 45 | endif |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 46 | |
Pankaj Gupta | dd906e6 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 47 | ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK})) |
| 48 | include ${PLAT_CERT_CREATE_HELPER_MK} |
| 49 | endif |
| 50 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 51 | # Select OpenSSL version flag according to the OpenSSL build selected |
| 52 | # from setting the OPENSSL_DIR path. |
| 53 | $(eval $(call SELECT_OPENSSL_API_VERSION)) |
| 54 | |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 55 | HOSTCCFLAGS := -Wall -std=c99 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 56 | |
| 57 | ifeq (${DEBUG},1) |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 58 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 59 | else |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 60 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 61 | endif |
Sandrine Bailleux | 3f9df3d | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 62 | |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 63 | ifeq (${V},0) |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 64 | Q := @ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 65 | else |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 66 | Q := |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 67 | endif |
| 68 | |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 69 | HOSTCCFLAGS += ${DEFINES} |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 70 | # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 71 | # computed value. |
| 72 | HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 73 | |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 74 | # Make soft links and include from local directory otherwise wrong headers |
| 75 | # could get pulled in from firmware tree. |
Pankaj Gupta | dd906e6 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 76 | INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 77 | |
| 78 | # Include library directories where OpenSSL library files are located. |
| 79 | # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 80 | # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 81 | # directory. However, for a local build of OpenSSL, the built binaries are |
| 82 | # located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 83 | # ${OPENSSL_DIR}/lib/). |
| 84 | LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 85 | LIB := -lssl -lcrypto |
| 86 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 87 | .PHONY: all clean realclean --openssl |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 88 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 89 | all: --openssl ${BINARY} |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 90 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 91 | ${BINARY}: ${OBJECTS} Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 92 | @echo " HOSTLD $@" |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 93 | @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \ |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 94 | const char platform_msg[] = "${PLAT_MSG}";' | \ |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 95 | $(host-cc) -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o |
| 96 | ${Q}$(host-cc) src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 97 | |
| 98 | %.o: %.c |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 99 | @echo " HOSTCC $<" |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 100 | ${Q}$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 101 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 102 | --openssl: |
| 103 | ifeq ($(DEBUG),1) |
| 104 | @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
| 105 | endif |
| 106 | |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 107 | clean: |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 108 | $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS}) |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 109 | |
| 110 | realclean: clean |
Jonathan Wright | 69da5f2 | 2018-04-30 15:04:02 +0100 | [diff] [blame] | 111 | $(call SHELL_DELETE,${BINARY}) |