You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

134 lines
3.4 KiB

# Copyright 2018, pEp Foundation
# This file is part of pEp JNI Adapter
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
PLATFORM:=$(shell uname | tr A-Z a-z)
JAVAC_CMD=javac -encoding UTF-8
JAVAH_CMD=javah -encoding UTF-8
# DEV ENV PATHS & CFG
# The build settings are set to a default value which can be overridden by using ./local.conf
######### DEFAULTS #########
DEBUG=0
PREFIX=$(HOME)
YML2_PATH=$(PREFIX)/src/yml2
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
YML2_OPTS=--encoding=utf8
ENGINE_LIB_PATH=$(PREFIX)/lib
ENGINE_INC_PATH=$(PREFIX)/include
AD_LIB_PATH=$(PREFIX)/lib
AD_INC_PATH=$(PREFIX)/include
BOOST_INCLUDE?=$(PREFIX)/include
BOOST_LIB?=$(PREFIX)/lib
CRYPTOPP_INCLUDE?=$(PREFIX)/include
CRYPTOPP_LIB?=$(PREFIX)/lib
OPENSSL_INCLUDE?=$(HOME)/include
OPENSSL_LIB?=$(HOME)/lib
LIBZ_INCLUDE?=$(HOME)/include
LIBZ_LIB?=$(HOME)/lib
### Guessing JAVA_HOME
ifeq ($(PLATFORM),linux)
JAVA_HOME=$(subst /bin,,$(dir $(realpath /usr/bin/javac)))
endif
######### Overrides from the config file(s) #########
ifneq ("$(wildcard $(HERE)local.conf)","")
$(info including: $(HERE)local.conf)
-include $(HERE)local.conf
else
$(info Optional build config not found: $(HERE)local.conf)
endif
ifndef JAVA_HOME
$(error JAVA_HOME is not set!)
endif
# Guessing USE_JAVAH
# cant be guessed earlier, because it depends on JAVA_HOME which can be set in the local.conf
# Old versions of a Java distribution have a `javah` binary, new version do not and the replacement is "javac -h"
# TODO: dont check for presence of javah, but check if javac -h is supported, because some java (RHEL) has javah but supports javac -h (and javac -h is preferred)
ifndef USE_JAVAH
DUMMY:=$(shell which $(JAVA_HOME)/bin/javah)
ifeq ($(.SHELLSTATUS),0)
USE_JAVAH=1
endif
endif
JAVA_BIN_DIR=$(JAVA_HOME)/bin
######### C and C++ #########
CXXFLAGS+=-O0 -std=c++17 -fpermissive -fPIC
INCLUDES+=-I$(JAVA_HOME)/include
INCLUDES+=-I$(JAVA_HOME)/include/$(PLATFORM)
INCLUDES+=-I$(AD_INC_PATH)
INCLUDES+=-I$(ENGINE_INC_PATH)
INCLUDES+=-I$(BOOST_INCLUDE)
INCLUDES+=-I$(CRYPTOPP_INCLUDE)
INCLUDES+=-I$(OPENSSL_INCLUDE)
INCLUDES+=-I$(LIBZ_INCLUDE)
CXXFLAGS+=$(INCLUDES)
LDFLAGS+=-shared
LIBS+=-L$(ENGINE_LIB_PATH)
LIBS+=-L$(AD_LIB_PATH)
LIBS+=-L$(BOOST_LIB)
LIBS+=-L$(CRYPTOPP_LIB)
LIBS+=-L$(OPENSSL_LIB)
LIBS+=-L$(LIBZ_LIB)
LIBS+=-lstdc++
LIBS+=-lpEpEngine
LIBS+=-lpEpAdapter
LIBS+=-lsignedpkg
LIBS+=-ldownloadclient
LIBS+=-larchive
LIBS+=-lboost_regex
LIBS+=-lboost_iostreams
LIBS+=-lboost_system
LIBS+=-lz
LIBS+=-lcryptopp
LIBS+=-lcrypto
LIBS+=-lssl
LDFLAGS+=$(LIBS)
ifneq (,$(findstring g++,$(CXX)))
CXXFLAGS+=-fdiagnostics-color=always
else ifneq (,$(findstring clang,$(CXX)))
CXXFLAGS+=-fcolor-diagnostics
endif
### Debug or Release build
ifeq ($(DEBUG),1)
$(info Debug build (set DEBUG=0 for release build))
CXXFLAGS+=-g
else
$(info Release Build (set DEBUG=1 for debug build))
CXXFLAGS+=-DNDEBUG=1 -O3
endif
### YML_PATH is needed in the environment of every call to a program of the YML2 distribution
export YML_PATH=$(YML2_PATH)
# BEGIN // kryptic hack to to replace a space with a newline
# $(subst ${ },${space}, whatever)
# maybe not well known: define/endef is custom makefile function definition
null :=
space := ${null} ${null}
${space} := ${space}
define \n
endef
# END // kryptic hack to to replace a space with a newline