xref: /rk3399_ARM-atf/tools/cert_create/Makefile (revision c32737033cf2b0ae9649a08273c07b739d368818)
16f971622SJuan Castillo#
2*c3273703SChris Kay# Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved.
36f971622SJuan Castillo#
482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
56f971622SJuan Castillo#
66f971622SJuan Castillo
76f971622SJuan CastilloPLAT		:= none
86f971622SJuan CastilloDEBUG		:= 0
9*c3273703SChris KayCRTTOOL		?= cert_create$(.exe)
10fafd3ec9SManish V BadarkheBINARY		:= $(notdir ${CRTTOOL})
1143743ea5SSandrine BailleuxCOT		:= tbbr
126f971622SJuan Castillo
13231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := ../../make_helpers/
14231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
157c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk
16cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
17cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk
18a004ee8dSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}utilities.mk
19231c1470SEvan Lloyd
20b94bf967SPankaj Guptaifneq (${PLAT},none)
21b94bf967SPankaj GuptaTF_PLATFORM_ROOT	:=	../../plat/
22b94bf967SPankaj Guptainclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
23b94bf967SPankaj GuptaPLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk
24b94bf967SPankaj Guptaendif
25b94bf967SPankaj Gupta
263b24b66eSSandrine Bailleux# Common source files.
273b24b66eSSandrine BailleuxOBJECTS := src/cert.o \
283b24b66eSSandrine Bailleux           src/cmd_opt.o \
293b24b66eSSandrine Bailleux           src/ext.o \
303b24b66eSSandrine Bailleux           src/key.o \
313b24b66eSSandrine Bailleux           src/main.o \
323b24b66eSSandrine Bailleux           src/sha.o
33bb41eb7aSMasahiro Yamada
3443743ea5SSandrine Bailleux# Chain of trust.
3543743ea5SSandrine Bailleuxifeq (${COT},tbbr)
363b24b66eSSandrine Bailleux  include src/tbbr/tbbr.mk
37a9d5c273SSandrine Bailleuxelse ifeq (${COT},dualroot)
38a9d5c273SSandrine Bailleux  include src/dualroot/cot.mk
390a6bf811Slaurenw-armelse ifeq (${COT},cca)
400a6bf811Slaurenw-arm  include src/cca/cot.mk
4143743ea5SSandrine Bailleuxelse
4243743ea5SSandrine Bailleux  $(error Unknown chain of trust ${COT})
4343743ea5SSandrine Bailleuxendif
44231c1470SEvan Lloyd
45b94bf967SPankaj Guptaifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK}))
46b94bf967SPankaj Guptainclude ${PLAT_CERT_CREATE_HELPER_MK}
47b94bf967SPankaj Guptaendif
48b94bf967SPankaj Gupta
49cf2dd17dSJuan Pablo Conde# Select OpenSSL version flag according to the OpenSSL build selected
50cf2dd17dSJuan Pablo Conde# from setting the OPENSSL_DIR path.
51cf2dd17dSJuan Pablo Conde$(eval $(call SELECT_OPENSSL_API_VERSION))
52cf2dd17dSJuan Pablo Conde
533b24b66eSSandrine BailleuxHOSTCCFLAGS := -Wall -std=c99
546f971622SJuan Castillo
556f971622SJuan Castilloifeq (${DEBUG},1)
56750e8d80SAntonio Nino Diaz  HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
576f971622SJuan Castilloelse
58750e8d80SAntonio Nino Diaz  HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
596f971622SJuan Castilloendif
603b24b66eSSandrine Bailleux
61a004ee8dSChris KayHOSTCCFLAGS += ${DEFINES} -DPLAT_MSG=$(call escape-shell,"$(PLAT_MSG)")
62cf2dd17dSJuan Pablo Conde# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
63cf2dd17dSJuan Pablo Conde# computed value.
64cf2dd17dSJuan Pablo CondeHOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
65bb41eb7aSMasahiro Yamada
666f971622SJuan Castillo# Make soft links and include from local directory otherwise wrong headers
676f971622SJuan Castillo# could get pulled in from firmware tree.
68b94bf967SPankaj GuptaINC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
699bc52d33SJuan Pablo Conde
709bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located.
719bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
729bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
739bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are
749bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
759bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/).
769bc52d33SJuan Pablo CondeLIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
776f971622SJuan CastilloLIB := -lssl -lcrypto
786f971622SJuan Castillo
79cf2dd17dSJuan Pablo Conde.PHONY: all clean realclean --openssl
806f971622SJuan Castillo
81aa57ce63SVincent Stehléall: --openssl ${BINARY}
826f971622SJuan Castillo
83aa57ce63SVincent Stehlé${BINARY}: ${OBJECTS} Makefile
847c4e1eeaSChris Kay	$(s)echo "  HOSTLD  $@"
85a004ee8dSChris Kay	$(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
866f971622SJuan Castillo
876f971622SJuan Castillo%.o: %.c
887c4e1eeaSChris Kay	$(s)echo "  HOSTCC  $<"
897c4e1eeaSChris Kay	$(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
906f971622SJuan Castillo
91cf2dd17dSJuan Pablo Conde--openssl:
92cf2dd17dSJuan Pablo Condeifeq ($(DEBUG),1)
937c4e1eeaSChris Kay	$(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
94cf2dd17dSJuan Pablo Condeendif
95cf2dd17dSJuan Pablo Conde
966f971622SJuan Castilloclean:
97*c3273703SChris Kay	$(q)rm -rf $(OBJECTS)
986f971622SJuan Castillo
996f971622SJuan Castillorealclean: clean
100*c3273703SChris Kay	$(q)rm -f $(BINARY)
101