blob: 54dee87e187163cd26068179f9a88ed5b7ed7765 [file] [log] [blame]
Harry Liebelf58ad362014-01-10 18:00:33 +00001#
Chris Kayc8a47ba2023-10-20 09:17:33 +00002# Copyright (c) 2014-2024, Arm Limited and Contributors. All rights reserved.
Harry Liebelf58ad362014-01-10 18:00:33 +00003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Harry Liebelf58ad362014-01-10 18:00:33 +00005#
6
Evan Lloyd26c6cb42015-12-02 18:33:55 +00007MAKE_HELPERS_DIRECTORY := ../../make_helpers/
8include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +00009include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kay1870c722024-05-02 17:52:37 +000010include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Pablo Conde3539c742022-10-25 19:41:02 -040011include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000012include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
Evan Lloyd26c6cb42015-12-02 18:33:55 +000013
Manish V Badarkheb9adb522020-09-05 04:40:41 +010014FIPTOOL ?= fiptool${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010015PROJECT := $(notdir ${FIPTOOL})
dp-arm4972ec52016-05-25 16:20:20 +010016OBJECTS := fiptool.o tbbr_config.o
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020017STATIC ?= 0
Harry Liebelf58ad362014-01-10 18:00:33 +000018
dp-arm4972ec52016-05-25 16:20:20 +010019override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010020HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000021ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010022 HOSTCCFLAGS += -g -O0 -DDEBUG
Harry Liebelf58ad362014-01-10 18:00:33 +000023else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010024 HOSTCCFLAGS += -O2
Harry Liebelf58ad362014-01-10 18:00:33 +000025endif
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050026
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020027INCLUDE_PATHS := -I../../include/tools_share
28
29DEFINES += -DSTATIC=$(STATIC)
30
31ifeq (${STATIC},1)
32LDOPTS := -static
33else
34OPENSSL_DIR := /usr
35
Juan Pablo Conde3539c742022-10-25 19:41:02 -040036# Select OpenSSL version flag according to the OpenSSL build selected
37# from setting the OPENSSL_DIR path.
38$(eval $(call SELECT_OPENSSL_API_VERSION))
39
Juan Pablo Conde3539c742022-10-25 19:41:02 -040040# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
41# computed value.
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020042DEFINES += -DUSING_OPENSSL3=$(USING_OPENSSL3)
Juan Pablo Conde3539c742022-10-25 19:41:02 -040043
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050044# Include library directories where OpenSSL library files are located.
45# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
46# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
47# directory. However, for a local build of OpenSSL, the built binaries are
48# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
49# ${OPENSSL_DIR}/lib/).
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020050LDOPTS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
51INCLUDE_PATHS += -I${OPENSSL_DIR}/include
52endif # STATIC
53
54HOSTCCFLAGS += ${DEFINES}
Harry Liebelf58ad362014-01-10 18:00:33 +000055
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053056ifneq (${PLAT},)
57TF_PLATFORM_ROOT := ../../plat/
58include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
Raef Colesf511dca2023-02-01 15:55:08 +000059COMBINED_PATH_FRAG := plat_fiptool/
60PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
61 $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
62 $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053063endif
64
Raef Colesf511dca2023-02-01 15:55:08 +000065ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053066include ${PLAT_FIPTOOL_HELPER_MK}
67endif
68
Mikael Olsson1f6e2482022-12-08 17:07:06 +010069DEPS := $(patsubst %.o,%.d,$(OBJECTS))
70
Juan Pablo Conde3539c742022-10-25 19:41:02 -040071.PHONY: all clean distclean --openssl
Harry Liebelf58ad362014-01-10 18:00:33 +000072
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020073all: --openssl ${PROJECT}
Harry Liebelf58ad362014-01-10 18:00:33 +000074
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020075${PROJECT}: ${OBJECTS} Makefile
Chris Kay1870c722024-05-02 17:52:37 +000076 $(s)echo " HOSTLD $@"
77 $(q)$(host-cc) ${OBJECTS} -o $@ $(LDOPTS)
78 $(s)echo
79 $(s)echo "Built $@ successfully"
80 $(s)echo
Harry Liebelf58ad362014-01-10 18:00:33 +000081
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053082%.o: %.c Makefile
Chris Kay1870c722024-05-02 17:52:37 +000083 $(s)echo " HOSTCC $<"
84 $(q)$(host-cc) -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
Mikael Olsson1f6e2482022-12-08 17:07:06 +010085
86-include $(DEPS)
Harry Liebelf58ad362014-01-10 18:00:33 +000087
Juan Pablo Conde3539c742022-10-25 19:41:02 -040088--openssl:
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020089ifeq ($(STATIC),0)
Juan Pablo Conde3539c742022-10-25 19:41:02 -040090ifeq ($(DEBUG),1)
Chris Kay1870c722024-05-02 17:52:37 +000091 $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
Juan Pablo Conde3539c742022-10-25 19:41:02 -040092endif
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020093endif # STATIC
Juan Pablo Conde3539c742022-10-25 19:41:02 -040094
Harry Liebelf58ad362014-01-10 18:00:33 +000095clean:
Mikael Olsson1f6e2482022-12-08 17:07:06 +010096 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))