Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 1 | # |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 2 | # Copyright (c) 2014-2023, 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 |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 10 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 11 | |
Manish V Badarkhe | b9adb52 | 2020-09-05 04:40:41 +0100 | [diff] [blame] | 12 | FIPTOOL ?= fiptool${BIN_EXT} |
Manish V Badarkhe | 635482e | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 13 | PROJECT := $(notdir ${FIPTOOL}) |
dp-arm | 4972ec5 | 2016-05-25 16:20:20 +0100 | [diff] [blame] | 14 | OBJECTS := fiptool.o tbbr_config.o |
dp-arm | 34c8201 | 2017-05-02 11:14:29 +0100 | [diff] [blame] | 15 | V ?= 0 |
Ross Burton | fdce8af | 2021-10-25 12:27:59 +0100 | [diff] [blame] | 16 | OPENSSL_DIR := /usr |
| 17 | |
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 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 27 | # 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 | |
| 31 | HOSTCCFLAGS += ${DEFINES} |
| 32 | # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 33 | # computed value. |
| 34 | HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
| 35 | |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 36 | # 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/). |
| 42 | LDLIBS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 43 | |
dp-arm | 4972ec5 | 2016-05-25 16:20:20 +0100 | [diff] [blame] | 44 | ifeq (${V},0) |
| 45 | Q := @ |
| 46 | else |
| 47 | Q := |
| 48 | endif |
| 49 | |
Ross Burton | fdce8af | 2021-10-25 12:27:59 +0100 | [diff] [blame] | 50 | INCLUDE_PATHS := -I../../include/tools_share -I${OPENSSL_DIR}/include |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 51 | |
dp-arm | e95aaa6 | 2017-05-02 11:09:11 +0100 | [diff] [blame] | 52 | HOSTCC ?= gcc |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 53 | |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 54 | ifneq (${PLAT},) |
| 55 | TF_PLATFORM_ROOT := ../../plat/ |
| 56 | include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk |
Raef Coles | f511dca | 2023-02-01 15:55:08 +0000 | [diff] [blame] | 57 | COMBINED_PATH_FRAG := plat_fiptool/ |
| 58 | PLAT_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 Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 61 | endif |
| 62 | |
Raef Coles | f511dca | 2023-02-01 15:55:08 +0000 | [diff] [blame] | 63 | ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK}))) |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 64 | include ${PLAT_FIPTOOL_HELPER_MK} |
| 65 | endif |
| 66 | |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 67 | DEPS := $(patsubst %.o,%.d,$(OBJECTS)) |
| 68 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 69 | .PHONY: all clean distclean --openssl |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 70 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 71 | all: --openssl ${PROJECT} |
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 | ${PROJECT}: ${OBJECTS} Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 74 | @echo " HOSTLD $@" |
dp-arm | e95aaa6 | 2017-05-02 11:09:11 +0100 | [diff] [blame] | 75 | ${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS} |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 76 | @${ECHO_BLANK_LINE} |
Sandrine Bailleux | 152c17f | 2014-10-27 17:10:46 +0000 | [diff] [blame] | 77 | @echo "Built $@ successfully" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 78 | @${ECHO_BLANK_LINE} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 79 | |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 80 | %.o: %.c Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 81 | @echo " HOSTCC $<" |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 82 | ${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@ |
| 83 | |
| 84 | -include $(DEPS) |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 85 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 86 | --openssl: |
| 87 | ifeq ($(DEBUG),1) |
| 88 | @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
| 89 | endif |
| 90 | |
| 91 | |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 92 | clean: |
Mikael Olsson | 1f6e248 | 2022-12-08 17:07:06 +0100 | [diff] [blame] | 93 | $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS)) |