1# javaexec.m4 serial 5
2dnl Copyright (C) 2001-2003, 2006, 2009-2012 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# Prerequisites of javaexec.sh.
8# gt_JAVAEXEC or gt_JAVAEXEC(testclass, its-directory)
9# Sets HAVE_JAVAEXEC to nonempty if javaexec.sh will work.
10
11AC_DEFUN([gt_JAVAEXEC],
12[
13  AC_MSG_CHECKING([for Java virtual machine])
14  AC_EGREP_CPP([yes], [
15#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
16  yes
17#endif
18], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
19  CONF_JAVA=
20  HAVE_JAVA_ENVVAR=
21  HAVE_GIJ=
22  HAVE_JAVA=
23  HAVE_JRE=
24  HAVE_JVIEW=
25  HAVE_JAVAEXEC=1
26  if test -n "$JAVA"; then
27    HAVE_JAVA_ENVVAR=1
28    CONF_JAVA="$JAVA"
29  else
30    pushdef([AC_MSG_CHECKING],[:])dnl
31    pushdef([AC_CHECKING],[:])dnl
32    pushdef([AC_MSG_RESULT],[:])dnl
33    AC_CHECK_PROG([HAVE_GIJ_IN_PATH], [gij], [yes])
34    AC_CHECK_PROG([HAVE_JAVA_IN_PATH], [java], [yes])
35    AC_CHECK_PROG([HAVE_JRE_IN_PATH], [jre], [yes])
36    AC_CHECK_PROG([HAVE_JVIEW_IN_PATH], [jview], [yes])
37    popdef([AC_MSG_RESULT])dnl
38    popdef([AC_CHECKING])dnl
39    popdef([AC_MSG_CHECKING])dnl
40    ifelse([$1], , , [
41      save_CLASSPATH="$CLASSPATH"
42      CLASSPATH="$2"${CLASSPATH+"$CLASSPATH_SEPARATOR$CLASSPATH"}
43      ])
44    export CLASSPATH
45    if test -n "$HAVE_GIJ_IN_PATH" \
46       && gij --version >/dev/null 2>/dev/null \
47       ifelse([$1], , , [&& {
48         echo "$as_me:__oline__: gij $1" >&AS_MESSAGE_LOG_FD
49         gij $1 >&AS_MESSAGE_LOG_FD 2>&1
50       }]); then
51      HAVE_GIJ=1
52      CONF_JAVA="gij"
53    else
54      if test -n "$HAVE_JAVA_IN_PATH" \
55         && java -version >/dev/null 2>/dev/null \
56         ifelse([$1], , , [&& {
57           echo "$as_me:__oline__: gij $1" >&AS_MESSAGE_LOG_FD
58           java $1 >&AS_MESSAGE_LOG_FD 2>&1
59         }]); then
60        HAVE_JAVA=1
61        CONF_JAVA="java"
62      else
63        if test -n "$HAVE_JRE_IN_PATH" \
64           && (jre >/dev/null 2>/dev/null || test $? = 1) \
65           ifelse([$1], , , [&& {
66             echo "$as_me:__oline__: gij $1" >&AS_MESSAGE_LOG_FD
67             jre $1 >&AS_MESSAGE_LOG_FD 2>&1
68           }]); then
69          HAVE_JRE=1
70          CONF_JAVA="jre"
71        else
72          if test -n "$HAVE_JVIEW_IN_PATH" \
73             && (jview -? >/dev/null 2>/dev/null || test $? = 1) \
74             ifelse([$1], , , [&& {
75               echo "$as_me:__oline__: gij $1" >&AS_MESSAGE_LOG_FD
76               jview $1 >&AS_MESSAGE_LOG_FD 2>&1
77             }]); then
78            HAVE_JVIEW=1
79            CONF_JAVA="jview"
80          else
81            HAVE_JAVAEXEC=
82          fi
83        fi
84      fi
85    fi
86    ifelse([$1], , , [
87      CLASSPATH="$save_CLASSPATH"
88    ])
89  fi
90  if test -n "$HAVE_JAVAEXEC"; then
91    ac_result="$CONF_JAVA"
92  else
93    ac_result="no"
94  fi
95  AC_MSG_RESULT([$ac_result])
96  AC_SUBST([CONF_JAVA])
97  AC_SUBST([CLASSPATH])
98  AC_SUBST([CLASSPATH_SEPARATOR])
99  AC_SUBST([HAVE_JAVA_ENVVAR])
100  AC_SUBST([HAVE_GIJ])
101  AC_SUBST([HAVE_JAVA])
102  AC_SUBST([HAVE_JRE])
103  AC_SUBST([HAVE_JVIEW])
104])
105