blob: 76de6660b88ed3b8f524c4afc64ba491e73ecdc9 [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001#
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +01002# Copyright (c) 2015-2020, 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
Juan Castillo11abdcd2014-10-21 11:30:42 +010013
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010014MAKE_HELPERS_DIRECTORY := ../../make_helpers/
15include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
16include ${MAKE_HELPERS_DIRECTORY}build_env.mk
17
18# Common source files.
Juan Castillo11abdcd2014-10-21 11:30:42 +010019OBJECTS := src/cert.o \
Juan Castillo1218dd52015-07-03 16:23:16 +010020 src/cmd_opt.o \
Juan Castillo11abdcd2014-10-21 11:30:42 +010021 src/ext.o \
22 src/key.o \
23 src/main.o \
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010024 src/sha.o
Juan Castillo11abdcd2014-10-21 11:30:42 +010025
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010026# TBBR chain of trust definitions.
27include src/tbbr/tbbr.mk
Juan Castillo11abdcd2014-10-21 11:30:42 +010028
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010029HOSTCCFLAGS := -Wall -std=c99
Juan Castillo11abdcd2014-10-21 11:30:42 +010030
31ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010032 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo11abdcd2014-10-21 11:30:42 +010033else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010034 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo11abdcd2014-10-21 11:30:42 +010035endif
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010036
Juan Castillo11abdcd2014-10-21 11:30:42 +010037ifeq (${V},0)
dp-arm34c82012017-05-02 11:14:29 +010038 Q := @
Juan Castillo11abdcd2014-10-21 11:30:42 +010039else
dp-arm34c82012017-05-02 11:14:29 +010040 Q :=
Juan Castillo11abdcd2014-10-21 11:30:42 +010041endif
42
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010043HOSTCCFLAGS += ${DEFINES}
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090044
Juan Castillo11abdcd2014-10-21 11:30:42 +010045# Make soft links and include from local directory otherwise wrong headers
46# could get pulled in from firmware tree.
Juan Castillof9f39c32015-06-01 16:34:23 +010047INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
48LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo11abdcd2014-10-21 11:30:42 +010049LIB := -lssl -lcrypto
50
dp-arme95aaa62017-05-02 11:09:11 +010051HOSTCC ?= gcc
Juan Castillo11abdcd2014-10-21 11:30:42 +010052
Evan Lloydc0f970d2015-12-02 18:22:22 +000053.PHONY: all clean realclean
Juan Castillo11abdcd2014-10-21 11:30:42 +010054
55all: clean ${BINARY}
56
57${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010058 @echo " HOSTLD $@"
Juan Castillo11abdcd2014-10-21 11:30:42 +010059 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090060 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010061 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arme95aaa62017-05-02 11:09:11 +010062 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010063
64%.o: %.c
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010065 @echo " HOSTCC $<"
66 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010067
68clean:
Evan Lloyd26c6cb42015-12-02 18:33:55 +000069 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo11abdcd2014-10-21 11:30:42 +010070
71realclean: clean
Jonathan Wright69da5f22018-04-30 15:04:02 +010072 $(call SHELL_DELETE,${BINARY})
Evan Lloyd26c6cb42015-12-02 18:33:55 +000073