javah, fix build using java 8 (javah instead of javac -h) Release_2.1.0-RC15
authorheck <heck@pep.foundation>
Tue, 15 Sep 2020 23:34:36 +0200
changeset 956f7f71b953273
parent 955 6a9e0b40b627
child 957 f2a0c97cfeb3
javah, fix build using java 8 (javah instead of javac -h)
Makefile.conf
src/Makefile
     1.1 --- a/Makefile.conf	Tue Sep 15 15:58:58 2020 +0200
     1.2 +++ b/Makefile.conf	Tue Sep 15 23:34:36 2020 +0200
     1.3 @@ -25,13 +25,8 @@
     1.4  endif
     1.5  
     1.6  
     1.7 -# 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`.
     1.8 -DUMMY:=$(shell which $(JAVA_HOME)/bin/javah)
     1.9 -ifeq ($(.SHELLSTATUS),0)
    1.10 -    OLD_JAVA=true
    1.11 -endif
    1.12 -
    1.13  JAVAC_CMD=javac -encoding UTF-8
    1.14 +JAVAH_CMD=javah -encoding UTF-8
    1.15  
    1.16  ######### Overrides from the config file(s) #########
    1.17  ifneq ("$(wildcard $(HERE)local.conf)","")
    1.18 @@ -51,6 +46,12 @@
    1.19      $(error JAVA_HOME is not set!)
    1.20  endif
    1.21  
    1.22 +# 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`.
    1.23 +DUMMY:=$(shell which $(JAVA_HOME)/bin/javah)
    1.24 +ifeq ($(.SHELLSTATUS),0)
    1.25 +    OLD_JAVA=true
    1.26 +endif
    1.27 +
    1.28  JAVA_BIN_DIR=$(JAVA_HOME)/bin
    1.29  
    1.30  ######### C and C++ #########
    1.31 @@ -75,3 +76,14 @@
    1.32  ### YML_PATH is needed in the environment of every call to a program of the YML2 distribution
    1.33  export YML_PATH=$(YML2_PATH)
    1.34  
    1.35 +# BEGIN // kryptic hack to to replace a space with a newline
    1.36 +# $(subst ${ },${space}, whatever)
    1.37 +null :=
    1.38 +space := ${null} ${null}
    1.39 +${space} := ${space}
    1.40 +
    1.41 +define \n
    1.42 +
    1.43 +
    1.44 +endef
    1.45 +# END // kryptic hack to to replace a space with a newline
     2.1 --- a/src/Makefile	Tue Sep 15 15:58:58 2020 +0200
     2.2 +++ b/src/Makefile	Tue Sep 15 23:34:36 2020 +0200
     2.3 @@ -50,9 +50,9 @@
     2.4  JAVA_DIR=java/
     2.5  JAVA_PKG_BASENAME=foundation/pEp/jniadapter/
     2.6  
     2.7 -JAVA_PKG_ROOT=$(JAVA_DIR)/$(JAVA_PKG_BASENAME)
     2.8 -JAVA_BUILD_ROOT=$(BUILD_ROOT)/$(JAVA_DIR)
     2.9 -OBJ_DIR=$(BUILD_ROOT)/$(CXX_DIR)
    2.10 +JAVA_PKG_ROOT=$(JAVA_DIR)$(JAVA_PKG_BASENAME)
    2.11 +JAVA_BUILD_ROOT=$(BUILD_ROOT)$(JAVA_DIR)
    2.12 +OBJ_DIR=$(BUILD_ROOT)$(CXX_DIR)
    2.13  
    2.14  
    2.15  # for "make clean" only
    2.16 @@ -142,9 +142,11 @@
    2.17  # --------- Generate JNI headers ----------
    2.18  gen-jni-headers: codegen $(JNI_GENERATED_HH)
    2.19  
    2.20 +# "new" javac -h accepts list of java files
    2.21 +# While "old" (Java 8) javah needs a list of java classes (e.g. foundation.pEp.jniadapter.Message)
    2.22  $(JNI_GENERATED_HH):
    2.23  ifdef OLD_JAVA
    2.24 -	cd $(JAVA_DIR);$(JAVA_BIN_DIR)/javah -d ../$(JAVA_BUILD_ROOT) $(subst /,.,$(subst .java,,$<))
    2.25 +	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/))))))
    2.26  else
    2.27  	cd $(JAVA_DIR);$(JAVA_BIN_DIR)/$(JAVAC_CMD) -d ../$(JAVA_BUILD_ROOT) -h ../$(CXX_DIR)/ $(JAVA_PKG_BASENAME)/*.java
    2.28  endif