Require Java version 1.6 or later

This commit is contained in:
Andrew Bettison 2017-09-27 11:07:54 +09:30
parent 9d785acaf2
commit f4ef1e59c7
3 changed files with 77 additions and 2 deletions

View File

@ -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:

View File

@ -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]))

View File

@ -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 <http://www.gnu.org/licenses/>.
#
# 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
])