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 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 7 | toolchains := host |
| 8 | |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 9 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 10 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 11 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 12 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 13 | include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 14 | |
Manish V Badarkhe | b9adb52 | 2020-09-05 04:40:41 +0100 | [diff] [blame] | 15 | FIPTOOL ?= fiptool${BIN_EXT} |
Manish V Badarkhe | 635482e | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 16 | PROJECT := $(notdir ${FIPTOOL}) |
dp-arm | 4972ec5 | 2016-05-25 16:20:20 +0100 | [diff] [blame] | 17 | OBJECTS := fiptool.o tbbr_config.o |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 18 | V ?= 0 |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 19 | STATIC ?= 0 |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 20 | |
dp-arm | 4972ec5 | 2016-05-25 16:20:20 +0100 | [diff] [blame] | 21 | override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700 |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 22 | HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99 |
Jeenu Viswambharan | 2f2cef4 | 2014-02-19 09:38:18 +0000 | [diff] [blame] | 23 | ifeq (${DEBUG},1) |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 24 | HOSTCCFLAGS += -g -O0 -DDEBUG |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 25 | else |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 26 | HOSTCCFLAGS += -O2 |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 27 | endif |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 28 | |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 29 | INCLUDE_PATHS := -I../../include/tools_share |
| 30 | |
| 31 | DEFINES += -DSTATIC=$(STATIC) |
| 32 | |
| 33 | ifeq (${STATIC},1) |
| 34 | LDOPTS := -static |
| 35 | else |
| 36 | OPENSSL_DIR := /usr |
| 37 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 38 | # 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 Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 42 | # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 43 | # computed value. |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 44 | DEFINES += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 45 | |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 46 | # 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 Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 52 | LDOPTS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto |
| 53 | INCLUDE_PATHS += -I${OPENSSL_DIR}/include |
| 54 | endif # STATIC |
| 55 | |
| 56 | HOSTCCFLAGS += ${DEFINES} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 57 | |
dp-arm | 4972ec5 | 2016-05-25 16:20:20 +0100 | [diff] [blame] | 58 | ifeq (${V},0) |
| 59 | Q := @ |
| 60 | else |
| 61 | Q := |
| 62 | endif |
| 63 | |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 64 | ifneq (${PLAT},) |
| 65 | TF_PLATFORM_ROOT := ../../plat/ |
| 66 | include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
Raef Coles | f511dca | 2023-02-01 15:55:08 +0000 | [diff] [blame] | 67 | COMBINED_PATH_FRAG := plat_fiptool/ |
| 68 | PLAT_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 Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 71 | endif |
| 72 | |
Raef Coles | f511dca | 2023-02-01 15:55:08 +0000 | [diff] [blame] | 73 | ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK}))) |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 74 | include ${PLAT_FIPTOOL_HELPER_MK} |
| 75 | endif |
| 76 | |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 77 | DEPS := $(patsubst %.o,%.d,$(OBJECTS)) |
| 78 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 79 | .PHONY: all clean distclean --openssl |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 80 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 81 | all: --openssl ${PROJECT} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 82 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 83 | ${PROJECT}: ${OBJECTS} Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 84 | @echo " HOSTLD $@" |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 85 | ${Q}$(host-cc) ${OBJECTS} -o $@ $(LDOPTS) |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 86 | @${ECHO_BLANK_LINE} |
Sandrine Bailleux | 152c17f | 2014-10-27 17:10:46 +0000 | [diff] [blame] | 87 | @echo "Built $@ successfully" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 88 | @${ECHO_BLANK_LINE} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 89 | |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 90 | %.o: %.c Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 91 | @echo " HOSTCC $<" |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 92 | ${Q}$(host-cc) -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@ |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 93 | |
| 94 | -include $(DEPS) |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 95 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 96 | --openssl: |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 97 | ifeq ($(STATIC),0) |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 98 | ifeq ($(DEBUG),1) |
| 99 | @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
| 100 | endif |
Olivier Deprez | 9b9a5dc | 2023-08-31 11:46:54 +0200 | [diff] [blame] | 101 | endif # STATIC |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 102 | |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 103 | clean: |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 104 | $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS)) |