blob: ac262cdffb9dd1ddfba86bacabfe8495f9d908df [file] [log] [blame]
Harry Liebelf58ad362014-01-10 18:00:33 +00001#
Mikael Olsson1f6e2482022-12-08 17:07:06 +01002# Copyright (c) 2014-2023, 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
Juan Pablo Conde3539c742022-10-25 19:41:02 -040010include ${MAKE_HELPERS_DIRECTORY}defaults.mk
Evan Lloyd26c6cb42015-12-02 18:33:55 +000011
Manish V Badarkheb9adb522020-09-05 04:40:41 +010012FIPTOOL ?= fiptool${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010013PROJECT := $(notdir ${FIPTOOL})
dp-arm4972ec52016-05-25 16:20:20 +010014OBJECTS := fiptool.o tbbr_config.o
dp-arm34c82012017-05-02 11:14:29 +010015V ?= 0
Ross Burtonfdce8af2021-10-25 12:27:59 +010016OPENSSL_DIR := /usr
17
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
Juan Pablo Conde3539c742022-10-25 19:41:02 -040027# Select OpenSSL version flag according to the OpenSSL build selected
28# from setting the OPENSSL_DIR path.
29$(eval $(call SELECT_OPENSSL_API_VERSION))
30
31HOSTCCFLAGS += ${DEFINES}
32# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
33# computed value.
34HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
35
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050036# Include library directories where OpenSSL library files are located.
37# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
38# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
39# directory. However, for a local build of OpenSSL, the built binaries are
40# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
41# ${OPENSSL_DIR}/lib/).
42LDLIBS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
Harry Liebelf58ad362014-01-10 18:00:33 +000043
dp-arm4972ec52016-05-25 16:20:20 +010044ifeq (${V},0)
45 Q := @
46else
47 Q :=
48endif
49
Ross Burtonfdce8af2021-10-25 12:27:59 +010050INCLUDE_PATHS := -I../../include/tools_share -I${OPENSSL_DIR}/include
Harry Liebelf58ad362014-01-10 18:00:33 +000051
dp-arme95aaa62017-05-02 11:09:11 +010052HOSTCC ?= gcc
Harry Liebelf58ad362014-01-10 18:00:33 +000053
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053054ifneq (${PLAT},)
55TF_PLATFORM_ROOT := ../../plat/
56include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
57PLAT_FIPTOOL_HELPER_MK := ${PLAT_DIR}/plat_fiptool.mk
58endif
59
60ifneq (,$(wildcard ${PLAT_FIPTOOL_HELPER_MK}))
61include ${PLAT_FIPTOOL_HELPER_MK}
62endif
63
Mikael Olsson1f6e2482022-12-08 17:07:06 +010064DEPS := $(patsubst %.o,%.d,$(OBJECTS))
65
Juan Pablo Conde3539c742022-10-25 19:41:02 -040066.PHONY: all clean distclean --openssl
Harry Liebelf58ad362014-01-10 18:00:33 +000067
Pali Rohár40f33f42021-03-25 16:08:09 +010068all: ${PROJECT}
Harry Liebelf58ad362014-01-10 18:00:33 +000069
Juan Pablo Conde3539c742022-10-25 19:41:02 -040070${PROJECT}: --openssl ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010071 @echo " HOSTLD $@"
dp-arme95aaa62017-05-02 11:09:11 +010072 ${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS}
Evan Lloyd26c6cb42015-12-02 18:33:55 +000073 @${ECHO_BLANK_LINE}
Sandrine Bailleux152c17f2014-10-27 17:10:46 +000074 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000075 @${ECHO_BLANK_LINE}
Harry Liebelf58ad362014-01-10 18:00:33 +000076
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053077%.o: %.c Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010078 @echo " HOSTCC $<"
Mikael Olsson1f6e2482022-12-08 17:07:06 +010079 ${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
80
81-include $(DEPS)
Harry Liebelf58ad362014-01-10 18:00:33 +000082
Juan Pablo Conde3539c742022-10-25 19:41:02 -040083--openssl:
84ifeq ($(DEBUG),1)
85 @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
86endif
87
88
Harry Liebelf58ad362014-01-10 18:00:33 +000089clean:
Mikael Olsson1f6e2482022-12-08 17:07:06 +010090 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))