diff --git a/Makefile.conf b/Makefile.conf index 02e0872..8e567e0 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -25,13 +25,8 @@ ifeq ($(PLATFORM),linux) 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 +JAVAH_CMD=javah -encoding UTF-8 ######### Overrides from the config file(s) ######### ifneq ("$(wildcard $(HERE)local.conf)","") @@ -51,6 +46,12 @@ ifndef JAVA_HOME $(error JAVA_HOME is not set!) 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 + JAVA_BIN_DIR=$(JAVA_HOME)/bin ######### C and C++ ######### @@ -75,3 +76,14 @@ 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) +null := +space := ${null} ${null} +${space} := ${space} + +define \n + + +endef +# END // kryptic hack to to replace a space with a newline diff --git a/src/Makefile b/src/Makefile index 08dc37b..926d660 100644 --- a/src/Makefile +++ b/src/Makefile @@ -50,9 +50,9 @@ CXX_DIR=cxx/ JAVA_DIR=java/ JAVA_PKG_BASENAME=foundation/pEp/jniadapter/ -JAVA_PKG_ROOT=$(JAVA_DIR)/$(JAVA_PKG_BASENAME) -JAVA_BUILD_ROOT=$(BUILD_ROOT)/$(JAVA_DIR) -OBJ_DIR=$(BUILD_ROOT)/$(CXX_DIR) +JAVA_PKG_ROOT=$(JAVA_DIR)$(JAVA_PKG_BASENAME) +JAVA_BUILD_ROOT=$(BUILD_ROOT)$(JAVA_DIR) +OBJ_DIR=$(BUILD_ROOT)$(CXX_DIR) # for "make clean" only @@ -142,9 +142,11 @@ $(OBJECTS): $(BUILD_ROOT)%.o: %.cc # --------- Generate JNI headers ---------- gen-jni-headers: codegen $(JNI_GENERATED_HH) +# "new" javac -h accepts list of java files +# While "old" (Java 8) javah needs a list of java classes (e.g. foundation.pEp.jniadapter.Message) $(JNI_GENERATED_HH): ifdef OLD_JAVA - cd $(JAVA_DIR);$(JAVA_BIN_DIR)/javah -d ../$(JAVA_BUILD_ROOT) $(subst /,.,$(subst .java,,$<)) + cd $(JAVA_BUILD_ROOT)/;$(JAVA_BIN_DIR)/$(JAVAH_CMD) -d ../../src/$(CXX_DIR) $(subst ${ },${space}\${\n}, $(subst /,.,$(subst $(JAVA_BUILD_ROOT),,$(basename $(sort $(wildcard $(JAVA_BUILD_ROOT)$(JAVA_PKG_BASENAME)*.class/)))))) else cd $(JAVA_DIR);$(JAVA_BIN_DIR)/$(JAVAC_CMD) -d ../$(JAVA_BUILD_ROOT) -h ../$(CXX_DIR)/ $(JAVA_PKG_BASENAME)/*.java endif