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