[m-rev.] diff: support jdk in path with spaces

Peter Wang novalazy at gmail.com
Thu Oct 1 12:05:01 AEST 2009


Branches: main

aclocal.m4:
        If the detected paths to Java executables contain spaces then keep only
        the basenames.  Everything will still work so long as the executables
        can be found on the PATH later.

diff --git a/aclocal.m4 b/aclocal.m4
index bca3c34..fd7a613 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -315,12 +315,32 @@ 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.
+# On Windows, the Java SDK has a high chance of being installed in a path with
+# directory components containing spaces.  The simplest solution is to use only
+# the basename and require the user have their PATH set correctly.
 AC_PATH_PROGS(JAVAC, jikes javac gcj)
-case "$JAVAC" in *gcj)
-	JAVAC="$JAVAC -C" ;;
+case "$JAVAC" in
+    *" "*)
+        JAVAC=`basename "$JAVAC"`
+        ;;
+esac
+case "$JAVAC" in
+    *gcj)
+        JAVAC="$JAVAC -C"
+        ;;
 esac
 AC_PATH_PROG(JAVA_INTERPRETER, java gij)
+case "$JAVA_INTERPRETER" in
+    *" "*)
+        JAVA_INTERPRETER=`basename "$JAVA_INTERPRETER"`
+        ;;
+esac
 AC_PATH_PROG(JAR, jar)
+case "$JAR" in
+    *" "*)
+        JAR=`basename "$JAR"`
+        ;;
+esac
 
 AC_CACHE_VAL(mercury_cv_java, [
 if test "$JAVAC" != "" -a "$JAVA_INTERPRETER" != "" -a "$JAR" != ""; then
@@ -357,10 +377,10 @@ if test "$JAVAC" != "" -a "$JAVA_INTERPRETER" != "" -a "$JAR" != ""; then
 		}
 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 &&
+		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"

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list