1 dnl @synopsis AX_JAVAC_AND_JAVA
2 dnl @synopsis AX_CHECK_JAVA_CLASS(CLASSNAME)
4 dnl Test for the presence of a JDK, and (optionally) specific classes.
6 dnl If "JAVA" is defined in the environment, that will be the only
7 dnl java command tested. Otherwise, a hard-coded list will be used.
8 dnl Similarly for "JAVAC".
10 dnl AX_JAVAC_AND_JAVA does not currently support testing for a particular
11 dnl Java version, testing for only one of "java" and "javac", or
12 dnl compiling or running user-provided Java code.
14 dnl After AX_JAVAC_AND_JAVA runs, the shell variables "success" and
15 dnl "ax_javac_and_java" are set to "yes" or "no", and "JAVAC" and
16 dnl "JAVA" are set to the appropriate commands.
18 dnl AX_CHECK_JAVA_CLASS must be run after AX_JAVAC_AND_JAVA.
19 dnl It tests for the presence of a class based on a fully-qualified name.
20 dnl It sets the shell variable "success" to "yes" or "no".
23 dnl @version 2009-02-09
24 dnl @license AllPermissive
26 dnl Copyright (C) 2009 David Reiss
27 dnl Copying and distribution of this file, with or without modification,
28 dnl are permitted in any medium without royalty provided the copyright
29 dnl notice and this notice are preserved.
32 AC_DEFUN([AX_JAVAC_AND_JAVA],
35 dnl Hard-coded default commands to test.
36 JAVAC_PROGS="javac,jikes,gcj -C"
37 JAVA_PROGS="java,kaffe"
39 dnl Allow the user to specify an alternative.
40 if test -n "$JAVAC" ; then
43 if test -n "$JAVA" ; then
47 AC_MSG_CHECKING(for javac and java)
49 echo "public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
54 for JAVAC in $JAVAC_PROGS ; do
57 echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD
58 if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then
60 # prevent $JAVA VM issues with UTF-8 path names (THRIFT-3271)
65 for JAVA in $JAVA_PROGS ; do
68 echo "Running \"$JAVA configtest_ax_javac_and_java\"" >&AS_MESSAGE_LOG_FD
69 if $JAVA configtest_ax_javac_and_java >&AS_MESSAGE_LOG_FD 2>&1 ; then
84 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
86 if test "$success" != "yes" ; then
94 ax_javac_and_java="$success"
99 AC_DEFUN([AX_CHECK_JAVA_CLASS],
101 AC_MSG_CHECKING(for Java class [$1])
103 echo "import $1; public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
105 echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD
106 if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then
114 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
118 AC_DEFUN([AX_CHECK_ANT_VERSION],
120 AC_MSG_CHECKING(for ant version > $2)
121 ANT_VALID=`expr "x$(printf "$2\n$($1 -version 2>/dev/null | sed -n 's/.*version \(@<:@0-9\.@:>@*\).*/\1/p')" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -g | sed -n 1p)" = "x$2"`
122 if test "x$ANT_VALID" = "x1" ; then