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