blob: eff929ef02b5a644b81e1093c47c8f153e35d94f [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
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
19# Common source files.
Juan Castillo11abdcd2014-10-21 11:30:42 +010020OBJECTS := src/cert.o \
Juan Castillo1218dd52015-07-03 16:23:16 +010021 src/cmd_opt.o \
Juan Castillo11abdcd2014-10-21 11:30:42 +010022 src/ext.o \
23 src/key.o \
24 src/main.o \
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010025 src/sha.o
Juan Castillo11abdcd2014-10-21 11:30:42 +010026
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010027# Chain of trust.
28ifeq (${COT},tbbr)
29 include src/tbbr/tbbr.mk
30else
31 $(error Unknown chain of trust ${COT})
32endif
Juan Castillo11abdcd2014-10-21 11:30:42 +010033
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010034HOSTCCFLAGS := -Wall -std=c99
Juan Castillo11abdcd2014-10-21 11:30:42 +010035
36ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010037 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo11abdcd2014-10-21 11:30:42 +010038else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010039 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo11abdcd2014-10-21 11:30:42 +010040endif
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010041
Juan Castillo11abdcd2014-10-21 11:30:42 +010042ifeq (${V},0)
dp-arm34c82012017-05-02 11:14:29 +010043 Q := @
Juan Castillo11abdcd2014-10-21 11:30:42 +010044else
dp-arm34c82012017-05-02 11:14:29 +010045 Q :=
Juan Castillo11abdcd2014-10-21 11:30:42 +010046endif
47
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010048HOSTCCFLAGS += ${DEFINES}
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090049
Juan Castillo11abdcd2014-10-21 11:30:42 +010050# Make soft links and include from local directory otherwise wrong headers
51# could get pulled in from firmware tree.
Juan Castillof9f39c32015-06-01 16:34:23 +010052INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
53LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo11abdcd2014-10-21 11:30:42 +010054LIB := -lssl -lcrypto
55
dp-arme95aaa62017-05-02 11:09:11 +010056HOSTCC ?= gcc
Juan Castillo11abdcd2014-10-21 11:30:42 +010057
Evan Lloydc0f970d2015-12-02 18:22:22 +000058.PHONY: all clean realclean
Juan Castillo11abdcd2014-10-21 11:30:42 +010059
60all: clean ${BINARY}
61
62${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010063 @echo " HOSTLD $@"
Juan Castillo11abdcd2014-10-21 11:30:42 +010064 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090065 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010066 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arme95aaa62017-05-02 11:09:11 +010067 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010068
69%.o: %.c
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010070 @echo " HOSTCC $<"
71 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010072
73clean:
Evan Lloyd26c6cb42015-12-02 18:33:55 +000074 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo11abdcd2014-10-21 11:30:42 +010075
76realclean: clean
Jonathan Wright69da5f22018-04-30 15:04:02 +010077 $(call SHELL_DELETE,${BINARY})
Evan Lloyd26c6cb42015-12-02 18:33:55 +000078