blob: 96dff232486e85be3c2f6d0a523479b6e6fd093c [file] [log] [blame]
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05301#
Manish V Badarkhe635482e2020-08-13 05:56:33 +01002# Copyright (c) 2019-2020, Linaro Limited. All rights reserved.
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05303#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
Sumit Gargb6c4b3c2019-11-11 18:46:36 +05307V ?= 0
8BUILD_INFO ?= 1
9DEBUG := 0
Manish V Badarkheb9adb522020-09-05 04:40:41 +010010ENCTOOL ?= encrypt_fw${BIN_EXT}
Manish V Badarkhe635482e2020-08-13 05:56:33 +010011BINARY := $(notdir ${ENCTOOL})
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053012OPENSSL_DIR := /usr
13
14OBJECTS := src/encrypt.o \
15 src/cmd_opt.o \
16 src/main.o
17
18HOSTCCFLAGS := -Wall -std=c99
19
20MAKE_HELPERS_DIRECTORY := ../../make_helpers/
21include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
22include ${MAKE_HELPERS_DIRECTORY}build_env.mk
23
24ifeq (${DEBUG},1)
25 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
26else
27ifeq (${BUILD_INFO},1)
28 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
29else
30 HOSTCCFLAGS += -O2 -DLOG_LEVEL=10
31endif
32endif
33ifeq (${V},0)
34 Q := @
35else
36 Q :=
37endif
38
39# Make soft links and include from local directory otherwise wrong headers
40# could get pulled in from firmware tree.
41INC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include
42LIB_DIR := -L ${OPENSSL_DIR}/lib
43LIB := -lssl -lcrypto
44
45HOSTCC ?= gcc
46
47.PHONY: all clean realclean
48
Ross Burton7d7916d2021-01-13 12:47:25 +000049all: ${BINARY}
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053050
51${BINARY}: ${OBJECTS} Makefile
52 @echo " HOSTLD $@"
53 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__;' | \
54 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
55 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
56
57%.o: %.c
58 @echo " HOSTCC $<"
59 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
60
61clean:
62 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
63
64realclean: clean
65 $(call SHELL_DELETE,${BINARY})