xref: /rk3399_ARM-atf/tools/cert_create/Makefile (revision 9bc52d330fccb0e4df22006630350a42457d3306)
16f971622SJuan Castillo#
2*9bc52d33SJuan Pablo Conde# Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
36f971622SJuan Castillo#
482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
56f971622SJuan Castillo#
66f971622SJuan Castillo
76f971622SJuan CastilloPLAT		:= none
8a9673900Sdp-armV		?= 0
96f971622SJuan CastilloDEBUG		:= 0
10b13e3f9fSManish V BadarkheCRTTOOL		?= cert_create${BIN_EXT}
11fafd3ec9SManish V BadarkheBINARY		:= $(notdir ${CRTTOOL})
12ccbf890eSJuan CastilloOPENSSL_DIR	:= /usr
1343743ea5SSandrine BailleuxCOT		:= tbbr
146f971622SJuan Castillo
15231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := ../../make_helpers/
16231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
17e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk
18231c1470SEvan Lloyd
19b94bf967SPankaj Guptaifneq (${PLAT},none)
20b94bf967SPankaj GuptaTF_PLATFORM_ROOT	:=	../../plat/
21b94bf967SPankaj Guptainclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
22b94bf967SPankaj GuptaPLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk
23b94bf967SPankaj Guptaendif
24b94bf967SPankaj Gupta
253b24b66eSSandrine Bailleux# Common source files.
263b24b66eSSandrine BailleuxOBJECTS := src/cert.o \
273b24b66eSSandrine Bailleux           src/cmd_opt.o \
283b24b66eSSandrine Bailleux           src/ext.o \
293b24b66eSSandrine Bailleux           src/key.o \
303b24b66eSSandrine Bailleux           src/main.o \
313b24b66eSSandrine Bailleux           src/sha.o
32bb41eb7aSMasahiro Yamada
3343743ea5SSandrine Bailleux# Chain of trust.
3443743ea5SSandrine Bailleuxifeq (${COT},tbbr)
353b24b66eSSandrine Bailleux  include src/tbbr/tbbr.mk
36a9d5c273SSandrine Bailleuxelse ifeq (${COT},dualroot)
37a9d5c273SSandrine Bailleux  include src/dualroot/cot.mk
3843743ea5SSandrine Bailleuxelse
3943743ea5SSandrine Bailleux  $(error Unknown chain of trust ${COT})
4043743ea5SSandrine Bailleuxendif
41231c1470SEvan Lloyd
42b94bf967SPankaj Guptaifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK}))
43b94bf967SPankaj Guptainclude ${PLAT_CERT_CREATE_HELPER_MK}
44b94bf967SPankaj Guptaendif
45b94bf967SPankaj Gupta
463b24b66eSSandrine BailleuxHOSTCCFLAGS := -Wall -std=c99
476f971622SJuan Castillo
486f971622SJuan Castilloifeq (${DEBUG},1)
49750e8d80SAntonio Nino Diaz  HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
506f971622SJuan Castilloelse
51750e8d80SAntonio Nino Diaz  HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
526f971622SJuan Castilloendif
533b24b66eSSandrine Bailleux
546f971622SJuan Castilloifeq (${V},0)
556f971622SJuan Castillo  Q := @
566f971622SJuan Castilloelse
576f971622SJuan Castillo  Q :=
586f971622SJuan Castilloendif
596f971622SJuan Castillo
60750e8d80SAntonio Nino DiazHOSTCCFLAGS += ${DEFINES}
61bb41eb7aSMasahiro Yamada
626f971622SJuan Castillo# Make soft links and include from local directory otherwise wrong headers
636f971622SJuan Castillo# could get pulled in from firmware tree.
64b94bf967SPankaj GuptaINC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
65*9bc52d33SJuan Pablo Conde
66*9bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located.
67*9bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
68*9bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
69*9bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are
70*9bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
71*9bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/).
72*9bc52d33SJuan Pablo CondeLIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
736f971622SJuan CastilloLIB := -lssl -lcrypto
746f971622SJuan Castillo
7572610c41Sdp-armHOSTCC ?= gcc
766f971622SJuan Castillo
77aeb25668SEvan Lloyd.PHONY: all clean realclean
786f971622SJuan Castillo
7969a91659SRoss Burtonall: ${BINARY}
806f971622SJuan Castillo
816f971622SJuan Castillo${BINARY}: ${OBJECTS} Makefile
82750e8d80SAntonio Nino Diaz	@echo "  HOSTLD  $@"
836f971622SJuan Castillo	@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
84bb41eb7aSMasahiro Yamada                const char platform_msg[] = "${PLAT_MSG}";' | \
85750e8d80SAntonio Nino Diaz                ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
8672610c41Sdp-arm	${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
876f971622SJuan Castillo
886f971622SJuan Castillo%.o: %.c
89750e8d80SAntonio Nino Diaz	@echo "  HOSTCC  $<"
90750e8d80SAntonio Nino Diaz	${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
916f971622SJuan Castillo
926f971622SJuan Castilloclean:
93f1477d4aSEvan Lloyd	$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
946f971622SJuan Castillo
956f971622SJuan Castillorealclean: clean
96f1477d4aSEvan Lloyd	$(call SHELL_DELETE,${BINARY})
97f1477d4aSEvan Lloyd
98