Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 1 | # |
Chris Kay | 0199544 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 2 | # Copyright (c) 2024, Arm Limited. All rights reserved. |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 3 | # Copyright (c) 2019-2022, Linaro Limited. All rights reserved. |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 8 | BUILD_INFO ?= 1 |
| 9 | DEBUG := 0 |
Manish V Badarkhe | b9adb52 | 2020-09-05 04:40:41 +0100 | [diff] [blame] | 10 | ENCTOOL ?= encrypt_fw${BIN_EXT} |
Manish V Badarkhe | 635482e | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 11 | BINARY := $(notdir ${ENCTOOL}) |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 12 | OPENSSL_DIR := /usr |
| 13 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 14 | toolchains := host |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 15 | |
| 16 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 17 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 18 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 19 | include ${MAKE_HELPERS_DIRECTORY}common.mk |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 20 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 21 | include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 22 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 23 | OBJECTS := src/encrypt.o \ |
| 24 | src/cmd_opt.o \ |
| 25 | src/main.o |
| 26 | |
| 27 | HOSTCCFLAGS := -Wall -std=c99 |
| 28 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 29 | # Select OpenSSL version flag according to the OpenSSL build selected |
| 30 | # from setting the OPENSSL_DIR path. |
| 31 | $(eval $(call SELECT_OPENSSL_API_VERSION)) |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 32 | |
| 33 | ifeq (${DEBUG},1) |
| 34 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
| 35 | else |
| 36 | ifeq (${BUILD_INFO},1) |
| 37 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
| 38 | else |
| 39 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=10 |
| 40 | endif |
| 41 | endif |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 42 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 43 | HOSTCCFLAGS += ${DEFINES} |
| 44 | # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 45 | # computed value. |
| 46 | HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
| 47 | |
| 48 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 49 | # Make soft links and include from local directory otherwise wrong headers |
| 50 | # could get pulled in from firmware tree. |
| 51 | INC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 52 | |
| 53 | # Include library directories where OpenSSL library files are located. |
| 54 | # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 55 | # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 56 | # directory. However, for a local build of OpenSSL, the built binaries are |
| 57 | # located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 58 | # ${OPENSSL_DIR}/lib/). |
| 59 | LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 60 | LIB := -lssl -lcrypto |
| 61 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 62 | .PHONY: all clean realclean --openssl |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 63 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 64 | all: --openssl ${BINARY} |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 65 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 66 | ${BINARY}: ${OBJECTS} Makefile |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 67 | $(s)echo " HOSTLD $@" |
Chris Kay | 0199544 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 68 | $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 69 | |
| 70 | %.o: %.c |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 71 | $(s)echo " HOSTCC $<" |
| 72 | $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 73 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 74 | --openssl: |
| 75 | ifeq ($(DEBUG),1) |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 76 | $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 77 | endif |
| 78 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 79 | clean: |
Chris Kay | 0199544 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 80 | $(call SHELL_DELETE_ALL,${OBJECTS}) |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 81 | |
| 82 | realclean: clean |
| 83 | $(call SHELL_DELETE,${BINARY}) |