Index: /trunk/Configure
===================================================================
--- /trunk/Configure	(revision 1055)
+++ /trunk/Configure	(revision 1056)
@@ -19,7 +19,7 @@
 #
 
-# $Id: Configure,v 1.112 2009/01/22 14:26:31 bmorgan Exp $
-#
-# Generated on Thu Jan 22 14:06:57 GMT 2009 [metaconfig 3.0 PL70]
+# $Id: Configure,v 1.116 2009/05/26 17:37:44 bmorgan Exp $
+#
+# Generated on Tue May 26 18:39:05 BST 2009 [metaconfig 3.0 PL70]
 
 cat >/tmp/c1$$ <<EOF
@@ -304,4 +304,7 @@
 g4vis_use_openglqt='n'
 #END QT VIS DRIVER OPTIONS
+#INITIALIZE G4MAKE
+g4make=""
+#END G4MAKE INITIALIZATION
 
 : Find the basic shell for Bourne shell scripts
@@ -1264,13 +1267,16 @@
 		*) n='-n' c='';;
 		esac
-		cat <<FOO
-They are not compatible!  You are probably running ksh on a non-USG system.
-I'll have to use $echo instead of the builtin, since Bourne shell doesn't
-have echo built in and we may have to run some Bourne shell scripts.  That
-means I'll have to use '$n$c' to suppress newlines now.
-
-FOO
-		$echo $n "The star should be here-->$c"
-		$echo "*"
+#We suppress the following message to avoid problems where the system points
+#sh to dash (Ubuntu). If you have problems with echo, uncomment the cat and
+#two $echo s to see if you're warned!!
+#		cat <<FOO
+#They are not compatible!  You are probably running ksh on a non-USG system.
+#I'll have to use $echo instead of the builtin, since Bourne shell doesn't
+#have echo built in and we may have to run some Bourne shell scripts.  That
+#means I'll have to use '$n$c' to suppress newlines now.
+#
+#FOO
+#		$echo $n "The star should be here-->$c"
+#		$echo "*"
 	fi
 	$rm -f foo1 foo2
@@ -2377,21 +2383,14 @@
         if test -x "/usr/bin/moc" ; then
             g4_qt_moc="/usr/bin/moc"
+            echo "checking for moc... \$g4_qt_moc"
+
+            g4_qt_dir=\`dirname \$g4_qt_include_dir\`
+            g4_qt_dir=\`dirname \$g4_qt_dir\`
+
 	    g4_qt_version="4"
-            # checking moc version
-	    g4_qt_moc_major_version=\`\$g4_qt_moc -v 2>&1|sed 's/^.*(Qt \(.*\)\..*\..*)/\1/'\`
-            echo "checking for moc... found \$g4_qt_moc version \$g4_qt_moc_major_version"
-            if test "\$g4_qt_version" = "\$g4_qt_moc_major_version" ; then
-                g4_qt_dir=\`dirname \$g4_qt_include_dir\`
-                g4_qt_dir=\`dirname \$g4_qt_dir\`
-                
-                g4_qt_version="4"
-                g4_qt_cxxflags="-I\$g4_qt_dir/QtCore.framework/Headers -I\$g4_qt_dir/QtGui.framework/Headers"
-                g4_qt_gl_cxxflags="-I\$g4_qt_dir/QtOpenGl.framework/Headers"
-                g4_qt_libs="-F\$g4_qt_dir -framework QtCore -framework QtGui"
-                g4_qt_gl_libs="-framework QtOpenGL"
-            else
-                echo "moc version (\$g4_qt_moc_major_version) is not compatible with previous founded Qt (\$g4_qt_ver) version. Please update/move \$g4_qt_moc to Qt \$g4_qt_ver compatible version"
-                g4_havegoodqt=no
-            fi
+            g4_qt_cxxflags="-I\$g4_qt_dir/QtCore.framework/Headers -I\$g4_qt_dir/QtGui.framework/Headers"
+            g4_qt_gl_cxxflags="-I\$g4_qt_dir/QtOpenGl.framework/Headers"
+            g4_qt_libs="-F\$g4_qt_dir -framework QtCore -framework QtGui"
+            g4_qt_gl_libs="-framework QtOpenGL"
         else
             echo "checking for moc... no"
@@ -2539,26 +2538,95 @@
         #
         # Finally, we need to search for moc
+	# We use prior knowledge of the detected Qt version to
+	# try and grab the correct moc straight off.
         #
         g4_qt_bin_dir=\$g4_qt_dir/bin
         g4_qtmoc=no
-        if test -x "\$g4_qt_bin_dir/moc" ; then
-           g4_qtmoc="\$g4_qt_bin_dir/moc"
-        elif test -x "\$g4_qt_bin_dir/moc-qt4" ; then
-           g4_qtmoc="\$g4_qt_bin_dir/moc-qt4"
-        elif test -x "\$g4_qt_bin_dir/qt4-moc" ; then
-           g4_qtmoc="\$g4_qt_bin_dir/qt4-moc"
-        else
-            g4_havegoodqt=no
+	g4_qt_cross_check_moc=no
+
+	if test "x\$g4_is_qt4" = "xyes" ; then
+	    # Try the qt4 variants first...
+	    if test -x "\$g4_qt_bin_dir/moc-qt4" ; then
+		g4_qtmoc="\$g4_qt_bin_dir/moc-qt4"
+	    elif test -x "\$g4_qt_bin_dir/qt4-moc" ; then
+		g4_qtmoc="\$g4_qt_bin_dir/qt4-moc"
+	    elif test -x "\$g4_qt_bin_dir/moc" ; then
+		g4_qtmoc="\$g4_qt_bin_dir/moc"
+		g4_qt_cross_check_moc=yes
+	    else
+		g4_havegoodqt=no
+	    fi
+	else
+	    # We've probably got Qt3, so check for
+	    # the qt3 variants first
+	    if test -x "\$g4_qt_bin_dir/moc-qt3" ; then
+		g4_qtmoc="\$g4_qt_bin_dir/moc-qt3"
+	    elif test -x "\$g4_qt_bin_dir/qt3-moc" ; then
+		g4_qtmoc="\$g4_qt_bin_dir/qt3-moc"
+	    elif test -x "\$g4_qt_bin_dir/moc" ; then
+		g4_qtmoc="\$g4_qt_bin_dir/moc"
+		g4_qt_cross_check_moc=yes
+	    else
+		g4_havegoodqt=no
+	    fi
         fi
-        # checking moc version
-        g4_qt_moc_major_version=\`\$g4_qtmoc -v 2>&1|sed 's/^.*(Qt \(.*\)\..*\..*)/\1/'\`
-        echo "checking for moc... found \$g4_qtmoc version \$g4_qt_moc_major_version"
-
-        if test "\$g4_qt_major_ver" = "\$g4_qt_moc_major_version" ; then
-            g4_havegoodqt=yes
-        else
-            echo "moc version (\$g4_qt_moc_major_version) is not compatible with previous founded Qt (\$g4_qt_major_ver) version. Please update/move \$g4_qt_moc to Qt \$g4_qt_major_ver compatible version"
-            g4_havegoodqt=no
-        fi
+        echo "checking for moc... \$g4_qtmoc"
+
+	#
+	# If pure 'moc' was found, cross check its version
+	# against previously detected Qt major version
+	#
+	if test "x\$g4_qt_cross_check_moc" = "xyes" ; then
+	    $echo $n "Checking \$g4_qtmoc major version is \$g4_qt_major_ver... $c"
+	    # Grab version of found moc
+	    g4_qt_found_moc_major_version=\`\$g4_qtmoc -v 2>&1 | sed -s 's/^.*(Qt \([0-9]\)\..*/\1/'\`
+	    if test "x\$g4_qt_found_moc_major_version" != "x\$g4_qt_major_ver" ; then
+		# We need to ask the user where correct moc is
+		$echo "no"
+		promptend="no"
+		user_moc="\$g4_qtmoc"
+
+		while test "x\$promptend" = "xno" ; do
+		    echo " "
+		    g4message=\`cat << EOM
+Qt moc was found as \$user_moc and has major version \$g4_qt_found_moc_major_version. 
+This does not match the version of the detected Qt install 
+which is \$g4_qt_major_ver.
+Please enter the full path to the moc program which matches this Qt
+version, or type '-' to CANCEL the Qt checks.
+EOM\`
+		    dflt="\$user_moc"
+		    rp=\$g4message
+                    . ./myread
+
+		    # Check for user cancellation
+                    if test "x\$ans" = "x-" ; then
+			g4_havegoodqt="no"
+			g4_qtmoc=""
+			promptend="yes"
+                    else
+                        user_moc="\$ans"
+			if test -x "\$user_moc" ; then
+			    g4_qt_found_moc_major_version=\`\$user_moc -v 2>&1 | sed -s 's/^.*(Qt \([0-9]\)\..*/\1/'\`
+			    if test "x\$g4_qt_found_moc_major_version" != "x\$g4_qt_major_ver" ; then
+			        echo "Checking if \$user_moc version is \$g4_qt_major_ver... no"
+			    else
+			        echo "Checking if \$user_moc version is \$g4_qt_major_ver... yes"
+				g4_qtmoc=\$user_moc
+				promptend=yes
+                            fi
+			else
+			    echo "warning: \$user_moc is not executable."
+			    user_moc="<null>"
+                            g4_qt_found_moc_major_version="<null>"
+			fi
+                    fi
+		# We need to ask the user where correct moc is
+		done
+            else
+                $echo "yes"
+            fi
+	fi
+
         ## THIS IS POINT AT WHICH TO DO FALLBACK TESTS I.E DOES
         ## COMPILATION OF SMALL TEST PROGRAM WORK - THEN HEADERS AND
@@ -2604,4 +2672,5 @@
 
             g4_qt_moc=\$g4_qtmoc
+
             g4_qt_is_configured=yes
         else
@@ -3186,5 +3255,5 @@
 
 g4message=`cat <<EOM
-Specify the path where are the Geant4 data libraries 
+Specify the path where the Geant4 data libraries 
 
 $g4data_alllibs 
@@ -6176,8 +6245,11 @@
 #
 # Because the vis driver only works with UI, only probe if g4ui_none is
-# NOT set AND also that g4vis_none is NOT set
+# NOT set AND g4vis_none is NOT set.
+# Also, Qt vis driver has dependency on Qt UI module - so only ask if
+# build is required IF Qt UI was selected.
 #
 if test "x$g4ui_none" = "xn" -a "x$g4vis_none" = "xn" ; then
-    # Query the user to see if build of Qt UI module is needed
+if test "x$g4ui_build_qt_session" = "xy" ; then
+    # Query the user to see if build of Qt GL module is needed
     g4message=`cat <<EOM
 
@@ -6263,4 +6335,10 @@
         fi #END TEST g4_havegoodqt = no (for user prompt)
     fi #END TEST g4vis_build_openglqt_driver (whether to build at all)
+else # TEST g4ui_build_qt_session
+    # Because we can 'drop through' this test on repeat
+    # running Configure, force build and use to n
+    g4vis_build_openglqt_driver=n
+    g4vis_use_openglqt=n
+fi #END TEST g4ui_build_qt_session (dependency on Qt UI module)
 fi #END TEST g4ui_none = n AND g4vis_none=n
 
@@ -6392,93 +6470,112 @@
 #END OF GDML/XERCES PROBE
 
+#
+# Configure which make to use...
+# On WIN32, we have to watch for cygwin/Matlab clash
+# Here, cygwin supplies make, Matlab 'gmake', but we must select
+# cygwin make.
+#
+# Yes, we could use Loc's built in make, but want full control
+# for now....
+#
+
 echo " "
 
-case "$g4make" in
-'')
-	g4make=gmake
-	;;
-esac
-
-echo ""
-
-	g4_gmake_version=`(gmake -v) 2>/dev/null` 
-				case $g4_gmake_version in
-				GNU*) 
-				g4_gmake=y				
-				;;
-				*) 
-				g4_gmake=n
-				;;
-				esac				
-
-	g4_make_version=`(make -v) 2>/dev/null`
-				case $g4_make_version in
-				GNU*) 
-				g4_make=y				
-				;;
-				*) 
-				g4_make=n
-				;;
-				esac				
-
-if  [ $g4_gmake = y ] ; then
-
-g4make=gmake
-
-g4message=`cat << EOM
-
-  G4MAKE
-
-You have GNU make which could be used to build GEANT4.
-You can select your own 'make' program if you want.
-EOM`
-
-fi
-
-if [ $g4_gmake = n ] && [ $g4_make = y ] ; then
-
-g4make=make
-
-g4message=`cat << EOM
-
-  G4MAKE
-
-You have GNU make which could be used to build GEANT4.
-You can select your own 'make' program if you want.
-EOM`
-
-fi
-
-if [ $g4_gmake = n ] && [ $g4_make = n ] ; then
-
-g4make=none
-
-g4message=`cat << EOM
-
-  G4MAKE
-
-You have NO GNU make which could be used to build GEANT4.
-Please select your own 'make' program compatible with GNU make.
-EOM`
-
-dflt=$g4make
-rp=$g4message
-
-
-. ./myread
-gans=$ans
-
-	case $gans in
-	
-	'') 
-		g4make=$dflt
-		;;
-	*) 
-		g4make=$gans
+g4_make_loc="no"
+g4_gmake_loc="no"
+
+g4_make_program=make
+g4_gmake_program=gmake
+
+g4_check_make_msg="Checking for $g4_make_program..."
+g4_check_gmake_msg="Checking for $g4_gmake_program..."
+
+g4_make_isgnu="no"
+g4_gmake_isgnu="no"
+
+g4_make_dirs=`echo $PATH | sed 's/\:/ /g'`
+
+# Check for 'make' on all systems
+g4_make_loc=`./loc $g4_make_program no $g4_make_dirs`
+echo "$g4_check_make_msg $g4_make_loc"
+
+
+# On anything but Windows, check for gmake as well
+if test "x$g4osname" != "xWIN32" ; then
+    g4_gmake_loc=`./loc $g4_gmake_program no $g4_make_dirs`
+    echo "$g4_check_gmake_msg $g4_gmake_loc"
+fi
+ 
+
+# Now see if make/gmake are GNU make.
+if test "x$g4_make_loc" != "xno" ; then
+    g4_make_version=`$g4_make_loc -v 2>/dev/null`
+
+    case $g4_make_version in
+	GNU*)
+	    g4_make_isgnu=yes
+	    ;;
+	*)
+	    g4_make_isgnu=no
+	    ;;
+    esac
+    echo "Checking if make is GNU make... $g4_make_isgnu"
+fi
+
+if test "x$g4osname" != "xWIN32" ; then
+    if test "x$g4_gmake_loc" != "xno" ; then
+	g4_gmake_version=`$g4_gmake_loc -v 2>/dev/null`
+
+	case $g4_gmake_version in
+	    GNU*)
+		g4_gmake_isgnu=yes
+	    	;;
+	    *)
+		g4_gmake_isgnu=no
 		;;
 	esac
-
-fi
-
+	echo "Checking if gmake is GNU make... $g4_gmake_isgnu"
+    fi
+fi
+
+# Now perform selection on following logic
+# 1) If we have gmake AND it's GNU make, use that
+# 2) If we have make AND it's GNU make, use that
+# 3) If none of the above, prompt user for path to make program
+if test "x$g4_gmake_loc" != "xno" -a "x$g4_gmake_isgnu" = "xyes" ; then
+    g4make=$g4_gmake_loc
+elif test "x$g4_make_loc" != "xno" -a "x$g4_make_isgnu" = "xyes" ; then
+    g4make=$g4_make_loc
+else
+    g4_got_user_make="no"
+    while test "x$g4_got_user_make" = "xno"; do
+        g4message=`cat << EOM
+
+    G4MAKE
+
+A GNU make program could not be located on your system.
+Please enter the full path to the GNU make program you
+want to use:
+EOM`
+        dflt=$g4make
+        rp=$g4message
+        . ./myread
+        gans=$ans
+
+        #Check if this is GNU make...
+        g4_user_make_version=`$gans -v 2>/dev/null`
+
+        case $g4_user_make_version in
+	    "GNU Make"*)
+		echo "Checking that $gans is GNU Make... yes"
+	        g4make=$gans
+                g4_got_user_make=yes
+		;;
+	    *)
+	        echo "Checking that $gans is GNU Make... no"
+		;;
+	esac
+    done
+fi
 
 
