From 0f044489054dfe2ee4b505a76ccfa946f4aeb71b Mon Sep 17 00:00:00 2001 From: heck Date: Fri, 3 Jul 2020 17:01:05 +0200 Subject: [PATCH] add Makefile targets install/uninstall (to $PREFIX) update local.conf.example --- Makefile | 9 ++++++++- Makefile.conf | 19 ++++++++++--------- local.conf.example | 25 +++++++++++++++---------- src/Makefile | 13 ++++++++++++- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 45acece..4acf87e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -.PHONY: all src test clean doxy-all doxy-cxx doxy-java doxy-clean +.PHONY: all src test clean doxy-all doxy-cxx doxy-java doxy-clean install uninstall all: src @@ -29,3 +29,10 @@ doxy-java: src doxy-clean: rm -rf doc/doxygen/cxx rm -rf doc/doxygen/java + +install: + $(MAKE) -C src install + +uninstall: + $(MAKE) -C src uninstall + diff --git a/Makefile.conf b/Makefile.conf index 9cfb440..2551f0d 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -10,24 +10,20 @@ PLATFORM:=$(shell uname | tr A-Z a-z) # 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 +PREFIX=$(HOME)/local 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 +ENGINE_LIB_PATH=$(PREFIX)/lib +ENGINE_INC_PATH=$(PREFIX)/include +AD_LIB_PATH=$(PREFIX)/lib +AD_INC_PATH=$(PREFIX)/include ### Guessing JAVA_HOME ifeq ($(PLATFORM),linux) JAVA_HOME=$(subst /bin,,$(dir $(realpath /usr/bin/javac))) endif -ifndef JAVA_HOME - $(error JAVA_HOME is not set!) -endif - -JAVA_BIN_DIR=$(JAVA_HOME)/bin # 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) @@ -49,6 +45,11 @@ ENGINE_INC=-I$(ENGINE_INC_PATH) AD_LIB=-L$(AD_LIB_PATH) AD_INC=-I$(AD_INC_PATH) +ifndef JAVA_HOME + $(error JAVA_HOME is not set!) +endif + +JAVA_BIN_DIR=$(JAVA_HOME)/bin ######### C and C++ ######### CXXFLAGS+=-O0 -std=c++11 -fpermissive -fPIC -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(PLATFORM) $(AD_INC) $(ENGINE_INC) diff --git a/local.conf.example b/local.conf.example index 8de0aa8..d550ae5 100644 --- a/local.conf.example +++ b/local.conf.example @@ -2,23 +2,28 @@ # you might not need this file, but if the defaults dont work for you # You can override them here. # Tweak the values to your needs and rename it to local.conf +# These example values here reflect the defaults + +############ Install ########### +# PREFIX=$(HOME)/local ######### C++ Compiler ######### # Should work with clang and g++ # CXX=g++ -# DEBUG=1 # DEBUG Build (Default) -# DEBUG=0 # RELEASE Build +# DEBUG=0 # RELEASE Build / set to 1 for DEBUG build -######### JAVA ######### +############ JAVA ############## # JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home -######### YML2 ######### +############ YML2 ############## # YML2_PATH=$(HOME)/code/yml2 -######### Engine ######### -# ENGINE_LIB_PATH=$(HOME)/local/lib -# ENGINE_INC_PATH=$(HOME)/local/include +########### Engine ############# +# ENGINE_LIB_PATH=$(PREFIX)/lib +# ENGINE_INC_PATH=$(PREFIX)/include + +########## libAdapter ########## +# AD_LIB_PATH=$(PREFIX)/lib +# AD_INC_PATH=$(PREFIX)/include + -######### libAdapter ######### -# AD_LIB_PATH=$(HOME)/local/lib -# AD_INC_PATH=$(HOME)/local/include diff --git a/src/Makefile b/src/Makefile index b465ff7..4d3225b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -89,7 +89,7 @@ tmp=$(SOURCES:.cc=.o) OBJECTS=$(addprefix $(OBJ_DIR), $(tmp)) DEPENDS=$(OBJECTS:.o=.d) -.PHONY: all lib-java lib-cxx compile-java compile-cxx gen-jni-headers codegen clean create-dirs remove-dirs +.PHONY: all lib-java lib-cxx compile-java compile-cxx gen-jni-headers codegen clean create-dirs remove-dirs install uninstall $(info SOURCES: $(SOURCES)) $(info OBJECTS: $(OBJECTS)) @@ -167,3 +167,14 @@ clean: remove-dirs rm -f $(DEPENDS) rm -f $(OBJECTS) +install: $(LIB_JAVA) $(LIB_CXX_STATIC) $(LIB_CXX_DYN) + mkdir -p $(PREFIX)/lib + cp -v $(DIST_DIR)/$(LIB_JAVA) $(PREFIX)/lib/ + cp -v $(DIST_DIR)/$(LIB_CXX_STATIC) $(PREFIX)/lib/ + cp -v $(DIST_DIR)/$(LIB_CXX_DYN) $(PREFIX)/lib/ + +uninstall: + cd $(PREFIX)/lib && rm -vf $(LIB_JAVA) + cd $(PREFIX)/lib && rm -vf $(LIB_CXX_STATIC) + cd $(PREFIX)/lib && rm -vf $(LIB_CXX_DYN) +