Makefile 1.67 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
30
31
32
# Chain of trust.
ifeq (${COT},tbbr)
  include src/tbbr/tbbr.mk
else
  $(error Unknown chain of trust ${COT})
endif
33

34
HOSTCCFLAGS := -Wall -std=c99
35
36

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

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

48
HOSTCCFLAGS += ${DEFINES}
49

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

dp-arm's avatar
dp-arm committed
56
HOSTCC ?= gcc
57

Evan Lloyd's avatar
Evan Lloyd committed
58
.PHONY: all clean realclean
59
60
61
62

all: clean ${BINARY}

${BINARY}: ${OBJECTS} Makefile
63
	@echo "  HOSTLD  $@"
64
	@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
65
                const char platform_msg[] = "${PLAT_MSG}";' | \
66
                ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arm's avatar
dp-arm committed
67
	${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
68
69

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

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

realclean: clean
77
	$(call SHELL_DELETE,${BINARY})
78