blob: 581b45066659463ba3fd2970e29a7dcecb4150e0 [file] [log] [blame]
David Reissd9cdf422009-03-13 21:25:29 +00001dnl @synopsis AX_JAVAC_AND_JAVA
David Reisseaa8d7e2009-05-12 23:16:53 +00002dnl @synopsis AX_CHECK_JAVA_CLASS(CLASSNAME)
David Reissd9cdf422009-03-13 21:25:29 +00003dnl
David Reisseaa8d7e2009-05-12 23:16:53 +00004dnl Test for the presence of a JDK, and (optionally) specific classes.
David Reissd9cdf422009-03-13 21:25:29 +00005dnl
6dnl If "JAVA" is defined in the environment, that will be the only
7dnl java command tested. Otherwise, a hard-coded list will be used.
8dnl Similarly for "JAVAC".
9dnl
Konrad Grochowski3b5dacb2014-11-24 10:55:31 +010010dnl AX_JAVAC_AND_JAVA does not currently support testing for a particular
David Reisseaa8d7e2009-05-12 23:16:53 +000011dnl Java version, testing for only one of "java" and "javac", or
12dnl compiling or running user-provided Java code.
David Reissd9cdf422009-03-13 21:25:29 +000013dnl
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
David Reisseaa8d7e2009-05-12 23:16:53 +000018dnl AX_CHECK_JAVA_CLASS must be run after AX_JAVAC_AND_JAVA.
19dnl It tests for the presence of a class based on a fully-qualified name.
20dnl It sets the shell variable "success" to "yes" or "no".
21dnl
David Reissd9cdf422009-03-13 21:25:29 +000022dnl @category Java
David Reissd9cdf422009-03-13 21:25:29 +000023dnl @version 2009-02-09
24dnl @license AllPermissive
25dnl
26dnl Copyright (C) 2009 David Reiss
27dnl Copying and distribution of this file, with or without modification,
28dnl are permitted in any medium without royalty provided the copyright
29dnl notice and this notice are preserved.
30
31
32AC_DEFUN([AX_JAVAC_AND_JAVA],
33 [
34
35 dnl Hard-coded default commands to test.
36 JAVAC_PROGS="javac,jikes,gcj -C"
37 JAVA_PROGS="java,kaffe"
38
39 dnl Allow the user to specify an alternative.
40 if test -n "$JAVAC" ; then
41 JAVAC_PROGS="$JAVAC"
42 fi
43 if test -n "$JAVA" ; then
44 JAVA_PROGS="$JAVA"
45 fi
46
47 AC_MSG_CHECKING(for javac and java)
48
49 echo "public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
50 success=no
51 oIFS="$IFS"
52
53 IFS=","
54 for JAVAC in $JAVAC_PROGS ; do
55 IFS="$oIFS"
56
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
59
60 IFS=","
61 for JAVA in $JAVA_PROGS ; do
62 IFS="$oIFS"
63
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
66 success=yes
67 break 2
68 fi
69
70 done
71
72 fi
73
74 done
75
76 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
77
78 if test "$success" != "yes" ; then
79 AC_MSG_RESULT(no)
80 JAVAC=""
81 JAVA=""
82 else
83 AC_MSG_RESULT(yes)
84 fi
85
86 ax_javac_and_java="$success"
87
88 ])
David Reisseaa8d7e2009-05-12 23:16:53 +000089
90
91AC_DEFUN([AX_CHECK_JAVA_CLASS],
92 [
93 AC_MSG_CHECKING(for Java class [$1])
94
95 echo "import $1; public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
96
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
99 AC_MSG_RESULT(yes)
100 success=yes
101 else
102 AC_MSG_RESULT(no)
103 success=no
104 fi
105
106 rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
107 ])
Jake Farrell210d7662011-05-25 21:07:29 +0000108
109
110AC_DEFUN([AX_CHECK_ANT_VERSION],
111 [
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
115 AC_MSG_RESULT(yes)
116 else
117 AC_MSG_RESULT(no)
118 ANT=""
119 fi
120 ])
121