blob: 16f4aa3c9b5e03beef856bf85f048c51ca261786 [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001#
Chris Kayc8a47ba2023-10-20 09:17:33 +00002# Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
Juan Castillo11abdcd2014-10-21 11:30:42 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Juan Castillo11abdcd2014-10-21 11:30:42 +01005#
6
Juan Castillo11abdcd2014-10-21 11:30:42 +01007PLAT := none
Juan Castillo11abdcd2014-10-21 11:30:42 +01008DEBUG := 0
Manish V Badarkheb9adb522020-09-05 04:40:41 +01009CRTTOOL ?= cert_create${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010010BINARY := $(notdir ${CRTTOOL})
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010011COT := tbbr
Juan Castillo11abdcd2014-10-21 11:30:42 +010012
Chris Kayc8a47ba2023-10-20 09:17:33 +000013toolchains := host
14
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010015MAKE_HELPERS_DIRECTORY := ../../make_helpers/
16include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
17include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kay1870c722024-05-02 17:52:37 +000018include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Pablo Conde3539c742022-10-25 19:41:02 -040019include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000020include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
Chris Kaya9f543a2024-06-14 11:31:03 +000021include ${MAKE_HELPERS_DIRECTORY}utilities.mk
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010022
Pankaj Guptadd906e62020-12-09 14:02:38 +053023ifneq (${PLAT},none)
24TF_PLATFORM_ROOT := ../../plat/
25include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
26PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk
27endif
28
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010029# Common source files.
Juan Castillo11abdcd2014-10-21 11:30:42 +010030OBJECTS := src/cert.o \
Juan Castillo1218dd52015-07-03 16:23:16 +010031 src/cmd_opt.o \
Juan Castillo11abdcd2014-10-21 11:30:42 +010032 src/ext.o \
33 src/key.o \
34 src/main.o \
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010035 src/sha.o
Juan Castillo11abdcd2014-10-21 11:30:42 +010036
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010037# Chain of trust.
38ifeq (${COT},tbbr)
39 include src/tbbr/tbbr.mk
Sandrine Bailleux5d505082020-01-10 14:32:30 +010040else ifeq (${COT},dualroot)
41 include src/dualroot/cot.mk
laurenw-arm1c7c5762022-04-21 16:21:53 -050042else ifeq (${COT},cca)
43 include src/cca/cot.mk
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010044else
45 $(error Unknown chain of trust ${COT})
46endif
Juan Castillo11abdcd2014-10-21 11:30:42 +010047
Pankaj Guptadd906e62020-12-09 14:02:38 +053048ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK}))
49include ${PLAT_CERT_CREATE_HELPER_MK}
50endif
51
Juan Pablo Conde3539c742022-10-25 19:41:02 -040052# Select OpenSSL version flag according to the OpenSSL build selected
53# from setting the OPENSSL_DIR path.
54$(eval $(call SELECT_OPENSSL_API_VERSION))
55
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010056HOSTCCFLAGS := -Wall -std=c99
Juan Castillo11abdcd2014-10-21 11:30:42 +010057
58ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010059 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo11abdcd2014-10-21 11:30:42 +010060else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010061 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo11abdcd2014-10-21 11:30:42 +010062endif
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010063
Chris Kaya9f543a2024-06-14 11:31:03 +000064HOSTCCFLAGS += ${DEFINES} -DPLAT_MSG=$(call escape-shell,"$(PLAT_MSG)")
Juan Pablo Conde3539c742022-10-25 19:41:02 -040065# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
66# computed value.
67HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090068
Juan Castillo11abdcd2014-10-21 11:30:42 +010069# Make soft links and include from local directory otherwise wrong headers
70# could get pulled in from firmware tree.
Pankaj Guptadd906e62020-12-09 14:02:38 +053071INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050072
73# Include library directories where OpenSSL library files are located.
74# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
75# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
76# directory. However, for a local build of OpenSSL, the built binaries are
77# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
78# ${OPENSSL_DIR}/lib/).
79LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
Juan Castillo11abdcd2014-10-21 11:30:42 +010080LIB := -lssl -lcrypto
81
Juan Pablo Conde3539c742022-10-25 19:41:02 -040082.PHONY: all clean realclean --openssl
Juan Castillo11abdcd2014-10-21 11:30:42 +010083
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020084all: --openssl ${BINARY}
Juan Castillo11abdcd2014-10-21 11:30:42 +010085
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020086${BINARY}: ${OBJECTS} Makefile
Chris Kay1870c722024-05-02 17:52:37 +000087 $(s)echo " HOSTLD $@"
Chris Kaya9f543a2024-06-14 11:31:03 +000088 $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010089
90%.o: %.c
Chris Kay1870c722024-05-02 17:52:37 +000091 $(s)echo " HOSTCC $<"
92 $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010093
Juan Pablo Conde3539c742022-10-25 19:41:02 -040094--openssl:
95ifeq ($(DEBUG),1)
Chris Kay1870c722024-05-02 17:52:37 +000096 $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
Juan Pablo Conde3539c742022-10-25 19:41:02 -040097endif
98
Juan Castillo11abdcd2014-10-21 11:30:42 +010099clean:
Chris Kaya9f543a2024-06-14 11:31:03 +0000100 $(call SHELL_DELETE_ALL,${OBJECTS})
Juan Castillo11abdcd2014-10-21 11:30:42 +0100101
102realclean: clean
Jonathan Wright69da5f22018-04-30 15:04:02 +0100103 $(call SHELL_DELETE,${BINARY})