Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 1 | # |
Chris Kay | c327370 | 2025-01-13 15:57:32 +0000 | [diff] [blame] | 2 | # Copyright (c) 2024-2025, Arm Limited. All rights reserved. |
Juan Pablo Conde | 9bc52d3 | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 3 | # Copyright (c) 2019-2022, Linaro Limited. All rights reserved. |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 8 | BUILD_INFO ?= 1 |
| 9 | DEBUG := 0 |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 10 | OPENSSL_DIR := /usr |
| 11 | |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 12 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 13 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 14 | include ${MAKE_HELPERS_DIRECTORY}build-rules.mk |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 15 | include ${MAKE_HELPERS_DIRECTORY}common.mk |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 16 | include ${MAKE_HELPERS_DIRECTORY}defaults.mk |
Chris Kay | cc277de | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 17 | include ${MAKE_HELPERS_DIRECTORY}toolchain.mk |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 18 | |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 19 | ENCTOOL_SOURCES := src/encrypt.c \ |
| 20 | src/cmd_opt.c \ |
| 21 | src/main.c |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 22 | |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 23 | ENCTOOL_CFLAGS := -Wall -std=c99 |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 24 | |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 25 | # Select OpenSSL version flag according to the OpenSSL build selected |
| 26 | # from setting the OPENSSL_DIR path. |
| 27 | $(eval $(call SELECT_OPENSSL_API_VERSION)) |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 28 | |
| 29 | ifeq (${DEBUG},1) |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 30 | ENCTOOL_CFLAGS += -g -O0 |
| 31 | ENCTOOL_DEFINES += DEBUG LOG_LEVEL=40 |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 32 | else |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 33 | ENCTOOL_CFLAGS += -O2 |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 34 | ifeq (${BUILD_INFO},1) |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 35 | ENCTOOL_DEFINES += LOG_LEVEL=20 |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 36 | else |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 37 | ENCTOOL_DEFINES += LOG_LEVEL=10 |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 38 | endif |
| 39 | endif |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 40 | |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 41 | # USING_OPENSSL3 flag will be added to the proper computed value. |
| 42 | ENCTOOL_DEFINES += USING_OPENSSL3=$(USING_OPENSSL3) |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 43 | |
| 44 | |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 45 | # Make soft links and include from local directory otherwise wrong headers |
| 46 | # could get pulled in from firmware tree. |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 47 | ENCTOOL_INCLUDE_DIRS := ./include ../../include/tools_share ${OPENSSL_DIR}/include |
Juan Pablo Conde | 9bc52d3 | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 48 | |
| 49 | # Include library directories where OpenSSL library files are located. |
| 50 | # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or |
| 51 | # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ |
| 52 | # directory. However, for a local build of OpenSSL, the built binaries are |
| 53 | # located under the main project directory (i.e.: ${OPENSSL_DIR}, not |
| 54 | # ${OPENSSL_DIR}/lib/). |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 55 | ENCTOOL_LDFLAGS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} |
| 56 | ENCTOOL_LDFLAGS += -lssl -lcrypto |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 57 | |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 58 | .PHONY: all clean realclean --openssl |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 59 | |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 60 | all: --openssl |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 61 | |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 62 | $(eval $(call MAKE_TOOL,$(BUILD_PLAT)/tools,encrypt_fw,ENCTOOL)) |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 63 | |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 64 | --openssl: |
| 65 | ifeq ($(DEBUG),1) |
Chris Kay | 7c4e1ee | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 66 | $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}" |
Juan Pablo Conde | cf2dd17 | 2022-10-25 19:41:02 -0400 | [diff] [blame] | 67 | endif |
| 68 | |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 69 | clean: |
Boyan Karatotev | 96fbe88 | 2025-05-02 16:40:40 +0100 | [diff] [blame] | 70 | $(q)rm -rf $(BUILD_PLAT)/tools/encrypt_fw |
Sumit Garg | 90aa901 | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 71 | |
| 72 | realclean: clean |