Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 1 | # |
Chris Kay | c327370 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 2 | # Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 3 | # |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 5 | # |
| 6 | |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 7 | PLAT := none |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 8 | DEBUG := 0 |
Chris Kay | c327370 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 9 | CRTTOOL ?= cert_create$(.exe) |
Manish V Badarkhe | fafd3ec | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 10 | BINARY := $(notdir ${CRTTOOL}) |
Sandrine Bailleux | 43743ea | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 11 | COT := tbbr |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 12 | |
Evan Lloyd | 231c147 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 13 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 14 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 15 | include ${MAKE_HELPERS_DIRECTORY}common.mk |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 16 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Chris Kay | cc277de | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 17 | include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
Chris Kay | a004ee8 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 18 | include ${MAKE_HELPERS_DIRECTORY}utilities.mk |
Evan Lloyd | 231c147 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 19 | |
Pankaj Gupta | b94bf96 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 20 | ifneq (${PLAT},none) |
| 21 | TF_PLATFORM_ROOT := ../../plat/ |
| 22 | include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
| 23 | PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk |
| 24 | endif |
| 25 | |
Sandrine Bailleux | 3b24b66 | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 26 | # Common source files. |
| 27 | OBJECTS := src/cert.o \ |
| 28 | src/cmd_opt.o \ |
| 29 | src/ext.o \ |
| 30 | src/key.o \ |
| 31 | src/main.o \ |
| 32 | src/sha.o |
Masahiro Yamada | bb41eb7 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 33 | |
Sandrine Bailleux | 43743ea | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 34 | # Chain of trust. |
| 35 | ifeq (${COT},tbbr) |
| 36 | include src/tbbr/tbbr.mk |
Sandrine Bailleux | a9d5c27 | 2020-01-10 14:32:30 +0100 | [diff] [blame] | 37 | else ifeq (${COT},dualroot) |
| 38 | include src/dualroot/cot.mk |
laurenw-arm | 0a6bf81 | 2022-04-21 16:21:53 -0500 | [diff] [blame] | 39 | else ifeq (${COT},cca) |
| 40 | include src/cca/cot.mk |
Sandrine Bailleux | 43743ea | 2020-01-15 10:11:07 +0100 | [diff] [blame] | 41 | else |
| 42 | $(error Unknown chain of trust ${COT}) |
| 43 | endif |
Evan Lloyd | 231c147 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 44 | |
Pankaj Gupta | b94bf96 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 45 | ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK})) |
| 46 | include ${PLAT_CERT_CREATE_HELPER_MK} |
| 47 | endif |
| 48 | |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 49 | # Select OpenSSL version flag according to the OpenSSL build selected |
| 50 | # from setting the OPENSSL_DIR path. |
| 51 | $(eval $(call SELECT_OPENSSL_API_VERSION)) |
| 52 | |
Sandrine Bailleux | 3b24b66 | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 53 | HOSTCCFLAGS := -Wall -std=c99 |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 54 | |
| 55 | ifeq (${DEBUG},1) |
Antonio Nino Diaz | 750e8d8 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 56 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 57 | else |
Antonio Nino Diaz | 750e8d8 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 58 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 59 | endif |
Sandrine Bailleux | 3b24b66 | 2020-01-14 18:06:38 +0100 | [diff] [blame] | 60 | |
Chris Kay | a004ee8 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 61 | HOSTCCFLAGS += ${DEFINES} -DPLAT_MSG=$(call escape-shell,"$(PLAT_MSG)") |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 62 | # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 63 | # computed value. |
| 64 | HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
Masahiro Yamada | bb41eb7 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 65 | |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 66 | # Make soft links and include from local directory otherwise wrong headers |
| 67 | # could get pulled in from firmware tree. |
Pankaj Gupta | b94bf96 | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 68 | INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include |
Juan Pablo Conde | 9bc52d3 | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 69 | |
| 70 | # Include library directories where OpenSSL library files are located. |
| 71 | # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 72 | # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 73 | # directory. However, for a local build of OpenSSL, the built binaries are |
| 74 | # located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 75 | # ${OPENSSL_DIR}/lib/). |
| 76 | LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 77 | LIB := -lssl -lcrypto |
| 78 | |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 79 | .PHONY: all clean realclean --openssl |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 80 | |
Vincent Stehlé | aa57ce6 | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 81 | all: --openssl ${BINARY} |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 82 | |
Vincent Stehlé | aa57ce6 | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 83 | ${BINARY}: ${OBJECTS} Makefile |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 84 | $(s)echo " HOSTLD $@" |
Chris Kay | a004ee8 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 85 | $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 86 | |
| 87 | %.o: %.c |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 88 | $(s)echo " HOSTCC $<" |
| 89 | $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 90 | |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 91 | --openssl: |
| 92 | ifeq ($(DEBUG),1) |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 93 | $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 94 | endif |
| 95 | |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 96 | clean: |
Chris Kay | c327370 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 97 | $(q)rm -rf $(OBJECTS) |
Juan Castillo | 6f97162 | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 98 | |
| 99 | realclean: clean |
Chris Kay | c327370 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 100 | $(q)rm -f $(BINARY) |