Makefile 1.99 KB
Newer Older
1
#
2
# Copyright (c) 2015-2021, 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
CRTTOOL		?= cert_create${BIN_EXT}
11
BINARY		:= $(notdir ${CRTTOOL})
12
OPENSSL_DIR	:= /usr
13
COT		:= tbbr
14

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

19
20
21
22
23
24
ifneq (${PLAT},none)
TF_PLATFORM_ROOT	:=	../../plat/
include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk
endif

25
# Common source files.
26
OBJECTS := src/cert.o \
27
           src/cmd_opt.o \
28
29
30
           src/ext.o \
           src/key.o \
           src/main.o \
31
           src/sha.o
32

33
34
35
# Chain of trust.
ifeq (${COT},tbbr)
  include src/tbbr/tbbr.mk
36
37
else ifeq (${COT},dualroot)
  include src/dualroot/cot.mk
38
39
40
else
  $(error Unknown chain of trust ${COT})
endif
41

42
43
44
45
ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK}))
include ${PLAT_CERT_CREATE_HELPER_MK}
endif

46
HOSTCCFLAGS := -Wall -std=c99
47
48

ifeq (${DEBUG},1)
49
  HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
50
else
51
  HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
52
endif
53

54
ifeq (${V},0)
55
  Q := @
56
else
57
  Q :=
58
59
endif

60
HOSTCCFLAGS += ${DEFINES}
61

62
63
# Make soft links and include from local directory otherwise wrong headers
# could get pulled in from firmware tree.
64
INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
65
LIB_DIR := -L ${OPENSSL_DIR}/lib
66
67
LIB := -lssl -lcrypto

dp-arm's avatar
dp-arm committed
68
HOSTCC ?= gcc
69

Evan Lloyd's avatar
Evan Lloyd committed
70
.PHONY: all clean realclean
71

Ross Burton's avatar
Ross Burton committed
72
all: ${BINARY}
73
74

${BINARY}: ${OBJECTS} Makefile
75
	@echo "  HOSTLD  $@"
76
	@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
77
                const char platform_msg[] = "${PLAT_MSG}";' | \
78
                ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arm's avatar
dp-arm committed
79
	${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
80
81

%.o: %.c
82
83
	@echo "  HOSTCC  $<"
	${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
84
85

clean:
86
	$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
87
88

realclean: clean
89
	$(call SHELL_DELETE,${BINARY})
90