blob: 76de6660b88ed3b8f524c4afc64ba491e73ecdc9 [file] [log] [blame]
Juan Castillo6f971622014-10-21 11:30:42 +01001#
Sandrine Bailleux3b24b662020-01-14 18:06:38 +01002# Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
Juan Castillo6f971622014-10-21 11:30:42 +01003#
dp-arm82cb2c12017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Juan Castillo6f971622014-10-21 11:30:42 +01005#
6
7PROJECT := cert_create
8PLAT := none
dp-arma9673902017-05-02 11:14:29 +01009V ?= 0
Juan Castillo6f971622014-10-21 11:30:42 +010010DEBUG := 0
Evan Lloyd42a45b52015-12-03 11:35:40 +000011BINARY := ${PROJECT}${BIN_EXT}
Juan Castilloccbf8902015-06-01 16:34:23 +010012OPENSSL_DIR := /usr
Juan Castillo6f971622014-10-21 11:30:42 +010013
Evan Lloyd231c1472015-12-02 18:17:37 +000014MAKE_HELPERS_DIRECTORY := ../../make_helpers/
15include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000016include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloyd231c1472015-12-02 18:17:37 +000017
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010018# Common source files.
19OBJECTS := src/cert.o \
20 src/cmd_opt.o \
21 src/ext.o \
22 src/key.o \
23 src/main.o \
24 src/sha.o
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090025
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010026# TBBR chain of trust definitions.
27include src/tbbr/tbbr.mk
Evan Lloyd231c1472015-12-02 18:17:37 +000028
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010029HOSTCCFLAGS := -Wall -std=c99
Juan Castillo6f971622014-10-21 11:30:42 +010030
31ifeq (${DEBUG},1)
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010032 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo6f971622014-10-21 11:30:42 +010033else
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010034 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo6f971622014-10-21 11:30:42 +010035endif
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010036
Juan Castillo6f971622014-10-21 11:30:42 +010037ifeq (${V},0)
dp-arma9673902017-05-02 11:14:29 +010038 Q := @
Juan Castillo6f971622014-10-21 11:30:42 +010039else
dp-arma9673902017-05-02 11:14:29 +010040 Q :=
Juan Castillo6f971622014-10-21 11:30:42 +010041endif
42
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010043HOSTCCFLAGS += ${DEFINES}
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090044
Juan Castillo6f971622014-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 Castilloccbf8902015-06-01 16:34:23 +010047INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
48LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo6f971622014-10-21 11:30:42 +010049LIB := -lssl -lcrypto
50
dp-arm72610c42017-05-02 11:09:11 +010051HOSTCC ?= gcc
Juan Castillo6f971622014-10-21 11:30:42 +010052
Evan Lloydaeb25662015-12-02 18:22:22 +000053.PHONY: all clean realclean
Juan Castillo6f971622014-10-21 11:30:42 +010054
55all: clean ${BINARY}
56
57${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010058 @echo " HOSTLD $@"
Juan Castillo6f971622014-10-21 11:30:42 +010059 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090060 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010061 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arm72610c42017-05-02 11:09:11 +010062 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010063
64%.o: %.c
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010065 @echo " HOSTCC $<"
66 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010067
68clean:
Evan Lloydf1477d42015-12-02 18:33:55 +000069 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo6f971622014-10-21 11:30:42 +010070
71realclean: clean
Jonathan Wright2f36e852018-04-30 15:04:02 +010072 $(call SHELL_DELETE,${BINARY})
Evan Lloydf1477d42015-12-02 18:33:55 +000073