blob: 23c8e6489756669c764468c3d37d0391874ed3ac [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
Chris Kayc8a47ba2023-10-20 09:17:33 +00007toolchains := host
8
Evan Lloyd26c6cb42015-12-02 18:33:55 +00009MAKE_HELPERS_DIRECTORY := ../../make_helpers/
10include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000011include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Chris Kay1870c722024-05-02 17:52:37 +000012include ${MAKE_HELPERS_DIRECTORY}common.mk
Juan Pablo Conde3539c742022-10-25 19:41:02 -040013include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000014include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
Evan Lloyd26c6cb42015-12-02 18:33:55 +000015
Manish V Badarkheb9adb522020-09-05 04:40:41 +010016FIPTOOL ?= fiptool${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010017PROJECT := $(notdir ${FIPTOOL})
dp-arm4972ec52016-05-25 16:20:20 +010018OBJECTS := fiptool.o tbbr_config.o
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020019STATIC ?= 0
Harry Liebelf58ad362014-01-10 18:00:33 +000020
dp-arm4972ec52016-05-25 16:20:20 +010021override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010022HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000023ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010024 HOSTCCFLAGS += -g -O0 -DDEBUG
Harry Liebelf58ad362014-01-10 18:00:33 +000025else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010026 HOSTCCFLAGS += -O2
Harry Liebelf58ad362014-01-10 18:00:33 +000027endif
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050028
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020029INCLUDE_PATHS := -I../../include/tools_share
30
31DEFINES += -DSTATIC=$(STATIC)
32
33ifeq (${STATIC},1)
34LDOPTS := -static
35else
36OPENSSL_DIR := /usr
37
Juan Pablo Conde3539c742022-10-25 19:41:02 -040038# Select OpenSSL version flag according to the OpenSSL build selected
39# from setting the OPENSSL_DIR path.
40$(eval $(call SELECT_OPENSSL_API_VERSION))
41
Juan Pablo Conde3539c742022-10-25 19:41:02 -040042# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
43# computed value.
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020044DEFINES += -DUSING_OPENSSL3=$(USING_OPENSSL3)
Juan Pablo Conde3539c742022-10-25 19:41:02 -040045
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050046# Include library directories where OpenSSL library files are located.
47# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
48# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
49# directory. However, for a local build of OpenSSL, the built binaries are
50# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
51# ${OPENSSL_DIR}/lib/).
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020052LDOPTS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
53INCLUDE_PATHS += -I${OPENSSL_DIR}/include
54endif # STATIC
55
56HOSTCCFLAGS += ${DEFINES}
Harry Liebelf58ad362014-01-10 18:00:33 +000057
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053058ifneq (${PLAT},)
59TF_PLATFORM_ROOT := ../../plat/
60include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
Raef Colesf511dca2023-02-01 15:55:08 +000061COMBINED_PATH_FRAG := plat_fiptool/
62PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
63 $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
64 $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053065endif
66
Raef Colesf511dca2023-02-01 15:55:08 +000067ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053068include ${PLAT_FIPTOOL_HELPER_MK}
69endif
70
Mikael Olsson1f6e2482022-12-08 17:07:06 +010071DEPS := $(patsubst %.o,%.d,$(OBJECTS))
72
Juan Pablo Conde3539c742022-10-25 19:41:02 -040073.PHONY: all clean distclean --openssl
Harry Liebelf58ad362014-01-10 18:00:33 +000074
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020075all: --openssl ${PROJECT}
Harry Liebelf58ad362014-01-10 18:00:33 +000076
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020077${PROJECT}: ${OBJECTS} Makefile
Chris Kay1870c722024-05-02 17:52:37 +000078 $(s)echo " HOSTLD $@"
79 $(q)$(host-cc) ${OBJECTS} -o $@ $(LDOPTS)
80 $(s)echo
81 $(s)echo "Built $@ successfully"
82 $(s)echo
Harry Liebelf58ad362014-01-10 18:00:33 +000083
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053084%.o: %.c Makefile
Chris Kay1870c722024-05-02 17:52:37 +000085 $(s)echo " HOSTCC $<"
86 $(q)$(host-cc) -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
Mikael Olsson1f6e2482022-12-08 17:07:06 +010087
88-include $(DEPS)
Harry Liebelf58ad362014-01-10 18:00:33 +000089
Juan Pablo Conde3539c742022-10-25 19:41:02 -040090--openssl:
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020091ifeq ($(STATIC),0)
Juan Pablo Conde3539c742022-10-25 19:41:02 -040092ifeq ($(DEBUG),1)
Chris Kay1870c722024-05-02 17:52:37 +000093 $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
Juan Pablo Conde3539c742022-10-25 19:41:02 -040094endif
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020095endif # STATIC
Juan Pablo Conde3539c742022-10-25 19:41:02 -040096
Harry Liebelf58ad362014-01-10 18:00:33 +000097clean:
Mikael Olsson1f6e2482022-12-08 17:07:06 +010098 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))