Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 1 | # |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 2 | # Copyright (c) 2014-2024, Arm Limited and Contributors. All rights reserved. |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 5 | # |
| 6 | |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 7 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 8 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 9 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 10 | include ${MAKE_HELPERS_DIRECTORY}common.mk |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 11 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 12 | include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 13 | |
Manish V Badarkhe | b9adb52 | 2020-09-05 04:40:41 +0100 | [diff] [blame] | 14 | FIPTOOL ?= fiptool${BIN_EXT} |
Manish V Badarkhe | 635482e | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 15 | PROJECT := $(notdir ${FIPTOOL}) |
dp-arm | 4972ec5 | 2016-05-25 16:20:20 +0100 | [diff] [blame] | 16 | OBJECTS := fiptool.o tbbr_config.o |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 17 | STATIC ?= 0 |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 18 | |
dp-arm | 4972ec5 | 2016-05-25 16:20:20 +0100 | [diff] [blame] | 19 | override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700 |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 20 | HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99 |
Jeenu Viswambharan | 2f2cef4 | 2014-02-19 09:38:18 +0000 | [diff] [blame] | 21 | ifeq (${DEBUG},1) |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 22 | HOSTCCFLAGS += -g -O0 -DDEBUG |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 23 | else |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 24 | HOSTCCFLAGS += -O2 |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 25 | endif |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 26 | |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 27 | INCLUDE_PATHS := -I../../include/tools_share |
| 28 | |
| 29 | DEFINES += -DSTATIC=$(STATIC) |
| 30 | |
| 31 | ifeq (${STATIC},1) |
| 32 | LDOPTS := -static |
| 33 | else |
| 34 | OPENSSL_DIR := /usr |
| 35 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 36 | # Select OpenSSL version flag according to the OpenSSL build selected |
| 37 | # from setting the OPENSSL_DIR path. |
| 38 | $(eval $(call SELECT_OPENSSL_API_VERSION)) |
| 39 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 40 | # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 41 | # computed value. |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 42 | DEFINES += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 43 | |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 44 | # Include library directories where OpenSSL library files are located. |
| 45 | # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 46 | # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 47 | # directory. However, for a local build of OpenSSL, the built binaries are |
| 48 | # located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 49 | # ${OPENSSL_DIR}/lib/). |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 50 | LDOPTS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto |
| 51 | INCLUDE_PATHS += -I${OPENSSL_DIR}/include |
| 52 | endif # STATIC |
| 53 | |
| 54 | HOSTCCFLAGS += ${DEFINES} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 55 | |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 56 | ifneq (${PLAT},) |
| 57 | TF_PLATFORM_ROOT := ../../plat/ |
| 58 | include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
Raef Coles | f511dca | 2023-02-01 15:55:08 +0000 | [diff] [blame] | 59 | COMBINED_PATH_FRAG := plat_fiptool/ |
| 60 | PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\ |
| 61 | $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\ |
| 62 | $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk)) |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 63 | endif |
| 64 | |
Raef Coles | f511dca | 2023-02-01 15:55:08 +0000 | [diff] [blame] | 65 | ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK}))) |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 66 | include ${PLAT_FIPTOOL_HELPER_MK} |
| 67 | endif |
| 68 | |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 69 | DEPS := $(patsubst %.o,%.d,$(OBJECTS)) |
| 70 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 71 | .PHONY: all clean distclean --openssl |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 72 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 73 | all: --openssl ${PROJECT} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 74 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 75 | ${PROJECT}: ${OBJECTS} Makefile |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 76 | $(s)echo " HOSTLD $@" |
| 77 | $(q)$(host-cc) ${OBJECTS} -o $@ $(LDOPTS) |
| 78 | $(s)echo |
| 79 | $(s)echo "Built $@ successfully" |
| 80 | $(s)echo |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 81 | |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 82 | %.o: %.c Makefile |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 83 | $(s)echo " HOSTCC $<" |
| 84 | $(q)$(host-cc) -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@ |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 85 | |
| 86 | -include $(DEPS) |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 87 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 88 | --openssl: |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 89 | ifeq ($(STATIC),0) |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 90 | ifeq ($(DEBUG),1) |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 91 | $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 92 | endif |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 93 | endif # STATIC |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 94 | |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 95 | clean: |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 96 | $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS)) |