Makefile 1.73 KB
Newer Older
1
#
2
# Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
3
#
dp-arm's avatar
dp-arm committed
4
# SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
#

PROJECT		:= cert_create
PLAT		:= none
9
V		?= 0
10
DEBUG		:= 0
11
BINARY		:= ${PROJECT}${BIN_EXT}
12
OPENSSL_DIR	:= /usr
13
COT		:= tbbr
14

15
16
17
18
19
MAKE_HELPERS_DIRECTORY := ../../make_helpers/
include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
include ${MAKE_HELPERS_DIRECTORY}build_env.mk

# Common source files.
20
OBJECTS := src/cert.o \
21
           src/cmd_opt.o \
22
23
24
           src/ext.o \
           src/key.o \
           src/main.o \
25
           src/sha.o
26

27
28
29
# Chain of trust.
ifeq (${COT},tbbr)
  include src/tbbr/tbbr.mk
30
31
else ifeq (${COT},dualroot)
  include src/dualroot/cot.mk
32
33
34
else
  $(error Unknown chain of trust ${COT})
endif
35

36
HOSTCCFLAGS := -Wall -std=c99
37
38

ifeq (${DEBUG},1)
39
  HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
40
else
41
  HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
42
endif
43

44
ifeq (${V},0)
45
  Q := @
46
else
47
  Q :=
48
49
endif

50
HOSTCCFLAGS += ${DEFINES}
51

52
53
# Make soft links and include from local directory otherwise wrong headers
# could get pulled in from firmware tree.
54
55
INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
LIB_DIR := -L ${OPENSSL_DIR}/lib
56
57
LIB := -lssl -lcrypto

dp-arm's avatar
dp-arm committed
58
HOSTCC ?= gcc
59

Evan Lloyd's avatar
Evan Lloyd committed
60
.PHONY: all clean realclean
61
62
63
64

all: clean ${BINARY}

${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
dp-arm's avatar
dp-arm committed
69
	${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
70
71

%.o: %.c
72
73
	@echo "  HOSTCC  $<"
	${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
74
75

clean:
76
	$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
77
78

realclean: clean
79
	$(call SHELL_DELETE,${BINARY})
80