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
61 for JAVA in $JAVA_PROGS ; do
64 echo "Running \"$JAVA configtest_ax_javac_and_java\"" >&AS_MESSAGE_LOG_FD
65 if $JAVA configtest_ax_javac_and_java >&AS_MESSAGE_LOG_FD 2>&1 ; then
76 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
78 if test "$success" != "yes" ; then
86 ax_javac_and_java="$success"
91 AC_DEFUN([AX_CHECK_JAVA_CLASS],
93 AC_MSG_CHECKING(for Java class [$1])
95 echo "import $1; public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
97 echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD
98 if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then
106 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
110 AC_DEFUN([AX_CHECK_ANT_VERSION],
112 AC_MSG_CHECKING(for ant version > $2)
113 ANT_VALID=`expr $($1 -version 2>/dev/null | sed -n 's/.*version \(@<:@0-9\.@:>@*\).*/\1/p') \>= $2`
114 if test "x$ANT_VALID" = "x1" ; then