xref: /rk3399_ARM-atf/tools/cert_create/Makefile (revision d6104f5ab4e68f92cf97f6a3e55395c71ed137ac)
1#
2# Copyright (c) 2015-2016, 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
30PLATFORM_ROOT		:=	../../plat/
31include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
32
33PLAT_INCLUDE		:=	$(wildcard ${PLAT_DIR}include)
34
35ifeq ($(PLAT_INCLUDE),)
36  $(error "Error: Invalid platform '${PLAT}' has no include directory.")
37endif
38
39ifeq (${DEBUG},1)
40  CFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
41else
42  CFLAGS += -O2 -DLOG_LEVEL=20
43endif
44ifeq (${V},0)
45	Q := @
46else
47	Q :=
48endif
49
50# Make soft links and include from local directory otherwise wrong headers
51# could get pulled in from firmware tree.
52INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
53LIB_DIR := -L ${OPENSSL_DIR}/lib
54LIB := -lssl -lcrypto
55
56CC := gcc
57
58.PHONY: all clean realclean
59
60all: clean ${BINARY}
61
62${BINARY}: ${OBJECTS} Makefile
63	@echo "  LD      $@"
64	@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
65                const char platform_msg[] = "${PLAT}";' | \
66                ${CC} -c ${CFLAGS} -xc - -o src/build_msg.o
67	${Q}${CC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
68
69%.o: %.c
70	@echo "  CC      $<"
71	${Q}${CC} -c ${CFLAGS} ${INC_DIR} $< -o $@
72
73clean:
74	$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
75
76realclean: clean
77	$(call SHELL_DELETE, ${BINARY})
78
79