blob: c03629a00732daef9a671f8a18db3bb52be946da [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001#
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +01002# Copyright (c) 2015-2018, 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
7PROJECT := cert_create
8PLAT := none
dp-arm34c82012017-05-02 11:14:29 +01009V ?= 0
Juan Castillo11abdcd2014-10-21 11:30:42 +010010DEBUG := 0
Evan Lloyd004c9a52015-12-03 11:35:40 +000011BINARY := ${PROJECT}${BIN_EXT}
Juan Castillof9f39c32015-06-01 16:34:23 +010012OPENSSL_DIR := /usr
Soby Mathew87be6c12017-09-08 10:54:12 +010013USE_TBBR_DEFS := 1
Juan Castillo11abdcd2014-10-21 11:30:42 +010014
15OBJECTS := src/cert.o \
Juan Castillo1218dd52015-07-03 16:23:16 +010016 src/cmd_opt.o \
Juan Castillo11abdcd2014-10-21 11:30:42 +010017 src/ext.o \
18 src/key.o \
19 src/main.o \
Juan Castilloe6d30e92015-06-12 11:27:59 +010020 src/sha.o \
21 src/tbbr/tbb_cert.o \
22 src/tbbr/tbb_ext.o \
23 src/tbbr/tbb_key.o
Juan Castillo11abdcd2014-10-21 11:30:42 +010024
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010025HOSTCCFLAGS := -Wall -std=c99
Juan Castillo11abdcd2014-10-21 11:30:42 +010026
Evan Lloydf2697142015-12-02 18:17:37 +000027MAKE_HELPERS_DIRECTORY := ../../make_helpers/
28include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000029include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloydf2697142015-12-02 18:17:37 +000030
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090031ifeq (${USE_TBBR_DEFS},1)
32# In this case, cert_tool is platform-independent
33PLAT_MSG := TBBR Generic
34PLAT_INCLUDE := ../../include/tools_share
35else
36PLAT_MSG := ${PLAT}
37
Heyi Guo335433a2018-03-01 18:57:58 +080038TF_PLATFORM_ROOT := ../../plat/
Evan Lloydf2697142015-12-02 18:17:37 +000039include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
40
41PLAT_INCLUDE := $(wildcard ${PLAT_DIR}include)
42
Dan Handley81be1002015-03-27 17:44:35 +000043ifeq ($(PLAT_INCLUDE),)
Evan Lloydf2697142015-12-02 18:17:37 +000044 $(error "Error: Invalid platform '${PLAT}' has no include directory.")
Juan Castillo11abdcd2014-10-21 11:30:42 +010045endif
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090046endif
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
53ifeq (${V},0)
dp-arm34c82012017-05-02 11:14:29 +010054 Q := @
Juan Castillo11abdcd2014-10-21 11:30:42 +010055else
dp-arm34c82012017-05-02 11:14:29 +010056 Q :=
Juan Castillo11abdcd2014-10-21 11:30:42 +010057endif
58
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090059$(eval $(call add_define,USE_TBBR_DEFS))
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.
Juan Castillof9f39c32015-06-01 16:34:23 +010064INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
65LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo11abdcd2014-10-21 11:30:42 +010066LIB := -lssl -lcrypto
67
dp-arme95aaa62017-05-02 11:09:11 +010068HOSTCC ?= gcc
Juan Castillo11abdcd2014-10-21 11:30:42 +010069
Evan Lloydc0f970d2015-12-02 18:22:22 +000070.PHONY: all clean realclean
Juan Castillo11abdcd2014-10-21 11:30:42 +010071
72all: clean ${BINARY}
73
74${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010075 @echo " HOSTLD $@"
Juan Castillo11abdcd2014-10-21 11:30:42 +010076 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090077 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010078 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arme95aaa62017-05-02 11:09:11 +010079 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010080
81%.o: %.c
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010082 @echo " HOSTCC $<"
83 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010084
85clean:
Evan Lloyd26c6cb42015-12-02 18:33:55 +000086 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo11abdcd2014-10-21 11:30:42 +010087
88realclean: clean
Jonathan Wright69da5f22018-04-30 15:04:02 +010089 $(call SHELL_DELETE,${BINARY})
Evan Lloyd26c6cb42015-12-02 18:33:55 +000090