From: Bruno Haible Date: Tue, 18 Sep 2001 12:21:19 +0000 (+0000) Subject: Support for compiling and executing Java programs. X-Git-Tag: v0.11~488 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9a917abf20e510d398250d4c432ab3fe0922dcf;p=thirdparty%2Fgettext.git Support for compiling and executing Java programs. --- diff --git a/ChangeLog b/ChangeLog index 01d75f497..be67ccc8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-09-08 Bruno Haible + + * 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 * configure.in: Add AC_REPLACE_FUNCS of strpbrk. diff --git a/configure.in b/configure.in index f1437028d..25f3f8353 100644 --- a/configure.in +++ b/configure.in @@ -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 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]) diff --git a/lib/ChangeLog b/lib/ChangeLog index 1560eca4e..7b37a0c44 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2001-09-08 Bruno Haible + + * javacomp.sh.in: New file. + * javaexec.sh.in: New file. + 2001-09-06 Bruno Haible * javacomp.h: New file. diff --git a/lib/javacomp.sh.in b/lib/javacomp.sh.in new file mode 100644 index 000000000..f1d07dc48 --- /dev/null +++ b/lib/javacomp.sh.in @@ -0,0 +1,73 @@ +#!/bin/sh +# Compile a Java program. + +# Copyright (C) 2001 Free Software Foundation, Inc. +# Written by Bruno Haible , 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 index 000000000..0c14c7523 --- /dev/null +++ b/lib/javaexec.sh.in @@ -0,0 +1,69 @@ +#!/bin/sh +# Execute a Java program. + +# Copyright (C) 2001 Free Software Foundation, Inc. +# Written by Bruno Haible , 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 diff --git a/m4/ChangeLog b/m4/ChangeLog index 94cc14e91..037c3104c 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,9 @@ +2001-09-08 Bruno Haible + + * javacomp.m4: New file. + * javaexec.m4: New file. + * Makefile.am (EXTRA_DIST): Add them. + 2001-09-06 Bruno Haible * setenv.m4: New file. diff --git a/m4/Makefile.am b/m4/Makefile.am index ce5c3cc7d..825b22a59 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -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 index 000000000..6aef360e5 --- /dev/null +++ b/m4/javacomp.m4 @@ -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 </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) +])