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