1 |
773 |
jeremybenn |
dnl Available from the GNU Autoconf Macro Archive at:
|
2 |
|
|
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_java_works.html
|
3 |
|
|
dnl
|
4 |
|
|
AC_DEFUN_ONCE([AC_PROG_JAVA_WORKS], [
|
5 |
|
|
AC_REQUIRE([AC_PROG_JAVA])
|
6 |
|
|
AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
|
7 |
|
|
if test x$uudecode = xyes; then
|
8 |
|
|
AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
|
9 |
|
|
dnl /**
|
10 |
|
|
dnl * Test.java: used to test if java compiler works.
|
11 |
|
|
dnl */
|
12 |
|
|
dnl public class Test
|
13 |
|
|
dnl {
|
14 |
|
|
dnl
|
15 |
|
|
dnl public static void
|
16 |
|
|
dnl main( String[] argv )
|
17 |
|
|
dnl {
|
18 |
|
|
dnl System.exit (0);
|
19 |
|
|
dnl }
|
20 |
|
|
dnl
|
21 |
|
|
dnl }
|
22 |
|
|
cat << \EOF > Test.uue
|
23 |
|
|
begin-base64 644 Test.class
|
24 |
|
|
yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
|
25 |
|
|
bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
|
26 |
|
|
bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
|
27 |
|
|
YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
|
28 |
|
|
aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
|
29 |
|
|
AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
|
30 |
|
|
AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
|
31 |
|
|
====
|
32 |
|
|
EOF
|
33 |
|
|
if uudecode$EXEEXT Test.uue; then
|
34 |
|
|
ac_cv_prog_uudecode_base64=yes
|
35 |
|
|
else
|
36 |
|
|
echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
|
37 |
|
|
echo "configure: failed file was:" >&AC_FD_CC
|
38 |
|
|
cat Test.uue >&AC_FD_CC
|
39 |
|
|
ac_cv_prog_uudecode_base64=no
|
40 |
|
|
fi
|
41 |
|
|
rm -f Test.uue])
|
42 |
|
|
fi
|
43 |
|
|
if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
44 |
|
|
rm -f Test.class
|
45 |
|
|
AC_MSG_WARN([I have to compile Test.class from scratch])
|
46 |
|
|
if test x$ac_cv_prog_javac_works = xno; then
|
47 |
|
|
AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
|
48 |
|
|
fi
|
49 |
|
|
fi
|
50 |
|
|
AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
|
51 |
|
|
JAVA_TEST=Test.java
|
52 |
|
|
CLASS_TEST=Test.class
|
53 |
|
|
TEST=Test
|
54 |
|
|
changequote(, )dnl
|
55 |
|
|
cat << \EOF > $JAVA_TEST
|
56 |
|
|
/* [#]line __oline__ "configure" */
|
57 |
|
|
public class Test {
|
58 |
|
|
public static void main (String args[]) {
|
59 |
|
|
System.exit (0);
|
60 |
|
|
} }
|
61 |
|
|
EOF
|
62 |
|
|
changequote([, ])dnl
|
63 |
|
|
if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
64 |
|
|
AC_REQUIRE([AC_PROG_JAVAC_WORKS])
|
65 |
|
|
if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
|
66 |
|
|
:
|
67 |
|
|
else
|
68 |
|
|
echo "configure: failed program was:" >&AC_FD_CC
|
69 |
|
|
cat $JAVA_TEST >&AC_FD_CC
|
70 |
|
|
AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
|
71 |
|
|
fi
|
72 |
|
|
fi
|
73 |
|
|
if AC_TRY_COMMAND(CLASSPATH=.:$CLASSPATH $JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
|
74 |
|
|
ac_cv_prog_java_works=yes
|
75 |
|
|
else
|
76 |
|
|
echo "configure: failed program was:" >&AC_FD_CC
|
77 |
|
|
cat $JAVA_TEST >&AC_FD_CC
|
78 |
|
|
AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
|
79 |
|
|
fi
|
80 |
|
|
rm -fr $JAVA_TEST $CLASS_TEST Test.uue
|
81 |
|
|
])
|
82 |
|
|
AC_PROVIDE([$0])dnl
|
83 |
|
|
]
|
84 |
|
|
)
|
85 |
|
|
dnl Available from the GNU Autoconf Macro Archive at:
|
86 |
|
|
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_try_compile_java.html
|
87 |
|
|
dnl
|
88 |
|
|
AC_DEFUN_ONCE([AC_TRY_COMPILE_JAVA],[
|
89 |
|
|
AC_REQUIRE([AC_PROG_JAVAC_WORKS])dnl
|
90 |
|
|
cat << \EOF > Test.java
|
91 |
|
|
/* [#]line __oline__ "configure" */
|
92 |
|
|
ifelse([$1], , , [import $1;])
|
93 |
|
|
public class Test {
|
94 |
|
|
[$2]
|
95 |
|
|
}
|
96 |
|
|
EOF
|
97 |
|
|
if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class
|
98 |
|
|
then
|
99 |
|
|
dnl Don't remove the temporary files here, so they can be examined.
|
100 |
|
|
ifelse([$3], , :, [$3])
|
101 |
|
|
else
|
102 |
|
|
echo "configure: failed program was:" >&AC_FD_CC
|
103 |
|
|
cat Test.java >&AC_FD_CC
|
104 |
|
|
ifelse([$4], , , [ rm -fr Test*
|
105 |
|
|
$4
|
106 |
|
|
])dnl
|
107 |
|
|
fi
|
108 |
|
|
rm -fr Test*])
|