blob: 418e06cf320bb41f4fba57a72eb95404791cc564 [file] [log] [blame]
Juan Castillo6f971622014-10-21 11:30:42 +01001#
Sandrine Bailleux3b24b662020-01-14 18:06:38 +01002# Copyright (c) 2015-2020, 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
Juan Castillo6f971622014-10-21 11:30:42 +01007PLAT := none
dp-arma9673902017-05-02 11:14:29 +01008V ?= 0
Juan Castillo6f971622014-10-21 11:30:42 +01009DEBUG := 0
Manish V Badarkhefafd3ec2020-08-13 05:56:33 +010010BINARY := $(notdir ${CRTTOOL})
Juan Castilloccbf8902015-06-01 16:34:23 +010011OPENSSL_DIR := /usr
Sandrine Bailleux43743ea2020-01-15 10:11:07 +010012COT := tbbr
Juan Castillo6f971622014-10-21 11:30:42 +010013
Evan Lloyd231c1472015-12-02 18:17:37 +000014MAKE_HELPERS_DIRECTORY := ../../make_helpers/
15include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyde7f54db2015-12-02 18:56:06 +000016include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloyd231c1472015-12-02 18:17:37 +000017
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010018# Common source files.
19OBJECTS := src/cert.o \
20 src/cmd_opt.o \
21 src/ext.o \
22 src/key.o \
23 src/main.o \
24 src/sha.o
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090025
Sandrine Bailleux43743ea2020-01-15 10:11:07 +010026# Chain of trust.
27ifeq (${COT},tbbr)
28 include src/tbbr/tbbr.mk
Sandrine Bailleuxa9d5c272020-01-10 14:32:30 +010029else ifeq (${COT},dualroot)
30 include src/dualroot/cot.mk
Sandrine Bailleux43743ea2020-01-15 10:11:07 +010031else
32 $(error Unknown chain of trust ${COT})
33endif
Evan Lloyd231c1472015-12-02 18:17:37 +000034
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010035HOSTCCFLAGS := -Wall -std=c99
Juan Castillo6f971622014-10-21 11:30:42 +010036
37ifeq (${DEBUG},1)
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010038 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
Juan Castillo6f971622014-10-21 11:30:42 +010039else
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010040 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
Juan Castillo6f971622014-10-21 11:30:42 +010041endif
Sandrine Bailleux3b24b662020-01-14 18:06:38 +010042
Juan Castillo6f971622014-10-21 11:30:42 +010043ifeq (${V},0)
dp-arma9673902017-05-02 11:14:29 +010044 Q := @
Juan Castillo6f971622014-10-21 11:30:42 +010045else
dp-arma9673902017-05-02 11:14:29 +010046 Q :=
Juan Castillo6f971622014-10-21 11:30:42 +010047endif
48
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010049HOSTCCFLAGS += ${DEFINES}
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090050
Juan Castillo6f971622014-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 Castilloccbf8902015-06-01 16:34:23 +010053INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
54LIB_DIR := -L ${OPENSSL_DIR}/lib
Juan Castillo6f971622014-10-21 11:30:42 +010055LIB := -lssl -lcrypto
56
dp-arm72610c42017-05-02 11:09:11 +010057HOSTCC ?= gcc
Juan Castillo6f971622014-10-21 11:30:42 +010058
Evan Lloydaeb25662015-12-02 18:22:22 +000059.PHONY: all clean realclean
Juan Castillo6f971622014-10-21 11:30:42 +010060
61all: clean ${BINARY}
62
63${BINARY}: ${OBJECTS} Makefile
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010064 @echo " HOSTLD $@"
Juan Castillo6f971622014-10-21 11:30:42 +010065 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
Masahiro Yamadabb41eb72017-05-22 12:11:24 +090066 const char platform_msg[] = "${PLAT_MSG}";' | \
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010067 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
dp-arm72610c42017-05-02 11:09:11 +010068 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010069
70%.o: %.c
Antonio Nino Diaz750e8d82018-10-04 14:35:38 +010071 @echo " HOSTCC $<"
72 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Juan Castillo6f971622014-10-21 11:30:42 +010073
74clean:
Evan Lloydf1477d42015-12-02 18:33:55 +000075 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
Juan Castillo6f971622014-10-21 11:30:42 +010076
77realclean: clean
Jonathan Wright2f36e852018-04-30 15:04:02 +010078 $(call SHELL_DELETE,${BINARY})
Evan Lloydf1477d42015-12-02 18:33:55 +000079