a180647a52ac0d3e8b584d579ba1a58cda1a0e3b
[gnulib.git] / m4 / javacomp.m4
1 # javacomp.m4 serial 6 (gettext-0.13)
2 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 # Prerequisites of javacomp.sh.
8 # Sets HAVE_JAVACOMP to nonempty if javacomp.sh will work.
9
10 AC_DEFUN([gt_JAVACOMP],
11 [
12   AC_MSG_CHECKING([for Java compiler])
13   AC_EGREP_CPP(yes, [
14 #if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
15   yes
16 #endif
17 ], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
18   HAVE_JAVACOMP=1
19   if test -n "$JAVAC"; then
20     ac_result="$JAVAC"
21   else
22     pushdef([AC_MSG_CHECKING],[:])dnl
23     pushdef([AC_CHECKING],[:])dnl
24     pushdef([AC_MSG_RESULT],[:])dnl
25     AC_CHECK_PROG(HAVE_GCJ_IN_PATH, gcj, yes)
26     AC_CHECK_PROG(HAVE_JAVAC_IN_PATH, javac, yes)
27     AC_CHECK_PROG(HAVE_JIKES_IN_PATH, jikes, yes)
28     popdef([AC_MSG_RESULT])dnl
29     popdef([AC_CHECKING])dnl
30     popdef([AC_MSG_CHECKING])dnl
31 changequote(,)dnl
32     # Test for a good gcj version (>= 3.0).
33     # Exclude some versions of gcj: gcj 3.0.4 compiles GetURL.java to invalid
34     # bytecode, that crashes with an IllegalAccessError when executed by
35     # gij 3.0.4 or with a VerifyError when executed by Sun Java. Likewise for
36     # gcj 3.1.
37     # I also exclude gcj 3.2, 3.3 etc. because I have no idea when this bug
38     # will be fixed. The bug is registered as java/7066, see
39     # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
40     # FIXME: Check new versions of gcj as they come out.
41     if test -n "$HAVE_GCJ_IN_PATH" \
42        && gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[0123456789]/d' | grep '^[3-9]' >/dev/null \
43        && (
44         # See if libgcj.jar is well installed.
45         cat > conftest.java <<EOF
46 public class conftest {
47   public static void main (String[] args) {
48   }
49 }
50 EOF
51         gcj -C -d . conftest.java 2>/dev/null
52         error=$?
53         rm -f conftest.java conftest.class
54         exit $error
55        ); then
56       HAVE_GCJ_C=1
57       ac_result="gcj -C"
58     else
59       if test -n "$HAVE_JAVAC_IN_PATH" \
60          && (javac -version >/dev/null 2>/dev/null || test $? -le 2) \
61          && (if javac -help 2>&1 >/dev/null | grep at.dms.kjc.Main >/dev/null && javac -help 2>/dev/null | grep 'released.*2000' >/dev/null ; then exit 1; else exit 0; fi); then
62         HAVE_JAVAC=1
63         ac_result="javac"
64       else
65         if test -n "$HAVE_JIKES_IN_PATH" \
66            && (jikes >/dev/null 2>/dev/null || test $? = 1) \
67            && (
68             # See if the existing CLASSPATH is sufficient to make jikes work.
69             cat > conftest.java <<EOF
70 public class conftest {
71   public static void main (String[] args) {
72   }
73 }
74 EOF
75             unset JAVA_HOME
76             jikes conftest.java 2>/dev/null
77             error=$?
78             rm -f conftest.java conftest.class
79             exit $error
80            ); then
81           HAVE_JIKES=1
82           ac_result="jikes"
83         else
84           HAVE_JAVACOMP=
85           ac_result="no"
86         fi
87       fi
88     fi
89 changequote([,])dnl
90   fi
91   AC_MSG_RESULT([$ac_result])
92   AC_SUBST(JAVAC)
93   AC_SUBST(CLASSPATH)
94   AC_SUBST(CLASSPATH_SEPARATOR)
95   AC_SUBST(HAVE_GCJ_C)
96   AC_SUBST(HAVE_JAVAC)
97   AC_SUBST(HAVE_JIKES)
98 ])