blob: 3c8577f46e066bb3b00b5c695379ea75ae4175ff [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
David Reissd9cdf422009-03-13 21:25:29 +000019dnl @version 2009-02-09
20dnl @license AllPermissive
21dnl
22dnl Copyright (C) 2009 David Reiss
23dnl Copying and distribution of this file, with or without modification,
24dnl are permitted in any medium without royalty provided the copyright
25dnl notice and this notice are preserved.
26
27
28AC_DEFUN([AX_JAVAC_AND_JAVA],
29 [
30
31 dnl Hard-coded default commands to test.
32 JAVAC_PROGS="javac,jikes,gcj -C"
33 JAVA_PROGS="java,kaffe"
34
35 dnl Allow the user to specify an alternative.
36 if test -n "$JAVAC" ; then
37 JAVAC_PROGS="$JAVAC"
38 fi
39 if test -n "$JAVA" ; then
40 JAVA_PROGS="$JAVA"
41 fi
42
43 AC_MSG_CHECKING(for javac and java)
44
45 echo "public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
46 success=no
47 oIFS="$IFS"
48
49 IFS=","
50 for JAVAC in $JAVAC_PROGS ; do
51 IFS="$oIFS"
52
53 echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD
54 if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then
55
56 IFS=","
57 for JAVA in $JAVA_PROGS ; do
58 IFS="$oIFS"
59
60 echo "Running \"$JAVA configtest_ax_javac_and_java\"" >&AS_MESSAGE_LOG_FD
61 if $JAVA configtest_ax_javac_and_java >&AS_MESSAGE_LOG_FD 2>&1 ; then
62 success=yes
63 break 2
64 fi
65
66 done
67
68 fi
69
70 done
71
72 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
73
74 if test "$success" != "yes" ; then
75 AC_MSG_RESULT(no)
76 JAVAC=""
77 JAVA=""
78 else
79 AC_MSG_RESULT(yes)
80 fi
81
82 ax_javac_and_java="$success"
83
84 ])