Debian Codegraph @

tools/encrypt_fw/Makefile

raw
1 #
2 # Copyright (c) 2024, Arm Limited. All rights reserved.
3 # Copyright (c) 2019-2022, Linaro Limited. All rights reserved.
4 #
5 # SPDX-License-Identifier: BSD-3-Clause
6 #
7
8 BUILD_INFO ?= 1
9 DEBUG := 0
10 ENCTOOL ?= encrypt_fw${BIN_EXT}
11 BINARY := $(notdir ${ENCTOOL})
12 OPENSSL_DIR := /usr
13
14 MAKE_HELPERS_DIRECTORY := ../../make_helpers/
15 include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
16 include ${MAKE_HELPERS_DIRECTORY}build_env.mk
17 include ${MAKE_HELPERS_DIRECTORY}common.mk
18 include ${MAKE_HELPERS_DIRECTORY}defaults.mk
19 include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
20
21 OBJECTS := src/encrypt.o \
22 src/cmd_opt.o \
23 src/main.o
24
25 HOSTCCFLAGS := -Wall -std=c99
26
27 # Select OpenSSL version flag according to the OpenSSL build selected
28 # from setting the OPENSSL_DIR path.
29 $(eval $(call SELECT_OPENSSL_API_VERSION))
30
31 ifeq (${DEBUG},1)
32 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
33 else
34 ifeq (${BUILD_INFO},1)
35 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
36 else
37 HOSTCCFLAGS += -O2 -DLOG_LEVEL=10
38 endif
39 endif
40
41 HOSTCCFLAGS += ${DEFINES}
42 # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
43 # computed value.
44 HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
45
46
47 # Make soft links and include from local directory otherwise wrong headers
48 # could get pulled in from firmware tree.
49 INC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include
50
51 # Include library directories where OpenSSL library files are located.
52 # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
53 # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
54 # directory. However, for a local build of OpenSSL, the built binaries are
55 # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
56 # ${OPENSSL_DIR}/lib/).
57 LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
58 LIB := -lssl -lcrypto
59
60 .PHONY: all clean realclean --openssl
61
62 all: --openssl ${BINARY}
63
64 ${BINARY}: ${OBJECTS} Makefile
65 $(s)echo " HOSTLD $@"
66 $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
67
68 %.o: %.c
69 $(s)echo " HOSTCC $<"
70 $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
71
72 --openssl:
73 ifeq ($(DEBUG),1)
74 $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
75 endif
76
77 clean:
78 $(call SHELL_DELETE_ALL,${OBJECTS})
79
80 realclean: clean
81 $(call SHELL_DELETE,${BINARY})