blob: 4bdebd9235ea2d73fedce16c0797893c6d80a6cd [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
Raef Colesf511dca2023-02-01 15:55:08 +000057COMBINED_PATH_FRAG := plat_fiptool/
58PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
59 $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
60 $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053061endif
62
Raef Colesf511dca2023-02-01 15:55:08 +000063ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053064include ${PLAT_FIPTOOL_HELPER_MK}
65endif
66
Mikael Olsson1f6e2482022-12-08 17:07:06 +010067DEPS := $(patsubst %.o,%.d,$(OBJECTS))
68
Juan Pablo Conde3539c742022-10-25 19:41:02 -040069.PHONY: all clean distclean --openssl
Harry Liebelf58ad362014-01-10 18:00:33 +000070
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020071all: --openssl ${PROJECT}
Harry Liebelf58ad362014-01-10 18:00:33 +000072
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020073${PROJECT}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010074 @echo " HOSTLD $@"
dp-arme95aaa62017-05-02 11:09:11 +010075 ${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS}
Evan Lloyd26c6cb42015-12-02 18:33:55 +000076 @${ECHO_BLANK_LINE}
Sandrine Bailleux152c17f2014-10-27 17:10:46 +000077 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000078 @${ECHO_BLANK_LINE}
Harry Liebelf58ad362014-01-10 18:00:33 +000079
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053080%.o: %.c Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010081 @echo " HOSTCC $<"
Mikael Olsson1f6e2482022-12-08 17:07:06 +010082 ${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
83
84-include $(DEPS)
Harry Liebelf58ad362014-01-10 18:00:33 +000085
Juan Pablo Conde3539c742022-10-25 19:41:02 -040086--openssl:
87ifeq ($(DEBUG),1)
88 @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
89endif
90
91
Harry Liebelf58ad362014-01-10 18:00:33 +000092clean:
Mikael Olsson1f6e2482022-12-08 17:07:06 +010093 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))