xref: /rk3399_ARM-atf/tools/cert_create/Makefile (revision 69520877af7b3f6560d3781e2408a86c13434e8b)
16f971622SJuan Castillo#
2c3273703SChris 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
7231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := ../../make_helpers/
8231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
9*f4595e6eSBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}build-rules.mk
107c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk
11cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
12cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk
13a004ee8dSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}utilities.mk
14231c1470SEvan Lloyd
15b94bf967SPankaj Guptaifneq (${PLAT},none)
16b94bf967SPankaj GuptaTF_PLATFORM_ROOT	:=	../../plat/
17b94bf967SPankaj Guptainclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
18b94bf967SPankaj GuptaPLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk
19b94bf967SPankaj Guptaendif
20b94bf967SPankaj Gupta
213b24b66eSSandrine Bailleux# Common source files.
22*f4595e6eSBoyan KaratotevCRTTOOL_SOURCES	:= src/cert.c \
23*f4595e6eSBoyan Karatotev		src/cmd_opt.c \
24*f4595e6eSBoyan Karatotev		src/ext.c \
25*f4595e6eSBoyan Karatotev		src/key.c \
26*f4595e6eSBoyan Karatotev		src/main.c \
27*f4595e6eSBoyan Karatotev		src/sha.c
28bb41eb7aSMasahiro Yamada
2943743ea5SSandrine Bailleux# Chain of trust.
3043743ea5SSandrine Bailleuxifeq (${COT},tbbr)
313b24b66eSSandrine Bailleux  include src/tbbr/tbbr.mk
32a9d5c273SSandrine Bailleuxelse ifeq (${COT},dualroot)
33a9d5c273SSandrine Bailleux  include src/dualroot/cot.mk
340a6bf811Slaurenw-armelse ifeq (${COT},cca)
350a6bf811Slaurenw-arm  include src/cca/cot.mk
3643743ea5SSandrine Bailleuxelse
3743743ea5SSandrine Bailleux  $(error Unknown chain of trust ${COT})
3843743ea5SSandrine Bailleuxendif
39231c1470SEvan Lloyd
40b94bf967SPankaj Guptaifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK}))
41b94bf967SPankaj Guptainclude ${PLAT_CERT_CREATE_HELPER_MK}
42b94bf967SPankaj Guptaendif
43b94bf967SPankaj Gupta
44cf2dd17dSJuan Pablo Conde# Select OpenSSL version flag according to the OpenSSL build selected
45cf2dd17dSJuan Pablo Conde# from setting the OPENSSL_DIR path.
46cf2dd17dSJuan Pablo Conde$(eval $(call SELECT_OPENSSL_API_VERSION))
47cf2dd17dSJuan Pablo Conde
48*f4595e6eSBoyan KaratotevCRTTOOL_CFLAGS := -Wall -std=c99
496f971622SJuan Castillo
506f971622SJuan Castilloifeq (${DEBUG},1)
51*f4595e6eSBoyan Karatotev  CRTTOOL_DEFINES += DEBUG LOG_LEVEL=40
52*f4595e6eSBoyan Karatotev  CRTTOOL_CFLAGS+= -g -O0
536f971622SJuan Castilloelse
54*f4595e6eSBoyan Karatotev  CRTTOOL_DEFINES += LOG_LEVEL=20
55*f4595e6eSBoyan Karatotev  CRTTOOL_CFLAGS += -O2
566f971622SJuan Castilloendif
573b24b66eSSandrine Bailleux
58*f4595e6eSBoyan KaratotevCRTTOOL_DEFINES += PLAT_MSG=$(call escape-shell,"$(PLAT_MSG)")
59cf2dd17dSJuan Pablo Conde# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
60cf2dd17dSJuan Pablo Conde# computed value.
61*f4595e6eSBoyan KaratotevCRTTOOL_DEFINES += USING_OPENSSL3=$(USING_OPENSSL3)
62bb41eb7aSMasahiro Yamada
636f971622SJuan Castillo# Make soft links and include from local directory otherwise wrong headers
646f971622SJuan Castillo# could get pulled in from firmware tree.
65*f4595e6eSBoyan KaratotevCRTTOOL_INCLUDE_DIRS += ./include ${PLAT_INCLUDE} ${OPENSSL_DIR}/include
669bc52d33SJuan Pablo Conde
679bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located.
689bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
699bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
709bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are
719bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
729bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/).
73*f4595e6eSBoyan KaratotevCRTTOOL_LDFLAGS += -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
74*f4595e6eSBoyan KaratotevCRTTOOL_LDFLAGS += -lssl -lcrypto
756f971622SJuan Castillo
76cf2dd17dSJuan Pablo Conde.PHONY: all clean realclean --openssl
776f971622SJuan Castillo
78*f4595e6eSBoyan Karatotev$(eval $(call MAKE_TOOL,$(BUILD_PLAT)/tools,cert_create,CRTTOOL))
796f971622SJuan Castillo
80*f4595e6eSBoyan Karatotevall: --openssl
816f971622SJuan Castillo
82cf2dd17dSJuan Pablo Conde--openssl:
83cf2dd17dSJuan Pablo Condeifeq ($(DEBUG),1)
847c4e1eeaSChris Kay	$(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
85cf2dd17dSJuan Pablo Condeendif
86cf2dd17dSJuan Pablo Conde
876f971622SJuan Castilloclean:
88*f4595e6eSBoyan Karatotev	$(q)rm -rf $(BUILD_PLAT)/tools/cert_create
896f971622SJuan Castillo
906f971622SJuan Castillorealclean: clean
91