1# gcj.m4 serial 2 (gettext-0.17)
2dnl Copyright (C) 2002, 2006 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# Check for a Java compiler that creates executables.
8# Assigns the variables GCJ and GCJFLAGS, and set HAVE_GCJ to nonempty,
9# if found. Otherwise sets HAVE_GCJ to empty.
10
11AC_DEFUN([gt_GCJ],
12[
13  AC_ARG_VAR([GCJ], [Java native code compiler command])
14  AC_ARG_VAR([GCJFLAGS], [Java native code compiler flags])
15
16  AC_MSG_CHECKING([for Java to native code compiler])
17  # Search for the gcj command or use the one provided by the user.
18  if test -z "$GCJ"; then
19    pushdef([AC_MSG_CHECKING],[:])dnl
20    pushdef([AC_CHECKING],[:])dnl
21    pushdef([AC_MSG_RESULT],[:])dnl
22    AC_CHECK_TOOL([GCJ], [gcj], [none])
23    popdef([AC_MSG_RESULT])dnl
24    popdef([AC_CHECKING])dnl
25    popdef([AC_MSG_CHECKING])dnl
26  fi
27  # Choose GCJFLAGS or use the one provided by the user.
28  if test "$GCJ" != none; then
29    test "${GCJFLAGS+set}" != set || GCJFLAGS="-O2 -g"
30  fi
31  # Check whether the version is ok and it can create executables.
32  ac_gcj_link="$GCJ $GCJFLAGS conftest.java --main=conftest -o conftest$ac_exeext"
33changequote(,)dnl
34  if test "$GCJ" != none \
35     && $GCJ --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | grep '^[3-9]' >/dev/null \
36     && (
37      # See if libgcj.so is well installed and if exception handling works.
38      cat > conftest.java <<EOF
39public class conftest {
40  public static void main (String[] args) {
41    try {
42      java.util.ResourceBundle.getBundle("foobar");
43    } catch (Exception e) {
44    }
45    System.exit(0);
46  }
47}
48EOF
49changequote([,])dnl
50      AC_TRY_EVAL([ac_gcj_link])
51      error=$?
52      if test $error = 0 && test "$cross_compiling" != yes; then
53        # Run conftest and catch its exit status, but silently.
54        error=`./conftest >/dev/null 2>&1; echo $?`
55        test $error = 0 || error=1
56        rm -f core conftest.core
57      fi
58      rm -f conftest.java conftest$ac_exeext
59      exit $error
60     ); then
61    :
62  else
63    GCJ=none
64  fi
65  AC_MSG_RESULT($GCJ)
66  if test "$GCJ" != none; then
67    HAVE_GCJ=1
68  else
69    HAVE_GCJ=
70  fi
71  AC_SUBST(GCJ)
72  AC_SUBST(GCJFLAGS)
73  AC_SUBST(HAVE_GCJ)
74])
75