blob: 989a8e4dc1abb09c378067519bef2523fe5761ff [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001#
Evan Lloyda71d2592015-12-02 18:56:06 +00002# Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
Juan Castillo11abdcd2014-10-21 11:30:42 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Juan Castillo11abdcd2014-10-21 11:30:42 +01005#
6
7PROJECT := cert_create
8PLAT := none
9V := 0
10DEBUG := 0
Evan Lloyd004c9a52015-12-03 11:35:40 +000011BINARY := ${PROJECT}${BIN_EXT}
Juan Castillof9f39c32015-06-01 16:34:23 +010012OPENSSL_DIR := /usr
Juan Castillo11abdcd2014-10-21 11:30:42 +010013
14OBJECTS := src/cert.o \
Juan Castillo1218dd52015-07-03 16:23:16 +010015 src/cmd_opt.o \
Juan Castillo11abdcd2014-10-21 11:30:42 +010016 src/ext.o \
17 src/key.o \
18 src/main.o \
Juan Castilloe6d30e92015-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 Castillo11abdcd2014-10-21 11:30:42 +010023
24CFLAGS := -Wall -std=c99
25
Evan Lloydf2697142015-12-02 18:17:37 +000026MAKE_HELPERS_DIRECTORY := ../../make_helpers/
27include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000028include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloydf2697142015-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 Handley81be1002015-03-27 17:44:35 +000035ifeq ($(PLAT_INCLUDE),)
Evan Lloydf2697142015-12-02 18:17:37 +000036 $(error "Error: Invalid platform '${PLAT}' has no include directory.")
Juan Castillo11abdcd2014-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 Castillof9f39c32015-06-01 16:34:23 +010052INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
53LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo11abdcd2014-10-21 11:30:42 +010054LIB := -lssl -lcrypto
55
56CC := gcc
Juan Castillo11abdcd2014-10-21 11:30:42 +010057
Evan Lloydc0f970d2015-12-02 18:22:22 +000058.PHONY: all clean realclean
Juan Castillo11abdcd2014-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 Lloyd26c6cb42015-12-02 18:33:55 +000074 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo11abdcd2014-10-21 11:30:42 +010075
76realclean: clean
Evan Lloyd26c6cb42015-12-02 18:33:55 +000077 $(call SHELL_DELETE, ${BINARY})
78