From: Bruno Haible Date: Wed, 17 Jul 2002 10:29:58 +0000 (+0000) Subject: Create Java executables if gcj is found. X-Git-Tag: v0.11.3~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa7725d180f459a72285c934d1a9daa9cda8f311;p=thirdparty%2Fgettext.git Create Java executables if gcj is found. --- diff --git a/ChangeLog b/ChangeLog index cb1759391..d48d42a18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-07-16 Bruno Haible + + * configure.in: Call gt_GCJ and set BUILDJAVAEXE. + 2002-07-16 Bruno Haible * config.guess, config.sub: Update to GNU version 2002-07-09. diff --git a/configure.in b/configure.in index d47322bcb..90e11543a 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.52) AC_INIT AC_CONFIG_SRCDIR(src/msgfmt.c) -AM_INIT_AUTOMAKE(gettext, 0.11.3-pre2) -RELEASE_DATE=2002-04-24 dnl in "date +%Y-%m-%d" format +AM_INIT_AUTOMAKE(gettext, 0.11.3) +RELEASE_DATE=2002-07-17 dnl in "date +%Y-%m-%d" format AM_CONFIG_HEADER(config.h) dnl Checks for programs. @@ -12,6 +12,14 @@ AC_PROG_INSTALL AC_PROG_YACC gt_PROG_LEX +gt_GCJ +if test -n "$HAVE_GCJ"; then + BUILDJAVAEXE=yes +else + BUILDJAVAEXE=no +fi +AC_SUBST(BUILDJAVAEXE) + gt_JAVACOMP AC_CHECK_PROG(JAR, jar, jar) if test -n "$HAVE_JAVACOMP" && test -n "$JAR"; then diff --git a/lib/ChangeLog b/lib/ChangeLog index 7454ccc96..cca7ac55c 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,11 @@ +2002-07-16 Bruno Haible + + * javaexec.h (execute_java_class): Add argument exe_dir. + * javaexec.c (execute_java_class): Add argument exe_dir. If given, + attempt to run a native executable. + * Makefile.am (DEFS): Define EXEEXT. + * javacomp.sh.in: Use HAVE_GCJ_C instead of HAVE_GCJ. + 2002-06-15 Bruno Haible * javacomp.c (compile_java_class): Ignore gcj versions that start with diff --git a/lib/Makefile.am b/lib/Makefile.am index 2c4b89323..3f89a1351 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -116,7 +116,7 @@ $(LIBADD_SOURCE) $(UNUSED_SOURCE) \ stdbool.h.in \ gen-lbrkprop.c 3level.h Combining.txt -DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@ +DEFS = -DLIBDIR=\"$(libdir)\" -DEXEEXT=\"$(EXEEXT)\" @DEFS@ INCLUDES = -I. -I$(srcdir) -I.. -I../intl -I$(top_srcdir)/intl diff --git a/lib/javacomp.sh.in b/lib/javacomp.sh.in index f1d07dc48..e21a1af3a 100644 --- a/lib/javacomp.sh.in +++ b/lib/javacomp.sh.in @@ -1,7 +1,7 @@ #!/bin/sh # Compile a Java program. -# Copyright (C) 2001 Free Software Foundation, Inc. +# Copyright (C) 2001-2002 Free Software Foundation, Inc. # Written by Bruno Haible , 2001. # # This program is free software; you can redistribute it and/or modify @@ -42,7 +42,7 @@ if test -n "$CONF_JAVAC"; then exec $CONF_JAVAC "$@" else unset JAVA_HOME - if test -n "@HAVE_GCJ@"; then + if test -n "@HAVE_GCJ_C@"; then CLASSPATH="$CLASSPATH" export CLASSPATH test -z "$JAVA_VERBOSE" || echo gcj -C "$@" diff --git a/lib/javaexec.c b/lib/javaexec.c index fd11f5c93..092396c6e 100644 --- a/lib/javaexec.c +++ b/lib/javaexec.c @@ -1,5 +1,5 @@ /* Execute a Java program. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001-2002 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -31,6 +31,7 @@ #include "execute.h" #include "xsetenv.h" #include "sh-quote.h" +#include "pathname.h" #include "xmalloc.h" #include "error.h" #include "gettext.h" @@ -75,6 +76,7 @@ bool execute_java_class (class_name, classpaths, classpaths_count, use_minimal_classpath, + exe_dir, args, verbose, quiet, executer, private_data) @@ -82,6 +84,7 @@ execute_java_class (class_name, const char * const *classpaths; unsigned int classpaths_count; bool use_minimal_classpath; + const char *exe_dir; const char * const *args; bool verbose; bool quiet; @@ -92,6 +95,46 @@ execute_java_class (class_name, unsigned int nargs; char *old_JAVA_HOME; + /* Count args. */ + { + const char * const *arg; + + for (nargs = 0, arg = args; *arg != NULL; nargs++, arg++) + ; + } + + /* First, try a class compiled to a native code executable. */ + if (exe_dir != NULL) + { + char *exe_pathname = concatenated_pathname (exe_dir, class_name, EXEEXT); + char *old_classpath; + char **argv = (char **) alloca ((1 + nargs + 1) * sizeof (char *)); + unsigned int i; + + /* Set CLASSPATH. */ + old_classpath = + set_classpath (classpaths, classpaths_count, use_minimal_classpath, + verbose); + + argv[0] = exe_pathname; + for (i = 0; i <= nargs; i++) + argv[1 + i] = (char *) args[i]; + + if (verbose) + { + char *command = shell_quote_argv (argv); + printf ("%s\n", command); + free (command); + } + + err = executer (class_name, exe_pathname, argv, private_data); + + /* Reset CLASSPATH. */ + reset_classpath (old_classpath); + + goto done1; + } + { const char *java = getenv ("JAVA"); if (java != NULL && java[0] != '\0') @@ -152,14 +195,6 @@ execute_java_class (class_name, } } - /* Count args. */ - { - const char * const *arg; - - for (nargs = 0, arg = args; *arg != NULL; nargs++, arg++) - ; - } - /* Unset the JAVA_HOME environment variable. */ old_JAVA_HOME = getenv ("JAVA_HOME"); if (old_JAVA_HOME != NULL) diff --git a/lib/javaexec.h b/lib/javaexec.h index 8c4a16769..9f33aacfe 100644 --- a/lib/javaexec.h +++ b/lib/javaexec.h @@ -1,5 +1,5 @@ /* Execute a Java program. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001-2002 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ typedef bool execute_fn PARAMS ((const char *progname, use a minimal one. This is likely to reduce possible problems if the user's CLASSPATH contains garbage or a classes.zip file of the wrong Java version. + exe_dir is a directory that may contain a native executable for the class. args is a NULL terminated list of arguments to be passed to the program. If verbose, the command to be executed will be printed. Then the command is passed to the execute function together with the @@ -42,6 +43,7 @@ extern bool execute_java_class PARAMS ((const char *class_name, const char * const *classpaths, unsigned int classpaths_count, bool use_minimal_classpath, + const char *exe_dir, const char * const *args, bool verbose, bool quiet, execute_fn *executer, diff --git a/m4/ChangeLog b/m4/ChangeLog index 7b905ac69..739f17d0f 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,9 @@ +2002-07-16 Bruno Haible + + * gcj.m4: New file. + * Makefile.am (EXTRA_DIST): Add it. + * javacomp.m4 (gt_JAVACOMP): Set HAVE_GCJ_C instead of HAVE_GCJ. + 2002-07-14 Bruno Haible * libtool.m4 (_LT_AC_LTCONFIG_HACK): Add support for GNU/FreeBSD. diff --git a/m4/Makefile.am b/m4/Makefile.am index 7ebe8b8ce..53203cab4 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -7,10 +7,10 @@ aclocal_DATA = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 isc-posix.m4 # find . -type f -name '*.m4' -printf '%f\n'|sort |fmt |tr '\012' @ \ # |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012' EXTRA_DIST = README \ -backupfile.m4 c-bs-a.m4 codeset.m4 error.m4 flex.m4 fnmatch.m4 getline.m4 \ -gettext.m4 glibc21.m4 hostname.m4 iconv.m4 intdiv0.m4 inttypes_h.m4 \ -isc-posix.m4 javacomp.m4 javaexec.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 \ -lib-prefix.m4 libtool.m4 mbrtowc.m4 mbstate_t.m4 mbswidth.m4 mkdtemp.m4 \ -progtest.m4 setenv.m4 setlocale.m4 siginfo.m4 signalblocking.m4 signed.m4 \ -ssize_t.m4 stdbool.m4 stdint_h.m4 tmpdir.m4 uintmax_t.m4 ulonglong.m4 \ -unionwait.m4 +backupfile.m4 c-bs-a.m4 codeset.m4 error.m4 flex.m4 fnmatch.m4 gcj.m4 \ +getline.m4 gettext.m4 glibc21.m4 hostname.m4 iconv.m4 intdiv0.m4 \ +inttypes_h.m4 isc-posix.m4 javacomp.m4 javaexec.m4 lcmessage.m4 lib-ld.m4 \ +lib-link.m4 lib-prefix.m4 libtool.m4 mbrtowc.m4 mbstate_t.m4 mbswidth.m4 \ +mkdtemp.m4 progtest.m4 setenv.m4 setlocale.m4 siginfo.m4 signalblocking.m4 \ +signed.m4 ssize_t.m4 stdbool.m4 stdint_h.m4 tmpdir.m4 uintmax_t.m4 \ +ulonglong.m4 unionwait.m4 diff --git a/m4/gcj.m4 b/m4/gcj.m4 new file mode 100644 index 000000000..af167071e --- /dev/null +++ b/m4/gcj.m4 @@ -0,0 +1,76 @@ +# gcj.m4 serial 1 (gettext-0.11.3) +dnl Copyright (C) 2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# Check for a Java compiler that creates executables. +# Assigns the variables GCJ and GCJFLAGS, and set HAVE_GCJ to nonempty, +# if found. Otherwise sets HAVE_GCJ to empty. + +AC_DEFUN([gt_GCJ], +[ + AC_ARG_VAR([GCJ], [Java native code compiler command]) + AC_ARG_VAR([GCJFLAGS], [Java native code compiler flags]) + + AC_MSG_CHECKING([for Java to native code compiler]) + # Search for the gcj command or use the one provided by the user. + if test -z "$GCJ"; then + pushdef([AC_MSG_CHECKING],[:])dnl + pushdef([AC_CHECKING],[:])dnl + pushdef([AC_MSG_RESULT],[:])dnl + AC_CHECK_PROGS(GCJ, [gcj], [none]) + popdef([AC_MSG_RESULT])dnl + popdef([AC_CHECKING])dnl + popdef([AC_MSG_CHECKING])dnl + fi + # Choose GCJFLAGS or use the one provided by the user. + if test "$GCJ" != none; then + test "${GCJFLAGS+set}" != set || GCJFLAGS="-O2 -g" + fi + # Check whether the version is ok and it can create executables. + ac_gcj_link="$GCJ $GCJFLAGS conftest.java --main=conftest -o conftest$ac_exeext" +changequote(,)dnl + if test "$GCJ" != none \ + && $GCJ --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | grep '^[3-9]' >/dev/null \ + && ( + # See if libgcj.so is well installed and if exception handling works. + cat > conftest.java </dev/null 2>&1; echo $?` + test $error = 0 || error=1 + rm -f core conftest.core + fi + rm -f conftest.java conftest$ac_exeext + exit $error + ); then + : + else + GCJ=none + fi + AC_MSG_RESULT($GCJ) + if test "$GCJ" != none; then + HAVE_GCJ=1 + else + HAVE_GCJ= + fi + AC_SUBST(GCJ) + AC_SUBST(GCJFLAGS) + AC_SUBST(HAVE_GCJ) +]) diff --git a/m4/javacomp.m4 b/m4/javacomp.m4 index 2286540bb..3a74a2bec 100644 --- a/m4/javacomp.m4 +++ b/m4/javacomp.m4 @@ -46,7 +46,7 @@ EOF rm -f conftest.java conftest.class exit $error ); then - HAVE_GCJ=1 + HAVE_GCJ_C=1 ac_result="gcj -C" else if test -n "$HAVE_JAVAC_IN_PATH" \ @@ -85,7 +85,7 @@ changequote([,])dnl AC_SUBST(JAVAC) AC_SUBST(CLASSPATH) AC_SUBST(CLASSPATH_SEPARATOR) - AC_SUBST(HAVE_GCJ) + AC_SUBST(HAVE_GCJ_C) AC_SUBST(HAVE_JAVAC) AC_SUBST(HAVE_JIKES) ]) diff --git a/src/ChangeLog b/src/ChangeLog index 9653d8cef..9e8c0ad07 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2002-07-16 Bruno Haible + + * read-java.c (msgdomain_read_java): Pass $GETTEXTJEXEDIR to + execute_java_class. + * urlget.c (fetch): Likewise. + * Makefile.am (DEFS): Define USEJEXE and GETTEXTJEXEDIR. + (GCJ, GCJFLAGS, USEJEXE): New variables. + (all-java*): Renamed to take into account BUILDJAVAEXE. + (install-data-java*): Likewise. + (installdirs-java*): Likewise. + (uninstall-java*): Likewise. + (install-exec-*): New rules. + (gnu.gettext.DumpResource, gnu.gettext.GetURL): New rules. + (CLEANFILES): Add them. + 2002-07-16 Bruno Haible * project-id: Make it work when the configure file was generated by diff --git a/src/Makefile.am b/src/Makefile.am index a4fc1ad2f..613b5865f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,13 +46,16 @@ projectsdir = $(pkgdatadir)/projects INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libuniname \ -I../lib -I$(top_srcdir)/lib -I../intl -I$(top_srcdir)/intl -DEFS = -DLOCALEDIR=\"$(localedir)\" -DGETTEXTJAR=\"$(jardir)/gettext.jar\" \ +DEFS = -DLOCALEDIR=\"$(localedir)\" -DUSEJEXE=$(USEJEXE) \ +-DGETTEXTJEXEDIR=\"$(pkglibdir)\" -DGETTEXTJAR=\"$(jardir)/gettext.jar\" \ -DLIBDIR=\"$(libdir)\" -DGETTEXTDATADIR=\"$(pkgdatadir)\" \ -DPROJECTSDIR=\"$(projectsdir)\" @DEFS@ LDADD = ../lib/libgettextlib.la @LTLIBINTL@ SED = sed YACC = @YACC@ -d +GCJ = @GCJ@ +GCJFLAGS = @GCJFLAGS@ JAR = @JAR@ JAVACOMP = $(SHELL) ../lib/javacomp.sh @@ -178,9 +181,21 @@ uninstall-local: # Special rules for Java compilation. -all-local: all-java-@BUILDJAVA@ -all-java-no: -all-java-yes: gettext.jar +USEJEXE = $(USEJEXE_@BUILDJAVAEXE@) +USEJEXE_yes = 1 +USEJEXE_no = 0 + +all-local: all-java-@BUILDJAVAEXE@ +all-java-yes: gnu.gettext.DumpResource$(EXEEXT) gnu.gettext.GetURL$(EXEEXT) +all-java-no: all-java-no-@BUILDJAVA@ +all-java-no-yes: gettext.jar +all-java-no-no: + +gnu.gettext.DumpResource$(EXEEXT): $(srcdir)/gnu/gettext/DumpResource.java + $(GCJ) $(GCJFLAGS) $(srcdir)/gnu/gettext/DumpResource.java --main=gnu.gettext.DumpResource -o $@ + +gnu.gettext.GetURL$(EXEEXT): $(srcdir)/gnu/gettext/GetURL.java + $(GCJ) $(GCJFLAGS) $(srcdir)/gnu/gettext/GetURL.java --main=gnu.gettext.GetURL -o $@ gnu/gettext/DumpResource.class: $(srcdir)/gnu/gettext/DumpResource.java $(JAVACOMP) -d . $(srcdir)/gnu/gettext/DumpResource.java @@ -191,22 +206,39 @@ gnu/gettext/GetURL.class: $(srcdir)/gnu/gettext/GetURL.java gettext.jar: gnu/gettext/DumpResource.class gnu/gettext/GetURL.class $(JAR) cf $@ gnu/gettext/DumpResource*.class gnu/gettext/GetURL*.class -CLEANFILES = gettext.jar gnu/gettext/*.class +CLEANFILES = gnu.gettext.DumpResource$(EXEEXT) gnu.gettext.GetURL$(EXEEXT) \ + gettext.jar gnu/gettext/*.class -install-data-local: install-java-@BUILDJAVA@ -install-java-no: -install-java-yes: all-java-yes +install-exec-local: install-exec-java-@BUILDJAVAEXE@ +install-exec-java-yes: all-java-yes + $(mkinstalldirs) $(DESTDIR)$(libdir)/$(PACKAGE) + $(INSTALL_PROGRAM) gnu.gettext.DumpResource$(EXEEXT) $(DESTDIR)$(libdir)/$(PACKAGE)/gnu.gettext.DumpResource$(EXEEXT) + $(INSTALL_PROGRAM) gnu.gettext.GetURL$(EXEEXT) $(DESTDIR)$(libdir)/$(PACKAGE)/gnu.gettext.GetURL$(EXEEXT) +install-exec-java-no: + +install-data-local: install-data-java-@BUILDJAVAEXE@ +install-data-java-yes: +install-data-java-no: install-data-java-no-@BUILDJAVA@ +install-data-java-no-yes: all-java-no-yes $(INSTALL_DATA) gettext.jar $(DESTDIR)$(jardir)/gettext.jar +install-data-java-no-no: -installdirs-local: installdirs-java-@BUILDJAVA@ -installdirs-java-no: +installdirs-local: installdirs-java-@BUILDJAVAEXE@ installdirs-java-yes: + $(mkinstalldirs) $(DESTDIR)$(libdir)/$(PACKAGE) +installdirs-java-no: installdirs-java-no-@BUILDJAVA@ +installdirs-java-no-yes: $(mkinstalldirs) $(DESTDIR)$(jardir) +installdirs-java-no-no: -uninstall-local: uninstall-java-@BUILDJAVA@ -uninstall-java-no: +uninstall-local: uninstall-java-@BUILDJAVAEXE@ uninstall-java-yes: + $(RM) $(DESTDIR)$(libdir)/$(PACKAGE)/gnu.gettext.DumpResource$(EXEEXT) + $(RM) $(DESTDIR)$(libdir)/$(PACKAGE)/gnu.gettext.GetURL$(EXEEXT) +uninstall-java-no: uninstall-java-no-@BUILDJAVA@ +uninstall-java-no-yes: $(RM) $(DESTDIR)$(jardir)/gettext.jar +uninstall-java-no-no: # Special rules for Tcl auxiliary program. diff --git a/src/read-java.c b/src/read-java.c index 6ca86a698..3528bec60 100644 --- a/src/read-java.c +++ b/src/read-java.c @@ -1,5 +1,5 @@ /* Reading Java ResourceBundles. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001-2002 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -100,10 +100,21 @@ msgdomain_read_java (resource_name, locale_name) const char *locale_name; { const char *class_name = "gnu.gettext.DumpResource"; + const char *gettextjexedir; const char *gettextjar; const char *args[3]; struct locals locals; +#if USEJEXE + /* Make it possible to override the executable's location. This is + necessary for running the testsuite before "make install". */ + gettextjexedir = getenv ("GETTEXTJEXEDIR"); + if (gettextjexedir == NULL || gettextjexedir[0] == '\0') + gettextjexedir = GETTEXTJEXEDIR; +#else + gettextjexedir = NULL; +#endif + /* Make it possible to override the gettext.jar location. This is necessary for running the testsuite before "make install". */ gettextjar = getenv ("GETTEXTJAR"); @@ -127,7 +138,7 @@ msgdomain_read_java (resource_name, locale_name) /* Dump the resource and retrieve the resulting output. Here we use the user's CLASSPATH, not a minimal one, so that the resource can be found. */ - if (execute_java_class (class_name, &gettextjar, 1, false, + if (execute_java_class (class_name, &gettextjar, 1, false, gettextjexedir, args, verbose, false, execute_and_read_po_output, &locals)) diff --git a/src/urlget.c b/src/urlget.c index 356410bce..51d3d5c7f 100644 --- a/src/urlget.c +++ b/src/urlget.c @@ -1,5 +1,5 @@ /* Get the contents of an URL. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001-2002 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -248,9 +248,20 @@ fetch (url, file) /* First try: using Java. */ { const char *class_name = "gnu.gettext.GetURL"; + const char *gettextjexedir; const char *gettextjar; const char *args[2]; +#if USEJEXE + /* Make it possible to override the executable's location. This is + necessary for running the testsuite before "make install". */ + gettextjexedir = getenv ("GETTEXTJEXEDIR"); + if (gettextjexedir == NULL || gettextjexedir[0] == '\0') + gettextjexedir = GETTEXTJEXEDIR; +#else + gettextjexedir = NULL; +#endif + /* Make it possible to override the gettext.jar location. This is necessary for running the testsuite before "make install". */ gettextjar = getenv ("GETTEXTJAR"); @@ -262,7 +273,7 @@ fetch (url, file) args[1] = NULL; /* Fetch the URL's contents. */ - if (execute_java_class (class_name, &gettextjar, 1, true, + if (execute_java_class (class_name, &gettextjar, 1, true, gettextjexedir, args, false, true, execute_it, NULL) == 0) diff --git a/tests/ChangeLog b/tests/ChangeLog index 001402f76..2c847d63c 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2002-07-16 Bruno Haible + + * msgunfmt-2: Set GETTEXTJEXEDIR. + 2002-06-14 Bruno Haible * msgfmt-11: New file. diff --git a/tests/msgunfmt-2 b/tests/msgunfmt-2 index 3a5814dad..a27cf4550 100755 --- a/tests/msgunfmt-2 +++ b/tests/msgunfmt-2 @@ -37,7 +37,7 @@ ${MSGFMT} -j -d . -r prog -l fr fr.po || exit 1 tmpfiles="$tmpfiles prog.out" : ${MSGUNFMT=msgunfmt} -GETTEXTJAR=../src/gettext.jar \ +GETTEXTJEXEDIR=../src GETTEXTJAR=../src/gettext.jar \ ${MSGUNFMT} --java -d . -r prog -l fr -o prog.out || exit 1 tmpfiles="$tmpfiles prog.sort"