Makefile 1.71 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
#

PLAT		:= none
8
V		?= 0
9
DEBUG		:= 0
10
BINARY		:= $(notdir ${CRTTOOL})
11
OPENSSL_DIR	:= /usr
12
COT		:= tbbr
13

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

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

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

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

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

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

49
HOSTCCFLAGS += ${DEFINES}
50

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

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

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

all: clean ${BINARY}

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

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

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

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