Use discovered java path for compiler and jni include files
authorKeith Packard <keithp@keithp.com>
Wed, 17 Jul 2019 18:40:06 +0000 (11:40 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 17 Jul 2019 18:40:06 +0000 (11:40 -0700)
Instead of using the discovered java bits just for jni.h, also use
javac from that directory. Add JAVA_VERSION param to set language
version for newer compilers.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/Makefile.am
altosui/Makefile.am
altosuilib/Makefile.am
configure.ac
libaltos/Makefile.am
map-server/altos-mapd/Makefile.am
map-server/altos-mapj/Makefile.am
micropeak/Makefile.am
telegps/Makefile.am

index 82ad2ea..d16a79d 100644 (file)
@@ -1,4 +1,4 @@
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 JAVAROOT=bin
 
index b5fdf0f..1413de5 100644 (file)
@@ -1,6 +1,6 @@
 
 JAVAROOT=classes
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 man_MANS=altosui.1
 
index 3b2e49d..10a5b49 100644 (file)
@@ -1,4 +1,4 @@
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 JAVAROOT=bin
 
index 0e4b204..cc6a23d 100644 (file)
@@ -64,27 +64,41 @@ AC_ARG_WITH(jcommon, AS_HELP_STRING([--with-jcommon=PATH],
 
 AC_SUBST(JCOMMON)
 
-AC_ARG_WITH(jvm, AS_HELP_STRING([--with-jvm-include=PATH],
-       [Set jvm include path for jni builds (default searches in /usr/lib/jvm)]),
-       [JVM_INCLUDE=$withval], [JVM_INCLUDE=auto])
-
-if test "x$JVM_INCLUDE" = "xauto"; then
-       AC_MSG_CHECKING([JVM include files])
-       for jvm in default-java java-6-openjdk java-6-sun; do
-               if test "x$JVM_INCLUDE" = "xauto"; then
+AC_ARG_WITH(jvm, AS_HELP_STRING([--with-jvm=PATH],
+       [Set jvm path for java builds (default searches in /usr/lib/jvm)]),
+       [JVM=$withval], [JVM=auto])
+
+if test "x$JVM" = "xauto"; then
+       AC_MSG_CHECKING([JVM])
+       for jvm in default-java java-6-openjdk java-7-openjdk java-8-openjdk java-9-openjdk java-10-openjdk java-11-openjdk java-12-openjdk java-13-openjdk java-6-sun; do
+               if test "x$JVM" = "xauto"; then
                        INCLUDE="/usr/lib/jvm/$jvm/include"
                        if test -f "$INCLUDE"/jni.h; then
-                               JVM_INCLUDE="$INCLUDE"
+                               JVM=/usr/lib/jvm/"$jvm"
                        fi
                fi
        done
-       if test "x$JVM_INCLUDE" = "xauto"; then
-               AC_MSG_ERROR([no JVM include files found])
+       if test "x$JVM" = "xauto"; then
+               AC_MSG_ERROR([no JVM files found])
        fi
-       AC_MSG_RESULT([$JVM_INCLUDE])
+       AC_MSG_RESULT([$JVM])
 fi
 
+AC_ARG_WITH(java-version, AS_HELP_STRING([--with-java-version=7],
+                                        [Set java language compatibility version (default is 7)]),
+          [JAVA_VERSION=$withval], [JAVA_VERSION=7])
+
+JAVAC="$JVM"/bin/javac
+JAVA="$JVM"/bin/java
+JVM_INCLUDE="$JVM"/include
+JAVAC_VERSION_FLAGS="-target 1.$JAVA_VERSION -source 1.$JAVA_VERSION"
+
+AC_SUBST(JAVAC)
+AC_SUBST(JAVA)
+AC_SUBST(JVM)
 AC_SUBST(JVM_INCLUDE)
+AC_SUBST(JAVAC_VERSION_FLAGS)
+
 
 AC_ARG_WITH(android, AS_HELP_STRING([--with-android=PATH],
        [Set android SDK path (default searches in a variety of places)]),
index 69fe7a5..eb5eb67 100644 (file)
@@ -1,6 +1,5 @@
-JAVAC=javac
 AM_CFLAGS=-DLINUX -DPOSIX_TTY -I$(JVM_INCLUDE) -I$(JVM_INCLUDE)/linux
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 altoslibdir=$(libdir)/altos
 
index 315a33d..bb20dd8 100644 (file)
@@ -1,5 +1,5 @@
 JAVAROOT=classes
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 altoslibdir=$(libdir)/altos
 
index 98d4f17..a8dfffe 100644 (file)
@@ -1,5 +1,5 @@
 JAVAROOT=classes
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 altoslibdir=$(libdir)/altos
 
index 7e9b490..23ec077 100644 (file)
@@ -1,5 +1,5 @@
 JAVAROOT=classes
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 man_MANS=micropeak.1
 
index ae1e83e..0e75abf 100644 (file)
@@ -1,5 +1,5 @@
 JAVAROOT=classes
-AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6
+AM_JAVACFLAGS=$(JAVAC_VERSION_FLAGS) -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked
 
 man_MANS=telegps.1