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 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 14 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 15 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 16 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 17 | include ${MAKE_HELPERS_DIRECTORY}common.mk |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 18 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 19 | include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 20 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 21 | OBJECTS := src/encrypt.o \ |
| 22 | src/cmd_opt.o \ |
| 23 | src/main.o |
| 24 | |
| 25 | HOSTCCFLAGS := -Wall -std=c99 |
| 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)) |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 30 | |
| 31 | ifeq (${DEBUG},1) |
| 32 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
| 33 | else |
| 34 | ifeq (${BUILD_INFO},1) |
| 35 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
| 36 | else |
| 37 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=10 |
| 38 | endif |
| 39 | endif |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 40 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 41 | HOSTCCFLAGS += ${DEFINES} |
| 42 | # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper |
| 43 | # computed value. |
| 44 | HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3) |
| 45 | |
| 46 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 47 | # Make soft links and include from local directory otherwise wrong headers |
| 48 | # could get pulled in from firmware tree. |
| 49 | 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] | 50 | |
| 51 | # Include library directories where OpenSSL library files are located. |
| 52 | # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 53 | # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 54 | # directory. However, for a local build of OpenSSL, the built binaries are |
| 55 | # located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 56 | # ${OPENSSL_DIR}/lib/). |
| 57 | LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 58 | LIB := -lssl -lcrypto |
| 59 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 60 | .PHONY: all clean realclean --openssl |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 61 | |
Vincent Stehlé | b75a0dd | 2023-07-04 16:14:02 +0200 | [diff] [blame] | 62 | all: --openssl ${BINARY} |
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 | ${BINARY}: ${OBJECTS} Makefile |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 65 | $(s)echo " HOSTLD $@" |
Chris Kay | 0199544 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 66 | $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 67 | |
| 68 | %.o: %.c |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 69 | $(s)echo " HOSTCC $<" |
| 70 | $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 71 | |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 72 | --openssl: |
| 73 | ifeq ($(DEBUG),1) |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 74 | $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
Juan Pablo Conde | 3539c74 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 75 | endif |
| 76 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 77 | clean: |
Chris Kay | 0199544 | 2024-06-14 11:31:03 +0000 | [diff] [blame] | 78 | $(call SHELL_DELETE_ALL,${OBJECTS}) |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 79 | |
| 80 | realclean: clean |
| 81 | $(call SHELL_DELETE,${BINARY}) |