[cp-patches] FYI: Support GCJ fully as JAVAC

Andrew John Hughes gnu_andrew at member.fsf.org
Sat Sep 13 03:07:02 UTC 2008


GCJ has quite different command line options from
javac and ecj, so we need slightly different syntax
to support it.  This patch adds a check on $JAVAC --version
to see if gcj is in use.  If it is, appropriate JAVAC
commands are used instead.

ChangeLog:

2008-09-13  Andrew John Hughes  <gnu_andrew at member.fsf.org>

	* examples/Makefile.am,
	* lib/Makefile.am:
	Add GCJ rules.
	* m4/ac_prog_javac.m4:
	Check whether JAVAC is gcj.
	* m4/ac_prog_javac_works.m4:
	Add GCJ rules.
	* m4/acinclude.m4:
	Don't bother checking for -J
	if using GCJ.
	* tools/Makefile.am:
	Add GCJ rules.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
-------------- next part --------------
Index: examples/Makefile.am
===================================================================
RCS file: /sources/classpath/classpath/examples/Makefile.am,v
retrieving revision 1.27
diff -u -u -r1.27 Makefile.am
--- examples/Makefile.am	27 Jun 2008 00:18:39 -0000	1.27
+++ examples/Makefile.am	13 Sep 2008 03:03:20 -0000
@@ -1,7 +1,11 @@
 ## Input file for automake to generate the Makefile.in used by configure
 GLIBJ_CLASSPATH='$(top_builddir)/lib/glibj.zip'
 
+if GCJ_JAVAC
+JCOMPILER = $(JAVAC) $(JAVACFLAGS) -fsource=1.5 -ftarget=1.5 --encoding=UTF-8 --bootclasspath=$(GLIBJ_CLASSPATH) --classpath='$(top_builddir)/tools/tools.zip'
+else
 JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath '$(top_builddir)/tools/tools.zip'
+endif
 
 # All our example java source files
 EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*/*.java
Index: lib/Makefile.am
===================================================================
RCS file: /sources/classpath/classpath/lib/Makefile.am,v
retrieving revision 1.148
diff -u -u -r1.148 Makefile.am
--- lib/Makefile.am	27 Jun 2008 00:18:39 -0000	1.148
+++ lib/Makefile.am	13 Sep 2008 03:03:27 -0000
@@ -8,7 +8,11 @@
 compile_classpath = $(vm_classes):$(top_srcdir):$(top_srcdir)/external/w3c_dom:$(top_srcdir)/external/sax:$(top_srcdir)/external/relaxngDatatype:$(top_srcdir)/external/jsr166:.:$(PATH_TO_GLIBJ_ZIP):$(PATH_TO_ESCHER)
 
 # handling source to bytecode compiler programs like gcj, jikes  and kjc
+if GCJ_JAVAC
+JCOMPILER = $(JAVAC) $(JAVACFLAGS) -fsource=1.5 -ftarget=1.5 --bootclasspath='' --classpath=$(compile_classpath) -d . @classes
+else
 JCOMPILER = $(JAVAC) $(JAVACFLAGS) $(JAVAC_MEM_OPT) -source 1.5 -target 1.5 -bootclasspath '' -classpath $(compile_classpath) -d . @classes
+endif
 
 if CREATE_COLLECTIONS
 COLLECTIONS = collections.jar
Index: m4/ac_prog_javac.m4
===================================================================
RCS file: /sources/classpath/classpath/m4/ac_prog_javac.m4,v
retrieving revision 1.5
diff -u -u -r1.5 ac_prog_javac.m4
--- m4/ac_prog_javac.m4	21 Jun 2008 19:51:19 -0000	1.5
+++ m4/ac_prog_javac.m4	13 Sep 2008 03:03:27 -0000
@@ -38,12 +38,20 @@
 AC_REQUIRE([AC_EXEEXT])dnl
 ECJ_OPTS="-warn:-deprecation,serial,unusedImport"
 JAVAC_OPTS="-Xlint:unchecked,cast,divzero,empty,finally,overrides"
+GCJ_OPTS="-g"
 if test "x$JAVAPREFIX" = x; then
         test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, ["ecj$EXEEXT $ECJ_OPTS"] ["ecj-3.3$EXEEXT $ECJ_OPTS"] ["ecj-3.2$EXEEXT $ECJ_OPTS"] ["javac$EXEEXT $JAVAC_OPTS"] "gcj$EXEEXT -C")
 else
         test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, ["ecj$EXEEXT $ECJ_OPTS"] ["ecj-3.3$EXEEXT $ECJ_OPTS"] ["ecj-3.2$EXEEXT $ECJ_OPTS"] ["javac$EXEEXT $JAVAC_OPTS"] "gcj$EXEEXT -C", $JAVAPREFIX)
 fi
 test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
+AC_CACHE_CHECK([if $JAVAC is a version of gcj], ac_cv_prog_javac_is_gcj, [
+if $JAVAC --version | grep gcj > /dev/null; then
+  ac_cv_prog_javac_is_gcj=yes;
+  JAVAC="$JAVAC $GCJ_OPTS";
+fi])
+AC_SUBST(JAVAC_IS_GCJ, $ac_cv_prog_javac_is_gcj)
+AM_CONDITIONAL(GCJ_JAVAC, test x"${JAVAC_IS_GCJ}" = xyes)
 AC_PROG_JAVAC_WORKS
 AC_PROVIDE([$0])dnl
 ])
Index: m4/ac_prog_javac_works.m4
===================================================================
RCS file: /sources/classpath/classpath/m4/ac_prog_javac_works.m4,v
retrieving revision 1.2
diff -u -u -r1.2 ac_prog_javac_works.m4
--- m4/ac_prog_javac_works.m4	15 Feb 2008 21:13:02 -0000	1.2
+++ m4/ac_prog_javac_works.m4	13 Sep 2008 03:03:28 -0000
@@ -31,7 +31,12 @@
   }
 }
 EOF
-if AC_TRY_COMMAND($JAVAC $JAVACFLAGS -source 1.5 -target 1.5 $JAVA_TEST) >/dev/null 2>&1; then
+if test x$JAVAC_IS_GCJ = xyes; then
+  CMD="$JAVAC $JAVACFLAGS -fsource=1.5 -ftarget=1.5 $JAVA_TEST"
+else
+  CMD="$JAVAC $JAVACFLAGS -source 1.5 -target 1.5 $JAVA_TEST"
+fi
+if AC_TRY_COMMAND($CMD) >/dev/null 2>&1; then
   ac_cv_prog_javac_works=yes
 else
   AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
Index: m4/acinclude.m4
===================================================================
RCS file: /sources/classpath/classpath/m4/acinclude.m4,v
retrieving revision 1.40
diff -u -u -r1.40 acinclude.m4
--- m4/acinclude.m4	21 Aug 2008 20:46:20 -0000	1.40
+++ m4/acinclude.m4	13 Sep 2008 03:03:28 -0000
@@ -257,14 +257,16 @@
     }
   }
 EOF
-  AC_MSG_CHECKING([whether javac supports -J])
-  $JAVAC $JAVACFLAGS -J-Xmx768M -sourcepath '' $JAVA_TEST
-  javac_result=$?
-  if test "x$javac_result" = "x0"; then
-    AC_MSG_RESULT([yes])
-    JAVAC_MEM_OPT="-J-Xmx768M"
-  else
-    AC_MSG_RESULT([no])
+  if test x$JAVAC_IS_GCJ != xyes; then
+    AC_MSG_CHECKING([whether javac supports -J])
+    $JAVAC $JAVACFLAGS -J-Xmx768M -sourcepath '' $JAVA_TEST
+    javac_result=$?
+    if test "x$javac_result" = "x0"; then
+      AC_MSG_RESULT([yes])
+      JAVAC_MEM_OPT="-J-Xmx768M"
+    else
+      AC_MSG_RESULT([no])
+    fi
   fi
   rm -f $JAVA_TEST $CLASS_TEST
   AC_SUBST(JAVAC_MEM_OPT)
Index: tools/Makefile.am
===================================================================
RCS file: /sources/classpath/classpath/tools/Makefile.am,v
retrieving revision 1.54
diff -u -u -r1.54 Makefile.am
--- tools/Makefile.am	21 Aug 2008 00:32:04 -0000	1.54
+++ tools/Makefile.am	13 Sep 2008 03:03:30 -0000
@@ -4,7 +4,11 @@
 GLIBJ_CLASSPATH=asm
 
 # Setup the compiler to use the GNU Classpath library we just built.
+if GCJ_JAVAC
+JCOMPILER = $(JAVAC) $(JAVACFLAGS) -fsource=1.5 -ftarget=1.5 --encoding=UTF-8 --bootclasspath=$(GLIBJ_BOOTCLASSPATH) --classpath=$(GLIBJ_CLASSPATH)
+else
 JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_BOOTCLASSPATH) -classpath $(GLIBJ_CLASSPATH)
+endif
 
 if CREATE_GJDOC
 USE_JAVAC_FLAGS = -classpath $(CLASSPATH):$(srcdir):$(ANTLR_JAR):generated:. $(JAVAC_FLAGS)


More information about the Classpath-patches mailing list