blob: ca548b83668c19170c9f14e620252bb2c3ca1838 [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001#
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -05002# Copyright (c) 2015-2022, 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
dp-arm34c82012017-05-02 11:14:29 +01008V ?= 0
Juan Castillo11abdcd2014-10-21 11:30:42 +01009DEBUG := 0
Manish V Badarkheb9adb522020-09-05 04:40:41 +010010CRTTOOL ?= cert_create${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010011BINARY := $(notdir ${CRTTOOL})
Juan Castillof9f39c32015-06-01 16:34:23 +010012OPENSSL_DIR := /usr
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010013COT := tbbr
Juan Castillo11abdcd2014-10-21 11:30:42 +010014
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
18
Pankaj Guptadd906e62020-12-09 14:02:38 +053019ifneq (${PLAT},none)
20TF_PLATFORM_ROOT := ../../plat/
21include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
22PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk
23endif
24
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010025# Common source files.
Juan Castillo11abdcd2014-10-21 11:30:42 +010026OBJECTS := src/cert.o \
Juan Castillo1218dd52015-07-03 16:23:16 +010027 src/cmd_opt.o \
Juan Castillo11abdcd2014-10-21 11:30:42 +010028 src/ext.o \
29 src/key.o \
30 src/main.o \
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010031 src/sha.o
Juan Castillo11abdcd2014-10-21 11:30:42 +010032
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010033# Chain of trust.
34ifeq (${COT},tbbr)
35 include src/tbbr/tbbr.mk
Sandrine Bailleux5d505082020-01-10 14:32:30 +010036else ifeq (${COT},dualroot)
37 include src/dualroot/cot.mk
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010038else
39 $(error Unknown chain of trust ${COT})
40endif
Juan Castillo11abdcd2014-10-21 11:30:42 +010041
Pankaj Guptadd906e62020-12-09 14:02:38 +053042ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK}))
43include ${PLAT_CERT_CREATE_HELPER_MK}
44endif
45
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010046HOSTCCFLAGS := -Wall -std=c99
Juan Castillo11abdcd2014-10-21 11:30:42 +010047
48ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010049 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo11abdcd2014-10-21 11:30:42 +010050else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010051 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo11abdcd2014-10-21 11:30:42 +010052endif
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010053
Juan Castillo11abdcd2014-10-21 11:30:42 +010054ifeq (${V},0)
dp-arm34c82012017-05-02 11:14:29 +010055 Q := @
Juan Castillo11abdcd2014-10-21 11:30:42 +010056else
dp-arm34c82012017-05-02 11:14:29 +010057 Q :=
Juan Castillo11abdcd2014-10-21 11:30:42 +010058endif
59
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010060HOSTCCFLAGS += ${DEFINES}
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090061
Juan Castillo11abdcd2014-10-21 11:30:42 +010062# Make soft links and include from local directory otherwise wrong headers
63# could get pulled in from firmware tree.
Pankaj Guptadd906e62020-12-09 14:02:38 +053064INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050065
66# Include library directories where OpenSSL library files are located.
67# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
68# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
69# directory. However, for a local build of OpenSSL, the built binaries are
70# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
71# ${OPENSSL_DIR}/lib/).
72LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
Juan Castillo11abdcd2014-10-21 11:30:42 +010073LIB := -lssl -lcrypto
74
dp-arme95aaa62017-05-02 11:09:11 +010075HOSTCC ?= gcc
Juan Castillo11abdcd2014-10-21 11:30:42 +010076
Evan Lloydc0f970d2015-12-02 18:22:22 +000077.PHONY: all clean realclean
Juan Castillo11abdcd2014-10-21 11:30:42 +010078
Ross Burton7d7916d2021-01-13 12:47:25 +000079all: ${BINARY}
Juan Castillo11abdcd2014-10-21 11:30:42 +010080
81${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010082 @echo " HOSTLD $@"
Juan Castillo11abdcd2014-10-21 11:30:42 +010083 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090084 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010085 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arme95aaa62017-05-02 11:09:11 +010086 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010087
88%.o: %.c
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010089 @echo " HOSTCC $<"
90 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010091
92clean:
Evan Lloyd26c6cb42015-12-02 18:33:55 +000093 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo11abdcd2014-10-21 11:30:42 +010094
95realclean: clean
Jonathan Wright69da5f22018-04-30 15:04:02 +010096 $(call SHELL_DELETE,${BINARY})
Evan Lloyd26c6cb42015-12-02 18:33:55 +000097