This patch makes Classpath use the AC_PROG_JAVAC macros from the autoconf archive, as Kaffe now does (see Dalibor's recent patches). Instead of detecting both ecj and javac, the build will now test for ecj, javac and gcj in that order, and use the first one. It tests the chosen compiler for 1.5 compatibility (a local extension) and we also retain the -J test. You can override the choice with JAVAC=<compiler of choice> and add options with JAVACFLAGS=<flags of choice>.
ChangeLog: 2008-02-10 Andrew John Hughes <[EMAIL PROTECTED]> * NEWS: Mention javah and javac build changes. * configure.ac: Call AC_PROG_JAVAC and CLASSPATH_JAVAC_MEM_CHECK instead of CLASSPATH_FIND_JAVAC. * examples/Makefile.am: Simplify compiler choice to just use JAVAC. * lib/Makefile.am: Likewise, but with JAVAC_MEM_OPT too. * m4/ac_prog_javac.m4: New file. * m4/ac_prog_javac_works.m4: Likewise. * m4/acinclude.m4: (CLASSPATH_FIND_JAVAC): Removed. (CLASSPATH_WITH_GCJ): Removed. (CLASSPATH_CHECK_GCJ): Removed. (CLASSPATH_WITH_JIKES): Removed. (CLASSPATH_CHECK_JIKES): Removed. (CLASSPATH_WITH_KJC): Removed. (CLASSPATH_CHECK_KJC): Removed. (CLASSPATH_WITH_ECJ): Removed. (CLASSPATH_CHECK_ECJ): Removed. (CLASSPATH_WITH_JAVAC): Removed. (CLASSPATH_CHECK_JAVAC): Removed. (CLASSPATH_JAVAC_MEM_CHECK): Added. * tools/Makefile.am: Simplify compiler choice to just javac. -- Andrew :-) Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... }
Index: NEWS =================================================================== RCS file: /sources/classpath/classpath/NEWS,v retrieving revision 1.188 diff -u -3 -p -u -r1.188 NEWS --- NEWS 8 Feb 2008 18:40:48 -0000 1.188 +++ NEWS 11 Feb 2008 20:56:34 -0000 @@ -1,5 +1,13 @@ New in release 0.97 +Build changes: + +* A copy of javah (to produce C header files from Java source code) +is now required to generate the files in include. +* The javac check has been changed so that it attempts to find ecj, +javac and gcj (in that order). You may override this by using +JAVAC=<preferred javac> + Runtime interface changes: * Removed VMFloat.floatToIntBits amd VMDouble.doubleToLongBits. Index: configure.ac =================================================================== RCS file: /sources/classpath/classpath/configure.ac,v retrieving revision 1.222 diff -u -3 -p -u -r1.222 configure.ac --- configure.ac 9 Feb 2008 21:16:18 -0000 1.222 +++ configure.ac 11 Feb 2008 20:56:39 -0000 @@ -728,7 +728,8 @@ if test "x${COMPILE_JNI}" = xyes; then AC_CONFIG_LINKS([$ac_config_links_1]) fi -CLASSPATH_FIND_JAVAC +AC_PROG_JAVAC +CLASSPATH_JAVAC_MEM_CHECK CLASSPATH_WITH_CLASSLIB Index: examples/Makefile.am =================================================================== RCS file: /sources/classpath/classpath/examples/Makefile.am,v retrieving revision 1.23 diff -u -3 -p -u -r1.23 Makefile.am --- examples/Makefile.am 8 Oct 2007 23:09:16 -0000 1.23 +++ examples/Makefile.am 11 Feb 2008 20:56:40 -0000 @@ -1,24 +1,7 @@ ## Input file for automake to generate the Makefile.in used by configure GLIBJ_CLASSPATH='$(top_builddir)/lib/glibj.zip' -# Setup the compiler to use the GNU Classpath library we just build -#if FOUND_GCJ -#JCOMPILER = $(GCJ) --bootclasspath '$(top_builddir)/lib' --classpath . -C -#else -#if FOUND_JIKES -#JCOMPILER = $(JIKES) -bootclasspath '' -extdirs '' -sourcepath '' --classpath $(top_builddir)/lib:. -#else -if FOUND_ECJ -JCOMPILER = $(ECJ) -1.5 -encoding UTF-8 -warn:-deprecation,serial,typeHiding,unchecked,unused,varargsCast -bootclasspath $(GLIBJ_CLASSPATH) -classpath '$(top_builddir)/tools/tools.zip' -else -if FOUND_JAVAC -JCOMPILER = $(JAVAC) -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath '$(top_builddir)/tools/tools.zip' -else -JCOMPILER = echo "No compiler found" 1>&2; exit 1 -#endif -#endif -endif -endif +JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath '$(top_builddir)/tools/tools.zip' # 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.141 diff -u -3 -p -u -r1.141 Makefile.am --- lib/Makefile.am 10 Feb 2008 23:28:11 -0000 1.141 +++ lib/Makefile.am 11 Feb 2008 20:56:51 -0000 @@ -8,31 +8,7 @@ sinclude $(JAVA_DEPEND) 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 FOUND_ECJ -JCOMPILER = $(ECJ) -1.5 -warn:-deprecation,serial,typeHiding,unchecked,unused -proceedOnError -bootclasspath '' -classpath $(compile_classpath) -d . @classes -else -if FOUND_JAVAC -JCOMPILER = $(JAVAC) $(JAVAC_OPTS) -bootclasspath '' -classpath $(compile_classpath) -d . @classes -#else -#if FOUND_GCJ -## This should never be used when gcj is the compiler. -## See the compile-classes target. -#JCOMPILER = exit 1 -#else -#if FOUND_JIKES -#JCOMPILER = $(JIKES) $(JIKESWARNINGS) +F $(JIKESENCODING) -bootclasspath '' -extdirs '' -sourcepath '' --classpath $(compile_classpath) -d . @classes -#else -#if FOUND_KJC -### FIXME: from what I can tell, kjc does not support a -encoding option. -#JCOMPILER = $(KJC) -classpath .:$(USER_CLASSLIB) -d . @classes -else -JCOMPILER = echo "No compiler found" 1>&2; exit 1 -#endif -#endif # FOUND_KJC -#endif # FOUND_GCJ -#endif # FOUND_JIKES -endif # FOUND_JAVAC -endif # FOUND_ECJ +JCOMPILER = $(JAVAC) $(JAVACFLAGS) $(JAVAC_MEM_OPT) -source 1.5 -target 1.5 -bootclasspath '' -classpath $(compile_classpath) -d . @classes if CREATE_COLLECTIONS COLLECTIONS = collections.jar Index: m4/ac_prog_javac.m4 =================================================================== RCS file: m4/ac_prog_javac.m4 diff -N m4/ac_prog_javac.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ m4/ac_prog_javac.m4 11 Feb 2008 20:56:51 -0000 @@ -0,0 +1,47 @@ +dnl @synopsis AC_PROG_JAVAC +dnl +dnl AC_PROG_JAVAC tests an existing Java compiler. It uses the +dnl environment variable JAVAC then tests in sequence various common +dnl Java compilers. For political reasons, it starts with the free +dnl ones. +dnl +dnl If you want to force a specific compiler: +dnl +dnl - at the configure.in level, set JAVAC=yourcompiler before calling +dnl AC_PROG_JAVAC +dnl +dnl - at the configure level, setenv JAVAC +dnl +dnl You can use the JAVAC variable in your Makefile.in, with @[EMAIL PROTECTED] +dnl +dnl *Warning*: its success or failure can depend on a proper setting of +dnl the CLASSPATH env. variable. +dnl +dnl TODO: allow to exclude compilers (rationale: most Java programs +dnl cannot compile with some compilers like guavac). +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java +dnl programs. It is VERY IMPORTANT that you download the whole set, +dnl some macros depend on other. Unfortunately, the autoconf archive +dnl does not support the concept of set of macros, so I had to break it +dnl for submission. The general documentation, as well as the sample +dnl configure.in, is included in the AC_PROG_JAVA macro. +dnl +dnl @category Java +dnl @author Stephane Bortzmeyer <[EMAIL PROTECTED]> +dnl @version 2000-07-19 +dnl @license GPLWithACException +dnl +dnl Modified to remove jikes by Andrew John Hughes on 2008-02-11 + +AC_DEFUN([AC_PROG_JAVAC],[ +AC_REQUIRE([AC_EXEEXT])dnl +if test "x$JAVAPREFIX" = x; then + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, ecj$EXEEXT javac$EXEEXT "gcj$EXEEXT -C") +else + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, ecj$EXEEXT javac$EXEEXT "gcj$EXEEXT -C", $JAVAPREFIX) +fi +test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) +AC_PROG_JAVAC_WORKS +AC_PROVIDE([$0])dnl +]) Index: m4/ac_prog_javac_works.m4 =================================================================== RCS file: m4/ac_prog_javac_works.m4 diff -N m4/ac_prog_javac_works.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ m4/ac_prog_javac_works.m4 11 Feb 2008 20:56:51 -0000 @@ -0,0 +1,40 @@ +dnl @synopsis AC_PROG_JAVAC_WORKS +dnl +dnl Internal use ONLY. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java +dnl programs. It is VERY IMPORTANT that you download the whole set, +dnl some macros depend on other. Unfortunately, the autoconf archive +dnl does not support the concept of set of macros, so I had to break it +dnl for submission. The general documentation, as well as the sample +dnl configure.in, is included in the AC_PROG_JAVA macro. +dnl +dnl @category Java +dnl @author Stephane Bortzmeyer <[EMAIL PROTECTED]> +dnl @version 2000-07-19 +dnl @license GPLWithACException +dnl +dnl Modified to test for 1.5 by Andrew John Hughes on 2008-02-11 + +AC_DEFUN([AC_PROG_JAVAC_WORKS],[ +AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ +JAVA_TEST=Colour.java +CLASS_TEST=Colour.class +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public enum Colour +{ +RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET; +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS -source 1.5 -target 1.5 $JAVA_TEST) >/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?)]) + echo "configure: failed program was:" >&AC_FD_CC + cat $JAVA_TEST >&AC_FD_CC +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +]) Index: m4/acinclude.m4 =================================================================== RCS file: /sources/classpath/classpath/m4/acinclude.m4,v retrieving revision 1.31 diff -u -3 -p -u -r1.31 acinclude.m4 --- m4/acinclude.m4 10 Feb 2008 23:28:11 -0000 1.31 +++ m4/acinclude.m4 11 Feb 2008 20:56:51 -0000 @@ -1,197 +1,6 @@ dnl Used by aclocal to generate configure dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_FIND_JAVAC], -[ - user_specified_ecj= - user_specified_javac= - -dnl CLASSPATH_WITH_GCJ -dnl CLASSPATH_WITH_JIKES -dnl CLASSPATH_WITH_KJC - CLASSPATH_WITH_ECJ - CLASSPATH_WITH_JAVAC - - if test "x${user_specified_ecj}" = x; then - AM_CONDITIONAL(FOUND_ECJ, test "x${ECJ}" != x) - else - AM_CONDITIONAL(FOUND_ECJ, test "x${user_specified_ecj}" = xecj && test "x${ECJ}" != x) - fi - - if test "x${user_specified_javac}" = x; then -dnl AM_CONDITIONAL(FOUND_GCJ, test "x${GCJ}" != x) -dnl AM_CONDITIONAL(FOUND_JIKES, test "x${JIKES}" != x) - AM_CONDITIONAL(FOUND_JAVAC, test "x${JAVAC}" != x) - else -dnl AM_CONDITIONAL(FOUND_GCJ, test "x${user_specified_javac}" = xgcj) -dnl AM_CONDITIONAL(FOUND_JIKES, test "x${user_specified_javac}" = xjikes) - AM_CONDITIONAL(FOUND_JAVAC, test "x${user_specified_javac}" = xjavac && test "x${JAVAC}" != x) - fi - -dnl AM_CONDITIONAL(FOUND_KJC, test "x${user_specified_javac}" = xkjc) - -dnl if test "x${GCJ}" = x && test "x${JIKES}" = x && test "x${user_specified_javac}" != xkjc; then - if test "x${ECJ}" = x && test "x${JAVAC}" = x && test "x${user_specified_ecj}" != xecj && test "x${user_specified_javac}" != xjavac; then - AC_MSG_ERROR([cannot find javac, try --with-ecj or --with-javac]) - fi -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_WITH_GCJ], -[ - AC_ARG_WITH([gcj], - [AS_HELP_STRING(--with-gcj,bytecode compilation with gcj)], - [ - if test "x${withval}" != x && test "x${withval}" != xyes && test "x${withval}" != xno; then - CLASSPATH_CHECK_GCJ(${withval}) - else - if test "x${withval}" != xno; then - CLASSPATH_CHECK_GCJ - fi - fi - user_specified_javac=gcj - ], - [ - CLASSPATH_CHECK_GCJ - ]) - AC_SUBST(GCJ) -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_CHECK_GCJ], -[ - if test "x$1" != x; then - if test -f "$1"; then - GCJ="$1" - else - AC_PATH_PROG(GCJ, "$1") - fi - else - AC_PATH_PROG(GCJ, "gcj") - fi - dnl Test the given GCJ, but use it as C (!) compiler to check version - if test "x$GCJ" != x; then - AC_MSG_CHECKING([gcj version 4.0]) - AC_LANG_PUSH([C]) - AC_LANG_CONFTEST( - [[#if __GNUC__ <= 3 - #error GCJ 4.0.0 or higher is required - #endif - ]]) - $GCJ -E conftest.c > /dev/null - gcj_4_result=$? - if test "x$gcj_4_result" = "x0"; then - AC_MSG_RESULT([4.0 or higher found]) - else - AC_MSG_WARN([4.0 or higher required]) - fi - AC_LANG_POP - fi -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_WITH_JIKES], -[ - AC_ARG_WITH([jikes], - [AS_HELP_STRING(--with-jikes,bytecode compilation with jikes)], - [ - if test "x${withval}" != x && test "x${withval}" != xyes && test "x${withval}" != xno; then - CLASSPATH_CHECK_JIKES(${withval}) - else - if test "x${withval}" != xno; then - CLASSPATH_CHECK_JIKES - fi - fi - user_specified_javac=jikes - ], - [ - CLASSPATH_CHECK_JIKES - ]) - AC_SUBST(JIKES) -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_CHECK_JIKES], -[ - if test "x$1" != x; then - if test -f "$1"; then - JIKES="$1" - else - AC_PATH_PROG(JIKES, "$1") - fi - else - AC_PATH_PROG(JIKES, "jikes") - fi - if test "x$JIKES" != "x"; then - dnl Require at least version 1.19 - AC_MSG_CHECKING(jikes version) - JIKES_VERSION=`$JIKES --version | awk '/^Jikes Compiler/' | cut -d ' ' -f 5` - JIKES_VERSION_MAJOR=`echo "$JIKES_VERSION" | cut -d '.' -f 1` - JIKES_VERSION_MINOR=`echo "$JIKES_VERSION" | cut -d '.' -f 2` - if expr "$JIKES_VERSION_MAJOR" = 1 > /dev/null; then - if expr "$JIKES_VERSION_MINOR" \< 19 > /dev/null; then - JIKES="" - fi - fi - if test "x$JIKES" != "x"; then - AC_MSG_RESULT($JIKES_VERSION) - else - AC_MSG_WARN($JIKES_VERSION: jikes 1.19 or higher required) - fi - - JIKESENCODING= - if test -n "`$JIKES --help 2>&1 | grep encoding`"; then - JIKESENCODING='-encoding UTF-8' - fi - AC_SUBST(JIKESENCODING) - - JIKESWARNINGS="+Pno-switchcheck" - if test "x$JIKES_VERSION_MAJOR" = x"1" ; then - if ! test "x$JIKES_VERSION_MINOR" = x"19"; then - JIKESWARNINGS="$JIKESWARNINGS +Pno-shadow" - fi - fi - AC_SUBST(JIKESWARNINGS) - - fi -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_WITH_KJC], -[ - AC_ARG_WITH([kjc], - [AS_HELP_STRING(--with-kjc,bytecode compilation with kjc)], - [ - if test "x${withval}" != x && test "x${withval}" != xyes && test "x${withval}" != xno; then - CLASSPATH_CHECK_KJC(${withval}) - else - if test "x${withval}" != xno; then - CLASSPATH_CHECK_KJC - fi - fi - user_specified_javac=kjc - ], - [ - CLASSPATH_CHECK_KJC - ]) - AC_SUBST(KJC) -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_CHECK_KJC], -[ - if test "x$1" != x; then - if test -f "$1"; then - KJC="$1" - else - AC_PATH_PROG(KJC, "$1") - fi - else - AC_PATH_PROG(KJC, "kJC") - fi -]) - -dnl ----------------------------------------------------------- AC_DEFUN([CLASSPATH_WITH_JAVAH], [ AC_ARG_WITH([javah], @@ -369,92 +178,29 @@ AC_DEFUN([REGEN_WITH_JAY], ]) dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_WITH_ECJ], +AC_DEFUN([CLASSPATH_JAVAC_MEM_CHECK], [ - AC_ARG_WITH([ecj], - [AS_HELP_STRING(--with-ecj,bytecode compilation with ecj)], - [ - if test "x${withval}" != x && test "x${withval}" != xyes && test "x${withval}" != xno; then - CLASSPATH_CHECK_ECJ(${withval}) - else - if test "x${withval}" != xno; then - CLASSPATH_CHECK_ECJ - fi - fi - user_specified_ecj=ecj - ], - [ - CLASSPATH_CHECK_ECJ - ]) - AC_SUBST(ECJ) -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_CHECK_ECJ], -[ - if test "x$1" != x; then - if test -f "$1"; then - ECJ="$1" - else - AC_PATH_PROG(ECJ, "$1") - fi - else - AC_PATH_PROG(ECJ, "ecj") - fi -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_WITH_JAVAC], -[ - AC_ARG_WITH([javac], - [AS_HELP_STRING(--with-javac,bytecode compilation with javac)], - [ - if test "x${withval}" != x && test "x${withval}" != xyes && test "x${withval}" != xno; then - CLASSPATH_CHECK_JAVAC(${withval}) - else - if test "x${withval}" != xno; then - CLASSPATH_CHECK_JAVAC - fi - fi - user_specified_javac=javac - ], - [ - CLASSPATH_CHECK_JAVAC - ]) - AC_SUBST(JAVAC) - AC_SUBST(JAVAC_OPTS) -]) - -dnl ----------------------------------------------------------- -AC_DEFUN([CLASSPATH_CHECK_JAVAC], -[ - if test "x$1" != x; then - JAVAC="$1" - else - AC_PATH_PROG(JAVAC, "javac") - fi - dnl Test the given javac - AC_MSG_CHECKING([if javac is 1.5-capable]) - cat > Colour.java << EOF -public enum Colour { -RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET; -} + JAVA_TEST=Test.java + CLASS_TEST=Test.class + cat << \EOF > $JAVA_TEST + /* [#]line __oline__ "configure" */ + public class Test + { + public static void main(String[] args) + { + System.out.println("Hello World"); + } + } EOF - $JAVAC -sourcepath '' Colour.java - javac_result=$? - if test "x$javac_result" = "x0"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_WARN([1.5 capable javac required]) - fi AC_MSG_CHECKING([whether javac supports -J]) - $JAVAC -J-Xmx512M -sourcepath '' Colour.java + $JAVAC $JAVACFLAGS -J-Xmx512M -sourcepath '' $JAVA_TEST javac_result=$? if test "x$javac_result" = "x0"; then AC_MSG_RESULT([yes]) - JAVAC_OPTS="-J-Xmx512M" + JAVAC_MEM_OPT="-J-Xmx512M" else - AC_MSG_RESULT([javac doesn't support -J]) + AC_MSG_RESULT([no]) fi - rm -f Colour.java Colour.class + 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.42 diff -u -3 -p -u -r1.42 Makefile.am --- tools/Makefile.am 28 Dec 2007 17:35:35 -0000 1.42 +++ tools/Makefile.am 11 Feb 2008 20:56:52 -0000 @@ -4,15 +4,7 @@ GLIBJ_BOOTCLASSPATH='$(top_builddir)/lib GLIBJ_CLASSPATH=asm # Setup the compiler to use the GNU Classpath library we just built. -if FOUND_ECJ -JCOMPILER = $(ECJ) -1.5 -encoding UTF-8 -warn:-deprecation,serial,typeHiding,unchecked,unused,varargsCast -bootclasspath $(GLIBJ_BOOTCLASSPATH) -classpath .:$(GLIBJ_CLASSPATH) -else -if FOUND_JAVAC -JCOMPILER = $(JAVAC) -encoding UTF-8 -bootclasspath $(GLIBJ_BOOTCLASSPATH) -classpath $(GLIBJ_CLASSPATH) -else -error dunno how to setup the JCOMPILER and compile -endif -endif +JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_BOOTCLASSPATH) -classpath $(GLIBJ_CLASSPATH) if CREATE_WRAPPERS bin_SCRIPTS =
signature.asc
Description: Digital signature