• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7PLAT		:= none
8V		?= 0
9DEBUG		:= 0
10CRTTOOL		?= cert_create${BIN_EXT}
11BINARY		:= $(notdir ${CRTTOOL})
12OPENSSL_DIR	:= /usr
13COT		:= tbbr
14
15MAKE_HELPERS_DIRECTORY := ../../make_helpers/
16include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
17include ${MAKE_HELPERS_DIRECTORY}build_env.mk
18
19# 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
26
27# Chain of trust.
28ifeq (${COT},tbbr)
29  include src/tbbr/tbbr.mk
30else ifeq (${COT},dualroot)
31  include src/dualroot/cot.mk
32else
33  $(error Unknown chain of trust ${COT})
34endif
35
36HOSTCCFLAGS := -Wall -std=c99
37
38ifeq (${DEBUG},1)
39  HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
40else
41  HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
42endif
43
44ifeq (${V},0)
45  Q := @
46else
47  Q :=
48endif
49
50HOSTCCFLAGS += ${DEFINES}
51
52# Make soft links and include from local directory otherwise wrong headers
53# could get pulled in from firmware tree.
54INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
55LIB_DIR := -L ${OPENSSL_DIR}/lib
56LIB := -lssl -lcrypto
57
58HOSTCC ?= gcc
59
60.PHONY: all clean realclean
61
62all: ${BINARY}
63
64${BINARY}: ${OBJECTS} Makefile
65	@echo "  HOSTLD  $@"
66	@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
67                const char platform_msg[] = "${PLAT_MSG}";' | \
68                ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
69	${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
70
71%.o: %.c
72	@echo "  HOSTCC  $<"
73	${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
74
75clean:
76	$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
77
78realclean: clean
79	$(call SHELL_DELETE,${BINARY})
80
81