Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 1 | # |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 2 | # Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 5 | # |
| 6 | |
| 7 | PROJECT := cert_create |
| 8 | PLAT := none |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 9 | V ?= 0 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 10 | DEBUG := 0 |
Evan Lloyd | 004c9a5 | 2015-12-03 11:35:40 +0000 | [diff] [blame] | 11 | BINARY := ${PROJECT}${BIN_EXT} |
Juan Castillo | f9f39c3 | 2015-06-01 16:34:23 +0100 | [diff] [blame] | 12 | OPENSSL_DIR := /usr |
Soby Mathew | 87be6c1 | 2017-09-08 10:54:12 +0100 | [diff] [blame] | 13 | USE_TBBR_DEFS := 1 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 14 | |
| 15 | OBJECTS := src/cert.o \ |
Juan Castillo | 1218dd5 | 2015-07-03 16:23:16 +0100 | [diff] [blame] | 16 | src/cmd_opt.o \ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 17 | src/ext.o \ |
| 18 | src/key.o \ |
| 19 | src/main.o \ |
Juan Castillo | e6d30e9 | 2015-06-12 11:27:59 +0100 | [diff] [blame] | 20 | src/sha.o \ |
| 21 | src/tbbr/tbb_cert.o \ |
| 22 | src/tbbr/tbb_ext.o \ |
| 23 | src/tbbr/tbb_key.o |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 24 | |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 25 | HOSTCCFLAGS := -Wall -std=c99 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 26 | |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 27 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 28 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 29 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 30 | |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 31 | ifeq (${USE_TBBR_DEFS},1) |
| 32 | # In this case, cert_tool is platform-independent |
| 33 | PLAT_MSG := TBBR Generic |
| 34 | PLAT_INCLUDE := ../../include/tools_share |
| 35 | else |
| 36 | PLAT_MSG := ${PLAT} |
| 37 | |
Heyi Guo | 335433a | 2018-03-01 18:57:58 +0800 | [diff] [blame] | 38 | TF_PLATFORM_ROOT := ../../plat/ |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 39 | include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
| 40 | |
| 41 | PLAT_INCLUDE := $(wildcard ${PLAT_DIR}include) |
| 42 | |
Dan Handley | 81be100 | 2015-03-27 17:44:35 +0000 | [diff] [blame] | 43 | ifeq ($(PLAT_INCLUDE),) |
Evan Lloyd | f269714 | 2015-12-02 18:17:37 +0000 | [diff] [blame] | 44 | $(error "Error: Invalid platform '${PLAT}' has no include directory.") |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 45 | endif |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 46 | endif |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 47 | |
| 48 | ifeq (${DEBUG},1) |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 49 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 50 | else |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 51 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 52 | endif |
| 53 | ifeq (${V},0) |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 54 | Q := @ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 55 | else |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 56 | Q := |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 57 | endif |
| 58 | |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 59 | $(eval $(call add_define,USE_TBBR_DEFS)) |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 60 | HOSTCCFLAGS += ${DEFINES} |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 61 | |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 62 | # Make soft links and include from local directory otherwise wrong headers |
| 63 | # could get pulled in from firmware tree. |
Juan Castillo | f9f39c3 | 2015-06-01 16:34:23 +0100 | [diff] [blame] | 64 | INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include |
| 65 | LIB_DIR := -L ${OPENSSL_DIR}/lib |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 66 | LIB := -lssl -lcrypto |
| 67 | |
dp-arm | e95aaa6 | 2017-05-02 11:09:11 +0100 | [diff] [blame] | 68 | HOSTCC ?= gcc |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 69 | |
Evan Lloyd | c0f970d | 2015-12-02 18:22:22 +0000 | [diff] [blame] | 70 | .PHONY: all clean realclean |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 71 | |
| 72 | all: clean ${BINARY} |
| 73 | |
| 74 | ${BINARY}: ${OBJECTS} Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 75 | @echo " HOSTLD $@" |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 76 | @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \ |
Masahiro Yamada | a27c166 | 2017-05-22 12:11:24 +0900 | [diff] [blame] | 77 | const char platform_msg[] = "${PLAT_MSG}";' | \ |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 78 | ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o |
dp-arm | e95aaa6 | 2017-05-02 11:09:11 +0100 | [diff] [blame] | 79 | ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 80 | |
| 81 | %.o: %.c |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame^] | 82 | @echo " HOSTCC $<" |
| 83 | ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 84 | |
| 85 | clean: |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 86 | $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS}) |
Juan Castillo | 11abdcd | 2014-10-21 11:30:42 +0100 | [diff] [blame] | 87 | |
| 88 | realclean: clean |
Jonathan Wright | 69da5f2 | 2018-04-30 15:04:02 +0100 | [diff] [blame] | 89 | $(call SHELL_DELETE,${BINARY}) |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 90 | |