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