blob: 0210c36e7e77ada1c038c2a66e1d7171075d586b [file] [log] [blame]
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301#
Chris Kay01995442024-06-14 11:31:03 +00002# Copyright (c) 2024, Arm Limited. All rights reserved.
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -05003# Copyright (c) 2019-2022, Linaro Limited. All rights reserved.
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05304#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05308BUILD_INFO ?= 1
9DEBUG := 0
Manish V Badarkheb9adb522020-09-05 04:40:41 +010010ENCTOOL ?= encrypt_fw${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010011BINARY := $(notdir ${ENCTOOL})
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053012OPENSSL_DIR := /usr
13
Chris Kayc8a47ba2023-10-20 09:17:33 +000014toolchains := host
Juan Pablo Conde3539c742022-10-25 19:41:02 -040015
16MAKE_HELPERS_DIRECTORY := ../../make_helpers/
17include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
18include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kay1870c722024-05-02 17:52:37 +000019include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Pablo Conde3539c742022-10-25 19:41:02 -040020include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000021include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
Juan Pablo Conde3539c742022-10-25 19:41:02 -040022
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053023OBJECTS := src/encrypt.o \
24 src/cmd_opt.o \
25 src/main.o
26
27HOSTCCFLAGS := -Wall -std=c99
28
Juan Pablo Conde3539c742022-10-25 19:41:02 -040029# Select OpenSSL version flag according to the OpenSSL build selected
30# from setting the OPENSSL_DIR path.
31$(eval $(call SELECT_OPENSSL_API_VERSION))
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053032
33ifeq (${DEBUG},1)
34 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
35else
36ifeq (${BUILD_INFO},1)
37 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
38else
39 HOSTCCFLAGS += -O2 -DLOG_LEVEL=10
40endif
41endif
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053042
Juan Pablo Conde3539c742022-10-25 19:41:02 -040043HOSTCCFLAGS += ${DEFINES}
44# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
45# computed value.
46HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
47
48
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053049# Make soft links and include from local directory otherwise wrong headers
50# could get pulled in from firmware tree.
51INC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050052
53# Include library directories where OpenSSL library files are located.
54# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
55# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
56# directory. However, for a local build of OpenSSL, the built binaries are
57# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
58# ${OPENSSL_DIR}/lib/).
59LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053060LIB := -lssl -lcrypto
61
Juan Pablo Conde3539c742022-10-25 19:41:02 -040062.PHONY: all clean realclean --openssl
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053063
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020064all: --openssl ${BINARY}
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053065
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020066${BINARY}: ${OBJECTS} Makefile
Chris Kay1870c722024-05-02 17:52:37 +000067 $(s)echo " HOSTLD $@"
Chris Kay01995442024-06-14 11:31:03 +000068 $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053069
70%.o: %.c
Chris Kay1870c722024-05-02 17:52:37 +000071 $(s)echo " HOSTCC $<"
72 $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053073
Juan Pablo Conde3539c742022-10-25 19:41:02 -040074--openssl:
75ifeq ($(DEBUG),1)
Chris Kay1870c722024-05-02 17:52:37 +000076 $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
Juan Pablo Conde3539c742022-10-25 19:41:02 -040077endif
78
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053079clean:
Chris Kay01995442024-06-14 11:31:03 +000080 $(call SHELL_DELETE_ALL,${OBJECTS})
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053081
82realclean: clean
83 $(call SHELL_DELETE,${BINARY})