xref: /rk3399_ARM-atf/tools/fiptool/Makefile (revision 69520877af7b3f6560d3781e2408a86c13434e8b)
1#
2# Copyright (c) 2014-2025, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7MAKE_HELPERS_DIRECTORY := ../../make_helpers/
8include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
9include ${MAKE_HELPERS_DIRECTORY}build-rules.mk
10include ${MAKE_HELPERS_DIRECTORY}common.mk
11include ${MAKE_HELPERS_DIRECTORY}defaults.mk
12include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
13
14FIPTOOL_SOURCES := fiptool.c tbbr_config.c
15STATIC ?= 0
16
17FIPTOOL_DEFINES += _GNU_SOURCE _XOPEN_SOURCE=700
18FIPTOOL_CFLAGS := -Wall -Werror -pedantic -std=c99
19ifeq (${DEBUG},1)
20  FIPTOOL_CFLAGS += -g -O0 -DDEBUG
21else
22  FIPTOOL_CFLAGS += -O2
23endif
24
25FIPTOOL_INCLUDE_DIRS := ../../include/tools_share
26
27FIPTOOL_DEFINES += STATIC=$(STATIC)
28
29ifeq (${STATIC},1)
30FIPTOOL_LDFLAGS := -static
31else
32OPENSSL_DIR := /usr
33
34# Select OpenSSL version flag according to the OpenSSL build selected
35# from setting the OPENSSL_DIR path.
36$(eval $(call SELECT_OPENSSL_API_VERSION))
37
38# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
39# computed value.
40FIPTOOL_DEFINES += USING_OPENSSL3=$(USING_OPENSSL3)
41
42# Include library directories where OpenSSL library files are located.
43# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
44# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
45# directory. However, for a local build of OpenSSL, the built binaries are
46# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
47# ${OPENSSL_DIR}/lib/).
48FIPTOOL_LDFLAGS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
49FIPTOOL_INCLUDE_DIRS += ${OPENSSL_DIR}/include
50endif # STATIC
51
52ifneq (${PLAT},)
53TF_PLATFORM_ROOT	:=	../../plat/
54include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
55COMBINED_PATH_FRAG := plat_fiptool/
56PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
57			  $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
58			  $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
59endif
60
61ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
62include ${PLAT_FIPTOOL_HELPER_MK}
63endif
64
65$(eval $(call MAKE_TOOL,$(BUILD_PLAT)/tools,fiptool,FIPTOOL))
66
67.PHONY: all clean distclean --openssl
68
69all: --openssl
70
71--openssl:
72ifeq ($(STATIC),0)
73ifeq ($(DEBUG),1)
74	$(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
75endif
76endif # STATIC
77
78clean:
79	$(q)rm -rf $(BUILD_PLAT)/tools/fiptool
80