[m-rev.] For review: Have configure decide whether to install the Java grade
James Goddard
goddardjames at yahoo.com
Tue Feb 10 16:49:51 AEDT 2004
> We currently rely on some features of J2SE 1.2, right?
>
> I think it would be a good idea for configure to test
> that you can compile and run a simple test program conftest.java
> which uses those features, similar to the way we check $BOOTSTRAP_MC.
I've added such a program, but instead of checking for each required
feature we use from J2SE 1.2 (of which I believe there are many many)
I've got it just checking the appropriate runtime constant for the
version (java.specification.version) is >= 1.2. All 'compatible' Java
implementations should have this constant, since it's part of the API
specification.
I've also added a check for the java interpreter.
--------------------------------------------------------------------
diff -u aclocal.m4 aclocal.m4
--- aclocal.m4 9 Feb 2004 07:12:48 -0000
+++ aclocal.m4 10 Feb 2004 05:41:14 -0000
@@ -286,18 +286,61 @@
AC_DEFUN(MERCURY_CHECK_JAVA,
[
AC_PATH_PROG(JAVAC, javac)
+AC_PATH_PROG(JAVAI, java)
-AC_MSG_CHECKING(for Java SDK)
AC_CACHE_VAL(mercury_cv_java, [
-if test "$JAVAC" != ""; then
- mercury_cv_java="yes"
+if test "$JAVAC" != "" -a "$JAVAI" != ""; 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 $JAVAI conftest > conftest.out 2>&AC_FD_CC &&
+ $JAVAI 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
- mercury_cv_java="no"
+ mercury_cv_java="no"
fi
])
-AC_MSG_RESULT($mercury_cv_java)
AC_SUBST(JAVAC)
+AC_SUBST(JAVAI)
])
#-----------------------------------------------------------------------------#
--------------------------------------------------------------------------
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