blob: 865ff4c707f6b3614cbfc0907e6f45697f8d3eb7 [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
Juan Pablo Conde3539c742022-10-25 19:41:02 -040012include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000013include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
Evan Lloyd26c6cb42015-12-02 18:33:55 +000014
Manish V Badarkheb9adb522020-09-05 04:40:41 +010015FIPTOOL ?= fiptool${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010016PROJECT := $(notdir ${FIPTOOL})
dp-arm4972ec52016-05-25 16:20:20 +010017OBJECTS := fiptool.o tbbr_config.o
dp-arm34c82012017-05-02 11:14:29 +010018V ?= 0
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
dp-arm4972ec52016-05-25 16:20:20 +010058ifeq (${V},0)
59 Q := @
60else
61 Q :=
62endif
63
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053064ifneq (${PLAT},)
65TF_PLATFORM_ROOT := ../../plat/
66include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
Raef Colesf511dca2023-02-01 15:55:08 +000067COMBINED_PATH_FRAG := plat_fiptool/
68PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
69 $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
70 $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053071endif
72
Raef Colesf511dca2023-02-01 15:55:08 +000073ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053074include ${PLAT_FIPTOOL_HELPER_MK}
75endif
76
Mikael Olsson1f6e2482022-12-08 17:07:06 +010077DEPS := $(patsubst %.o,%.d,$(OBJECTS))
78
Juan Pablo Conde3539c742022-10-25 19:41:02 -040079.PHONY: all clean distclean --openssl
Harry Liebelf58ad362014-01-10 18:00:33 +000080
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020081all: --openssl ${PROJECT}
Harry Liebelf58ad362014-01-10 18:00:33 +000082
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020083${PROJECT}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010084 @echo " HOSTLD $@"
Chris Kay523e8642023-12-04 12:03:51 +000085 ${Q}$(host-cc) ${OBJECTS} -o $@ $(LDOPTS)
Evan Lloyd26c6cb42015-12-02 18:33:55 +000086 @${ECHO_BLANK_LINE}
Sandrine Bailleux152c17f2014-10-27 17:10:46 +000087 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000088 @${ECHO_BLANK_LINE}
Harry Liebelf58ad362014-01-10 18:00:33 +000089
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053090%.o: %.c Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010091 @echo " HOSTCC $<"
Chris Kay523e8642023-12-04 12:03:51 +000092 ${Q}$(host-cc) -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
Mikael Olsson1f6e2482022-12-08 17:07:06 +010093
94-include $(DEPS)
Harry Liebelf58ad362014-01-10 18:00:33 +000095
Juan Pablo Conde3539c742022-10-25 19:41:02 -040096--openssl:
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020097ifeq ($(STATIC),0)
Juan Pablo Conde3539c742022-10-25 19:41:02 -040098ifeq ($(DEBUG),1)
99 @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
100endif
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +0200101endif # STATIC
Juan Pablo Conde3539c742022-10-25 19:41:02 -0400102
Harry Liebelf58ad362014-01-10 18:00:33 +0000103clean:
Mikael Olsson1f6e2482022-12-08 17:07:06 +0100104 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))