common/autoconf/toolchain.m4

Print this page
rev 902 : 8020779: Improve detection and handling of jtreg/jtdiff executable path
8026988: Makefile is confused if JT_HOME is a different location than jtreg executable
Reviewed-by: duke

@@ -1096,17 +1096,26 @@
 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
 [
   AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
       [Regression Test Harness @<:@probed@:>@])],
       [],
-      [with_jtreg=no])
+      [with_jtreg=optional])
 
   if test "x$with_jtreg" = xno; then
     # jtreg disabled
     AC_MSG_CHECKING([for jtreg])
     AC_MSG_RESULT(no)
+    # force undefine.
+    JTREG=
+    JTDIFF=
   else
+    if test "x$with_jtreg" = xoptional; then
+      # non-fatal if not found
+      jtreg_optional=yes
+      with_jtreg=yes
+    fi
+
     if test "x$with_jtreg" != xyes; then
       # with path specified.
       JT_HOME="$with_jtreg"
     fi
 

@@ -1115,22 +1124,61 @@
 
       # use JT_HOME enviroment var.
       BASIC_FIXUP_PATH([JT_HOME])
 
       # jtreg win32 script works for everybody
-      JTREGEXE="$JT_HOME/win32/bin/jtreg"
+      JTREG="$JT_HOME/win32/bin/jtreg"
+
+      # jtdiff win32 script works for everybody
+      JTDIFF="$JT_HOME/win32/bin/jtdiff"
 
-      if test ! -f "$JTREGEXE"; then
-        AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
+      if test ! -f "$JTREG"; then
+        AC_MSG_ERROR([JTReg executable does not exist: $JTREG])
       fi
 
-      AC_MSG_RESULT($JTREGEXE)
+      if test ! -f "$JTDIFF"; then
+        AC_MSG_ERROR([JTDiff executable does not exist: $JTDIFF])
+      fi
+
+      AC_MSG_RESULT($JTREG)
+    else
+      if test "x$jtreg_optional" != xyes; then
+         # require that JTReg be on the path
+         BASIC_REQUIRE_PROG(JTREG, jtreg)
+         # require that JTDiff be on the path
+         BASIC_REQUIRE_PROG(JTDIFF, jtdiff)
     else
-      # try to find jtreg on path
-      BASIC_REQUIRE_PROG(JTREGEXE, jtreg)
-      JT_HOME="`$DIRNAME $JTREGEXE`"
+         # check if JTReg is on the path
+         AC_PATH_PROG(JTREG, jtreg)
+         # check if JTDiff is on the path
+         AC_PATH_PROG(JTDIFF, jtdiff)
+      fi
+    fi
+
+    if test "x$JTREG" != x; then
+      # check the jtreg version
+      JTREG_REQUIRED_VERSION="4.1 fcs b07"
+      AC_MSG_CHECKING([jtreg version])
+      JTREG_VERSION="`$JTREG -version 2>&1 | $HEAD -n 1`"
+      JTREGVER="`$ECHO $JTREG_VERSION | $SED -e "s/jtreg, version \([.]*\)/\1/g"`"
+#      if test "$JTREGVER" != "$JTREG_REQUIRED_VERSION"; then
+#        AC_MSG_ERROR([Unsupported JTReg version : $JTREGVER])
+#      fi
+      AC_MSG_RESULT($JTREGVER)
+    fi
+
+    if test "x$JTDIFF" != x; then
+      # check the jtdiff version
+      JTDIFF_REQUIRED_VERSION="4.1 fcs b07"
+      AC_MSG_CHECKING([jtdiff version])
+      JTDIFF_VERSION="`$JTDIFF -version 2>&1 | $HEAD -n 1`"
+      JTDIFFVER="`$ECHO $JTDIFF_VERSION | $SED -e "s/jtdiff, version \([.]*\)/\1/g"`"
+#      if test "$JTREGVER" != "$JTREG_REQUIRED_VERSION"; then
+#        AC_MSG_ERROR([Unsupported JTReg version : $JTREGVER])
+#      fi
+      AC_MSG_RESULT($JTDIFFVER)
     fi
   fi
 
-  AC_SUBST(JT_HOME)
-  AC_SUBST(JTREGEXE)
+  AC_SUBST(JTREG)
+  AC_SUBST(JTDIFF)
 ])