]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Support for compiling and executing Java programs.
authorBruno Haible <bruno@clisp.org>
Tue, 18 Sep 2001 12:21:19 +0000 (12:21 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 18 Sep 2001 12:21:19 +0000 (12:21 +0000)
ChangeLog
configure.in
lib/ChangeLog
lib/javacomp.sh.in [new file with mode: 0644]
lib/javaexec.sh.in [new file with mode: 0644]
m4/ChangeLog
m4/Makefile.am
m4/javacomp.m4 [new file with mode: 0644]
m4/javaexec.m4 [new file with mode: 0644]

index 01d75f497d4642d0dbd838237a81de0f6ac8294d..be67ccc8c8fc1cba4d29980a634808b6ba54830d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-09-08  Bruno Haible  <haible@clisp.cons.org>
+
+       * configure.in: Call gt_JAVACOMP and check for 'jar'. Define BUILDJAVA.
+       Call gt_JAVAEXEC. Define TESTJAVA.
+       (AC_OUTPUT): Also create lib/javacomp.sh and lib/javaexec.sh.
+
 2001-09-06  Bruno Haible  <haible@clisp.cons.org>
 
        * configure.in: Add AC_REPLACE_FUNCS of strpbrk.
index f1437028df23996bf252f412a1f38bb63ca7d472..25f3f83530e9a435497ebe7892d90537f70f448f 100644 (file)
@@ -11,6 +11,23 @@ AC_PROG_INSTALL
 AC_PROG_YACC
 gt_PROG_LEX
 
+gt_JAVACOMP
+AC_CHECK_PROG(JAR, jar, jar)
+if test -n "$HAVE_JAVACOMP" && test -n "$JAR"; then
+  BUILDJAVA=yes
+else
+  BUILDJAVA=no
+fi
+AC_SUBST(BUILDJAVA)
+
+gt_JAVAEXEC
+if test -n "$HAVE_JAVAEXEC" && test $BUILDJAVA = yes; then
+  TESTJAVA=yes
+else
+  TESTJAVA=no
+fi
+AC_SUBST(TESTJAVA)
+
 dnl Check for host type.
 AC_CANONICAL_HOST
 
@@ -98,6 +115,12 @@ $RELEASE_DATE  GNU  <bug-gnu-gettext@gnu.org>
 
 EOF
 
-AC_OUTPUT([Makefile lib/Makefile intl/Makefile src/Makefile po/Makefile.in \
-           doc/Makefile man/Makefile man/x-to-1 tests/Makefile m4/Makefile \
+AC_OUTPUT([Makefile \
+           lib/Makefile lib/javacomp.sh lib/javaexec.sh \
+           intl/Makefile \
+           src/Makefile \
+           po/Makefile.in \
+           doc/Makefile man/Makefile man/x-to-1 \
+           tests/Makefile \
+           m4/Makefile \
            misc/Makefile misc/gettextize])
index 1560eca4efeecc77619598b98b8b4bc59276f847..7b37a0c440fd826bbd6be127bf28808399a26ec7 100644 (file)
@@ -1,3 +1,8 @@
+2001-09-08  Bruno Haible  <haible@clisp.cons.org>
+
+       * javacomp.sh.in: New file.
+       * javaexec.sh.in: New file.
+
 2001-09-06  Bruno Haible  <haible@clisp.cons.org>
 
        * javacomp.h: New file.
diff --git a/lib/javacomp.sh.in b/lib/javacomp.sh.in
new file mode 100644 (file)
index 0000000..f1d07dc
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+# Compile a Java program.
+
+# Copyright (C) 2001 Free Software Foundation, Inc.
+# Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+# This uses the same choices as javacomp.c, but instead of relying on the
+# environment settings at run time, it uses the environment variables
+# present at configuration time.
+#
+# This is a separate shell script, because it must be able to unset JAVA_HOME
+# in some cases, which a simple shell command cannot do.
+#
+# The extra CLASSPATH must have been set prior to calling this script.
+# Options that can be passed are -O, -g and "-d DIRECTORY".
+
+CONF_JAVAC='@JAVAC@'
+CONF_CLASSPATH='@CLASSPATH@'
+if test -n "$CONF_JAVAC"; then
+  # Combine given CLASSPATH and configured CLASSPATH.
+  if test -n "$CLASSPATH"; then
+    CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
+  else
+    CLASSPATH="$CONF_CLASSPATH"
+  fi
+  export CLASSPATH
+  test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
+  exec $CONF_JAVAC "$@"
+else
+  unset JAVA_HOME
+  if test -n "@HAVE_GCJ@"; then
+    CLASSPATH="$CLASSPATH"
+    export CLASSPATH
+    test -z "$JAVA_VERBOSE" || echo gcj -C "$@"
+    exec gcj -C "$@"
+  else
+    if test -n "@HAVE_JAVAC@"; then
+      CLASSPATH="$CLASSPATH"
+      export CLASSPATH
+      test -z "$JAVA_VERBOSE" || echo javac "$@"
+      exec javac "$@"
+    else
+      if test -n "@HAVE_JIKES@"; then
+        # Combine given CLASSPATH and configured CLASSPATH.
+        if test -n "$CLASSPATH"; then
+          CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
+        else
+          CLASSPATH="$CONF_CLASSPATH"
+        fi
+        export CLASSPATH
+        test -z "$JAVA_VERBOSE" || echo jikes "$@"
+        exec jikes "$@"
+      else
+        echo 'Java compiler not found, try installing gcj or set $JAVAC, then reconfigure' 1>&2
+        exit 1
+      fi
+    fi
+  fi
+fi
diff --git a/lib/javaexec.sh.in b/lib/javaexec.sh.in
new file mode 100644 (file)
index 0000000..0c14c75
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+# Execute a Java program.
+
+# Copyright (C) 2001 Free Software Foundation, Inc.
+# Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+# This uses the same choices as javaexec.c, but instead of relying on the
+# environment settings at run time, it uses the environment variables
+# present at configuration time.
+#
+# This is a separate shell script, because it must be able to unset JAVA_HOME
+# in some cases, which a simple shell command cannot do.
+#
+# The extra CLASSPATH must have been set prior to calling this script.
+
+CONF_JAVA='@JAVA@'
+CONF_CLASSPATH='@CLASSPATH@'
+if test -n "$CONF_JAVA"; then
+  # Combine given CLASSPATH and configured CLASSPATH.
+  if test -n "$CLASSPATH"; then
+    CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
+  else
+    CLASSPATH="$CONF_CLASSPATH"
+  fi
+  export CLASSPATH
+  test -z "$JAVA_VERBOSE" || echo "$CONF_JAVA $@"
+  exec $CONF_JAVA "$@"
+else
+  unset JAVA_HOME
+  export CLASSPATH
+  if test -n "@HAVE_GIJ@"; then
+    test -z "$JAVA_VERBOSE" || echo gij "$@"
+    exec gij "$@"
+  else
+    # We call this variable HAVE_JAVA_JVM, not HAVE_JAVA, because otherwise
+    # automake creates a dependency to "classHAVE.stamp" in every Makefile!!
+    if test -n "@HAVE_JAVA_JVM@"; then
+      test -z "$JAVA_VERBOSE" || echo java "$@"
+      exec java "$@"
+    else
+      if test -n "@HAVE_JRE@"; then
+        test -z "$JAVA_VERBOSE" || echo jre "$@"
+        exec jre "$@"
+      else
+        if test -n "@HAVE_JVIEW@"; then
+          test -z "$JAVA_VERBOSE" || echo jview "$@"
+          exec jview "$@"
+        else
+          echo 'Java virtual machine not found, try installing gij or set $JAVA, then reconfigure' 1>&2
+          exit 1
+        fi
+      fi
+    fi
+  fi
+fi
index 94cc14e91c0dbdd1dbde90847c9111e5f7f9c996..037c3104c57e7e6602ba78e77f7212966b033d60 100644 (file)
@@ -1,3 +1,9 @@
+2001-09-08  Bruno Haible  <haible@clisp.cons.org>
+
+       * javacomp.m4: New file.
+       * javaexec.m4: New file.
+       * Makefile.am (EXTRA_DIST): Add them.
+
 2001-09-06  Bruno Haible  <haible@clisp.cons.org>
 
        * setenv.m4: New file.
index ce5c3cc7da8f63942a0b67fe16dcf84af727b0bb..825b22a5932ce8ce3b0a8e3494cafa6fb369fca5 100644 (file)
@@ -8,6 +8,7 @@ aclocal_DATA = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.
 #   |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012'
 EXTRA_DIST = README \
 c-bs-a.m4 codeset.m4 flex.m4 getline.m4 gettext.m4 glibc21.m4 iconv.m4 \
-inttypes_h.m4 isc-posix.m4 lcmessage.m4 libtool.m4 mbrtowc.m4 mbstate_t.m4 \
-mbswidth.m4 mkdtemp.m4 progtest.m4 setenv.m4 setlocale.m4 signed.m4 \
-ssize_t.m4 stdbool.m4 tmpdir.m4 uintmax_t.m4 ulonglong.m4 unionwait.m4
+inttypes_h.m4 isc-posix.m4 javacomp.m4 javaexec.m4 lcmessage.m4 libtool.m4 \
+mbrtowc.m4 mbstate_t.m4 mbswidth.m4 mkdtemp.m4 progtest.m4 setenv.m4 \
+setlocale.m4 signed.m4 ssize_t.m4 stdbool.m4 tmpdir.m4 uintmax_t.m4 \
+ulonglong.m4 unionwait.m4
diff --git a/m4/javacomp.m4 b/m4/javacomp.m4
new file mode 100644 (file)
index 0000000..6aef360
--- /dev/null
@@ -0,0 +1,56 @@
+#serial 1
+
+# Prerequisites of javacomp.sh.
+# Sets HAVE_JAVACOMP to nonempty if javacomp.sh will work.
+
+AC_DEFUN([gt_JAVACOMP],
+[
+  AC_MSG_CHECKING([for Java compiler])
+  AC_EGREP_CPP(yes, [
+#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
+  yes
+#endif
+], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
+  HAVE_JAVACOMP=1
+  if test -n "$JAVAC"; then
+    ac_result="$JAVAC"
+  else
+    if gcj --version >/dev/null 2>/dev/null; then
+      HAVE_GCJ=1
+      ac_result="gcj -C"
+    else
+      if (javac -version >/dev/null 2>/dev/null || test $? = 1); then
+        HAVE_JAVAC=1
+        ac_result="javac"
+      else
+        if (jikes >/dev/null 2>/dev/null || test $? = 1) && (
+            # See if the existing CLASSPATH is sufficient to make jikes work.
+            cat > conftest.java <<EOF
+public class conftest {
+  public static void main (String[] args) {
+  }
+}
+EOF
+            unset JAVA_HOME
+            jikes conftest.java
+            error=$?
+            rm -f conftest.java conftest.class
+            exit $?
+           ); then
+          HAVE_JIKES=1
+          ac_result="jikes"
+        else
+          HAVE_JAVACOMP=
+          ac_result="no"
+        fi
+      fi
+    fi
+  fi
+  AC_MSG_RESULT([$ac_result])
+  AC_SUBST(JAVAC)
+  AC_SUBST(CLASSPATH)
+  AC_SUBST(CLASSPATH_SEPARATOR)
+  AC_SUBST(HAVE_GCJ)
+  AC_SUBST(HAVE_JAVAC)
+  AC_SUBST(HAVE_JIKES)
+])
diff --git a/m4/javaexec.m4 b/m4/javaexec.m4
new file mode 100644 (file)
index 0000000..99604ae
--- /dev/null
@@ -0,0 +1,49 @@
+#serial 1
+
+# Prerequisites of javaexec.sh.
+# Sets HAVE_JAVAEXEC to nonempty if javaexec.sh will work.
+
+AC_DEFUN([gt_JAVAEXEC],
+[
+  AC_MSG_CHECKING([for Java virtual machine])
+  AC_EGREP_CPP(yes, [
+#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
+  yes
+#endif
+], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
+  HAVE_JAVAEXEC=1
+  if test -n "$JAVA"; then
+    ac_result="$JAVA"
+  else
+    if gij --version >/dev/null 2>/dev/null; then
+      HAVE_GIJ=1
+      ac_result="gij"
+    else
+      if java -version >/dev/null 2>/dev/null; then
+        HAVE_JAVA_JVM=1
+        ac_result="java"
+      else
+        if (jre >/dev/null 2>/dev/null || test $? = 1); then
+          HAVE_JRE=1
+          ac_result="jre"
+        else
+          if (jview -? >/dev/null 2>/dev/null || test $? = 1); then
+            HAVE_JVIEW=1
+            ac_result="jview"
+          else
+            HAVE_JAVAEXEC=
+            ac_result="no"
+          fi
+        fi
+      fi
+    fi
+  fi
+  AC_MSG_RESULT([$ac_result])
+  AC_SUBST(JAVA)
+  AC_SUBST(CLASSPATH)
+  AC_SUBST(CLASSPATH_SEPARATOR)
+  AC_SUBST(HAVE_GIJ)
+  AC_SUBST(HAVE_JAVA_JVM)
+  AC_SUBST(HAVE_JRE)
+  AC_SUBST(HAVE_JVIEW)
+])