[m-rev.] diff: Have configure decide whether to install the Java grade
James Goddard
goddardjames at yahoo.com
Wed Feb 11 14:51:39 AEDT 2004
Estimated hours taken: 8
Branches: main
Have the configure script decide whether to install the Java grade.
configure.in:
Add Java to the list of library grades to install by default,
if the Java SDK is installed.
Add the option to disable the Java grade.
aclocal.m4:
Detect whether the Java SDK is installed. Currently this is done
by checking for javac, java and jar, then testing whether a program
can be compiled which confirms the version is recent enough.
scripts/Mmake.vars.in:
Add JAVAC, JAVA_INTERPRETER and JAR to the generated make variables.
Add JAR_CREATE_FLAGS make variable, set as "cf"
scripts/Mercury.config.in:
scripts/Mercury.config.bootstrap.in:
Define environmental variables MERCURY_JAVA_COMPILER and
MERCURY_JAVA_INTERPRETER.
Have the configure script set the default java compiler and interpreter
as part of DEFAULT_MC_FLAGS.
library/Mmakefile:
Use "$(JAR) $(JAR_CREATE_FLAGS)" instead of "jar cf"
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.385
diff -u -d -r1.385 configure.in
--- configure.in 5 Feb 2004 09:26:32 -0000 1.385
+++ configure.in 9 Feb 2004 06:54:47 -0000
@@ -695,6 +695,11 @@
MERCURY_CHECK_DOTNET
#-----------------------------------------------------------------------------#
+# Java configuration
+#
+MERCURY_CHECK_JAVA
+
+#-----------------------------------------------------------------------------#
mercury_check_for_functions () {
for mercury_cv_func in "$@"
@@ -2434,6 +2439,10 @@
[ --disable-dotnet-grades do not install the .NET grades],
enable_dotnet_grades="$enableval",enable_dotnet_grades=yes)
+AC_ARG_ENABLE(java-grade,
+[ --disable-java-grade do not install the Java grade],
+enable_java_grade="$enableval",enable_java_grade=yes)
+
AC_ARG_ENABLE(libgrades,
[ --enable-libgrades=...
install exactly the given versions of the library.
@@ -2452,6 +2461,7 @@
enable_hlc_prof_grades=no
enable_par_grades=no
enable_dotnet_grades=no
+ enable_java_grade=no
fi
#-----------------------------------------------------------------------------#
@@ -2605,6 +2615,12 @@
if test $mercury_cv_microsoft_dotnet = yes -a "$enable_dotnet_grades" = yes
then
LIBGRADES="$LIBGRADES il"
+fi
+
+# add Java back-end grade, if Java is installed
+if test $mercury_cv_java = yes -a "$enable_java_grade" = yes
+then
+ LIBGRADES="$LIBGRADES java"
fi
# Allow the user to override the default list of library grades
Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.21
diff -u -d -r1.21 aclocal.m4
--- aclocal.m4 6 Aug 2003 12:38:02 -0000 1.21
+++ aclocal.m4 11 Feb 2004 03:10:30 -0000
@@ -280,3 +280,81 @@
])
#-----------------------------------------------------------------------------#
+#
+# Java configuration
+#
+AC_DEFUN(MERCURY_CHECK_JAVA,
+[
+# jikes requires the usual Java SDK to run, so if we checked for javac first,
+# then that's what we'd get. If the user has jikes installed, then that
+# probably means that they want to use it, so we check for jikes before javac.
+AC_PATH_PROGS(JAVAC, jikes javac gcj)
+AC_PATH_PROG(JAVA_INTERPRETER, java)
+AC_PATH_PROG(JAR, jar)
+
+AC_CACHE_VAL(mercury_cv_java, [
+if test "$JAVAC" != "" -a "$JAVA_INTERPRETER" != "" -a "$JAR" != ""; then
+ AC_MSG_CHECKING(if the above Java SDK works and is sufficiently recent)
+ cat > conftest.java << EOF
+ // This program simply retrieves the constant
+ // specifying the version number of the Java SDK and
+ // checks it is at least 1.2, printing "Hello, world"
+ // if successful.
+ public class conftest {
+ public static void main (String[[]] args) {
+ float version;
+ String strVer = System.getProperty(
+ "java.specification.version");
+
+ try {
+ version = Float.valueOf(strVer).floatValue();
+ }
+ catch (NumberFormatException e) {
+ System.out.println("ERROR: \"java." +
+ "specification.version\" " +
+ "constant has incorrect " +
+ "format.\nGot \"" + strVer +
+ "\", expected a number.");
+ version = 0f;
+ }
+
+ if (version >= 1.2f) {
+ System.out.println("Hello, world\n");
+ } else {
+ System.out.println("Nope, sorry.\n");
+ }
+ }
+ }
+EOF
+ if
+ echo $JAVAC conftest.java >&AC_FD_CC 2>&1 &&
+ $JAVAC conftest.java >&AC_FD_CC 2>&1 &&
+ echo $JAVA_INTERPRETER conftest > conftest.out 2>&AC_FD_CC &&
+ $JAVA_INTERPRETER conftest > conftest.out 2>&AC_FD_CC &&
+ test "`tr -d '\015' < conftest.out`" = "Hello, world"
+ then
+ mercury_cv_java="yes"
+ else
+ mercury_cv_java="no"
+ fi
+ AC_MSG_RESULT($mercury_cv_java)
+else
+ if test "$JAVAC" = ""; then
+ JAVAC="javac"
+ fi
+ if test "$JAVA_INTERPRETER" = ""; then
+ JAVA_INTERPRETER="java"
+ fi
+ if test "$JAR" = ""; then
+ JAR="jar"
+ fi
+ mercury_cv_java="no"
+fi
+])
+
+AC_SUBST(JAVAC)
+AC_SUBST(JAVA_INTERPRETER)
+AC_SUBST(JAR)
+])
+
+#-----------------------------------------------------------------------------#
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.92
diff -u -d -r1.92 Mmake.vars.in
--- scripts/Mmake.vars.in 27 Jan 2004 00:20:35 -0000 1.92
+++ scripts/Mmake.vars.in 11 Feb 2004 03:11:40 -0000
@@ -276,13 +276,22 @@
# JAVAC is the command line java compiler;
# it should generate .class files from .java files.
-JAVAC = javac
+JAVAC = @JAVAC@
ALL_JAVACFLAGS = $(JAVACFLAGS) $(EXTRA_JAVACFLAGS) $(TARGET_JAVACFLAGS) \
$(LIB_JAVACFLAGS)
JAVACFLAGS =
EXTRA_JAVACFLAGS =
# XXX Should we set LIB_JAVACFLAGS?
LIB_JAVACFLAGS =
+
+# JAVA_INTERPRETER is the command line Java interpreter;
+# it should be able to run Java bytecode files.
+JAVA_INTERPRETER = @JAVA_INTERPRETER@
+
+# JAR is the command line Java archive tool;
+# it should generate .jar files.
+JAR = @JAR@
+JAR_CREATE_FLAGS = cf
#-----------------------------------------------------------------------------#
#
Index: scripts/Mercury.config.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mercury.config.in,v
retrieving revision 1.7
diff -u -d -r1.7 Mercury.config.in
--- scripts/Mercury.config.in 6 Aug 2003 12:38:14 -0000 1.7
+++ scripts/Mercury.config.in 11 Feb 2004 03:30:31 -0000
@@ -14,7 +14,8 @@
# Mercury.config.bootstrap.in should also be updated.
#
# Environment variables: MERCURY_STDLIB_DIR, MERCURY_C_COMPILER,
-# MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL.
+# MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL,
+# MERCURY_JAVA_COMPILER, MERCURY_JAVA_INTERPRETER.
# These settings won't override settings in the environment.
MERCURY_STDLIB_DIR=@LIBDIR@
@@ -22,6 +23,8 @@
MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@
MERCURY_C_COMPILER=@CC@
MERCURY_MATH_LIB=@MATH_LIB@
+MERCURY_JAVA_COMPILER=@JAVAC@
+MERCURY_JAVA_INTERPRETER=@JAVA_INTERPRETER@
# $(MATH_LIB) needs to be defined because it may
# be used by the substitution for SHARED_LIBS.
MATH_LIB=$(MERCURY_MATH_LIB)
@@ -34,6 +37,8 @@
@ALL_LOCAL_C_INCL_DIR_MMC_OPTS@ \
@ALL_LOCAL_C_LIB_DIR_MMC_OPTS@ \
--cc "$(MERCURY_C_COMPILER)" \
+ --java-compiler "$(MERCURY_JAVA_COMPILER)" \
+ --java-interpreter "$(MERCURY_JAVA_INTERPRETER)" \
--grade "$(MERCURY_DEFAULT_GRADE)" \
--cflags-for-ansi "@CFLAGS_FOR_ANSI@" \
--cflags-for-optimization "@CFLAGS_FOR_OPT@" \
Index: scripts/Mercury.config.bootstrap.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mercury.config.bootstrap.in,v
retrieving revision 1.1
diff -u -d -r1.1 Mercury.config.bootstrap.in
--- scripts/Mercury.config.bootstrap.in 15 May 2003 07:23:43 -0000 1.1
+++ scripts/Mercury.config.bootstrap.in 11 Feb 2004 03:44:53 -0000
@@ -15,7 +15,8 @@
# understood by the installed compilers.
#
# Environment variables: MERCURY_STDLIB_DIR, MERCURY_C_COMPILER,
-# MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL.
+# MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL,
+# MERCURY_JAVA_COMPILER, MERCURY_JAVA_INTERPRETER.
# These settings won't override settings in the environment.
MERCURY_STDLIB_DIR=@LIBDIR@
@@ -23,6 +24,8 @@
MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@
MERCURY_C_COMPILER=@CC@
MERCURY_MATH_LIB=@MATH_LIB@
+MERCURY_JAVA_COMPILER=@JAVAC@
+MERCURY_JAVA_INTERPRETER=@JAVA_INTERPRETER@
# $(MATH_LIB) needs to be defined because it may
# be used by the substitution for SHARED_LIBS.
MATH_LIB=$(MERCURY_MATH_LIB)
@@ -35,6 +38,9 @@
@ALL_LOCAL_C_INCL_DIR_MMC_OPTS@ \
@ALL_LOCAL_C_LIB_DIR_MMC_OPTS@ \
--cc "$(MERCURY_C_COMPILER)" \
+ --java-compiler "$(MERCURY_JAVA_COMPILER)" \
+# uncomment this when the --java-interpreter option has been around for a while
+# --java-interpreter "$(MERCURY_JAVA_INTERPRETER)" \
--grade "$(MERCURY_DEFAULT_GRADE)" \
--cflags-for-ansi "@CFLAGS_FOR_ANSI@" \
--cflags-for-optimization "@CFLAGS_FOR_OPT@" \
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.130
diff -u -d -r1.130 Mmakefile
--- library/Mmakefile 5 Feb 2004 07:35:56 -0000 1.130
+++ library/Mmakefile 11 Feb 2004 03:12:21 -0000
@@ -254,8 +254,9 @@
# any architecture-specific objects.
.PHONY: jars
jars: classes
- jar cf $(STD_LIB_NAME).jar mercury/*.class
- jar cf $(STD_LIB_NAME).runtime.jar mercury/runtime/*.class
+ $(JAR) $(JAR_CREATE_FLAGS) $(STD_LIB_NAME).jar mercury/*.class
+ $(JAR) $(JAR_CREATE_FLAGS) $(STD_LIB_NAME).runtime.jar \
+ mercury/runtime/*.class
-+cd mercury/runtime && mmake $(NATIVE_SO)
-cp mercury/runtime/$(NATIVE_SO) .
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list