# 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) # DEV ENV PATHS & CFG # The dev environment paths and configs are set to a default value which can be overridden by ./local.conf and overridden again by /local.conf ######### Build Config Defaults ######### DEBUG=1 YML2_PATH=$(HOME)/yml2 YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS) YML2_OPTS=--encoding=utf8 ENGINE_LIB_PATH=$(HOME)/lib ENGINE_INC_PATH=$(HOME)/include AD_LIB_PATH=$(HOME)/lib AD_INC_PATH=$(HOME)/include ### Guessing JAVA_HOME ifeq ($(PLATFORM),linux) JAVA_HOME=$(subst /bin,,$(dir $(realpath /usr/bin/javac))) endif # Old versions of a Java distribution have a `javah` binary, new versions do not. This checks whether or not `javah` can be found in the Java distribution found in the directory `$JAVA_HOME`. DUMMY:=$(shell which $(JAVA_HOME)/bin/javah) ifeq ($(.SHELLSTATUS),0) OLD_JAVA=true endif JAVAC_CMD=javac -encoding UTF-8 ######### 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 ifneq ("$(wildcard $(HERE)src/local.conf)","") $(info including: $(HERE)src/local.conf) -include $(HERE)src/local.conf else $(info Optional build config not found: $(HERE)src/local.conf) endif ### Apply config ENGINE_LIB=-L$(ENGINE_LIB_PATH) ENGINE_INC=-I$(ENGINE_INC_PATH) AD_LIB=-L$(AD_LIB_PATH) AD_INC=-I$(AD_INC_PATH) ######### C and C++ ######### CXXFLAGS+=-O0 -std=c++11 -fpermissive -fPIC -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(PLATFORM) $(AD_INC) $(ENGINE_INC) LDFLAGS+=-shared $(ENGINE_LIB) $(AD_LIB) LDLIBS=-lstdc++ -lpEpEngine -lpEpAdapter 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)