1819281eeSdp-arm# 20165ddd7SMikael Olsson# Copyright (c) 2014-2023, 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 9819281eeSdp-arminclude ${MAKE_HELPERS_DIRECTORY}build_env.mk 10cf2dd17dSJuan Pablo Condeinclude ${MAKE_HELPERS_DIRECTORY}defaults.mk 11819281eeSdp-arm 12b13e3f9fSManish V BadarkheFIPTOOL ?= fiptool${BIN_EXT} 13fafd3ec9SManish V BadarkhePROJECT := $(notdir ${FIPTOOL}) 14819281eeSdp-armOBJECTS := fiptool.o tbbr_config.o 15a9673900Sdp-armV ?= 0 16*4d4fec28SOlivier DeprezSTATIC ?= 0 17819281eeSdp-arm 18819281eeSdp-armoverride CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700 19750e8d80SAntonio Nino DiazHOSTCCFLAGS := -Wall -Werror -pedantic -std=c99 20819281eeSdp-armifeq (${DEBUG},1) 21750e8d80SAntonio Nino Diaz HOSTCCFLAGS += -g -O0 -DDEBUG 22819281eeSdp-armelse 23750e8d80SAntonio Nino Diaz HOSTCCFLAGS += -O2 24819281eeSdp-armendif 259bc52d33SJuan Pablo Conde 26*4d4fec28SOlivier DeprezINCLUDE_PATHS := -I../../include/tools_share 27*4d4fec28SOlivier Deprez 28*4d4fec28SOlivier DeprezDEFINES += -DSTATIC=$(STATIC) 29*4d4fec28SOlivier Deprez 30*4d4fec28SOlivier Deprezifeq (${STATIC},1) 31*4d4fec28SOlivier DeprezLDOPTS := -static 32*4d4fec28SOlivier Deprezelse 33*4d4fec28SOlivier DeprezOPENSSL_DIR := /usr 34*4d4fec28SOlivier Deprez 35cf2dd17dSJuan Pablo Conde# Select OpenSSL version flag according to the OpenSSL build selected 36cf2dd17dSJuan Pablo Conde# from setting the OPENSSL_DIR path. 37cf2dd17dSJuan Pablo Conde$(eval $(call SELECT_OPENSSL_API_VERSION)) 38cf2dd17dSJuan Pablo Conde 39cf2dd17dSJuan Pablo Conde# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper 40cf2dd17dSJuan Pablo Conde# computed value. 41*4d4fec28SOlivier DeprezDEFINES += -DUSING_OPENSSL3=$(USING_OPENSSL3) 42cf2dd17dSJuan Pablo Conde 439bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located. 449bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or 459bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ 469bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are 479bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not 489bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/). 49*4d4fec28SOlivier DeprezLDOPTS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto 50*4d4fec28SOlivier DeprezINCLUDE_PATHS += -I${OPENSSL_DIR}/include 51*4d4fec28SOlivier Deprezendif # STATIC 52*4d4fec28SOlivier Deprez 53*4d4fec28SOlivier DeprezHOSTCCFLAGS += ${DEFINES} 54819281eeSdp-arm 55819281eeSdp-armifeq (${V},0) 56819281eeSdp-arm Q := @ 57819281eeSdp-armelse 58819281eeSdp-arm Q := 59819281eeSdp-armendif 60819281eeSdp-arm 6172610c41Sdp-armHOSTCC ?= gcc 62819281eeSdp-arm 633527d6d2SPankaj Guptaifneq (${PLAT},) 643527d6d2SPankaj GuptaTF_PLATFORM_ROOT := ../../plat/ 653527d6d2SPankaj Guptainclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 66034a2e3eSRaef ColesCOMBINED_PATH_FRAG := plat_fiptool/ 67034a2e3eSRaef ColesPLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\ 68034a2e3eSRaef Coles $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\ 69034a2e3eSRaef Coles $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk)) 703527d6d2SPankaj Guptaendif 713527d6d2SPankaj Gupta 72034a2e3eSRaef Colesifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK}))) 733527d6d2SPankaj Guptainclude ${PLAT_FIPTOOL_HELPER_MK} 743527d6d2SPankaj Guptaendif 753527d6d2SPankaj Gupta 760165ddd7SMikael OlssonDEPS := $(patsubst %.o,%.d,$(OBJECTS)) 770165ddd7SMikael Olsson 78cf2dd17dSJuan Pablo Conde.PHONY: all clean distclean --openssl 79819281eeSdp-arm 80aa57ce63SVincent Stehléall: --openssl ${PROJECT} 81819281eeSdp-arm 82aa57ce63SVincent Stehlé${PROJECT}: ${OBJECTS} Makefile 83750e8d80SAntonio Nino Diaz @echo " HOSTLD $@" 84*4d4fec28SOlivier Deprez ${Q}${HOSTCC} ${OBJECTS} -o $@ $(LDOPTS) 85819281eeSdp-arm @${ECHO_BLANK_LINE} 86819281eeSdp-arm @echo "Built $@ successfully" 87819281eeSdp-arm @${ECHO_BLANK_LINE} 88819281eeSdp-arm 893527d6d2SPankaj Gupta%.o: %.c Makefile 90750e8d80SAntonio Nino Diaz @echo " HOSTCC $<" 910165ddd7SMikael Olsson ${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@ 920165ddd7SMikael Olsson 930165ddd7SMikael Olsson-include $(DEPS) 94819281eeSdp-arm 95cf2dd17dSJuan Pablo Conde--openssl: 96*4d4fec28SOlivier Deprezifeq ($(STATIC),0) 97cf2dd17dSJuan Pablo Condeifeq ($(DEBUG),1) 98cf2dd17dSJuan Pablo Conde @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" 99cf2dd17dSJuan Pablo Condeendif 100*4d4fec28SOlivier Deprezendif # STATIC 101cf2dd17dSJuan Pablo Conde 102819281eeSdp-armclean: 1030165ddd7SMikael Olsson $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS)) 104