blob: eae76dfb17e6d643e8033913587e690527313b4b [file] [log] [blame]
Juan Castillo6f971622014-10-21 11:30:42 +01001#
Masahiro Yamadabb41eb72017-05-22 12:11:24 +09002# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Juan Castillo6f971622014-10-21 11:30:42 +01003#
dp-arm82cb2c12017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Juan Castillo6f971622014-10-21 11:30:42 +01005#
6
7PROJECT := cert_create
8PLAT := none
dp-arma9673902017-05-02 11:14:29 +01009V ?= 0
Juan Castillo6f971622014-10-21 11:30:42 +010010DEBUG := 0
Evan Lloyd42a45b52015-12-03 11:35:40 +000011BINARY := ${PROJECT}${BIN_EXT}
Juan Castilloccbf8902015-06-01 16:34:23 +010012OPENSSL_DIR := /usr
Juan Castillo6f971622014-10-21 11:30:42 +010013
14OBJECTS := src/cert.o \
Juan Castilload2c1a92015-07-03 16:23:16 +010015 src/cmd_opt.o \
Juan Castillo6f971622014-10-21 11:30:42 +010016 src/ext.o \
17 src/key.o \
18 src/main.o \
Juan Castillo55e291a2015-06-12 11:27:59 +010019 src/sha.o \
20 src/tbbr/tbb_cert.o \
21 src/tbbr/tbb_ext.o \
22 src/tbbr/tbb_key.o
Juan Castillo6f971622014-10-21 11:30:42 +010023
24CFLAGS := -Wall -std=c99
25
Evan Lloyd231c1472015-12-02 18:17:37 +000026MAKE_HELPERS_DIRECTORY := ../../make_helpers/
27include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000028include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloyd231c1472015-12-02 18:17:37 +000029
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090030ifeq (${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
Evan Lloyd231c1472015-12-02 18:17:37 +000037PLATFORM_ROOT := ../../plat/
38include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
39
40PLAT_INCLUDE := $(wildcard ${PLAT_DIR}include)
41
Dan Handleyc04d2602015-03-27 17:44:35 +000042ifeq ($(PLAT_INCLUDE),)
Evan Lloyd231c1472015-12-02 18:17:37 +000043 $(error "Error: Invalid platform '${PLAT}' has no include directory.")
Juan Castillo6f971622014-10-21 11:30:42 +010044endif
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090045endif
Juan Castillo6f971622014-10-21 11:30:42 +010046
47ifeq (${DEBUG},1)
48 CFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
49else
50 CFLAGS += -O2 -DLOG_LEVEL=20
51endif
52ifeq (${V},0)
dp-arma9673902017-05-02 11:14:29 +010053 Q := @
Juan Castillo6f971622014-10-21 11:30:42 +010054else
dp-arma9673902017-05-02 11:14:29 +010055 Q :=
Juan Castillo6f971622014-10-21 11:30:42 +010056endif
57
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090058$(eval $(call add_define,USE_TBBR_DEFS))
59CFLAGS += ${DEFINES}
60
Juan Castillo6f971622014-10-21 11:30:42 +010061# Make soft links and include from local directory otherwise wrong headers
62# could get pulled in from firmware tree.
Juan Castilloccbf8902015-06-01 16:34:23 +010063INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
64LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo6f971622014-10-21 11:30:42 +010065LIB := -lssl -lcrypto
66
dp-arm72610c42017-05-02 11:09:11 +010067HOSTCC ?= gcc
Juan Castillo6f971622014-10-21 11:30:42 +010068
Evan Lloydaeb25662015-12-02 18:22:22 +000069.PHONY: all clean realclean
Juan Castillo6f971622014-10-21 11:30:42 +010070
71all: clean ${BINARY}
72
73${BINARY}: ${OBJECTS} Makefile
74 @echo " LD $@"
75 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090076 const char platform_msg[] = "${PLAT_MSG}";' | \
Juan Castillo6f971622014-10-21 11:30:42 +010077 ${CC} -c ${CFLAGS} -xc - -o src/build_msg.o
dp-arm72610c42017-05-02 11:09:11 +010078 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010079
80%.o: %.c
81 @echo " CC $<"
dp-arm72610c42017-05-02 11:09:11 +010082 ${Q}${HOSTCC} -c ${CFLAGS} ${INC_DIR} $< -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010083
84clean:
Evan Lloydf1477d42015-12-02 18:33:55 +000085 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo6f971622014-10-21 11:30:42 +010086
87realclean: clean
Evan Lloydf1477d42015-12-02 18:33:55 +000088 $(call SHELL_DELETE, ${BINARY})
89