Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 1 | # |
Manish V Badarkhe | 635482e | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 2 | # Copyright (c) 2019-2020, 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 | 635482e | 2020-08-13 05:56:33 +0100 | [diff] [blame] | 10 | BINARY := $(notdir ${ENCTOOL}) |
Sumit Garg | b6c4b3c | 2019-11-11 18:46:36 +0530 | [diff] [blame] | 11 | OPENSSL_DIR := /usr |
| 12 | |
| 13 | OBJECTS := src/encrypt.o \ |
| 14 | src/cmd_opt.o \ |
| 15 | src/main.o |
| 16 | |
| 17 | HOSTCCFLAGS := -Wall -std=c99 |
| 18 | |
| 19 | MAKE_HELPERS_DIRECTORY := ../../make_helpers/ |
| 20 | include ${MAKE_HELPERS_DIRECTORY}build_macros.mk |
| 21 | include ${MAKE_HELPERS_DIRECTORY}build_env.mk |
| 22 | |
| 23 | ifeq (${DEBUG},1) |
| 24 | HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 |
| 25 | else |
| 26 | ifeq (${BUILD_INFO},1) |
| 27 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 |
| 28 | else |
| 29 | HOSTCCFLAGS += -O2 -DLOG_LEVEL=10 |
| 30 | endif |
| 31 | endif |
| 32 | ifeq (${V},0) |
| 33 | Q := @ |
| 34 | else |
| 35 | Q := |
| 36 | endif |
| 37 | |
| 38 | # Make soft links and include from local directory otherwise wrong headers |
| 39 | # could get pulled in from firmware tree. |
| 40 | INC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include |
| 41 | LIB_DIR := -L ${OPENSSL_DIR}/lib |
| 42 | LIB := -lssl -lcrypto |
| 43 | |
| 44 | HOSTCC ?= gcc |
| 45 | |
| 46 | .PHONY: all clean realclean |
| 47 | |
| 48 | all: 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 | |
| 60 | clean: |
| 61 | $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS}) |
| 62 | |
| 63 | realclean: clean |
| 64 | $(call SHELL_DELETE,${BINARY}) |