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