xref: /rk3399_ARM-atf/tools/encrypt_fw/Makefile (revision c32737033cf2b0ae9649a08273c07b739d368818)
190aa901fSSumit Garg#
2*c3273703SChris 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
10*c3273703SChris KayENCTOOL		?= encrypt_fw$(.exe)
11fafd3ec9SManish V BadarkheBINARY		:= $(notdir ${ENCTOOL})
1290aa901fSSumit GargOPENSSL_DIR	:= /usr
1390aa901fSSumit Garg
14cf2dd17dSJuan Pablo CondeMAKE_HELPERS_DIRECTORY := ../../make_helpers/
15cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk
167c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk
17cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}defaults.mk
18cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk
19cf2dd17dSJuan Pablo Conde
2090aa901fSSumit GargOBJECTS := src/encrypt.o \
2190aa901fSSumit Garg           src/cmd_opt.o \
2290aa901fSSumit Garg           src/main.o
2390aa901fSSumit Garg
2490aa901fSSumit GargHOSTCCFLAGS := -Wall -std=c99
2590aa901fSSumit Garg
26cf2dd17dSJuan Pablo Conde# Select OpenSSL version flag according to the OpenSSL build selected
27cf2dd17dSJuan Pablo Conde# from setting the OPENSSL_DIR path.
28cf2dd17dSJuan Pablo Conde$(eval $(call SELECT_OPENSSL_API_VERSION))
2990aa901fSSumit Garg
3090aa901fSSumit Gargifeq (${DEBUG},1)
3190aa901fSSumit Garg  HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
3290aa901fSSumit Gargelse
3390aa901fSSumit Gargifeq (${BUILD_INFO},1)
3490aa901fSSumit Garg  HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
3590aa901fSSumit Gargelse
3690aa901fSSumit Garg  HOSTCCFLAGS += -O2 -DLOG_LEVEL=10
3790aa901fSSumit Gargendif
3890aa901fSSumit Gargendif
3990aa901fSSumit Garg
40cf2dd17dSJuan Pablo CondeHOSTCCFLAGS += ${DEFINES}
41cf2dd17dSJuan Pablo Conde# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
42cf2dd17dSJuan Pablo Conde# computed value.
43cf2dd17dSJuan Pablo CondeHOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
44cf2dd17dSJuan Pablo Conde
45cf2dd17dSJuan Pablo Conde
4690aa901fSSumit Garg# Make soft links and include from local directory otherwise wrong headers
4790aa901fSSumit Garg# could get pulled in from firmware tree.
4890aa901fSSumit GargINC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include
499bc52d33SJuan Pablo Conde
509bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located.
519bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
529bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
539bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are
549bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
559bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/).
569bc52d33SJuan Pablo CondeLIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
5790aa901fSSumit GargLIB := -lssl -lcrypto
5890aa901fSSumit Garg
59cf2dd17dSJuan Pablo Conde.PHONY: all clean realclean --openssl
6090aa901fSSumit Garg
61aa57ce63SVincent Stehléall: --openssl ${BINARY}
6290aa901fSSumit Garg
63aa57ce63SVincent Stehlé${BINARY}: ${OBJECTS} Makefile
647c4e1eeaSChris Kay	$(s)echo "  HOSTLD  $@"
65415049a2SChris Kay	$(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
6690aa901fSSumit Garg
6790aa901fSSumit Garg%.o: %.c
687c4e1eeaSChris Kay	$(s)echo "  HOSTCC  $<"
697c4e1eeaSChris Kay	$(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
7090aa901fSSumit Garg
71cf2dd17dSJuan Pablo Conde--openssl:
72cf2dd17dSJuan Pablo Condeifeq ($(DEBUG),1)
737c4e1eeaSChris Kay	$(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
74cf2dd17dSJuan Pablo Condeendif
75cf2dd17dSJuan Pablo Conde
7690aa901fSSumit Gargclean:
77*c3273703SChris Kay	$(q)rm -rf $(OBJECTS)
7890aa901fSSumit Garg
7990aa901fSSumit Gargrealclean: clean
80*c3273703SChris Kay	$(q)rm -f $(BINARY)
81