blob: fda7c7795f5a15d53f5ede3097c6e67a107acd3c [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
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020016STATIC ?= 0
Harry Liebelf58ad362014-01-10 18:00:33 +000017
dp-arm4972ec52016-05-25 16:20:20 +010018override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010019HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000020ifeq (${DEBUG},1)
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010021 HOSTCCFLAGS += -g -O0 -DDEBUG
Harry Liebelf58ad362014-01-10 18:00:33 +000022else
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010023 HOSTCCFLAGS += -O2
Harry Liebelf58ad362014-01-10 18:00:33 +000024endif
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050025
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020026INCLUDE_PATHS := -I../../include/tools_share
27
28DEFINES += -DSTATIC=$(STATIC)
29
30ifeq (${STATIC},1)
31LDOPTS := -static
32else
33OPENSSL_DIR := /usr
34
Juan Pablo Conde3539c742022-10-25 19:41:02 -040035# Select OpenSSL version flag according to the OpenSSL build selected
36# from setting the OPENSSL_DIR path.
37$(eval $(call SELECT_OPENSSL_API_VERSION))
38
Juan Pablo Conde3539c742022-10-25 19:41:02 -040039# USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
40# computed value.
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020041DEFINES += -DUSING_OPENSSL3=$(USING_OPENSSL3)
Juan Pablo Conde3539c742022-10-25 19:41:02 -040042
Juan Pablo Conde7275a5a2022-03-02 18:10:08 -050043# Include library directories where OpenSSL library files are located.
44# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
45# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
46# directory. However, for a local build of OpenSSL, the built binaries are
47# located under the main project directory (i.e.: ${OPENSSL_DIR}, not
48# ${OPENSSL_DIR}/lib/).
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020049LDOPTS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
50INCLUDE_PATHS += -I${OPENSSL_DIR}/include
51endif # STATIC
52
53HOSTCCFLAGS += ${DEFINES}
Harry Liebelf58ad362014-01-10 18:00:33 +000054
dp-arm4972ec52016-05-25 16:20:20 +010055ifeq (${V},0)
56 Q := @
57else
58 Q :=
59endif
60
dp-arme95aaa62017-05-02 11:09:11 +010061HOSTCC ?= gcc
Harry Liebelf58ad362014-01-10 18:00:33 +000062
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053063ifneq (${PLAT},)
64TF_PLATFORM_ROOT := ../../plat/
65include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
Raef Colesf511dca2023-02-01 15:55:08 +000066COMBINED_PATH_FRAG := plat_fiptool/
67PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
68 $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
69 $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053070endif
71
Raef Colesf511dca2023-02-01 15:55:08 +000072ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053073include ${PLAT_FIPTOOL_HELPER_MK}
74endif
75
Mikael Olsson1f6e2482022-12-08 17:07:06 +010076DEPS := $(patsubst %.o,%.d,$(OBJECTS))
77
Juan Pablo Conde3539c742022-10-25 19:41:02 -040078.PHONY: all clean distclean --openssl
Harry Liebelf58ad362014-01-10 18:00:33 +000079
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020080all: --openssl ${PROJECT}
Harry Liebelf58ad362014-01-10 18:00:33 +000081
Vincent Stehléb75a0dd2023-07-04 16:14:02 +020082${PROJECT}: ${OBJECTS} Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010083 @echo " HOSTLD $@"
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020084 ${Q}${HOSTCC} ${OBJECTS} -o $@ $(LDOPTS)
Evan Lloyd26c6cb42015-12-02 18:33:55 +000085 @${ECHO_BLANK_LINE}
Sandrine Bailleux152c17f2014-10-27 17:10:46 +000086 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000087 @${ECHO_BLANK_LINE}
Harry Liebelf58ad362014-01-10 18:00:33 +000088
Pankaj Guptae4aa1bd2020-12-09 14:02:38 +053089%.o: %.c Makefile
Antonio Nino Diaz1c4d3622018-10-04 14:35:38 +010090 @echo " HOSTCC $<"
Mikael Olsson1f6e2482022-12-08 17:07:06 +010091 ${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
92
93-include $(DEPS)
Harry Liebelf58ad362014-01-10 18:00:33 +000094
Juan Pablo Conde3539c742022-10-25 19:41:02 -040095--openssl:
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +020096ifeq ($(STATIC),0)
Juan Pablo Conde3539c742022-10-25 19:41:02 -040097ifeq ($(DEBUG),1)
98 @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
99endif
Olivier Deprez9b9a5dc2023-08-31 11:46:54 +0200100endif # STATIC
Juan Pablo Conde3539c742022-10-25 19:41:02 -0400101
Harry Liebelf58ad362014-01-10 18:00:33 +0000102clean:
Mikael Olsson1f6e2482022-12-08 17:07:06 +0100103 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))