190aa901fSSumit Garg# 2*9bc52d33SJuan Pablo Conde# Copyright (c) 2019-2022, Linaro Limited. All rights reserved. 390aa901fSSumit Garg# 490aa901fSSumit Garg# SPDX-License-Identifier: BSD-3-Clause 590aa901fSSumit Garg# 690aa901fSSumit Garg 790aa901fSSumit GargV ?= 0 890aa901fSSumit GargBUILD_INFO ?= 1 990aa901fSSumit GargDEBUG := 0 10b13e3f9fSManish V BadarkheENCTOOL ?= encrypt_fw${BIN_EXT} 11fafd3ec9SManish V BadarkheBINARY := $(notdir ${ENCTOOL}) 1290aa901fSSumit GargOPENSSL_DIR := /usr 1390aa901fSSumit Garg 1490aa901fSSumit GargOBJECTS := src/encrypt.o \ 1590aa901fSSumit Garg src/cmd_opt.o \ 1690aa901fSSumit Garg src/main.o 1790aa901fSSumit Garg 1890aa901fSSumit GargHOSTCCFLAGS := -Wall -std=c99 1990aa901fSSumit Garg 2090aa901fSSumit GargMAKE_HELPERS_DIRECTORY := ../../make_helpers/ 2190aa901fSSumit Garginclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk 2290aa901fSSumit Garginclude ${MAKE_HELPERS_DIRECTORY}build_env.mk 2390aa901fSSumit Garg 2490aa901fSSumit Gargifeq (${DEBUG},1) 2590aa901fSSumit Garg HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40 2690aa901fSSumit Gargelse 2790aa901fSSumit Gargifeq (${BUILD_INFO},1) 2890aa901fSSumit Garg HOSTCCFLAGS += -O2 -DLOG_LEVEL=20 2990aa901fSSumit Gargelse 3090aa901fSSumit Garg HOSTCCFLAGS += -O2 -DLOG_LEVEL=10 3190aa901fSSumit Gargendif 3290aa901fSSumit Gargendif 3390aa901fSSumit Gargifeq (${V},0) 3490aa901fSSumit Garg Q := @ 3590aa901fSSumit Gargelse 3690aa901fSSumit Garg Q := 3790aa901fSSumit Gargendif 3890aa901fSSumit Garg 3990aa901fSSumit Garg# Make soft links and include from local directory otherwise wrong headers 4090aa901fSSumit Garg# could get pulled in from firmware tree. 4190aa901fSSumit GargINC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include 42*9bc52d33SJuan Pablo Conde 43*9bc52d33SJuan Pablo Conde# Include library directories where OpenSSL library files are located. 44*9bc52d33SJuan Pablo Conde# For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or 45*9bc52d33SJuan Pablo Conde# /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/ 46*9bc52d33SJuan Pablo Conde# directory. However, for a local build of OpenSSL, the built binaries are 47*9bc52d33SJuan Pablo Conde# located under the main project directory (i.e.: ${OPENSSL_DIR}, not 48*9bc52d33SJuan Pablo Conde# ${OPENSSL_DIR}/lib/). 49*9bc52d33SJuan Pablo CondeLIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} 5090aa901fSSumit GargLIB := -lssl -lcrypto 5190aa901fSSumit Garg 5290aa901fSSumit GargHOSTCC ?= gcc 5390aa901fSSumit Garg 5490aa901fSSumit Garg.PHONY: all clean realclean 5590aa901fSSumit Garg 5669a91659SRoss Burtonall: ${BINARY} 5790aa901fSSumit Garg 5890aa901fSSumit Garg${BINARY}: ${OBJECTS} Makefile 5990aa901fSSumit Garg @echo " HOSTLD $@" 6090aa901fSSumit Garg @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__;' | \ 6190aa901fSSumit Garg ${HOSTCC} -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o 6290aa901fSSumit Garg ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@ 6390aa901fSSumit Garg 6490aa901fSSumit Garg%.o: %.c 6590aa901fSSumit Garg @echo " HOSTCC $<" 6690aa901fSSumit Garg ${Q}${HOSTCC} -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@ 6790aa901fSSumit Garg 6890aa901fSSumit Gargclean: 6990aa901fSSumit Garg $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS}) 7090aa901fSSumit Garg 7190aa901fSSumit Gargrealclean: clean 7290aa901fSSumit Garg $(call SHELL_DELETE,${BINARY}) 73