1# 2# Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6 7PLAT := none 8DEBUG := 0 9CRTTOOL ?= cert_create${BIN_EXT} 10BINARY := $(notdir ${CRTTOOL}) 11COT := tbbr 12 13MAKE_HELPERS_DIRECTORY := ../../make_helpers/ 14include ${MAKE_HELPERS_DIRECTORY}build_macros.mk 15include ${MAKE_HELPERS_DIRECTORY}build_env.mk 16include ${MAKE_HELPERS_DIRECTORY}common.mk 17include ${MAKE_HELPERS_DIRECTORY}defaults.mk 18include ${MAKE_HELPERS_DIRECTORY}toolchain.mk 19include ${MAKE_HELPERS_DIRECTORY}utilities.mk 20 21ifneq (${PLAT},none) 22TF_PLATFORM_ROOT := ../../plat/ 23include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 24PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk 25endif 26 27# Common source files. 28OBJECTS := 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. 36ifeq (${COT},tbbr) 37 include src/tbbr/tbbr.mk 38else ifeq (${COT},dualroot) 39 include src/dualroot/cot.mk 40else ifeq (${COT},cca) 41 include src/cca/cot.mk 42else 43 $(error Unknown chain of trust ${COT}) 44endif 45 46ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK})) 47include ${PLAT_CERT_CREATE_HELPER_MK} 48endif 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 54HOSTCCFLAGS := -Wall -std=c99 55 56ifeq (${DEBUG},1) 57 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 58else 59 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 60endif 61 62HOSTCCFLAGS += ${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. 65HOSTCCFLAGS += -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. 69INC_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/). 77LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} 78LIB := -lssl -lcrypto 79 80.PHONY: all clean realclean --openssl 81 82all: --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: 93ifeq ($(DEBUG),1) 94 $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" 95endif 96 97clean: 98 $(call SHELL_DELETE_ALL,${OBJECTS}) 99 100realclean: clean 101 $(call SHELL_DELETE,${BINARY}) 102