swh:1:snp:af87cd67498ef4fe47c76ed3e7caffe5b61facaf
Raw File
Tip revision: c6326bb5ce68bef76f8f86bb53ec6387625e66fb authored by Unknown Author on 30 May 2007, 11:18:20 UTC
This commit was manufactured by cvs2svn to create tag 'v5-14-00f'.
Tip revision: c6326bb
configure
#! /bin/sh
#
# A (not so) simple configure script.
#
# Authors: Christian Holm Christensen and Fons Rademakers
#
# To help with debugging the script, some comments are preprended with
# 3 '#' echo and 3 '%' - replace that pattern with echo and 3 '%' to
# get printouts.  When done replace the pattern echo and 3 '%' with the
# original pattern of 3 '#' echo and 3 '%'.  Emacs command M-C-% does
# this easily.
#
######################################################################
#
### echo %%% Some global variables
#
found_lib=no
found_dir=no
found_hdr=no
show_pkglist=no
fail_on_missing=no
noact="no"
nohowto="no"
logfile=config.log

options="                    \
   enable_afs                \
   enable_alien              \
   enable_asimage            \
   enable_astiff             \
   enable_builtin_afterimage \
   enable_builtin_freetype   \
   enable_builtin_pcre       \
   enable_builtin_zlib       \
   enable_castor             \
   enable_cern               \
   enable_chirp              \
   enable_cint7              \
   enable_cintex             \
   enable_clarens            \
   enable_dcache             \
   enable_exceptions         \
   enable_explicitlink       \
   enable_fftw3              \
   enable_gdml               \
   enable_gfal               \
   enable_g4root             \
   enable_globus             \
   enable_krb5               \
   enable_ldap               \
   enable_mathcore           \
   enable_mathmore           \
   enable_monalisa           \
   enable_mysql              \
   enable_odbc               \
   enable_opengl             \
   enable_oracle             \
   enable_pch                \
   enable_peac               \
   enable_pgsql              \
   enable_pythia6            \
   enable_python             \
   enable_qt                 \
   enable_qtgsi              \
   enable_reflex             \
   enable_roofit             \
   enable_minuit2            \
   enable_ruby               \
   enable_rfio               \
   enable_rpath              \
   enable_sapdb              \
   enable_shadowpw           \
   enable_shared             \
   enable_soversion          \
   enable_srp                \
   enable_ssl                \
   enable_table              \
   enable_thread             \
   enable_unuran             \
   enable_winrtdebug         \
   enable_xml                \
   enable_xrootd             \
"

#
# This sets all options to "yes" - we turn off those we don't want
# on per default explictly afterwards.
#
for c in $options ; do eval ${c}="yes" ; done
for c in $options ; do eval ${c}_explicit="no" ; done

enable_afs=no
enable_cint7=no
enable_gdml=no
enable_explicitlink=no
enable_qt=no
enable_qtgsi=no
enable_roofit=no
enable_minuit2=no
enable_rpath=no
enable_ruby=no
enable_shadowpw=
enable_soversion=no
enable_table=no
enable_unuran=no
enable_winrtdebug=
enable_xrootd=           # must be set explicitely via --enable-xrootd

# Remove old log file
rm -f $logfile

#
# ./configure arguments and defaults set via supported env vars
#
envvars="
THREAD           \
OPENGL           \
MYSQL            \
ORACLE           \
PGSQL            \
QTDIR            \
SAPDB            \
RFIO             \
CASTOR           \
GFAL             \
G4ROOT           \
GSL              \
CERNLIB          \
PYTHIA6          \
FFTW3            \
PYTHONDIR        \
DCACHE           \
CHIRP            \
ALIEN            \
ASIMAGE          \
LDAP             \
GLOBUS_LOCATION  \
MONALISA         \
SRP              \
SSL              \
AFS              \
ROOFIT           \
MINUIT2          \
TABLE            \
XMLDIR           \
ROOTDICTTYPE     \
"
configenvvars=
for c in $envvars ; do
   cc=`eval echo "$"$c | sed 's,\\\,\\\\\\\,g'`
   if test ! "x$cc" = "x" ; then
      if test ! "x$configenvvars" = "x" ; then
         configenvvars="$configenvvars $c=$cc"
      else
         configenvvars="$c=$cc"
      fi
   fi
done

configargs="$*"
# don't write --nohowto to config.h
configargs=`echo $configargs | sed 's, *--nohowto,,g'`

configoptions=
if test ! "x$configenvvars" = "x" ; then
   configoptions=$configenvvars
fi
if test ! "x$configargs" = "x" ; then
   if test ! "x$configoptions" = "x" ; then
      configoptions="$configoptions $configargs"
   else
      configoptions=$configargs
   fi
fi
configoptions=`echo $configoptions | sed 's,\\\,\\\\\\\,g'`

######################################################################
#
### echo %%% Some common functions
#
#_____________________________________________________________________
message() {
    # Write a simple message to std out
    if test $# -lt 1 ; then
	echo "message: Too few arguments"
	return 1
    fi
    echo $ac_n "$* ... $ac_c"
    logmsg "$*"
}

#_____________________________________________________________________
logmsg() {
    # Write a simple message to std out
    if test $# -lt 1 ; then
	echo "logmsg: Too few arguments"
	return 1
    fi
    if test "x$1" = "x-n"; then
       shift
       echo -n "$*" >> $logfile
    else
       echo "$*" >> $logfile
    fi
}

#_____________________________________________________________________
result() {
    echo "$*"
    logmsg "Result: $*"
}

#_____________________________________________________________________
checking_msg() {
    # Write a simple "checking" message to std out.
    if test $# -lt 1 ; then
	echo "checking_msg: Too few arguments"
	return 1
    fi
    echo $ac_n "Checking for$ac_c"
    logmsg $ac_n "Checking for$ac_c"
    while test $# -gt 1 ; do
	echo $ac_n " $1,$ac_c"
	logmsg $ac_n " $1,$ac_c"
	shift
	if test $# -eq 1 ; then
	    echo $ac_n " or$ac_c"
	    logmsg $ac_n " or$ac_c"
	fi
    done
    echo $ac_n " $1 ... $ac_c"
    logmsg " $1 ... "
}

#_____________________________________________________________________
check_lib64() {
    # This function will try to find out if a library [$1] contains 64 bit
    # or 32 bit code. Currently works only for linux.
    # The result of the check is stored in is_lib64, 1 if true,
    # 0 otherwise, which should be immediately copied, since the variable
    # will be overwritten at next invocation of this function.

    is_lib64=0

    # Assert that we got enough arguments
    if test $# -ne 1 ; then
	echo "check_lib64: not 1 argument"
	return 1
    fi

    # Save arguments in logical names
    chklib64=$1
    logmsg "Checking if $chklib64 is a 64bit library"
    if [ "x`basename $chklib64 .a`" != "x`basename $chklib64`" ]; then
        # we have an archive .a file
	logmsg "objdump -a $chklib64 | grep 'x86-64'"
        objdump -a $chklib64 | grep 'x86-64' > /dev/null 2>& 1
	ret=$?
    else
	logmsg "file -L $chklib64 | grep '64-bit'"
        file -L $chklib64 | grep '64-bit' > /dev/null 2>& 1
	ret=$?
    fi
    logmsg "result: $ret"
    if test $? -eq 0 ; then
        is_lib64=1
	logmsg "is a 64bit library"
    fi
}

#_____________________________________________________________________
check_library() {
    # This function will try to locate a library [$1] in the specific
    # directory [$3] or in a default path [$*].  If the second argument
    # [$2] is not "no", then shared libraries are favoured.
    # The result of the search is stored in found_lib and found_dir,
    # which should be immediately copied, since the variables value will
    # be overwritten at next invocation of this function.

    # Assert that we got enough arguments
    if test $# -lt 4 ; then
	echo "check_library: Too few arguments"
	return 1
    fi

    # Save arguments in local names
    lib=$1       ; shift
    shared=$1    ; shift
    libdirl=$1   ; shift
    libdirs="$*"

    # Write a message
    checking_msg $lib

    # check if we got a specific argument as to where the library
    # is to be found
    if test ! "x$libdirl" = "x" ; then
        libdirs=$libdirl
    fi
    found_lib=no
    found_dir=no

    # Make list of libraries to search for. The .lib extension is for
    # Windoze - note $shared is always "no" on windoze, since we need
    # the .lib export library to link.
    libs=""
    for i in $lib ; do
	for ext in .a .lib "" ; do     # lib without extension for MacOS X
	    libs="$libs $i$ext"
	done
    done
    slibs=""
    for i in $lib ; do
        for ext in .so .sl .dylib .dll.a ; do      # .dll.a for cygwin gcc
            slibs="$slibs $i$ext"
        done
    done
    if test ! "x$shared" = "xno" ; then
	libs="$slibs $libs"
    else
        libs="$libs $slibs"
    fi

    logmsg "libraries to check for: $libs"
    # Loop over the list of possible directories, and see if we can
    # find any of the library files as determind above.
    for i in $libdirs ; do
        # look first in the lib32 directories
        if test "x$checklib32" = "xyes" ; then
            i32=`echo $i | sed -e 's|lib$|lib32|' -e 's|lib/|lib32/|'`
            #i="$i32 $i"
            i="$i32"
        fi
        # look first in the lib64 directories
        if test "x$checklib64" = "xyes" ; then
            i64=`echo $i | sed -e 's|lib$|lib64|' -e 's|lib/|lib64/|'`
            i="$i64 $i"
        fi
        # look only in the lib64 directories
        if test "x$checkonlylib64" = "xyes" ; then
            i64=`echo $i | sed -e 's|lib$|lib64|' -e 's|lib/|lib64/|'`
            i="$i64"
        fi
        # look only in the hpux64 directories
        if test "x$checkhpux64" = "xyes" ; then
            i64=`echo $i | sed 's|\(lib\)|\1/hpux64|'`
            i="$i64"
        fi
	logmsg "Checking in directories $i for $libs"
        for l in $i ; do
            l=`echo $l | sed 's,^//,/,'`
            if test ! -d $l ; then
		continue
            fi
            for j in ${libs} ; do
		logmsg "Checking for library $j in directory $i"
	        # if we found the file (it's readable by user), we set the
	        # logical variables and are on our way, otherwise we continue
                liblist=`echo $l/$j`    # expands wildcard in $l/$j
                for n in ${liblist} ; do
		    logmsg "Checking $n"
                    if test -f $n ; then
			logmsg "Found file $n"
                        if test "x$checklib64" = "xyes" ; then
                            check_lib64 $n
                            if test $is_lib64 -eq 1 ; then
                                found_dir=$l
                                found_lib=$j
                                break 4
                            fi
                        else
                            found_dir=$l
                            found_lib=$j
                            # skip cygwin libraries when in pure Win32 mode
                            if test "x$platform" = "xwin32"; then
                                case $found_dir in
                                    /lib|/lib/*|/usr/*) found_dir="no" ;;
                                    *) break 4;;
                                esac
                            else
                              break 4
                            fi
                        fi
		    else
			logmsg "$j not found in $j"
                    fi
                done
            done
        done
    done

    echo $found_dir
    unset libs
    unset libdirs

    if test "x$found_dir" = "xno" || test "x$found_lib" = "xno" ; then
	found_dir=""
	found_lib=""
	logmsg "library not found"
    else
	flib=""
        maclib=""
	for i in $lib ; do
	    for ext in .a .lib "" ; do     # lib without extension for MacOS X
		if test "x$found_lib" = "x$i$ext" ; then
		    flib=$i$ext
                    if test "x$ext" = "x" ; then
                        maclib="yes"
                    fi
                    break 2
		fi
	    done
	done

	if (test "x$found_lib" = "x$flib" && test "x$shared" = "xno") || \
           test "x$maclib" = "xyes" ; then
	    found_lib=${found_dir}/${found_lib}
	    found_dir=""
	else
	    found_lib=`echo $found_lib | sed 's|^lib\(.*\)\..*|-l\1|'`
	    found_dir=-L${found_dir}
            # Avoid inclusion of /usr/lib, which is always included anyway
            if test "x$found_dir" = "x-L/usr/lib"   || \
               test "x$found_dir" = "x-L/usr/lib32" || \
               test "x$found_dir" = "x-L/usr/lib64" ; then
		found_dir=""
	    fi
	fi

        # Correct path for win32
        if test "x$platform" = "xwin32"; then
            if test ! "x$found_lib" = "x" ; then
                found_lib=`cygpath -m $found_lib`
            fi
            if test ! "x$found_dir" = "x" ; then
               found_dir=`cygpath -m $found_dir`
            fi
        fi
    fi
    unset shared
    unset slibs
    unset lib
    unset flib
    unset maclib
    unset libdirl
}

#_____________________________________________________________________
check_header()  {
    # This function will try to locate a header [$1] in the specific
    # directory [$2] or in a default path [$*].
    # The result of the search is stored in found_hdr and found_dir,
    # which should be immediately copied, since the variables value will
    # be overwritten at next invocation of this function.

    # Assert that we got enough arguments
    if test $# -lt 3 ; then
	echo "check_header: Too few arguments"
	return 1
    fi

    # Save arguments in logical names
    hdrs=$1     ; shift
    hdrdir=$1   ; shift
    hdrdirs="$*"

    # Write a message
    checking_msg $hdrs

    # Check if we got a specific argument as to where the library
    # is to be found
    if test ! "x$hdrdir" = "x" ; then
        hdrdirs=$hdrdir
    fi
    found_hdr=no
    found_dir=no

    # Loop over the list of possible directories, and see if we can
    # find any of the library files as determind above.

    for i in $hdrdirs; do
	logmsg "Checking in directory $i"
        for j in ${hdrs} ; do
	    logmsg "Checking for $j in directory $i"
	    # if we found the file (it's readable by user), we set the
	    # logical variables and are on our way, otherwise we continue
            if test -r $i/$j ; then
		logmsg "$i/$j is read-able"
                found_dir=$i
                found_hdr=$j
                # skip cygwin headers when in pure Win32 mode
                if test "x$platform" = "xwin32"; then
                    case $found_dir in
                        /usr/*) found_dir="no" ;;
                        *) break 2;;
                    esac
                else
                    break 2
                fi
            fi
        done
    done

    echo $found_dir

    if test "x$found_hdr" = "xno" || test "x$found_dir" = "xno" ; then
	found_hdr=""
	found_dir=""
    fi

    # Avoid inclusion of /usr/include, which is always included anyway
    #if test "x$found_dir" = "x/usr/include" ; then
	# found_dir="include"
    #fi

    # Correct path for win32
    if test "x$platform" = "xwin32"; then
        if test ! "x$found_hdr" = "x" ; then
           found_hdr=`cygpath -m $found_hdr`
        fi
        if test ! "x$found_dir" = "x" ; then
           found_dir=`cygpath -m $found_dir`
        fi
    fi

    unset hdrs
    unset hdrdirs
    unset hdrdir
}

#_____________________________________________________________________
check_symbol() {
    # This function will try to locate a symbol [$1] in a specific
    # library [$2] and in a given directory [$3].
    # The result of the check is stored in found_symbol, 1 if true,
    # 0 otherwise, which should be immediately copied, since the variable
    # will be overwritten at next invocation of this function.

    # Assert that we got enough arguments
    if test $# -ne 3 ; then
	echo "check_symbol: not 3 arguments"
        found_symbol=0
	return 1
    fi

    # Save arguments in logical names
    symbol=$1     ; shift
    symbollib=$1  ; shift
    symboldir=$1

    if test "x$symbollib" = "x" ; then
        found_symbol=0
        return 1
    fi

    symbollib=`echo $symbollib | sed -e 's/^-l/lib/'`

    if test ! "x$symboldir" = "x" ; then
        symboldir=`echo $symboldir | sed -e 's/^-L//'`
    fi

    # Check if we got a specific argument as to where the library
    # is to be found
    symbolfile=$symbollib
    exts=".so .lib"
    if test ! "x$shared" = "xno" ; then
	exts="$exts .a"
    else
	exts=".a $exts"
    fi

    usrlib="/usr/lib"
    # look first in the lib32 directories
    if test "x$checklib32" = "xyes" ; then
        usrlib="/usr/lib32 $usrlib"
    fi
    # look first in the lib64 directories
    if test "x$checklib64" = "xyes" ; then
        usrlib="/usr/lib64 $usrlib"
    fi
    # look only in the lib64 directories
    if test "x$checkonlylib64" = "xyes" ; then
        usrlib="/usr/lib64"
    fi
    # look only in the hpux64 directories
    if test "x$checkhpux64" = "xyes" ; then
        usrlib="/usr/lib/hpux64"
    fi

    for d in "$symboldir" $usrlib ; do
	logmsg "Checking in $d"
	if test ! -r $d/$symbollib ; then
	    logmsg "$d/$symbollib not readable"
	    for i in $exts ; do
		logmsg "Checking extension $i with $d/$symbollib"
		if test -r $d/$symbollib$i ; then
		    logmsg "$d/$symbollib$i readable"
		    symbolfile=$d/$symbollib$i
		    break 2
                fi
             done
        else
            logmsg "$d/$symbollib readable"
            symbolfile=$d/$symbollib
            break
        fi
    done

    if test "x$symbolfile" = "x" || test ! -r $symbolfile ; then
       found_symbol=0
       logmsg "Symbol not found"
       return 1
    fi

    checking_msg "$symbol in $symbolfile"
    nm $symbolfile 2>&1 | grep $symbol > /dev/null 2>&1
    if test $? -eq 0 ; then
        found_symbol=1
        logmsg "Symbol found"
    else
	nm $symbolfile 2>&1 | grep "no symbols" > /dev/null 2>&1
	if test $? -eq 0 ; then
	    logmsg "$symbolfile is stripped, trying a link"
	    # stripped library - only safe test is to link against the
	    # library!  However, we do not know what compiler to use
	    # so we can not do the test.  Assume the symbol is in
	    cat <<EOF > conftest.mk
include config/Makefile.${arch}
conftest:conftest.c $symbolfile
	\$(CC) \$(CFLAGS) \$(LDFLAGS) $symbolfile \$< -o \$@

conftest.c:
	echo "extern int $symbol (); " > \$@
	echo "int main() { $symbol (); return 0; }" >> \$@
EOF
	    $gnumake -f conftest.mk >> $logfile 2>&1
	    if test $? -eq 0 ; then
		found_symbol=1
		logmsg "Link OK"
	    else
		found_symbol=0
		logmsg "Failed code was"
		cat conftest.mk >> $logfile
	    fi
	    rm -rf conftest.c conftest.mk conftest
	else
	    found_symbol=0
	fi
    fi
    if test $found_symbol -eq 1 ; then
	result "ok"
    else
	result "no"
    fi
}

#_____________________________________________________________________
check_explicit()
{
    feat=$1 ; shift
    expl=$1 ; shift
    emsg=$1 ; shift

    if test "x$fail_on_missing" = "xno" ; then return 0 ; fi
    if test "x$expl" = "xno" ; then return 0 ; fi
    if test ! "x$feat" = "xyes" ; then
	result $emsg
	exit 1
    fi
}

#_____________________________________________________________________
guess_architecture () {
    # Try to guess the architecture of the host system
    # Note, that there's no attempt at guessing the compiler.
    # The `native' compiler is used in all cases.
    # If a user really want a specifific compiler, s/he better use the
    # first argument to do so.
    arch=`uname -s | tr '[A-Z]' '[a-z]'`
    chip=`uname -m | tr '[A-Z]' '[a-z]'`
    rele=`uname -r`
    logmsg "arch=$arch"
    logmsg "chip=$chip"
    logmsg "rele=$rele"
    case "$arch:$chip:$rele" in
        aix*)                  arch=aix5            ;;
        osf1*:alpha:*)         arch=alphacxx6       ;;
        freebsd*:*:6*)         arch=freebsd5        ;;
        freebsd*:*:5*)         arch=freebsd5        ;;
        freebsd*:*:4*)         arch=freebsd4        ;;
        freebsd*:*:*)          arch=freebsd         ;;
        hp-ux:ia64:*)          arch=hpuxia64acc     ;;
        hp-ux:*:*)             arch=hpuxacc         ;;
        hurd*:*:*)             arch=hurddeb         ;;
        linux:ia64:*)          arch=linuxia64gcc    ;;
        linux:x86_64:*)        arch=linuxx8664gcc   ;;
        linux:alpha:*)         arch=linuxalphagcc   ;;
        linux:arm*:*)          arch=linuxarm        ;;
        linux:ppc64*:*)        arch=linuxppc64gcc   ;;
        linux:ppc*:*)          arch=linuxppcgcc     ;;
        linux:i*86:*)          arch=linux           ;;
        openbsd*:*:*)          arch=openbsd         ;;
        lynx:*:*)              arch=lynxos          ;;
        darwin:power*:*)       arch=macosx          ;;
        darwin:*86*:*)         arch=macosx          ;;
        irix*:sgi*:*)          arch=sgicc           ;;
        sunos:sun*:6*)         arch=solarisCC5      ;;
        sunos:sun*:5*)         arch=solarisCC5      ;;
        sunos:sun*:4*)         arch=solaris         ;;
        sunos:i86pc:5*)        arch=solarisCC5      ;;
        cygwin_*:*86:*)        arch=win32           ;;
        cygwin_*:pentium:*)    arch=win32           ;;
        cygwin_*:ia64)         arch=win32           ;;
        *)
            echo "Attempts at guessing your architecture failed."
            echo "Please specify the architecture as the first argument."
            echo "Do '$0 --help' for a list of avaliable architectures."
            exit 1
            ;;
    esac
    if [ "$arch" = "macosx" ]; then
       if [ `sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2` = 5 ]; then
          if `sysctl machdep.cpu.extfeatures | grep "64" > /dev/null  2>&1` ; then
             arch=macosx64
          fi
       fi
    fi
    logmsg "$arch"
}

###################################################################
#
### echo %%% Some skeleton and config files
#
ARCHS=config/ARCHS
MAKEIN=config/Makefile.in
MAKEOUT=config/Makefile.config
CONFIGUREIN=config/RConfigure.in
CONFIGUREOUT=include/RConfigure.h
RCONFIN=config/root-config.in
RCONFOUT=bin/root-config
ROOTRCIN=config/rootrc.in
ROOTRCOUT=etc/system.rootrc
ROOTAUTHRCIN=config/rootauthrc.in
ROOTAUTHRCOUT=etc/system.rootauthrc
ROOTDAEMONRCIN=config/rootdaemonrc.in
ROOTDAEMONRCOUT=etc/system.rootdaemonrc
MEMPROBEIN=config/memprobe.in
MEMPROBEOUT=bin/memprobe
MIMEUNIXIN=config/mimes.unix.in
MIMEWIN32IN=config/mimes.win32.in
MIMEOUT=etc/root.mimes
ROOTDIN=config/rootd.in
ROOTDOUT=etc/daemons/rootd.rc.d
ROOTDXINETDIN=config/rootd.xinetd.in
ROOTDXINETDOUT=etc/daemons/rootd.xinetd
PROOFDIN=config/proofd.in
PROOFDOUT=etc/daemons/proofd.rc.d
PROOFDXINETDIN=config/proofd.xinetd.in
PROOFDXINETDOUT=etc/daemons/proofd.xinetd
XROOTDIN=config/xrootd.in
XROOTDOUT=etc/daemons/xrootd.rc.d
OLBDIN=config/olbd.in
OLBDOUT=etc/daemons/olbd.rc.d
ROOTHELPIN=config/root-help.el.in
ROOTHELPOUT=build/misc/root-help.el
HTMLIN=config/html.C.in
HTMLOUT=macros/html.C
THISROOTSHIN=config/thisroot.sh
THISROOTSHOUT=bin/thisroot.sh
THISROOTCSHIN=config/thisroot.csh
THISROOTCSHOUT=bin/thisroot.csh

######################################################################
#
### echo %%% Testing the echo features
#
if `(echo "testing\c"; echo 1,2,3) | grep c > /dev/null` ; then
  if `(echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn > /dev/null`; then
    ac_n= ac_c='
' ac_t='	'
  else
    ac_n=-n ac_c= ac_t=
  fi
else
  ac_n= ac_c='\c' ac_t=
fi

######################################################################
#
### echo %%% Help function
#
confhelp() {
vers=`cat build/version_number`
cat <<EOF
\`configure' configures ROOT $vers to adapt to many kind of systems.

Usage:     $0 [architecture] [flag=value]

The architecture to build for will be guessed from the output of 'uname'.
If, however, that fails, or you don't want the 'native' compiler on the
host platform, you can specify the architecture to use by passing as the
FIRST argument one of the architecures given at the end of this message.

   FLAG            DESCRIPTION               DEFAULT
   --aclocaldir    Autoconf macro install dir(<prefix>/share/aclocal)
   --bindir        Binary installation dir   (<prefix>/bin)
   --build         Build configuration [debug, exceptions, ...],
                   overrides the ROOTBUILD shell variable
   --cintincdir    CINT interpeted headers   (<libdir>/cint)
   --datadir       Data installation dir     (<prefix>/share/root)
   --docdir        Documentation             (<prefix>/share/doc/root)
   --elispdir      Where to put Emacs Lisp   (<prefix>/share/emacs/site-lisp)
   --etcdir        Config installation dir   (/etc/root)
   --fontdir       Font installation dir     (<datadir>/fonts)
   --iconpath      Icon installation dir     (<datadir>/icons)
   --incdir        Header installation dir   (<prefix>/include/root)
   --libdir        Library installation dir  (<prefix>/lib/root)
   --macrodir      Macro installation dir    (<datadir>/macros)
   --mandir        Manpages installation dir (<prefix>/share/man/man1)
   --no-create     Do not create output files, dry run
   --prefix        Installation prefix       (/usr/local)
   --srcdir        Sources installation dir  (<datadir>/src)
   --testdir       Tests                     (<docdir>/test)
   --tutdir        Tutorials                 (<docdir>/tutorial)

If any of the flags --cintincdir, --datadir, --docdir, --etcdir, --iconpath
--incdir, --libdir, --macrodir, --mandir, or --prefix is given,
ROOT will be compiled with static directory names, and you should not set
the ROOTSYS environment variable.

enable/disable options, prefix with either --enable- or --disable-
  afs                AFS support, requires AFS libs and objects
  alien              AliEn support, requires libgapiUI from ALICE
  asimage            Image processing support, requires libAfterImage
  astiff             Include tiff support in image processing
  builtin-afterimage Built included libAfterImage, or use system libAfterImage
  builtin-freetype   Built included libfreetype, or use system libfreetype
  builtin-pcre       Built included libpcre, or use system libpcre
  builtin-zlib       Built included libz, or use system libz
  castor             CASTOR support, requires libshift from CASTOR >= 1.5.2
  cern               CERNLIB usage, build h2root and g2root
  chirp              Chirp support (Condor remote I/O), requires libchirp_client
  cint7              Build the *experimental* new Cint library
  cintex             Build the libCintex Reflex interface library
  clarens            Clarens RPC support, optionally used by PROOF
  dcache             dCache support, requires libdcap from DESY
  exceptions         Turn on compiler exception handling capability
  explicitlink       Explicitly link with all dependent libraries
  fftw3              Fast Fourier Transform support, requires libfftw3
  gdml               GDML writer and reader
  gfal               GFAL support, requires libgfal
  g4root             GEANT4 navigator based on TGeo, requires GEANT4 installed
  globus             Globus authentication support, requires Globus toolkit
  krb5               Kerberos5 support, requires Kerberos libs
  ldap               LDAP support, requires (Open)LDAP libs
  mathcore           Build the new libMathCore math library
  mathmore           Build the new libMathMore extended math library, requires GSL (vers. >= 1.8)
  minuit2            Build the new libMinuit2 minimizer library
  monalisa           Monalisa monitoring support, requires libapmoncpp
  mysql              MySQL support, requires libmysqlclient
  odbc               ODBC support, requires libiodbc or libodbc
  opengl             OpenGL support, requires libGL and libGLU
  oracle             Oracle support, requires libocci
  pch                Precompiled headers (if supported by the compiler)
  peac               PEAC, PROOF Enabled Analysis Center, requires Clarens
  pgsql              PostgreSQL support, requires libpq
  pythia6            Pythia6 EG support, requires libPythia6
  python             Python ROOT bindings, requires python >= 2.2
  qt                 Qt graphics backend, requires libqt >= 3
  qtgsi              GSI's Qt integration, requires libqt >= 3
  reflex             Build the libReflex dictionary library
  rfio               RFIO support, requires libshift from CASTOR >= 1.5.2
  roofit             Build the libRooFit advanced fitting package
  rpath              Set run-time library load path on executables
  ruby               Ruby ROOT bindings, requires ruby >= 1.8
  sapdb              MaxDB/SapDB support, requires libsqlod and libsqlrte
  shadowpw           Shadow password support
  shared             Use shared 3rd party libraries if possible
  soversion          Set version number in sonames (recommended)
  srp                SRP support, requires SRP source tree
  ssl                SSL encryption support, requires openssl
  table              Build libTable contrib library
  thread             Thread support
  unuran             UNURAN - package for generating non-uniform random numbers
  winrtdebug         Link against the Windows debug runtime library
  xml                XML parser interface
  xrootd             Build xrootd file server and its client (if supported)

with options, prefix with --with-, enables corresponding support

  afs                AFS support, location of AFS distribution
  alien-incdir       AliEn support, location of gapiUI.h
  alien-libdir       AliEn support, location of libapiUI
  castor-incdir      CASTOR support, location of stager_api.h
  castor-libdir      CASTOR support, location of libshift
  cern-libdir        HBOOK converter, location of CERNLIB libraries
  chirp-incdir       Chirp support, location of chirp_client.h
  chirp-libdir       Chirp support, location of libchirp_client
  cppunit            Cppunit testing, directory of the cppunit installation
  dcap-incdir        dCache support, location of dcap.h
  dcap-libdir        dCache support, location of libdcap
  dicttype           dictionary type: "cint" (default), "reflex", or "gccxml"
  fftw3-incdir       FFTW3 support, location of fftw3.h
  fftw3-libdir       FFTW3 support, location of libfftw3 (libfftw3-3 for windows)
  gfal-incdir        GFAL support, location of gfal_api.h
  gfal-libdir        GFAL support, location of libgfal
  g4-incdir          GEANT4 support, location of GEANT4 header files
  g4-libdir          GEANT4 support, location of GEANT4 libraries
  clhep-incdir       CLHEP support, location of CLHEP header files
  gsl-incdir         GSL support, location of gsl/gsl_version.h
  gsl-libdir         GSL support, location of libgsl
  gccxml             Gccxml support, directory of the gccxml installation
  globus             Globus support, path to what should be GLOBUS_LOCATION
  globus-incdir      Globus support, location of globus header files
  globus-libdir      Globus support, location of globus libraries
  krb5               Kerberos5 support, location of Kerberos distribution
  krb5-incdir        Kerberos5 support, location of krb5.h
  krb5-libdir        Kerberos5 support, location of libkrb5
  ldap-incdir        LDAP support, location of ldap.h
  ldap-libdir        LDAP support, location of libldap
  monalisa-incdir    Monalisa support, location of ApMon.h, monalisawsclient.h
  monalisa-libdir    Monalisa support, location of libapmoncpp, libmonalisawsclient
  mysql-incdir       MySQL support, location of mysql.h
  mysql-libdir       MySQL support, location of libmysqlclient
  odbc-incdir        ODBC support, location of sqlext.h
  odbc-libdir        ODBC support, location of libiodbc or libodbc
  opengl-incdir      OpenGL support, location of GL/gl.h
  opengl-libdir      OpenGL support, location of libGL
  oracle-incdir      Oracle support, location of occi.h
  oracle-libdir      Oracle support, location of libocci
  pgsql-incdir       PostgreSQL support, location of libpq-fe.h
  pgsql-libdir       PostgreSQL support, location of libpq
  pythia6-libdir     PYHTIA6 support, location of libPythia6
  python-incdir      Python support, location of Python.h
  python-libdir      Python support, location of libpython
  qt-incdir          Qt support, location of qt.h
  qt-libdir          Qt support, location of libqt-mt or libqt
  ruby-incdir        Ruby support, location of ruby.h
  ruby-libdir        Ruby support, location of libruby
  sapdb-incdir       SapDB support, location of sql.h
  sapdb-libdir       SapDB support, location of libsqlod
  rfio-incdir        RFIO support, location of rfio_api.h
  rfio-libdir        RFIO support, location of librfio or libshift
  srp                Secure Remote Passwd support, location of SRP distribution
  srp-incdir         SRP support, location header of t_server.h
  srp-libdir         SRP support, location header of libsrp.a
  ssl-incdir         OpenSSL support, location of openssl headers
  ssl-libdir         OpenSSL support, location of libssl
  sys-iconpath       Extra icon path
  thread-libdir      Thread support, path to libpthread
  xml-incdir         XML support, location of libxml/tree.h
  xml-libdir         XML support, location of libxml2
  x11-libdir         X11 support, path to libX11
  xpm-libdir         XPM support, path to libXpm
  xrootd             XROOTD support, path to alternative XROOTD distribution

Supported Architectures:

EOF
   cat config/ARCHS | sed -e 's/^/   /'
cat <<EOF

Help output is rather long, so you may want to pipe it through a pager, like
for example

  $0 --help | more

Report bugs to <rootdev@root.cern.ch>
EOF
}

######################################################################
#
### echo %%% See if we got the architecture
#
if test $# -lt 1 ; then
   guess_architecture
else
   case $1 in
      -h|--help) confhelp ; exit 0 ;;
      -*) # in case the first argument wasn't an architecure but an option
          guess_architecture
          ;;
       *) arch=$1
	  logmsg "Architecture set to $arch by user"
          shift
          ;;
   esac
fi

# check that we got a valid architecture
if test "$arch" = "linuxegcs" ; then
    arch="linux"
fi
if test "$arch" = "win32gdk" ; then
    arch="win32"
fi

if `awk '{ print $1 }' $ARCHS | grep "^$arch$" > /dev/null  2>&1` ; then
   echo "Configuring for $arch"
else
   echo "Invalid architecture. Try $0 --help"
   exit 1
fi

platform=`grep "^PLATFORM *=" config/Makefile.$arch | awk '{ print $3 }'`

case $arch in
sgicc)
   logmsg "Will check 32bit libraries"
   checklib32="yes" ;;
linuxppc64*|sgicc64)
   logmsg "Will ONLY check 64bit libraries"
   checkonlylib64="yes" ;;
linuxx8664*)
   logmsg "Will check 64bit libraries"
   checklib64="yes" ;;
hpuxia64acc)
   logmsg "Will check HP/UX 64bit libraries"
   checkhpux64="yes" ;;
esac

# check for (g)make
case $platform in
win32|linux|macosx) gnumake="make"  ;;
*)                  gnumake="gmake" ;;
esac

# check for which
case $platform in
macosx) cwhich="type -path" ;;
*)      cwhich="which"      ;;
esac

# check for Fink on MacOS X
# and for sanity of source e.g. pcre-*.tar.gz must exist
# which might not be the case if source was unpacked with StuffIt
if test "x$platform" = "xmacosx" ; then
   if test ! -f pcre/src/pcre-*.tar.gz ; then
      echo "Source tree does not contain expected files, please unpack"
      echo "using tar and not StuffIt"
      exit 1
   fi
   logmsg "Checking Fink directory"
   finkdir=`$cwhich fink 2>&1 | sed -ne "s/\/bin\/fink//p"`
   logmsg "$finkdir"
fi

######################################################################
#
### echo %%% Some clean up
#
trapcmd="rm -f Makefile.tmp RConfigure.tmp root-config.tmp rootrc.tmp \
         rootauthrc.tmp rootdaemonrc.tmp memprobe.tmp rootd.tmp \
         proofd.tmp rootd.xinetd.tmp proofd.xinetd.tmp conftest.mk \
         conftest.c conftest xrootd.tmp olbd.tmp"
trap "$trapcmd; exit 1" 1 2 3 15
trap "$trapcmd" 0

######################################################################
#
### echo %%% Command line arguments
#
if test $# -gt 0 ; then
   while test ! "x$1" = "x" ; do
      case "$1" in
      -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
      *) optarg= ;;
      esac

      case $1 in
      --help|-h) confhelp ;   exit 0 ;;
      ################################################################
      #
      # With options to specifiy third part software
      #
      --no-create)             noact="yes"           ;;
      --nohowto)               nohowto="yes"         ;;
      --fail-on-missing)       fail_on_missing="yes" ;;
      --with-afs=*)            afsdir=$optarg        ; enable_afs="yes"     ;;
      --with-alien-incdir=*)   alienincdir=$optarg   ; enable_alien="yes"   ;;
      --with-alien-libdir=*)   alienlibdir=$optarg   ; enable_alien="yes"   ;;
      --with-afterimage-incdir=*) afterimageincdir=$optarg; enable_builtin_afterimage=no ;;
      --with-afterimage-libdir=*) afterimagelibdir=$optarg; enable_builtin_afterimage=no ;;
      --with-castor-incdir=*)  castorincdir=$optarg  ; enable_castor="yes"  ;;
      --with-castor-libdir=*)  castorlibdir=$optarg  ; enable_castor="yes"  ;;
      --with-cern-libdir=*)    cernlibdir=$optarg    ; enable_cern="yes"    ;;
      --with-chirp-incdir=*)   chirpincdir=$optarg   ; enable_chirp="yes"   ;;
      --with-chirp-libdir=*)   chirplibdir=$optarg   ; enable_chirp="yes"   ;;
      --with-cppunit=*)        cppunit=$optarg       ;;
      --with-dcap-incdir=*)    dcapincdir=$optarg    ; enable_dcache="yes"  ;;
      --with-dcap-libdir=*)    dcaplibdir=$optarg    ; enable_dcache="yes"  ;;
      --with-dicttype=*)       dicttype=$optarg      ;;
      --with-fftw3-incdir=*)   fftw3incdir=$optarg   ; enable_fftw3="yes"   ;;
      --with-fftw3-libdir=*)   fftw3libdir=$optarg   ; enable_fftw3="yes"   ;;
      --with-gfal-incdir=*)    gfalincdir=$optarg    ; enable_gfal="yes"    ;;
      --with-gfal-libdir=*)    gfallibdir=$optarg    ; enable_gfal="yes"    ;;
      --with-g4-incdir=*)      g4incdir=$optarg      ; enable_g4root="yes"  ;;
      --with-g4-libdir=*)      g4libdir=$optarg      ; enable_g4root="yes"  ;;
      --with-clhep-incdir=*)   clhepincdir=$optarg   ;;
      --with-gsl-incdir=*)     gslincdir=$optarg     ; enable_gsl="yes"     ;;
      --with-gsl-libdir=*)     gsllibdir=$optarg     ; enable_gsl="yes"     ;;
      --with-globus=*)         globusdir=$optarg     ; enable_globus="yes"  ;;
      --with-globus-incdir=*)  globusincdir=$optarg  ; enable_globus="yes"    ;;
      --with-globus-libdir=*)  globuslibdir=$optarg  ; enable_globus="yes"    ;;
      --with-gccxml=*)         gccxml=$optarg        ;;
      --with-krb5=*)           krb5dir=$optarg       ; enable_krb5="yes"    ;;
      --with-krb5-incdir=*)    krb5incdir=$optarg    ; enable_krb5="yes"    ;;
      --with-krb5-libdir=*)    krb5libdir=$optarg    ; enable_krb5="yes"    ;;
      --with-ldap-incdir=*)    ldapincdir=$optarg    ; enable_ldap="yes"    ;;
      --with-ldap-libdir=*)    ldaplibdir=$optarg    ; enable_ldap="yes"    ;;
      --with-mysql-incdir=*)   mysqlincdir=$optarg   ; enable_mysql="yes"   ;;
      --with-mysql-libdir=*)   mysqllibdir=$optarg   ; enable_mysql="yes"   ;;
      --with-monalisa-incdir=*)monalisaincdir=$optarg; enable_monalisa="yes";;
      --with-monalisa-libdir=*)monalisalibdir=$optarg; enable_monalisa="yes";;
      --with-odbc-incdir=*)    odbcincdir=$optarg    ; enable_odbc="yes"    ;;
      --with-odbc-libdir=*)    odbclibdir=$optarg    ; enable_odbc="yes"    ;;
      --with-opengl-incdir=*)  openglincdir=$optarg  ; enable_opengl="yes"  ;;
      --with-opengl-libdir=*)  opengllibdir=$optarg  ; enable_opengl="yes"  ;;
      --with-oracle-incdir=*)  oracleincdir=$optarg  ; enable_oracle="yes"  ;;
      --with-oracle-libdir=*)  oraclelibdir=$optarg  ; enable_oracle="yes"  ;;
      --with-pgsql-incdir=*)   pgsqlincdir=$optarg   ; enable_pgsql="yes"   ;;
      --with-pgsql-libdir=*)   pgsqllibdir=$optarg   ; enable_pgsql="yes"   ;;
      --with-pythia6-libdir=*) pythia6libdir=$optarg ; enable_pythia6="yes" ;;
      --with-pythia6-uscore=*) pythia6uscore=$optarg ; enable_pythia6="yes" ;;
      --with-python-incdir=*)  pythonincdir=$optarg  ; enable_python="yes"  ;;
      --with-python-libdir=*)  pythonlibdir=$optarg  ; enable_python="yes"  ;;
      --with-qt-incdir=*)      qtincdir=$optarg      ; enable_qt="yes"; enable_qtgsi="yes" ;;
      --with-qt-libdir=*)      qtlibdir=$optarg      ; enable_qt="yes"; enable_qtgsi="yes" ;;
      --with-ruby-incdir=*)    rubyincdir=$optarg    ; enable_ruby="yes"    ;;
      --with-ruby-libdir=*)    rubylibdir=$optarg    ; enable_ruby="yes"    ;;
      --with-sapdb-incdir=*)   sapdbincdir=$optarg   ; enable_sapdb="yes"   ;;
      --with-sapdb-libdir=*)   sapdblibdir=$optarg   ; enable_sapdb="yes"   ;;
      --with-rfio-incdir=*)    shiftincdir=$optarg   ; enable_rfio="yes"    ;;
      --with-rfio-libdir=*)    shiftlibdir=$optarg   ; enable_rfio="yes"    ;;
      # leave --with-shift-* for backward compatibility, use --with-rfio-* instead
      --with-shift-incdir=*)   shiftincdir=$optarg   ; enable_rfio="yes"    ;;
      --with-shift-libdir=*)   shiftlibdir=$optarg   ; enable_rfio="yes"    ;;
      --with-srp=*)            srpdir=$optarg        ; enable_srp="yes"     ;;
      --with-srp-incdir=*)     srpincdir=$optarg     ; enable_srp="yes"     ;;
      --with-srp-libdir=*)     srplibdir=$optarg     ; enable_srp="yes"     ;;
      --with-ssl-incdir=*)     sslincdir=$optarg     ; enable_ssl="yes"     ;;
      --with-ssl-libdir=*)     ssllibdir=$optarg     ; enable_ssl="yes"     ;;
      --with-sys-iconpath=*)   extraiconpath=$optarg ;;
      --with-thread-libdir=*)  threadlibdir=$optarg  ; enable_thread="yes"  ;;
      --with-xml-incdir=*)     xmlincdir=$optarg     ; enable_xml="yes"     ;;
      --with-xml-libdir=*)     xmllibdir=$optarg     ; enable_xml="yes"     ;;
      --with-x11-libdir=*)     x11libdir=$optarg     ;;
      --with-xpm-libdir=*)     xpmlibdir=$optarg     ;;
      --with-xrootd=*)         xrootddir=$optarg     ; enable_xrootd="yes"  ;;
      ################################################################
      #
      # Enable/disable to turn on/off third party software linkage and
      # features
      #
      --enable-*)
	f=`echo $1 | sed -e 's/--//' -e 's/-/_/g'`
	eval ${f}=yes
	eval ${f}_explicit=yes
	for c in $options ; do
	   if test "x$c" = "x$f" ; then
	      f=""
	   fi
	done
	if test "x$f" != "x" ; then
	   echo "Invalid option '$1'. Try $0 --help" ; exit 1 ;
	fi
	;;
      --disable-*)
	f=`echo $1 | sed -e 's/--disable/enable/' -e 's/-/_/g'`
	eval ${f}=no
	eval ${f}_explicit=no
	for c in $options ; do
	   if test "x$c" = "x$f" ; then
	      f=""
	   fi
	done
	if test "x$f" != "x" ; then
	   echo "Invalid option '$1'. Try $0 --help" ; exit 1 ;
	fi
	;;
      ################################################################
      #
      # Build steering option
      #
      --build=*)      rootbuild="ROOTBUILD      := $optarg"  ;;
      ################################################################
      #
      # Install path options
      #
      --aclocaldir=*) haveconfig=-DR__HAVE_CONFIG ; aclocaldir=$optarg  ;;
      --bindir=*)     haveconfig=-DR__HAVE_CONFIG ; bindir=$optarg      ;;
      --cintincdir=*) haveconfig=-DR__HAVE_CONFIG ; cintincdir=$optarg  ;;
      --datadir=*)    haveconfig=-DR__HAVE_CONFIG ; datadir=$optarg     ;;
      --docdir=*)     haveconfig=-DR__HAVE_CONFIG ; docdir=$optarg      ;;
      --elispdir=*)   haveconfig=-DR__HAVE_CONFIG ; elispdir=$optarg    ;;
      --etcdir=*)     haveconfig=-DR__HAVE_CONFIG ; etcdir=$optarg      ;;
      --fontdir=*)    haveconfig=-DR__HAVE_CONFIG ; fontdir=$optarg     ;;
      --iconpath=*)   haveconfig=-DR__HAVE_CONFIG ; iconpath=$optarg    ;;
      --incdir=*)     haveconfig=-DR__HAVE_CONFIG ; incdir=$optarg      ;;
      --libdir=*)     haveconfig=-DR__HAVE_CONFIG ; libdir=$optarg      ;;
      --macrodir=*)   haveconfig=-DR__HAVE_CONFIG ; macrodir=$optarg    ;;
      --mandir=*)     haveconfig=-DR__HAVE_CONFIG ; mandir=$optarg      ;;
      --pkglist*)     show_pkglist="yes"          ; noact="yes"         ;;
      --prefix*)      haveconfig=-DR__HAVE_CONFIG ; prefix=$optarg      ;;
      --srcdir=*)     haveconfig=-DR__HAVE_CONFIG ; srcdir=$optarg      ;;
      --testdir=*)    haveconfig=-DR__HAVE_CONFIG ; testdir=$optarg     ;;
      --tutdir=*)     haveconfig=-DR__HAVE_CONFIG ; tutdir=$optarg      ;;
      *)  echo "Invalid option '$1'. Try $0 --help" ; exit 1 ;;
      esac
      shift
   done
fi

######################################################################
#
### echo %%% Copy skeletons to temporary files
#
if test "x$noact" = "xno"; then
    cp -f $MAKEIN Makefile.tmp
    cp -f $CONFIGUREIN RConfigure.tmp
    cp -f $RCONFIN root-config.tmp
    cp -f $ROOTRCIN rootrc.tmp
    cp -f $ROOTAUTHRCIN rootauthrc.tmp
    cp -f $ROOTDAEMONRCIN rootdaemonrc.tmp
    cp -f $MEMPROBEIN memprobe.tmp
    cp -f $ROOTDIN rootd.tmp
    cp -f $ROOTDXINETDIN rootd.xinetd.tmp
    cp -f $PROOFDIN proofd.tmp
    cp -f $PROOFDXINETDIN proofd.xinetd.tmp
    cp -f $XROOTDIN xrootd.tmp
    cp -f $OLBDIN olbd.tmp
fi

######################################################################
#
### echo %%% Should sonames contain version numbers
#
if test "x$enable_soversion" = "xyes"; then
    logmsg "Enabling version numbers in so names"
    major=`sed 's|\(.*\)\..*/.*|\1|' < build/version_number`
    minor=`sed 's|.*\.\(.*\)/.*|\1|' < build/version_number`
    revis=`sed 's|.*\..*/\([0-9]*\).*|\1|' < build/version_number`

    mkliboption="-v $major $minor $revis "
    unset major
    unset minor
    unset revis
fi

######################################################################
#
### echo %%% On Windoze always set enable_shared to no; need .lib
#
if test "x$platform" = "xwin32"; then
    enable_shared="no"
fi

######################################################################
#
### echo %%% X11 and XPM Library - Mandatory lib on Unix
#
# Mandatory test, must succeed
# Check for X11 and Xpm library (for X11 use always shared lib)
#
if test ! "$platform" = "win32"; then
    check_library "libX11" "yes" "$x11libdir" \
	/usr/lib /usr/X11R6/lib /usr/lib/X11 /usr/openwin/lib \
	/usr/local/lib /usr/local/lib/X11 /usr/local/X11R6/lib \
	/usr/X11/lib /usr/lib/X11R5
    x11libdir=$found_dir

    if test "x$found_lib" = "x" ; then
	result "`basename $0`: libX11 (package x11-devel) MUST be installed"
        exit 1
    fi

    check_header "X11/Xlib.h" "" \
	/usr/include /usr/X11R6/include /usr/include/X11 /usr/openwin/include \
	/usr/local/include /usr/local/include/X11 /usr/local/X11R6/include \
	/usr/X11/include /usr/include/X11R5

    if test "x$found_dir" = "x" ; then
	result "`basename $0`: X11 headers (package x11-devel) MUST be installed"
        exit 1
    fi

    check_library "libXpm" "$enable_shared" "$xpmlibdir" \
	$XPM $XPM/lib /usr/local/lib /usr/lib /usr/lib/X11 \
	/usr/local/lib/X11 /usr/X11R6/lib /usr/local/X11R6/lib \
	/usr/X11/lib
    xpmlib=$found_lib
    xpmlibdir=$found_dir

    if test "x$xpmlib" = "x" ; then
	result "`basename $0`: libXpm MUST be installed"
        exit 1
    fi
fi

######################################################################
#
### echo %%% Exceptions - compiler feature
#
if test "x$EXCEPTIONS" = "xno" ; then
    enable_exceptions=no
fi
e=`echo $rootbuild | sed 's/.*exceptions.*/1/'`
if test "x$e" = "x1" ; then
    enable_exceptions=no
fi

######################################################################
#
### echo %%% Windows Debug Runtime (-MDd)
#
if test "x$enable_winrtdebug" = "x" ; then
    e=`echo $rootbuild | sed 's/.*debug.*/1/'`
    if test "x$e" = "x1"; then
        enable_winrtdebug=yes
    else
        enable_winrtdebug=no
    fi
fi

######################################################################
#
### echo %%% Posix Thread Library
#
# Check for posix thread library
#
case $platform in
macosx|win32)
    if test "x$enable_thread" = "x"; then
        enable_thread="yes"
    fi
    ;;
linux|fbsd)
    if test "x$enable_thread" = "x" || test "x$enable_thread" = "xyes"; then
        enable_thread="yes"
        threadflag="-pthread"
        threadlib="-pthread"
        threadlibdir=
    fi
    ;;
esac
case $arch in
win32gcc)
    # if it was not set it was turned on in the above "linux" case
    if test "x$enable_thread" = "xyes"; then
        threadflag=
        threadlib=
    fi
    ;;
hpuxia64acc)
    if test "x$enable_thread" = "x"; then
        enable_thread="yes"
        threadflag="-mt"
        threadlib="-mt"
        threadlibdir=
    fi
    ;;
esac
if test "x$enable_thread" = "xyes" && \
   test ! "$platform" = "win32"    && \
   test "x$threadlib" = "x" ; then
    check_library "libpthread" "$enable_shared" "$threadlibdir" \
	$THREAD $THREAD/lib /usr/lib /usr/local/lib /usr/lib/X11 \
	/usr/local/lib/X11 /usr/X11R6/lib /usr/local/X11R6/lib \
	/usr/X11/lib /usr/shlib
    threadlib=$found_lib
    threadlibdir=$found_dir

    if test "x$threadlib" = "x" ; then
        enable_thread="no"
    fi
fi

haspthread="undef"
if test "x$enable_thread" = "xyes" && \
   test ! "$platform" = "win32"; then
   haspthread="define"
fi

######################################################################
#
### echo %%% libfreetype (builtin or system) - Mandatory lib
#
# Mandatory test, must succeed (see http://www.freetype.org/)
#
if test "x$enable_builtin_freetype" = "x" || \
   test "x$enable_builtin_freetype" = "xno" ; then

   checking_msg "freetype-config"
   if `$cwhich freetype-config > /dev/null 2>&1` ; then
      $cwhich freetype-config

      message "Checking for libfreetype version >= 9.3.0"
      ttf2_version=`freetype-config --version | \
          tr '.' ' ' | \
          awk 'BEGIN { FS = " "; } \
              { printf "%d", ($''1 * 1000 + $''2) * 1000 + $''3;}'`
      # First good version is 9.3.0
      if test $ttf2_version -lt 9003000 ; then
         result "no (`freetype-config --version`)"
         enable_builtin_freetype="yes"
      else
         result "ok"
         enable_builtin_freetype="no"
      fi
   else
      enable_builtin_freetype="yes"
      result "not found"
   fi
fi
message "Checking whether to build included libfreetype6"
result "$enable_builtin_freetype"

######################################################################
#
### echo %%% libpcre (builtin or system) - Mandatory lib
#
# Mandatory test, must succeed (see http://www.pcre.org/)
#
if test "x$enable_builtin_pcre" = "x" || \
   test "x$enable_builtin_pcre" = "xno" ; then

   checking_msg "pcre-config"
   if `$cwhich pcre-config > /dev/null 2>&1` ; then
      $cwhich pcre-config

      message "Checking for libpcre version >= 3.9"
      pcre_version=`pcre-config --version | \
          tr '.' ' ' | \
          awk 'BEGIN { FS = " "; } \
              { printf "%d", ($''1 * 1000 + $''2) * 1000 + $''3;}'`
      # First good version is 3.9
      if test $pcre_version -lt 3009000 ; then
         result "no (`pcre-config --version`)"
         enable_builtin_pcre="yes"
      else
         result "ok"
         enable_builtin_pcre="no"
      fi
   else
      enable_builtin_pcre="yes"
      echo "not found"
   fi
fi
message "Checking whether to build included libpcre"
result "$enable_builtin_pcre"

######################################################################
#
### echo %%% Use included ZLib or use systems
#
if test "x$enable_builtin_zlib" = "xno" ; then
    check_header "zlib.h" "/usr/include"  $ZLIB $ZLIB/include \
	/usr/local/include /usr/include/zlib /usr/local/include/zlib \
	/opt/zlib/include
    if test "x$found_dir" = "x" ; then
	enable_builtin_zlib=yes
    else
        zlibinc=$found_hdr
        zlibincdir=$found_dir
    fi

    check_library "libz" "$enable_shared" "" "/usr/lib" \
	$ZLIB $ZLIB/lib /usr/local/zlib/lib /usr/local/lib \
            /usr/lib/zlib /usr/local/lib/zlib /usr/zlib/lib /usr/lib \
            /usr/zlib /usr/local/zlilb /opt/zlib /opt/zlib/lib
    if test "x$found_lib" = "x" ; then
	zliblib=""
	zliblibdir=""
	enable_builtin_zlib="yes"
    else
	zliblib="$found_lib"
	zliblibdir="$found_dir"
    fi

    if test "x$zlibincdir" = "x" || test "x$zliblib" = "x"; then
        enable_builtin_zlib="yes"
    fi
fi
message "Checking whether to build included zlib"
result "$enable_builtin_zlib"

######################################################################
#
### echo %%% OpenGL Support - Third party libraries
#
# (see mesa3d.org)
#
if test ! "x$enable_opengl" = "xno" && test ! "$platform" = "win32" ; then
    # Check for OpenGL compatible include and library
    check_header "GL/gl.h" "$openglincdir" $OPENGL $OPENGL/include \
	/usr/include /usr/include/X11 /usr/X11/include \
	/usr/X11R6/include /usr/local/include/X11 \
	/usr/local/X11R6/include /usr/local/include \
	/usr/include/Mesa /usr/local/include/Mesa /usr/Mesa/include \
	/usr/local/Mesa/include /usr/Mesa /usr/local/Mesa /opt/Mesa \
	/opt/Mesa/include /opt/graphics/OpenGL/include
    openglinc=$found_hdr
    openglincdir=$found_dir

    opengllibdirs="$OPENGL $OPENGL/lib /usr/lib /usr/local/lib /usr/lib/X11 \
	/usr/X11R6/lib /usr/local/lib/X11 /usr/local/X11R6/lib \
        /usr/X11/lib /usr/lib/Mesa /usr/local/lib/Mesa /usr/Mesa/lib \
	/usr/local/Mesa/lib /usr/Mesa /usr/local/Mesa /opt/Mesa \
	/opt/Mesa/lib /opt/graphics/OpenGL/lib"

    keep=$opengllibdir
    check_library "libGL libMesaGL" "$enable_shared" \
	"$opengllibdir" $opengllibdirs
    opengllib=$found_lib
    opengllibdir=$found_dir

    check_library "libGLU libMesaGLU" "$enable_shared" \
	"$keep" $opengllibdirs
    openglulib=$found_lib
    openglulibdir=$found_dir

    if test "x$openglincdir" = "x" || \
       test "x$opengllib" = "x" || \
       test "x$openglulib" = "x" ; then
        enable_opengl="no"
    fi
fi
check_explicit "$enable_opengl" "$enable_opengl_explicit" \
     "Explicitly required OpenGL dependencies not fulfilled"

######################################################################
#
### echo %%% OpenGL support on Windoze
#
# On win32 we always have OpenGL available (is this true?)
#
if test "$platform" = "win32"; then
   enable_opengl="yes"
   openglincdir="include"
fi

######################################################################
#
### echo %%% MySQL Support - Third party libraries
#
# (See mysql.org)
#
# If the user has set the flags "--disable-mysql", we don't check for
# MySQL at all.
#
if test ! "x$enable_mysql" = "xno"; then
    # Check for MySQL include and library
    checking_msg "mysql_config"
    mysql_config=`$cwhich mysql_config 2> /dev/null`
    if test ! "x$mysql_config" = "x" && test -x "$mysql_config" && \
       test "x$mysqlincdir" = "x"    && test "x$mysqllibdir" = "x" && \
       test ! "x$platform" = "xwin32" ; then
       $cwhich mysql_config
       # we found mysql_config - now check the version number
       message "Checking for libmysqlclient version >= 3.23.*"
       mysql_version=`mysql_config --version | awk 'BEGIN { FS="." } { printf "%d", $1 * 1000 + $2 }'`
       if test $mysql_version -lt 3023 ; then
          result "no (`mysql_config --version`)"
          enable_mysql="no"
          mysqllibdir=""
       else
          result "ok"
          mysqllib=`mysql_config --libs | sed -e s/\'//g`
          mysqlincdir=`mysql_config --cflags | sed -e 's,^.*-I\([^ ]*\).*$,\1,' -e s/\'//g`
          mysqllibdir=""
       fi
    else
       result "not found"
       # fall back in case mysql_config is not found
       check_header "mysql.h" "$mysqlincdir" \
	   $MYSQL $MYSQL/include $MYSQL/include/mysql /usr/local/include \
	   /usr/local/include/mysql /usr/local/mysql /usr/local/mysql/include \
	   /opt/mysql /opt/mysql/include \
	   /usr/include /usr/include/mysql /usr/mysql /usr/mysql/include \
	   $finkdir/include/mysql
       mysqlinc=$found_hdr
       mysqlincdir=$found_dir

       mysqlclientlibs="libmysqlclient mysqlclient"
       if test "x$enable_thread" = "xyes"; then
           mysqlclientlibs="libmysqlclient_r $mysqlclientlibs"
       fi

       check_library "$mysqlclientlibs" "$enable_shared" "$mysqllibdir" \
	   $MYSQL $MYSQL/lib $MYSQL/lib/mysql /usr/local/lib \
	   /usr/local/lib/mysql /usr/local/mysql /usr/local/mysql/lib \
	   /opt/mysql /opt/mysql/lib \
	   /usr/lib /usr/lib/mysql /usr/mysql /usr/mysql/lib \
           $finkdir/lib/mysql
       mysqllib=$found_lib
       mysqllibdir=$found_dir

       # on linux, but maybe also other systems, explicitely add libz
       # (formally only needed when linking against the static libmysqlclient.a)
       if test ! "x$mysqllib" = "x" ; then
	   case $platform in
	       linux) mysqllib="$mysqllib -lz" ;;
	       win32) mysqllib="`echo $mysqllib | sed 's/mysqlclient/libmysql/'` $mysqllib" ;;
	   esac
       fi

       if test "x$mysqlincdir" = "x" || test "x$mysqllib" = "x"; then
           enable_mysql="no"
       fi
    fi
fi
check_explicit "$enable_mysql" "$enable_mysql_explicit" \
     "Explicitly required MySQL dependencies not fulfilled"

######################################################################
#
### echo %%% Oracle Support - Third party libraries
#
# (See oracle.com)
#
# If the user has set the flags "--disable-oracle", we don't check for
# Oracle at all.
#
if test ! "x$enable_oracle" = "xno"; then
    # Check for oracle include and library
    check_header "occi.h" "$oracleincdir" \
        $ORACLE $ORACLE/include $ORACLEINCDIR /usr/local/include \
        /usr/include /usr/include/oracle/*/client
    oracleinc=$found_hdr
    oracleincdir=$found_dir

    keeplibdir=$oraclelibdir
    check_library "libclntsh oci" "$enable_shared" "$oraclelibdir" \
       $ORACLE $ORACLE/lib $ORACLELIBDIR /usr/local/lib /usr/lib \
	/usr/lib/oracle/*/client/lib
    oraclelib=$found_lib
    oraclelibdir=$found_dir

    check_library "libocci oraocci10" "$enable_shared" "$keeplibdir" \
       $ORACLE $ORACLE/lib $ORACLELIBDIR /usr/local/lib /usr/lib
    oraclelib="$oraclelib $found_lib"

    # space in "x " is intentional
    if test "x$oracleincdir" = "x" || test "x$oraclelib" = "x "; then
        enable_oracle="no"
    fi
fi
check_explicit "$enable_oracle" "$enable_oracle_explicit" \
     "Explicitly required Oracle dependencies not fulfilled"

######################################################################
#
### echo %%% PostgreSQL Support - Third party libraries
#
# (See postgresql.org)
#
# If the user has set the flags "--disable-pgsql", we don't check for
# PostgreSQL at all.
#
if test ! "x$enable_pgsql" = "xno"; then
    # Check for PgSQL include and library
    check_header "libpq-fe.h" "$pgsqlincdir" $PGSQL $PGSQL/include \
	/usr/include /usr/local/include /usr/local/pgsql/include \
        /usr/include/pgsql /usr/include/postgresql \
	/usr/include/postgresql/8.0 /usr/pgsql/include \
        /usr/local/include/pgsql /usr/local/include/postgresql \
	/usr/include/postgresql/8.0 /usr/pgsql /usr/local/pgsql \
	/opt/pgsql /opt/pgsql/include
    pgsqlinc=$found_hdr
    pgsqlincdir=$found_dir

    check_library "libpq" "$enable_shared" "$pgsqllibdir" \
	$PGSQL $PGSQL/lib /usr/local/pgsql/lib /usr/local/lib \
	/usr/lib/pgsql /usr/local/lib/pgsql /usr/pgsql/lib /usr/lib \
	/usr/pgsql /usr/local/pgsql /opt/pgsql /opt/pgsql/lib
    pgsqllib=$found_lib
    pgsqllibdir=$found_dir

    if test "x$pgsqlincdir" = "x" || test "x$pgsqllib" = "x"; then
        enable_pgsql="no"
    fi
fi
check_explicit "$enable_pgsql" "$enable_pgsql_explicit" \
     "Explicitly required PostGreSQL dependencies not fulfilled"

######################################################################
#
### echo %%% SapDB/MaxDB Support - Third party libraries
#
# (See www.sapdb.org or http://www.mysql.com/products/maxdb)
#
# If the user has set the flags "--disable-sapdb", we don't check for
# SapDB at all.
#
if test ! "x$enable_sapdb" = "xno"; then
    # Check for SapDB include and library
    check_header "sql.h" "$sapdbincdir" $SAPDB $SAPDB/include \
	/opt/sapdb/interfaces/odbc/incl /usr/sapdb/interfaces/odbc/incl \
	/usr/sapdb/include /usr/local/sapdb/interfaces/odbc/incl \
	/usr/sapdb/web/incl /usr/include/sapdb /usr/include/maxdb \
	/usr/local/include/sapdb /usr/local/include/maxdb \
	/usr/local/sapdb/include /usr/local/sapdb/web/incl /usr/sapdb \
	/usr/local/sapdb /opt/sapdb /opt/sapdb/include /opt/sapdb/web/incl
    sapdbinc=$found_hdr
    sapdbincdir=$found_dir

    check_library "libsqlod" "$enable_shared" "$sapdblibdir" \
	$SAPDB $SAPDB/lib /opt/sapdb/interfaces/odbc/lib \
	/usr/sapdb/interfaces/odbc/lib /usr/sapdb/lib \
	/usr/local/sapdb/interfaces/odbc/lib /usr/local/sapdb/lib \
	/usr/lib/sapdb /usr/local/lib/sapdb /usr/sapdb/lib \
	/usr/local/sapdb/lib /usr/sapdb /usr/local/sapdb \
	/opt/sapdb /opt/sapdb/lib /usr/sapdb/web/lib \
	/usr/local/sapdb/web/lib /opt/sapdb/web/lib \
	/usr/lib /usr/local/lib
    sapdblib=$found_lib
    sapdblibdir=$found_dir

    if test "x$sapdbincdir" = "x" || test "x$sapdblib" = "x"; then
        enable_sapdb="no"
    fi
fi
check_explicit "$enable_sapdb" "$enable_sapdb_explicit" \
     "Explicitly required SapDB dependencies not fulfilled"

######################################################################
#
### echo %%% ODBC Support - Third party libraries
#
# (See unixodbc.org or iodbc.org)
#
# If the user has set the flags "--disable-odbc", we don't check for
# ODBC at all.
#
if test ! "x$enable_odbc" = "xno"; then
    # Check for odbc include and library
    if test "x$platform" = xwin32 ; then
        odbcinc="sqlext.h"
        odbcincdir=""
        odbclib="odbc32.lib"
        odbclibdir=""
        enable_odbc="yes"
    else
        check_header "sqlext.h" "$odbcincdir" \
            $ODBC $ODBC/include $ODBCINCDIR /usr/local/include \
            /usr/include $finkdir/include
        odbcinc=$found_hdr
        odbcincdir=$found_dir

        check_library "libiodbc libodbc odbc32" "$enable_shared" "$odbclibdir" \
            $ODBC $ODBC/lib $ODBCLIBDIR /usr/local/lib /usr/lib \
            $finkdir/lib
        odbclib=$found_lib
        odbclibdir=$found_dir

        if test "x$odbcincdir" = "x" || test "x$odbclib" = "x"; then
            enable_odbc="no"
        fi
    fi
fi
check_explicit "$enable_odbc" "$enable_odbc_explicit" \
     "Explicitly required ODBC dependencies not fulfilled"

######################################################################
#
### echo %%% Qt Support - Optional alternative graphics backend
#
# If the user has not set the flags "--enable-qt" or "--enable-qtgsi",
# we don't check for Qt at all.
#
if test ! "x$enable_qt" = "xno" || \
   test ! "x$enable_qtgsi" = "xno"; then
    # Check for Qt include and library
    check_header "qt.h" "$qtincdir" $QTDIR $QTDIR/include \
        /usr/local/include  /usr/local/qt/include /usr/include \
        /usr/include/qt /usr/include/qt3
    qtinc=$found_hdr
    qtincdir=$found_dir

    check_library "libqt-mt libqt qt-mt* qt-mt334 qt-mt335 qt-mt336 qt" "$enable_shared" \
        "$qtlibdir" $QTDIR $QTDIR/lib /usr/local/lib /usr/local/qt/lib \
        /usr/lib /usr/qt/lib
    qtlib=$found_lib
    qtlibdir=$found_dir

    message "Checking for moc or moc.exe"
    qtmocexe=`$cwhich moc`
    if test $? -ne 0 ; then
       for i in $QTDIR $QTDIR/bin /usr/local/bin /usr/local/qt/bin /usr/bin \
           /usr/qt3/bin /usr/share/qt3/bin ; do
	  logmsg "Checking for $qtmocexe in $i"
	  if test -x $i/moc ; then
	      qtmocexe=$i/moc
	      logmsg "$qtmocexe is executable"
	      break
	  elif test -x $i/moc.exe ; then
	      qtmocexe=$i/moc.exe
	      logmsg "$qtmocexe is executable"
	      break
	  fi
       done
    fi
    result "$qtmocexe"

    if test "x$qtincdir" = "x" || test "x$qtlib" = "x" || \
	test "x$qtmocexe" = "x"; then
        enable_qt="no"
        enable_qtgsi="no"
    else
	qtverneed="3.3.0"
	qttoonew="4.0.0"
        message "Checking whether $qtverneed <= Qt version < $qttoonew"
	logmsg "grep '# *define *QT_VERSION_STR *' $qtincdir/qglobal.h"
	qtverstr=`grep "# *define *QT_VERSION_STR *" $qtincdir/qglobal.h | \
          sed '-e s/[^"]*"//' -e 's/".*$//' 2>> $logfile`
	if test $? -eq 0 ; then
	    logmsg "Got Qt version $qtverstr"
	    qtgot=`echo $qtverstr | \
	      awk 'BEGIN {FS="."} {printf "%d", ((($1*2^8)+$2)*2^8)+$3; }'`;
	    qtneed=`echo $qtverneed | \
	      awk 'BEGIN {FS="."}{ printf "%d", (($1*2^8)+$2)*2^8+$3; }'`
	    qtnew=`echo $qttoonew | \
	      awk 'BEGIN {FS="."}{ printf "%d", (($1*2^8)+$2)*2^8+$3; }'`
	    logmsg "Got $qtgot, min $qtneed, max $qtnew"
	    if test $qtgot -lt $qtneed ; then
		logmsg "Please update to Qt $qtverneed"
		enable_qt="no"
		enable_qtgsi="no"
		result "no"
	    elif test $qtgot -ge $qtnew; then
		logmsg "Qt $qtverstr too new (>= $qttoonew)"
		enable_qt="no"
		enable_qtgsi="no"
		result "no"
	    else
		result "$qtverstr"
	    fi
	else
	    result "no"
	    enable_qt="no"
	    enable_qtgsi="no"
	fi
    fi
fi
check_explicit "$enable_qt" "$enable_qt_explicit" \
     "Explicitly required Qt dependencies not fulfilled"

######################################################################
#
### echo %%% RFIO Support - Third party libraries
#
# (See http://http://savannah.cern.ch/files/?group=castor)
#
# Check for rfio_api.h of CASTOR 2 and librfio or libshift
#
shiftold=""
if test ! "x$enable_rfio" = "xno" ; then
    # Check for RFIO include and library
    keepincdir=$shiftincdir
    check_header "rfio_api.h" "$shiftincdir" $RFIO $RFIO/include $RFIO/h \
	/cern/pro/include /cern/new/include /cern/old/include \
	/opt/shift/include /usr/local/shift/inlcude /usr/include/shift \
	/usr/local/include/shift /usr/include /usr/local/include
    shiftinc=$found_hdr
    shiftincdir=$found_dir

    if test ! "x$shiftincdir" = "x"; then
        message "Checking whether rfio_fchmod declared in $shiftinc"
	logmsg "grep rfio_fchmod $shiftincdir/$shiftinc"
        if `grep rfio_fchmod $shiftincdir/$shiftinc >> $logfile 2>&1` ; then
            result "yes"
        else
            shiftincdir=""
            shiftold="yes"
            result "no"
            result "### Found old version of libshift, please uprade to >=1.5.2"
        fi
    fi

    check_library "librfio libshift shiftmd shift" "$enable_shared" \
	"$shiftlibdir" \
	$RFIO $RFIO/lib /cern/pro/lib /cern/new/lib /cern/old/lib \
	/opt/shift/lib /usr/local/shift/lib /usr/lib/shift \
	/usr/local/lib/shift /usr/lib /usr/local/lib
    shiftlib=$found_lib
    shiftlibdir=$found_dir

    if test "x$shiftincdir" = "x" || test "x$shiftlib" = "x"; then
        enable_rfio="no"
    else
        case $platform in
           linux)      shiftlib="$shiftlib -lnsl"
		for i in "" -ladns ; do
		    echo "extern rfio_fchmod(); int main() { rfio_fchmod(); return 0; }" > conftest.c
		    logmsg "Checking if we can link against $shiflib"
		    logmsg "gcc conftest.c $shiftlibdir $shiftlib $i -o conftest"
		    gcc conftest.c $shiftlibdir $shiftlib $i -o conftest >> $logfile 2>&1
		    if test $? -eq 0 ; then
			shiftlib="$shiftlib $i" ;
			break ;
		    else
			logmsg "Failed program was:"
			cat conftest.c >> $logfile
		    fi
		done
		rm -f conftest.c conftest
		;;
           solaris)    shiftlib="$shiftlib -lposix4" ;;
           win32)      shiftincdir="$shiftincdir $shiftincdir/../win32"
                       shiftlib="$shiftlib WSock32.lib Ws2_32.lib" ;;
        esac
    fi
fi
check_explicit "$enable_rfio" "$enable_rfio_explicit" \
     "Explicitly required RFIO dependencies not fulfilled"

######################################################################
#
### echo %%% CASTOR Support - Third party libraries
#
# (See http://savannah.cern.ch/files/?group=castor)
#
# Check for rfio_api.h, stager_api.h for CASTOR 2 and libshift
#
castorold=""
if test ! "x$enable_castor" = "xno" ; then
    # Check for Castor include and library
    keepincdir=$castorincdir
    check_header "rfio_api.h" "$castorincdir" $CASTOR $CASTOR/include $CASTOR/h \
	/cern/pro/include /cern/new/include /cern/old/include \
	/opt/shift/include /usr/local/shift/inlcude /usr/include/shift \
	/usr/local/include/shift /usr/include /usr/local/include
    castorinc=$found_hdr
    castorincdir=$found_dir

    if test ! "x$castorincdir" = "x"; then
        message "Checking whether rfio_fchmod declared in $castorinc"
	logmsg "grep rfio_fchmod $castorincdir/$castorinc"
        if `grep rfio_fchmod $castorincdir/$castorinc >> $logfile 2>&1` ; then
            result "yes"
        else
            castorincdir=""
            castorold="yes"
            result "no"
            result "### Found old version of libshift, please uprade to >=1.5.2"
        fi
    fi

    check_header "stager_api.h" "$keepincdir" $CASTOR $CASTOR/include $CASTOR/h \
	/cern/pro/include /cern/new/include /cern/old/include \
	/opt/shift/include /usr/local/shift/inlcude /usr/include/shift \
	/usr/local/include/shift /usr/include /usr/local/include
    stagerinc=$found_hdr

    if test ! "x$stagerinc" = "x"; then
        castorcflags=-DR__CASTOR2
        # check for Castor >= 2.1
        message "Checking for Castor version >= 2.1"
        castor_version=`grep "define BASEVERSION" $castorincdir/patchlevel.h | sed 's/^.*"\([0-9]\.[0-9]\.[0-9]\)"/\1/' | awk 'BEGIN { FS="." } { printf "%d", $1 * 1000 + $2 }'`
        if test $castor_version -lt 2001; then
            castorincdir=""
            result "no"
        else
            result "ok"
        fi
    fi

    check_library "libshift shiftmd shift" "$enable_shared" "$castorlibdir" \
	$CASTOR $CASTOR/lib /cern/pro/lib /cern/new/lib /cern/old/lib \
	/opt/shift/lib /usr/local/shift/lib /usr/lib/shift \
	/usr/local/lib/shift /usr/lib /usr/local/lib
    castorlib=$found_lib
    castorlibdir=$found_dir

    if test "x$castorincdir" = "x" || test "x$castorlib" = "x"; then
        enable_castor="no"
    else
        case $platform in
           linux)      castorlib="$castorlib -lnsl"
		for i in "" -ladns ; do
		    echo "extern rfio_fchmod(); int main() { rfio_fchmod(); return 0; }" > conftest.c
		    logmsg "Checking if we can link against $castorlib"
		    logmsg "gcc conftest.c $castorlibdir $castorlib $i -o conftest"
		    gcc conftest.c $castorlibdir $castorlib $i -o conftest >> $logfile 2>&1
		    if test $? -eq 0 ; then
			castorlib="$castorlib $i" ;
			break ;
		    else
			logmsg "Failed program was:"
			cat conftest.c >> $logfile
		    fi
		done
		rm -f conftest.c conftest
		;;
           solaris)    castorlib="$castorlib -lposix4" ;;
           win32)      castorincdir="$castorincdir $castorincdir/../win32"
                       castorlib="$castorlib WSock32.lib Ws2_32.lib" ;;
        esac
    fi
fi
check_explicit "$enable_castor" "$enable_castor_explicit" \
     "Explicitly required Castor dependencies not fulfilled"

######################################################################
#
### echo %%% GFAL Support - Third party libraries
#
# (See http://grid-deployment.web.cern.ch/grid-deployment/gis/GFAL/gfal.3.html)
#
# If the user has set the flags "--disable-gfal", we don't check for
# GFAL at all.
#
if test ! "x$enable_gfal" = "xno"; then
    # Check for GFAL include and library
    check_header "gfal_api.h" "$gfalincdir" $GFAL $GFAL/include \
	/opt/lcg/include /opt/gfal/include /usr/local/lcg/include \
	/usr/local/gfal/include
    gfalinc=$found_hdr
    gfalincdir=$found_dir

    check_library "libgfal" "$enable_shared" "$gfallibdir" \
	$GFAL $GFAL/lib /opt/lcg/lib /opt/gfal/lib /usr/local/lcg/lib \
	/usr/local/gfal/lib
    gfallib=$found_lib
    gfallibdir=$found_dir

    if test "x$gfalincdir" = "x" || test "x$gfallib" = "x"; then
        enable_gfal="no"
    fi
fi
check_explicit "$enable_gfal" "$enable_gfal_explicit" \
     "Explicitly required GFAL dependencies not fulfilled"

######################################################################
#
### echo %%% GEANT4 Support - Third party libraries
#
# (See http://geant4.web.cern.ch/geant4/)
#
# If the user has set the flags "--disable-g4root", we don't check for
# GEANT4 at all.
#
if test ! "x$enable_g4root" = "xno"; then
    # Check for GEANT4 include and library
    check_header "G4Navigator.hh" "$g4incdir" "$g4incdir" \
        $G4INCLUDE /opt/geant4/include /opt/g4/include \
        /usr/local/include /usr/include
    g4rootinc=$found_hdr
    g4incdir=$found_dir

    if test ! "$G4LIB/$G4SYSTEM" = "/"; then
        G4SYSLIBDIR=$G4LIB/$G4SYSTEM
    fi
    check_library "libG4navigation" "$enable_shared" "$g4libdir" \
	$G4SYSLIBDIR /opt/geant4/lib /opt/g4/lib /usr/local/lib /usr/lib

    g4rootlib=$found_lib
    g4libdir=$found_dir

    # Check for CLHEP include
    check_header "CLHEP/Vector/Rotation.h" "$clhepincdir" "$clhepincdir" \
        $CLHEP_INCLUDE_DIR
    clhepinc=$found_hdr
    clhepincdir=$found_dir

    if test "x$g4incdir" = "x" || test "x$g4rootlib" = "x" || test "x$clhepincdir" = "x"; then
        enable_g4root="no"
    fi
fi
check_explicit "$enable_g4root" "$enable_g4root_explicit" \
     "Explicitly required G4root dependencies not fulfilled"

######################################################################
#
### echo %%% Monalisa Support - Third party libraries
#
# (See http://monalisa.cacr.caltech.edu/monalisa__Download__ApMon.html)
#
# If the user has set the flags "--disable-monalisa", we don't check for
# Monalisa at all.
#
if test ! "x$enable_monalisa" = "xno"; then
    # Check for Monalisa include and library
    tmpincdir=$monalisaincdir
    check_header "ApMon.h" "$monalisaincdir" $MONALISA $MONALISA/include \
	/usr/local/include /opt/alien/api/include /opt/monalisa/include \
        /usr/include
    monalisainc=$found_hdr
    monalisaincdir=$found_dir

    tmplibdir=$monalisalibdir
    check_library "libapmoncpp" "$enable_shared" "$monalisalibdir" \
	$MONALISA $MONALISA/lib /usr/local/lib /opt/alien/api/lib \
        /opt/monalisa/lib /usr/lib
    monalisalib=$found_lib
    monalisalibdir=$found_dir

    check_header "monalisawsclient.h" "$tmpincdir" $MONALISA $MONALISA/include \
	/usr/local/include /opt/alien/include /opt/monalisa/include \
	/usr/include
    monalisawsinc=$found_hdr
    monalisawsincdir=$found_dir

    check_library "libmonalisawsclient" "$enable_shared" "$tmplibdir" \
	$MONALISA $MONALISA/lib /usr/local/lib /opt/alien/lib \
	/opt/monalisa/lib /usr/lib
    monalisawslib=$found_lib
    monalisawslibdir=$found_dir

    if test "x$monalisaincdir" = "x" || test "x$monalisalib" = "x"; then
        enable_monalisa="no"
    fi

    if test "x$monalisawsincdir" = "x" || test "x$monalisawslib" = "x"; then
        enable_monalisa="no"
    fi
fi
check_explicit "$enable_monalisa" "$enable_monalisa_explicit" \
     "Explicitly required MonaLisa dependencies not fulfilled"

######################################################################
#
### echo %%% FFTW3 Support - Third party libraries
#
# (See http://www.fftw.org)
#
# If the user has set the flags "--disable-fftw3", we don't check for
# FFTW3 at all.
#
if test ! "x$enable_fftw3" = "xno"; then
    # Check for FFTW3 include and library
    check_header "fftw3.h" "$fftw3incdir" $FFTW3 $FFTW3/include \
	$FFTW3/api /usr/local/include /usr/include /opt/fftw3/include \
        $finkdir/include
    fftw3inc=$found_hdr
    fftw3incdir=$found_dir

    check_library "libfftw3 libfftw3-3" "$enable_shared" "$fftw3libdir" \
	$FFTW3 $FFTW3/lib $FFTW3/.libs /usr/local/lib /usr/lib /opt/fftw3/lib \
        $finkdir/lib
    fftw3lib=$found_lib
    fftw3libdir=$found_dir

    if test "x$fftw3incdir" = "x" || test "x$fftw3lib" = "x"; then
        enable_fftw3="no"
    fi
fi
check_explicit "$enable_fftw3" "$enable_fftw3_explicit" \
     "Explicitly required FFT in the West dependencies not fulfilled"

######################################################################
#
### echo %%% CERNLIB Usage - Third party libraries
#
# (See http://www.cern.ch)
#
# Check for CERN libs (libpacklib and libkernlib)
#
if test ! "x$enable_cern" = "xno"; then
    cernlibdirs="$CERNLIB $CERNLIB/lib ${CERN}/${CERN_LEVEL}/lib  \
	/cern/pro/lib /cern/new/lib /cern/old/lib /opt/cern/pro/lib \
	/opt/cern/new/lib /opt/cern/old/lib /usr/local/cern/pro/lib \
	/usr/local/cern/new/lib /usr/local/cern/old/lib /usr/lib \
	/usr/lib/cern /usr/local/lib /usr/local/lib/cern"
    check_library "libpacklib_noshift libpacklib packmd packlib" \
	"$enable_shared" "${cernlibdir}" $cernlibdirs
    packlib=$found_lib
    packlibdir=$found_dir

    check_library "libkernlib_noshift libkernlib kernmd kernlib" \
	"$enable_shared" "${cernlibdir}" $cernlibdirs
    kernlib=$found_lib
    kernlibdir=$found_dir

    if test ! "x$packlib" = "x" && test "x$enable_rfio" = "xno" ; then
        # check if libpacklib contains rfio references, if yes make further check
        check_symbol rfio "$packlib" "$packlibdir"
        if test  $found_symbol -eq 1 ; then
            # check if libpacklib contains rfio code (case of < 2002 version)
            check_symbol rfio_connect "$packlib" "$packlibdir"
            if test  $found_symbol -eq 0 ; then
                result "### Need libshift with this version of $packlib"
                if test "x$shiftold" = "xyes"; then
                    result "### Found old version of libshift, please uprade to >=1.5.2"
                else
                    result "### Run configure with --enable-rfio or set --with-shift-libdir"
                fi
                packlib=""
            fi
        fi
    fi

    if test "x$packlib" = "x" || test "x$kernlib" = "x"; then
        enable_cern="no"
     else
        cernlib="$packlib $kernlib"
        cernlibdir="$packlibdir $kernlibdir"
    fi
fi
check_explicit "$enable_cern" "$enable_cern_explicit" \
     "Explicitly required CernLib dependencies not fulfilled"


######################################################################
#
### echo %%% Pythia6  Usage - Third party libraries
#
# (See http://root.cern.ch and Lund)
#
# Check for libPythia6
#

if test ! "x$enable_pythia6" = "xno" ; then
    if test "x$pythia6uscore" = "xDOUBLE" || \
       test "x$pythia6uscore" = "xSINGLE" || \
       test "x$pythia6uscore" = "xNO" ; then
	pythia6cppflags=-DPYTHIA6_${pythia6uscore}_UNDERSCORE
	pythia6lib=
	pythia6dir=
	result "Using custom pythia6 library with $pythia6uscore underscore"
    else
	check_library "libPythia6" "$enable_shared" "$pythia6libdir" \
	    $PYTHIA6 $PYTHIA6/lib /cern/pro/lib /opt/pythia /opt/pythia6 \
	    /usr/lib/pythia /usr/local/lib/pythia /usr/lib/pythia6 \
	    /usr/local/lib/pythia6 /usr/lib /usr/local/lib
	pythia6lib=$found_lib
	pythia6libdir=$found_dir

	if test "x$pythia6lib" = "x" ; then
	    enable_pythia6=no
	else
	    check_symbol pythia6_common_block_address__ \
		"$found_lib" "$found_dir"
	    if test $found_symbol -eq 1 ; then
		pythia6cppflags=-DPYTHIA6_DOUBLE_UNDERSCORE
	    else
		check_symbol pythia6_common_block_address_ \
		    "$found_lib" "$found_dir"
		if test $found_symbol -eq 1  ; then
		    pythia6cppflags=-DPYTHIA6_SINGLE_UNDERSCORE
		else
		    check_symbol pythia6_common_address \
			"$found_lib" "$found_dir"
		    if test $found_symbol -eq 1  ; then
			pythia6cppflags=-DPYTHIA6_NO_UNDERSCORE
		    else
			result " didn't find pythia6_common_block_address[_]* in $found_lib"
			enable_pythia6=no
		    fi
		fi
	    fi
	    if test "x$platform" = "xmacosx" ; then
		check_symbol intel_cpu_indicator "$found_lib" "$found_dir"
		if test $found_symbol -eq 1 ; then
		    pythia6lib="$pythia6lib -L`$cwhich ifort | sed -e 's|bin/ifort|lib|'` -lifcore -lirc -limf"
		fi
            fi
	fi
    fi
fi
check_explicit "$enable_pythia6" "$enable_pythia6_explicit" \
     "Explicitly required Pythia6 dependencies not fulfilled"


######################################################################
#
### echo %%% dCache Support - Third party libraries
#
# (See http://www.dcache.org)
#
# Check for libdcap
#
if test ! "x$enable_dcache" = "xno" ; then
    check_header "dcap.h" "$dcapincdir" $DCACHE $DCACHE/include \
        /opt/d-cache/dcap/include /products/dcache/include \
        /opt/dcache/include /usr/include /usr/local/include
    dcapincdir=$found_dir

    check_library "libdcap" "$enable_shared" "$dcaplibdir" $DCACHE $DCACHE/lib \
	/opt/d-cache/dcap/lib /products/dcache/lib /opt/dcache/lib \
        /usr/lib /usr/local/lib
    dcaplib=$found_lib
    dcaplibdir=$found_dir

    if test ! "x$dcaplib" = "x" ; then
        check_symbol dc_lseek64 "$dcaplib" "$dcaplibdir"
        if test  $found_symbol -eq 0 ; then
            result "### Need dc_lseek64 in libdcap, upgrade your d-cache client library"
            dcaplib=
            dcaplibdir=
            dcapincdir=
        fi
    fi

    if test "x$dcapincdir" = "x" || test "x$dcaplib" = "x"; then
        enable_dcache="no"
    fi
fi
check_explicit "$enable_dcache" "$enable_dcache_explicit" \
     "Explicitly required dCache dependencies not fulfilled"

######################################################################
#
### echo %%% Chirp Support - Third party libraries
#
# (See http://www.cs.wisc.edu/condor/chirp)
#
# Check for libchirp_client
#
if test ! "x$enable_chirp" = "xno" ; then
    check_header "chirp_client.h" "$chirpincdir" $CHIRP $CHIRP/include \
	/opt/chirp/include /usr/include /usr/local/include
    chirpincdir=$found_dir

    #At this time, libchirp_client.a should always be prefered over .so,
    #to avoid problems with linkage on grid execute machines.

    check_library "libchirp_client" "no" "$chirplibdir" $CHIRP $CHIRP/lib \
	/opt/chirp/lib /usr/lib /usr/local/lib
    chirplib=$found_lib
    chirplibdir=$found_dir

    if test "x$chirpincdir" = "x" || test "x$chirplib" = "x"; then
        enable_chirp="no"
    fi
fi
check_explicit "$enable_chirp" "$enable_chirp_explicit" \
     "Explicitly required Chirp dependencies not fulfilled"

######################################################################
#
### echo %%% AliEn Support - Third party libraries
#
# (See http://alien.cern.ch)
#
# Check for libgliteUI
#
if test ! "x$enable_alien" = "xno" ; then
    check_header "gapiUI.h" "$alienincdir" $ALIEN $ALIEN/include \
	/opt/alien/api/include /usr/local/alien/api/include /usr/include \
	/usr/local/include
    alienincdir=$found_dir

    check_library "libgapiUI" "$enable_shared" "$alienlibdir" \
	$ALIEN $ALIEN/lib /opt/alien/api/lib /usr/local/alien/api/lib /usr/lib \
        /usr/local/lib
    alienlib=$found_lib
    alienlibdir=$found_dir

    if test "x$alienincdir" = "x" || test "x$alienlib" = "x"; then
        enable_alien="no"
    fi
fi
check_explicit "$enable_alien" "$enable_alien_explicit" \
     "Explicitly required AliEn dependencies not fulfilled"

######################################################################
#
### echo %%% AfterImage Support - Third party libraries
#
# (See http://afterstep.sourceforge.net/afterimage/)
#
# Check for graphics libraries used by libAfterImage, like libjpeg, etc.
#
if test ! "x$enable_asimage" = "xno" ; then
    # Currently our libAfterImage is completely out of sync with the official
    # libAfterImage due to many new features, use always the builtin_afterimage
    if test "x$enable_builtin_afterimage" = "xno" ||
       test "x$enable_builtin_afterimage" = "x" ; then
       # Assume failure
       enable_builtin_afterimage="yes"
       checking_msg "afterimage-config"
       if `$cwhich afterimage-config > /dev/null 2>&1` ; then
          $cwhich afterimage-config
          # we found afterimage-config - now check the version number
          asimage_version=`afterimage-config --version | awk 'BEGIN { FS="." } { printf "%d", $1 * 1000 + $2 }'`
          #if test $asimage_version -gt 1003 ; then
          if test $asimage_version -gt 0 ; then
             result "WARNING: System libAfterImage is too new, using built-in"
          else
             enable_builtin_afterimage="no"
             asextralib=`afterimage-config --libs`
             asimageincdir=`afterimage-config --cflags | sed 's/-I//g'`
          fi
       else
          result "not found"
       fi
    fi
    # If we didn't find the system libAfterImage, or the user didn't ask
    # for a system library, then see if we have various headers needed.
    if test "x$enable_builtin_afterimage" = "xyes" ; then
       check_header "jpeglib.h" "" $ASIMAGE $ASIMAGE/include \
          /usr/local/include /usr/include /opt/include
       asjpegincdir=$found_dir
       check_header "png.h" "" $ASIMAGE $ASIMAGE/include \
          /usr/local/include /usr/include /usr/local/include/libpng \
          /opt/include
       aspngincdir=$found_dir
       if test ! "x$enable_astiff" = "xno" ; then
           check_header "tiffio.h" "" $ASIMAGE $ASIMAGE/include \
               /usr/local/include /usr/include /opt/include
           astiffincdir=$found_dir
       else
           astiffincdir="--with-tiff=no"
       fi
       check_header "gif_lib.h" "" $ASIMAGE $ASIMAGE/include \
          /usr/local/include /usr/include /opt/include
       asgifincdir=$found_dir

       asextralib=""
       asextralibdir=""
       found_libz=""
       found_dirz=""
       # libz must be before libpng, if libz is not found don't
       # add libpng which needs libz
       # note that failure to find system libungif is not fatal since
       # libAfterImage contains embedded libungif source if needed
       if test ! "x$enable_astiff" = "xno" ; then
           aslibs="libjpeg libtiff libungif libz libpng"
       else
           aslibs="libjpeg libungif libz libpng"
       fi
       for k in $aslibs ; do
           check_library $k "$enable_shared" "" \
             $ASIMAGE $ASIMAGE/lib /usr/local/lib /usr/lib /opt/lib
           if test "x$k" = "xlibz" ; then
               found_libz=$found_lib
               found_dirz=$found_dir
               continue;
           fi
           if test "x$k" = "xlibpng" && test "x$found_libz" = "x" ; then
               break;
           fi
           if test "x$k" = "xlibungif" && test "x$found_lib" = "x" ; then
               asgifincdir=""
           fi
           if test ! "x$found_lib" = "x" ; then
               asextralib="$asextralib $found_lib"
               asextralibdir="$asextralibdir $found_dir"
           fi
       done
       if test "x$asextralib" = "x" ; then
           asextralib=""
           asextralibdir=""
           asjpegincdir=""
           aspngincdir=""
           astiffincdir=""
           asgifincdir=""
       else
           asextralib="$asextralib $found_libz"
           asextralibdir="$asextralibdir $found_dirz"
       fi
   fi
   message "Checking whether to build included libAfterImage"
   result "$enable_builtin_afterimage"
fi
check_explicit "$enable_asimage" "$enable_asimage_explicit" \
     "Explicitly required AfterImage dependencies not fulfilled"

######################################################################
#
### echo %%% LDAP Support - Third party libraries
#
# (See openldap.org)
#
# If the user has set the flags "--disable-ldap", we don't check for
# LDAP at all.
#
if test ! "x$enable_ldap" = "xno"; then
    # Check for ldap include and library
    check_header "ldap.h" "$ldapincdir" $LDAP $LDAP/include \
	/usr/include /usr/local/include /usr/local/ldap/include \
        /usr/include/ldap /usr/include/openldap /usr/ldap/include \
        /usr/local/include/ldap /usr/local/include/openldap \
	/usr/ldap /usr/local/ldap /opt/ldap /opt/ldap/include
    ldapinc=$found_hdr
    ldapincdir=$found_dir

    ldaplib=""
    ldaplibdir=""

    for i in libldap liblber ; do
        check_library $i "$enable_shared" "" $ldaplibdir \
            $LDAP $LDAP/lib /usr/local/ldap/lib /usr/local/lib \
            /usr/lib/ldap /usr/local/lib/ldap /usr/ldap/lib /usr/lib \
            /usr/ldap /usr/local/ldap /opt/ldap /opt/ldap/lib
        if test "x$found_lib" = "x" ; then
            ldaplib=""
            ldaplibdir=""
            enable_ldap="no"
            break
        fi
        ldaplib="$ldaplib $found_lib"
        ldaplibdir="$ldaplibdir $found_dir"
    done

    if test "x$ldapincdir" = "x" || test "x$ldaplib" = "x"; then
        enable_ldap="no"
    fi
fi
check_explicit "$enable_ldap" "$enable_ldap_explicit" \
     "Explicitly required LDAP dependencies not fulfilled"

######################################################################
#
### echo %%% Python - Optional alternative interpreter
#
# (See http://www.python.org)
#
if test ! "x$enable_python" = "xno" ; then
    # Check for Python include and library
    pythonhdrdirs="\
        $PYTHONDIR/include \
        /Library/Frameworks/Python.framework/Versions/Current/include \
        /System/Library/Frameworks/Python.framework/Versions/Current/include \
        /usr/local/include /usr/include"
    if test "x$platform" = xwin32 ; then
	pythonhdrdirs="$pythonhdrdirs \
        /cygdrive/c/Python25/include /cygdrive/c/Python24/include \
        /cygdrive/c/Python23/include /cygdrive/c/Python22/include"
    fi
    check_header "python/Python.h python2.5/Python.h python2.4/Python.h \
                  python2.3/Python.h python2.2/Python.h Python.h" \
                  "$pythonincdir" $pythonhdrdirs
    pythoninc=$found_hdr
    if test ! "x$pythoninc" = "x"; then
       pythonincdir=`dirname $found_dir/$found_hdr`
    fi
    if test "x$platform" = "xwin32"; then
       if test ! "x$pythonincdir" = "x" ; then
          pythonincdir=`cygpath -m $pythonincdir`
       fi
    fi

    pythonlibdirs="\
        $PYTHONDIR/lib $PYTHONDIR/libs \
        /Library/Frameworks/Python.framework/Versions/Current \
        /System/Library/Frameworks/Python.framework/Versions/Current \
        /usr/local/lib /usr/lib \
        /usr/local/lib/python2.2/config /usr/lib/python2.2/config \
        /usr/local/lib/python2.4/config /usr/lib/python2.4/config"

    if test "x$platform" = xwin32 ; then
	pythonlibdirs="$pythonlibdirs \
        /cygdrive/c/Python25/libs /cygdrive/c/Python24/libs \
        /cygdrive/c/Python23/libs /cygdrive/c/Python22/libs"
    fi
    check_library "libpython libpython2.5 libpython2.4 libpython2.3 libpython2.2 \
                   python25 python24 python23 \
                   Python" \
        "$enable_shared" "$pythonlibdir" $pythonlibdirs
    pythonlib=$found_lib
    pythonlibdir=$found_dir

    if test "x$pythonincdir" = "x" || test "x$pythonlib" = "x"; then
        enable_python="no"
    else
        pythonlibflags=
        case $platform in
            win32) pythonlibflags="-nodefaultlib:`basename $pythonlib`" ;;
        esac
    fi
fi
check_explicit "$enable_python" "$enable_python_explicit" \
     "Explicitly required Python dependencies not fulfilled"

######################################################################
#
### echo %%% Ruby - Optional alternative interpreter
#
# (See http://www.ruby-lang.org)
#
if test ! "x$enable_ruby" = "xno" ; then
    # Check for Ruby include and library
    myruby=`$cwhich ruby 2> /dev/null`
    if test ! "x$myruby" = "x" && test -x "$myruby" ; then
       rubysysincdir=`ruby -rrbconfig -e 'puts Config::CONFIG["archdir"]'`
       rubysyslibdir=`ruby -rrbconfig -e 'puts Config::CONFIG["libdir"]'`
    fi
    rubysysincdir2=
    if test "x$platform" = "xmacosx" ; then
       rubysysincdir2=`echo $rubysysincdir | sed -e 's/powerpc/universal/'`
    fi
    check_header "ruby.h" "$rubyincdir" $RUBYDIR $RUBYDIR/include \
        $rubysysincdir $rubysysincdir2
    rubyinc=$found_hdr
    rubyincdir=$found_dir

    if test "x$arch" = "xwin32" || \
       test "x$enable_shared" = "xno" ; then
        check_library_options="libruby-static libruby1.8-static libruby1.9-static"
    else
        check_library_options="libruby libruby1.8 libruby18 libruby1.9 libruby19"
    fi
    check_library "$check_library_options" \
        "$enable_shared" "$rubylibdir" $RUBYDIR $RUBYDIR/lib \
        $rubysyslibdir
    rubylib=$found_lib
    rubylibdir=$found_dir

    if test "x$rubyincdir" = "x" || test "x$rubylib" = "x"; then
        enable_ruby="no"
    else
        # Ruby support requires the explicitlink option
        enable_explicitlink="yes"
    fi
fi
check_explicit "$enable_ruby" "$enable_ruby_explicit" \
     "Explicitly required Ruby dependencies not fulfilled"

######################################################################
#
### echo %%% xml - the XML parser interface
#
# (See http://www.xmlsoft.org)
#
# If the user has set the flags "--disable-xml", we don't check for
# XML at all.
#
if test ! "x$enable_xml" = "xno" ; then
    # Check for xml include and library
    checking_msg "xml2-config"
    xml2_config=`$cwhich xml2-config 2> /dev/null`
    if test ! "x$xml2_config" = "x" && test -x "$xml2_config" && \
       test ! "x$platform" = "xwin32" ; then
       $cwhich xml2-config
       # we found xml2-config - now check the version number
       message "Checking for libxml2 version >= 2.4.x"
       xml2_version=`xml2-config --version | awk 'BEGIN { FS="." } { printf "%d", $1 * 1000 + $2 }'`
       if test $xml2_version -lt 2004 ; then
          result "no (`xml2-config --version`)"
          enable_xml="no"
          xmllibdir=""
       else
          result "ok"
          xmllib=`xml2-config --libs`
          xmlincdir=`xml2-config --cflags | sed 's/-I//g'`
          xmllibdir=""
       fi
    else
       result "not found"
       # fall back in case xml2-config is not found
       keepincdir=$xmlincdir
       check_header "libxml/tree.h" "$xmlincdir" $XMLDIR $XMLDIR/include \
           /opt/libxml2/include /usr/local/include/libxml2 /usr/include/libxml2
       xmlincdir=$found_dir

       keeplibdir=$xmllibdir
       check_library "libxml2_a libxml2" "$enable_shared" "$xmllibdir" $XMLDIR \
           $XMLDIR/lib $XMLDIR/.libs /opt/libxml2/lib /usr/local/lib /usr/lib
       xmllib=$found_lib
       xmllibdir=$found_dir

       if test "x$platform" = "xwin32"; then
          check_header "iconv.h" "$keepincdir" $ICONVDIR $ICONVDIR/include \
              $XMLDIR $XMLDIR/include \
              /opt/libxml2/include /usr/local/include/libxml2 /usr/include/libxml2
          iconvincdir=$found_dir

          check_library "iconv_a" "$enable_shared" "$keeplibdir" $ICONVDIR \
              $ICONVDIR/lib $XMLDIR $XMLDIR/lib $XMLDIR/.libs \
              /opt/libxml2/lib /usr/local/lib /usr/lib
          iconvlib=$found_lib
          iconvlibdir=$found_dir
       else
          iconvincdir=$xmlincdir
          iconvlib="-liconv"
       fi

       if test "x$xmlincdir"   = "x" || test "x$xmllib"    = "x" ||
          test "x$iconvincdir" = "x" || test "x$iconvlib"  = "x" ; then
          xmlincdir=""
          enable_xml="no"
       else
          case $arch in
             win32gcc)  xmllib="$xmllib -liconv"              ;;
          esac
          case $platform in
             linux)     xmllib="$xmllib -lpthread"            ;;
             solaris)   xmllib="$xmllib -liconv"              ;;
             win32)     xmlincdir="$xmlincdir $iconvincdir"
                        xmllib="$xmllib $iconvlib Ws2_32.lib" ;;
          esac
       fi
    fi
fi
check_explicit "$enable_xml" "$enable_xml_explicit" \
     "Explicitly required Xml dependencies not fulfilled"

######################################################################
#
### echo %%% Check for xrootd support
#
message "Checking whether to build xrootd"
xrdcomm=""

# If we are required to use an external XROOTD distribution
# we just define the pointers
if test ! "x$xrootddir" = "x"; then

   # We do not need to build, just the paths for includes and libs
   xrdcomm="no, using xrootd at $xrootddir"

else

   # Xrootd and its client need thread support
   if test "x$enable_thread" = "xyes"; then
       # Ok, now check the architecture
       case $arch in
       # xrootd does not build on all platforms yet
       linux*)
           if test "x$enable_xrootd" = "x"; then
               enable_xrootd="yes"
           fi
           ;;
       macos*)
           if test "x$enable_xrootd" = "x"; then
               enable_xrootd="yes"
           fi
           ;;
       solaris*)
           if test "x$enable_xrootd" = "x"; then
               enable_xrootd="yes"
           fi
           ;;
       win32)
           if test "x$enable_xrootd" = "x"; then
               enable_xrootd="yes"
           fi
           ;;
       *)
           if test "x$enable_xrootd" = "xyes"; then
               enable_xrootd="yes"
               xrdcomm=", but not officially supported"
           else
               enable_xrootd="no"
           fi
           ;;
       esac
   else
      if test "x$enable_xrootd" = "xyes"; then
         enable_xrootd="no"
         xrdcomm=", needs thread support (rerun with --enable-thread)"
      else
         enable_xrootd="no"
      fi
   fi

   xrdcomm="$enable_xrootd$xrdcomm"
fi

result $xrdcomm

if test "x$enable_xrootd" = "xyes"; then
    buildxrd="yes"
    hasxrd=""
else
    buildxrd="no"
    hasxrd="#"
fi
check_explicit "$enable_xrootd" "$enable_xrootd_explicit" \
     "Explicitly required Xrootd dependencies not fulfilled"

######################################################################
#
### echo %%% Globus Support - Third party libraries
#
# (See www.globus.org)
#
# If the user has set the flags "--disable-globus", we don't check for
# Globus at all.
#
glbextracflags=""
glbpatchcflags=""
haveglobus=""
if test ! "x$enable_globus" = "xno"; then
   # Check if the GLOBUS_LOCATION variable is set
   checking_msg "for globusdir"
   if test "x$globusdir" = "x" ; then
      result "no"
      checking_msg "GLOBUS_LOCATION"
      if test ! "x$GLOBUS_LOCATION" = "x" ; then
         globusdir=$GLOBUS_LOCATION
         result "$GLOBUS_LOCATION"
      else
         result "no"
      fi
   else
      result "$globusdir"
   fi
fi

if test "x$enable_globus" = "xyes"; then

    pthr="pthr"
    #determine flavour tag of the building
    flavour=""
    if test "x$globusincdir" = "x" ; then
       globusincdir=$globusdir/include
    fi
    searchincdir="$globusincdir/gcc32 $globusincdir/gcc32dbg \
                  $globusincdir/gcc32pthr $globusincdir/gcc32dbgpthr"

    # Found the reference dir first
    check_header "openssl/x509.h" "" "$searchincdir"
    if test "x$found_hdr" = "x" ; then
       globusinc=""
       globusincdir=""
       enable_globus="no"
       break
    fi
    globusinc="$globusinc $found_hdr"
    globusincdir=$found_dir
    flavour=`basename $globusincdir`

    # The other headers now
    inclist="openssl/pem.h globus_gss_assist.h globus_common.h"
    for i in $inclist ; do
       check_header $i "" "$globusincdir"
       if test "x$found_hdr" = "x" ; then
          globusinc=""
          globusincdir=""
          enable_globus="no"
          break
       fi
       globusinc="$globusinc $found_hdr"
    done
fi

if test "x$enable_globus" = "xyes"; then

   # With more recent versions we need an additional header
   check_header globus_gsi_credential.h "" "$globusincdir"
   gsiversion="no"
   if test ! "x$found_hdr" = "x" ; then
       gsiversion="yes"
       globusinc="$globusinc $found_hdr"
       gsicredentialh=$found_dir/globus_gsi_credential.h
       echo "Checking for gsi version ... yes"
   else
       echo "Checking for gsi version ... no"
       check_header sslutils.h "" "$globusincdir"
       if test ! "x$found_hdr" = "x" ; then
          globusinc="$globusinc $found_hdr"
       else
         globusinc=""
         globusincdir=""
         enable_globus="no"
       fi
   fi
fi

if test "x$enable_globus" = "xyes"; then

   globuslib=""
   if test "x$globuslibdir" = "x" ; then
       globuslibdir=$globusdir/lib
   fi
   if test "x$globusdir" = "x" ; then
       globusdir=`dirname $globuslibdir`
       echo "Globus main path set to $globusdir"
   fi
   searchlibdir=$globuslibdir
   globuslibdir=""

   globuslibs="libglobus_gss_assist_$flavour libglobus_gssapi_gsi_$flavour
              libglobus_gsi_credential_$flavour libglobus_common_$flavour
              libglobus_gsi_callback_$flavour libglobus_proxy_ssl_$flavour
              libglobus_gsi_sysconfig_$flavour libglobus_openssl_error_$flavour
              libglobus_gssapi_gsi_$flavour libglobus_gsi_callback_$flavour
              libglobus_oldgaa_$flavour libglobus_gsi_cert_utils_$flavour
              libglobus_openssl_$flavour  libglobus_gsi_proxy_core_$flavour
              libglobus_callout_$flavour  libltdl_$flavour 
              libssl_$flavour libcrypto_$flavour"

   for i in $globuslibs ; do
      check_library $i "no" "$searchlibdir" /opt/globus /usr/lib \
      /usr/local/lib
      if test "x$found_lib" = "x" ; then
         globuslib=""
         globuslibdir=""
         enable_globus="no"
         break
      fi
      globuslib="$globuslib $found_lib"
      if test "x$globuslibdir" = "x" && test ! "x$found_dir" = "x" ; then
         globuslibdir="$found_dir"
      fi
   done
fi

if test "x$enable_globus" = "xyes"; then

   # Need to source this before init proxies
   sourcepath=""
   if test -s $globusdir/etc/globus-user-env.sh ; then
      sourcepath="$globusdir/etc"
   fi
   if test "x$sourcepath" = "x" ; then
      result "Checking for globus-user-env.sh ... no (cannot run as client)"
   else
      result "Checking for globus-user-env.sh ... $sourcepath"
   fi

   # Need this to init proxies
   initpath=""
   if test -s $globusdir/bin/grid-proxy-init ; then
      initpath="$globusdir/bin"
   fi
   if test "x$sourcepath" = "x" ; then
      result "Checking for grid-proxy-init ... no (cannot run as client)"
   else
      result "Checking for grid-proxy-init ... $initpath"
   fi

   if test "x$globusincdir" = "x" || test "x$globuslib" = "x"; then
      globuslib=""
      enable_globus="no"
   else
      haveglobus="globus"
   fi

fi

if test "x$enable_globus" = "xyes"; then

   glbextracflags="-DR__GLBS"
   if test "x$gsiversion" = "xyes" ; then
      glbextracflags="$glbextracflags -DR__GLBS22"
   fi

   # Everything seems ok: now check if there is the need for a patch
   patchneeded="no"

   tobepatched="globus_gsi_credential"
   package="globus_gsi_credential"
   version=""

   # No explicit version given: try to find version out from gpt files ...
   packdir="$globusdir/etc/globus_packages/$package"
   if test -d $packdir ; then
      for i in pkg_data_${flavour}_rtl.gpt pkg_data_${flavour}_dev.gpt ; do
         if test -r $packdir/$i ; then
            packfileinfo=$packdir/$i
            break
         fi
      done
      version=""
      checkminor=""
      if test ! "x$packfileinfo" = "x" ; then
         packfiletmp=`basename $packfileinfo`
         echo "Checking for $packfiletmp ... $packdir"
         versionstring=`grep Minor $packfileinfo`
         for i in $versionstring ; do
            # Check for Major: only versions 0.x may need the patch
            if test "x$checkminor" = "x" ; then
               if test "Major=\"0\"" = "$i" ; then
                  checkminor="yes"
               fi
            else
               if test "x$checkminor" = "xyes" ; then
                  for k in 5 7 8 9 ; do
                     if test "Minor=\"$k\"" = "$i" ; then
                        version="0.$k"
                        break 2
                     fi
                  done
               fi
            fi
         done
      fi
      if test "x$version" = "x" ; then
         patchneeded="no"
         result "Checking for need of globus patch ... no"
      else
         patchneeded="yes"
         result "Checking for need of globus patch ... yes, version $version"
         # Check consistency: get reference versions
         gsicredconstantsh=`echo $gsicredentialh | sed 's|credential.h|cred_constants.h|'`
         grepout=`grep "Revision:" $gsicredentialh`
         grepout=`echo "$grepout" | sed 's|Revision:||'`
         for i in $grepout ; do
           if test ! "x$i" = "x\$"; then
              gcver=$i
           fi
         done
         grepout=`grep "Revision:" $gsicredconstantsh`
         grepout=`echo "$grepout" | sed 's|Revision:||'`
         for i in $grepout ; do
           if test ! "x$i" = "x\$"; then
              gccver=$i
           fi
         done

         # Get info from map file
         vertmp=""
         mismatch="no"
         mapfile="globusauth/src/patches/$tobepatched/map"
         exec 10< $mapfile
         read v1 v2 v3 <&10
         while [ ! "x$v1" = "x" ] ; do
           if test "x$v1" = "x$version" ; then
              if test ! "x$gcver" = "x$v2" || test ! "x$gccver" = "x$v3"; then
                 mismatch="yes"
              fi
           fi
           if test "x$gcver" = "x$v2" && test "x$gccver" = "x$v3"; then
              vertmp=$v1
           fi
           read v1 v2 v3 <&10
         done
         # Final check
         message "Checking for patch version consistency"
         if test "x$mismatch" = "xyes" ; then
            if test ! "x$vertmp" = "x" ; then
               version=$vertmp
               result "no: guess value from map file: $version"
            else
               result "no: unable to guess value from map file: keep $version"
            fi
         else
            result "yes"
         fi
      fi

   else
      result "Checking for need of globus patch ... information directory not available"
   fi

   # Now find includes needed for patch, if the case
   if test "x$patchneeded" = "xyes" ; then

      # build patching flags
      glbpatchcflags="-DR__GLBCPATCH"

      for i in globus_gsi_system_config.h globus_gsi_cert_utils.h ; do
         dirtmp=`find $globusincdir -name $i -exec dirname {} \;`
         if test ! "x$dirtmp" = "x" ; then
            result "Checking for $i ... $dirtmp"
            add="yes"
            for k in $glbpatchcflags ; do
               if test "x$k" = "x-I$dirtmp" ; then
                  add="no"
               fi
            done
            if test "x$add" = "xyes" ; then
               glbpatchcflags="$glbpatchcflags -I$dirtmp"
            fi
         else
            result "Checking for $i ... no (globus patch not applied)"
            patchneeded="no"
            glbpatchcflags=""
            break
         fi
      done
   fi

   if test "x$patchneeded" = "xyes" ; then

      # Path with patched files and includes
      globuspatchdir="globusauth/src/patches/$tobepatched/$version"

      # copy patched file in the globusauth/src directory
      cp -rp $globuspatchdir/$tobepatched.c globusauth/src/$tobepatched.c

      glbpatchcflags="$glbpatchcflags -I$globuspatchdir/include"

      if test ! "x$glbpatchcflags" = "x" ; then
         result "Applying experimental patch to $tobepatched.c"
      fi
   fi
fi
check_explicit "$enable_globus" "$enable_globus_explicit" \
     "Explicitly required Globus dependencies not fulfilled"

######################################################################
#
### echo %%% SSL Support - Third party libraries
#
# (See www.openssl.org)
#
# For public and symmetric key encryption. If missing, the local rsa
# simple implementation is used to protect password exchange.
# If configured with support for Globus/GSI authentication,
# use the SSL libraries coming with the globus tool kit to avoid
# conflicts.
#
if test "x$enable_ssl" = "xyes" ; then
     #
     # libssl
     #
     libssl="libssl"
     tmpssllibdir=""
     check_library "$libssl" "$enable_shared" "$ssllibdir" \
         $SSL $SSL/lib /usr/lib /usr/local/lib /opt/lib $finkdir/lib
     if test "x$found_lib" != "x" ; then
         ssllib="$found_lib"
         if test ! "x$found_lib" = "x-lssl" ; then
            tmpssllibdir="$ssllibdir"
            ssllibdir=""
            if test ! "x$tmpssllibdir" = "x" ; then
               tmpssllibdir=`dirname $found_lib`
            fi
            if test ! "x$ssl_shared" = "xno" ; then
               ssl_shared=no
            fi
         else
            ssllibdir="$found_dir"
            tmpssllibdir=`echo $ssllibdir | cut -c3-`
         fi

         #
         # libcrypto, in the same dir
         #
         libcrypto="libcrypto"
         check_library "$libcrypto" "$enable_shared" "$ssllibdir" \
                      /usr/lib /opt/lib /usr/local/lib $finkdir/lib
         if test "x$found_lib" != "x" ; then
             ssllib="$ssllib $found_lib"
             ssllibdir="$found_dir"
         else
             ssllib=""
             ssllibdir=""
             enable_ssl="no"
         fi
     else
         ssllib=""
         ssllibdir=""
         enable_ssl="no"
     fi
fi

if test "x$enable_ssl" = "xyes" ; then
    incssl="bio.h blowfish.h err.h pem.h rand.h rsa.h"
    ssl_incdir=""
    for i in $incssl ; do
        check_header "openssl/$i" "$sslincdir" $SSL $SSL/include \
           /usr/include /usr/local/include /opt/include $finkdir/include
        if test "x$found_hdr" = "x" ; then
            ssl_incdir=""
            enable_ssl="no"
            break
        fi
        if test "x$ssl_incdir" = "x" ; then
            ssl_incdir=$found_dir
        else
            for i in $ssl_incdir ; do
                if test "x$i" != "x$found_dir" ; then
		    ssl_incdir="$found_dir $ssl_incdir"
                fi
            done
        fi
    done
fi

if test "x$enable_ssl" = "xno" ; then
    ssllib=""
    ssllibdir=""
    sslincdir=""
    sslextracflags=""
else
    sslincdir=$ssl_incdir
    sslextracflags="-DR__SSL -DOPENSSL_NO_KRB5"
fi
check_explicit "$enable_ssl" "$enable_ssl_explicit" \
     "Explicitly required SSL dependencies not fulfilled"

######################################################################
#
### echo %%% SRP Support - Third party libraries
#
# (See http://srp.stanford.edu/srp)
# Note: You can not make do with the libsrp package. You need the full
# source for this add-on.
#
# Check for SRP (libsrp.a)
#
srpextracflags=""
havesrp=""
if test ! "x$enable_srp" = "xno" ; then
    if test "x$srpincdir" = "x" && test ! "x$srpdir" = "x" ; then
	srpincdir=$srpdir/include
        if test ! -d $srpincdir ; then
            srpincdir=$srpdir/libsrp
        fi
    fi

    check_header "t_server.h" "$srpincdir" $SRP/include $SRP/libsrp \
        /usr/srp/include /usr/include /usr/include/srp /usr/local/include \
        /usr/local/srp/include /usr/local/include/srp
    srpinc=$found_hdr
    srpincdir=$found_dir

    if test "x$srpincdir" = "x" ; then
	enable_srp="no"
    fi

    if test "x$srplibdir" = "x" && test ! "x$srpdir" = "x" ; then
	srplibdir=$srpdir/lib
        if test ! -d $srplibdir ; then
            srplibdir=$srpdir/libsrp
        fi
    fi

    srplibdirs="$SRP $SRP/lib $SRP/libsrp /usr/srp/lib /usr/local/srp/lib \
        /usr/lib/srp /usr/local/lib/srp /usr/lib /usr/local/lib"

    check_library "libsrp" "no" "$srplibdir" $srplibdirs
    srplib=$found_lib
    srplibdir=$found_dir

    check_symbol BN_new "$srplib" "$srplibdir"

    if test $found_symbol -eq 0 ; then
        check_library "libgmp" "$enable_shared" "" $srplibdir $srplibdirs
        gmplib=$found_lib
        gmplibdir=$found_dir
    else
        check_library "libcrypto" "$enable_shared" "" $srplibdir $srplibdirs
        cryptolib=$found_lib
        cryptolibdir=$found_dir
        if test -r $cryptolib && test "x$enable_shared" = "xno" ; then
           case $platform in
               linux) cryptolib="$cryptolib -ldl"
           esac
        fi
    fi

    if test "x$srplib" = "x" ; then
        enable_srp="no"
        srplibdir=""
    elif test "x$gmplib" = "x" && test "x$cryptolib" = "x" ; then
        enable_srp="no"
        gmplibdir=""
    else
        srplib="$srplib $gmplib"
        srplibdir="$srplibdir $gmplibdir"
    fi

    srputillib=""
    srputillibdir=""
    srplibdirs="$srpdir/base/libmisc $srpdir/base/lib \
        $SRP/base/libmisc $SRP/base/lib \
        /usr/local/srp/lib /usr/local/lib/srp /usr/srp/lib /usr/lib/srp \
        /usr/local/lib /usr/lib"
    for i in libmisc libshadow ; do
	check_library "$i" "no" "" $srplibdirs
	if test "x$found_lib" = "x" ; then
	    srputillib=""
	    srputillibdir=""
	    enable_srp="no"
	    break
        fi
	srputillib="$srputillib $found_lib"
	srputillibdir="$srputillibdir $found_dir"
    done


    if test ! "x$srpdir" = "x" ; then
	srputilincdir=$srpdir/base/lib
    fi
    check_header "pwauth.h" "$srputilincdir" $SRP $SRP/base/lib \
        /usr/local/srp/base/lib /usr/srp/base/lib
    srputilincdir=$found_dir

    if test "x$srputilincdir" = "x" ; then
	enable_srp="no"
    fi

    if test "x$enable_srp" = "xno" ; then
	srplib=""
	srputillib=""
    else
        srpextracflags="-DR__SRP"
        havesrp="srp"
    fi
fi
check_explicit "$enable_srp" "$enable_srp_explicit" \
     "Explicitly required SRP dependencies not fulfilled"

######################################################################
#
### echo %%% AFS Support - Third party libraries
#
# (See http://www.openafs.org)
#
# Check for AFS (libdes.a)
#
if test ! "x$enable_afs" = "xno" ; then
    if test ! "x$afsdir" = "x" ; then
	afsdir="$afsdir $afsdir/afs"
    fi

    afslibdirs="$AFS/lib /usr/afsws/lib /usr/local/afsws/lib \
        /opt/afs/lib /usr/local/afs/lib /usr/lib /usr/local/lib \
        /usr/athena/lib /usr/local/athena/lib"
    afslib=""
    afslibdir=""
    for i in afs/libkauth afs/libprot afs/libauth afs/libsys afs/libcmd \
             afs/libaudit afs/util libubik librx librxkad \
             liblwp libafsrpc libdes ; do
	check_library "$i" "no" "$afsdir" $afslibdirs
	if test "x$found_lib" = "x" ; then
	    afslib=""
	    afslibdir=""
	    enable_afs="no"
	    break
        fi
	afslib="$afslib $found_lib"
	afslibdir="$afslibdir $found_dir"
    done

    if test "x$afslib" = "x" ; then
        enable_afs="no"
    fi
fi
check_explicit "$enable_afs" "$enable_afs_explicit" \
     "Explicitly required Afs dependencies not fulfilled"

######################################################################
#
### echo %%% krb5 Support - Third party libraries
#
#
# Check for krb5 (libkrb5.a)
#
krb5extracflags=""
havekrb5=""
if test ! "x$enable_krb5" = "xno" ; then
    enable_krb5="yes"
    if test "x$krb5incdir" = "x" && test ! "x$krb5dir" = "x" ; then
	krb5incdir=$krb5dir/include
    fi
    check_header "krb5.h" "$krb5incdir" /usr/athena/include \
	    /usr/local/athena/include /usr/kerberos/include \
	    /usr/krb5/include /usr/local/kerberos/include \
	    /usr/include /usr/include/kerberosV /usr/local/include
    if test "x$found_dir" = "x" ; then
	enable_krb5=no
    else
        krb5inc=$found_hdr
        krb5incdir=$found_dir
    fi

    krb5libdirorg=""
    if test ! "x$krb5libdir" = "x" ; then
	krb5libdirorg=$krb5libdir
    fi
    if test "x$krb5libdir" = "x" && test ! "x$krb5dir" = "x" ; then
	krb5libdirorg=$krb5dir/lib
    fi
    krb5libdirs="/usr/athena/lib /usr/local/athena/lib /usr/kerberos/lib \
                 /usr/krb5/lib /usr/local/kerberos/lib /usr/lib /usr/local/lib"

    # check whether using MIT krb5
    krb5mit=no
    krb5lib=""
    krb5libdir=""
    check_library libk5crypto "$enable_shared" "$krb5libdirorg" $krb5libdirs
    if test ! "x$found_lib" = "x" ; then
	krb5mit=yes
        krb5lib=$found_lib
        krb5libdir=$found_dir
    fi
    message "Checking whether we're using MIT Kerberos"
    result "$krb5mit"

    check_library libkrb5 "$enable_shared" "$krb5libdirorg" $krb5libdirs
    if test "x$found_lib" = "x" ; then
	enable_krb5=no
    else
	# The order is important here
	krb5lib="$found_lib $krb5lib"
	krb5libdir="$found_dir $krb5libdir"
	if test "x$cryptolib" = "x" ; then
            check_library "libcrypto" "$enable_shared" "$krb5libdirorg" \
                          $krb5libdirs
            cryptolib=$found_lib
            cryptolibdir=$found_dir
            if test -r $cryptolib && test "x$enable_shared" = "xno" ; then
               case $platform in
                   linux) cryptolib="$cryptolib -ldl"
               esac
            fi
	    if test "x$cryptolib" = "x" ; then
                enable_krb5=no
	    fi
	fi
    fi

    krb5init=""
    krb5bindir=""
    if test ! "x$krb5dir" = "x" ; then
	krb5bindir=$krb5dir/bin
    fi
    for i in "$krb5bindir" /usr/athena/bin \
             /usr/local/athena/bin /usr/kerberos/bin \
             /usr/krb5/bin /usr/local/kerberos/bin \
             /usr/bin /usr/local/bin ; do
        if test -x $i/kinit ; then
            krb5init=$i/kinit
            break
        fi
    done

    if test "x$krb5init" = "x" ; then
        result "Checking for kinit ... no"
    else
        echo "Checking for kinit ... $krb5init"
    fi

    if test ! "x$enable_krb5" = "xyes" ; then
        krb5incdir=""
        krb5lib=""
        krb5libdir=""
    else
        krb5extracflags="-DR__KRB5"
        havekrb5="krb5"
    fi
fi
check_explicit "$enable_krb5" "$enable_krb5_explicit" \
     "Explicitly required Kerberos5 dependencies not fulfilled"

######################################################################
#
### echo %%% Communication of errors library
#
# This library is needed by both AFS and Kerberos support, so to
# avoid duplicate linkage, this is done here.
#
if test "x$enable_afs" = "xyes" || test "x$enable_krb5" = "xyes" ; then
    if test ! "x$afsdir" = "x" ; then
        comerrlibdir=$afsdir
    fi
    if test ! "x$krb5libdirorg" = "x" ; then
        if test ! "x$comerrlibdir" = "x" ; then
            comerrlibdir="$comerrlibdir $krb5libdirorg"
        else
            comerrlibdir=$krb5libdirorg
        fi
    fi
    check_library libcom_err "$enable_shared" "$comerrlibdir" \
                                              "$afslibdirs $krb5libdirs"
    if test "x$found_lib" = "x" ; then
	enable_krb5=no
        krb5incdir=""
        krb5lib=""
        krb5libdir=""
        krb5extracflags=""
	enable_afs=no
        afslib=""
	comerrlib=""
	comerrlibdir=""
    else
	comerrlib=$found_lib
	comerrlibdir=$found_dir
    fi

    case $platform in
	linux|solaris) # Resolver lives in separate library
	    resolvlib="-lresolv"
	    ;;
    esac
fi

######################################################################
#
### echo %%% Shadow password support
#

checking_msg "shadow passwords"

if test "x$enable_shadowpw" = "x"; then
   if test -f "/etc/shadow" ; then
      enable_shadowpw="yes"
   else
      enable_shadowpw="no"
   fi
fi

if test "x$enable_shadowpw" = "xyes"; then
   shadowpw="-DR__SHADOWPW "
fi

result $enable_shadowpw
check_explicit "$enable_shadowpw" "$enable_shadowpw_explicit" \
     "Explicitly required Shadow passwords dependencies not fulfilled"

######################################################################
#
### echo %%% MathMore Library - Contributed library
#
if test ! "x$enable_mathmore" = "xno"; then
    # Check for GSL include and library
    gslskip=
    hasmathmore="define"
    check_header "gsl/gsl_version.h" "$gslincdir" $GSL $GSL/include \
	$GSL/api /usr/local/include /usr/include /opt/gsl/include \
	$finkdir/include

    # check for gsl version >= 1.8
    if test ! "x$found_dir" = "x"; then
	message "Checking for GSL version >= 1.8"
	gsl_version=`grep "define GSL" $found_dir/gsl/gsl_version.h | sed 's/^.*"\([0-9]\.[0-9]\)"/\1/' |  awk 'BEGIN { FS="." } { printf "%d", $1 * 1000 + $2 }'`
	if test $gsl_version -lt 1008; then
	    gslskip="skip"
	    result "no"
            enable_mathmore="no"
	else
	    result "ok"
	    gslinc=$found_hdr
	    gslincdir=$found_dir
	    gslflags=-I$gslincdir
	fi
    fi

    if test ! "x$gslflags" = "x"; then
	#check for the library now
	gsllibdir0=$gsllibdir
	check_library "libgsl gslML gsl" "$enable_shared" "$gsllibdir" \
	    $GSL $GSL/lib $GSL/.libs /usr/local/lib /usr/lib /opt/gsl/lib \
	    $finkdir/lib

	if test ! "x$found_lib" = "x"; then
	    gsllibs=$found_lib
	    gsllibdir=$found_dir
	    # in case of shared libs (gsllibdir is not empty) need gslcblas
	    # assume libgslcblas is in same dir as libgsl
	    if test ! "x$gsllibdir" = "x"; then
		check_library "libgslcblas gslcblas" "$enable_shared" "$gsllibdir0" \
		    $GSL $GSL/lib $GSL/.libs /usr/local/lib /usr/lib /opt/gsl/lib \
		    $finkdir/lib
		if test ! "x$found_lib" = "x"; then
		    gsllibs="$gsllibs $found_lib"
		    gsllibdir=$found_dir
		else
		    #cblas not found
		    gsllibs=""
		fi
	    fi
	fi
    fi
    #
    # if gslincdir not specified look for gsl-config
    #
    # gsl-config check does not work on Solaris so lets skip it
    if test "x$platform" = "xsolaris"; then
	if (test "x$gslincdir" = "x" || test "x$gsllibs" = "x"); then
	    gslskip="skip"
	    enable_mathmore="no"
	fi
    fi
    # skip cygwin gsl-config when in pure Win32 mode
    if test "x$platform" = "xwin32"; then
        case `$cwhich gsl-config` in
            /bin/*|/usr/bin/*)
	        if (test "x$gslincdir" = "x" || test "x$gsllibs" = "x"); then
                    gslskip="skip"
                    enable_mathmore="no"
                fi
                ;;
        esac
    fi
    if (test "x$gslincdir" = "x" || test "x$gsllibs" = "x") && \
        test ! "x$gslskip" = "xskip"; then
	checking_msg "gsl-config"
	if `$cwhich gsl-config > /dev/null 2>&1` ; then
	    $cwhich gsl-config
            # we found gsl-config - now check the version number
            message "Checking for GSL version >= 1.8"
            gsl_version=`gsl-config --version | awk 'BEGIN { FS="." } { printf "%d", $1 * 1000 + $2 }'`
            if test $gsl_version -lt 1008 ; then
                result "no (`gsl-config --version`)"
                enable_mathmore="no"
            else
	        # We've found `gsl-config' - use that to get the compiler
	        # and linker flags
		result "ok"
	        gslflags=`gsl-config --cflags`
	        gsllibs=`gsl-config --libs`
		gsllibdir=""
            fi
        else
	    enable_mathmore="no"
	    result "not found"
	fi
    fi
fi
message "Checking whether to build libMathMore"
if test "x$enable_mathmore" = "xyes"; then
    result "yes"
    hasmathmore="define"
else
    result "no"
    hasmathmore="undef"
fi
check_explicit "$enable_mathmore" "$enable_mathmore_explicit" \
     "Explicitly required MathMore dependencies not fulfilled"


######################################################################
#
### echo %%% MathCore Library - Contributed library
#
message "Checking whether to build libMathCore"
if test ! "x$enable_mathcore" = "xno"; then
    enable_mathcore="yes"
    result "yes"
else
    enable_mathcore=""
    result "no"
fi
check_explicit "$enable_mathmore" "$enable_mathmore_explicit" \
     "Explicitly required MathMore dependencies not fulfilled"

######################################################################
#
### echo %%% Experimental Cint7 Library
#
message "Checking whether to build CINT7"
if test ! "x$enable_cint7" = "xno"; then
    enable_cint7="yes"
    enable_reflex="yes"
    result "yes"
else
    enable_cint7=""
    result "no"
fi

######################################################################
#
### echo %%% Cintex Library - Contributed library
#
message "Checking whether to build libCintex"
if test ! "x$enable_cintex" = "xno"; then
    enable_cintex="yes"
    result "yes"
else
    enable_cintex=""
    result "no"
fi

######################################################################
#
### echo %%% Reflex Library - Contributed library
#
message "Checking whether to build libReflex"
if test ! "x$enable_reflex" = "xno"; then
    enable_reflex="yes"
    result "yes"
else
    enable_reflex=""
    result "no"
fi

######################################################################
#
### echo %%% RooFit Library - Contributed library
#
message "Checking whether to build libRooFit"
if test "x$enable_roofit" = "xyes" || test ! "x$ROOFIT" = "x"; then
    enable_roofit="yes"
    result "yes"
else
    enable_roofit=""
    result "no"
fi

######################################################################
#
### echo %%% Minuit2 Library - Contributed library
#
message "Checking whether to build libMinuit2"
if test "x$enable_minuit2" = "xyes" || test ! "x$MINUIT2" = "x"; then
    enable_minuit2="yes"
    result "yes"
else
    enable_minuit2=""
    result "no"
fi

######################################################################
#
### echo %%% Unuran Library - Contributed library
#
message "Checking whether to build libUnuran"
if test "x$enable_unuran" = "xyes" || test ! "x$UNURAN" = "x"; then
    enable_unuran="yes"
    result "yes"
else
    enable_unuran=""
    result "no"
fi

######################################################################
#
### echo %%% GDML Library - Contributed library
#
message "Checking whether to build libGdml"
if test "x$enable_gdml" = "xyes" || test ! "x$GDML" = "x"; then
    enable_gdml="yes"
    result "yes"
else
    enable_gdml=""
    result "no"
fi

######################################################################
#
### echo %%% Table Library - Contributed library
#
message "Checking whether to build libTable"
if test "x$enable_table" = "xyes" || test ! "x$TABLE" = "x"; then
    enable_table="yes"
    result "yes"
else
    enable_table=""
    result "no"
fi

######################################################################
#
### echo %%% Clarens Support - Third party libraries
#
# (See http://clarens.sourceforge.net/)
#

checking_msg "Clarens support"

if test ! "x$enable_clarens" = "xno" ; then

    myxmlrpc=`$cwhich xmlrpc-c-config 2> /dev/null`
    if test ! "x$myxmlrpc" = "x" && test -x "$myxmlrpc" ; then
        clarensincdir=`xmlrpc-c-config curl-client --cflags 2> /dev/null`
        clarenslibs=`xmlrpc-c-config curl-client --ldadd 2> /dev/null`
	if test "x$clarensincdir" = "x" ; then
	    clarensincdir=`xmlrpc-c-config --cflags 2> /dev/null`
	    clarenslibs=`xmlrpc-c-config --ldadd 2> /dev/null`
	fi
    else
        clarensincdir=""
        clarenslibs=""
    fi
    if test "x$clarensincdir" = "x" || test "x$clarenslibs" = "x"; then
        enable_clarens="no"
    fi
fi

if test "x$enable_clarens" = "xyes" ; then
    result "yes"
else
    result "no"
fi
check_explicit "$enable_clarens" "$enable_clarens_explicit" \
     "Explicitly required Clarens dependencies not fulfilled"

######################################################################
#
### echo %%% PEAC Support - depends on Clarens
#
# (See http://www.clarens.org)
#

checking_msg "PEAC support"

if test ! "x$enable_peac" = "xno" ; then

    if test "x$enable_clarens" = "xno"; then
        enable_peac="no"
    fi
fi

if test "x$enable_peac" = "xyes" ; then
    buildpeac="yes"
else
    buildpeac="no"
fi

result "$buildpeac"
check_explicit "$enable_peac" "$enable_peac_explicit" \
     "Explicitly required Peac dependencies not fulfilled"

######################################################################
#
### echo %%% What dictionaries to build
#
# Can be either cint (default), reflex, or gccxml.
# Option will be passed to rootcint(_tmp),
# and root-config --libs will have -lReflex if needed.
#

# --with-dicttype overrides env var ROOTDICTTYPE
if test "x$dicttype" = "x" ; then
    dicttype="$ROOTDICTTYPE"
fi

# set default to cint
if test "x$dicttype" = "x"; then
    dicttype=cint
fi

case "$dicttype" in
    cint);;
    reflex | gccxml)
        # check that cintex is enabled for reflex/gccxml
        if test ! "x$enable_cintex" = "xyes"; then
            result "Cannot generate $dicttype dictionaries with cintex disabled."
            dicttype=cint
        fi ;;
    *)
        result "Unknown dictionary \"$dicttype\"."
        result "  Must be one of cint, reflex, gccxml."
        dicttype=cint
        ROOTDICTTYPE="trigger print info"
        ;;
esac

# Print info if dicttype!=cint, or --with-dict overrides $ROOTDICTTYPE
if test ! "x$dicttype" = "xcint" \
     -o ! "x$dicttype" = "x$ROOTDICTTYPE"; then
    result "Generating $dicttype dictionaries."
fi

######################################################################
#
### echo %%% Debian or Red Hat package list
#
# If we're asked to build for a set of RPMs or Debian packages, we
# make a list of the packages it's possible for us to build on this
# system.
#
if test "x$show_pkglist" = "xyes" ; then
    test "x$enable_alien"   = "xyes" && pkglist="$pkglist root-plugin-alien"
    test "x$enable_asimage" = "xyes" && pkglist="$pkglist root-plugin-asimage"
    test "x$enable_castor"  = "xyes" && pkglist="$pkglist root-plugin-castor"
    test "x$enable_cern"    = "xyes" && pkglist="$pkglist root-plugin-hbook"
    test "x$enable_chirp"   = "xyes" && pkglist="$pkglist root-plugin-chirp"
    test "x$enable_cint7"   = "xyes" && pkglist="$pkglist root-plugin-cint7"
    test "x$enable_clarens" = "xyes" && pkglist="$pkglist libroot-clarens"
    test "x$enable_dcache"  = "xyes" && pkglist="$pkglist root-plugin-dcache"
    test "x$enable_fftw3"   = "xyes" && pkglist="$pkglist root-plugin-fftw3"
    test "x$enable_gfal"    = "xyes" && pkglist="$pkglist root-plugin-gfal"
    test "x$enable_g4root"  = "xyes" && pkglist="$pkglist root-plugin-g4root"
    test "x$enable_globus"  = "xyes" && pkglist="$pkglist root-plugin-globus"
    test "x$enable_krb5"    = "xyes" && pkglist="$pkglist root-plugin-krb5"
    test "x$enable_ldap"    = "xyes" && pkglist="$pkglist libroot-ldap"
    test "x$enable_minuit2" = "xyes" && pkglist="$pkglist root-plugin-minuit2"
    test "x$enable_mathmore" = "xyes" && pkglist="$pkglist libroot-mathmore"
    test "x$enable_monalisa" = "xyes" && pkglist="$pkglist root-plugin-monalisa"
    test "x$enable_mysql"   = "xyes" && pkglist="$pkglist root-plugin-mysql"
    test "x$enable_odbc"    = "xyes" && pkglist="$pkglist root-plugin-odbc"
    test "x$enable_opengl"  = "xyes" && pkglist="$pkglist root-plugin-gl"
    test "x$enable_oracle"  = "xyes" && pkglist="$pkglist root-plugin-oracle"
    test "x$enable_peac"    = "xyes" && pkglist="$pkglist root-plugin-peac"
    test "x$enable_pgsql"   = "xyes" && pkglist="$pkglist root-plugin-pgsql"
    test "x$enable_pythia6" = "xyes" && pkglist="$pkglist root-plugin-pythia6"
    test "x$enable_python"  = "xyes" && pkglist="$pkglist libroot-python"
    test "x$enable_qt"      = "xyes" && pkglist="$pkglist root-plugin-qt"
    test "x$enable_roofit"  = "xyes" && pkglist="$pkglist libroot-roofit"
    test "x$enable_ruby"    = "xyes" && pkglist="$pkglist libroot-ruby"
    test "x$enable_rfio"    = "xyes" && pkglist="$pkglist root-plugin-rfio"
    test "x$enable_sapdb"   = "xyes" && pkglist="$pkglist root-plugin-maxdb"
    test "x$enable_srp"     = "xyes" && pkglist="$pkglist root-plugin-srp"
    test "x$enable_xml"     = "xyes" && pkglist="$pkglist root-plugin-xml"
    test "x$enable_xrootd"  = "xyes" && pkglist="$pkglist root-xrootd root-plugin-netx"

    pkglist="$pkglist root-plugin-fumili libroot-minuit libroot-mlp libroot-tmva root-plugin-proof root-plugin-xproof root-plugin-sql libroot-quadp root-proofd root-rootd root-doc root-bin libroot root-common ttf-root-installer"
    # If we're called from the package preparation script, then
    # print out the package list and exit
    result "packages: $pkglist"
    exit 0
fi

######################################################################
#
### echo %%% check for setresuid and setresgid
#
setresuid="undef"
case $platform in
    linux)
        message "Checking whether setresuid declared in /usr/include/unistd.h"
        if `grep setresuid /usr/include/unistd.h > /dev/null 2>&1` ; then
            setresuid="define"
            result "yes"
        else
            result "no"
        fi ;;
esac

######################################################################
#
### echo %%% Explicitlink - explicitly link with all dependent libraries
#
case $arch in
freebsd*|openbsd|aix*|win32*)
    enable_explicitlink="yes"
    ;;
esac
if test "x$enable_explicitlink" = "xyes" && test ! "$platform" = "win32" ; then
    mkliboption=$mkliboption"-x "
fi

######################################################################
#
### echo %%% Exit here if this is a dry run
#
if test "x$noact" = "xyes" ; then
    exit 0
fi

######################################################################
#
### echo %%% Create needed directories
#
if test ! -d include ; then
   message "Creating include"
   mkdir include
   result "done"
fi
if test ! -d bin ; then
   message "Creating bin"
   mkdir bin
   result "done"
fi
if test ! -d lib ; then
   message "Creating lib"
   mkdir lib
   result "done"
fi

######################################################################
#
### echo %%% Cleanup obsolete links and files
#
if test -h opengl ; then
   rm -f opengl
fi
if test -h ttf ; then
   rm -f ttf
fi
if test -f system.rootrc ; then
   rm -f system.rootrc
fi
if test -d new ; then
   rm -rf new
fi
if test -d star ; then
   rm -rf star
fi
rm -f lib/libRXML* bin/libRXML* bin/xproofd

######################################################################
#
### echo %%% Fleshin out paths
#
# First win32 does not support -L in ldflags, so remove @ldflags@.
#
if test "$platform" = "win32" ; then
    sed -e "s|@ldflags@||"        \
        < Makefile.tmp > Makefile.tmpp
    mv Makefile.tmpp Makefile.tmp
fi

if test "x$enable_globus" = "xyes" && test "x$enable_rpath" = "xyes"; then
    case "$arch" in
        solarisCC5)
          sed -e "s|@ldflags@|-R$globusdir/lib @ldflags@|" \
                 < Makefile.tmp > Makefile.tmpp
          ;;
        linux*)
          sed -e "s|@ldflags@|-Wl,-rpath,$globusdir/lib @ldflags@|" \
                 < Makefile.tmp > Makefile.tmpp
          ;;
    esac
    if test -f Makefile.tmpp ; then
       mv Makefile.tmpp Makefile.tmp
    fi
fi

if test ! "x$haveconfig" = "x" ; then
    ##################################################################
    #
    ### echo %%% Static directory build.
    #
    if test "x$prefix" = "x";       then prefix=/usr/local; fi
    if test "x$bindir" = "x";       then bindir=$prefix/bin; fi
    if test "x$libdir" = "x";       then libdir=$prefix/lib/root; fi
    if test "x$incdir" = "x";       then incdir=$prefix/include/root; fi
    if test "x$etcdir" = "x";       then etcdir=/etc/root; fi
    if test "x$mandir" = "x";       then mandir=$prefix/share/man/man1; fi
    if test "x$datadir" = "x";      then datadir=$prefix/share/root; fi
    if test "x$macrodir" = "x";     then macrodir=$datadir/macros; fi
    if test "x$cintincdir" = "x";   then cintincdir=$libdir/cint; fi
    if test "x$iconpath" = "x";     then iconpath=$datadir/icons; fi
    if test "x$srcdir" = "x";       then srcdir=$datadir/src; fi
    if test "x$fontdir" = "x";      then fontdir=$datadir/fonts; fi
    if test "x$docdir" = "x";       then docdir=$prefix/share/doc/root; fi
    if test "x$testdir" = "x";      then testdir=$docdir/test; fi
    if test "x$tutdir" = "x";       then tutdir=$docdir/tutorials; fi
    if test "x$aclocaldir" = "x";   then aclocaldir=$prefix/share/aclocal; fi
    if test "x$elispdir" = "x";     then elispdir=$prefix/share/emacs/site-lisp; fi

    if test "x$enable_rpath" = "xyes" ; then
       case "$arch" in
          solarisCC5)
             sed -e "s|@ldflags@|-R$libdir @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
             ;;
          linux*)
             sed -e "s|@ldflags@|-Wl,-rpath,$libdir @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
             ;;
       esac
       if test -f Makefile.tmpp ; then
          mv Makefile.tmpp Makefile.tmp
       fi
    fi

    sed -e "s|@useconfig@|TRUE|"                       \
        -e "s|@cflags@|$haveconfig|"                   \
            < Makefile.tmp > Makefile.tmpp
    mv Makefile.tmpp Makefile.tmp
else
    ##################################################################
    #
    ### echo %%% Environment driven build. Escape sequences very important
    #
    prefix=\$\(ROOTSYS\)
    bindir=\$\(ROOTSYS\)/bin
    libdir=\$\(ROOTSYS\)/lib
    incdir=\$\(ROOTSYS\)/include
    etcdir=\$\(ROOTSYS\)/etc
    datadir=\$\(ROOTSYS\)
    mandir=\$\(ROOTSYS\)/man/man1
    macrodir=\$\(ROOTSYS\)/macros
    cintincdir=\$\(ROOTSYS\)/cint
    iconpath=\$\(ROOTSYS\)/icons
    srcdir=\$\(ROOTSYS\)/src
    fontdir=\$\(ROOTSYS\)/fonts
    docdir=\$\(ROOTSYS\)
    testdir=\$\(ROOTSYS\)/test
    tutdir=\$\(ROOTSYS\)/tutorials
    aclocaldir=\$\(ROOTSYS\)/build/misc
    elispdir=\$\(ROOTSYS\)/build/misc

    # when using rpath in this case build product is not relocatable
    if test "x$enable_rpath" = "xyes" ; then
        if test "$arch" = "solarisCC5"; then
            sed -e "s|@ldflags@|-R$libdir @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
        else
            sed -e "s|@ldflags@|-Wl,-rpath,$libdir @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
        fi
        mv Makefile.tmpp Makefile.tmp
    fi

    sed -e "s|@useconfig@|FALSE|" \
        -e "s|@cflags@||"         \
        -e "s|@ldflags@||"        \
            < Makefile.tmp > Makefile.tmpp
    mv Makefile.tmpp Makefile.tmp
fi

######################################################################
#
### echo %%% Writing files
#
#---------------------------------------------------------------------
# config/Makefile.config
#
message "Writing $MAKEOUT"
sed -e "s|@aclocaldir@|$aclocaldir|"            \
    -e "s|@afslib@|$afslib|"                    \
    -e "s|@afslibdir@|$afslibdir|"              \
    -e "s|@alienincdir@|$alienincdir|"          \
    -e "s|@alienlib@|$alienlib|"                \
    -e "s|@alienlibdir@|$alienlibdir|"          \
    -e "s|@architecture@|$arch|"                \
    -e "s|@asextralib@|$asextralib|"            \
    -e "s|@asextralibdir@|$asextralibdir|"      \
    -e "s|@asjpegincdir@|$asjpegincdir|"        \
    -e "s|@aspngincdir@|$aspngincdir|"          \
    -e "s|@astiffincdir@|$astiffincdir|"        \
    -e "s|@asgifincdir@|$asgifincdir|"          \
    -e "s|@asimageincdir@|$asimageincdir|"      \
    -e "s|@asimagelib@|$asimagelib|"            \
    -e "s|@asimagelibdir@|$asimagelibdir|"      \
    -e "s|@bindir@|$bindir|"                    \
    -e "s|@buildasimage@|$enable_asimage|"      \
    -e "s|@builtinafterimage@|$enable_builtin_afterimage|"  \
    -e "s|@builtinfreetype@|$enable_builtin_freetype|"      \
    -e "s|@builtinpcre@|$enable_builtin_pcre|"  \
    -e "s|@buildxrd@|$buildxrd|"                \
    -e "s|@cernlibdir@|$cernlibdir|"            \
    -e "s|@cernlibs@|$cernlib|"                 \
    -e "s|@castorincdir@|$castorincdir|"        \
    -e "s|@castorlib@|$castorlib|"              \
    -e "s|@castorlibdir@|$castorlibdir|"        \
    -e "s|@castorcflags@|$castorcflags|"        \
    -e "s|@chirpincdir@|$chirpincdir|"          \
    -e "s|@chirplib@|$chirplib|"                \
    -e "s|@chirplibdir@|$chirplibdir|"          \
    -e "s|@buildcint7@|$enable_cint7|"          \
    -e "s|@clarensincdir@|$clarensincdir|"      \
    -e "s|@clarenslibs@|$clarenslibs|"          \
    -e "s|@cintincdir@|$cintincdir|"            \
    -e "s|@cppunit@|$cppunit|"                  \
    -e "s|@datadir@|$datadir|"                  \
    -e "s|@dcapincdir@|$dcapincdir|"            \
    -e "s|@comerrlib@|$comerrlib|"              \
    -e "s|@comerrlibdir@|$comerrlibdir|"        \
    -e "s|@cryptolib@|$cryptolib|"              \
    -e "s|@cryptolibdir@|$cryptolibdir|"        \
    -e "s|@dcaplib@|$dcaplib|"                  \
    -e "s|@dcaplibdir@|$dcaplibdir|"            \
    -e "s|@dicttype@|$dicttype|"                \
    -e "s|@docdir@|$docdir|"                    \
    -e "s|@elispdir@|$elispdir|"                \
    -e "s|@buildmathcore@|$enable_mathcore|"    \
    -e "s|@buildmathmore@|$enable_mathmore|"    \
    -e "s|@gslflags@|$gslflags|"                \
    -e "s|@gsllibdir@|$gsllibdir|"              \
    -e "s|@gsllibs@|$gsllibs|"                  \
    -e "s|@builtinzlib@|$enable_builtin_zlib|"  \
    -e "s|@zlibincdir@|$zlibincdir|"            \
    -e "s|@zliblib@|$zliblib|"                  \
    -e "s|@zliblibdir@|$zliblibdir|"            \
    -e "s|@buildcintex@|$enable_cintex|"        \
    -e "s|@buildreflex@|$enable_reflex|"        \
    -e "s|@buildroofit@|$enable_roofit|"        \
    -e "s|@buildminuit2@|$enable_minuit2|"      \
    -e "s|@buildunuran@|$enable_unuran|"        \
    -e "s|@buildgdml@|$enable_gdml|"            \
    -e "s|@buildmonalisa@|$enable_monalisa|"    \
    -e "s|@enable_pch@|$enable_pch|"            \
    -e "s|@buildtable@|$enable_table|"          \
    -e "s|@enable_thread@|$enable_thread|"      \
    -e "s|@etcdir@|$etcdir|"                    \
    -e "s|@exceptions@|$enable_exceptions|"     \
    -e "s|@explicitlink@|$enable_explicitlink|" \
    -e "s|@gfalincdir@|$gfalincdir|"            \
    -e "s|@gfallib@|$gfallib|"                  \
    -e "s|@gfallibdir@|$gfallibdir|"            \
    -e "s|@g4incdir@|$g4incdir|"                \
    -e "s|@g4libdir@|$g4libdir|"                \
    -e "s|@clhepincdir@|$clhepincdir|"          \
        < Makefile.tmp > Makefile.tmpp
mv Makefile.tmpp Makefile.tmp

sed -e "s|@globusincdir@|$globusincdir|"        \
    -e "s|@globuslib@|$globuslib|"              \
    -e "s|@globuslibdir@|$globuslibdir|"        \
    -e "s|@glbextracflags@|$glbextracflags|"    \
    -e "s|@glbpatchcflags@|$glbpatchcflags|"    \
    -e "s|@gccxml@|$gccxml|"                    \
    -e "s|@iconpath@|$iconpath|"                \
    -e "s|@incdir@|$incdir|"                    \
    -e "s|@krb5incdir@|$krb5incdir|"            \
    -e "s|@krb5lib@|$krb5lib|"                  \
    -e "s|@krb5libdir@|$krb5libdir|"            \
    -e "s|@krb5extracflags@|$krb5extracflags|"  \
    -e "s|@krb5init@|$krb5init|"                \
    -e "s|@ldapincdir@|$ldapincdir|"            \
    -e "s|@ldaplib@|$ldaplib|"                  \
    -e "s|@ldaplibdir@|$ldaplibdir|"            \
    -e "s|@ldflags@||"                          \
    -e "s|@libdir@|$libdir|"                    \
    -e "s|@macrodir@|$macrodir|"                \
    -e "s|@mandir@|$mandir|"                    \
    -e "s|@mkliboption@|$mkliboption|"          \
    -e "s|@monalisaincdir@|$monalisaincdir|"    \
    -e "s|@monalisalib@|$monalisalib|"          \
    -e "s|@monalisalibdir@|$monalisalibdir|"    \
    -e "s|@monalisawsincdir@|$monalisawsincdir|"\
    -e "s|@monalisawslib@|$monalisawslib|"      \
    -e "s|@monalisawslibdir@|$monalisawslibdir|"\
    -e "s|@fftw3incdir@|$fftw3incdir|"          \
    -e "s|@fftw3lib@|$fftw3lib|"                \
    -e "s|@fftw3libdir@|$fftw3libdir|"          \
    -e "s|@mysqlincdir@|$mysqlincdir|"          \
    -e "s|@mysqllib@|$mysqllib|"                \
    -e "s|@mysqllibdir@|$mysqllibdir|"          \
    -e "s|@odbcincdir@|$odbcincdir|"            \
    -e "s|@odbclib@|$odbclib|"                  \
    -e "s|@odbclibdir@|$odbclibdir|"            \
    -e "s|@openglincdir@|$openglincdir|"        \
    -e "s|@opengllib@|$opengllib|"              \
    -e "s|@opengllibdir@|$opengllibdir|"        \
    -e "s|@openglulib@|$openglulib|"            \
    -e "s|@oracleincdir@|$oracleincdir|"        \
    -e "s|@oraclelib@|$oraclelib|"              \
    -e "s|@oraclelibdir@|$oraclelibdir|"        \
    -e "s|@pgsqlincdir@|$pgsqlincdir|"          \
    -e "s|@pgsqllib@|$pgsqllib|"                \
    -e "s|@pgsqllibdir@|$pgsqllibdir|"          \
    -e "s|@pythia6lib@|$pythia6lib|"            \
    -e "s|@pythia6libdir@|$pythia6libdir|"      \
    -e "s|@pythia6cppflags@|$pythia6cppflags|"  \
    -e "s|@pythonlib@|$pythonlib|"              \
    -e "s|@pythonlibdir@|$pythonlibdir|"        \
    -e "s|@pythonincdir@|$pythonincdir|"        \
    -e "s|@pythonlibflags@|$pythonlibflags|"    \
    -e "s|@rubylib@|$rubylib|"                  \
    -e "s|@rubylibdir@|$rubylibdir|"            \
    -e "s|@rubyincdir@|$rubyincdir|"            \
    -e "s|@qtincdir@|$qtincdir|"                \
    -e "s|@qtlib@|$qtlib|"                      \
    -e "s|@qtlibdir@|$qtlibdir|"                \
    -e "s|@qtmocexe@|$qtmocexe|"                \
    -e "s|@resolvlib@|$resolvlib|"              \
    -e "s|@rootbuild@|$rootbuild|"              \
    -e "s|@sapdbincdir@|$sapdbincdir|"          \
    -e "s|@sapdblib@|$sapdblib|"                \
    -e "s|@sapdblibdir@|$sapdblibdir|"          \
    -e "s|@shadowpw@|$shadowpw|"                \
    -e "s|@shiftincdir@|$shiftincdir|"          \
    -e "s|@shiftlib@|$shiftlib|"                \
    -e "s|@shiftlibdir@|$shiftlibdir|"          \
    -e "s|@shiftcflags@|$shiftcflags|"          \
        < Makefile.tmp > Makefile.tmpp
mv Makefile.tmpp Makefile.tmp

sed -e "s|@srcdir@|$srcdir|"                    \
    -e "s|@srpincdir@|$srpincdir|"              \
    -e "s|@srplib@|$srplib|"                    \
    -e "s|@srplibdir@|$srplibdir|"              \
    -e "s|@srputilincdir@|$srputilincdir|"      \
    -e "s|@srputillib@|$srputillib|"            \
    -e "s|@srputillibdir@|$srputillibdir|"      \
    -e "s|@srpextracflags@|$srpextracflags|"    \
    -e "s|@sslincdir@|$sslincdir|"              \
    -e "s|@ssllib@|$ssllib|"                    \
    -e "s|@ssllibdir@|$ssllibdir|"              \
    -e "s|@sslextracflags@|$sslextracflags|"    \
    -e "s|@testdir@|$testdir|"                  \
    -e "s|@threadflag@|$threadflag|"            \
    -e "s|@threadlib@|$threadlib|"              \
    -e "s|@threadlibdir@|$threadlibdir|"        \
    -e "s|@ttffontdir@|$fontdir|"               \
    -e "s|@tutdir@|$tutdir|"                    \
    -e "s|@winrtdebug@|$enable_winrtdebug|"     \
    -e "s|@xmlincdir@|$xmlincdir|"              \
    -e "s|@xmllib@|$xmllib|"                    \
    -e "s|@xmllibdir@|$xmllibdir|"              \
    -e "s|@x11libdir@|$x11libdir|"              \
    -e "s|@xpmlib@|$xpmlib|"                    \
    -e "s|@xpmlibdir@|$xpmlibdir|"              \
    -e "s|@xrootddir@|$xrootddir|"              \
    -e "s|@buildgl@|$enable_opengl|"            \
    -e "s|@buildhbook@|$enable_cern|"           \
    -e "s|@buildldap@|$enable_ldap|"            \
    -e "s|@buildmysql@|$enable_mysql|"          \
    -e "s|@buildpgsql@|$enable_pgsql|"          \
    -e "s|@buildodbc@|$enable_odbc|"            \
    -e "s|@buildoracle@|$enable_oracle|"        \
    -e "s|@buildsapdb@|$enable_sapdb|"          \
    -e "s|@buildqt@|$enable_qt|"                \
    -e "s|@buildqtgsi@|$enable_qtgsi|"          \
    -e "s|@buildrfio@|$enable_rfio|"            \
    -e "s|@buildcastor@|$enable_castor|"        \
    -e "s|@builddcap@|$enable_dcache|"          \
    -e "s|@buildfftw3@|$enable_fftw3|"          \
    -e "s|@buildgfal@|$enable_gfal|"            \
    -e "s|@buildg4root@|$enable_g4root|"        \
    -e "s|@buildchirp@|$enable_chirp|"          \
    -e "s|@buildalien@|$enable_alien|"          \
    -e "s|@buildasimage@|$enable_asimage|"      \
    -e "s|@buildpythia6@|$enable_pythia6|"      \
    -e "s|@buildpython@|$enable_python|"        \
    -e "s|@buildruby@|$enable_ruby|"            \
    -e "s|@buildxml@|$enable_xml|"              \
    -e "s|@buildxrd@|$enable_xrd|"              \
    -e "s|@buildsrputil@|$enable_srputil|"      \
    -e "s|@buildkrb5@|$enable_krb5|"            \
    -e "s|@buildglobus@|$enable_globus|"        \
    -e "s|@buildclarens@|$enable_clarens|"      \
    -e "s|@buildpeac@|$buildpeac|"              \
    < Makefile.tmp > $MAKEOUT
rm -f Makefile.tmp

if test "x$platform" = "xwin32"; then
    echo 'ifeq ($(ROOTSYS),)' > Makefile.tmp
    echo '  ROOTSYS=.' >> Makefile.tmp
    echo 'endif' >> Makefile.tmp
    sed -e 's@$(ROOTSYS)\(.*\)@$(shell cygpath -u \"$(ROOTSYS)\1 ")@' \
    < $MAKEOUT >> Makefile.tmp
    mv -f Makefile.tmp $MAKEOUT
fi

result "done"

#---------------------------------------------------------------------
# include/RConfigure.h
#
message "Writing $CONFIGUREOUT"
sed \
    -e "s|@architecture@|$arch|"           \
    -e "s|@bindir@|$bindir|"               \
    -e "s|@cintincdir@|$cintincdir|"       \
    -e "s|@datadir@|$datadir|"             \
    -e "s|@docdir@|$docdir|"               \
    -e "s|@etcdir@|$etcdir|"               \
    -e "s|@extraiconpath@|$extraiconpath|" \
    -e "s|@iconpath@|$iconpath|"           \
    -e "s|@incdir@|$incdir|"               \
    -e "s|@libdir@|$libdir|"               \
    -e "s|@macrodir@|$macrodir|"           \
    -e "s|@prefix@|$prefix|"               \
    -e "s|@srcdir@|$srcdir|"               \
    -e "s|@ttffontdir@|$fontdir|"          \
    -e "s|@setresuid@|$setresuid|"         \
    -e "s|@configoptions@|$configoptions|" \
    -e "s|@hasmathmore@|$hasmathmore|"     \
    -e "s|@haspthread@|$haspthread|"       \
    < RConfigure.tmp > $CONFIGUREOUT
rm -f RConfigure.tmp

if test ! "x$enable_ruby" = "xno"; then
   echo "" >> $CONFIGUREOUT
   ruby -rrbconfig -e 'puts Config::CONFIG["ruby_version"]' | \
   sed 's/^\([0-9]\)\.\([0-9]\)/#define R__RUBY_MAJOR \1@#define R__RUBY_MINOR \2/' | \
   tr '@' '\n' >> $CONFIGUREOUT
fi

result "done"

#---------------------------------------------------------------------
# bin/root-config
#
message "Writing $RCONFOUT"
prefix2=$prefix
bindir2=$bindir
libdir2=$libdir
incdir2=$incdir
if test "$prefix2" = "\$(ROOTSYS)" ; then
    prefix2=\$ROOTSYS
    bindir2=\$ROOTSYS/bin
    libdir2=\$ROOTSYS/lib
    incdir2=\$ROOTSYS/include
fi
features=""
for f in $options ; do
    bar="$`echo $f`"
    if test "x`eval echo $bar`" = "xyes" ; then
       feat=`echo $f | sed 's/enable_//'`
       features="$features $feat"
    fi
done
sed -e "s|@architecture@|$arch|"           \
    -e "s|@platform@|$platform|"           \
    -e "s|@prefix@|$prefix2|"              \
    -e "s|@bindir@|$bindir2|"              \
    -e "s|@libdir@|$libdir2|"              \
    -e "s|@incdir@|$incdir2|"              \
    -e "s|@features@|$features|"           \
    -e "s|@winrtdebug@|$enable_winrtdebug|"\
    -e "s|@configargs@|$configargs|"       \
    -e "s|@dicttype@|$dicttype|"           \
    -e "s|@zliblib@|$zliblib|"             \
   < root-config.tmp > $RCONFOUT
rm -f root-config.tmp
chmod 755 $RCONFOUT
result "done"

#---------------------------------------------------------------------
# etc/system.rootrc
#
message "Writing $ROOTRCOUT"
sed -e "s|@libdir@|$libdir|"               \
    -e "s|@macrodir@|$macrodir|"           \
    -e "s|@bindir@|$bindir|"               \
    -e "s|@etcdir@|$etcdir|"               \
    -e "s|@ttffontdir@|$fontdir|"          \
    -e "s|@iconpath@|$iconpath|"           \
    -e "s|@hasxrd@|$hasxrd|"             \
   < rootrc.tmp > $ROOTRCOUT
rm -f rootrc.tmp
result "done"

#---------------------------------------------------------------------
# etc/system.rootauthrc
#
message "Writing $ROOTAUTHRCOUT"
sed -e "s|@havesrp@|$havesrp|"             \
    -e "s|@havekrb5@|$havekrb5|"           \
    -e "s|@haveglobus@|$haveglobus|"       \
   < rootauthrc.tmp > $ROOTAUTHRCOUT
rm -f rootauthrc.tmp
result "done"

#---------------------------------------------------------------------
# etc/system.rootdaemonrc
#
message "Writing $ROOTDAEMONRCOUT"
sed -e "s|@havesrp@|$havesrp|"             \
    -e "s|@havekrb5@|$havekrb5|"           \
    -e "s|@haveglobus@|$haveglobus|"       \
   < rootdaemonrc.tmp > $ROOTDAEMONRCOUT
rm -f rootdaemonrc.tmp
result "done"

#---------------------------------------------------------------------
# etc/root.mimes
#
message "Writing $MIMEOUT"
if test "$platform" = "win32" ; then
   cp -f $MIMEWIN32IN $MIMEOUT
else
   cp -f $MIMEUNIXIN $MIMEOUT
fi
result "done"

#---------------------------------------------------------------------
# etc/daemons/rootd.rc.d
#
message "Writing $ROOTDOUT"
sed -e "s|@bindir@|$bindir|" \
    < rootd.tmp > $ROOTDOUT
chmod a+x $ROOTDOUT
rm -f rootd.tmp
result "done"

#---------------------------------------------------------------------
# etc/daemons/rootd.xinetd
#
message "Writing $ROOTDXINETDOUT"
sed -e "s|@bindir@|$bindir|" \
    -e "s|@prefix@|$prefix|" \
    < rootd.xinetd.tmp > $ROOTDXINETDOUT
rm -f rootd.xinetd.tmp
result "done"

#---------------------------------------------------------------------
# etc/daemons/proofd.rc.d
#
message "Writing $PROOFDOUT"
sed -e "s|@bindir@|$bindir|" \
    < proofd.tmp > $PROOFDOUT
chmod a+x $PROOFDOUT
rm -f proofd.tmp
result "done"

#---------------------------------------------------------------------
# etc/daemons/proofd.xinetd
#
message "Writing $PROOFDXINETDOUT"
sed -e "s|@bindir@|$bindir|" \
    -e "s|@prefix@|$prefix|" \
    < proofd.xinetd.tmp > $PROOFDXINETDOUT
rm -f proofd.xinetd.tmp
result "done"

#---------------------------------------------------------------------
# etc/daemons/xrootd.rc.d
#
message "Writing $XROOTDOUT"
sed -e "s|@bindir@|$bindir|" \
    < xrootd.tmp > $XROOTDOUT
chmod a+x $XROOTDOUT
rm -f xrootd.tmp
result "done"

#---------------------------------------------------------------------
# etc/daemons/olbd.rc.d
#
message "Writing $OLBDOUT"
sed -e "s|@bindir@|$bindir|" \
    < olbd.tmp > $OLBDOUT
chmod a+x $OLBDOUT
rm -f olbd.tmp
result "done"

#---------------------------------------------------------------------
# bin/memprobe
#
message "Writing $MEMPROBEOUT"
if test -x /usr/bin/env ; then
   perlexe="/usr/bin/env perl"
else
   perlexe=`$cwhich perl`
fi
sed -e "s|@perl@|$perlexe|"                \
   < memprobe.tmp > $MEMPROBEOUT
rm -f memprobe.tmp
chmod 755 $MEMPROBEOUT
result "done"

#---------------------------------------------------------------------
# build/misc/root-help.el
#
message "Writing $ROOTHELPOUT"
sed -e "s|@bindir@|$bindir|"           \
    -e "s|@incdir@|$incdir|"           \
    < $ROOTHELPIN > $ROOTHELPOUT
result "done"

#---------------------------------------------------------------------
# macros/html.C
#
message "Writing $HTMLOUT"
sed_args=
for opt in $options; do
   sed_args="${sed_args} -e s/@$opt@/"
   if eval "test x$`eval echo $opt` = xyes"; then
      sed_args="${sed_args}kTRUE"
   else
      sed_args="${sed_args}kFALSE"
   fi
   sed_args="${sed_args}/g"
done
sed $sed_args < $HTMLIN > $HTMLOUT
result done

#---------------------------------------------------------------------
# bin/thisroot.sh and bin/thisroot.csh
#
message "Writing $THISROOTSHOUT"
cp -f $THISROOTSHIN $THISROOTSHOUT
result "done"
message "Writing $THISROOTCSHOUT"
cp -f $THISROOTCSHIN $THISROOTCSHOUT
result "done"

#---------------------------------------------------------------------
# config.status
#
message "Writing config.status"
configargs=`echo $configargs | sed 's,\\\,\\\\,g'`
echo "$configargs" > config.status
result done

#---------------------------------------------------------------------
# for reconfigure
#
touch Makefile

######################################################################
#
# FAT conversion in test/tutorials
#
# On win32 convert all files in tutorials and test to \r\n convention
# (only if CVS directory does not exist, otherwise cvs will already
# have made the conversion).
#
if test "x$platform" = "xwin32"  && test ! -d CVS ; then
   message "Converting files in tutorials and test to DOS format"
   for i in tutorials/*.C tutorials/*.sql test/*.cxx test/*.h \
            test/Makefile* test/README etc/system.rootrc
   do
      sed 's/$//' $i > r__tmp
      touch -r $i r__tmp
      mv -f r__tmp $i
   done
   echo "done"
fi

######################################################################
#
# Show successful configure options
#
enabled_options=""
for opt in $options; do
   if eval "test x$`eval echo $opt` = xyes"; then
      thisopt=`echo $opt | sed 's,^enable_,,'`
      if test "x$enabled_options" = "x"; then
         enabled_options="$thisopt"
      else
         enabled_options="$enabled_options, $thisopt"
      fi
   fi
done
if test "x$enabled_options" != "x"; then
   echo ""
   result "Enabled support for ${enabled_options}."
fi

######################################################################
#
# Warning about recommended build options
#
echo ""
if test "x$enable_opengl" = "xno" ; then
    result "To build the ROOT OpenGL add-on library see README/INSTALL."
    echo ""
    echo ""
fi

######################################################################
#
### echo %%% Final instructions
#
# List the possible Makefiles
#
if test "x$nohowto" = "xyes" ; then
    exit 0
fi

result "To build ROOT type:"
result ""
result "   $gnumake"
result "   $gnumake install"
result ""

exit 0
back to top