| 1 |
# |
| 2 |
# Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. |
| 3 |
# |
| 4 |
# SPDX-License-Identifier: BSD-3-Clause |
| 5 |
# |
| 6 |
|
| 7 |
PLAT := none |
| 8 |
DEBUG := 0 |
| 9 |
CRTTOOL ?= cert_create${BIN_EXT} |
| 10 |
BINARY := $(notdir ${CRTTOOL}) |
| 11 |
COT := tbbr |
| 12 |
|
| 13 |
MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 14 |
include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 15 |
include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
| 16 |
include ${MAKE_HELPERS_DIRECTORY}common.mk |
| 17 |
include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
| 18 |
include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
| 19 |
include ${MAKE_HELPERS_DIRECTORY}utilities.mk |
| 20 |
|
| 21 |
ifneq (${PLAT},none) |
| 22 |
TF_PLATFORM_ROOT := ../../plat/ |
| 23 |
include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
| 24 |
PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk |
| 25 |
endif |
| 26 |
|
| 27 |
# Common source files. |
| 28 |
OBJECTS := src/cert.o \ |
| 29 |
src/cmd_opt.o \ |
| 30 |
src/ext.o \ |
| 31 |
src/key.o \ |
| 32 |
src/main.o \ |
| 33 |
src/sha.o |
| 34 |
|
| 35 |
# Chain of trust. |
| 36 |
ifeq (${COT},tbbr) |
| 37 |
include src/tbbr/tbbr.mk |
| 38 |
else ifeq (${COT},dualroot) |
| 39 |
include src/dualroot/cot.mk |
| 40 |
else ifeq (${COT},cca) |
| 41 |
include src/cca/cot.mk |
| 42 |
else |
| 43 |
$(error Unknown chain of trust ${COT}) |
| 44 |
endif |
| 45 |
|
| 46 |
ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK})) |
| 47 |
include ${PLAT_CERT_CREATE_HELPER_MK} |
| 48 |
endif |
| 49 |
|
| 50 |
# Select OpenSSL version flag according to the OpenSSL build selected |
| 51 |
# from setting the OPENSSL_DIR path. |
| 52 |
$(eval $(call SELECT_OPENSSL_API_VERSION)) |
| 53 |
|
| 54 |
HOSTCCFLAGS := -Wall -std=c99 |
| 55 |
|
| 56 |
ifeq (${DEBUG},1) |
| 57 |
HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
| 58 |
else |
| 59 |
HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
| 60 |
endif |
| 61 |
|
| 62 |
HOSTCCFLAGS += ${DEFINES} -DPLAT_MSG=$(call escape-shell,"$(PLAT_MSG)") |
| 63 |
# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 64 |
# computed value. |
| 65 |
HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
| 66 |
|
| 67 |
# Make soft links and include from local directory otherwise wrong headers |
| 68 |
# could get pulled in from firmware tree. |
| 69 |
INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include |
| 70 |
|
| 71 |
# Include library directories where OpenSSL library files are located. |
| 72 |
# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 73 |
# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 74 |
# directory. However, for a local build of OpenSSL, the built binaries are |
| 75 |
# located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 76 |
# ${OPENSSL_DIR}/lib/). |
| 77 |
LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} |
| 78 |
LIB := -lssl -lcrypto |
| 79 |
|
| 80 |
.PHONY: all clean realclean --openssl |
| 81 |
|
| 82 |
all: --openssl ${BINARY} |
| 83 |
|
| 84 |
${BINARY}: ${OBJECTS} Makefile |
| 85 |
$(s)echo " HOSTLD $@" |
| 86 |
$(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
| 87 |
|
| 88 |
%.o: %.c |
| 89 |
$(s)echo " HOSTCC $<" |
| 90 |
$(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
| 91 |
|
| 92 |
--openssl: |
| 93 |
ifeq ($(DEBUG),1) |
| 94 |
$(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
| 95 |
endif |
| 96 |
|
| 97 |
clean: |
| 98 |
$(call SHELL_DELETE_ALL,${OBJECTS}) |
| 99 |
|
| 100 |
realclean: clean |
| 101 |
$(call SHELL_DELETE,${BINARY}) |