blob: 989a8e4dc1abb09c378067519bef2523fe5761ff [file] [log] [blame]
Juan Castillo6f971622014-10-21 11:30:42 +01001#
Evan Lloyde7f54db2015-12-02 18:56:06 +00002# Copyright (c) 2015-2016, 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
9V := 0
10DEBUG := 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
30PLATFORM_ROOT := ../../plat/
31include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
32
33PLAT_INCLUDE := $(wildcard ${PLAT_DIR}include)
34
Dan Handleyc04d2602015-03-27 17:44:35 +000035ifeq ($(PLAT_INCLUDE),)
Evan Lloyd231c1472015-12-02 18:17:37 +000036 $(error "Error: Invalid platform '${PLAT}' has no include directory.")
Juan Castillo6f971622014-10-21 11:30:42 +010037endif
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.
Juan Castilloccbf8902015-06-01 16:34:23 +010052INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
53LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo6f971622014-10-21 11:30:42 +010054LIB := -lssl -lcrypto
55
56CC := gcc
Juan Castillo6f971622014-10-21 11:30:42 +010057
Evan Lloydaeb25662015-12-02 18:22:22 +000058.PHONY: all clean realclean
Juan Castillo6f971622014-10-21 11:30:42 +010059
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:
Evan Lloydf1477d42015-12-02 18:33:55 +000074 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo6f971622014-10-21 11:30:42 +010075
76realclean: clean
Evan Lloydf1477d42015-12-02 18:33:55 +000077 $(call SHELL_DELETE, ${BINARY})
78