• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7PROJECT		:= cert_create
8PLAT		:= none
9V		?= 0
10DEBUG		:= 0
11BINARY		:= ${PROJECT}${BIN_EXT}
12OPENSSL_DIR	:= /usr
13USE_TBBR_DEFS   := 1
14
15OBJECTS := src/cert.o \
16           src/cmd_opt.o \
17           src/ext.o \
18           src/key.o \
19           src/main.o \
20           src/sha.o \
21           src/tbbr/tbb_cert.o \
22           src/tbbr/tbb_ext.o \
23           src/tbbr/tbb_key.o
24
25CFLAGS := -Wall -std=c99
26
27MAKE_HELPERS_DIRECTORY := ../../make_helpers/
28include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
29include ${MAKE_HELPERS_DIRECTORY}build_env.mk
30
31ifeq (${USE_TBBR_DEFS},1)
32# In this case, cert_tool is platform-independent
33PLAT_MSG		:=	TBBR Generic
34PLAT_INCLUDE		:=	../../include/tools_share
35else
36PLAT_MSG		:=	${PLAT}
37
38PLATFORM_ROOT		:=	../../plat/
39include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
40
41PLAT_INCLUDE		:=	$(wildcard ${PLAT_DIR}include)
42
43ifeq ($(PLAT_INCLUDE),)
44  $(error "Error: Invalid platform '${PLAT}' has no include directory.")
45endif
46endif
47
48ifeq (${DEBUG},1)
49  CFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
50else
51  CFLAGS += -O2 -DLOG_LEVEL=20
52endif
53ifeq (${V},0)
54  Q := @
55else
56  Q :=
57endif
58
59$(eval $(call add_define,USE_TBBR_DEFS))
60CFLAGS += ${DEFINES}
61
62# Make soft links and include from local directory otherwise wrong headers
63# could get pulled in from firmware tree.
64INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
65LIB_DIR := -L ${OPENSSL_DIR}/lib
66LIB := -lssl -lcrypto
67
68HOSTCC ?= gcc
69
70.PHONY: all clean realclean
71
72all: clean ${BINARY}
73
74${BINARY}: ${OBJECTS} Makefile
75	@echo "  LD      $@"
76	@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
77                const char platform_msg[] = "${PLAT_MSG}";' | \
78                ${CC} -c ${CFLAGS} -xc - -o src/build_msg.o
79	${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
80
81%.o: %.c
82	@echo "  CC      $<"
83	${Q}${HOSTCC} -c ${CFLAGS} ${INC_DIR} $< -o $@
84
85clean:
86	$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
87
88realclean: clean
89	$(call SHELL_DELETE, ${BINARY})
90
91