blob: 19f736f070b143b6f20cb4e389af59e53fc6479a [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
Sandrine Bailleux43743ea2020-01-15 10:11:07 +010013COT := tbbr
Juan Castillo6f971622014-10-21 11:30:42 +010014
Evan Lloyd231c1472015-12-02 18:17:37 +000015MAKE_HELPERS_DIRECTORY := ../../make_helpers/
16include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000017include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloyd231c1472015-12-02 18:17:37 +000018
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010019# Common source files.
20OBJECTS := src/cert.o \
21 src/cmd_opt.o \
22 src/ext.o \
23 src/key.o \
24 src/main.o \
25 src/sha.o
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090026
Sandrine Bailleux43743ea2020-01-15 10:11:07 +010027# Chain of trust.
28ifeq (${COT},tbbr)
29 include src/tbbr/tbbr.mk
Sandrine Bailleuxa9d5c272020-01-10 14:32:30 +010030else ifeq (${COT},dualroot)
31 include src/dualroot/cot.mk
Sandrine Bailleux43743ea2020-01-15 10:11:07 +010032else
33 $(error Unknown chain of trust ${COT})
34endif
Evan Lloyd231c1472015-12-02 18:17:37 +000035
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010036HOSTCCFLAGS := -Wall -std=c99
Juan Castillo6f971622014-10-21 11:30:42 +010037
38ifeq (${DEBUG},1)
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010039 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo6f971622014-10-21 11:30:42 +010040else
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010041 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo6f971622014-10-21 11:30:42 +010042endif
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010043
Juan Castillo6f971622014-10-21 11:30:42 +010044ifeq (${V},0)
dp-arma9673902017-05-02 11:14:29 +010045 Q := @
Juan Castillo6f971622014-10-21 11:30:42 +010046else
dp-arma9673902017-05-02 11:14:29 +010047 Q :=
Juan Castillo6f971622014-10-21 11:30:42 +010048endif
49
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010050HOSTCCFLAGS += ${DEFINES}
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090051
Juan Castillo6f971622014-10-21 11:30:42 +010052# Make soft links and include from local directory otherwise wrong headers
53# could get pulled in from firmware tree.
Juan Castilloccbf8902015-06-01 16:34:23 +010054INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
55LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo6f971622014-10-21 11:30:42 +010056LIB := -lssl -lcrypto
57
dp-arm72610c42017-05-02 11:09:11 +010058HOSTCC ?= gcc
Juan Castillo6f971622014-10-21 11:30:42 +010059
Evan Lloydaeb25662015-12-02 18:22:22 +000060.PHONY: all clean realclean
Juan Castillo6f971622014-10-21 11:30:42 +010061
62all: clean ${BINARY}
63
64${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010065 @echo " HOSTLD $@"
Juan Castillo6f971622014-10-21 11:30:42 +010066 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090067 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010068 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arm72610c42017-05-02 11:09:11 +010069 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010070
71%.o: %.c
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010072 @echo " HOSTCC $<"
73 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010074
75clean:
Evan Lloydf1477d42015-12-02 18:33:55 +000076 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo6f971622014-10-21 11:30:42 +010077
78realclean: clean
Jonathan Wright2f36e852018-04-30 15:04:02 +010079 $(call SHELL_DELETE,${BINARY})
Evan Lloydf1477d42015-12-02 18:33:55 +000080