Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 1 | # |
Juan Pablo Conde | 7275a5a | 2022-03-02 18:10:08 -0500 | [diff] [blame] | 2 | # Copyright (c) 2019-2022, Linaro Limited. All rights reserved. |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 7 | V ?= 0 |
| 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 | |
| 14 | OBJECTS := src/encrypt.o \ |
| 15 | src/cmd_opt.o \ |
| 16 | src/main.o |
| 17 | |
| 18 | HOSTCCFLAGS := -Wall -std=c99 |
| 19 | |
| 20 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 21 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 22 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
| 23 | |
| 24 | ifeq (${DEBUG},1) |
| 25 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
| 26 | else |
| 27 | ifeq (${BUILD_INFO},1) |
| 28 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
| 29 | else |
| 30 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=10 |
| 31 | endif |
| 32 | endif |
| 33 | ifeq (${V},0) |
| 34 | Q := @ |
| 35 | else |
| 36 | Q := |
| 37 | endif |
| 38 | |
| 39 | # Make soft links and include from local directory otherwise wrong headers |
| 40 | # could get pulled in from firmware tree. |
| 41 | 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] | 42 | |
| 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/). |
| 49 | LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 50 | LIB := -lssl -lcrypto |
| 51 | |
| 52 | HOSTCC ?= gcc |
| 53 | |
| 54 | .PHONY: all clean realclean |
| 55 | |
Ross Burton | 7d7916d | 2021-01-13 12:47:25 +0000 | [diff] [blame] | 56 | all: ${BINARY} |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 57 | |
| 58 | ${BINARY}: ${OBJECTS} Makefile |
| 59 | @echo " HOSTLD $@" |
| 60 | @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__;' | \ |
| 61 | ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o |
| 62 | ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ |
| 63 | |
| 64 | %.o: %.c |
| 65 | @echo " HOSTCC $<" |
| 66 | ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ |
| 67 | |
| 68 | clean: |
| 69 | $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS}) |
| 70 | |
| 71 | realclean: clean |
| 72 | $(call SHELL_DELETE,${BINARY}) |