1819281eeSdp-arm# 2c3273703SChris Kay# Copyright (c) 2014-2025, Arm Limited and Contributors. All rights reserved. 3819281eeSdp-arm# 482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause 5819281eeSdp-arm# 6819281eeSdp-arm 7819281eeSdp-armMAKE_HELPERS_DIRECTORY := ../../make_helpers/ 8819281eeSdp-arminclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk 9*cbd6cec3SBoyan Karatotevinclude ${MAKE_HELPERS_DIRECTORY}build-rules.mk 107c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk 11cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}defaults.mk 12cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk 13819281eeSdp-arm 14*cbd6cec3SBoyan KaratotevFIPTOOL_SOURCES := fiptool.c tbbr_config.c 154d4fec28SOlivier DeprezSTATIC ?= 0 16819281eeSdp-arm 17*cbd6cec3SBoyan KaratotevFIPTOOL_DEFINES += _GNU_SOURCE _XOPEN_SOURCE=700 18*cbd6cec3SBoyan KaratotevFIPTOOL_CFLAGS := -Wall -Werror -pedantic -std=c99 19819281eeSdp-armifeq (${DEBUG},1) 20*cbd6cec3SBoyan Karatotev FIPTOOL_CFLAGS += -g -O0 -DDEBUG 21819281eeSdp-armelse 22*cbd6cec3SBoyan Karatotev FIPTOOL_CFLAGS += -O2 23819281eeSdp-armendif 249bc52d33SJuan Pablo Conde 25*cbd6cec3SBoyan KaratotevFIPTOOL_INCLUDE_DIRS := ../../include/tools_share 264d4fec28SOlivier Deprez 27*cbd6cec3SBoyan KaratotevFIPTOOL_DEFINES += STATIC=$(STATIC) 284d4fec28SOlivier Deprez 294d4fec28SOlivier Deprezifeq (${STATIC},1) 30*cbd6cec3SBoyan KaratotevFIPTOOL_LDFLAGS := -static 314d4fec28SOlivier Deprezelse 324d4fec28SOlivier DeprezOPENSSL_DIR := /usr 334d4fec28SOlivier Deprez 34cf2dd17dSJuan Pablo Conde# Select OpenSSL version flag according to the OpenSSL build selected 35cf2dd17dSJuan Pablo Conde# from setting the OPENSSL_DIR path. 36cf2dd17dSJuan Pablo Conde$(eval $(call SELECT_OPENSSL_API_VERSION)) 37cf2dd17dSJuan Pablo Conde 38cf2dd17dSJuan Pablo Conde# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper 39cf2dd17dSJuan Pablo Conde# computed value. 40*cbd6cec3SBoyan KaratotevFIPTOOL_DEFINES += USING_OPENSSL3=$(USING_OPENSSL3) 41cf2dd17dSJuan Pablo Conde 429bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located. 439bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or 449bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ 459bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are 469bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not 479bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/). 48*cbd6cec3SBoyan KaratotevFIPTOOL_LDFLAGS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto 49*cbd6cec3SBoyan KaratotevFIPTOOL_INCLUDE_DIRS += ${OPENSSL_DIR}/include 504d4fec28SOlivier Deprezendif # STATIC 514d4fec28SOlivier Deprez 523527d6d2SPankaj Guptaifneq (${PLAT},) 533527d6d2SPankaj GuptaTF_PLATFORM_ROOT := ../../plat/ 543527d6d2SPankaj Guptainclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 55034a2e3eSRaef ColesCOMBINED_PATH_FRAG := plat_fiptool/ 56034a2e3eSRaef ColesPLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\ 57034a2e3eSRaef Coles $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\ 58034a2e3eSRaef Coles $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk)) 593527d6d2SPankaj Guptaendif 603527d6d2SPankaj Gupta 61034a2e3eSRaef Colesifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK}))) 623527d6d2SPankaj Guptainclude ${PLAT_FIPTOOL_HELPER_MK} 633527d6d2SPankaj Guptaendif 643527d6d2SPankaj Gupta 65*cbd6cec3SBoyan Karatotev$(eval $(call MAKE_TOOL,$(BUILD_PLAT)/tools,fiptool,FIPTOOL)) 660165ddd7SMikael Olsson 67cf2dd17dSJuan Pablo Conde.PHONY: all clean distclean --openssl 68819281eeSdp-arm 69*cbd6cec3SBoyan Karatotevall: --openssl 70819281eeSdp-arm 71cf2dd17dSJuan Pablo Conde--openssl: 724d4fec28SOlivier Deprezifeq ($(STATIC),0) 73cf2dd17dSJuan Pablo Condeifeq ($(DEBUG),1) 747c4e1eeaSChris Kay $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" 75cf2dd17dSJuan Pablo Condeendif 764d4fec28SOlivier Deprezendif # STATIC 77cf2dd17dSJuan Pablo Conde 78819281eeSdp-armclean: 79*cbd6cec3SBoyan Karatotev $(q)rm -rf $(BUILD_PLAT)/tools/fiptool 80