From f4ef1e59c72c931f60d269b38974b53165b6cabd Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Wed, 27 Sep 2017 11:07:54 +0930 Subject: [PATCH] Require Java version 1.6 or later --- INSTALL.md | 2 +- configure.ac | 18 ++++++++++- m4/ax_prog_javac_version.m4 | 59 +++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 m4/ax_prog_javac_version.m4 diff --git a/INSTALL.md b/INSTALL.md index 29af81a8..a8017fd3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -53,7 +53,7 @@ Mandatory dependencies: Optional: - * Java compiler and SDK + * Java compiler and SDK 1.6.0 or later * ALSA sound library and headers (present on Linux, not on Android) Test dependencies: diff --git a/configure.ac b/configure.ac index e7b44c20..8a8ae2b8 100644 --- a/configure.ac +++ b/configure.ac @@ -79,8 +79,24 @@ AC_PROG_JAVAC popdef([AC_MSG_ERROR]) AC_SUBST([JAVAC]) -dnl Check for JNI includes, keep going if not present. +dnl Check Java version, ditch Java if not adequate if test -n "$JAVAC"; then + dnl Discover the version of the Java compiler + AC_PROG_JAVAC_VERSION + dnl Check that the Java compiler is modern enough + AS_CASE($ax_cv_prog_javac_version, + [[1.[6-9].*|1.[1-9][0-9].*|2.*]], [], + [''], [ dnl + AC_MSG_WARN([Java version not detected; omitting Java API]) + JAVAC="" + ], [ dnl + AC_MSG_WARN([Java version $ax_cv_prog_javac_version is too old; omitting Java API]) + JAVAC="" + ]) +fi + +if test -n "$JAVAC"; then + dnl Discover the locations of JNI header files dnl *** Kludge: override AC_MSG_ERROR because AC_JNI_INCLUDE_DIR does not have dnl *** [if-found] and [if-not-found] action parameters. pushdef([AC_MSG_ERROR], defn([AC_MSG_WARN])) diff --git a/m4/ax_prog_javac_version.m4 b/m4/ax_prog_javac_version.m4 new file mode 100644 index 00000000..1b43b441 --- /dev/null +++ b/m4/ax_prog_javac_version.m4 @@ -0,0 +1,59 @@ +# SYNOPSIS +# +# AX_PROG_JAVAC_VERSION +# +# DESCRIPTION +# +# Discover the version of the java compiler by invoking it with the -version +# option and stripping off any leading "javac " word. Cache the result in +# $ac_cv_prog_javac_version +# +# LICENSE +# +# Copyright (C) 2017 Flinders University +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, Flinders University gives unlimited permission to +# copy, distribute and modify the configure scripts that are the output of +# Autoconf when processing the Macro. You need not follow the terms of the +# GNU General Public License when using or distributing such scripts, even +# though portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by Flinders University. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 1 + +AU_ALIAS([AC_PROG_JAVAC_VERSION], [AX_PROG_JAVAC_VERSION]) +AC_DEFUN([AX_PROG_JAVAC_VERSION],[ + AC_REQUIRE([AC_PROG_SED]) + AC_CACHE_CHECK([Java compiler version], + ax_cv_prog_javac_version, + [ dnl + dnl Many javac print their version number on standard output + if AC_TRY_COMMAND([$JAVAC -version >java_version 2>&1]); then + ax_cv_prog_javac_version=`sed -n 's/^javac //p' java_version` + else + AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log)]) + ax_cv_prog_javac_version="" + fi + rm -f java_version + ]) + AC_PROVIDE([$0])dnl +])