blob: ebbc66a8ebabdfe4864c5c7ba650438d86314f90 [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 Badarkhe635482e2020-08-13 05:56:33 +010010BINARY := $(notdir ${ENCTOOL})
Sumit Gargb6c4b3c2019-11-11 18:46:36 +053011OPENSSL_DIR := /usr
12
13OBJECTS := src/encrypt.o \
14 src/cmd_opt.o \
15 src/main.o
16
17HOSTCCFLAGS := -Wall -std=c99
18
19MAKE_HELPERS_DIRECTORY := ../../make_helpers/
20include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
21include ${MAKE_HELPERS_DIRECTORY}build_env.mk
22
23ifeq (${DEBUG},1)
24 HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
25else
26ifeq (${BUILD_INFO},1)
27 HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
28else
29 HOSTCCFLAGS += -O2 -DLOG_LEVEL=10
30endif
31endif
32ifeq (${V},0)
33 Q := @
34else
35 Q :=
36endif
37
38# Make soft links and include from local directory otherwise wrong headers
39# could get pulled in from firmware tree.
40INC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include
41LIB_DIR := -L ${OPENSSL_DIR}/lib
42LIB := -lssl -lcrypto
43
44HOSTCC ?= gcc
45
46.PHONY: all clean realclean
47
48all: clean ${BINARY}
49
50${BINARY}: ${OBJECTS} Makefile
51 @echo " HOSTLD $@"
52 @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__;' | \
53 ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
54 ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
55
56%.o: %.c
57 @echo " HOSTCC $<"
58 ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
59
60clean:
61 $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
62
63realclean: clean
64 $(call SHELL_DELETE,${BINARY})