#! /bin/sh
#
# If these # comments don't work, trim them. Don't worry about any other
# shell scripts, Configure will trim # comments from them for you.
#
# (If you are trying to port this package to a machine without sh,
# I would suggest you have a look at the prototypical config_h.SH file
# and edit it to reflect your system. Some packages may include samples
# of config.h for certain machines, so you might look for one of those.)
#
# Yes, you may rip this off to use in other distribution packages. This
# script belongs to the public domain and cannot be copyrighted.
#
# (Note: this Configure script was generated automatically. Rather than
# working with this copy of Configure, you may wish to get metaconfig.
# The dist-3.0 package (which contains metaconfig) was posted in
# comp.sources.misc and is available on CPAN under authors/id/RAM so
# you may fetch it yourself from your nearest archive site.)
#

# $Id: Configure,v 1.110.2.2 2009/08/11 09:09:47 gcosmo Exp $
#
# Generated on Tue May 26 18:39:05 BST 2009 [metaconfig 3.0 PL70]

cat >/tmp/c1$$ <<EOF
WARNING!!!!!

SCO csh still thinks true is false!  /bin/csh needs to be updated.
EOF
cat >/tmp/c2$$ <<EOF

You didn't run Configure with sh!
I'll attempt to run sh for you...
EOF

true || cat /tmp/c1$$ /tmp/c2$$
true || exec sh $0 $argv:q

(exit $?0) || cat /tmp/c2$$
(exit $?0) || exec sh $0 $argv:q
rm -f /tmp/c1$$ /tmp/c2$$

: compute my invocation name
me=$0
case "$0" in
*/*)
	me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
	test "$me" || me=$0
	;;
esac

: Proper PATH separator
p_=:
: On OS/2 this directory should exist if this is not floppy only system :-]
#if test -d c:/.; then
#	p_=\;
#	PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
#?X: That's a bug in ksh5.22
#	OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
#fi

: Proper PATH setting
paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
paths="$paths /sbin /usr/sbin /usr/libexec"

for p in $paths
do
	case "$p_$PATH$p_" in
	*$p_$p$p_*) ;;
	*) test -d $p && PATH=$PATH$p_$p ;;
	esac
done

PATH=.$p_$PATH
export PATH

: shall we be using ksh?
inksh=''
needksh=''
avoidksh=''
newsh=/bin/ksh
changesh=''
if (PATH=.; alias -x) >/dev/null 2>&1; then
		inksh=true
fi
if test -f /hp-ux -a -f /bin/ksh; then
	needksh='to avoid sh bug in "here document" expansion'
fi
if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
	if test X`/usr/bin/uname -v` = X4; then
		avoidksh="to avoid AIX 4's /bin/sh"
		newsh=/usr/bin/bsh
	fi
fi
case "$inksh/$needksh" in
/[a-z]*)
		unset ENV
		changesh=true
		reason="$needksh"
	;;
esac
case "$inksh/$avoidksh" in
true/[a-z]*)
	changesh=true
	reason="$avoidksh"
	;;
esac
case "$inksh/$needksh-$avoidksh-" in
true/--)
		cat <<EOM
(I see you are using the Korn shell.  In case of problems
 try the Bourne shell instead.)
EOM
	;;
esac
case "$changesh" in
true)
	echo "(Feeding myself to $newsh $reason.)"
	case "$0" in
	Configure|*/Configure) exec $newsh $0 "$@";;
	*) exec $newsh Configure "$@";;
	esac
	;;
esac

: Configure runs within the UU subdirectory
test -d .config/UU || mkdir -p .config/UU
unset CDPATH
cd .config/UU && rm -f ./*

eunicefix=''
g4compiler=''
g4osname=''
g4system=''
hint=''
myuname=''
osname=''
osvers=''
g4_qt_cxxflags=''
g4_qt_gl_cxxflags=''
g4_qt_gl_libs=''
g4_qt_libs=''
g4_qt_moc=''
g4_qt_version=''
Author=''
Date=''
Header=''
Id=''
Locker=''
Log=''
RCSfile=''
Revision=''
Source=''
State=''
cf_by=''
cf_time=''
contains=''
d_portable=''
g4base=''
g4conf=''
g4final_install=''
g4include=''
g4includes_flag=''
g4install=''
g4workdir=''
g4bin=''
g4lib=''
g4tmp=''
g4abladata=''
g4data=''
g4elasticdata=''
g4ledata=''
g4levelgammadata=''
g4neutronhpcrosssections=''
g4radioactivedata=''
g4clhep_base_dir=''
g4clhep_include_dir=''
g4clhep_lib=''
g4clhep_lib_dir=''
g4lib_build_shared=''
g4lib_build_static=''
g4lib_use_dll=''
g4lib_use_dyn=''
g4lib_use_shared=''
g4lib_use_static=''
g4global=''
g4granular=''
g4lib_use_granular=''
g4debug=''
g4ui_build_gag_session=''
g4ui_build_terminal_session=''
g4ui_build_win32_session=''
g4ui_build_xaw_session=''
g4ui_build_xm_session=''
g4ui_none=''
g4ui_use_gag=''
g4ui_use_tcsh=''
g4ui_use_terminal=''
g4ui_use_win32=''
g4ui_use_xaw=''
g4ui_use_xm=''
g4ui_xawflags=''
g4ui_xawhome=''
g4ui_xawlibs=''
g4vis_xmflags=''
g4vis_xmhome=''
g4vis_xmlibs=''
g4ui_build_qt_session=''
g4ui_use_qt=''
g4vis_build_asciitree_driver=''
g4vis_build_dawn_driver=''
g4vis_build_dawnfile_driver=''
g4vis_build_oiwin32_driver=''
g4vis_build_oix_driver=''
g4vis_build_openglwin32_driver=''
g4vis_build_openglx_driver=''
g4vis_build_openglxm_driver=''
g4vis_build_raytracer_driver=''
g4vis_build_raytracerx_driver=''
g4vis_build_vrml_driver=''
g4vis_build_vrmlfile_driver=''
g4vis_oglhome=''
g4vis_oivhome=''
g4vis_use_asciitree=''
g4vis_use_dawn=''
g4vis_use_dawnfile=''
g4vis_use_oiwin32=''
g4vis_use_oix=''
g4vis_use_openglwin32=''
g4vis_use_openglx=''
g4vis_use_openglxm=''
g4vis_use_raytracer=''
g4vis_use_raytracerx=''
g4vis_use_vrml=''
g4vis_use_vrmlfile=''
g4vis_xmflags=''
g4vis_xmhome=''
g4vis_xmlibs=''
g4vis_build_openglqt_driver=''
g4vis_use_openglqt=''
g4gdml_xercesc_root=''
g4lib_build_gdml=''
g4wanalysis_build=''
g4wanalysis_build_jas=''
g4wanalysis_build_lab=''
g4wanalysis_build_lizard=''
g4wanalysis_use=''
g4wanalysis_use_jas=''
g4wanalysis_use_lab=''
g4wanalysis_use_lizard=''
g4_gmake=''
g4_gmake_version=''
g4_make=''
g4_make_version=''
g4make=''
g4w_use_g3tog4=''
g4wlib_build_g3tog4=''
g4w_use_zlib=''
g4wlib_build_zlib=''
lns=''
c=''
n=''
package=''
spackage=''
sh=''
sharpbang=''
shsharp=''
spitshell=''
src=''
startsh=''
CONFIG=''

define='define'
undef='undef'
smallmach='pdp11 i8086 z8000 i80286 iAPX286'
rmlist=''

: We must find out about Eunice early
eunicefix=':'
if test -f /etc/unixtovms; then
	eunicefix=/etc/unixtovms
fi
if test -f /etc/unixtovms.exe; then
	eunicefix=/etc/unixtovms.exe
fi

#INITIALIZE QT UI OPTIONS
g4ui_build_qt_session='n'
g4ui_use_qt='n'
g4_qthome=''
#END QT UI OPTIONS
#INITIALIZE QT UI OPTIONS
g4ui_build_qt_session='n'
g4ui_use_qt='n'
#END QT UI OPTIONS
#INITIALIZE QT VIS DRIVER OPTIONS
g4vis_build_openglqt_driver='n'
g4vis_use_openglqt='n'
#END QT VIS DRIVER OPTIONS
#INITIALIZE G4MAKE
g4make=""
#END G4MAKE INITIALIZATION

: Find the basic shell for Bourne shell scripts
case "$sh" in
'')
	case "$SYSTYPE" in
	*bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
	*) xxx='/bin/sh';;
	esac
	if test -f "$xxx"; then
		sh="$xxx"
	else
		: Build up a list and do a single loop so we can 'break' out.
		pth=`echo $PATH | sed -e "s/$p_/ /g"`
		for xxx in sh bash ksh pdksh ash; do
			for p in $pth; do
				try="$try ${p}/${xxx}"
			done
		done
		for xxx in $try; do
			if test -f "$xxx"; then
				sh="$xxx";
				break
			elif test -f "$xxx.exe"; then
				sh="$xxx";
				break
			fi
		done
	fi
	;;
esac

case "$sh" in
'')	cat <<EOM >&2
$me:  Fatal Error:  I can't find a Bourne Shell anywhere.  

Usually it's in /bin/sh.
Please contact Serguei.Sadilov@cern.ch and 
we'll try to straighten this all out.
EOM
	exit 1
	;;
esac

: see if sh knows # comments
if `$sh -c '#' >/dev/null 2>&1`; then
	shsharp=true
	spitshell=cat
	xcat=/bin/cat
	test -f $xcat || xcat=/usr/bin/cat
	echo "#!$xcat" >try
	$eunicefix try
	chmod +x try
#
# $xcat is wrong on WIN32: there is no /bin/cat and /usr/bin/cat by default.
# But we are sure that sharpbang is to be '#!' and let 'today' will be !=0.
#
#	./try > today
	echo "#!$xcat" >today

	if test -s today; then
		sharpbang='#!'
	else
		echo "#! $xcat" > try
		$eunicefix try
		chmod +x try
#
# $xcat is wrong on WIN32: there is no /bin/cat and /usr/bin/cat by default.
# But we are sure that sharpbang is to be '#!' and let 'today' will be !=0.
#
#	./try > today
	echo "#!$xcat" >today

		if test -s today; then
			sharpbang='#! '
		else
			sharpbang=': use '
		fi
	fi
else
	echo " "
	echo "Your $sh doesn't grok # comments--I will strip them later on."
	shsharp=false
	cd ..
	echo "exec grep -v '^[ 	]*#'" >spitshell
	chmod +x spitshell
	$eunicefix spitshell
	spitshell=`pwd`/spitshell
	cd UU
	echo "I presume that if # doesn't work, #! won't work either!"
	sharpbang=': use '
fi
rm -f try today

: figure out how to guarantee sh startup
case "$startsh" in
'') startsh=${sharpbang}${sh} ;;
*)
esac
cat >try <<EOSS
$startsh
set abc
test "$?abc" != 1
EOSS

chmod +x try
$eunicefix try
if ./try; then
	: echo "Yup, it does."
else
	echo "Hmm... '$startsh' does not guarantee sh startup..."
	echo "You may have to fix up the shell scripts to make sure $sh runs them."
fi
rm -f try

: produce awk script to parse command line options
cat >options.awk <<'EOF'
BEGIN {
	optstr = "dD:eEf:hKOrsSU:V";	# getopt-style specification

	len = length(optstr);
	for (i = 1; i <= len; i++) {
		c = substr(optstr, i, 1);
		if (i < len) a = substr(optstr, i + 1, 1); else a = "";
		if (a == ":") {
			arg[c] = 1;
			i++;
		}
		opt[c] = 1;
	}
}
{
	expect = 0;
	str = $0;
	if (substr(str, 1, 1) != "-") {
		printf("'%s'\n", str);
		next;
	}
	len = length($0);
	for (i = 2; i <= len; i++) {
		c = substr(str, i, 1);
		if (!opt[c]) {
			printf("-%s\n", substr(str, i));
			next;
		}
		printf("-%s\n", c);
		if (arg[c]) {
			if (i < len)
				printf("'%s'\n", substr(str, i + 1));
			else
				expect = 1;
			next;
		}
	}
}
END {
	if (expect)
		print "?";
}
EOF

: process the command line options
set X `for arg in "$@"; do echo "X$arg"; done |
	sed -e s/X// | awk -f options.awk`
eval "set $*"
shift
rm -f options.awk

: set up default values
fastread=''
reuseval=false
config_sh=''
alldone=''
error=''
silent=''
extractsh=''
override=''
knowitall=''
rm -f optdef.sh
cat >optdef.sh <<EOS
$startsh
EOS


: option parsing
while test $# -gt 0; do
	case "$1" in
	-d) shift; fastread=yes;;
	-e) shift; alldone=cont;;
	-build) shift; g4build=yes;;
	-incflags) shift; g4incflags=yes;;
	-install) shift; install=yes;;
	-cppflags) shift; g4cppflags=yes;;
	-cxxflags) shift; g4cxxflags=yes;;
	-ldlibs) shift; g4ldlibs=yes;;
	-ldflags) shift; g4ldflags=yes;;
	-f)
		shift
		cd ../..
		if test -r "$1"; then
			config_sh="$1"
		else
			echo "$me: cannot read config file $1." >&2
			error=true
		fi
		cd .config/UU
		shift;;
	-h) shift; error=true;;
	-r) shift; reuseval=true;;
	-s) shift; silent=true; realsilent=true;;
	-E) shift; alldone=exit;;
	-K) shift; knowitall=true;;
	-O) shift; override=true;;
	-S) shift; silent=true; extractsh=true;;
	-D)
		shift
		case "$1" in
		*=)
			echo "$me: use '-U symbol=', not '-D symbol='." >&2
			echo "$me: ignoring -D $1" >&2
			;;
		*=*) echo "$1" | \
				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
		*) echo "$1='define'" >> optdef.sh;;
		esac
		shift
		;;
	-U)
		shift
		case "$1" in
		*=) echo "$1" >> optdef.sh;;
		*=*)
			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
			echo "$me: ignoring -U $1" >&2
			;;
		*) echo "$1='undef'" >> optdef.sh;;
		esac
		shift
		;;
	-V) echo "$me generated by metaconfig 3.0 PL70." >&2
		exit 0;;
	--) break;;
	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
	*) break;;
	esac
done

case "$error" in
true)
	cat >&2 <<EOM
Usage: $me [-dehrsEKOSV] [-install] [-build] [-libs] [-f config.sh] [-D symbol] [-D symbol=value]
                 [-U symbol] [-U symbol=]
  -d : use defaults for all answers.
  -e : go on without questioning past the production of config.sh.
  -build : start configuration AND build of Geant4 libraries. 
  -cppflags : retrieve the list of cppflags
  -cxxflags : retrieve the list of cxxflags
  -incflags : retrieve the list of incflags
  -install : start installation of Geant4 libraries. 
  -ldflags : retrieve the list of directories where libraries are placed
  -ldlibs : retrieve the list of libraries to link
  -f : specify an alternate default configuration file.
  -h : print this help message and exit (with an error status).
  -r : reuse C symbols value if possible (skips costly nm extraction).
  -s : silent mode, only echoes questions and essential information.
  -D : define symbol to have some value:
         -D symbol         symbol gets the value 'define'
         -D symbol=value   symbol gets the value 'value'
  -E : stop at the end of questions, after having produced config.sh.
  -K : do not use unless you know what you are doing.
  -O : let -D and -U override definitions from loaded configuration file.
  -S : perform variable substitutions on all .SH files (can mix with -f)
  -U : undefine symbol:
         -U symbol    symbol gets the value 'undef'
         -U symbol=   symbol gets completely empty
  -V : print version number and exit (with a zero status).
EOM
	exit 1
	;;
esac

: Sanity checks
case "$fastread$alldone" in
yescont|yesexit) ;;
*)
	if test ! -t 0; then
		echo "Say 'sh Configure', not 'sh <Configure'"
		exit 1
	fi
	;;
esac

exec 4>&1
case "$silent" in
true) exec 1>/dev/null;;
esac

: run the defines and the undefines, if any, but leave the file out there...
touch optdef.sh
. ./optdef.sh

: set package name
package=g4conf

: Some greps do not return status, grrr.
echo "grimblepritz" >grimble
if grep blurfldyick grimble >/dev/null 2>&1 ; then
	contains=contains
elif grep grimblepritz grimble >/dev/null 2>&1 ; then
	contains=grep
else
	contains=contains
fi
rm -f grimble
: the following should work in any shell
case "$contains" in
contains*)
	echo " "
	echo "Grep doesn't return a status!!  Attempting remedial action."
	cat >contains <<'EOSS'
grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
EOSS
chmod +x contains
esac

: first determine how to suppress newline on echo command
#echo " "
#echo "Checking echo to see how to suppress newlines..."
(echo "hi there\c" ; echo " ") >.echotmp
if $contains c .echotmp >/dev/null 2>&1 ; then
#	echo "...using -n."
	n='-n'
	c=''
else
#	cat <<'EOM'
#...using \c
#EOM
	n=''
	c='\c'
fi
#echo $n "The star should be here-->$c"
#echo '*'
rm -f .echotmp

: compute the number of columns on the terminal for proper question formatting
case "$COLUMNS" in
'') COLUMNS='80';;
esac

: set up the echo used in my read
myecho="case \"\$xxxm\" in
'') echo $n \"\$rp $c\" >&4;;
*) case \"\$rp\" in
	'') echo $n \"[\$xxxm] $c\";;
	*)
		if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
			echo \"\$rp\" >&4
			echo $n \"[\$xxxm] $c\" >&4
		else
			echo $n \"\$rp [\$xxxm] $c\" >&4
		fi
		;;
	esac;;
esac"

: now set up to do reads with possible shell escape and default assignment
cat <<EOSC >myread
$startsh
xxxm=\$dflt
$myecho
ans='!'
case "\$fastread" in
yes) case "\$dflt" in
	'') ;;
	*) ans='';
		case "\$silent-\$rp" in
		true-) ;;
		*) echo " " >&4;;
		esac;;
	esac;;
*) case "\$silent" in
	true) case "\$rp" in
		'') ans='';;
		esac;;
	esac;;
esac
while expr "X\$ans" : "X!" >/dev/null; do
	read answ
	set x \$xxxm
	shift
	aok=''; eval "ans=\\"\$answ\\"" && aok=y
	case  "\$answ" in
	"!")
		sh 1>&4
		echo " "
		$myecho
		;;
	!*)
		set x \`expr "X\$ans" : "X!\(.*\)\$"\`
		shift
		sh 1>&4 -c "\$*"
		echo " "
		$myecho
		;;
	"\$ans")
		case "\$ans" in
		\\&*)
			set x \`expr "X\$ans" : "X&\(.*\)\$"\`
			shift
			case "\$1" in
			-d)
				fastread=yes
				echo "(OK, I'll run with -d after this question.)" >&4
				;;
			-*)
				echo "*** Sorry, \$1 not supported yet." >&4
				;;
			esac
			$myecho
			ans=!
			;;
		esac;;
	*)
		case "\$aok" in
		y)
			echo "*** Substitution done -- please confirm."
			xxxm="\$ans"
			ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
			xxxm="\$ans"
			ans=!
			;;
		*)
			echo "*** Error -- try again."
			ans=!
			;;
		esac
		$myecho
		;;
	esac
	case "\$ans\$xxxm\$nostick" in
	'')
		ans=!
		$myecho
		;;
	esac
done
case "\$ans" in
'') ans="\$xxxm";;
esac
EOSC

: Find the path to the source tree
case "$src" in
'') src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`
#echo "src=$src"
;;
esac
case "$src" in
'')
	src=.
	rsrc=..
	;;
/*) rsrc="$src/.."
#echo "rsrc=$rsrc"
;;
./*) 	cur_dir=`pwd`
	cd ../../$src
	src=`pwd`
	cd $cur_dir
	rsrc="$src/.."
rsrc="$src/.."
#echo "src=$src"
#echo "rsrc=$rsrc"
;;
*) rsrc="../../$src"
#echo "rsrc=$rsrc"
;;
esac
#cur_dir=`pwd`
#echo "cur_dir=$cur_dir"
if test -f $src/Configure && \
	$contains "^package=$package" $src/Configure >/dev/null 2>&1
then
   : found it, so we are ok.
else
	rsrc=''
	for src in . .. ../.. ../../.. ../../../..; do
		if test -f ../../$src/Configure && \
			$contains "^package=$package" ../../$src/Configure >/dev/null 2>&1
		then
			rsrc=../../$src
			break
		fi
	done
fi
case "$rsrc" in
'')
	echo " "
#	dflt=
#	rp="Directory where sources for $package are located?"
#	. ./myread
#	src="$ans"
	rsrc="$src"
#echo "src=$src"
#echo "rsrc=$rsrc"
	if test -f $rsrc/Configure && \
		$contains "^package=$package" $rsrc/Configure >/dev/null 2>&1
	then
		echo "Ok, I've found them under $src"
	else
		echo "Sorry, I can't seem to be able to locate $package sources." >&4
		echo "Please, use absolute path or relative with './' to Configure." >&4
		exit 1
	fi
	;;
../../.) ;;
*)
#	echo " "
#	echo "Sources for $package found in $src" >&4
	;;
esac

: script used to extract .SH files with variable substitutions
cat >extract <<'EOS'
CONFIG=true
#echo "Doing variable substitutions on .SH files..."
if test -f $src/MANIFEST; then
	set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH'`
else
#	echo "(Looking for .SH files under the source directory.)"
	set x `(cd $src; find ./config/scripts -name "*.SH" -print)`
fi
shift
case $# in
0) set x `(cd $src; echo *.SH)`; shift;;
esac
if test ! -f $src/$1; then
	shift
fi
mkdir_p='
name=$1;
create="";
while test $name; do
	if test ! -d "$name"; then
		create="$name $create";
		name=`echo $name | sed -e "s|^[^/]*$||"`;
		name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
	else
		name="";
	fi;
done;
for file in $create; do
	mkdir $file;
done
'
for file in $*; do
	case "$src" in
	".")
		case "$file" in
		*/*)
			dir=`expr X$file : 'X\(.*\)/'`
			file_SH=`expr X$file : 'X.*/\(.*\)'`
			file_EX=`expr X$file : 'X.*/\(.*\).SH'`
			(cd $dir && . ./$file_SH && mkdir -p $abssrc/.config/bin/$g4system && mv $file_EX $abssrc/.config/bin/$g4system)
#			echo Sergei_1
#			echo "file_SH=$file_SH"
#			echo "file_EX=$file_EX"
#			echo "file=$file"
#			echo "dir=$dir"
#			echo "src=$src"
#			echo "g4system=$g4system"
#			echo Sergei_1
			;;
		*)
			file_SH=`expr X$file : 'X.*/\(.*\)'`
			file_EX=`expr X$file : 'X.*/\(.*\).SH'`
			(. ./$file && mkdir -p $abssrc/.config/bin/$g4system && mv file-SH $abssrc/.config/bin/$g4system)
#			echo Sergei_2
#			echo "file_SH=$file_SH"
#			echo "file_EX=$file_EX"
#			echo "file=$file"
#			echo "dir=$dir"
#			echo "src=$src"
#			echo "g4system=$g4system"
#			echo Sergei_2
			;;
		esac
		;;
	*)
		case "$file" in
		*/*)
			dir=`expr X$file : 'X\(.*\)/'`
			file_SH=`expr X$file : 'X.*/\(.*\)'`
			file_EX=`expr X$file : 'X.*/\(.*\)\.SH'`
			(set x $dir; shift; eval $mkdir_p)

			(sh <$src/$dir/$file_SH && mkdir -p $src/.config/bin/$g4system && mv $file_EX $src/.config/bin/$g4system)

#			echo Sergei_3
#			echo "dir=$dir"
#			echo "file=$file"

#			echo Sergei_3
			;;
		*)
			file_SH=`expr X$file : 'X.*/\(.*\)'`
			file_EX=`expr X$file : 'X.*/\(.*\)\.SH'`
			(sh <$src/$file && mkdir -p $src/.config/bin/$g4system && mv $file_EX $src/.config/bin/$g4system)
			echo Sergei_4
			;;
		esac
		;;
	esac
done
if test -f $src/config_h.SH; then
	if test ! -f config.h; then
	: oops, they left it out of MANIFEST, probably, so do it anyway.
	. $src/config_h.SH
	fi
fi
EOS

: extract files and exit if asked to do so
case "$extractsh" in
true)
	case "$realsilent" in
	true) ;;
	*) exec 1>&4;;
	esac
	case "$config_sh" in
	'') config_sh='$g4conf/config.sh'; config="$g4conf/config.sh";;
	/*) config="$g4conf/$config_sh";;
	*) config="$g4conf/$config_sh";;
	esac
	echo " "
	echo "Fetching answers from $config_sh..."
	. $config
	test "$override" && . ./optdef.sh
	echo " "
	cd ../..
	. .config/UU/extract
	rm -rf .config/UU
	echo "Done."
	exit 0
	;;
esac

: Eunice requires " " instead of "", can you believe it
#echo " "
: Here we go...
#if [ X$install = Xyes ] ; then
#echo " "
#echo " "
#echo " "
#echo "                --- Geant4 Toolkit Installation  ---"
#echo " "
#echo " "
#echo " "
#echo " "
#else
#echo " "
#echo " "
#echo " "
#echo "                --- Geant4 Toolkit Installation  ---"
#echo "                  (setting environments for USER )"
#echo " "
#echo " "
#echo " "
#fi

trap 'echo " ";rm -rf ../../.config/UU; test -d ../../.config/UU && rm -rf X $rmlist; exit 1' 1 2 3 15

: create .config dir to save info across Configure sessions
test -d ../.config || mkdir ../.config
cat >../.config/README <<EOF
This directory created by Configure to save information that should
persist across sessions for $package.

You may safely delete it if you wish.
EOF

: general instructions
needman=true
firsttime=true
user=`(logname) 2>/dev/null`
case "$user" in
'') user=`whoami 2>&1`;;
esac

#if [ X$install = Xyes ] ; then
#
#echo " "
#echo " "
#echo " "
#echo "                --- Geant4 Toolkit Installation  ---"
#echo " "
#echo " "
#echo " "
#echo " "
#
##if $contains "^$user\$" ../../.config/instruct >/dev/null 2>&1; then
##	firsttime=false
##	echo " "
##	rp='Would you like to see the instructions?'
##	dflt=n
##	. ./myread
##	case "$ans" in
##	[yY]*) ;;
##	*) needman=false;;
##	esac
##fi
#fi

if [ X$g4build = Xyes ] ; then

echo " "
echo " "
echo " "
echo "                --- Geant4 Toolkit Build  ---"
echo " "
echo " "
echo " "
echo " "

if $contains "^$user\$" ../../.config/instruct >/dev/null 2>&1; then
	firsttime=false
	echo " "
	rp='Would you like to see the instructions?'
	dflt=n
	. ./myread
	case "$ans" in
	[yY]*) ;;
	*) needman=false;;
	esac
fi
fi

if [ X$install = Xyes ] ; then
needman=false
fi

if [ X$install = X -a X$g4build = X ] ; then
needman=false
fi

if $needman; then
	cat <<EOH
 
This installation shell script will examine your system and ask you questions
to determine how the Geant4 Toolkit should be installed.  If you get stuck on
a question, you may use a ! shell escape to start a subshell or execute a
command.  Many of the questions will have default answers in square brackets;
typing carriage return will set the default.

On AFS it is allowed to specify either absolute or relative
paths (i.e. starting with the ~username construct).

EOH
	rp=''
	dflt='Type carriage return to continue'
	. ./myread
	cat <<'EOH'

The prompt used in this script allows you to use shell variables and backticks
in your answers. You may use $1, $2, etc...  to refer to the words in the
default answer, as if the default line was a set of arguments given to a
script shell. This means you may also use $* to repeat the whole default line.

Everytime there is a substitution, you will have to confirm.  If there is an
error (e.g. an unmatched backtick), the default answer will remain unchanged
and you will be prompted again.

Running 'Configure -d' will bypass nearly all the questions and
use the computed defaults (or answers saved in a configuration
previously generated).

Type 'Configure -h' for a list of options.

You may also start interactively and then answer '& -d' at any prompt to turn
on the non-interactive behaviour for the rest of the execution.

EOH
	. ./myread
	cat <<EOH

Much effort has been spent to ensure that this shell script will run on any
Unix system. If despite that you can't run Configure for some reason, you'll
have to set the proper environment variables by hand and follow the "manual"
installation as specified in the Geant4 Installation Guide.

EOH
	dflt='Type carriage return to continue'
	. ./myread
	case "$firsttime" in
	true) echo $user >>../../.config/instruct;;
	esac
fi

: find out where common programs are
#echo " "
#echo "Locating common programs..." >&4
cat <<EOSC >loc
$startsh
case \$# in
0) exit 1;;
esac
thing=\$1
shift
dflt=\$1
shift
for dir in \$*; do
	case "\$thing" in
	.)
	if test -d \$dir/\$thing; then
		echo \$dir
		exit 0
	fi
	;;
	*)
	for thisthing in \$dir/\$thing; do
		: just loop through to pick last item
	done
	if test -f \$thisthing; then
		echo \$thisthing
		exit 0
	elif test -f \$dir/\$thing.exe; then
		: on Eunice apparently
		echo \$dir/\$thing
		exit 0
	fi
	;;
	esac
done
echo \$dflt
exit 1
EOSC
chmod +x loc
$eunicefix loc
loclist="
awk
cat
echo
expr
grep
rm
sed
touch
tr
"
trylist="
date
gcc
ln
test
uname
"
pth=`echo $PATH | sed -e "s/$p_/ /g"`
pth="$pth /lib /usr/lib"
for file in $loclist; do
	eval xxx=\$$file
	case "$xxx" in
	/*|?:[\\/]*)
		if test -f "$xxx"; then
			: ok
		else
			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
			xxx=`./loc $file $file $pth`
		fi
		;;
	'') xxx=`./loc $file $file $pth`;;
	*) xxx=`./loc $xxx $xxx $pth`;;
	esac
	eval $file=$xxx
	eval _$file=$xxx
	case "$xxx" in
	/*)
		echo "$file is in $xxx." > /dev/null
		;;
	?:[\\/]*)
		echo "$file is in $xxx." > /dev/null
		;;
	*)
		echo "I don't know where '$file' is." >&4
		echo "Please, install it or fix your PATH settings!" >&4
		exit 1
		;;
	esac
done
#echo " "
#echo "Don't worry if any of the following aren't found..."
say=offhand
for file in $trylist; do
	eval xxx=\$$file
	case "$xxx" in
	/*|?:[\\/]*)
		if test -f "$xxx"; then
			: ok
		else
			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
			xxx=`./loc $file $file $pth`
		fi
		;;
	'') xxx=`./loc $file $file $pth`;;
	*) xxx=`./loc $xxx $xxx $pth`;;
	esac
	eval $file=$xxx
	eval _$file=$xxx
	case "$xxx" in
	/*)
		echo "$file is in $xxx." > /dev/null
		;;
	?:[\\/]*)
		echo "$file is in $xxx." > /dev/null
		;;
	*)
		echo "I don't see $file out there, $say."
		say=either
		;;
	esac
done
case "$egrep" in
egrep)
#	echo "Substituting grep for egrep."
	egrep=$grep
	;;
esac
case "$ln" in
ln)
#	echo "Substituting cp for ln."
	ln=$cp
	;;
esac
case "$test" in
test)
	echo "Hopefully test is built into your sh." > /dev/null
	;;
*)
	if `sh -c "PATH= test true" >/dev/null 2>&1`; then
		echo "Using the test built into your sh." > /dev/null
		test=test
		_test=test
	fi
	;;
esac
case "$echo" in
echo)
	echo "Hopefully echo is built into your sh." > /dev/null
	;;
'') ;;
*)
#	echo " "
#echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
	$echo $n "hi there$c" >foo1
	echo $n "hi there$c" >foo2
	if cmp foo1 foo2 >/dev/null 2>&1; then
		echo "They are compatible.  In fact, they may be identical." > /dev/null
	else
		case "$n" in
		'-n') n='' c='\c';;
		*) n='-n' c='';;
		esac
#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
	;;
esac

: determine whether symbolic links are supported
#echo " "
$touch blurfl
if $ln -s blurfl sym > /dev/null 2>&1 ; then
#	echo "Symbolic links are supported." >&4
	lns="$ln -s"
else
#	echo "Symbolic links are NOT supported." >&4
	lns="$ln"
fi
$rm -f blurfl sym

: see whether [:lower:] and [:upper:] are supported character classes
#echo " "
up='[A-Z]'
low='[a-z]'
case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
ABYZ)
#	echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
	up='[:upper:]'
	low='[:lower:]'
	;;
*)
#	echo "Your tr only supports [a-z] and [A-Z] to convert case." >&4
	;;
esac
: set up the translation script tr, must be called with ./tr of course
cat >tr <<EOSC
$startsh
case "\$1\$2" in
'[A-Z][a-z]') exec $tr '$up' '$low';;
'[a-z][A-Z]') exec $tr '$low' '$up';;
esac
exec $tr "\$@"
EOSC
chmod +x tr
$eunicefix tr

: Try to determine whether config.sh was made on this system
case "$config_sh" in
'')
myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`

mygcc=`( ($g++ -v) 2>/dev/null) 2>&1`
myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
	./tr '[A-Z]' '[a-z]' | tr '\012' ' '`
newmyuname="$myuname"
dflt=n
case "$knowitall" in
'')
	if test -f ../config.sh; then
		if $contains myuname= ../config.sh >/dev/null 2>&1; then
			eval "`grep myuname= ../config.sh`"
		fi
		if test "X$myuname" = "X$newmyuname"; then
			dflt=y
		fi
	fi
	;;
*) dflt=y;;
esac

: Get old answers from old config file if Configure was run on the
: same system, otherwise use the hints.
hint=default
cd ../..

	if $test -d $src/hints ; then
	(cd $src/hints; ls -C *.sh 2> /dev/null) | $sed 's/\.sh/   /g' >&4 
	fi
	dflt=''
	: Half the following guesses are probably wrong... If you have better
	: tests or hints, please send them to Serguei.Sadilov@cern.ch
	: The metaconfig authors would also appreciate a copy...
	$test -f /irix && osname=irix
	$test -f /xenix && osname=sco_xenix
	$test -f /dynix && osname=dynix
	$test -f /dnix && osname=dnix
	$test -f /lynx.os && osname=lynxos
	$test -f /unicos && osname=unicos && osvers=`$uname -r`
	$test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
	$test -f /bin/mips && /bin/mips && osname=mips
	$test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
		$sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
	$test -d /usr/apollo/bin && osname=apollo
	$test -f /etc/saf/_sactab && osname=svr4
	$test -d /usr/include/minix && osname=minix
	if $test -d /MachTen; then
		osname=machten
		if $test -x /sbin/version; then
			osvers=`/sbin/version | $awk '{print $2}' |
			$sed -e 's/[A-Za-z]$//'`
		elif $test -x /usr/etc/version; then
			osvers=`/usr/etc/version | $awk '{print $2}' |
			$sed -e 's/[A-Za-z]$//'`
		else
			osvers="$2.$3"
		fi
	fi
	if $test -f $uname; then
		set X $myuname
		shift

		case "$5" in
		fps*) osname=fps ;;
		mips*)
			case "$4" in
			umips) osname=umips ;;
			*) osname=mips ;;
			esac;;
		[23]100) osname=mips ;;
		next*) osname=next ;;
		news*) osname=news ;;
		i386*)
			if $test -f /etc/kconfig; then
				osname=isc
				if test "$lns" = "ln -s"; then
					osvers=4
				elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
					osvers=3
				elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
					osvers=2
				fi
			fi
			;;
		esac

		case "$1" in
		aix) osname=aix
			tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
			case "$tmp" in
			'not found') osvers="$4"."$3" ;;
			'<3240'|'<>3240') osvers=3.2.0 ;;
			'=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
			'=3250'|'>3250') osvers=3.2.5 ;;
			*) osvers=$tmp;;
			esac
			;;
		*dc.osx) osname=dcosx
			osvers="$3"
			;;
		dnix) osname=dnix
			osvers="$3"
			;;
		cygwin*) osname=win32
			;;
		darwin*) osname=darwin
			;;
		domainos) osname=apollo
			osvers="$3"
			;;
		dgux) osname=dgux 
			osvers="$3"
			;;
		dynixptx*) osname=dynixptx
			osvers="$3"
			;;
		freebsd) osname=freebsd 
			osvers="$3" ;;
		genix) osname=genix ;;
		hp*) osname=hpux 
			case "$3" in
			*.08.*) osvers=9 ;;
			*.09.*) osvers=9 ;;
			*.10.*) osvers=10 ;;
			*)	osvers="$3" ;;
			esac
			;;
		irix*) osname=irix
			case "$3" in
			4*) osvers=4 ;;
			5*) osvers=5 ;;
			*)	osvers="$3" ;;
			esac
			;;
		linux) osname=linux
			case "$3" in
			1*) osvers=1 ;;
			*)	osvers="$3" ;;
			esac
			;;
		netbsd*) osname=netbsd 
			osvers="$3"
			;;
		bsd386) osname=bsd386
			osvers=`$uname -r`
			;;
		next*) osname=next ;;
		solaris) osname=solaris
			case "$3" in
			5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
			*)	osvers="$3" ;;
			esac
			;;
		sunos) osname=sunos
			case "$3" in
			5*) osname=solaris
				osvers=`echo $3 | $sed 's/^5/2/g'` ;;
			*)	osvers="$3" ;;
			esac
			;;
		titanos) osname=titanos
			case "$3" in
			1*) osvers=1 ;;
			2*) osvers=2 ;;
			3*) osvers=3 ;;
			4*) osvers=4 ;;
			*)	osvers="$3" ;;
			esac
			;;
		ultrix) osname=ultrix
			osvers="$3"
			;;
		osf1|mls+)	case "$5" in
				alpha)
					osname=dec_osf
					osvers=`echo "$3" | sed 's/^[vt]//'`
					;;
			hp*)	osname=hp_osf1	;;
			mips)	osname=mips_osf1 ;;
			esac
			;;
		uts) osname=uts 
			osvers="$3"
			;;
		qnx) osname=qnx
			osvers="$4"
			;;
		$2) case "$osname" in
			*isc*) ;;
			*freebsd*) ;;
			svr*)
				: svr4.x or possibly later
				case "svr$3" in	
				${osname}*)
					osname=svr$3
					osvers=$4
					;;
				esac
				case "$osname" in
				svr4.0)
					: Check for ESIX
					if test -f /stand/boot ; then
						eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
						if test -n "$INITPROG" -a -f "$INITPROG"; then
			isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
							if test -n "$isesix"; then
								osname=esix4
							fi
						fi
					fi
					;;
				esac
				;;
			*)	if test -f /etc/systemid; then
					osname=sco
					set `echo $3 | $sed 's/\./ /g'` $4
					if $test -f sco_$1_$2_$3.sh; then
						osvers=$1.$2.$3
					elif $test -f sco_$1_$2.sh; then
						osvers=$1.$2
					elif $test -f sco_$1.sh; then
						osvers=$1
					fi
				else
					case "$osname" in
					'') : Still unknown.  Probably a generic Sys V.
						osname="sysv"
						osvers="$3"
						;;
					esac
				fi
				;;
			esac
			;;
		*)	case "$osname" in
			'') : Still unknown.  Probably a generic BSD.
				osname="$1"
				osvers="$3"
				;;
			esac
			;;
		esac
	else
		if test -f /vmunix -a -f $src/hints/news_os.sh; then
			(what /vmunix | .config/UU/tr '[A-Z]' '[a-z]') > .config/UU/kernel.what 2>&1
			if $contains news-os .config/UU/kernel.what >/dev/null 2>&1; then
				osname=news_os
			fi
			$rm -f .config/UU/kernel.what
		elif test -d c:/.; then
			set X $myuname
			osname=os2
			osvers="$5"
		fi
	fi
	: Now look for a hint file osname_osvers, unless one has been
	: specified already.
	case "$hintfile" in
	''|' ')
		file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
		: Also try without trailing minor version numbers.
		xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
		xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
		xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
		xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
		case "$file" in
		'') dflt=none ;;
		*)  case "$osvers" in
			'') dflt=$file
				;;
			*)  if $test -f $src/hints/$file.sh ; then
					dflt=$file
				elif $test -f $src/hints/$xfile.sh ; then
					dflt=$xfile
				elif $test -f $src/hints/$xxfile.sh ; then
					dflt=$xxfile
				elif $test -f $src/hints/$xxxfile.sh ; then
					dflt=$xxxfile
				elif $test -f $src/hints/$xxxxfile.sh ; then
					dflt=$xxxxfile
				elif $test -f "$src/hints/${osname}.sh" ; then
					dflt="${osname}"
				else
					dflt=none
				fi
				;;
			esac
			;;
		esac
		;;
	*)
		dflt=`echo $hintfile | $sed 's/\.sh$//'`
		;;
	esac

if [ X$install = Xnever ] ; then
	$cat <<EOM

You may give one or more space-separated answers, or "none" if appropriate.
If your OS version has no hints, DO NOT give a wrong version -- say "none".

EOM
	rp="Which of these apply, if any?"
	. .config/UU/myread
	tans=$ans
	for file in $tans; do
		if $test -f $src/hints/$file.sh; then
			. $src/hints/$file.sh
			$cat $src/hints/$file.sh >> .config/UU/config.sh
		elif $test X$tans = X -o X$tans = Xnone ; then
			: nothing
		else
			: Give one chance to correct a possible typo.
			echo "$file.sh does not exist"
			dflt=$file
			rp="hint to use instead?"
			. .config/UU/myread
			for file in $ans; do
				if $test -f "$src/hints/$file.sh"; then
					. $src/hints/$file.sh
					$cat $src/hints/$file.sh >> .config/UU/config.sh
				elif $test X$ans = X -o X$ans = Xnone ; then
					: nothing
				else
					echo "$file.sh does not exist -- ignored."
				fi
			done
		fi
	done
fi

	hint=recommended
	: Remember our hint file for later.
	if $test -f "$src/hints/$file.sh" ; then
		hintfile="$file"
	else
		hintfile=''
	fi
	: Sadilov: g4system.U - inserted here.
	: 'current' directory is where 'Configure' is started 
#echo " "
case "$g4osname" in

'')
	case "$osname" in
		'aix')		g4osname=AIX
				;;
		'dec_osf')	g4osname=DEC
				;;
		'hpux')		g4osname=HP
				;;
		'linux')	g4osname=Linux
				;;
		'irix')		g4osname=SGI
				;;
		'sunos')	g4osname=SUN
				;;
		'solaris')	g4osname=SUN
				;;
		'win32')	g4osname=WIN32
				;;
		'darwin')	g4osname=Darwin
				;;
	esac
esac

#echo " "

case  "$g4compiler" in

'')	
	case "$g4osname" in
		'AIX')
				g4compiler=xlC
				;;
		'DEC')
				g4compiler=cxx
				;;
		'HP')
				g4compiler=aCC
				;;
		'Linux')
#				g4compiler=g++
# Assume if "gcc" is in place then "g++" is here
	gcccompiler=`( ($gcc -v) 1>/dev/null || echo "ERROR: There is no 'gcc' ('g++'?) compiler.") 2>&1`
				case $gcccompiler in
				*egcs*) g4compiler=egcs
				;;
				*2.96*) 
				echo "WARNING: Found version of 'g++' (2.96.XXX) is known to be buggy!"
				g4compiler="g++"
				;;
				*) g4compiler="g++"
				;;
				esac				

				;;
		'SGI')
				g4compiler=CC
				;;
		'SUN')
				g4compiler=CC
				;;
		'WIN32')
				g4compiler=VC
	clcompiler=`( cl 1>/dev/null || echo "ERROR: There is no 'cl' compiler.") 2>&1`
				case $clcompiler in
				*"Version 12"*) g4compiler=VC6
				;;
				*"Version 13"*) g4compiler=VC
				;;
				*) g4compiler=VC
				;;
				esac				
				;;
		'Darwin')
				g4compiler=g++
				;;
	esac
esac

if [ X$g4system = X ] ; then

if [ X$g4build = Xyes ] ; then
while test 1 = 1  ; do

g4message=`cat << EOM

Definition of G4SYSTEM variable is $g4osname-$g4compiler.
That stands for:

1) OS		: $g4osname

2) Compiler	: $g4compiler

To modify default settings, select number above (e.g. 2) 
EOM`

dflt="Press [Enter] for default settings"
rp=$g4message
. .config/UU/myread
gans=$ans

	case $gans in

	1) 
		case "$osname" in
			'aix')
					g4osnamerec=AIX
					;;
			'dec_osf')
					g4osnamerec=DEC
					;;
			'hpux')	
					g4osnamerec=HP
					;;
			'linux')
					g4osnamerec=Linux
					;;
			'irix')	
					g4osnamerec=SGI
					;;
			'sunos')
					g4osnamerec=SUN
					;;
			'win32')
					g4osnamerec=WIN32
					;;
			'darwin')
					g4osnamerec=Darwin
					;;
		esac
		dflt=$g4osname
		rp="What is your OS'?"
		. .config/UU/myread
		tans=$ans

		if test X$tans != X$g4osnamerec ; then
		echo ""

cat << EOM

		You are running 'Configure' on NOT native platform!
		You are on your own way !!!

EOM

		dflt=$tans
		rp="Confirm your selection or set native '$g4osnamerec'!"
		. .config/UU/myread
		tans=$ans
		fi

		g4osname=$tans
		;;
	2) 
		case "$g4osname" in
			'AIX')
					g4compilerrec=xlC
					;;
			'DEC')
					g4compilerrec=cxx
					;;
			'HP')
					g4compilerrec=aCC
					;;
			'Linux')
					g4compilerrec=g++
					;;
			'SGI')
					g4compilerrec=CC
					;;
			'SUN')
					g4compilerrec=CC
					;;
			'WIN32')
					g4compilerrec=VC
					;;
			'Darwin')
					g4compilerrec=g++
					;;
		esac
		dflt=$g4compiler
		rp="Which C++ compiler?"
		. .config/UU/myread
		tans=$ans

		if test X$tans != X$g4compilerrec ; then
		echo ""

cat << EOM

		The recommmended compiler for this platform ($g4osname) is $g4compilerrec.
		You are on your own way !!!

EOM

		dflt=$tans
		rp="Confirm your selection or set recommended '$g4compilerrec'!"
		. .config/UU/myread
		tans=$ans
		fi

		g4compiler=$tans
		;;
#	[eE]) 
#		break
#		;;
	*) 
#		echo " "
		break
		;;
	esac
done

fi

#
# Ask about compiler used. 
#
g4system=$g4osname-$g4compiler

fi

#cat << EOM
#
#G4SYSTEM is now set to $g4system.
#
#EOM

cd .config/UU

myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
	./tr '[A-Z]' '[a-z]' | tr '\012' ' '`
newmyuname="$myuname"
dflt=n

cd ../..


if [ X$g4build = X ] ; then

	if test -f $src/.config/bin/$g4system/env.sh; then

	# create not_display flag

if [ X$g4ldlibs != X -o X$g4ldflags != X -o X$g4cxxflags != X -o X$g4cppflags != X -o X$g4incflags != X ] ; then
	g4non_display=yes
#	echo g4non_display=$g4non_display
fi

	if [ X$install = Xyes ] ; then

	$rm -rf .config/UU
	
	. $src/.config/bin/$g4system/move.sh

	exit 1

	fi #end of cppflags

	if [ X$g4cppflags = Xyes ] ; then

	. $src/.config/bin/$g4system/env.sh

	CPPFLAGS=`grep 'CPPFLAGS_FINAL :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'`

#	echo CPPFLAGS=$CPPFLAGS
	echo $CPPFLAGS
	
	$rm -rf .config/UU
	exit 1

	fi #end of cppflags

	if [ X$g4cxxflags = Xyes ] ; then

	. $src/.config/bin/$g4system/env.sh

	CXXFLAGS=`grep 'CXXFLAGS_FINAL :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'`

#	echo CXXFLAGS=$CXXFLAGS
	echo $CXXFLAGS
	
	$rm -rf .config/UU
	exit 1

	fi #end of cxxflags



	g4install_lib_AAA=`echo $g4install/lib|sed -e "s/\//AAA/g"`
	g4final_install_lib_AAA=`echo $g4final_install/lib/geant4|sed -e "s/\//AAA/g"`
	

#############################################################################
	if [ X$g4incflags = Xyes ] ; then

	. $src/.config/bin/$g4system/env.sh

### Getting G4FIRST_INSTALL
	G4FIRST_INSTALL_AAA=`grep 'G4INSTALL =' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\)= //'|$sed -e 's/\//AAA/g'`
	G4INSTALL_AAA=`echo $G4INSTALL|sed -e "s/\//AAA/g"`
###
	INCFLAGS_AAA=`grep 'INCFLAGS_FINAL :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'|$sed -e 's/\//AAA/g'`

#	echo INCFLAGS_AAA=$INCFLAGS_AAA
#	echo G4INSTALL_AAA=$G4INSTALL_AAA
#	echo G4FIRST_INSTALL_AAA=$G4FIRST_INSTALL_AAA

	INCFLAGS_AAA_NEW=`echo $INCFLAGS_AAA| $sed -e "s/$G4FIRST_INSTALL_AAA/$G4INSTALL_AAA/g"`

#	echo INCFLAGS_AAA_NEW=$INCFLAGS_AAA_NEW

	INCFLAGS=`echo $INCFLAGS_AAA_NEW| $sed -e "s/AAA/\//g"`

#	echo INCFLAGS=$INCFLAGS

	if [ X$G4INCLUDE = X ] ; then
	echo $INCFLAGS
	else
	echo -I$G4INCLUDE
	fi
	
	$rm -rf .config/UU
	exit 1

	fi #end of incflags
#############################################################################


#############################################################################
	if [ X$g4ldflags = Xyes ] ; then

	. $src/.config/bin/$g4system/env.sh

### Getting G4FIRST_INSTALL
	G4FIRST_LIB_AAA=`grep 'G4LIB =' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\)= //'|$sed -e 's/\//AAA/g'`
	G4LIB_AAA=`echo $G4LIB|sed -e "s/\//AAA/g"`
###
#	G4FIRST_INSTALL_LIB_AAA=${G4FIRST_INSTALL_AAA}AAAlib
#	G4INSTALL_LIB_AAA=${G4INSTALL_AAA}AAAlibAAAgeant4

#	echo G4FIRST_INSTALL_LIB_AAA=$G4FIRST_INSTALL_LIB_AAA
#	echo G4INSTALL_LIB_AAA=$G4INSTALL_LIB_AAA
	
	LDFLAGS_AAA=`grep 'LDFLAGS_FINAL :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'|$sed -e 's/\//AAA/g'`
	LDFLAGS_AAA_NEW=`echo $LDFLAGS_AAA| $sed -e "s/$G4FIRST_LIB_AAA/$G4LIB_AAA/g"`
	LDFLAGS=`echo $LDFLAGS_AAA_NEW| $sed -e "s/AAA/\//g"`

#	echo LDFLAGS=$LDFLAGS
	echo $LDFLAGS
	
	$rm -rf .config/UU
	exit 1

	fi #end of ldflags
#############################################################################

	if [ X$g4ldlibs = Xyes ] ; then

#	cat >&2 <<EOM
#---------------------------------------------------
#LibList mode :)
#---------------------------------------------------
#EOM
	
	. $src/.config/bin/$g4system/env.sh

#	echo TEST

#	ls -l $G4INSTALL/config/scripts/GNUmakefile
#	ls -l $G4LIB/$G4SYSTEM/GNUmakefile.db

#	LDLIBS_1=`grep 'LDLIBS_FINAL :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | awk -F := '{print $2}'`
#	LDLIBS_2=`echo $LDLIBS_1 | awk -F -lMarker '{print $2}'`

#	echo LDLIBS_2=$LDLIBS_2
#	echo $LDLIBS_2

	if [ X$G4LIB_USE_GRANULAR = X ] ; then
	
# Global libs

###	LDLIBS_1=`grep 'LDLIBS_FINAL :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'`
###	LDLIBS_2=`echo $LDLIBS_1 | $sed  -e 's/^\(.*\)-lMarker//'`
###	echo "$LDLIBS_2 $c"

	LIBLIST_LIST=`$G4LIB/$G4SYSTEM/liblist -m $G4LIB/$G4SYSTEM < $G4LIB/$G4SYSTEM/libname.map`

	LDLIBS3=`grep 'LDLIBS3 :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'`
	LDLIBS4=`grep 'LDLIBS4 :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'`

	LDLIBS=$LIBLIST_LIST $LDLIBS3 $LDLIBS4

	echo $LDLIBS

#	echo "-L$G4WORKDIR/lib/$G4SYSTEM -lG4persistency -lG4readout -lG4run -lG4event -lG4tracking -lG4parmodels -lG4processes -lG4digits+hits -lG4track -lG4particles -lG4geometry -lG4materials -lG4graphics_reps -lG4intercoms -lG4global $c"

	$rm -rf .config/UU
	exit 1

	else 

# Granular libs

#	echo $n "-L$G4WORKDIR/lib/$G4SYSTEM $c" ; $G4WORKDIR/lib/$G4SYSTEM/liblist -m $G4WORKDIR/lib/$G4SYSTEM < $G4WORKDIR/lib/$G4SYSTEM/libname.map

#	echo G4LIB=$G4LIB/$G4SYSTEM

	LIBLIST_LIST=`$G4LIB/$G4SYSTEM/liblist -m $G4LIB/$G4SYSTEM < $G4LIB/$G4SYSTEM/libname.map`

	LDLIBS3=`grep 'LDLIBS3 :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'`
	LDLIBS4=`grep 'LDLIBS4 :=' $G4LIB/$G4SYSTEM/GNUmakefile.db | $sed  -e 's/^\(.*\):=//'`

	LDLIBS=$LIBLIST_LIST $LDLIBS3 $LDLIBS4	

	echo $LDLIBS	
	
	$rm -rf .config/UU

	exit 1
	fi #end of check for global/granular

	else #if not -lib but user mode

# header for User
echo " "
echo " "
echo " "
echo "                --- Geant4 Toolkit Installation  ---"
echo "                  (setting environments for USER )"
echo " "
echo " "
echo " "

#cat << EOM
#
#G4SYSTEM is now set to $g4system.
#
#EOM

	cat >&2 <<EOM
---------------------------------------------------
The Geant4 toolkit installation was found.
The files env.[c]sh will be copied to your current directory.
For setting Geant4 environments you should make:

source env.csh

or

. env.sh

It will also check G4WORKDIR setting and set it to
your HOME if needed.
You can use these files also for further modifications
(adding your own environments).
---------------------------------------------------
EOM
	$rm -rf .config/UU

cp -i $src/.config/bin/$g4system/env.csh .
cp -i $src/.config/bin/$g4system/env.sh  .

	exit 1
	fi #end of -lib or user
else #there is no env.sh

# header for Installer
echo " "
echo " "
echo " "
echo "                --- Geant4 Toolkit Installation  ---"
echo " "
echo " "
echo " "
echo " "

	echo " "
	echo "WARNING: Geant4 is NOT built yet!"
	echo "You (or the administrator if you have not enough privileges)"
	echo "should start with \$G4INSTALL/Configure -build."
	echo "(where \$G4INSTALL is Geant4 install directory)."
	echo " "
	$rm -rf .config/UU
	exit 1
 fi #end of check for existence of env.sh 
fi #end of check for "not -install"

cd .config/UU

case "$knowitall" in
'')
	cd ../..
	if test -f $src/.config/bin/$g4system/config.sh; then
		if $contains myuname= $src/.config/bin/$g4system/config.sh >/dev/null 2>&1; then
			eval "`grep myuname= $src/.config/bin/$g4system/config.sh`"
		fi
		if test "X$myuname" = "X$newmyuname"; then
			dflt=y
		fi
	fi
	cd .config/UU
	;;
*) dflt=y;;
esac

cd ../..

if test -f $src/.config/bin/$g4system/config.sh; then
	echo " "
	rp="There exists a config.sh file. Shall I use it to set the defaults?"
	. .config/UU/myread
	case "$ans" in
	n*|N*) echo "OK, I'll ignore it."; mv $src/.config/bin/$g4system/config.sh $src/.config/bin/$g4system/config.sh.old;;
	*)  echo "Fetching default answers from your old config.sh file..." >&4
		tmp_n="$n"
		tmp_c="$c"
		tmp_sh="$sh"
		. $src/.config/bin/$g4system/config.sh
		cp $src/.config/bin/$g4system/config.sh .config/UU
		n="$tmp_n"
		c="$tmp_c"
		: Older versions did not always set $sh.  Catch re-use of such
		: an old config.sh.
		case "$sh" in
		'') sh="$tmp_sh" ;;
		esac
		hint=previous
		;;
	esac
fi

cd .config/UU
;;
*)
	echo " "
	echo "Fetching default answers from $config_sh..." >&4
	tmp_n="$n"
	tmp_c="$c"
	cd ../..
	cp $config_sh config.sh 2>/dev/null
	chmod +w config.sh
	. ./config.sh
	cd .config/UU
	cp ../config.sh .
	n="$tmp_n"
	c="$tmp_c"
	hint=previous
	;;
esac
test "$override" && . ./optdef.sh
myuname="$newmyuname"

: Restore computed paths
for file in $loclist $trylist; do
	eval $file="\$_$file"
done


: who configured the system
cf_time=`$date 2>&1`
cf_by=`(logname) 2>/dev/null`
case "$cf_by" in
"")
	cf_by=`(whoami) 2>/dev/null`
	case "$cf_by" in
	"") cf_by=unknown ;;
	esac ;;
esac

cat <<EOSC >qt
$startsh
#
# Autoconf(ish) style check for Qt headers, libraries and moc application
#

#
# These are variables that the final unit generated script may use
#
with_qt_dir="\$qt_search_dir"

#
# Only run if we haven't succesfully found Qt already
#
if test "x\$g4_qt_is_configured" = "x" ; then
    #
    # Flag specifying if we've configured Qt o.k.
    #
    g4_qt_is_configured="yes" # Optimism

    # Flag to be set if any part of configuration fails
    g4_havegoodqt="yes" # Optimism

    # Qt4 flag
    g4_is_qt4="no"

    # Variables to be set
    g4_qt_include_dir=''
    g4_qt_lib_dir=''
    g4_qt_moc=''

    g4_qt_version=''
    g4_qt_cxxflags=''
    g4_qt_gl_cxxflags=''
    g4_qt_libs=''
    g4_qt_gl_libs=''

    #
    # User may supply a value for 'QTDIR' and in that case we ASSUME a
    # Trolltech style installation or a Mac Framework
    #
    if test "x\$with_qt_dir" != "x" ; then
        g4_qt_dir="\$with_qt_dir"
        g4_qt_possible_qt_include_dirs="\$with_qt_dir/include/QtCore
                                        \$with_qt_dir/include/Qt 
                                        \`ls -dr \$with_qt_dir/include/qt*/QtCore 2>/dev/null\` 
                                        \`ls -dr \$with_qt_dir/include/qt*/Qt 2>/dev/null\` 
                                        \`ls -dr \$with_qt_dir/include/qt* 2>/dev/null\` 
                                        \$with_qt_dir/include
                                        \$with_qt_dir/QtCore.framework/Headers"

        # Check for qglobal.h
        g4_qglobal_loc=\`./loc qglobal.h no \$g4_qt_possible_qt_include_dirs\`

        if test "x\$g4_qglobal_loc" = "xno" ; then
            g4_havegoodqt=no
            g4_qt_include_dir=no
        fi
        echo "checking for qglobal.h... \$g4_qglobal_loc"

        if test "x\$g4_qglobal_loc" != "xno" ; then
            g4_qt_include_dir="\`dirname \$g4_qglobal_loc\`"
        fi

    else
        # We use standard search paths...
        qt_direct_test_header="qglobal.h"

        g4_qt_include_path_list="
            \`ls -dr /Library/Frameworks/QtCore.framework/Headers 2>/dev/null\` 
            \`ls -dr /System/Library/Frameworks/QtCore.framework/Headers 2>/dev/null\`
            /usr/include/QtCore
            \`ls -dr /usr/include/qt*/QtCore 2>/dev/null\`
	    \`ls -dr /usr/local/include/QtCore 2>/dev/null\`
            \`ls -dr /usr/local/include/qt*/QtCore 2>/dev/null\`
	    \`ls -dr /usr/local/qt*/include/QtCore 2>/dev/null\` 
            \`ls -dr /opt/qt*/include/QtCore 2>/dev/null\` 
            \`ls -dr /usr/qt*/include/QtCore 2>/dev/null\`
            \`ls -dr /usr/qt/*/include/QtCore 2>/dev/null\` 
            \`ls -dr /usr/include/qt/*/QtCore 2>/dev/null\`
            \`ls -dr /sw/include/QtCore 2>/dev/null\`
            \`ls -dr /sw/qt*/include/QtCore 2>/dev/null\`
            \`ls -dr /sw/qt/*/include/QtCore 2>/dev/null\`
            /usr/include
            \`ls -dr /usr/include/qt* 2>/dev/null\`
            \`ls -dr /usr/local/include 2>/dev/null\`
	    \`ls -dr /usr/local/include/qt* 2>/dev/null\`
            \`ls -dr /usr/local/qt*/include 2>/dev/null\`
            \`ls -dr /opt/qt*/include 2>/dev/null\` 
            \`ls -dr /usr/qt*/include 2>/dev/null\`
            \`ls -dr /usr/qt/*/include 2>/dev/null\` 
            \`ls -dr /usr/include/qt/* 2>/dev/null\`
            \`ls -dr /sw/include 2>/dev/null\`
            \`ls -dr /sw/qt*/include 2>/dev/null\`
            \`ls -dr /sw/qt/*/include 2>/dev/null\`
            /usr/include/Qt
            \`ls -dr /usr/include/qt*/Qt 2>/dev/null\`
            \`ls -dr /usr/local/include/Qt 2>/dev/null\`
            \`ls -dr /usr/local/include/qt*/Qt 2>/dev/null\`
            \`ls -dr /opt/qt*/include/Qt 2>/dev/null\` 
            \`ls -dr /usr/qt*/include/Qt 2>/dev/null\`
            \`ls -dr /usr/qt/*/include/Qt 2>/dev/null\` 
            \`ls -dr /usr/include/qt/*/Qt 2>/dev/null\`
            \`ls -dr /sw/include/Qt 2>/dev/null\`
            \`ls -dr /sw/qt*/include/Qt 2>/dev/null\`
            \`ls -dr /sw/qt/*/include/Qt 2>/dev/null\`
        "

        # Find ALL installed versions of qglobal.h
        for g4_qt_dir in \$g4_qt_include_path_list ; do
            if test -r "\$g4_qt_dir/\$qt_direct_test_header" ; then
                g4_qt_found_dirs="\$g4_qt_found_dirs \$g4_qt_dir"
            fi
        done

        # Which one relates to the newest Qt?
        g4_qt_prev_ver=0
        for g4_qt_dir in \$g4_qt_found_dirs ; do
            g4_qt_this_ver=\`grep -w '#define QT_VERSION' \$g4_qt_dir/\$qt_direct_test_header | sed s/'#define QT_VERSION'//\`

            if expr \$g4_qt_this_ver '>' \$g4_qt_prev_ver > /dev/null ; then
                g4_qt_include_dir=\$g4_qt_dir
                g4_qt_prev_ver=\$g4_qt_this_ver
            fi
        done

        if test "x\$g4_qt_include_dir" = "x" ; then
            g4_qt_include_dir=no
            g4_havegoodqt=no
        fi

        echo "checking for qglobal.h... \$g4_qt_include_dir/qglobal.h"
    fi # END TEST with_qt_dir is set

    #
    # Result of above tests should have given us g4_qt_include_dir
    # We can now use this to check other things, taking care to deal with the
    # correct paths...
    #

    # Immediate and obvious Darwin check...
    if test "x\`basename \$g4_qt_include_dir\`" = "xHeaders" ; then
        #check for moc
        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"
            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"
            g4_havegoodqt=no
        fi
    else
        # Probably have Unix-style installation, in which case estimated
        # 'QTDIR' equivalent is $with_qt_dir if supplied, or directory
        # one level below the 'include' directory in \$g4_qt_include_dir
        if test "x\$with_qt_dir" = "x" ; then
            # We need to strip g4_qt_include_dir, if it was found
            g4_qt_dir=\$g4_qt_include_dir

            # Only do this IF there's an 'include' in the path name!
            if test "x\`echo \$g4_qt_dir | grep include\`" != "x" ; then
                while test "x\`basename \$g4_qt_dir\`" != "xinclude" ;
                do
                    g4_qt_dir=\`dirname \$g4_qt_dir\`
                done
            fi

            #Now should be one level above equivalent QTDIR
            g4_qt_dir=\`dirname \$g4_qt_dir\`
        fi

        # At this point, we need get Qt version of detected qglobal.h because
        # Qt3/4 libraries MAY be installed alongside each other...
        qt_direct_test_header=qglobal.h
        g4_qt_major_ver=\`grep QT_VERSION_STR \$g4_qt_include_dir/\$qt_direct_test_header 2>/dev/null | sed 's/.* \"\([0-9]\)\..*\"/\1/'\`

        #
        # We might have an odd install where our found qglobal.h #includes
        # the real qglobal...
        #
        if test "x\$g4_qt_major_ver" = "x" ; then
            # check for a #include of qglobal...
            possible_actual_qglobal=\`grep '#include.*qglobal' \$g4_qt_include_dir/\$qt_direct_test_header 2>/dev/null\`

            if test "x\$possible_actual_qglobal" != "x" ; then
                #We did get something, and it's likely the include
                #will give us a relative path (but an ASSUMPTION at present)
                relative_path_to_qglobal=\`grep '#include.*qglobal' \$g4_qt_include_dir/\$qt_direct_test_header 2>/dev/null | sed 's/.*\"\(.*\)\"/\1/'\`

                if test -r \$g4_qt_include_dir/\$relative_path_to_qglobal ; then
                    g4_qt_major_ver=\`grep QT_VERSION_STR \$g4_qt_include_dir/\$relative_path_to_qglobal 2>/dev/null | sed 's/.* \"\([0-9]\)\..*\"/\1/'\`
                else
                    g4_qt_major_ver=no
                    g4_havegoodqt=no
                fi
            else
                g4_qt_major_ver=no
                g4_havegoodqt=no
            fi
        fi #END TEST odd qglobal includes qglobal behaviour
            
        if test "x\$g4_qt_major_ver" = "x4" ; then
            g4_is_qt4=yes
        else
            g4_is_qt4=no
        fi
        echo "checking Qt major version... \$g4_qt_major_ver"

        #
        # We also need to check for Qt4 installations with QtCore type
        # directory structures. That being the case, make sure we have
        # the extra headers..
        #
        if test "x\`basename \$g4_qt_include_dir\`" = "xQtCore" ; then
            g4_qt_extra_headers=""
            g4_qt_gl_headers=""
            g4_qt_extra_packages="QtGui"
            g4_qt_gl_packages="QtOpenGL"

            for i in \$g4_qt_extra_packages ; do
                if test -d "\`dirname \$g4_qt_include_dir\`/\$i" ; then
                    echo "checking for \$i headers... yes"
                    g4_qt_extra_headers="\$g4_qt_extra_headers \`dirname \$g4_qt_include_dir\`/\$i"
                else
                    echo "checking for \$i headers... no"
                    g4_havegoodqt=no
                fi
            done

            for i in \$g4_qt_gl_packages ; do
                if test -d "\`dirname \$g4_qt_include_dir\`/\$i" ; then
                    echo "checking for \$i headers... yes"
                    g4_qt_gl_headers="\$g4_qt_gl_headers \`dirname \$g4_qt_include_dir\`/\$i"
                else
                    echo "checking for \$i headers... no"
                    g4_havegoodqt=no
                fi
            done

        fi #END TEST QtCore style install


        #
        # Now check for appropriate library...
        #
        if test -d "\$g4_qt_dir/lib64" ; then
            g4_qt_lib_dir=\$g4_qt_dir/lib64
        else
            g4_qt_lib_dir=\$g4_qt_dir/lib
        fi

        if test "x\$g4_is_qt4" = "xyes" ; then
            g4_qt_lib="\`ls \$g4_qt_lib_dir/libQtCore* 2> /dev/null | sed -n 1p |
                    sed s@\$g4_qt_lib_dir/lib@@ | sed s@[.].*@@\`"

            if test "x\$g4_qt_lib" = "x" ; then
                # We might be on Windows...
                g4_qt_lib="\`ls \$g4_qt_lib_dir/QtCore4.lib 2> /dev/null | sed -n 1p | sed s@\$g4_qt_lib_dir/@@\`"
            fi

            if test "x\$g4_qt_lib" != "x" ; then
                echo "checking for QtCore library... \$g4_qt_lib"
            else
                echo "checking for QtCore library... no"
                g4_havegoodqt=no
            fi
        else
            g4_qt_lib="\`ls \$g4_qt_lib_dir/libqt-mt.* \$g4_qt_lib_dir/libqt.* 2> /dev/null | sed -n 1p | sed s@\$g4_qt_lib_dir/lib@@ | sed s@[.].*@@\`"

            if test "x\$g4_qt_lib" != "x" ; then
                echo "checking for qt-mt or qt library... \$g4_qt_lib"

                # On Darwin we also need libqui for Qt3
                if test "x\$osname" = "xdarwin" ; then
                    g4_qt_lib_qui="\`ls \$g4_qt_lib_dir/libqui.* 2> /dev/null | 
                                    sed -n 1p | sed s@\$g4_qt_lib_dir/lib@@ | 
                                    sed s@[.].*@@\`"
                    if test "x\$g4_qt_lib_qui" != "x" ; then
                        echo "checking for qui library... yes"
                    else
                        echo "checking for qui library... no"
                        g4_havegoodqt=no
                    fi
                fi
            else
                echo "checking for qt-mt or qt library... no"
                g4_havegoodqt=no
            fi
        fi #END TEST for Qt4/3 libraries

        #
        # 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
	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
        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
        ## LIBS ARE AUTOMATICALLY FOUND BY LINKER

        #
        ## Finally, set output variables, raw for now
        #
        if test "x\$g4_havegoodqt" = "xyes" ; then
	    g4_qt_version=\$g4_qt_major_ver
            
            # Take care of Qt4 style header structure...
            if test "x\`basename \$g4_qt_include_dir\`" = "xQtCore"; then
		g4_qt_cxxflags="-I\`dirname \$g4_qt_include_dir\` -I\$g4_qt_include_dir"
	    else
	    	g4_qt_cxxflags="-I\$g4_qt_include_dir"
	    fi
            if test "x\$g4_is_qt4" = "xyes" ; then
                for i in \$g4_qt_extra_headers ; do
                    g4_qt_cxxflags="\$g4_qt_cxxflags -I\$i"
                done
                for i in \$g4_qt_gl_headers ; do
                    g4_qt_gl_cxxflags="\$g4_qt_gl_cxxflags -I\$i"
                done
            fi

            g4_qt_libs="-L\$g4_qt_lib_dir"
            if test "x\$g4_qt_lib" = "xQtCore4.lib" ; then
                #We have Windows...
                g4_qt_libs="\$g4_qt_libs QtCore4.lib QtGui4.lib"
                g4_qt_gl_libs="QtOpenGL4.lib"
            else
                g4_qt_libs="\$g4_qt_libs -l\$g4_qt_lib"
                if test "x\$g4_is_qt4" = "xyes" ; then
                    g4_qt_libs="\$g4_qt_libs -lQtGui"
                    g4_qt_gl_libs="-lQtOpenGL"
                fi
            fi
            if test "x\$g4_qt_lib_qui" != "x" ; then
                g4_qt_libs="\$g4_qt_libs -lqui"
            fi


            g4_qt_moc=\$g4_qtmoc

            g4_qt_is_configured=yes
        else
            g4_qt_is_configured=''
        fi
    fi #END TEST for Darwin Framework

else
    #Probably also want flags here to reset variables if requested
    echo "configure: Qt already configured, no recheck neccessary"
fi #END TEST "x\$g4_qt_is_configured" = "x" 

EOSC
: decide how portable to be
case "$d_portable" in
"$define") dflt=y;;
*)	dflt=n;;
esac
$cat <<'EOH'
 
I can set things up so that your shell scripts and binaries are more portable,
at what may be a noticable cost in performance.  In particular, if you
ask to be portable, the following happens:

     1) Shell scripts will rely on the PATH variable rather than using
	the paths derived above.
     2) ~username interpretations will be done at run time rather than
	by Configure.

EOH
rp="Do you expect to run these scripts and binaries on multiple machines?"
. ./myread
case "$ans" in
	y*) d_portable="$define"
	;;
	*)  d_portable="$undef" ;;
esac

: set up shell script to do ~ expansion
cat >filexp <<EOSS
$startsh
: expand filename
case "\$1" in
 ~/*|~)
	echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
	;;
 ~*)
	if $test -f /bin/csh; then
		/bin/csh -f -c "glob \$1"
		failed=\$?
		echo ""
		exit \$failed
	else
		name=\`$expr x\$1 : '..\([^/]*\)'\`
		dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
		if $test ! -d "\$dir"; then
			me=\`basename \$0\`
			echo "\$me: can't locate home directory for: \$name" >&2
			exit 1
		fi
		case "\$1" in
		*/*)
			echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
			;;
		*)
			echo \$dir
			;;
		esac
	fi
	;;
*)
	echo \$1
	;;
esac
EOSS
chmod +x filexp
$eunicefix filexp

: now set up to get a file name
cat <<EOS >getfile
$startsh
EOS
cat <<'EOSC' >>getfile
tilde=''
fullpath=''
already=''
skip=''
none_ok=''
exp_file=''
nopath_ok=''
orig_rp="$rp"
orig_dflt="$dflt"

case "$fn" in
*\(*)
	expr $fn : '.*(\(.*\)).*' | tr ',' '\012' >getfile.ok
	fn=`echo $fn | sed 's/(.*)//'`
	;;
esac

case "$fn" in
*:*)
	loc_file=`expr $fn : '.*:\(.*\)'`
	fn=`expr $fn : '\(.*\):.*'`
	;;
esac

case "$fn" in
*~*) tilde=true;;
esac
case "$fn" in
*/*) fullpath=true;;
esac
case "$fn" in
*+*) skip=true;;
esac
case "$fn" in
*n*) none_ok=true;;
esac
case "$fn" in
*e*) exp_file=true;;
esac
case "$fn" in
*p*) nopath_ok=true;;
esac

case "$fn" in
*f*) type='File';;
*d*) type='Directory';;
*l*) type='Locate';;
esac

what="$type"
case "$what" in
Locate) what='File';;
esac

case "$exp_file" in
'')
	case "$d_portable" in
	"$define") ;;
	*) exp_file=true;;
	esac
	;;
esac

cd ../..
while test "$type"; do
	redo=''
	rp="$orig_rp"
	dflt="$orig_dflt"
	case "$tilde" in
	true) rp="$rp ";;
	esac
	. .config/UU/myread
	if test -f .config/UU/getfile.ok && \
		$contains "^$ans\$" .config/UU/getfile.ok >/dev/null 2>&1
	then
		value="$ans"
		ansexp="$ans"
		break
	fi
	case "$ans" in
	none)
		value=''
		ansexp=''
		case "$none_ok" in
		true) type='';;
		esac
		;;
	*)
		case "$tilde" in
		'') value="$ans"
			ansexp="$ans";;
		*)
			value=`.config/UU/filexp $ans`
			case $? in
			0)
				if test "$ans" != "$value"; then
					echo "(That expands to $value on this system.)"
				fi
				;;
			*) value="$ans";;
			esac
			ansexp="$value"
			case "$exp_file" in
			'') value="$ans";;
			esac
			;;
		esac
		case "$fullpath" in
		true)
			case "$ansexp" in
			/*) value="$ansexp" ;;
			*)
				redo=true
				case "$already" in
				true)
				echo "I shall only accept a full path name, as in /bin/ls." >&4
				echo "Use a ! shell escape if you wish to check pathnames." >&4
					;;
				*)
				echo "Please give a full path name, starting with slash." >&4
					case "$tilde" in
					true)
				echo "Note that using ~username is ok provided it expands well." >&4
						already=true
						;;
					esac
				esac
				;;
			esac
			;;
		esac
		case "$redo" in
		'')
			case "$type" in
			File)
				if test -f "$ansexp"; then
					type=''
				elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
				then
					echo "($value is not a plain file, but that's ok.)"
					type=''
				fi
				;;
			Directory)
				if test -d "$ansexp"; then
					type=''
				fi
				;;
			Locate)
				if test -d "$ansexp"; then
					echo "(Looking for $loc_file in directory $value.)"
					value="$value/$loc_file"
					ansexp="$ansexp/$loc_file"
				fi
				if test -f "$ansexp"; then
					type=''
				fi
				case "$nopath_ok" in
				true)	case "$value" in
					*/*) ;;
					*)	echo "Assuming $value will be in people's path."
						type=''
						;;
					esac
					;;
				esac
				;;
			esac

			case "$skip" in
			true) type='';
			esac

			case "$type" in
			'') ;;
			*)
				if test "$fastread" = yes; then
					dflt=y
				else
					dflt=n
				fi
				rp="$what $value doesn't exist.  Use that name anyway?"
				. .config/UU/myread
				dflt=''
				case "$ans" in
				y*) type='';;
				*) echo " ";;
				esac
				;;
			esac
			;;
		esac
		;;
	esac
done
cd .config/UU
ans="$value"

# Check for Windows!
if test "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7"; then

checkdrive=`echo $ans|cut -d"/" -f2`

if test "X$checkdrive" = "Xcygdrive"; then

windrive=`echo $ans|cut -d"/" -f3`
winpath=`echo $ans|cut -d"/" -f4-`

fullwinpath="$windrive:/$winpath"
ans=$fullwinpath

fi # if cygwin syntax is used
fi # if Win

rp="$orig_rp"
dflt="$orig_dflt"
rm -f getfile.ok
EOSC

echo " "

#echo "SSS"
#echo `pwd`
#echo "SSS"

if [ X$src = X. ] ; then
	cd ../..
	abssrc=`pwd`
	cd .config/UU
else
	abssrc=$src
fi

case "$g4conf" in
'')
	g4conf=$abssrc/.config/bin/$g4system
	;;
esac

#echo "g4conf=$g4conf"

case "$g4install" in
'')
if test $g4system = "WIN32-VC" -o $g4system = "WIN32-VC7"; then
#	g4install="c:/geant4"
	g4install=$abssrc
else
#	if [ X"$HOME" = X/ ] ; then
#	HOME=""
#	fi
#	g4install="$HOME"/geant4
	g4install=$abssrc

fi

# Check for Windows!
if test $g4system = "WIN32-VC" -o $g4system = "WIN32-VC7"; then

checkdrive=`echo $g4install|cut -d"/" -f2`

if test $checkdrive = "cygdrive"; then

windrive=`echo $g4install|cut -d"/" -f3`
winpath=`echo $g4install|cut -d"/" -f4-`

fullwinpath="$windrive:/$winpath"
g4install=$fullwinpath

fi
fi
	;;
esac

case "$g4final_install" in
'')
	g4final_install=$g4install
	;;
esac

case "$g4workdir" in
'')
	g4workdir=$g4install
	;;
esac

case "$g4includes_flag" in
'')
	g4includes_flag=n
	;;
esac


g4message=`cat << EOM

Where is Geant4 source installed?
EOM`

#dflt="NO DEFAULT ANSWER"
dflt=$g4install
fn='d~'
rp=$g4message
. ./getfile
g4install=$ans
g4workdir=$g4install
#################################
g4message=`cat << EOM

Specify the path where Geant4 libraries and source files should be
installed.
EOM`

#dflt="NO DEFAULT ANSWER"
dflt=$g4final_install
fn='d~'
rp=$g4message
. ./getfile
g4final_install=$ans
#g4workdir=$g4install

##################################
g4message=`cat << EOM

Do you want to copy all Geant4 headers 
in one directory?
EOM`

#dflt="NO DEFAULT ANSWER"
dflt=$g4includes_flag
#fn='d~'
rp=$g4message
. ./myread
g4includes_flag=$ans

if [ X$g4includes_flag = Xy ] ; then

case "$g4include" in
'')
	g4include=$g4install/include
#	g4include=''
	;;
esac

#g4message=`cat << EOM
#
#Where will be directory to copy all Geant4 headers?
#EOM`
#
##dflt="NO DEFAULT ANSWER"
####dflt=$g4install/include
#dflt=$g4include
#fn='d~+'
#rp=$g4message
#. ./getfile
#g4include=$ans

# Set constantly!
if [ X$g4install != X$g4final_install ] ; then
g4include=$g4final_install/include/geant4
else
g4include=$g4final_install/include
fi

fi

#if test "X$g4include" = "X[NOT DEFINED]" ; then
#g4include=""
#fi

echo " "

case "$g4tmp" in
'')
	g4tmp=$g4workdir/tmp
	;;
esac

case "$g4lib" in
'')
	g4lib=$g4workdir/lib
	;;
esac

#case "$g4bin" in
#'')
#	g4bin=$g4workdir/bin
#	;;
#esac

while test 1 = 0  ; do

g4message=`cat << EOM

(OPTIONAL) You can now customise installation directories:
  G4TMP - tmp/ containing temporary dependency (.d) and object (.o) files;
  G4LIB - lib/ containing final static (.a) or shared (.so) libraries;

1) G4TMP:		$g4tmp

2) G4LIB:		$g4lib

To modify default settings, select number above (e.g. 2) 
EOM`

#dflt="NO DEFAULT ANSWER"
dflt="Press [Enter] for default settings"
#fn='d~'
rp=$g4message
. ./myread
gans=$ans


	case $gans in

	1) 
		dflt=$g4tmp
		fn='d~+'
		rp="Where will be your Geant4 tmp directory?"
		. ./getfile
		g4tmp=$ans
		;;
	2) 
		dflt=$g4lib
		fn='d~+'
		rp="Where will be your Geant4 lib directory?"
		. ./getfile
		g4lib=$ans
		;;
#	3) 
#		dflt=$g4bin
#		fn='d~+'
#		rp="Where will be your Geant4 bin directory?"
#		. ./getfile
#		g4bin=$ans
#		;;

#	[eE]) 
#		break
#		;;
	*) 
		break
#		echo " "
		;;
	esac
done

g4data_photonevaporation_version='PhotonEvaporation2.0'
g4data_radioactivedecay_version='RadioactiveDecay3.2'
g4data_g4emlow_version='G4EMLOW6.2'
g4data_g4ndl_version='G4NDL3.13'
g4data_g4abla_version='G4ABLA3.0'
#END GEANT4 DATA OPTIONS
echo " "


#
# Set defaults for data paths - here, because we depend on g4install
#
case "$g4data" in
'')
	g4data=$g4install/data
	;;
esac

case "$g4levelgammadata" in
'')
	g4levelgammadata=$g4data/$g4data_photonevaporation_version
	;;
esac

case "$g4radioactivedata" in
'')
	g4radioactivedata=$g4data/$g4data_radioactivedecay_version
	;;
esac

case "$g4ledata" in
'')
	g4ledata=$g4data/$g4data_g4emlow_version
	;;
esac

case "$g4neutronhpcrosssections" in
'')
	g4neutronhpcrosssections=$g4data/$g4data_g4ndl_version
	;;
esac

case "$g4abladata" in
'')
	g4abladata=$g4data/$g4data_g4abla_version
	;;
esac


#
# Now we have defaults, prompt user to see if this is where they want to use
# 
g4data_alllibs="$g4data_photonevaporation_version $g4data_radioactivedecay_version $g4data_g4emlow_version $g4data_g4ndl_version $g4data_g4abla_version"

g4message=`cat <<EOM
Specify the path where the Geant4 data libraries 

$g4data_alllibs 

are installed. For now, a flat directory structure is assumed, and this can 
be customized at the next step if needed.
EOM`

dflt=$g4data
rp=$g4message
. ./myread
g4data=$ans

#
# Using this, we can now check that the libs exist, but only on a directory
# level
#
g4data_foundall='yes'
promptend="no"
g4data_customize="no"

while test "x$promptend" = "xno" ; do
	### PhotonEvaporation
	$echo $n "checking for $g4data_photonevaporation_version... $c"
	if test -d "$g4data/$g4data_photonevaporation_version" ; then
		$echo "yes"
		g4levelgammadata=$g4data/$g4data_photonevaporation_version
	else
		$echo "no"
		g4data_foundall="no"
	fi

	### RadioactiveDecay
	$echo $n "checking for $g4data_radioactivedecay_version... $c"
	if test -d "$g4data/$g4data_radioactivedecay_version" ; then
        	$echo "yes"
        	g4radioactivedata=$g4data/$g4data_radioactivedecay_version
	else
        	$echo "no"
        	g4data_foundall="no"
	fi

	### G4EMLOW
	$echo $n "checking for $g4data_g4emlow_version... $c"
	if test -d "$g4data/$g4data_g4emlow_version" ; then
        	$echo "yes"
        	g4ledata=$g4data/$g4data_g4emlow_version
	else
        	$echo "no"
        	g4data_foundall="no"
	fi

	### G4NDL
	$echo $n "checking for $g4data_g4ndl_version... $c"
	if test -d "$g4data/$g4data_g4ndl_version" ; then
        	$echo "yes"
        	g4neutronhpcrosssections=$g4data/$g4data_g4ndl_version
	else
        	$echo "no"
        	g4data_foundall="no"
	fi

	### G4ABLA
	$echo $n "checking for $g4data_g4abla_version... $c"
	if test -d "$g4data/$g4data_g4abla_version" ; then
        	$echo "yes"
        	g4abladata=$g4data/$g4data_g4abla_version
	else
        	$echo "no"
        	g4data_foundall="no"
	fi

	#
	# If we haven't found all the data, query the user as to whether they
	# want to
	# 1) try again with a different path
	# 2) use the path they input
	# 3) customize paths
	#
	if test "x$g4data_foundall" = "xyes" ; then
		promptend=yes
	else
		g4message=`cat << EOM

Failed to locate one or more of the Geant4 data libraries in 

$g4data 

Please enter
1) Another path to search in
2) 'f' to force the use of the path you entered previously (the data libraries
   are not needed to build Geant4, but are needed to run applications later).
3) 'c' to customize the data paths, e.g. if you have the data libraries
   installed in different locations.
EOM`
		dflt="f"
		rp=$g4message
		. ./myread
		gans=$ans

		if test "x$gans" = "xf" ; then
			# Force paths
			promptend="yes"
			g4levelgammadata="$g4data/$g4data_photonevaporation_version"
			g4radioactivedata="$g4data/$g4data_radioactivedecay_version"
			g4ledata="$g4data/$g4data_g4emlow_version"
			g4neutronhpcrosssections="$g4data/$g4data_g4ndl_version"
			g4abladata="$g4data/$g4data_g4abla_version"
			

		elif test "x$gans" = "xc" ; then
			# enable customization - we use input g4data to set
			# defaults
			promptend="yes"
			g4data_customize="yes"

			g4levelgammadata="$g4data/$g4data_photonevaporation_version"
                        g4radioactivedata="$g4data/$g4data_radioactivedecay_version"
                        g4ledata="$g4data/$g4data_g4emlow_version"
                        g4neutronhpcrosssections="$g4data/$g4data_g4ndl_version"
                        g4abladata="$g4data/$g4data_g4abla_version"


		else
			#try again
		        g4data_foundall=yes
			g4data=$gans
		fi
	fi
done


#
# Now customize paths if required
#
if test "x$g4data_customize" = "xyes" ; then
while test "x" = "x" ; do

	g4message=`cat <<EOM

You have chosen to customize the Geant4 data library paths.

1) $g4data_photonevaporation_version: 
	$g4levelgammadata
2) $g4data_radioactivedecay_version: 
	$g4radioactivedata
3) $g4data_g4emlow_version: 
	$g4ledata
4) $g4data_g4ndl_version: 
	$g4neutronhpcrosssections
5) $g4data_g4abla_version: 
	$g4abladata

Choose a number from the list above to customize that path (e.g. 2)
EOM`

	dflt="Press [Enter] to exit customization with paths as above"
	rp=$g4message
	. ./myread
	gans=$ans

	case $gans in

	"1")
		dflt=$g4levelgammadata
		fn='d~'
		rp="Custom path to $g4data_photonevaporation_version?"
		. ./getfile
		g4levelgammadata=$ans
		;;

	"2")
		dflt=$g4radioactivedata
		fn='d~'
		rp="Custom path to $g4data_radioactivedecay_version?"
		. ./getfile
		g4radioactivedata=$ans
		;;

	"3")
		dflt=$g4ledata
		fn='d~'
		rp="Custom path to $g4data_g4emlow_version?"
		. ./getfile
		g4ledata=$ans
		;;

	"4")
		dflt=$g4neutronhpcrosssections
		fn='d~'
		rp="Custom path to $g4data_g4ndl_version?"
		. ./getfile
		g4neutronhpcrosssections=$ans
		;;

	"5")
		dflt=$g4abladata
		fn='d~'
		rp="Custom path to $g4data_g4abla_version?"
		. ./getfile
		g4abladata=$ans
		;;

	*)
		break
		;;

	esac

done
fi





if test "X$g4clhep_base_dir" = "X" ; then

clhep_dirs=`find $g4clhep_base_dir /usr/local/include /usr/include -type d -name CLHEP 2>/dev/null |xargs echo`
#echo clhep_dirs=$clhep_dirs

fi

if test "X$clhep_dirs" != "X" ; then

g4clhep_base_dir_found=`echo $clhep_dirs|cut -d" " -f1`
#echo g4clhep_base_dir_found=$g4clhep_base_dir_found


#g4clhep_base_dir_n=`echo $g4clhep_base_dir_found |awk -F"/" '{print NF}'`
#echo g4clhep_base_dir_n=$g4clhep_base_dir_n
g4clhep_base_dir_found=`dirname $g4clhep_base_dir_found`
g4clhep_base_dir_found=`dirname $g4clhep_base_dir_found`

	g4clhep_base_dir=$g4clhep_base_dir_found

#else
#case "$g4clhep_base_dir" in
#'')
#	if test "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7"; then
#	g4clhep_base_dir="c:/usr/local"
#	else
#	g4clhep_base_dir=/usr/local
#	fi
#	;;
#esac
fi


#while test 1 = 1  ; do

#if test "X$g4clhep_base_dir" != "X" ; then
#clhep_dirs=$g4clhep_base_dir
#echo 1 g4clhep_base_dir=$g4clhep_base_dir
#fi

if test "X$g4clhep_base_dir" != "X" ; then

g4message=`cat << EOM

Please, specify where CLHEP is installed. It was found in:

CLHEP_BASE_DIR:			$g4clhep_base_dir

EOM`

dflt=$g4clhep_base_dir
fn='d~'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/CLHEP" ; then
cend="yes"

g4clhep_base_dir=$ans

else

g4message=`cat << EOM

Could not find CLHEP installed in $ans!
Please, specify where CLHEP is installed:

CLHEP_BASE_DIR:			

EOM`

dflt=""
fn='d~'
rp=$g4message
. ./getfile
fi
done

else

g4message=`cat << EOM

Could not find CLHEP installed on this system!
Please, specify where CLHEP is installed:

CLHEP_BASE_DIR:			

EOM`

dflt=""
fn='d~'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/CLHEP" ; then
cend="yes"

g4clhep_base_dir=$ans

else

g4message=`cat << EOM

Could not find CLHEP installed in $ans!
Please, specify where CLHEP is installed:

CLHEP_BASE_DIR:			

EOM`

dflt=""
fn='d~'
rp=$g4message
. ./getfile
fi
done

fi

#dflt="Press [Enter] for default settings"
#fn='d~'
#####rp=$g4message
#. ./myread
#gans=$ans

#	case $gans in

#	1) 
##		dflt=""
##		fn='d~'
#		rp="Where is CLHEP installed?"
##		. ./getfile
##		g4clhep_base_dir=$ans

#####		g4clhep_include_dir=$ans/include
#####		g4clhep_lib_dir=$ans/lib
#		;;
#	2) 
#		dflt=$g4clhep_include_dir
#		fn='d~'
#		rp="Where is CLHEP include directory?"
#		. ./getfile
#		g4clhep_include_dir=$ans
#		;;
#	3) 
#		dflt=$g4clhep_lib_dir
#		fn='d~'
#		rp="Where is CLHEP lib directory?"
#		. ./getfile
#		g4clhep_lib_dir=$ans
#		;;
#	4) 
#		dflt=$g4clhep_lib
#		rp="What is CLHEP lib title?"
#		. ./myread
#		g4clhep_lib=$ans
#		;;
##	[eE]) 
##		break
##		;;
#	*) 
#		echo " "
#		break
#		;;
#	esac
#done

case "$g4clhep_include_dir" in
'')
	g4clhep_include_dir=$g4clhep_base_dir/include
	;;
esac

case "$g4clhep_lib_dir" in
'')
	g4clhep_lib_dir=$g4clhep_base_dir/lib
	;;
esac

case "$g4clhep_lib" in
'')
	if test "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7"; then
	g4clhep_lib="CLHEP.lib"
	else
	g4clhep_lib=CLHEP
	fi
	;;
esac

while test 1 = 1  ; do

g4message_1=`cat << You

You can customize paths and library name of you CLHEP installation:

1) CLHEP_INCLUDE_DIR:		$g4clhep_include_dir
2) CLHEP_LIB_DIR:		$g4clhep_lib_dir
3) CLHEP_LIB:			$g4clhep_lib

You`

g4message_2=" need to use full library name with its extension (e.g. libCLHEP.lib)."

g4message_3=`cat << EOM

To modify default settings, select number above (e.g. 2)
EOM`


if test "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7"; then
rp=$g4message_1$g4message_3
else
rp=$g4message_1$g4message_2$g4message_3
fi

dflt="Press [Enter] for default settings"
#fn='d~'
. ./myread
gans=$ans

	case $gans in

	1) 
		dflt=$g4clhep_include_dir
		fn='d~'
		rp="Where is CLHEP include directory?"
		. ./getfile
		g4clhep_include_dir=$ans
		;;
	2) 
		dflt=$g4clhep_lib_dir
		fn='d~'
		rp="Where is CLHEP lib directory?"
		. ./getfile
		g4clhep_lib_dir=$ans
		;;
	3) 
		dflt=$g4clhep_lib
		rp="What is CLHEP lib title?"
		. ./myread
		g4clhep_lib=$ans
		;;
#	[eE]) 
##		break
##		;;
	*) 
#		echo " "
		break
		;;
	esac
done

#if test "X$g4clhep_base_dir" = "X/usr" -o "X$g4clhep_base_dir" = "X/usr/local"; then
#g4clhep_base_dir=""
#fi
#
#if test "X$g4clhep_include_dir" = "X/usr/include" -o "X$g4clhep_include_dir" = "X/usr/local/include"; then
#g4clhep_include_dir=""
#fi
#
#if test "X$g4clhep_lib_dir" = "X/usr/lib" -o "X$g4clhep_lib_dir" = "X/usr/local/lib"; then
#g4clhep_lib_dir=""
#fi

echo " "

case "$g4lib_build_shared" in
'')
	g4lib_build_shared=n
	;;
esac

echo " "

case "$g4lib_build_static" in
'')
	g4lib_build_static=n
	;;
esac

echo " "

case "$g4lib_use_shared" in
'')
	g4lib_use_shared=n
	;;
esac

echo " "

case "$g4lib_use_static" in
'')
	g4lib_use_static=n
	;;
esac

case "$g4lib_build_dll" in
'')
	g4lib_build_dll=n
	;;
esac

case "$g4lib_build_dyn" in
'')
	g4lib_build_dyn=n
	;;
esac

#
# Ask about building of SHARED|STATIC libraries - default STATIC. 
#
echo ""

if test "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7"; then

while test 1 = 1  ; do

g4message=`cat << EOM

By default 'static'  libraries are built.

Do you want to build DLL (.dll) libraries?
EOM`

dflt=$g4lib_build_dll
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4lib_build_dll=n
		g4lib_build_shared=n
		g4lib_build_static=y
		break
		;;
	y*|Y*) 
		g4lib_build_dll=y
		g4lib_build_shared=n
		g4lib_build_static=n

#		g4lib_build_static=""
#		g4lib_use_shared=1
#		g4lib_use_static=""
		break
		;;
#	[eE]) 
#		break
#		;;
#	*) 
#		echo " "
#		break
#		;;
	esac
done

fi

if test "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7" ; then

while test 1 = 1  ; do

g4message=`cat << EOM

By default 'static' (.a) libraries are built.

Do you want to build 'shared' (.so) libraries?
EOM`

dflt=$g4lib_build_shared
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4lib_build_shared=n
		g4lib_build_static=y
		break
		;;
	y*|Y*) 
		g4lib_build_shared=y
#		g4lib_build_static=""
#		g4lib_use_shared=1
#		g4lib_use_static=""
		break
		;;
#	[eE]) 
#		break
#		;;
#	*) 
#		echo " "
#		break
#		;;
	esac
done

if [ X$g4lib_build_shared = Xy ] ; then
#
# Ask about g4lib_build_static - default "n". 
#
echo ""

while test 1 = 1  ; do

g4message=`cat << EOM

You selected to build 'shared' (.so) libraries. 
Do you want to build 'static' (.a) libraries too?
EOM`

#dflt=$g4lib_build_static
dflt=n
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4lib_build_static=n
		break
		;;
	y*|Y*) 
#		g4lib_build_shared=1
		g4lib_build_static=y
#		g4lib_use_shared=1
#		g4lib_use_static=""
		break
		;;
#	[eE]) 
#		break
#		;;
#	*) 
#		echo " "
#		break
#		;;
	esac
done

## Comment out in waiting G4LIB_USE_STATIC and G4LIB_USE_SHARED.
#
#if [ X$g4lib_build_static = Xy ] ; then
##
## Ask about g4lib_use_static - default "n". 
##
#echo ""
#
#while test 1 = 1  ; do
#
#g4message=`cat << EOM
#
#You selected to build 'shared' (.so) and 'static' (.a) libraries. 
#Do you want to use 'static' (.a) libraries?
#EOM`
#
#dflt=$g4lib_use_static
#rp=$g4message
#. ./myread
#gans=$ans
#
#	case $gans in
#	
#	n*|N*) 
#		break
#		;;
#	y*|Y*) 
##		g4lib_build_shared=1
##		g4lib_build_static=1
##		g4lib_use_shared=1
#		g4lib_use_static=y
#		break
#		;;
##	[eE]) 
##		break
##		;;
##	*) 
##		echo " "
##		break
##		;;
#	esac
#done
#fi

fi

fi # if !Win

echo " "
case "$g4global" in
'')
	g4global=n
	;;
esac

echo " "
# By default it's 'grabular'!
case "$g4granular" in
'')
	g4granular=y
	;;
esac

echo " "
# Will be set (if needed) in GNUmakefile!
case "$g4lib_use_granular" in
'')
	g4lib_use_granular=y
	;;
esac

if test \( \( "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7" \) -a "X$g4lib_build_dll" = "Xy" \) -o  \( "X$g4system" = "XDarwin-g++"  -a "X$g4lib_build_dyn" = "Xy" \) ; then

	g4global=n
	g4granular=n
	g4lib_use_granular=n

fi

if test \( "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7" -a "X$g4system" != "XDarwin-g++" \) -o    \( \( "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7" \) -a "X$g4lib_build_dll" = "Xn" \) -o \( "X$g4system" = "XDarwin-g++" -a "X$g4lib_build_dyn" = "Xn" \) ; then

#
# Ask about g4global - default "(empty)". 
#
echo ""

while test 1 = 1  ; do

g4message=`cat << EOM

Do you want to build 'global' compound libraries?
EOM`

dflt=$g4global
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4global=n
		g4granular=y
		g4lib_use_granular=y
		break
		;;
	y*|Y*) 
		g4global=y
# Shoud be comment out to keep settings from config.sh - not now to keep as in release
		g4granular=n
# Shoud be comment out to keep settings from config.sh - not now to keep as in release
		g4lib_use_granular=n
		break
		;;
#	[eE]) 
#		break
#		;;
#	*) 
#		echo " "
#		break
#		;;
	esac
done

if [ X$g4global = Xy ] ; then
#
# Ask about g4granular - default "n". 
#
echo ""

while test 1 = 1  ; do

g4message=`cat << EOM

Granular libraries are used by defaults, you asked to build global
compound libraries. Do you want to build 'granular' libraries too?
EOM`

dflt=$g4granular
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4granular=n
		break
		;;
	y*|Y*) 
		g4granular=y
		break
		;;
#	[eE]) 
#		break
#		;;
#	*) 
#		echo " "
#		break
#		;;
	esac
done

if [ X$g4granular = Xy ] ; then
#
# Ask about g4lib_use_granular - default "n". 
#
echo ""

while test 1 = 1  ; do

g4message=`cat << EOM

Global libraries are used by defaults, you asked to build global
compound libraries and granular libraries. 
Do you want to use 'granular' libraries instead?
EOM`

dflt=$g4lib_use_granular
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4lib_use_granular=n
		break
		;;
	y*|Y*) 
		g4lib_use_granular=y
		break
		;;
#	[eE]) 
#		break
#		;;
#	*) 
#		echo " "
#		break
#		;;
	esac
done
fi
fi

fi # !Win

### End file - without will be problem! Check in others...


echo " "
case "$g4debug" in
'')
	g4debug=n
	;;
esac

#
# Ask about g4debug - default "(empty)". 
#
echo ""

while test 1 = 1  ; do

g4message=`cat << EOM

Do you want to compile libraries in DEBUG mode (-g)?
EOM`

dflt=$g4debug
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		break
		;;
	y*|Y*) 
		g4debug=y
		break
		;;
#	[eE]) 
#		break
#		;;
#	*) 
#		echo " "
#		break
#		;;
	esac
done


echo " "

case "$g4ui_none" in
'')
	g4ui_none=n
	;;
esac

# Set by default!
case "$g4ui_build_terminal_session" in
'')
	g4ui_build_terminal_session=y
	;;
esac

# Set by default!
case "$g4ui_use_terminal" in
'')
	g4ui_use_terminal=y
	;;
esac

# Set by default!
case "$g4ui_build_gag_session" in
'')
	g4ui_build_gag_session=y
	;;
esac

# Set by default!
case "$g4ui_use_gag" in
'')
	g4ui_use_gag=y
	;;
esac

case "$g4ui_build_xm_session" in
'')
	g4ui_build_xm_session=n
	;;
esac

case "$g4ui_use_xm" in
'')
	g4ui_use_xm=n
	;;
esac

case "$g4ui_build_xaw_session" in
'')
	g4ui_build_xaw_session=n
	;;
esac

case "$g4ui_use_xaw" in
'')
	g4ui_use_xaw=n
	;;
esac

case "$g4ui_build_win32_session" in
'')
	g4ui_build_win32_session=n
	;;
esac

case "$g4ui_use_win32" in
'')
	g4ui_use_win32=n
	;;
esac

# Set by default!
case "$g4ui_use_tcsh" in
'')
	g4ui_use_tcsh=y
	;;
esac




echo ""

g4message=`cat << EOM

  G4UI_NONE

If this variable is set, no UI sessions nor any UI libraries are built. 
This can be useful when running a pure batch job or in a user framework 
having its own UI system.
Do you want to set this variable ?

EOM`

dflt=$g4ui_none
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4ui_none=n
		;;
	y*|Y*) 
		g4ui_none=y
		;;
	esac

case $g4ui_none in

n)

g4message=`cat << EOM

  G4UI_BUILD_TERMINAL_SESSION
  Specifies to include in kernel library a basic dumb terminal
  user interface (default).

  G4UI_USE_TERMINAL
  Specifies to use dumb terminal interface in the application to be
  built (default).
EOM`

dflt=$g4ui_use_terminal
rp=$g4message
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4ui_build_terminal_session=n
		g4ui_use_terminal=n
		;;
	y*|Y*) 
		g4ui_build_terminal_session=y
		g4ui_use_terminal=y
		;;
	esac

g4message=`cat << EOM

  G4UI_BUILD_GAG_SESSION
  Specifies to include in kernel library the GAG based
  user interface.

  G4UI_USE_GAG
  Specifies to use the GAG interface in the application to be
  built.
EOM`

dflt=$g4ui_use_gag
rp=$g4message
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4ui_build_gag_session=n
		g4ui_use_gag=n
		;;
	y*|Y*) 
		g4ui_build_gag_session=y
		g4ui_use_gag=y
		;;
	esac

if test "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7"; then

g4message=`cat << EOM

  G4UI_BUILD_XAW_SESSION
  G4UI_USE_XAW

  Specifies to include and use the XAW interfaces in the
  application to be built.
  The XAW (X11 Athena Widget set) extensions are required to activate 
  and build this driver.
EOM`

dflt=$g4ui_use_xaw
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4ui_build_xaw_session=n
		g4ui_use_xaw=n
		;;
	y*|Y*) 
		g4ui_build_xaw_session=y
		g4ui_use_xaw=y
		;;
	esac

############################################################
############################################################

if test "X$g4ui_build_xaw_session" = "Xy" ; then

if test "X$g4ui_xawhome" = "X" ; then
xaw_dirs=`find $g4ui_xawhome /usr/X11R6/include /usr/local/include /usr/include /sw/include -type d -name Xaw 2>/dev/null |xargs echo`
#echo ogl_dirs=$ogl_dirs

if test "X$xaw_dirs" != "X" ; then

g4xaw_base_dir_found=`echo $xaw_dirs|cut -d" " -f1`
#echo g4ogl_base_dir_found=$g4ogl_base_dir_found

# That's right: should be 3 times! (e.g./usr/local/lib/libGLU.so -> /usr/local)
g4xaw_base_dir_found=`dirname $g4xaw_base_dir_found`
g4xaw_base_dir_found=`dirname $g4xaw_base_dir_found`
g4xaw_base_dir_found=`dirname $g4xaw_base_dir_found`

	g4ui_xawhome=$g4xaw_base_dir_found
#else
#case "$g4ui_xawhome" in
#'')
#	g4ui_xawhome=/usr/X11R6/
#	;;
#esac
fi
fi

##########################################################################

#if test "X$g4ui_xawhome" != "X" ; then
#xaw_dirs=$g4ui_xawhome
#fi

if test "X$g4ui_xawhome" != "X" ; then

g4message=`cat << EOM

You have selected to use the XAW based user interfaces.
Specify the correct path where XAW is installed in your system.
It was found in $g4ui_xawhome. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the XAW flag at all:

EOM`

dflt=$g4ui_xawhome
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/X11/Xaw" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4ui_xawhome=$ans

else

g4ui_build_xaw_session=n
g4ui_use_xaw=n

fi
else

g4message=`cat << EOM

You have selected to use XAW based user interfaces.
But XAW was not found in $ans.
Please specify the correct path where XAW is installed in your system.

You can set '-' (without quotation) to CANCEL the XAW flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done

else

g4message=`cat << EOM

You have selected to use XAW based user interfaces.
But XAW was not found in expected place.
Please specify the correct path where XAW is installed in your system.

You can set '-' (without quotation) to CANCEL the XAW flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/X11/Xaw" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4ui_xawhome=$ans

else

g4ui_build_xaw_session=n
g4ui_use_xaw=n

fi
else

g4message=`cat << EOM

You have selected to use XAW based user interfaces.
But XAW was not found in $ans.
Please specify the correct path where XAW is installed in your system.

You can set '-' (without quotation) to CANCEL the XAW flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done
fi

if test "X$g4osname" = "XLinux"; then 

if test "X$g4ui_xawhome" = "X/usr" -o "X$g4ui_xawhome" = "X/usr/local" ; then
g4ui_xawhome=""
fi
fi
fi # g4vis_build_opheglxm_driver

###############################################
# Set XMFLAGS and XMLIBS
#

if test "X$g4ui_build_xaw_session" = "Xy" ; then

if test "X$g4osname" = "XAIX" ; then
g4ui_xawflags=" -I$g4ui_xawhome/include "
g4ui_xawlibs=" -L$g4ui_xawhome/lib -lXaw -lXmu -lXt -lX11 -lXext "
fi

if test "X$g4osname" = "XLinux" ; then
	if test "X$g4ui_xawhome" = "X" ; then
		g4ui_xawflags=""
	else
		g4ui_xawflags=" -I$g4ui_xawhome/include "
	fi

	if test "X$g4ui_xawhome" = "X/usr/X11R6" -o "X$g4ui_xawhome" = "X" ; then
		g4ui_xawlibs=" -lXaw "
	else
		if test -d "$g4ui_xawhome/lib64" ; then
			g4ui_xawlibs=" -L$g4ui_xawhome/lib64 -lXaw "
		else
			g4ui_xawlibs=" -L$g4ui_xawhome/lib -lXaw "
		fi
	fi
fi

if test "X$g4osname" = "XDarwin" ; then
g4ui_xawflags=" -I$g4ui_xawhome/include "
g4ui_xawlibs=" -L$g4ui_xawhome/lib -lXaw "
fi

if test "X$g4osname" = "XDEC" ; then
g4ui_xawflags=" -I$g4ui_xawhome/include "
g4ui_xawlibs=" -L$g4ui_xawhome/lib -lXaw "
fi

if test "X$g4osname" = "XHP" ; then
g4ui_xawflags=" -I$g4ui_xawhome/include "
g4ui_xawlibs=" -L$g4ui_xawhome/lib -lXaw "
fi

if test "X$g4osname" = "XSGI" ; then
g4ui_xawflags=" -I$g4ui_xawhome/include "
g4ui_xawlibs=" -L$g4ui_xawhome/lib -lXaw "
fi

if test "X$g4osname" = "XSUN" ; then
g4ui_xawflags=" -I$g4ui_xawhome/include "
g4ui_xawlibs=" -L$g4ui_xawhome/lib -L/usr/openwin/lib -L/usr/dt/lib -L/usr/ucblib -R/usr/openwin/lib -lXaw -lXmu -lXt -lX11 -lXext "
fi

fi # end of XM build 

###############################################
###############################################

g4message=`cat << EOM

  G4UI_BUILD_XM_SESSION
  G4UI_USE_XM

  Specifies to include and use the XM Motif based user interfaces.
  The XM Motif extensions are required to activate and build this
  driver.

EOM`

dflt=$g4ui_use_xm
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4ui_build_xm_session=n
		g4ui_use_xm=n
		;;
	y*|Y*) 
		g4ui_build_xm_session=y
		g4ui_use_xm=y
		;;
	esac


############################################################
############################################################

if test "X$g4ui_build_xm_session" = "Xy" ; then

if test "X$g4vis_xmhome" = "X" ; then
xm_dirs=`find $g4vis_xmhome /usr/X11R6/include /usr/local/include /usr/include /sw/include -type d -name Xm 2>/dev/null |xargs echo`
#echo ogl_dirs=$ogl_dirs

if test "X$xm_dirs" != "X" ; then

g4xm_base_dir_found=`echo $xm_dirs|cut -d" " -f1`
#echo g4ogl_base_dir_found=$g4ogl_base_dir_found

# That's right: should be twice! (e.g./usr/local/lib/libGLU.so -> /usr/local)
g4xm_base_dir_found=`dirname $g4xm_base_dir_found`
g4xm_base_dir_found=`dirname $g4xm_base_dir_found`

	g4vis_xmhome=$g4xm_base_dir_found
#else
#case "$g4vis_xmhome" in
#'')
#	g4vis_xmhome=/usr/X11R6/
#	;;
#esac
fi
fi

##########################################################################

#if test "X$g4vis_xmhome" != "X" ; then
#xm_dirs=$g4vis_xmhome
#fi

if test "X$g4vis_xmhome" != "X" ; then

g4message=`cat << EOM

You have selected to use the XM Motif based user interfaces.
Specify the correct path where Xm is installed in your system.
It was found in $g4vis_xmhome. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=$g4vis_xmhome
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Xm" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_xmhome=$ans

else

g4ui_build_xm_session=n
g4ui_use_xm=n

fi
else

g4message=`cat << EOM

You have selected to use XM Motif based user interfaces.
But XM Motif was not found in $ans.
Please specify the correct path where Xm is installed in your system.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done

else

g4message=`cat << EOM

You have selected to use XM Motif based user interfaces.
But XM Motif was not found in expected place.
Please specify the correct path where Xm is installed in your system.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Xm" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_xmhome=$ans

else

g4ui_build_xm_session=n
g4ui_use_xm=n

fi
else

g4message=`cat << EOM

You have selected to use XM Motif based user interfaces.
But XM Motif was not found in $ans.
Please specify the correct path where Xm is installed in your system.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done
fi

if test "X$g4osname" = "XLinux"; then 
	if test "X$g4vis_xmhome" = "X/usr" -o "X$g4vis_xmhome" = "X/usr/local" ; then
		g4vis_xmhome=""
	fi
fi
fi # g4vis_build_opheglxm_driver

###############################################
# Set XMFLAGS and XMLIBS
#

if test "X$g4ui_build_xm_session" = "Xy" ; then

if test "X$g4osname" = "XAIX" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm -lXt -lX11 "
fi

if test "X$g4osname" = "XLinux" ; then
	if test "X$g4vis_xmhome" = "X" ; then
		g4vis_xmflags=""
	else
		g4vis_xmflags=" -I$g4vis_xmhome/include "
	fi

	if test "X$g4vis_xmhome" = "X/usr/X11R6" -o "X$g4vis_xmhome" = "X" ; then
		g4vis_xmlibs=" -lXm -lXpm "
	else
		if test -d "$g4vis_xmhome/lib64" ; then
			g4vis_xmlibs=" -L$g4vis_xmhome/lib64 -lXm -lXpm "
		else
			g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm -lXpm "
		fi
	fi
fi

if test "X$g4osname" = "XDarwin" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm -lXpm "
fi

if test "X$g4osname" = "XDEC" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm "
fi

if test "X$g4osname" = "XHP" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include/Motif1.2 "
g4vis_xmlibs=" -L$g4vis_xmhome/lib/Motif1.2 -lXm "
fi

if test "X$g4osname" = "XSGI" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm "
fi

if test "X$g4osname" = "XSUN" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -L/usr/openwin/lib -L/usr/dt/lib -L/usr/ucblib -R/usr/openwin/lib -lXt -lXm -lX11 "
fi

fi # end of XM build 

###############################################
###############################################

fi # if !WIN

if test "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7"; then

g4message=`cat << EOM

  G4UI_BUILD_WIN32_SESSION
  G4UI_USE_WIN32

  Specifies to include and use the terminal interface for 
  Windows systems.

EOM`

dflt=$g4ui_use_win32
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4ui_build_win32_session=n
		g4ui_use_win32=n
		;;
	y*|Y*) 
		g4ui_build_win32_session=y
		g4ui_use_win32=y
		;;
	esac

fi # if WIN

g4message=`cat << EOM

  G4UI_USE_TCSH
  Specifies to use the tcsh-style terminal in the application
  to be built.
EOM`

dflt=$g4ui_use_tcsh
rp=$g4message
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4ui_use_tcsh=n
		;;
	y*|Y*) 
		g4ui_use_tcsh=y
		;;
	esac

;;
esac

#
# BEGIN QT/QTUI PROBE
#

# Checks applied for all systems ONLY IF g4ui_none HAS NOT BEEN SET TO y
if test "x$g4ui_none" = "xn" ; then
    # Query the user to see if build of Qt UI module is needed
    g4message=`cat <<EOM

    G4UI_BUILD_QT_SESSION
    G4UI_USE_QT

Setting these variables will enable the building of the G4 Qt based 
user interface module and the use of this module in your applications
respectively.
The Qt3 or Qt4 headers, libraries and moc application are required to enable
the building of this module.
Do you want to enable build and use of this module?
EOM`

    # Read in the user response
    dflt=$g4ui_build_qt_session
    rp=$g4message
    . ./myread
    gans=$ans

    # Check response and take set variables as needed.
    case $gans in
        n*|N*)
	    g4ui_build_qt_session=n
            g4ui_use_qt=n
	    ;;
	y*|Y*)
	    g4ui_build_qt_session=y
            g4ui_use_qt=y
            ;;
    esac

    ##########

    ##########
    # Now, if user chose to build module, we need to check for a Qt
    # installation
    #
    if test "x$g4ui_build_qt_session" = "xy" ; then
	echo " "
	# NB Have to supply arg to qt script, just blank in this case!
	qt_search_dir=""
	. ./qt

	# If we didn't find Qt automatically, then ask user if they know
	# where it's installed...
	if test "x$g4_havegoodqt" = "xno" ; then
	    promptend="no"
	    user_qthome="the standard locations"

            while test "x$promptend" = "xno" ; do
	        g4message=`cat << EOM

Autodetection failed to locate Qt3 or Qt4 in $qthomeloc on your system.
Please enter the path to your Qt3 OR Qt4 install (i.e. if Qt4 is installed
in PATH/include/QT, PATH/include or PATH/include/qt4, enter PATH),
or type '-' to CANCEL the build of the Qt UI module.
Qt path:
EOM`
		dflt=""
                fn='d~(-)'
		rp=$g4message
		. ./getfile
		user_qthome=$ans

		if test "x$user_qthome" = "x-" ; then
		    # Cancel build...
		    g4ui_build_qt_session=n
		    g4ui_use_qt=n
		    echo "configure: build/use of Qt UI module cancelled"
		    promptend=yes
		else
		    # Check for installation in user directory
		    echo " "
		    qt_search_dir=$user_qthome
		    . ./qt

		    if test "x$g4_havegoodqt" = "xyes" ; then
			promptend=yes
		    fi
		fi #END TEST user_qthome = -
            done #END while promptend=no (for user input of Qt install)
        fi #END TEST g4_havegoodqt = no (for user prompt)
    fi #END TEST g4ui_build_qt_session (whether to build at all)
fi #END TEST g4ui_none = n

echo " "
case "$g4vis_none" in
'')
	g4vis_none=n
	;;
esac


case "$g4vis_build_openglwin32_driver" in
'')
	g4vis_build_openglwin32_driver=n
	;;
esac

case "$g4vis_use_openglwin32" in
'')
	g4vis_use_openglwin32=n
	;;
esac

case "$g4vis_build_oiwin32_driver" in
'')
	g4vis_build_oiwin32_driver=n
	;;
esac

case "$g4vis_use_oiwin32" in
'')
	g4vis_use_oiwin32=n
	;;
esac

case "$g4vis_build_dawn_driver" in
'')
	g4vis_build_dawn_driver=n
	;;
esac

case "$g4vis_use_dawn" in
'')
	g4vis_use_dawn=n
	;;
esac

# Set by default!
case "$g4vis_build_dawnfile_driver" in
'')
	g4vis_build_dawnfile_driver=y
	;;
esac

# Set by default!
case "$g4vis_use_dawnfile" in
'')
	g4vis_use_dawnfile=y
	;;
esac

case "$g4vis_build_openglx_driver" in
'')
	g4vis_build_openglx_driver=n
	;;
esac

case "$g4vis_use_openglx" in
'')
	g4vis_use_openglx=n
	;;
esac

case "$g4vis_build_openglxm_driver" in
'')
	g4vis_build_openglxm_driver=n
	;;
esac

case "$g4vis_use_openglxm" in
'')
	g4vis_use_openglxm=n
	;;
esac

case "$g4vis_build_oix_driver" in
'')
	g4vis_build_oix_driver=n
	;;
esac

case "$g4vis_use_oix" in
'')
	g4vis_use_oix=n
	;;
esac

case "$g4vis_build_raytracerx_driver" in
'')
	g4vis_build_raytracerx_driver=n
	;;
esac

case "$g4vis_use_raytracerx" in
'')
	g4vis_use_raytracerx=n
	;;
esac

# Set by default!
case "$g4vis_build_raytracer_driver" in
'')
	g4vis_build_raytracer_driver=y
	;;
esac

# Set by default!
case "$g4vis_use_raytracer" in
'')
	g4vis_use_raytracer=y
	;;
esac

case "$g4vis_build_vrml_driver" in
'')
	g4vis_build_vrml_driver=n
	;;
esac

case "$g4vis_use_vrml" in
'')
	g4vis_use_vrml=n
	;;
esac

# Set by default!
case "$g4vis_build_asciitree_driver" in
'')
	g4vis_build_asciitree_driver=y
	;;
esac

# Set by default!
case "$g4vis_use_asciitree" in
'')
	g4vis_use_asciitree=y
	;;
esac

# Set by default!
case "$g4vis_build_gagtree_driver" in
'')
	g4vis_build_gagtree_driver=y
	;;
esac

# Set by default!
case "$g4vis_use_gagtree" in
'')
	g4vis_use_gagtree=y
	;;
esac

echo ""

g4message=`cat << EOM

  G4VIS_NONE

If this variable is set, no visualization drivers will be built or used.
Do you want to set this variable ?

EOM`

dflt=$g4vis_none
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_none=n
		;;
	y*|Y*) 
		g4vis_none=y
		;;
	esac

case $g4vis_none in

n)

if test "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7"; then

g4message=`cat << EOM

  G4VIS_BUILD_OPENGLX_DRIVER
  G4VIS_USE_OPENGLX

It is an interface to the de facto standard 3D graphics library,
OpenGL. It is well suited for real-time fast visualization
and prototyping. The X11 version of the OpenGL libraries is
required.
EOM`

dflt=$g4vis_use_openglx
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_openglx_driver=n
		g4vis_use_openglx=n
		;;
	y*|Y*) 
		g4vis_build_openglx_driver=y
		g4vis_use_openglx=y
		;;
	esac

#############################################3
g4message=`cat << EOM

  G4VIS_BUILD_OPENGLXM_DRIVER
  G4VIS_USE_OPENGLXM

It is an interface to the de facto standard 3D graphics library,
OpenGL. It is well suited for real-time fast visualization
and prototyping. The X11 version of the OpenGL libraries and 
the Motif Xm extension is required.

EOM`

dflt=$g4vis_use_openglxm
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_openglxm_driver=n
		g4vis_use_openglxm=n
		;;
	y*|Y*) 
		g4vis_build_openglxm_driver=y
		g4vis_use_openglxm=y
		;;
	esac

############################################################
#echo xm_dirs=$xm_dirs
#echo g4vis_xmhome=$g4vis_xmhome
#echo g4ui_build_xm_session=$g4ui_build_xm_session
#echo g4vis_build_openglxm_driver=$g4vis_build_openglxm_driver

if test "X$g4ui_build_xm_session" = "Xn" ; then

#echo PASS1

if test "X$g4vis_build_openglxm_driver" = "Xy" ; then

#echo PASS2

if test "X$g4vis_xmhome" = "X" ; then
xm_dirs=`find $g4vis_xmhome /usr/X11R6/include /usr/local/include /usr/include /sw/include -type d -name Xm 2>/dev/null |xargs echo`
#echo ogl_dirs=$ogl_dirs

if test "X$xm_dirs" != "X" ; then

g4xm_base_dir_found=`echo $xm_dirs|cut -d" " -f1`
#echo g4ogl_base_dir_found=$g4ogl_base_dir_found

# That's right: should be twice! (e.g./usr/local/lib/libGLU.so -> /usr/local)
g4xm_base_dir_found=`dirname $g4xm_base_dir_found`
g4xm_base_dir_found=`dirname $g4xm_base_dir_found`

	g4vis_xmhome=$g4xm_base_dir_found
#else
#case "$g4vis_xmhome" in
#'')
#	g4vis_xmhome=/usr/X11R6/
#	;;
#esac
fi
fi

##########################################################################

#if test "X$g4vis_xmhome" != "X" ; then
#xm_dirs=$g4vis_xmhome
#fi

if test "X$g4vis_xmhome" != "X" ; then

g4message=`cat << EOM

You have selected to use OPENGLXM driver.
Specify the correct path where Xm is installed in your system.
It was found in $g4vis_xmhome. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=$g4vis_xmhome
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Xm" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_xmhome=$ans

else

g4vis_build_openglxm_driver=n
g4vis_use_openglxm=n

fi
else

g4message=`cat << EOM

You have selected to use OPENGLXM driver.
But it was not found in $ans.
Please specify the correct path where Xm is installed in your system.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done

else

g4message=`cat << EOM

You have selected to use OPENGLXM driver.
But it was not found in expected place.
Please specify the correct path where Xm is installed in your system.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Xm" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_xmhome=$ans

else

g4vis_build_openglxm_driver=n
g4vis_use_openglxm=n

fi
else

g4message=`cat << EOM

You have selected to use OPENGLXM driver.
But it was not found in $ans.
Please specify the correct path where Xm is installed in your system.

You can set '-' (without quotation) to CANCEL the XM flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done
fi

if test "X$g4osname" = "XLinux"; then 

if test "X$g4vis_xmhome" = "X/usr" -o "X$g4vis_xmhome" = "X/usr/local" ; then
g4vis_xmhome=""
fi
fi
fi # g4vis_build_opheglxm_driver

###############################################
# Set XMFLAGS and XMLIBS
#

if test "X$g4vis_build_openglxm_driver" = "Xy" ; then

if test "X$g4osname" = "XAIX" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm -lXt -lX11 "
fi

if test "X$g4osname" = "XLinux" ; then
	if test "X$g4vis_xmhome" = "X" ; then
		g4vis_xmflags=""
	else
		g4vis_xmflags=" -I$g4vis_xmhome/include "
	fi

	if test "X$g4vis_xmhome" = "X/usr/X11R6" -o "X$g4vis_xmhome" = "X" ; then
		g4vis_xmlibs=" -lXm -lXpm "
	else
		if test -d "$g4vis_xmhome/lib64" ; then
			g4vis_xmlibs=" -L$g4vis_xmhome/lib64 -lXm -lXpm "
		else
			g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm -lXpm "
		fi
	fi
fi

if test "X$g4osname" = "XDarwin" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm -lXpm "
fi

if test "X$g4osname" = "XDEC" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm "
fi

if test "X$g4osname" = "XHP" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include/Motif1.2 "
g4vis_xmlibs=" -L$g4vis_xmhome/lib/Motif1.2 -lXm "
fi

if test "X$g4osname" = "XSGI" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -lXm "
fi

if test "X$g4osname" = "XSUN" ; then
g4vis_xmflags=" -I$g4vis_xmhome/include "
g4vis_xmlibs=" -L$g4vis_xmhome/lib -L/usr/openwin/lib -L/usr/dt/lib -L/usr/ucblib -R/usr/openwin/lib -lXt -lXm -lX11 "
fi

fi # end of XM build 
fi
###############################################

fi # if !WIN

######################################################################
if test "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7"; then

g4message=`cat << EOM

  G4VIS_BUILD_OPENGLWIN32_DRIVER
  G4VIS_USE_OPENGLWIN32

It is an interface to the de facto standard 3D graphics library,
OpenGL. It is well suited for real-time fast visualization
and prototyping. The Windows version of the OpenGL libraries is
required.

EOM`

dflt=$g4vis_use_openglwin32
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_openglwin32_driver=n
		g4vis_use_openglwin32=n
		;;
	y*|Y*) 
		g4vis_build_openglwin32_driver=y
		g4vis_use_openglwin32=y
		;;
	esac

fi # if WIN
###########################################

if test "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7"; then

g4message=`cat << EOM

  G4VIS_BUILD_DAWN_DRIVER
  G4VIS_USE_DAWN

DAWN drivers are interfaces to the Fukui Renderer DAWN. DAWN is
a vectorized 3D PostScript processor suited to prepare technical
high quality outputs for presentation and/or documentation.

EOM`

dflt=$g4vis_use_dawn
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_dawn_driver=n
		g4vis_use_dawn=n
		;;
	y*|Y*) 
		g4vis_build_dawn_driver=y
		g4vis_use_dawn=y
		;;
	esac


#######################################
g4message=`cat << EOM

  G4VIS_BUILD_OIX_DRIVER
  G4VIS_USE_OIX

The OpenInventor driver is based on OpenInventor technology 
for scientific visualization.
The X11 version of OpenInventor is required.

EOM`

dflt=$g4vis_use_oix
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_oix_driver=n
		g4vis_use_oix=n
		;;
	y*|Y*) 
		g4vis_build_oix_driver=y
		g4vis_use_oix=y
		;;
	esac

############################################################
if test "X$g4vis_build_oix_driver" = "Xy" ; then

oiv_dirs=`find $g4vis_oivhome /usr/X11R6/include /usr/local/include /usr/include  -type d -name Inventor 2>/dev/null|xargs echo`
#echo ogl_dirs=$ogl_dirs

if test "X$oiv_dirs" != "X" ; then

g4oiv_base_dir_found=`echo $oiv_dirs|cut -d" " -f1`
#echo g4ogl_base_dir_found=$g4ogl_base_dir_found

# That's right: should be twice! (e.g./usr/local/lib/libGLU.so -> /usr/local)
g4oiv_base_dir_found=`dirname $g4oiv_base_dir_found`
g4oiv_base_dir_found=`dirname $g4oiv_base_dir_found`

	g4vis_oivhome=$g4oiv_base_dir_found
#else
#case "$g4vis_oivhome" in
#'')
#	g4vis_oivhome=/usr
#	;;
#esac
fi

##########################################################################

#if test "X$g4vis_oivhome" != "X" ; then
#oiv_dirs=$g4vis_oivhome
#fi

if test "X$g4vis_oivhome" != "X" ; then

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
Specify the correct path (OIVHOME) where OpenInventor is installed in your system.
It was found in $g4vis_oivhome. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=$g4vis_oivhome
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Inventor" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_oivhome=$ans

else

g4vis_build_oix_driver=n
g4vis_use_oix=n

fi
else

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
But it was not found in $ans.
Please specify the correct path where OpenInventor is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done

else

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
But it was not found in expected place.
Please specify the correct path where OpenInventor is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Inventor" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_oivhome=$ans

else

g4vis_build_oix_driver=n
g4vis_use_oix=n

fi
else

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
But it was not found in $ans.
Please specify the correct path where OpenInventor is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done
fi

if test "X$g4osname" = "XLinux"; then 

if test "X$g4vis_oivhome" = "X/usr" -o "X$g4vis_oivhome" = "X/usr/local"; then
g4vis_oivhome=""
fi
fi
fi # g4vis_build_oix_driver

###############################################

g4message=`cat << EOM

  G4VIS_BUILD_RAYTRACERX_DRIVER
  G4VIS_USE_RAYTRACERX

Allows for interactive ray-tracing graphics through X11.
The X11 package is required.

EOM`

dflt=$g4vis_use_raytracerx
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_raytracerx_driver=n
		g4vis_use_raytracerx=n
		;;
	y*|Y*) 
		g4vis_build_raytracerx_driver=y
		g4vis_use_raytracerx=y
		;;
	esac

########################################################
fi # if !WIN

###############################################################
if test "X$g4system" = "XWIN32-VC" -o "X$g4system" = "XWIN32-VC7"; then

g4message=`cat << EOM

  G4VIS_BUILD_OIWIN32_DRIVER
  G4VIS_USE_OIWIN32

Specifies to build and use the driver for the free X11 version of
OpenInventor on Windows systems.
The Windows version of OpenInventor is required.

EOM`

dflt=$g4vis_use_oiwin32
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_oiwin32_driver=n
		g4vis_use_oiwin32=n
		;;
	y*|Y*) 
		g4vis_build_oiwin32_driver=y
		g4vis_use_oiwin32=y
		;;
	esac

############################################################
if test "X$g4vis_build_oiwin32_driver" = "Xy" ; then

oiv_dirs=`find $g4vis_oivhome /usr/X11R6/include /usr/local/include /usr/include  -type d -name Inventor 2>/dev/null|xargs echo`
#echo ogl_dirs=$ogl_dirs

if test "X$oiv_dirs" != "X" ; then

g4oiv_base_dir_found=`echo $oiv_dirs|cut -d" " -f1`
#echo g4ogl_base_dir_found=$g4ogl_base_dir_found

# That's right: should be twice! (e.g./usr/local/lib/libGLU.so -> /usr/local)
g4oiv_base_dir_found=`dirname $g4oiv_base_dir_found`
g4oiv_base_dir_found=`dirname $g4oiv_base_dir_found`

	g4vis_oivhome=$g4oiv_base_dir_found
#else
#case "$g4vis_oivhome" in
#'')
#	g4vis_oivhome=/usr
#	;;
#esac
fi

##########################################################################

#if test "X$g4vis_oivhome" != "X" ; then
#oiv_dirs=$g4vis_oivhome
#fi

if test "X$g4vis_oivhome" != "X" ; then

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
Specify the correct path (OIVHOME) where OpenInventor is installed in your system.
It was found in $g4vis_oivhome. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=$g4vis_oivhome
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Inventor" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_oivhome=$ans

else

g4vis_build_oiwin32_driver=n
g4vis_use_oiwin32=n

fi
else

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
But it was not found in $ans.
Please specify the correct path where OpenInventor is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done

else

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
But it was not found in expected place.
Please specify the correct path where OpenInventor is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/Inventor" || [ "X$ans" = "X-"  ]; then
cend="yes"
if test "X$ans" != "X-" ; then

g4vis_oivhome=$ans

else

g4vis_build_oiwin32_driver=n
g4vis_use_oiwin32=n

fi
else

g4message=`cat << EOM

  OIVHOME/include
  OIVHOME/lib

You have selected to use OpenInventor driver.
But it was not found in $ans.
Please specify the correct path where OpenInventor is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done
fi

if test "X$g4osname" = "XLinux"; then 

if test "X$g4vis_oivhome" = "X/usr" -o "X$g4vis_oivhome" = "X/usr/local"; then
g4vis_oivhome=""
fi
fi
fi # g4vis_build_oiwin32_driver

###############################################

fi # if WIN
################################################################

if test "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7"; then

g4message=`cat << EOM

  G4VIS_BUILD_DAWNFILE_DRIVER
  G4VIS_USE_DAWNFILE

DAWN drivers are interfaces to Fukui Renderer DAWN. It is a vectorized 3D 
PostScript processor, and so well suited to prepare technical high
quality outputs for presentation and/or documentation. 
The DAWNFILE driver sends 3D data to DAWN via an intermediate file, 
named g4.prim in the current directory. The file g4.prim is able to 
be re-visualized later without the help of Geant4. 
EOM`

dflt=$g4vis_use_dawnfile
rp=$g4message
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4vis_build_dawnfile_driver=n
		g4vis_use_dawnfile=n
		;;
	y*|Y*) 
		g4vis_build_dawnfile_driver=y
		g4vis_use_dawnfile=y
		;;
	esac

g4message=`cat << EOM

  G4VIS_BUILD_RAYTRACER_DRIVER
  G4VIS_USE_RAYTRACER

It performs ray-tracing visualization using the tracking routines of Geant4. 
It is, therefore, available for debugging tracking routines. 
It is well suited for photo-realistic high quality output for 
presentation, and for intuitive debugging of detector geometry. 
EOM`

dflt=$g4vis_use_raytracer
rp=$g4message
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4vis_build_raytracer_driver=n
		g4vis_use_raytracer=n
		;;
	y*|Y*) 
		g4vis_build_raytracer_driver=y
		g4vis_use_raytracer=y
		;;
	esac

g4message=`cat << EOM

  G4VIS_BUILD_VRML_DRIVER
  G4VIS_USE_VRML

These driver generate VRML files, which describe 3D scenes to be 
visualized with a proper VRML viewer.

EOM`

dflt=$g4vis_use_vrml
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4vis_build_vrml_driver=n
		g4vis_use_vrml=n
		;;
	y*|Y*) 
		g4vis_build_vrml_driver=y
		g4vis_use_vrml=y
		;;
	esac

g4message=`cat << EOM

  G4VIS_BUILD_VRMLFILE_DRIVER
  G4VIS_USE_VRMLFILE

This driver generates VRML files, which describe 3D scenes to be 
visualized with a proper VRML viewer, at either a local or a remote host. 
The VRMLFILE driver sends 3D data to your VRML viewer, which is running 
in the same host machine as Geant4, via an intermediate file named 
g4.wrl created in the current directory. This file is available for 
re-visualization afterwards. In visualization, you should specify a 
name of the VRML viewer by setting the environment variable G4VRML_VIEWER 
beforehand.
EOM`

dflt=$g4vis_use_vrmlfile
rp=$g4message
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4vis_build_vrmlfile_driver=n
		g4vis_use_vrmlfile=n
		;;
	y*|Y*) 
		g4vis_build_vrmlfile_driver=y
		g4vis_use_vrmlfile=y
		;;
	esac

fi # if !WIN

g4message=`cat << EOM

  G4VIS_BUILD_ASCIITREE_DRIVER
  G4VIS_USE_ASCIITREE

Description????????????????????????
EOM`

dflt=$g4vis_use_asciitree
rp=$g4message
# Don't ask by default and set to 'y'!
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4vis_build_asciitree_driver=n
		g4vis_use_asciitree=n
		;;
	y*|Y*) 
		g4vis_build_asciitree_driver=y
		g4vis_use_asciitree=y
		;;
	esac


g4message=`cat << EOM

  G4VIS_BUILD_GAGTREE_DRIVER
  G4VIS_USE_GAGTREE

Description????????????????????????
EOM`

dflt=$g4vis_use_gagtree
rp=$g4message
# Don't ask by default and set to 'y'!
#. ./myread
#gans=$ans
gans=y

	case $gans in
	
	n*|N*) 
		g4vis_build_gagtree_driver=n
		g4vis_use_gagtree=n
		;;
	y*|Y*) 
		g4vis_build_gagtree_driver=y
		g4vis_use_gagtree=y
		;;
	esac

;;
esac

if test "X$g4system" != "XWIN32-VC" -a "X$g4system" != "XWIN32-VC7" -a "X$g4system" != "XDarwin-g++"; then

#echo PASS1

if [ X$g4vis_build_openglx_driver = Xy ] || [ X$g4vis_build_openglxm_driver = Xy ] || [ X$g4vis_build_openglwin32_driver = Xy ] ; then 

#echo PASS2

#####################################################################
ogl_dirs=`find $g4vis_oglhome /usr/X11R6/include /usr/local/include /usr/include -type d -name GL 2>/dev/null|xargs echo`
#echo ogl_dirs=$ogl_dirs

if test "X$ogl_dirs" != "X" ; then

g4ogl_base_dir_found=`echo $ogl_dirs|cut -d" " -f1`
#echo g4ogl_base_dir_found=$g4ogl_base_dir_found

# That's right: should be twice! (e.g./usr/local/lib/libGLU.so -> /usr/local)
g4ogl_base_dir_found=`dirname $g4ogl_base_dir_found`
g4ogl_base_dir_found=`dirname $g4ogl_base_dir_found`

	g4vis_oglhome=$g4ogl_base_dir_found
#else
#case "$g4vis_oglhome" in
#'')
#	g4vis_oglhome=/usr
#	;;
#esac
fi

##########################################################################
if test "X$g4vis_oglhome" != "X" ; then
ogl_dirs=$g4vis_oglhome
fi

if test "X$ogl_dirs" != "X" ; then

g4message=`cat << EOM

  OGLHOME/include
  OGLHOME/lib

You have selected to use OpenGL driver.
Specify the correct path (OGLHOME) where OpenGL is installed in your system.
It was found in $g4vis_oglhome. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the OpenGL flag at all:

EOM`

dflt=$g4vis_oglhome
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/GL" || [ "X$ans" = "X-"  ]; then
cend="yes"

if test "X$ans" != "X-" ; then

g4vis_oglhome=$ans

else

g4vis_build_openglx_driver=n
g4vis_use_openglx=n

g4vis_build_openglxm_driver=n
g4vis_use_openglxm=n

g4vis_build_openglwin32_driver=n
g4vis_use_openglwin32=n

fi
else

g4message=`cat << EOM

  OGLHOME/include
  OGLHOME/lib

You have selected to use OpenGL driver.
But it was not found in $ans.
Please specify the correct path where OpenGL is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenGL flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done

else

g4message=`cat << EOM

  OGLHOME/include
  OGLHOME/lib

You have selected to use OpenGL driver.
But it was not found in expected place.
Please specify the correct path where OpenGL is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenGL flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile

cend="no"
while test "$cend" = "no" ; do
if test -e "$ans/include/GL" || [ "X$ans" = "X-"  ]; then
cend="yes"

if test "X$ans" != "X-" ; then

g4vis_oglhome=$ans

else

g4vis_build_openglx_driver=n
g4vis_use_openglx=n

g4vis_build_openglxm_driver=n
g4vis_use_openglxm=n

g4vis_build_openglwin32_driver=n
g4vis_use_openglwin32=n

fi
else

g4message=`cat << EOM

  OGLHOME/include
  OGLHOME/lib

You have selected to use OpenGL driver.
But it was not found in $ans.
Please specify the correct path where OpenGL is installed in your system.

You can set '-' (without quotation) to CANCEL the OpenGL flag at all:

EOM`

dflt=""
fn='d~(-)'
rp=$g4message
. ./getfile
fi
done

fi

if test "X$g4osname" = "XLinux"; then 

if test "X$g4vis_oglhome" = "X/usr" -o "X$g4vis_oglhome" = "X/usr/local"; then
g4vis_oglhome=""
fi

fi # if platform (Linux vs SUN)

fi # if need
###########################################
fi # if platform (Unix vs Win)

#
# BEGIN QTVIS/QT PROBE
#
# Because the vis driver only works with UI, only probe if g4ui_none is
# 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
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

    G4UI_BUILD_OPENGLQT_DRIVER
    G4UI_USE_OPENGLQT

Setting these variables will enable the building of the G4 OpenGL Qt based 
visualisation driver and the use of this driver in your applications
respectively.
The Qt3 or Qt4 headers, libraries and moc application are required to enable
the building of this module.
Do you want to enable build and use of this module?
EOM`

    # Read in the user response
    dflt=$g4vis_build_openglqt_driver
    rp=$g4message
    . ./myread
    gans=$ans

    # Check response and take set variables as needed.
    case $gans in
        n*|N*)
	    g4vis_build_openglqt_driver=n
            g4vis_use_openglqt=n
	    ;;
	y*|Y*)
	    g4vis_build_openglqt_driver=y
            g4vis_use_openglqt=y
            ;;
    esac

    ##########

    ##########
    # Now, if user chose to build module, we need to check for a Qt
    # installation
    #
    if test "x$g4vis_build_openglqt_driver" = "xy" ; then
	echo " "
	# NB Have to supply arg to qt script, just blank in this case!
	qt_search_dir=""
	. ./qt

	# If we didn't find Qt automatically, then ask user if they know
	# where it's installed...
	if test "x$g4_havegoodqt" = "xno" ; then
	    promptend="no"
	    user_qthome="the standard locations"

            while test "x$promptend" = "xno" ; do
	        g4message=`cat << EOM

Autodetection failed to locate Qt3 or Qt4 in $qthomeloc on your system.
Please enter the path to your Qt3 OR Qt4 install (i.e. if Qt4 is installed
in PATH/include/QT, PATH/include or PATH/include/qt4, enter PATH),
or type '-' to CANCEL the build of the Qt UI module.
Qt path:
EOM`
		dflt=""
                fn='d~(-)'
		rp=$g4message
		. ./getfile
		user_qthome=$ans

		if test "x$user_qthome" = "x-" ; then
		    # Cancel build...
		    g4vis_build_openglqt_driver=n
		    g4vis_use_openglqt=n
		    echo "configure: build/use of Qt OpenGl driver cancelled"
		    promptend=yes
		else
		    # Check for installation in user directory
		    echo " "
		    qt_search_dir=$user_qthome
		    . ./qt

		    if test "x$g4_havegoodqt" = "xyes" ; then
			promptend=yes
		    fi
		fi #END TEST user_qthome = -
            done #END while promptend=no (for user input of Qt install)
        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

#
# BEGIN GDML/XERCESC PROBE 
#

# Set default build option to no
echo " "
case "$g4lib_build_gdml" in
'')
	g4lib_build_gdml=n
	;;
esac


# Now query the user to see if they want to build the GDML plugin
echo ""

g4message=`cat << EOM

  G4LIB_BUILD_GDML

Setting this variable will enable building of the GDML plugin module embedded
in Geant4 for detector description persistency.
It requires your system to have the XercesC library and headers installed.
Do you want to set this variable?

EOM`

#
# read in the users response
#
dflt=$g4lib_build_gdml
rp=$g4message
. ./myread
gans=$ans

#
# Check response
#
case $gans in
     n*|N*)
	g4lib_build_gdml=n
	;;
     y*|Y*)
	g4lib_build_gdml=y
	;;
esac


#
# If user does want to build GDML plugin, now try to locate Xerces install
#
if test "X$g4lib_build_gdml" != "Xn"; then

   if test "X$g4gdml_xercesc_root" = "X"; then
      #probe for Xerces, using example from UI and Vis
      xercesc_root=`find $g4gdml_xercesc_root /usr/include /usr/local/include \
/opt/local/include /sw/include -type d -name xercesc 2>/dev/null | xargs echo`

      #If we got something, strip off the include/xerces part
      if test "X$xercesc_root" != "X"; then
	 g4gdml_xercesc_root=`dirname $xercesc_root`
	 g4gdml_xercesc_root=`dirname $g4gdml_xercesc_root`

	 echo " "
	 echo "checking for XercesC install... $g4gdml_xercesc_root"
      else
         g4gdml_xercesc_root=""
	 echo " "
	 echo "checking for XercesC install... no"
      fi
   fi #END OF XERCES AUTOPROBE

   #
   # If the autoprobe failed, prompt the user to enter the path to the Xerces
   # install
   #
   if test "X$g4gdml_xercesc_root" = "X"; then

      promptend="no"
      xercesloc="the standard locations"
      
      while test "$promptend" = "no"; do
	    g4message=`cat << EOM

Autodetection failed to locate XercesC in $xercesloc on your system. 
Please enter the path to your XercesC install (i.e. if XercesC is installed
in PATH/include/xercesc, enter PATH), or type '-' to CANCEL the build of the 
GDML module.
XercesC path:
EOM`

	    dflt=$g4gdml_xercesc_root
	    fn='d~(-)'
	    rp=$g4message
	    . ./getfile

	    #check for user cancellation
	    if test "X$ans" = "X-"; then
	       g4lib_build_gdml=n
	       g4gdml_xercesc_root=""
	       echo "G4LIB_BUILD_GDML cancelled..."
	       promptend=yes
	    else
	       if test -r "$ans/include/xercesc"; then
		  g4gdml_xercesc_root=$ans
		  echo "checking for XercesC install... $g4gdml_xercesc_root"
		  promptend=yes
	       else
	          xercesloc=$ans
	          echo "checking for Xercesc install... no"
	       fi
            fi #END OF USER INPUT CHECKING
      done #END OF WHILE LOOP OVER USER INPUT
   fi #END OF USER INPUT SECTION

   #
   # If a filter on g4gdml_xerces_root is needed to remove common system paths
   # then it should be put here...
   #
	if test "x$g4gdml_xercesc_root" = "x/usr" -o "x$g4gdml_xercesc_root" = "x/usr/local" ; then
		g4gdml_xercesc_root=""
	fi

fi #END XERCES PROBE

#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 " "

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
	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



echo " "
case "$g4wlib_build_g3tog4" in
'')
	g4wlib_build_g3tog4=n
	;;
esac

case "$g4w_use_g3tog4" in
'')
	g4w_use_g3tog4=n
	;;
esac

echo ""

g4message=`cat << EOM

  G4LIB_BUILD_G3TOG4  

The utility module 'g3tog4' will be built by setting this
variable. NOTE: it requires a valid FORTRAN compiler to be
installed on your system and the 'cernlib' command in the
path, in order to build the ancillary tools!
Do you want to build 'g3tog4' ?
 
EOM`

dflt=$g4wlib_build_g3tog4
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4wlib_build_g3tog4=n
		g4w_use_g3tog4=n
		;;
	y*|Y*) 
		g4wlib_build_g3tog4=y
		g4w_use_g3tog4=y
		;;
	esac


echo " "
case "$g4wlib_build_zlib" in
'')
	g4wlib_build_zlib=n
	;;
esac

case "$g4w_use_zlib" in
'')
	g4w_use_zlib=n
	;;
esac

echo ""

g4message=`cat << EOM

  G4LIB_BUILD_ZLIB  

Do you want to activate compression for output files
generated by the HepRep visualization driver?
 
EOM`

dflt=$g4wlib_build_zlib
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4wlib_build_zlib=n
		g4w_use_zlib=n
		;;
	y*|Y*) 
		g4wlib_build_zlib=y
		g4w_use_zlib=y
		;;
	esac


echo " "

case "$g4wanalysis_use" in
'')
	g4wanalysis_use=n
	;;
esac

echo ""

g4message=`cat << EOM

  G4ANALYSIS_USE

Activates the configuration setup for allowing plugins to
analysis tools based on AIDA (Astract Interfaces for Data
Analysis). In order to use AIDA features and compliant analysis
tools, the proper environment for these tools will have to be
set (see documentation for the specific analysis tools).
EOM`

dflt=$g4wanalysis_use
rp=$g4message
. ./myread
gans=$ans

	case $gans in
	
	n*|N*) 
		g4wanalysis_use=n
		;;
	y*|Y*) 
		g4wanalysis_use=y
		;;
	esac


: end of configuration questions
echo " "
echo "End of configuration phase."
echo " "

: back to where it started
if test -d ../../.config/UU; then
	cd ../..
fi

: configuration may be patched via a 'config.over' file
if $test -f config.over; then
	echo " "
	dflt=y
	rp='A config.over file exists.  Do you wish to load it?'
	. .config/UU/myread
	case "$ans" in
	n*) echo "OK, I'll ignore it.";;
	*)	. ./config.over
		echo "Configuration settings have been loaded."
		;;
	esac
fi

: in case they want portability, strip down executable paths
case "$d_portable" in
"$define")
	echo " "
	echo "Stripping down executable paths..." >&4
	for file in $loclist $trylist; do
		eval $file="\$file"
	done
	;;
esac

: create config.sh file
echo " "
echo "Creating configuration setup file..." >&4
mkdir -p $g4conf
$spitshell <<EOT > $g4conf/config.sh
$startsh
#
# This file was produced by running the Configure script. It holds all the
# definitions figured out by Configure. Should you modify one of these values,
# do not forget to propagate your changes by running "Configure -der". You may
# instead choose to run each of the .SH files by yourself, or "Configure -S".
#

# Package name      : $package
# Source directory  : $src
# Configuration time: $cf_time
# Configured by     : $cf_by
# Target system     : $myuname

Author='$Author'
Date='$Date'
Header='$Header'
Id='$Id'
Locker='$Locker'
Log='$Log'
RCSfile='$RCSfile'
Revision='$Revision'
Source='$Source'
State='$State'
c='$c'
cf_by='$cf_by'
cf_time='$cf_time'
contains='$contains'
d_portable='$d_portable'
eunicefix='$eunicefix'
g4_gmake='$g4_gmake'
g4_gmake_version='$g4_gmake_version'
g4_make='$g4_make'
g4_make_version='$g4_make_version'
g4_qt_cxxflags='$g4_qt_cxxflags'
g4_qt_gl_cxxflags='$g4_qt_gl_cxxflags'
g4_qt_gl_libs='$g4_qt_gl_libs'
g4_qt_libs='$g4_qt_libs'
g4_qt_moc='$g4_qt_moc'
g4_qt_version='$g4_qt_version'
g4abladata='$g4abladata'
g4base='$g4base'
g4bin='$g4bin'
g4clhep_base_dir='$g4clhep_base_dir'
g4clhep_include_dir='$g4clhep_include_dir'
g4clhep_lib='$g4clhep_lib'
g4clhep_lib_dir='$g4clhep_lib_dir'
g4compiler='$g4compiler'
g4conf='$g4conf'
g4data='$g4data'
g4debug='$g4debug'
g4elasticdata='$g4elasticdata'
g4final_install='$g4final_install'
g4gdml_xercesc_root='$g4gdml_xercesc_root'
g4global='$g4global'
g4granular='$g4granular'
g4include='$g4include'
g4includes_flag='$g4includes_flag'
g4install='$g4install'
g4ledata='$g4ledata'
g4levelgammadata='$g4levelgammadata'
g4lib='$g4lib'
g4lib_build_gdml='$g4lib_build_gdml'
g4lib_build_shared='$g4lib_build_shared'
g4lib_build_static='$g4lib_build_static'
g4lib_use_dll='$g4lib_use_dll'
g4lib_use_dyn='$g4lib_use_dyn'
g4lib_use_granular='$g4lib_use_granular'
g4lib_use_shared='$g4lib_use_shared'
g4lib_use_static='$g4lib_use_static'
g4make='$g4make'
g4neutronhpcrosssections='$g4neutronhpcrosssections'
g4osname='$g4osname'
g4radioactivedata='$g4radioactivedata'
g4system='$g4system'
g4tmp='$g4tmp'
g4ui_build_gag_session='$g4ui_build_gag_session'
g4ui_build_qt_session='$g4ui_build_qt_session'
g4ui_build_terminal_session='$g4ui_build_terminal_session'
g4ui_build_win32_session='$g4ui_build_win32_session'
g4ui_build_xaw_session='$g4ui_build_xaw_session'
g4ui_build_xm_session='$g4ui_build_xm_session'
g4ui_none='$g4ui_none'
g4ui_use_gag='$g4ui_use_gag'
g4ui_use_qt='$g4ui_use_qt'
g4ui_use_tcsh='$g4ui_use_tcsh'
g4ui_use_terminal='$g4ui_use_terminal'
g4ui_use_win32='$g4ui_use_win32'
g4ui_use_xaw='$g4ui_use_xaw'
g4ui_use_xm='$g4ui_use_xm'
g4ui_xawflags='$g4ui_xawflags'
g4ui_xawhome='$g4ui_xawhome'
g4ui_xawlibs='$g4ui_xawlibs'
g4vis_build_asciitree_driver='$g4vis_build_asciitree_driver'
g4vis_build_dawn_driver='$g4vis_build_dawn_driver'
g4vis_build_dawnfile_driver='$g4vis_build_dawnfile_driver'
g4vis_build_oiwin32_driver='$g4vis_build_oiwin32_driver'
g4vis_build_oix_driver='$g4vis_build_oix_driver'
g4vis_build_openglqt_driver='$g4vis_build_openglqt_driver'
g4vis_build_openglwin32_driver='$g4vis_build_openglwin32_driver'
g4vis_build_openglx_driver='$g4vis_build_openglx_driver'
g4vis_build_openglxm_driver='$g4vis_build_openglxm_driver'
g4vis_build_raytracer_driver='$g4vis_build_raytracer_driver'
g4vis_build_raytracerx_driver='$g4vis_build_raytracerx_driver'
g4vis_build_vrml_driver='$g4vis_build_vrml_driver'
g4vis_build_vrmlfile_driver='$g4vis_build_vrmlfile_driver'
g4vis_oglhome='$g4vis_oglhome'
g4vis_oivhome='$g4vis_oivhome'
g4vis_use_asciitree='$g4vis_use_asciitree'
g4vis_use_dawn='$g4vis_use_dawn'
g4vis_use_dawnfile='$g4vis_use_dawnfile'
g4vis_use_oiwin32='$g4vis_use_oiwin32'
g4vis_use_oix='$g4vis_use_oix'
g4vis_use_openglqt='$g4vis_use_openglqt'
g4vis_use_openglwin32='$g4vis_use_openglwin32'
g4vis_use_openglx='$g4vis_use_openglx'
g4vis_use_openglxm='$g4vis_use_openglxm'
g4vis_use_raytracer='$g4vis_use_raytracer'
g4vis_use_raytracerx='$g4vis_use_raytracerx'
g4vis_use_vrml='$g4vis_use_vrml'
g4vis_use_vrmlfile='$g4vis_use_vrmlfile'
g4vis_xmflags='$g4vis_xmflags'
g4vis_xmflags='$g4vis_xmflags'
g4vis_xmhome='$g4vis_xmhome'
g4vis_xmhome='$g4vis_xmhome'
g4vis_xmlibs='$g4vis_xmlibs'
g4vis_xmlibs='$g4vis_xmlibs'
g4w_use_g3tog4='$g4w_use_g3tog4'
g4w_use_zlib='$g4w_use_zlib'
g4wanalysis_build='$g4wanalysis_build'
g4wanalysis_build_jas='$g4wanalysis_build_jas'
g4wanalysis_build_lab='$g4wanalysis_build_lab'
g4wanalysis_build_lizard='$g4wanalysis_build_lizard'
g4wanalysis_use='$g4wanalysis_use'
g4wanalysis_use_jas='$g4wanalysis_use_jas'
g4wanalysis_use_lab='$g4wanalysis_use_lab'
g4wanalysis_use_lizard='$g4wanalysis_use_lizard'
g4wlib_build_g3tog4='$g4wlib_build_g3tog4'
g4wlib_build_zlib='$g4wlib_build_zlib'
g4workdir='$g4workdir'
hint='$hint'
lns='$lns'
myuname='$myuname'
n='$n'
osname='$osname'
osvers='$osvers'
package='$package'
sh='$sh'
sharpbang='$sharpbang'
shsharp='$shsharp'
spackage='$spackage'
spitshell='$spitshell'
src='$src'
startsh='$startsh'
EOT

: add special variables
mkdir -p $g4conf
$test -f $src/patchlevel.h && \
awk '/^#define/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >> $g4conf/config.sh
echo "CONFIG=true" >> $g4conf/config.sh

: propagate old symbols
if $test -f .config/UU/config.sh; then
	<.config/UU/config.sh sort | uniq >.config/UU/oldconfig.sh
	sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' $g4conf/config.sh $g4conf/config.sh .config/UU/oldconfig.sh |\
	sort | uniq -u >.config/UU/oldsyms
	set X `cat .config/UU/oldsyms`
	shift
	case $# in
	0) ;;
	*)
		cat <<EOM
		
Hmm...You had some extra variables I don't know about...
      I'll try to keep 'em...

EOM
		echo "# Variables propagated from previous config.sh file." >>.config/bin/$g4system/config.sh
		for sym in `cat .config/UU/oldsyms`; do
			echo "    Propagating $hint variable "'$'"$sym..."
			eval 'tmp="$'"${sym}"'"'
			echo "$tmp" | \
				sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>.config/bin/$g4system/config.sh
		done
		;;
	esac
fi

: preserve RCS keywords in files with variable substitution, grrr
Id='$Id'

: Finish up by extracting the .SH files
case "$alldone" in
exit)
	$rm -rf .config/UU
	echo "Done."
	exit 0
	;;
cont)
	;;
'')
	dflt=''
	nostick=true
	$cat <<EOM

WARNING: the generated configuration file
can be edited if necessary!
You can introduce any change to the configuration file
$g4conf/config.sh before the final installation. 
To do so, use a shell escape now (e.g. !vi $g4conf/config.sh).

EOM
	rp="Press [Enter] to start installation or use a shell escape to edit config.sh:"
	. .config/UU/myread
	nostick=''
	case "$ans" in
	'') ;;
	*) : in case they cannot read
		sh 1>&4 -c "$ans";;
	esac
	;;
esac

: if this fails, just run all the .SH files by hand
. $g4conf/config.sh

echo " "
exec 1>&4
. ./.config/UU/extract

if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
	dflt=y
	case "$silent" in
	true) ;;
	*)
		$cat <<EOM

Now you need to generate make dependencies by running "make depend".
You might prefer to run it in background: "make depend > makedepend.out &"
It can take a while, so you might not want to run it right now.

EOM
		;;
	esac
	rp="Run make depend now?"
	. .config/UU/myread
	case "$ans" in
	y*)
		make depend && echo "Now you must run a make."
		;;
	*)
		echo "You must run 'make depend' then 'make'."
		;;
	esac
elif test -f [Mm]akefile; then
	echo " "
	echo "Now you must run a make."
elif [ -f $g4conf/install.sh -a X$g4build = Xyes ] ; then
	echo " "
	echo "Now starting Geant4 libraries build..."
	echo " "
	. $g4conf/install.sh
elif [ -f $g4conf/install.sh -a X$install = Xyes ] ; then
	echo " "
	echo "Now starting Geant4 libraries installation..."
	echo " "
	. $g4conf/move.sh
else
	echo " "
	echo "WARNING: Geant4 is NOT installed yet!"
	echo "You (or the administrator if you have not enough privileges)"
	echo "should start with \$G4INSTALL/Configure -install"
	echo "(where \$G4INSTALL is Geant4 install directory)."
	echo " "
fi

$rm -f kit*isdone ark*isdone
$rm -rf .config/UU

: End of Configure

