xref: /rk3399_ARM-atf/tools/encrypt_fw/Makefile (revision 69520877af7b3f6560d3781e2408a86c13434e8b)
190aa901fSSumit Garg#
2c3273703SChris Kay# Copyright (c) 2024-2025, Arm Limited. All rights reserved.
39bc52d33SJuan Pablo Conde# Copyright (c) 2019-2022, Linaro Limited. All rights reserved.
490aa901fSSumit Garg#
590aa901fSSumit Garg# SPDX-License-Identifier: BSD-3-Clause
690aa901fSSumit Garg#
790aa901fSSumit Garg
890aa901fSSumit GargBUILD_INFO	?= 1
990aa901fSSumit GargDEBUG		:= 0
1090aa901fSSumit GargOPENSSL_DIR	:= /usr
1190aa901fSSumit Garg
12cf2dd17dSJuan Pablo CondeMAKE_HELPERS_DIRECTORY := ../../make_helpers/
13cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
14*96fbe884SBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}build-rules.mk
157c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk
16cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
17cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk
18cf2dd17dSJuan Pablo Conde
19*96fbe884SBoyan KaratotevENCTOOL_SOURCES :=	src/encrypt.c \
20*96fbe884SBoyan Karatotev			src/cmd_opt.c \
21*96fbe884SBoyan Karatotev			src/main.c
2290aa901fSSumit Garg
23*96fbe884SBoyan KaratotevENCTOOL_CFLAGS := -Wall -std=c99
2490aa901fSSumit Garg
25cf2dd17dSJuan Pablo Conde# Select OpenSSL version flag according to the OpenSSL build selected
26cf2dd17dSJuan Pablo Conde# from setting the OPENSSL_DIR path.
27cf2dd17dSJuan Pablo Conde$(eval $(call SELECT_OPENSSL_API_VERSION))
2890aa901fSSumit Garg
2990aa901fSSumit Gargifeq (${DEBUG},1)
30*96fbe884SBoyan Karatotev  ENCTOOL_CFLAGS += -g -O0
31*96fbe884SBoyan Karatotev  ENCTOOL_DEFINES += DEBUG LOG_LEVEL=40
3290aa901fSSumit Gargelse
33*96fbe884SBoyan Karatotev  ENCTOOL_CFLAGS += -O2
3490aa901fSSumit Gargifeq (${BUILD_INFO},1)
35*96fbe884SBoyan Karatotev  ENCTOOL_DEFINES += LOG_LEVEL=20
3690aa901fSSumit Gargelse
37*96fbe884SBoyan Karatotev  ENCTOOL_DEFINES += LOG_LEVEL=10
3890aa901fSSumit Gargendif
3990aa901fSSumit Gargendif
4090aa901fSSumit Garg
41*96fbe884SBoyan Karatotev# USING_OPENSSL3 flag will be added to the proper computed value.
42*96fbe884SBoyan KaratotevENCTOOL_DEFINES += USING_OPENSSL3=$(USING_OPENSSL3)
43cf2dd17dSJuan Pablo Conde
44cf2dd17dSJuan Pablo Conde
4590aa901fSSumit Garg# Make soft links and include from local directory otherwise wrong headers
4690aa901fSSumit Garg# could get pulled in from firmware tree.
47*96fbe884SBoyan KaratotevENCTOOL_INCLUDE_DIRS := ./include ../../include/tools_share ${OPENSSL_DIR}/include
489bc52d33SJuan Pablo Conde
499bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located.
509bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
519bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
529bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are
539bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
549bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/).
55*96fbe884SBoyan KaratotevENCTOOL_LDFLAGS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR}
56*96fbe884SBoyan KaratotevENCTOOL_LDFLAGS += -lssl -lcrypto
5790aa901fSSumit Garg
58cf2dd17dSJuan Pablo Conde.PHONY: all clean realclean --openssl
5990aa901fSSumit Garg
60*96fbe884SBoyan Karatotevall: --openssl
6190aa901fSSumit Garg
62*96fbe884SBoyan Karatotev$(eval $(call MAKE_TOOL,$(BUILD_PLAT)/tools,encrypt_fw,ENCTOOL))
6390aa901fSSumit Garg
64cf2dd17dSJuan Pablo Conde--openssl:
65cf2dd17dSJuan Pablo Condeifeq ($(DEBUG),1)
667c4e1eeaSChris Kay	$(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
67cf2dd17dSJuan Pablo Condeendif
68cf2dd17dSJuan Pablo Conde
6990aa901fSSumit Gargclean:
70*96fbe884SBoyan Karatotev	$(q)rm -rf $(BUILD_PLAT)/tools/encrypt_fw
7190aa901fSSumit Garg
7290aa901fSSumit Gargrealclean: clean
73