Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 1 | # |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 2 | # Copyright (c) 2014-2022, 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 |
| 57 | PLAT_FIPTOOL_HELPER_MK := ${PLAT_DIR}/plat_fiptool.mk |
| 58 | endif |
| 59 | |
| 60 | ifneq (,$(wildcard ${PLAT_FIPTOOL_HELPER_MK})) |
| 61 | include ${PLAT_FIPTOOL_HELPER_MK} |
| 62 | endif |
| 63 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 64 | .PHONY: all clean distclean --openssl |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 65 | |
Pali Rohár | 40f33f4 | 2021-03-25 16:08:09 +0100 | [diff] [blame] | 66 | all: ${PROJECT} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 67 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 68 | ${PROJECT}: --openssl ${OBJECTS} Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 69 | @echo " HOSTLD $@" |
dp-arm | e95aaa6 | 2017-05-02 11:09:11 +0100 | [diff] [blame] | 70 | ${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS} |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 71 | @${ECHO_BLANK_LINE} |
Sandrine Bailleux | 152c17f | 2014-10-27 17:10:46 +0000 | [diff] [blame] | 72 | @echo "Built $@ successfully" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 73 | @${ECHO_BLANK_LINE} |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 74 | |
Pankaj Gupta | e4aa1bd | 2020-12-09 14:02:38 +0530 | [diff] [blame] | 75 | %.o: %.c Makefile |
Antonio Nino Diaz | 1c4d362 | 2018-10-04 14:35:38 +0100 | [diff] [blame] | 76 | @echo " HOSTCC $<" |
| 77 | ${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} $< -o $@ |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 78 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 79 | --openssl: |
| 80 | ifeq ($(DEBUG),1) |
| 81 | @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
| 82 | endif |
| 83 | |
| 84 | |
Harry Liebel | f58ad36 | 2014-01-10 18:00:33 +0000 | [diff] [blame] | 85 | clean: |
dp-arm | 4d133d9 | 2016-12-30 14:33:24 +0000 | [diff] [blame] | 86 | $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS}) |