| 30 |
ashish |
1 |
dnl @synopsis AX_JAVAC_AND_JAVA
|
|
|
2 |
dnl @synopsis AX_CHECK_JAVA_CLASS(CLASSNAME)
|
|
|
3 |
dnl
|
|
|
4 |
dnl Test for the presence of a JDK, and (optionally) specific classes.
|
|
|
5 |
dnl
|
|
|
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".
|
|
|
9 |
dnl
|
|
|
10 |
dnl AX_JAVAC_AND_JAVA does not currenly 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.
|
|
|
13 |
dnl
|
|
|
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.
|
|
|
17 |
dnl
|
|
|
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".
|
|
|
21 |
dnl
|
|
|
22 |
dnl @category Java
|
|
|
23 |
dnl @version 2009-02-09
|
|
|
24 |
dnl @license AllPermissive
|
|
|
25 |
dnl
|
|
|
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.
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
AC_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 |
])
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
AC_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 |
])
|