blob: 418e06cf320bb41f4fba57a72eb95404791cc564 [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001#
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +01002# Copyright (c) 2015-2020, 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
Juan Castillo11abdcd2014-10-21 11:30:42 +01007PLAT := none
dp-arm34c82012017-05-02 11:14:29 +01008V ?= 0
Juan Castillo11abdcd2014-10-21 11:30:42 +01009DEBUG := 0
Manish V Badarkhe635482e2020-08-13 05:56:33 +010010BINARY := $(notdir ${CRTTOOL})
Juan Castillof9f39c32015-06-01 16:34:23 +010011OPENSSL_DIR := /usr
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010012COT := tbbr
Juan Castillo11abdcd2014-10-21 11:30:42 +010013
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010014MAKE_HELPERS_DIRECTORY := ../../make_helpers/
15include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
16include ${MAKE_HELPERS_DIRECTORY}build_env.mk
17
18# Common source files.
Juan Castillo11abdcd2014-10-21 11:30:42 +010019OBJECTS := src/cert.o \
Juan Castillo1218dd52015-07-03 16:23:16 +010020 src/cmd_opt.o \
Juan Castillo11abdcd2014-10-21 11:30:42 +010021 src/ext.o \
22 src/key.o \
23 src/main.o \
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010024 src/sha.o
Juan Castillo11abdcd2014-10-21 11:30:42 +010025
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010026# Chain of trust.
27ifeq (${COT},tbbr)
28 include src/tbbr/tbbr.mk
Sandrine Bailleux5d505082020-01-10 14:32:30 +010029else ifeq (${COT},dualroot)
30 include src/dualroot/cot.mk
Sandrine Bailleux2f7f1442020-01-15 10:11:07 +010031else
32 $(error Unknown chain of trust ${COT})
33endif
Juan Castillo11abdcd2014-10-21 11:30:42 +010034
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010035HOSTCCFLAGS := -Wall -std=c99
Juan Castillo11abdcd2014-10-21 11:30:42 +010036
37ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010038 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo11abdcd2014-10-21 11:30:42 +010039else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010040 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo11abdcd2014-10-21 11:30:42 +010041endif
Sandrine Bailleux3f9df3d2020-01-14 18:06:38 +010042
Juan Castillo11abdcd2014-10-21 11:30:42 +010043ifeq (${V},0)
dp-arm34c82012017-05-02 11:14:29 +010044 Q := @
Juan Castillo11abdcd2014-10-21 11:30:42 +010045else
dp-arm34c82012017-05-02 11:14:29 +010046 Q :=
Juan Castillo11abdcd2014-10-21 11:30:42 +010047endif
48
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010049HOSTCCFLAGS += ${DEFINES}
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090050
Juan Castillo11abdcd2014-10-21 11:30:42 +010051# Make soft links and include from local directory otherwise wrong headers
52# could get pulled in from firmware tree.
Juan Castillof9f39c32015-06-01 16:34:23 +010053INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
54LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo11abdcd2014-10-21 11:30:42 +010055LIB := -lssl -lcrypto
56
dp-arme95aaa62017-05-02 11:09:11 +010057HOSTCC ?= gcc
Juan Castillo11abdcd2014-10-21 11:30:42 +010058
Evan Lloydc0f970d2015-12-02 18:22:22 +000059.PHONY: all clean realclean
Juan Castillo11abdcd2014-10-21 11:30:42 +010060
61all: clean ${BINARY}
62
63${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010064 @echo " HOSTLD $@"
Juan Castillo11abdcd2014-10-21 11:30:42 +010065 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090066 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010067 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arme95aaa62017-05-02 11:09:11 +010068 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010069
70%.o: %.c
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010071 @echo " HOSTCC $<"
72 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo11abdcd2014-10-21 11:30:42 +010073
74clean:
Evan Lloyd26c6cb42015-12-02 18:33:55 +000075 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo11abdcd2014-10-21 11:30:42 +010076
77realclean: clean
Jonathan Wright69da5f22018-04-30 15:04:02 +010078 $(call SHELL_DELETE,${BINARY})
Evan Lloyd26c6cb42015-12-02 18:33:55 +000079