blob: da41fbdbabd43a51331f3aa066216f9d9c862b90 [file] [log] [blame]
David Reissd9cdf422009-03-13 21:25:29 +00001dnl @synopsis AX_JAVAC_AND_JAVA
2dnl
3dnl Test for the presence of a JDK.
4dnl
5dnl If "JAVA" is defined in the environment, that will be the only
6dnl java command tested. Otherwise, a hard-coded list will be used.
7dnl Similarly for "JAVAC".
8dnl
9dnl This macro does not currenly support testing for a particular
10dnl Java version, the presence of a particular class, testing for
11dnl only one of "java" and "javac", or compiling or running
12dnl user-provided Java code.
13dnl
14dnl After AX_JAVAC_AND_JAVA runs, the shell variables "success" and
15dnl "ax_javac_and_java" are set to "yes" or "no", and "JAVAC" and
16dnl "JAVA" are set to the appropriate commands.
17dnl
18dnl @category Java
19dnl @author David Reiss <dreiss@facebook.com>
20dnl @version 2009-02-09
21dnl @license AllPermissive
22dnl
23dnl Copyright (C) 2009 David Reiss
24dnl Copying and distribution of this file, with or without modification,
25dnl are permitted in any medium without royalty provided the copyright
26dnl notice and this notice are preserved.
27
28
29AC_DEFUN([AX_JAVAC_AND_JAVA],
30 [
31
32 dnl Hard-coded default commands to test.
33 JAVAC_PROGS="javac,jikes,gcj -C"
34 JAVA_PROGS="java,kaffe"
35
36 dnl Allow the user to specify an alternative.
37 if test -n "$JAVAC" ; then
38 JAVAC_PROGS="$JAVAC"
39 fi
40 if test -n "$JAVA" ; then
41 JAVA_PROGS="$JAVA"
42 fi
43
44 AC_MSG_CHECKING(for javac and java)
45
46 echo "public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
47 success=no
48 oIFS="$IFS"
49
50 IFS=","
51 for JAVAC in $JAVAC_PROGS ; do
52 IFS="$oIFS"
53
54 echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD
55 if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then
56
57 IFS=","
58 for JAVA in $JAVA_PROGS ; do
59 IFS="$oIFS"
60
61 echo "Running \"$JAVA configtest_ax_javac_and_java\"" >&AS_MESSAGE_LOG_FD
62 if $JAVA configtest_ax_javac_and_java >&AS_MESSAGE_LOG_FD 2>&1 ; then
63 success=yes
64 break 2
65 fi
66
67 done
68
69 fi
70
71 done
72
73 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
74
75 if test "$success" != "yes" ; then
76 AC_MSG_RESULT(no)
77 JAVAC=""
78 JAVA=""
79 else
80 AC_MSG_RESULT(yes)
81 fi
82
83 ax_javac_and_java="$success"
84
85 ])