https://github.com/root-project/root
Raw File
Tip revision: 2794476700c916c4316b68570a2e7772dc7c9e5f authored by Pere Mato on 26 November 2014, 10:18:04 UTC
Update ROOT version files to v6.02/02
Tip revision: 2794476
configure
#!/bin/bash
#
# 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
found_ext=
show_pkglist=no
fail_on_missing=no
noact="no"
nohowto="no"
logfile=config.log
altcc=
altcxx=
altf77=
altld=
altccset=
gcctoolchain=
host=

deprecated_options="         \
   enable_mathcore           \
   enable_cern               \
   enable_editline           \
   enable_cintex             \
   enable_reflex             \
   enable_cxx11              \
"

options="                    \
   enable_afdsmgrd           \
   enable_afs                \
   enable_alien              \
   enable_alloc              \
   enable_asimage            \
   enable_astiff             \
   enable_bonjour            \
   enable_builtin_afterimage \
   enable_builtin_ftgl       \
   enable_builtin_freetype   \
   enable_builtin_glew       \
   enable_builtin_pcre       \
   enable_builtin_zlib       \
   enable_builtin_lzma       \
   enable_builtin_llvm       \
   enable_libcxx             \
   enable_castor             \
   enable_chirp              \
   enable_cocoa              \
   enable_davix              \
   enable_dcache             \
   enable_explicitlink       \
   enable_fink               \
   enable_fftw3              \
   enable_fitsio             \
   enable_gviz               \
   enable_gdml               \
   enable_genvector          \
   enable_geocad             \
   enable_gfal               \
   enable_glite              \
   enable_globus             \
   enable_gsl_shared         \
   enable_hdfs               \
   enable_http               \
   enable_krb5               \
   enable_ldap               \
   enable_mathmore           \
   enable_memstat            \
   enable_minuit2            \
   enable_monalisa           \
   enable_mysql              \
   enable_odbc               \
   enable_opengl             \
   enable_oracle             \
   enable_pgsql              \
   enable_pythia6            \
   enable_pythia8            \
   enable_python             \
   enable_qt                 \
   enable_qtgsi              \
   enable_roofit             \
   enable_ruby               \
   enable_rfio               \
   enable_rpath              \
   enable_sapdb              \
   enable_shadowpw           \
   enable_shared             \
   enable_soversion          \
   enable_sqlite             \
   enable_srp                \
   enable_ssl                \
   enable_table              \
   enable_tmva               \
   enable_unuran             \
   enable_vc                 \
   enable_vdt                \
   enable_werror             \
   enable_winrtdebug         \
   enable_x11                \
   enable_xft                \
   enable_xml                \
   enable_xrootd             \
"

ENABLEALL="no"
DEFAULTENABLE="yes"
for flag in "$@"; do
    case $flag in
    --all)
       ENABLEALL="yes"
       break ;;
    --gminimal)
       DEFAULTENABLE="no"
       MINIMALENABLE="enable_x11"
       break ;;
     --minimal)
       DEFAULTENABLE="no"
       MINIMALENABLE=""
       break ;;
    esac
done

#
# This sets all options to "yes" unless --minimal is specified.
# We turn off those we don't want on per default explictly afterwards.
#
for c in $options $deprecated_options; do
    case ${c} in
        ${MINIMALENABLE}) eval ${c}="yes" ;;
        enable_shared)    eval ${c}="yes" ;;
        *)                eval ${c}="${DEFAULTENABLE}" ;;
    esac
done
for c in $options ; do eval ${c}_explicit="" ; done

enable_cxx11=yes
enable_libcxx=no
enable_cocoa=
enable_afs=no
enable_alloc=no
enable_gdml=no
enable_geocad=no
enable_globus=no
enable_explicitlink=no
enable_gsl_shared=no
enable_http=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_thread=yes        # cannot be disabled (not in above options list)
enable_unuran=no
enable_vc=no
enable_werror=no
enable_winrtdebug=
enable_builtin_freetype=no
enable_builtin_ftgl=no
enable_builtin_glew=no
enable_builtin_pcre=no
enable_builtin_zlib=no
enable_builtin_lzma=no
enable_builtin_llvm=yes
enable_afdsmgrd=no

if test "x$ENABLEALL" = "xyes"; then
    enable_gdml=yes
    enable_geocad=yes
    enable_http=yes
    enable_qt=yes
    enable_qtgsi=yes
    enable_roofit=yes
    enable_minuit2=yes
    #enable_ruby=yes     #not supported in ROOT v6.0.0 yet
    enable_table=yes
    enable_unuran=yes
    enable_vc=yes
    enable_vdt=yes
fi

# Remove old log file
rm -f $logfile

#
# ./configure arguments and defaults set via supported env vars
#
envvars="
THREAD           \
ZLIB             \
LIBTIFF          \
LIBJPEG          \
LIBPNG           \
LZMA             \
OPENGL           \
MYSQL            \
ORACLE           \
PGSQL            \
SQLITE           \
QTDIR            \
SAPDB            \
RFIO             \
CASTOR           \
GFAL             \
GSL              \
HDFS             \
PYTHIA6          \
PYTHIA8          \
FFTW3            \
CFITSIO          \
GVIZ             \
PYTHONDIR        \
DCACHE           \
CHIRP            \
DNSSD            \
AVAHI            \
ALIEN            \
ASIMAGE          \
LDAP             \
GLOBUS_LOCATION  \
GLITE            \
MEMSTAT          \
MONALISA         \
SRP              \
SSL              \
AFS              \
ROOFIT           \
MINUIT2          \
TABLE            \
XMLDIR           \
CASROOT          \
VC               \
DAVIX            \
"
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_libpic() {
    # This function will try to find out if an archive library [$1]
    # contains relocatable code. Currently works only for linux.
    # The result of the check is stored in is_libpic, 1 if true,
    # 0 otherwise, which should be immediately copied, since the variable
    # will be overwritten at next invocation of this function.

    is_libpic=1

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

    case $platform in
    linux) ;;
    *)     return 0;
           ;;
    esac

    # Save arguments in logical names
    chklibpic=$1
    if [ "x`basename $chklibpic .a`" != "x`basename $chklibpic`" ]; then
        # we have an archive .a file
        logmsg "Checking if $chklibpic contains relocatable code"
        logmsg " objdump -r $chklibpic | grep -v ' .debug_' | grep 'R_X86_64_32'"
        objdump -r $chklibpic | grep -v ' .debug_' | grep 'R_X86_64_32' > /dev/null 2>& 1
        ret=$?
        logmsg " result: $ret"
        if test $ret -eq 0 ; then
            is_libpic=0
            logmsg " is not a relocatable library"
        fi
    fi
}

#_____________________________________________________________________
check_libcompat() {
    # This function will try to find out if a library [$1] contains
    # compatible 64 bit or 32 bit code matching the selected architecture.
    # Currently only MacOS X supports universal libs.
    # The result of the check is stored in is_libcompat, 1 if true,
    # 0 otherwise, which should be immediately copied, since the variable
    # will be overwritten at next invocation of this function.

    is_libcompat=0
    is_libnotcompat=0
    ret=0

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

    # Save arguments in logical names
    chklibcompat=$1
    logmsg "Checking if $chklibcompat contains compatible code"

    case $arch in
    macosx)
        logmsg " lipo $chklibcompat -verify_arch i386"
        if lipo $chklibcompat -verify_arch i386 ; then
            ret=1
        fi
        ;;
    macosx64)
        logmsg " lipo $chklibcompat -verify_arch x86_64"
        if lipo $chklibcompat -verify_arch x86_64 ; then
            ret=1
        fi
        ;;
    esac

    logmsg " result: $ret"
    if test $ret -eq 1 ; then
        is_libcompat=1
        logmsg " is a compatible library"
    else
        is_libnotcompat=1
        logmsg " is a not-compatible library"
    fi
}

#_____________________________________________________________________
check_libcxxcompat() {
    # This function will try to find out if a library [$1] is linked
    # against a compatible C++ run-time library (either libstdc++ or libc++).
    # Currently only MacOS X and Linux support libc++ and libstdc++.
    # The result of the check is stored in is_libcxxcompat, 1 if true,
    # 0 otherwise, which should be immediately copied, since the variable
    # will be overwritten at next invocation of this function.
    # To skip this check, in case std types are not used in the public
    # API of the library, set skipchecklibcxxcompat="yes".

    is_libcxxcompat=1
    ret=0

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

    # Can we skip the check in case library has no std C++ in public API
    if test "x$skipchecklibcxxcompat" = "xyes"; then
        skipchecklibcxxcompat=""
        logmsg "check_libcxxcompat: skipping check for $1"
        return
    fi

    # Save arguments in logical names
    chklibcxxcompat=$1
    logmsg "Checking if $chklibcxxcompat is linked against compatible C++ run-time"

    if test "x$enable_libcxx" = "xyes"; then
        case $arch in
        macosx*)
            logmsg " otool -L $chklibcxxcompat | grep libstdc++"
            if otool -L $chklibcxxcompat | grep 'libstdc++' > /dev/null 2>& 1 ; then
                ret=1
            fi
            ;;
        linux*)
            logmsg " ldd $chklibcxxcompat | grep libstdc++"
            if ldd $chklibcxxcompat | grep 'libstdc++' > /dev/null 2>& 1 ; then
                ret=1
            fi
            ;;
        esac
    else
        case $arch in
        macosx*)
            logmsg " otool -L $chklibcxxcompat | grep libc++"
            if otool -L $chklibcxxcompat | grep 'libc++' > /dev/null 2>& 1 ; then
                ret=1
            fi
            ;;
        linux*)
            logmsg " ldd $chklibcxxcompat | grep libc++"
            if ldd $chklibcxxcompat | grep 'libc++' > /dev/null 2>& 1 ; then
                ret=1
            fi
            ;;
        esac
    fi

    logmsg " result: $ret"
    if test $ret -eq 1 ; then
        is_libcxxcompat=0
        logmsg " is linked against not-compatible C++ run-time library"
    else
        logmsg " is linked against compatible C++ run-time library"
    fi
}

#_____________________________________________________________________
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 and solaris.
    # 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
    ret=0

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

    filearg=
    case $platform in
        linux)   filearg="-L" ;;
        solaris) ;;
        *)       return 1;;
    esac

    # Save arguments in logical names
    chklib64=$1
    logmsg "Checking if $chklib64 is a 64-bit library"
    if [ "x`basename $chklib64 .a`" != "x`basename $chklib64`" ]; then
        # we have an archive .a file
        if [ "x$platform" = "xlinux" ]; then
            logmsg " objdump -a $chklib64 | grep 'x86-64'"
            if objdump -a $chklib64 | grep 'x86-64' > /dev/null 2>& 1 ; then
                ret=1
            fi
        fi
        if [ "x$platform" = "xsolaris" ]; then
            chklib64file=`ar t $chklib64 | awk '{if (NR == 2) print $1}'`
            logmsg " ar x $chklib64 $chklib64file"
            ar x $chklib64 $chklib64file
            logmsg " file $filearg $chklib64file | grep '64-bit'"
            if file $filearg $chklib64file | grep '64-bit' > /dev/null 2>& 1 ; then
                ret=1
            fi
            rm -f $chklib64file
        fi
    else
        if file $filearg $chklib64 | grep 'ASCII' > /dev/null 2>& 1 ; then
            check_link $chklib64
            ret=$link_result
        else
            logmsg " file $filearg $chklib64 | grep '64-bit'"
            if file $filearg $chklib64 | grep '64-bit' > /dev/null 2>& 1 ; then
                ret=1
            fi
        fi
    fi
    logmsg " result: $ret"
    if test $ret -eq 1 ; 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" or "staticonly", 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="$*"

    if test ! "x$iossdk" = "x" ; then
        sdklibs=""
        for i in $libdirs; do
            #if test $i = "/usr/lib"; then
                sdklibs="$sdklibs ${iossdk}${i}"
            #else
            #    sdklibs="$sdklibs $i"
            #fi
        done
        libdirs="$sdklibs"
    fi

    # 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
    found_ext=

    # 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="$libs $slibs"
    elif test "x$shared" = "xstaticonly" ; then
        libs="$libs"
    else
        libs="$slibs $libs"
    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$checklinux64" = "xyes" ; then
            i64=`echo $i | sed -e 's|lib$|lib64|' -e 's|lib/|lib64/|'`
            i="$i64 $i"
        fi
        # look first in the DEB_HOST_MULTIARCH directories
        if test "x$debmultiarch" != "x" ; then
            i64=`echo $i | sed "s|\(lib\)$|\1/$debmultiarch|"`
            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
        # look first in the amd64 directories
        if test "x$checksolaris64" = "xyes" ; then
            i64=`echo $i | sed 's|\(lib\)|\1/amd64|'`
            i="$i64 $i"
        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 $l"
                # 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
                            if test "x$checklibcompat" = "xyes" ; then
                                check_libcompat $n
                                if test $is_libcompat -eq 0 ; then
                                    break 4
                                fi
                            fi
                            if test "x$checklibcxxcompat" = "xyes" ; then
                                check_libcxxcompat $n
                                if test $is_libcxxcompat -eq 0 ; then
                                    break 4
                                fi
                            fi
                            found_dir=$l
                            found_lib=$j
                            if test "x$arch" = "xlinux"; then
                               check_lib64 $n
                            else
                               is_lib64=0
                            fi
                            if test $is_lib64 -eq 1 ; then
                                found_dir=no
                                found_lib=no
                            else
                                # 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
                        fi
                    else
                        logmsg "  $j not found in $l"
                    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=""
        found_raw_lib=""
        logmsg " library not found"
    else
        found_ext=`echo $found_lib | sed 's|^lib\(.*\)\.\(.*\)|\2|'`
        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_raw_lib=${found_lib}
            found_lib=${found_dir}/${found_lib}
            found_raw_dir=${found_dir}
            found_dir=""
        else
            found_raw_lib=${found_lib}
            if test ! "x$shared" = "xstaticonly" ; then
                found_lib=`echo $found_lib | sed 's|^lib\(.*\)\..*|-l\1|'`
            fi
            found_raw_dir=${found_dir}
            if test ! "x$shared" = "xstaticonly" ; then
                found_dir=-L${found_dir}
            fi
            # 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
            if test "x$debmultiarch" != "x" ; then
                if test "x$found_dir" = "x-L/usr/lib/$debmultiarch" ; then
                    found_dir=""
                fi
            fi
            if test "x$checksolaris64" = "xyes" ; then
                if test "x$found_dir" = "x-L/usr/lib/amd64" || \
                   test "x$found_dir" = "x-L/usr/lib/64" ; then
                    found_dir=""
                fi
            fi
            if test "x$checkhpux64" = "xyes" ; then
                if test "x$found_dir" = "x-L/usr/lib/hpux64" ; then
                    found_dir=""
                fi
            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="$*"

    if test ! "x$iossdk" = "x" ; then
        sdkhdrs=""
        for i in $hdrdirs; do
            #if test $i = "/usr/include"; then
                sdkhdrs="$sdkhdrs ${iossdk}${i}"
            #else
            #    sdkhdrs="$sdkhdrs $i"
            #fi
        done
        hdrdirs="$sdkhdrs"
    fi

    # 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_link() {
    # This function will try to link a specific library [$1] in an
    # optional directory [$2] and test, optionally, for a specified
    # symbol [$3].
    # The result of the check is stored in link_result, 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 $# -lt 1 ; then
        echo "check_link: need at least one argument"
        link_result=0
        return 1
    fi

    # save arguments in logical names
    linklib="$1"; shift
    linkdir=""
    if test $# -ge 1 ; then
        linkdir="$1"; shift
    fi
    linksymbol=""
    if test $# -ge 1 ; then
        linksymbol="$1"
    fi

    if test "x$linksymbol" = "x" ; then
       if test "x$linkdir" = "x" ; then
          logmsg " trying to link against $linklib"
       else
          logmsg " trying to link against $linkdir $linklib"
       fi
       cat <<EOF > conftest.mk
include ${ac_srcdir}/config/Makefile.${arch}
CC  = ${altcc}
CXX = ${altcxx}
LD  = ${altld}
conftest: conftest.c
	\$(CC) \$(CFLAGS) \$(LDFLAGS) \$< -o \$@ $linkdir $linklib

conftest.c:
	echo "int main() { return 0; }" > \$@
EOF
    else
       if test "x$linkdir" = "x" ; then
           logmsg " trying to resolve symbol $linksymbol in $linklib"
       else
           logmsg " trying to resolve symbol $linksymbol in $linkdir $linklib"
       fi
       cat <<EOF > conftest.mk
include ${ac_srcdir}/config/Makefile.${arch}
CC  = ${altcc}
CXX = ${altcxx}
LD  = ${altld}
conftest:conftest.c
	\$(CC) \$(CFLAGS) \$(LDFLAGS) \$< -o \$@ $linkdir $linklib

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

    unset linklib
    unset linkdir
    unset linksymbol
}

#_____________________________________________________________________
check_cxxopt() {
    # This function will try to compile with a specific cxx compiler
    # option [$1]. The result of the check is stored in cxxopt_result,
    # 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 $# -lt 1 ; then
        echo "check_cxxopt: need at least one argument"
        cxxopt_result=0
        return 1
    fi

    # save arguments in logical names
    cxxopt="$1"; shift

    logmsg " trying to compile with option $cxxopt"
    cat <<EOF > conftest.mk
include ${ac_srcdir}/config/Makefile.${arch}
CC  = ${altcc}
CXX = ${altcxx}
LD  = ${altld}
conftest: conftest.cxx
	\$(CXX) \$(CFLAGS) $cxxopt \$(LDFLAGS) \$< -o \$@

conftest.cxx:
	echo "int main() { return 0; }" > \$@
EOF

    $gnumake -f conftest.mk >> $logfile 2>&1
    if test $? -eq 0 ; then
        cxxopt_result=1
        logmsg " Compilation OK"
    else
        cxxopt_result=0
        logmsg " Failed code was"
        cat conftest.mk >> $logfile
    fi
    rm -rf conftest.cxx conftest.mk conftest conftest.dSYM

    unset cxxopt
}

#_____________________________________________________________________
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
        unset symbol
        unset symbollib
        unset symboldir
        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 .dylib"
    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$checklinux64" = "xyes" ; then
        usrlib="/usr/lib64 $usrlib"
    fi
    # look first in the DEB_HOST_MULTIARCH directories
    if test "x$debmultiarch" != "x" ; then
        usrlib="/usr/lib/$debmultiarch $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
    # look first in the amd64 directories
    if test "x$checksolaris64" = "xyes" ; then
        usrlib="/usr/lib/amd64 $usrlib"
    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"
       unset symbol
       unset symbollib
       unset symboldir
       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 to link"
            # stripped library - only safe test is to link against the library
            check_link $symbolfile "" $symbol
            found_symbol=$link_result
        else
            found_symbol=0
        fi
    fi
    if test $found_symbol -eq 1 ; then
        result "ok"
    else
        result "no"
    fi

    unset symbol
    unset symbollib
    unset symboldir
}

#_____________________________________________________________________
check_comp() {
    # This function will try to locate the default or alt compiler
    # type [$1] in the PATH.
    # The result of the check is stored in found_comp, 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 1 ; then
        echo "check_comp: not 1 argument"
        found_comp=0
        return 1
    fi

    comptype="$1"
    nocomp=""

    if test "x$comptype" = "xLD" ; then
       message "Checking for ${compmsgextra}linker (LD)"
    else
       message "Checking for ${compmsgextra}$comptype compiler"
    fi

    found_comp=0
    case $comptype in
    C)
        if test "x$altcc" = "x" ; then
            if `$gnumake -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showcc > /dev/null 2>&1` ; then
                altcc=`$gnumake -s -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showcc`
            else
                altcc=`grep '^CC ' ${ac_srcdir}/config/Makefile.$arch | awk '{ if (NF==3) {print $3; exit 0} }'`
            fi
            if test "x$arch" = "xwin32" ; then
                altccorg="cl"
                altcctmp="$altcc"
                altcc="$altccorg"
            fi
        fi
        altcc1=`echo "$altcc" | awk '{print $1}'`
        if `$cwhich $altcc1 > /dev/null 2>&1` ; then
            found_comp=1
            if test ! "x$altcctmp" = "x" ; then
                altcc="$altcctmp"
            fi
            result "$altcc"
        else
            nocomp="$altcc"
        fi
        ;;
    C++)
        if test "x$altcxx" = "x" ; then
            if `$gnumake -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showcxx > /dev/null 2>&1` ; then
                altcxx=`$gnumake -s -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showcxx`
            else
                altcxx=`grep '^CXX ' ${ac_srcdir}/config/Makefile.$arch | awk '{ if (NF==3) {print $3; exit 0} }'`
            fi
            if test "x$arch" = "xwin32" ; then
                altcxxorg="cl"
                altcxxtmp="$altcxx"
                altcxx="$altcxxorg"
            fi
        fi
        altcxx1=`echo "$altcxx" | awk '{print $1}'`
        if `$cwhich $altcxx1 > /dev/null 2>&1` ; then
            found_comp=1
            if test ! "x$altcxxtmp" = "x" ; then
                altcxx="$altcxxtmp"
            fi
            result "$altcxx"
        else
            nocomp="$altcxx"
        fi
        ;;
    LD)
        if test "x$altld" = "x" ; then
            if `$gnumake -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showld > /dev/null 2>&1` ; then
                altld=`$gnumake -s -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showld`
            else
                altld=`grep '^LD ' ${ac_srcdir}/config/Makefile.$arch | awk '{ if (NF==3) {print $3; exit 0} }'`
            fi
            if test "x$arch" = "xwin32" ; then
                altldorg="link"
                altldtmp="$altld"
                altld="$altldorg"
            fi
            if test "x$arch" = "xwin32gcc" ; then
                altldorg="g++"
                altldtmp="$altld"
                altld="$altldorg"
            fi
        fi
        altld1=`echo "$altld" | awk '{print $1}'`
        if `$cwhich $altld1 > /dev/null 2>&1` ; then
            found_comp=1
            if test ! "x$altldtmp" = "x" ; then
                altld="$altldtmp"
            fi
            result "$altld"
        else
            nocomp="$altld"
            altldorg=""
        fi
        ;;
    F77)
        if test "x$altf77" = "x" ; then
            if `$gnumake -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showf77 > /dev/null 2>&1` ; then
                altf77=`$gnumake -s -f ${ac_srcdir}/config/Makefile.$arch ROOT_SRCDIR=${ac_srcdir} CONFIGURE=yes showf77`
            else
                altf77=`grep '^F77 ' ${ac_srcdir}/config/Makefile.$arch | awk '{ if (NF==3) {print $3; exit 0} }'`
            fi
            if test "x$arch" = "xwin32" ; then
                altf77org="fl32"
                altf77tmp="$altf77"
                altf77="$altf77org"
            fi
        fi
        altf771=`echo "$altf77" | awk '{print $1}'`
        if `$cwhich $altf771 > /dev/null 2>&1` ; then
            found_comp=1
            if test ! "x$altf77tmp" = "x" ; then
                altf77="$altf77tmp"
            fi
            result "$altf77"
        else
            nocomp="$altf77"
            altf77org=""
        fi
        ;;
    esac

    if test $found_comp -eq 0 ; then
       result "no $comptype compiler $nocomp found"
    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" = "xyes" ; then return 0 ; fi
    if test ! "x$feat" = "xyes" ; then
        result $emsg
        exit 1
    fi
}

invoke_preprocessor() {
    # This function will try to preprocess a given file. The result is stored in
    # preprocessor_output, which should be immediately copied, since the
    # variable will be overwritten at next invocation of this function.

    cat > conftest.h
    preprocessor_output=

    logmsg " preprocessing"
    cat <<EOF > conftest.mk
include ${ac_srcdir}/config/Makefile.${arch}
CXX = ${altcxx}
conftest.out: conftest.h
	\$(CXX) -E \$< -o \$@
EOF

    $gnumake -f conftest.mk >> $logfile 2>&1
    if test $? -eq 0 && test -f conftest.out; then
        preprocessor_output="`grep '^[^#]' conftest.out`"
        logmsg " Preprocessing OK"
    else
        logmsg " Failed code was"
        cat conftest.mk $1 >> $logfile
    fi
    rm -rf conftest.mk conftest.out conftest.h
}

#_____________________________________________________________________
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, they 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            ;;
        freebsd*:*:[789]*)     arch=freebsd7        ;;
        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:x32:*)           arch=linuxx32gcc     ;;
        linux:arm*:*)          arch=linuxarm        ;;
        linux:hppa*:*)         arch=linux           ;;
        linux:sparc*:*)        arch=linux           ;;
        linux:parisc*:*)       arch=linuxhppa       ;;
        linux:ppc64*:*)        arch=linuxppc64gcc   ;;
        linux:ppc*:*)          arch=linuxppcgcc     ;;
        linux:i*86:*)          arch=linux           ;;
        linux:s39*:*)          arch=linux           ;;
        openbsd*:*:*)          arch=openbsd         ;;
        lynx:*:*)              arch=lynxos          ;;
        darwin:power*:*)       arch=macosx          ;;
        darwin:*86*:*)         arch=macosx          ;;
        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           ;;
        mingw32_*:*86:*)       arch=win32           ;;
        *)
            echo "Attempts at guessing your architecture failed."
            echo "(triplet is $arch:$chip:$rele)"
            echo "Please specify the architecture as the first argument."
            echo "Do '$0 --help' for a list of available architectures."
            echo "Or file a bug at https://savannah.cern.ch/projects/savroot/"
            echo "including the full config.log and a dump of"
            echo "  touch dummy_file.c; gcc -E -dM dummy_file.c"
            exit 1
            ;;
    esac
    if [ "$arch" = "macosx" ]; then
       if [ `sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2` -ge 5 ]; then
          if `sysctl machdep.cpu.extfeatures | grep "64" > /dev/null  2>&1` ; then
             arch=macosx64
          fi
       fi
    fi
    if [ "$arch" = "solarisCC5" -a "$chip" = "i86pc" ]; then
       if `isainfo -b | grep "64" > /dev/null  2>&1` ; then
          arch=solaris64CC5
       fi
    fi
    logmsg "$arch"
}

######################################################################
#
### 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 %%% Find the source directory
#
message "Checking for source directory"
ac_pwd=`pwd` && test -n "$ac_pwd" && ls_di=`ls -di .` &&
pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
   { echo "$0: error: Working directory cannot be determined" >&2
      exit 1; }
test "x$ls_di" = "x$pwd_ls_di" ||
  { echo "$0: error: pwd does not report name of working directory" >&2
      exit 1; }

# Find the source files
# Try the directory containing this script, then the parent directory.
ac_confdir=`dirname -- "$0" ||
 expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
      X"$0" : 'X\(//\)[^/]' \| \
      X"$0" : 'X\(//\)$' \| \
      X"$0" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$0" |
 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
         s//\1/
         q
       }
       /^X\(\/\/\)[^/].*/{
         s//\1/
         q
       }
       /^X\(\/\/\)$/{
         s//\1/
         q
       }
       /^X\(\/\).*/{
         s//\1/
         q
       }
       s/.*/./; q'`
ac_srcdir=$ac_confdir
ac_unique_file="core/base/src/TObject.cxx"
if test ! -r "$ac_srcdir/$ac_unique_file"; then
   ac_srcdir=..
fi
if test ! -r "$ac_srcdir/$ac_unique_file"; then
   test ac_srcdir="$ac_confdir or .."
   { echo "$0: error: cannot find sources ($ac_unique_file) in $ac_srcdir" >&2
     exit 1; }
fi
ac_msg="sources are in $ac_srcdir, but \`cd $ac_srcdir' does not work"
ac_abs_confdir=`(
        cd "$ac_srcdir" && test -r "./$ac_unique_file" || { echo "$0: error: $ac_msg" >&2
   exit 1; }
   pwd)`

# When building in place, set ac_srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
   ac_srcdir=.
fi
# Remove unnecessary trailing slashes from ac_srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $ac_srcdir in
*/) ac_srcdir=`expr "X$ac_srcdir" : 'X\(.*[^/]\)' \| "X$ac_srcdir" : 'X\(.*\)'`;;
esac

top_builddir=$ac_pwd

case $ac_srcdir in
.) # we are building in place
   top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* )  # absolute name
   top_srcdir=$ac_srcdir ;;
*) # Relative name
   top_srcdir=$ac_pwd/$ac_srcdir ;;
esac

# populate build directory
if test ! "x$ac_srcdir" = "x."; then
   for d in config bin include build/misc main/src etc/daemons macros; do
      test ! -d $d && mkdir -p $d
   done
   cp -f ${ac_srcdir}/Makefile .
   cp -f ${ac_srcdir}/LICENSE .
fi
result "$top_srcdir"

###################################################################
#
### echo %%% Some skeleton and config files
#
ARCHS=${ac_srcdir}/config/ARCHS
MAKEIN=${ac_srcdir}/config/Makefile.in
MAKEOUT=config/Makefile.config
MAKECOMPIN=${ac_srcdir}/config/Makefile-comp.in
MAKECOMPOUT=config/Makefile.comp
CONFIGUREIN=${ac_srcdir}/config/RConfigure.in
CONFIGUREOUT=include/RConfigure.h
CONFIGOPTIN=${ac_srcdir}/config/RConfigOptions.in
CONFIGOPTOUT=include/RConfigOptions.h
RCONFIN=${ac_srcdir}/config/root-config.in
RCONFOUT=bin/root-config
ROOTRCIN=${ac_srcdir}/config/rootrc.in
ROOTRCOUT=etc/system.rootrc
ROOTAUTHRCIN=${ac_srcdir}/config/rootauthrc.in
ROOTAUTHRCOUT=etc/system.rootauthrc
ROOTDAEMONRCIN=${ac_srcdir}/config/rootdaemonrc.in
ROOTDAEMONRCOUT=etc/system.rootdaemonrc
MEMPROBEIN=${ac_srcdir}/config/memprobe.in
MEMPROBEOUT=bin/memprobe
MIMEUNIXIN=${ac_srcdir}/config/mimes.unix.in
MIMEWIN32IN=${ac_srcdir}/config/mimes.win32.in
MIMEOUT=etc/root.mimes
ROOTDIN=${ac_srcdir}/config/rootd.in
ROOTDOUT=etc/daemons/rootd.rc.d
ROOTDXINETDIN=${ac_srcdir}/config/rootd.xinetd.in
ROOTDXINETDOUT=etc/daemons/rootd.xinetd
PROOFDIN=${ac_srcdir}/config/proofd.in
PROOFDOUT=etc/daemons/proofd.rc.d
PROOFDXINETDIN=${ac_srcdir}/config/proofd.xinetd.in
PROOFDXINETDOUT=etc/daemons/proofd.xinetd
PROOFSERVIN=${ac_srcdir}/config/proofserv.in
PROOFSERVOUT=main/src/proofserv.sh
XPROOFDIN=${ac_srcdir}/config/xproofd.in
XPROOFDOUT=main/src/xproofd.sh
ROOTHELPIN=${ac_srcdir}/config/root-help.el.in
ROOTHELPOUT=build/misc/root-help.el
ROOTSIN=${ac_srcdir}/config/roots.in
ROOTSOUT=main/src/roots.sh
HTMLIN=${ac_srcdir}/config/html.C.in
HTMLOUT=macros/html.C
THISROOTSHIN=${ac_srcdir}/config/thisroot.sh
THISROOTSHOUT=bin/thisroot.sh
THISROOTCSHIN=${ac_srcdir}/config/thisroot.csh
THISROOTCSHOUT=bin/thisroot.csh
THISROOTBATIN=${ac_srcdir}/config/thisroot.bat
THISROOTBATOUT=bin/thisroot.bat
SETXRDSHIN=${ac_srcdir}/config/setxrd.sh
SETXRDSHOUT=bin/setxrd.sh
SETXRDCSHIN=${ac_srcdir}/config/setxrd.csh
SETXRDCSHOUT=bin/setxrd.csh

# unset global command options that can cause havoc
unset GREP_OPTIONS

######################################################################
#
### 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, ...],
                   overrides the ROOTBUILD shell variable
   --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   (<prefix>/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 --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.

To reduce the output of configure by removing the trailing howto message, use:

   --nohowto

Use the flag:

  --fail-on-missing

to force configure to fail if a component that has been explicitly enabled
is missing some dependencies and can not be built.

enable/disable options, prefix with either --enable- or --disable-

  afdsmgrd           Dataset manager for PROOF-based analysis facilities
  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
  bonjour            Bonjour support, requires libdns_sd and/or Avahi
  builtin-afterimage Build included libAfterImage, or use system libAfterImage
  builtin-ftgl       Build included libFTGL, or use system libftgl
  builtin-freetype   Build included libfreetype, or use system libfreetype
  builtin-glew       Build included libGLEW, or use system libGLEW
  builtin-pcre       Build included libpcre, or use system libpcre
  builtin-zlib       Build included libz, or use system libz
  builtin-lzma       Build included liblzma, or use system liblzma
  libcxx             Build using libc++, required by clang option (MacOS X only, for the time being)
  castor             CASTOR support, requires libshift from CASTOR >= 1.5.2
  chirp              Chirp filesystem support, requires cctools >= 3.2.2
  cocoa              Use native Cocoa/Quartz graphics backend (MacOS X only)
  davix              DavIx library for HTTP/WEBDAV access
  dcache             dCache support, requires libdcap from DESY
  explicitlink       Explicitly link with all dependent libraries
  fink               Use libraries from an extra MacOS X package manager (Fink, MacPorts, ...) (default: enabled)
  fftw3              Fast Fourier Transform support, requires libfftw3
  fitsio             Read images and data from FITS files, requires cfitsio
  gviz               Graphs visualization support, requires graphviz
  gdml               GDML writer and reader
  geocad             ROOT-CAD Interface
  gfal               GFAL support, requires libgfal or libgfal2
  globus             Globus authentication support, requires Globus toolkit
  glite              gLite support, requires libglite-api-wrapper v.3 from GSI (https://subversion.gsi.de/trac/dgrid/wiki)
  gsl-shared         Enable linking against shared libraries for GSL (default no)
  hdfs               HDFS support; requires libhdfs from HDFS >= 0.19.1
  http               Build the HTTP server library
  krb5               Kerberos5 support, requires Kerberos libs
  ldap               LDAP support, requires (Open)LDAP libs
  genvector          Build the new libGenVector library
  mathmore           Build the new libMathMore extended math library, requires GSL (vers. >= 1.10)
  memstat            A memory statistics utility, helps to detect memory leaks
  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
  pgsql              PostgreSQL support, requires libpq
  pythia6            Pythia6 EG support, requires libPythia6
  pythia8            Pythia8 EG support, requires libPythia8 >= 8180
  python             Python ROOT bindings, requires python >= 2.5
  qt                 Qt graphics backend, requires libqt >= 4.8
  qtgsi              GSI's Qt integration, requires libqt >= 4.8
  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)
  sqlite             SQLite support, requires libsqlite3
  srp                SRP support, requires SRP source tree
  ssl                SSL encryption support, requires openssl
  table              Build libTable contrib library
  tmva               Build TMVA multi variate analysis library
  unuran             UNURAN - package for generating non-uniform random numbers
  vc                 Vc adds a few new types for portable and intuitive SIMD programming
  werror             Turn on -Werror on most systems to force warnings to be errors
  winrtdebug         Link against the Windows debug runtime library
  x11                X11 support
  xml                XML parser interface
  xrootd             Build xrootd-dependent plugins for remote file access and PROOF (if supported)
  xft                Xft support (X11 antialiased fonts)

minimal set of libraries, can be combined with above --enable-... options

  --minimal          Do not automatically search for support libraries
  --gminimal         Do not automatically search for support libraries, but include X11

maximal set of libraries, enables all optional packages

  --all              Do try to enable all optional support libraries

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

  afs                AFS support, location of AFS distribution
  afs-incdir         AFS support, location of AFS headers
  afs-libdir         AFS support, location of libafsrpc. libasauthent
  afs-shared         AFS support, controls usage of shared linkage AFS libraries {yes/no}
  alien-incdir       AliEn support, location of gapiUI.h
  alien-libdir       AliEn support, location of libapiUI
  alloc-libdir       Alternative memory allocator support, location of allocator lib
  alloc-lib          Alternative memory allocator support, allocator lib
  avahi-libdir       Bonjour support, location of Avahi libraries
  avahi-incdir       Bonjour support, location of Avahi headers
  castor-incdir      CASTOR support, location of stager_api.h
  castor-libdir      CASTOR support, location of libshift
  chirp-incdir       Chirp support, location of chirp_reli.h
  chirp-libdir       Chirp support, location of libchirp_client
  cppunit            Cppunit testing, directory of the cppunit installation
  davix-incdir       DavIx support, location of davix.hpp
  davix-libdir       DavIx support, location of libdavix
  dcap-incdir        dCache support, location of dcap.h
  dcap-libdir        dCache support, location of libdcap
  dnssd-libdir       Bonjour support, location of libdns_sd
  dnssd-incdir       Bonjour support, location of dns_sd.h
  finkdir            Prefix of extra MacOS X package manager (Fink, MacPorts, ...)
  ftgl-incdir        FTGL support, location of FTGL.h
  ftgl-libdir        FTGL support, location of libftgl
  fftw3-incdir       FFTW3 support, location of fftw3.h
  fftw3-libdir       FFTW3 support, location of libfftw3 (libfftw3-3 for windows)
  cfitsio-incdir     FITS support, location of fitsio.h
  cfitsio-libdir     FITS support, location of libcfitsio
  gviz-incdir        Graphviz support, location of gvc.h
  gviz-libdir        Graphviz support, location of libgvplugin_core
  gfal-incdir        GFAL support, location of gfal_api.h
  srm-ifce-incdir    GFAL support, location of gfal_srm_ifce_types.h
  glib2-incdir       GFAL support, location of glib-2.0 headers
  gfal-libdir        GFAL support, location of libgfal or libgfal2
  glew-incdir        GLEW support, location of glew.h
  glew-libdir        GLEW support, location of libGLEW
  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
  hdfs-incdir        HDFS support, location of hdfs.h
  hdfs-libdir        HDFS support, location of libhdfs
  iosvers            iOS SDK version (6.1, 7.0), default will be latest SDK
  jni-incdir         HDFS support, location of JNI headers
  jvm-libdir         HDFS support, location of JVM library
  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
  llvm-config        LLVM/clang for cling, location of llvm-config script
  macosxvers         OS X SDK version (10.8, 10.9), default will be latest SDK
  monalisa-incdir    Monalisa support, location of ApMon.h
  monalisa-libdir    Monalisa support, location of libapmoncpp
  mysql-incdir       MySQL support, location of mysql.h
  mysql-libdir       MySQL support, location of libmysqlclient
  occ-incdir         GEOCAD support, location of OpenCascade inc files
  occ-libdir         GEOCAD support, location of OpenCascade lib files
  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     PYTHIA6 support, location of libPythia6
  pythia8-incdir     PYTHIA8 support, location of Pythia8 includes
  pythia8-libdir     PYTHIA8 support, location of libpythia8.so
  python-incdir      Python support, location of Python.h
  python-libdir      Python support, location of libpython
  qt-incdir          Qt support, location of Qt/qglobal.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, libdpm or libshift
  sqlite-incdir      SQLite support, location of sqlite3.h
  sqlite-libdir      SQLite support, location of libsqlite3
  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                OpenSSL support, location of openssl installation
  ssl-incdir         OpenSSL support, location of openssl headers
  ssl-libdir         OpenSSL support, location of libssl
  ssl-shared         OpenSSL support, controls usage of shared linkage SSL libraries {yes/no}
  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
  xft-libdir         Xft support, path to libXft
  xext-libdir        Xext support, path to libXext
  xrootd             XROOTD support, path to XROOTD distribution
  xrootd-incdir      XROOTD support, path to XROOTD header files (XrdVersion.hh, ...)
  xrootd-libdir      XROOTD support, path to XROOTD libraries (libXrdClient, ...)

with compiler options, prefix with --with-, overrides default value

  cc                 alternative C compiler and options to be used
  cxx                alternative C++ compiler and options to be used
  f77                alternative Fortran compiler and options to be used
  ld                 alternative Linker and options to be used
  gcc-toolchain      directory where gcc is installed (needed for compilation
                     of clang/LLVM in case not the default gcc is used)
  clang              use clang compiler instead of gcc (mutual exclusive with
                     the cc, cxx and ld options)
  python             alternative python interpreter to be used

cross compiling options, currently only used when building for ios and iossim

  --host[=hostarch]  host architecture to be used in case of cross compiling
  --with-hostcc      alternative host C compiler in case of cross compiling
  --with-hostcxx     alternative host C++ compiler in case of cross compiling
  --with-hostld      alternative host Linker in case of cross compiling

Supported Architectures:

EOF
   cat ${ac_srcdir}/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@cern.ch>
EOF
}

######################################################################
#
### echo %%% Store invocation and machine info in config.log
#
logmsg "Invoked on `hostname 2>/dev/null`"
logmsg "   with `uname -a 2>/dev/null`"
logmsg "   at `date 2>/dev/null`:"

logmsg "   $0"
for argv in "$@"; do
    logmsg "     \"${argv}\""
done

######################################################################
#
### 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"
   logmsg "Invalid architecture \"$arch\"."
   exit 1
fi

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

case $arch in
linuxppc64*)
   logmsg "Will ONLY check 64bit libraries"
   checkonlylib64="yes" ;;
linuxx8664k1om*)
   logmsg "Will not check 64bit libraries"
   checklinux64="no"
   checklib64="no"
   enable_genvector="no"
   enable_tmva="no"
   ;;
linuxx8664*)
   logmsg "Will check 64bit libraries"
   checklinux64="yes"
   checklib64="yes" ;;
linuxx32*)
   logmsg "Will check x32 libraries in the future"
   logmsg "For now expect proper libraries through configure flags" ;;
hpuxia64acc)
   logmsg "Will check HP/UX 64bit libraries"
   checkhpux64="yes" ;;
solaris64CC5)
   logmsg "Will check Solaris 64bit libraries"
   checksolaris64="yes"
   checklib64="yes" ;;
macosx*)
   logmsg "Will check for compatible libraries"
   checklibcompat="yes"
   logmsg "Will check for compatible C++ run-time libraries"
   checklibcxxcompat="yes"
   if test "x$macosxvers" = "x"; then
      # get most recent SDK version
      macosxminor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
      macosxvers=10.$macosxminor
   fi
   # make available to conftest.mk scripts
   export MACOSXVERS=$macosxvers
   ;;
ios*)
   logmsg "Will check iOS SDK libraries"
   message "Checking for iOS SDK"
   if test "x$iosvers" = "x"; then
      # get most recent SDK version
      iosvers=`xcodebuild -showsdks | sed -n '/iphoneos/s/.*iOS //p' | sed 's/ .*//'|awk 'END{print}'`
   fi
   if [ `echo $iosvers | cut -d . -f 1` -ge 7 ]; then
      ios7=yes
   fi
   xcodepath=`/usr/bin/xcode-select -print-path`
   if test "x$arch" = "xios" || test "x$arch" = "xios64"; then
      iossdk=$xcodepath/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$iosvers.sdk
   else
      iossdk=$xcodepath/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$iosvers.sdk
   fi
   result "$iossdk"
   if [ ! -d $iossdk ]; then
       result "`basename $0`: no iOS SDK found at $iossdk"
       result "Run "xcode-select" to update the developer directory path"
       result "or make sure the desired SDK version is installed"
       exit 1
   fi
   # make available to conftest.mk scripts
   export IOSSDK=$iossdk
   export IOSVERS=$iosvers
   enable_genvector="no"
   enable_tmva="no"
   enable_vdt="no"
   ;;
win32)
   logmsg "Will use by default builtin versions of libraries on Win32"
   enable_builtin_freetype="yes"
   enable_builtin_ftgl="yes"
   enable_builtin_glew="yes"
   enable_builtin_pcre="yes"
   enable_builtin_zlib="yes"
   enable_builtin_lzma="yes"
   top_builddir=`cygpath -u $top_builddir`
   top_srcdir=`cygpath -u $top_srcdir`
   ;;
esac

# check for which, avoid using which, as it may be a buggy csh script.
if type -path type >/dev/null 2>&1 ; then
   cwhich="type -path"
elif type whence >/dev/null 2>&1 ; then
   cwhich="whence"
else
   # XXX Should do something better...
   # ... possibly using type inside a sh function whence() { ... }
   cwhich="which"
fi

# Check for sanity of source on Mac OS X: 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 ${ac_srcdir}/core/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

   if [ `sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2` -ge 5 ]; then
      macosx105=yes
   fi
   if [ `sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2` -ge 6 ]; then
      macosx106=yes
   fi
   if [ `sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2` -ge 7 ]; then
      macosx107=yes
   fi
   if [ `sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2` -ge 8 ]; then
      macosx108=yes
   fi
   if [ `sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2` -ge 9 ]; then
      macosx109=yes
   fi
fi

if test "x$platform" = "xlinux" ; then
    linuxdist=
    if `$cwhich lsb_release > /dev/null 2>&1` ; then
       if lsb_release -d | grep -i 'ubuntu' > /dev/null 2>& 1; then
          linuxdist="multiarch"
       fi
       if lsb_release -d | grep -i 'debian' > /dev/null 2>& 1; then
          linuxdist="multiarch"
       fi
       if lsb_release -d | grep -i 'mint' > /dev/null 2>& 1; then
          linuxdist="multiarch"
       fi
    fi

    debmultiarch=
    if test "x$linuxdist" = "xmultiarch"; then
        if `$cwhich dpkg-architecture > /dev/null 2>&1` ; then
            if `dpkg-architecture -qDEB_HOST_MULTIARCH > /dev/null 2>&1` ; then
                logmsg "Checking dpkg-architecture"
                debmultiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
                logmsg "$debmultiarch"
            fi
        else
            result "`basename $0`: dpkg-architecture MUST be installed"
            result "See http://root.cern.ch/drupal/content/build-prerequisites"
            exit 1
        fi
    fi
fi

######################################################################
#
### echo %%% Some clean up
#
trapcmd="rm -rf Makefile.tmp RConfigure.tmp RConfigure-out.tmp \
         RConfigOptions.tmp RConfigOptions-out.tmp \
         Makefile-comp.tmp root-config.tmp rootrc.tmp \
         rootauthrc.tmp rootdaemonrc.tmp memprobe.tmp rootd.tmp \
         proofd.tmp rootd.xinetd.tmp proofd.xinetd.tmp proofserv.tmp \
         roots.tmp conftest.mk conftest.c conftest conftest.dSYM"
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" ;;
      --all)                   ;;
      --minimal)               ;;
      --gminimal)              ;;
      --host)                  savearch=$arch
                               guess_architecture
                               host=$arch
                               arch=$savearch        ;;
      --host=*)                host=$optarg          ;;
      --with-afs=*)            afsdir=$optarg        ; enable_afs="yes"     ;;
      --with-afs-incdir=*)     afsincdir=$optarg     ; enable_afs="yes"     ;;
      --with-afs-libdir=*)     afslibdir=$optarg     ; enable_afs="yes"     ;;
      --with-afs-shared=*)     afsshared=$optarg     ; enable_afs="yes"     ;;
      --with-alien-incdir=*)   alienincdir=$optarg   ; enable_alien="yes"   ;;
      --with-alien-libdir=*)   alienlibdir=$optarg   ; enable_alien="yes"   ;;
      --with-alloc-libdir=*)   alloclibdir=$optarg   ; enable_alloc="yes"   ;;
      --with-alloc-lib=*)      alloclib=$optarg      ; enable_alloc="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=*)    echo "WARNING: option $1 is deprecated and ignored"'!' ;;
      --with-chirp-incdir=*)   chirpincdir=$optarg   ; enable_chirp="yes"   ;;
      --with-chirp-libdir=*)   chirplibdir=$optarg   ; enable_chirp="yes"   ;;
      --with-cppunit=*)        cppunit=$optarg       ;;
      --with-davix-incdir=*)   davixincdir=$optarg   ; enable_davix="yes"   ;;
      --with-davix-libdir=*)   davixlibdir=$optarg   ; enable_davix="yes"   ;;
      --with-dcap-incdir=*)    dcapincdir=$optarg    ; enable_dcache="yes"  ;;
      --with-dcap-libdir=*)    dcaplibdir=$optarg    ; enable_dcache="yes"  ;;
      --with-dnssd-incdir=*)   dnssdincdir=$optarg   ; enable_bonjour="yes" ;;
      --with-dnssd-libdir=*)   dnssdlibdir=$optarg   ; enable_bonjour="yes" ;;
      --with-avahi-incdir=*)   avahiincdir=$optarg   ; enable_bonjour="yes" ;;
      --with-avahi-libdir=*)   avahilibdir=$optarg   ; enable_bonjour="yes" ;;
      --with-finkdir=*)        finkdir=$optarg       ; enable_fink="yes"    ;;
      --with-ftgl-incdir=*)    ftglincdir=$optarg    ; enable_builtin_ftgl=no;;
      --with-ftgl-libdir=*)    ftgllibdir=$optarg    ; enable_builtin_ftgl=no;;
      --with-fftw3-incdir=*)   fftw3incdir=$optarg   ; enable_fftw3="yes"   ;;
      --with-fftw3-libdir=*)   fftw3libdir=$optarg   ; enable_fftw3="yes"   ;;
      --with-cfitsio-incdir=*) cfitsioincdir=$optarg ; enable_fitsio="yes"  ;;
      --with-cfitsio-libdir=*) cfitsiolibdir=$optarg ; enable_fitsio="yes"  ;;
      --with-gviz-incdir=*)    gvizincdir=$optarg    ; enable_gviz="yes"    ;;
      --with-gviz-libdir=*)    gvizlibdir=$optarg    ; enable_gviz="yes"    ;;
      --with-gfal-incdir=*)    gfalincdir=$optarg    ; enable_gfal="yes"    ;;
      --with-gfal-libdir=*)    gfallibdir=$optarg    ; enable_gfal="yes"    ;;
      --with-srm-ifce-incdir=*) srmifceincdir=$optarg;;
      --with-glib2-incdir=*)    glib2incdir=$optarg;;
      --with-glew-incdir=*)    glewincdir=$optarg    ; enable_builtin_glew=no;;
      --with-glew-libdir=*)    glewlibdir=$optarg    ; enable_builtin_glew=no;;
      --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-geocad=*)         geocaddir=$optarg     ; enable_geocad="yes"  ;;
      --with-occ-incdir=*)     occincdir=$optarg     ; enable_geocad="yes"  ;;
      --with-occ-libdir=*)     occlibdir=$optarg     ; enable_geocad="yes"  ;;
      --with-gccxml=*)         gccxml=$optarg        ;;
      --with-hdfs-incdir=*)    hdfsincdir=$optarg    ; enable_hdfs="yes"    ;;
      --with-hdfs-libdir=*)    hdfslibdir=$optarg    ; enable_hdfs="yes"    ;;
      --with-iosvers=*)        iosvers=$optarg       ;;
      --with-jni-incdir=*)     jniincdir=$optarg     ;;
      --with-jvm-libdir=*)     jvmlibdir=$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-llvm-config=*)    llvmconfig=$optarg    ; enable_builtin_llvm=no;;
      --with-macosxvers=*)     macosxvers=$optarg    ;;
      --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-pythia8-incdir=*) pythia8incdir=$optarg ; enable_pythia8="yes" ;;
      --with-pythia8-libdir=*) pythia8libdir=$optarg ; enable_pythia8="yes" ;;
      --with-python-incdir=*)  pythonincdir=$optarg  ; enable_python="yes"  ;;
      --with-python-libdir=*)  pythonlibdir=$optarg  ; enable_python="yes"  ;;
      --with-qt-incdir=*)      qtincdir=$optarg      ; mocdir=$optarg/../bin; 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"    ;;
      --with-sqlite-incdir=*)  sqliteincdir=$optarg  ; enable_sqlite="yes"  ;;
      --with-sqlite-libdir=*)  sqlitelibdir=$optarg  ; enable_sqlite="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=*)            ssldir=$optarg        ; enable_ssl="yes"     ;;
      --with-ssl-incdir=*)     sslincdir=$optarg     ; enable_ssl="yes"     ;;
      --with-ssl-libdir=*)     ssllibdir=$optarg     ; enable_ssl="yes"     ;;
      --with-ssl-shared=*)     sslshared=$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-xft-libdir=*)     xftlibdir=$optarg     ;;
      --with-xext-libdir=*)    xextlibdir=$optarg    ;;
      --with-xrootd=*)         xrootddir=$optarg     ; enable_xrootd="yes"  ;;
      --with-xrootd-incdir=*)  xrdincdir=$optarg     ; enable_xrootd="yes"  ;;
      --with-xrootd-libdir=*)  xrdlibdir=$optarg     ; enable_xrootd="yes"  ;;
      --with-cc=*)             altcc=$optarg         ; altccset=1           ;;
      --with-cxx=*)            altcxx=$optarg        ;;
      --with-f77=*)            altf77=$optarg        ;;
      --with-ld=*)             altld=$optarg         ;;
      --with-gcc-toolchain=*)  gcctoolchain=$optarg  ;;
      --with-clang) altcc=clang; altcxx=clang++; altld=clang++; altccset=1 ;;
      --with-hostcc=*)         hostcc=$optarg        ;;
      --with-hostcxx=*)        hostcxx=$optarg       ;;
      --with-hostld=*)         hostld=$optarg        ;;
      --with-python=*)         pythonexe=$optarg     ;;
      ################################################################
      #
      # Enable/disable to turn on/off third party software linkage and
      # features
      #
      --enable-*)
        f=`echo $1 | sed -e 's/--//' -e 's/-/_/g' -e 's/++11/xx11/'`
        eval prev='$'`echo ${f}`
        eval prev_expl='$'`echo ${f}_explicit`
        if test ! "x`echo ${deprecated_options} | grep ${f}`" = "x"; then
            echo "WARNING: option $1 is deprecated and ignored"'!'
        else
            if test "${prev}:${prev_expl}" = "yes:"; then
                echo "INFO: $1: already enabled by default."
            fi
            if test "x${prev_expl}" = "xno"; then
                echo "WARNING: conflicting --disable / $1, $1 wins"
            fi
            eval ${f}=yes
            eval ${f}_explicit=yes
        fi
        for c in $options ; do
           if test "x$c" = "x$f" ; then
              f=""
           fi
        done
        for c in $deprecated_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' -e 's/++11/xx11/'`
        eval prev='$'`echo ${f}`
        eval prev_expl='$'`echo ${f}_explicit`
        if test ! "x`echo ${deprecated_options} | grep ${f}`" = "x"; then
            echo "WARNING: option $1 is deprecated and ignored"'!'
        else
            if test "${prev}:${prev_expl}" = "xno:"; then
                echo "INFO: $1: already disabled by default."
            fi
            if test "x${prev_expl}" = "xyes"; then
                echo "WARNING: conflicting --enable / $1, $1 wins"
            fi
            eval ${f}=no
            eval ${f}_explicit=no
        fi
        for c in $options ; do
           if test "x$c" = "x$f" ; then
              f=""
           fi
        done
        for c in $deprecated_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      ;;
      --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

# sanity check, prefix must be an absolute path
if test ! "x$haveconfig" = "x" ; then
   case $prefix in
      /*) ;;
      *)  echo "`basename $0`: --prefix argument must be an absolute path, not $prefix"; exit 1;;
   esac
fi

######################################################################
#
### echo %%% Copy skeletons to temporary files
#
if test "x$noact" = "xno"; then
    cp -f $MAKEIN Makefile.tmp
    cp -f $MAKECOMPIN Makefile-comp.tmp
    cp -f $CONFIGUREIN RConfigure.tmp
    cp -f $CONFIGOPTIN RConfigOptions.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 $PROOFSERVIN proofserv.tmp
    cp -f $ROOTSIN roots.tmp
    cp -f $XPROOFDIN xproofd.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|' < ${ac_srcdir}/build/version_number`
    minor=`sed 's|.*\.\(.*\)/.*|\1|' < ${ac_srcdir}/build/version_number`
    revis=`sed 's|.*\..*/\([0-9]*\).*|\1|' < ${ac_srcdir}/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"
    enable_x11="no"
fi

######################################################################
#
### echo %%% Check for Fink or MacPorts on Mac OS X
#
if test "x$platform" = "xmacosx"; then
    message "Checking for Fink/MacPorts directory"
    if test "x$enable_fink" = "xyes"; then
        if test -d "$finkdir"; then
            # User specified a directory with --with-finkdir=...
            logmsg "Using user-specified Fink directory"
            logmsg "$finkdir"
        else
            # Fink has precedence over MacPorts
            logmsg "Checking Fink directory"
            finkdir=`$cwhich fink 2>&1 | sed -ne "s/\/bin\/fink//p"`
            logmsg "$finkdir"

            if test "x$finkdir" = "x"; then
                logmsg "Checking MacPorts directory"
                finkdir=`$cwhich port 2>&1 | sed -ne "s/\/bin\/port//p"`
                logmsg "$finkdir"
            fi
        fi
        result "$finkdir"
    else
        logmsg "Fink/MacPorts disabled"
        result "disabled"
    fi
else
    enable_fink="no"
fi

######################################################################
#
### echo %%% On iOS and Intel MIC always disable X11
#
if test "x$platform" = "xios" || test "x$platform" = "xlinux-k1om"; then
    enable_x11="no"
    if test "x$host" = "x"; then
        savearch=$arch
        guess_architecture
        host=$arch
        arch=$savearch
    fi
else
    # cross compiling only supported for ios and Intel MIC for the time being
    host=
fi

######################################################################
#
### echo %%% If no X11 then also no OpenGL and ASImage on non Win32 platforms
#
if test "x$enable_x11" = "xno" && test ! "x$platform" = "xwin32"; then
   enable_opengl="no"
   enable_asimage="no"
fi

######################################################################
#
### echo %%% On MacOS X >=10.5 always enable_rpath in case of non-prefix install
#
if test ! "x$macosx105" = "x"; then
    if test "x$enable_rpath" = "xno" && test "x$haveconfig" = "x" ; then
        enable_rpath="yes"
    fi
fi

######################################################################
#
### echo %%% check for GNU make >= 3.80 - Mandatory version of make
#
# Mandatory test, must succeed
# Check for GNU make >= 3.80
#
message "Checking for GNU Make version >= 3.80"
gnumake="make --no-print-directory"
gnu=`$gnumake -v 2>&1 | awk 'BEGIN { FS=" "} { if (NR==1) print $1 }'`
if test ! "x$gnu" = "xGNU" ; then
    gnumake="gmake --no-print-directory"
    gnu=`$gnumake -v 2>&1 | awk 'BEGIN { FS=" "} { if (NR==1) print $1 }'`
    if test ! "x$gnu" = "xGNU" ; then
        gnumake=""
    fi
fi
if test ! "x$gnumake" = "x" ; then
    gnuv=`$gnumake -v | tr '.,' ' ' | awk 'BEGIN { FS=" "} { if (NR==1 && $3 == "version") printf "%d", ($4*1000)+($5*10)+$6; else printf "%d", ($3*1000)+($4*10)+$5 }'`
    if test $gnuv -lt 3800 ; then
        result "no"
        result "`basename $0`: GNU Make >= 3.80 MUST be installed, current version $gnuv is too old"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi
    result "ok"
else
    result "no"
    result "`basename $0`: GNU Make >= 3.80 MUST be installed"
    result "See http://root.cern.ch/drupal/content/build-prerequisites"
    exit 1
fi

######################################################################
#
### echo %%% check for compilers
#
# Mandatory test, must succeed
# Check for C, C++ compilers, and optionally FORTRAN
#
check_comp C
if test $found_comp -eq 0 ; then
   result "`basename $0`: C compiler MUST be installed"
   result "See http://root.cern.ch/drupal/content/build-prerequisites"
   exit 1
fi
check_comp C++
if test $found_comp -eq 0 ; then
   result "`basename $0`: C++ compiler MUST be installed"
   result "See http://root.cern.ch/drupal/content/build-prerequisites"
   exit 1
fi
check_comp LD
if test $found_comp -eq 0 ; then
   result "`basename $0`: Linker MUST be installed"
   result "See http://root.cern.ch/drupal/content/build-prerequisites"
   exit 1
fi
check_comp F77
if test $found_comp -eq 0 ; then
   # missing F77 is not fatal
   altf77=
fi

# the path for the gcctoolchain in case not the system gcc is used to
# build clang/LLVM. This path is used to build clang/LLVM.
if test "x$gcctoolchain" != "x"; then
   if test "x$altccset" = "x" ; then
      result "`basename $0`: no alternative gcc compiler specified, incompatible with --with-gcc-toolchain option"
      exit 1
   fi
fi

######################################################################
#
### echo %%% Check host environment in case of cross compiling
#
#
if test ! "x$host" = "x"; then
    if ! test -f ${ac_srcdir}/config/Makefile.$host; then
        echo 'Invalid host platform' $host
        exit 1
    fi

    compmsgextra="host "
    archbak=$arch
    arch=$host

    altccbak=$altcc
    altcc=$hostcc
    check_comp C
    if test ${found_comp} -eq 0; then
        echo "Cannot find host CC $hostcc"
        exit 1
    fi
    altcc=$altccbak

    altcxxbak=$altcxx
    altcxx=$hostcxx
    check_comp C++
    if test ${found_comp} -eq 0; then
        echo "Cannot find host CXX $hostcc"
        exit 1
    fi
    altcxx=$altcxxbak

    altldbak=$altld
    altld=$hostld
    check_comp LD
    if test ${found_comp} -eq 0; then
        echo 'Cannot find host linker (LD)' $hostcc
        exit 1
    fi
    altld=$altldbak

    compmsgextra=""
    arch=$archbak
fi

######################################################################
#
### echo %%% C++11 - compile using c++11 compatible option
#
# needs gcc > 4.7.x or clang
usecxx11="undef"
if test "x$enable_cxx11" = "xyes"; then
    message "Checking whether c++11 mode is supported"
    check_cxxopt -std=c++11
    if test $cxxopt_result -eq 0 ; then
        enable_cxx11="no"
        result "no"
        result "`basename $0`: c++11 mode is requested but the current compiler does not support it."
        exit 1
    else
        usecxx11="define"
        # on OS X libcxx is required for C++11 support with clang
        # so turn the option on when using clang
        if test "x$platform" = "xmacosx" && echo $altcxx | grep 'clang++' > /dev/null 2>&1; then
            enable_libcxx="yes"
        fi
        result "yes"
    fi
fi

######################################################################
#
### echo %%% libc++ - compile and link using libc++
#
# needs gcc > 4.7.x or clang

# OSX 10.9 only has libc++ with clang so make sure this option is turned on
if test "x$macosx109" = "xyes" && echo $altcxx | grep 'clang++' > /dev/null 2>&1; then
    enable_libcxx="yes"
fi
# iOS 7.0 only has libc++ with clang so make sure this option is turned on
if test "x$ios7" = "xyes" && echo $altcxx | grep 'clang++' > /dev/null 2>&1; then
    enable_libcxx="yes"
fi

uselibcxx="undef"
if test "x$enable_libcxx" = "xyes" ; then
    message "Checking whether libc++ is supported"
    check_cxxopt -stdlib=libc++
    if test $cxxopt_result -eq 0 ; then
        enable_libcxx="no"
        result "no"
    else
        uselibcxx="define"
        result "yes"
    fi
fi

######################################################################
#
### echo %%% Check for linker's support of --no-ctors-in-init-array
#
### This changes the sequence for static initialization to be right
### to left.
#
logmsg "Derminining support for --no-ctors-in-init-array"
cat <<EOF > conftest.mk
include ${ac_srcdir}/config/Makefile.${arch}
CC  = ${altcc}
CXX = ${altcxx}
LD  = ${altld}
conftest: conftest.cxx
	\$(CC) \$(LDFLAGS) -Wl,--no-ctors-in-init-array \$^ -o \$@

conftest.cxx:
	echo 'int main(int,char*[]){return 0;}' >> \$@
EOF
$gnumake -f conftest.mk >> $logfile 2>&1
if test $? -eq 0 ; then
    logmsg "  supported"
    ctorsinitarray="yes"
else
    logmsg "  not supported"
    ctorsinitarray="no"
fi
rm -f conftest.mk conftest conftest.cxx

######################################################################
#
### echo %%% Check for builtin or external LLVM/Clang
#
hasllvm="undef"
llvmdir="/**/"
if test "x$enable_builtin_llvm" = "x" || \
   test "x$enable_builtin_llvm" = "xno" ; then
    message "Checking for llvm-config for external llvm"
    # allow LLVMDIR instead of --with-llvm-config
    if test "x$llvmconfig" = "x" ; then
        if test ! "x$LLVMDIR" = "x" ; then
            llvmconfig="$LLVMDIR/bin"
        fi
    fi
    if test ! "x$llvmconfig" = "x"; then
        if test -d "$llvmconfig"; then
            llvmconfig=$llvmconfig/llvm-config
        fi
        if test -f $llvmconfig && test -x $llvmconfig; then
            hasllvm="define"
            llvmdir="`dirname $llvmconfig`"
            llvmdir='"'"`dirname $llvmdir`"'"'
        fi
    fi
    if test "x$hasllvm" = "xundef"; then
        enable_builtin_llvm="yes"
        llvmconfig=""
        result "no (needs --with-llvm-config or \$LLVMDIR)"
    else
        result "$llvmconfig"
    fi
fi

######################################################################
#
### echo %%% Check for Python version (required by LLVM/Clang)
#
message "Checking for Python version >= 2.5"

if test "x$pythonexe" = "x"; then
  pythonexe=`$cwhich python 2> /dev/null`
else
  if test ! -x "$pythonexe" ; then
    result "Python specified with --with-python $with-python is not usable"
    exit 1
  fi
fi

pythonvers=`$pythonexe -c 'import sys; sys.stdout.write(sys.version[:3])'`
pythonvers_major=`echo $pythonvers | cut -d'.' -f1`
pythonvers_minor=`echo $pythonvers | cut -d'.' -f2`

if test  "$pythonvers_major" -gt "2" || \
   (test "$pythonvers_major" -eq "2" && \
   test "$pythonvers_minor" -ge "5") ; then
  result yes
else
  result "no"
  result "`basename $0`: Python >= 2.5 MUST be installed"
  result "See http://root.cern.ch/drupal/content/build-prerequisites"
  exit 1
fi

######################################################################
#
### echo %%% Check if native MacOS X Cocoa/Quartz backend should be build
#
if test ! "x$platform" = "xmacosx"; then
    enable_cocoa="no"
fi
if test "x$macosx107" = "xyes" && test "x$enable_cocoa" = "x"; then
   enable_cocoa="yes"
fi
if test "x$enable_cocoa" = "x"; then
   enable_cocoa="no"
fi

hascocoa="undef"
if test "x$enable_cocoa" = "xyes"; then
    message "Checking whether to build native MacOS X Cocoa backend"
    hascocoa="define"
    enable_x11="no"
    result "yes"
    message "Checking for Xcode OSX SDK"
    xcodepath=`/usr/bin/xcode-select -print-path`
    xcodesdk=$xcodepath/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$macosxvers.sdk
    if [ -d $xcodesdk ]; then
        osxsdk=$xcodesdk
    else
        result "no"
        message "Checking for system OSX SDK"
        osxsdk=""
    fi
    openglincdir=${osxsdk}/System/Library/Frameworks/OpenGL.framework/Headers
    opengllibdir=${osxsdk}/System/Library/Frameworks/OpenGL.framework/Libraries
    if [ -d $openglincdir ] && [ -d $opengllibdir ]; then
        result "yes"
    else
        result "no"
        result "`basename $0`: no Xcode OSX SDK found at $xcodesdk"
        result "Run "xcode-select" to update the developer directory path"
        result "or make sure the desired SDK version is installed"
        exit 1
    fi
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 ! "x$enable_x11" = "xno" ; then
    check_library "libX11" "yes" "$x11libdir" \
        ${finkdir:+$finkdir/lib} \
        /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 MUST be installed"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi

    check_header "X11/Xlib.h" "" \
        ${finkdir:+$finkdir/include} \
        /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
    x11incdir=$found_dir

    if test "x$found_dir" = "x" ; then
        result "`basename $0`: X11 headers MUST be installed"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi

    check_header "X11/xpm.h" "" \
        $XPM ${XPM:+$XPM/include} \
        ${finkdir:+$finkdir/include} \
        /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`: xpm headers MUST be installed"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi

    check_header "X11/Xft/Xft.h" "" \
        ${finkdir:+$finkdir/include} \
        /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`: Xft headers MUST be installed"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi

    if test ! "x$arch" = "xaix5" ; then
        check_header "X11/extensions/shape.h" "" \
            ${finkdir:+$finkdir/include} \
            /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/extensions/shape.h header MUST be installed"
            result "See http://root.cern.ch/drupal/content/build-prerequisites"
            exit 1
        fi
    fi

    check_library "libXpm" "$enable_shared" "$xpmlibdir" \
        $XPM ${XPM:+$XPM/lib} \
        ${finkdir:+$finkdir/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"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi

    check_library "libXft" "$enable_shared" "$xftlibdir" \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib /usr/lib/X11 \
        /usr/local/lib/X11 /usr/X11R6/lib /usr/local/X11R6/lib \
        /usr/X11/lib

    if test "x$found_lib" = "x" ; then
        result "`basename $0`: libXft MUST be installed"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi
    if test "x$platform" = "xmacosx" &&
       test ! "x$x11libdir" = "x$found_dir" ; then
        result "`basename $0`: libXft not in same directory as libX11"
        result "For consistency they should be in the same directory"
        exit 1
    fi

    check_library "libXext" "$enable_shared" "$xextlibdir" \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib /usr/lib/X11 \
        /usr/local/lib/X11 /usr/X11R6/lib /usr/local/X11R6/lib \
        /usr/X11/lib

    if test "x$found_lib" = "x" ; then
        result "`basename $0`: libXext MUST be installed"
        result "See http://root.cern.ch/drupal/content/build-prerequisites"
        exit 1
    fi
    if test "x$platform" = "xmacosx" &&
       test ! "x$x11libdir" = "x$found_dir" ; then
        result "`basename $0`: libXext not in same directory as libX11"
        result "For consistency they should be in the same directory"
        exit 1
    fi
else
    x11libdir=""
    xpmlibdir=""
    xftlibdir=""
    xextlibdir=""
fi

######################################################################
#
### echo %%%Xft support (X11 antialiased fonts)
#
if test "x$enable_x11" = "xno"; then
   enable_xft="no"
fi
hasxft="undef"
if test "x$enable_xft" = "xyes"; then
   hasxft="define"
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
if test "x$platform" != "xwin32"; then
    enable_winrtdebug=no
fi

######################################################################
#
### echo %%% Posix Thread Library
#
# Check for posix thread library
#
case $platform in
win32)
    if test "x$enable_thread" = "x"; then
        enable_thread="yes"
    fi
    ;;
macosx)
    if test "x$enable_thread" = "x" || test "x$enable_thread" = "xyes"; then
        if test ! "x$macosx105" = "x"; then
            enable_thread="yes"
            threadflag="-pthread"
            threadlib="-lpthread"
            threadlibdir=
        else
            enable_thread="yes"
            threadflag="-D_REENTRANT"
        fi
    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" || test "x$enable_thread" = "xyes"; then
        enable_thread="yes"
        threadflag="-mt"
        threadlib="-mt"
        threadlibdir=
    fi
    ;;
esac
if test "x$enable_thread" = "xyes" && \
   test ! "x$platform" = "xwin32"  && \
   test "x$threadlib" = "x" ; then
    check_library "libpthread" "$enable_shared" "$threadlibdir" \
        $THREAD ${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 ! "x$platform" = "xwin32"; 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` && test "x$host" = "x" ; then
      if test "x$macosx108" = "xyes" && (file -h `$cwhich freetype-config` | grep 'xstub' > /dev/null 2>&1 || test "x$enable_cocoa" = "xyes"); then
         enable_builtin_freetype="yes"
         if file -h `$cwhich freetype-config` | grep 'xstub' > /dev/null 2>&1 ; then
            result "XQuartz not installed"
         else
            result "using builtin freetype"
         fi
      else
         $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
      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` && test "x$host" = "x" ; 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" "" \
        $ZLIB ${ZLIB:+$ZLIB/include} \
        ${finkdir:+$finkdir/include} \
        /usr/local/include /usr/include/zlib /usr/local/include/zlib \
        /opt/zlib/include /usr/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" "" \
        $ZLIB ${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/zlib /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 %%% Use included lzma or use systems
#
# (See http://tukaani.org/xz/)
#
if test "x$enable_builtin_lzma" = "xno" ; then
    check_header "lzma.h" "" \
        $LZMA ${LZMA:+$LZMA/include} \
        ${finkdir:+$finkdir/include} \
        /usr/local/include /usr/include \
        /usr/local/include/lzma /usr/include/lzma \
        /opt/lzma/include
    if test "x$found_dir" = "x" ; then
        enable_builtin_lzma=yes
    else
        lzmainc=$found_hdr
        lzmaincdir=$found_dir
    fi

    check_library "liblzma" "$enable_shared" "" \
        $LZMA ${LZMA:+$LZMA/lib} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lzma/lib /usr/local/lib \
        /usr/lib/lzma /usr/local/lib/lzma /usr/lzma/lib /usr/lib \
        /usr/lzma /usr/local/lzma /opt/lzma /opt/lzma/lib
    if test "x$found_lib" = "x" ; then
        lzmalib=""
        lzmalibdir=""
        enable_builtin_lzma="yes"
    else
        lzmalib="$found_lib"
        lzmalibdir="$found_dir"
    fi

    if test "x$lzmaincdir" = "x" || test "x$lzmalib" = "x"; then
        enable_builtin_lzma="yes"
    fi
fi
message "Checking whether to build included lzma"
result "$enable_builtin_lzma"

######################################################################
#
### echo %%% OpenGL Support - Third party libraries
#
# (see mesa3d.org)
#
if test ! "x$enable_opengl" = "xno" && test ! "x$platform" = "xwin32" ; then
    # Check for OpenGL compatible include and library
    openglincdirs="$OPENGL ${OPENGL:+$OPENGL/include} \
        ${finkdir:+$finkdir/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"
    check_header "GL/gl.h gl.h" "$openglincdir" $openglincdirs
    openglinc=$found_hdr
    openglincdir=$found_dir

    opengllibdirs="$OPENGL ${OPENGL:+$OPENGL/lib} \
        ${finkdir:+$finkdir/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

    if test ! "x$macosx105" = "x" && test "x$macosx106" = "x" ; then
        # Mac OS X 10.5 problem
        opengllib="-dylib_file /usr/X11R6/lib/libGL.dylib:/usr/X11R6/lib/libGL.dylib -lGL"
    fi

    skipchecklibcxxcompat="yes"
    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"
        enable_builtin_glew="no"
    else
        check_header "GL/glew.h" "$glewincdir" $openglincdirs
        glewinc="$found_hdr"
        glewincdir="$found_dir"

        check_library "libGLEW" "$enable_shared" "$keep" $opengllibdirs
        glewlib="$found_lib"
        glewlibdir=$found_dir
        glewlibs="$glewlib"

        if test "x$glewincdir" = "x" || test "x$glewlib" = "x" ||
           test "x$enable_builtin_glew_explicit" = "xyes" ; then
            enable_builtin_glew="yes"
            glewincdir="include"
            glewlibdir="-Llib"
            glewlibs="-lGLEW"
        fi
        message "Checking whether to build included GLEW"
        result "$enable_builtin_glew"
    fi
fi
check_explicit "$enable_opengl" "$enable_opengl_explicit" \
     "Explicitly required OpenGL dependencies not fulfilled"

######################################################################
#
### echo %%% libftgl (builtin or system) - Needed if OpenGL enabled
#
# Mandatory test, must succeed
# (see http://homepages.paradise.net.nz/henryj/code/index.html#FTGL)
#
if test ! "x$enable_opengl" = "xno" && test ! "x$platform" = "xwin32" ; then
   ftglincdir=
   ftgllibdir=-Llib
   ftgllibs=-lFTGL
   if test "x$enable_builtin_ftgl" = "x" || \
      test "x$enable_builtin_ftgl" = "xno" ; then

      # check if we have pkg-config
      checking_msg "pkg-config"
      if `$cwhich pkg-config > /dev/null 2>&1` ; then
         $cwhich pkg-config

         message "Checking for libftgl"
         if pkg-config --exists ftgl ; then
            result "ok"
            message "Checking for ftgl version > 2.1.2"
            ftgl_version=`pkg-config --modversion ftgl | \
            tr '.' ' ' | \
            awk 'BEGIN { FS = " "; } \
               { printf "%d", ($''1 * 1000 + $''2) * 1000 + $''3;}'`
            # Use FTGL/ftgl.h when > 2.1.2
            if test $ftgl_version -gt 2001002 ; then
               result "ok"
               ftglincdir=`pkg-config --cflags-only-I ftgl | sed 's/-I//g'`
               ftgllibs=`pkg-config --libs-only-l ftgl`
               ftgllibdir=`pkg-config --libs-only-L ftgl`
               enable_builtin_ftgl="no"
            else
               enable_builtin_ftgl="yes"
               result "no (`pkg-config --modversion ftgl`)"
            fi
         else
            enable_builtin_ftgl="yes"
            result "no"
         fi
      else
         enable_builtin_ftgl="yes"
         echo "not found"
      fi
   fi
   message "Checking whether to build included libftgl"
   result "$enable_builtin_ftgl"
fi

######################################################################
#
### echo %%% OpenGL support on Windoze
#
# On win32 we always have OpenGL available
#
if test "x$platform" = "xwin32"; then
   enable_opengl="yes"
   openglincdir="include"

   enable_builtin_glew="yes"
   glewincdir=include
   glewlibdir=
   glewlibs=lib/libGLEW.lib

   enable_builtin_ftgl="yes"
   ftglincdir=
   ftgllibdir=
   ftgllibs=lib/libFTGL.lib
fi

######################################################################
#
### echo %%% Alternative Memory Allocator Support - Third party libraries
#
if test ! "x$enable_alloc" = "xno"; then
    # Check for alternative memory allocator
    check_library "$alloclib" "$enable_shared" "$alloclibdir" \
        /usr/lib /usr/local/lib
    alloclib=$found_lib
    alloclibdir=$found_dir

    if test "x$alloclib" = "x"; then
        alloclibdir=""
        enable_alloc="no"
    fi
fi
check_explicit "$enable_alloc" "$enable_alloc_explicit" \
     "Explicitly required allocator dependencies not fulfilled"

######################################################################
#
### 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" && test "x$host" = "x" ; then
       echo $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
          if test "x$arch" = "xlinux" && mysql_config --libs | grep 'lib64/mysql' > /dev/null 2>& 1; then
             result "no (lib64 version found)"
             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=""
             check_header "mysql.h" "" $mysqlincdir
             if test "x$found_hdr" = "x"; then
                enable_mysql="no"
             fi
          fi
       fi
    else
       result "not found"
       # fall back in case mysql_config is not found
       check_header "mysql.h" "$mysqlincdir" \
           $MYSQL ${MYSQL:+$MYSQL/include} \
           ${MYSQL:+$MYSQL/include/mysql} \
           ${finkdir:+$finkdir/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
       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:+$MYSQL/lib} ${MYSQL:+$MYSQL/lib/mysql} \
           ${finkdir:+$finkdir/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
       mysqllib=$found_lib
       mysqllibdir=$found_dir

       # on linux, but maybe also other systems, explicitly 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:+ORACLE/include} \
        ${ORACLE:+$ORACLE/sdk/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:+$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:+$ORACLE/lib} $ORACLELIBDIR \
       /usr/local/lib /usr/lib /usr/lib/oracle/*/client/lib
    if test "x$found_lib" = "x"; then
       oraclelib=""
    elif test ! "x$oraclelib" = "x"; then
        oraclelib="$oraclelib $found_lib"
    fi

    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:+$PGSQL/include} \
        ${finkdir:+$finkdir/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:+$PGSQL/lib} \
        ${finkdir:+$finkdir/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"
    else
        if test "x$arch" = xwin32gcc; then
            pgsqllib="$pgsqllib -lssl -lldap -lcrypto -lintl"
        fi
    fi
fi
check_explicit "$enable_pgsql" "$enable_pgsql_explicit" \
     "Explicitly required PostGreSQL dependencies not fulfilled"

######################################################################
#
### echo %%% SQLite Support - Third party libraries
#
# (See sqlite.org)
#
# If the user has set the flags "--disable-sqlite", we don't check for
# SQLite at all.
#
if test ! "x$enable_sqlite" = "xno"; then
    # Check for SQLite include and library
    check_header "sqlite3.h" "$sqliteincdir" \
        $SQLITE ${SQLITE:+$SQLITE/include} \
        ${finkdir:+$finkdir/include} \
        /usr/include /usr/local/include \
        /usr/include/sqlite /usr/local/include/sqlite /usr/local/sqlite/include \
        /usr/include/sqlite3 /usr/local/include/sqlite3 /usr/local/sqlite3/include \
        /usr/sqlite /opt/sqlite /opt/sqlite3/include \
        /usr/sqlite3 /opt/sqlite3 /opt/sqlite/include
    sqliteinc=$found_hdr
    sqliteincdir=$found_dir

    check_library "libsqlite3" "$enable_shared" "$sqlitelibdir" \
        $SQLITE ${SQLITE:+$SQLITE/lib} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/sqlite/lib /usr/local/lib \
        /usr/lib/sqlite /usr/local/lib/sqlite /usr/sqlite/lib /usr/lib \
        /usr/sqlite /usr/local/sqlite /opt/sqlite /opt/sqlite/lib
    sqlitelib=$found_lib
    sqlitelibdir=$found_dir

    if test "x$sqliteincdir" = "x" || test "x$sqlitelib" = "x"; then
        enable_sqlite="no"
    fi
fi
check_explicit "$enable_sqlite" "$enable_sqlite_explicit" \
     "Explicitly required SQLite 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:+$SAPDB/include} \
        ${finkdir:+$finkdir/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:+$SAPDB/lib} \
        ${finkdir:+$finkdir/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:+$ODBC/include} $ODBCINCDIR \
            ${finkdir:+$finkdir/include} \
            /usr/local/include /usr/include
        odbcinc=$found_hdr
        odbcincdir=$found_dir

        check_library "libiodbc libodbc odbc32" "$enable_shared" "$odbclibdir" \
            $ODBC ${ODBC:+$ODBC/lib} $ODBCLIBDIR \
            ${finkdir:+$finkdir/lib} \
            /usr/local/lib /usr/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.
#
check_qtvers()
{
    qttestdir=$1 ; shift
    qtverneed=$1 ; shift
    qttoonew=$1  ; shift
    message "Checking for $qtverneed <= Qt version < $qttoonew "
    logmsg " grep '# *define *QT_VERSION_STR *' $qttestdir/qglobal.h"
    qtverstr=`grep "# *define *QT_VERSION_STR *" $qttestdir/qglobal.h | \
        sed '-e s/[^"]*"//' -e 's/".*$//' 2>> $logfile`
    qtvers=0
    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
            res="no"
            resprint="no (found version $qtverstr)"
        elif test $qtgot -ge $qtnew; then
            res="no"
            resprint="no (found version $qtverstr)"
        else
            res="$qtverstr"
            resprint="$res"
            qtvers=`echo $qtverstr | awk 'BEGIN {FS="."} {print $1}'`
        fi
    else
        res="no"
        resprint="$res"
    fi
    result $resprint
}

if test ! "x$enable_qt" = "xno" || \
   test ! "x$enable_qtgsi" = "xno"; then
    # Check for Qt include and library
    if test ! "x$QTDIR" = "x"; then
        # The user asked for a specific "QTDIR" ... search ONLY in there
        check_header "Qt/qglobal.h" "$qtincdir" $QTDIR ${QTDIR:+$QTDIR/include}
    else
        check_header "Qt/qglobal.h" "$qtincdir" \
            /usr/local/include/ /usr/local/qt/include  \
            /usr/include /usr/include/qt4 /usr/lib/qt4/include
    fi
    qtvers=0
    if test ! "x$found_hdr" = "x"; then
        qtvers=4
        qt4="yes"
        qtinc=$found_hdr
        qtmainincdir=$found_dir
        qtincdir=$qtmainincdir
        for i in `ls -d $qtmainincdir/Qt*` ; do
            if test -d $i ; then
                qtincdir="$qtincdir $i"
            fi
        done
        qtverneed="4.8.0"
        qttoonew="5.0.0"
        qttestdir=$qtmainincdir/../src/corelib/global
        if test ! -d $qttestdir ; then
            qttestdir=$qtmainincdir/Qt
        fi
        check_qtvers "$qttestdir" $qtverneed $qttoonew
        if test $qtvers -eq 4 ; then
            qt4suffix="4"
            if test "x$enable_winrtdebug" = "xyes"; then
                qt4suffix="d4"
            fi
            check_library "libQtCore QtCore QtCore$qt4suffix QtCore4" \
                "$enable_shared" \
                "$qtlibdir" $QTDIR ${QTDIR:+$QTDIR/lib} /usr/local/lib \
                /usr/local/qt/lib /usr/lib /usr/qt/lib /usr/lib/qt4
            qtlib=$found_lib
            qtlibdir=$found_dir
            check_library "libQtGui QtGui QtGui$qt4suffix QtGui4" \
                "$enable_shared" "$found_raw_dir" ""
            qtlib="$qtlib $found_lib"
            check_library "libQt3Support Qt3Support Qt3Support$qt4suffix Qt3Support4" \
                "$enable_shared" "$found_raw_dir" ""
            qtlib="$qtlib $found_lib"
        else
            qtinc=
            qtmainincdir=
            qtincdir=
        fi
    fi

    message "Checking for moc or moc.exe"
    for i in $QTDIR $QTDIR/bin "$mocdir" /usr/local/bin /usr/local/qt/bin \
             /usr/bin /usr/qt4/bin /usr/lib/qt4/bin /usr/share/qt4/bin ; do
    logmsg " Checking for $qtmocexe in $i"

        for j in $i/moc-qt${qtvers} $i/moc-qt${qtvers}.exe $i/moc $i/moc.exe ;
        do
            if test -x $j ; then
          moc_vers=`$j -v 2>&1 | \
          sed -e 's/.*(Qt //' -e 's/\.[0-9]*\.[0-9][-0-9a-z]*)//'`
                if test ! "$moc_vers" = "$qtvers" ; then
                    logmsg "$j: moc version ${moc_vers} does not match Qt version ${qtvers}"
                    continue
                fi
                qtmocexe=$j
                logmsg " $qtmocexe is executable"
                break
            fi
        done
        if test ! "x$qtmocexe" = "x" ; then break ; fi
    done

    # Correct path for win32
    if test "x$platform" = "xwin32"; then
        if test ! "x$qtmocexe" = "x" ; then
            qtmocexe=`cygpath -u $qtmocexe`
        fi
    fi
    #  we can pick the wrong moc this way  --  fi
    if test ! "x$qtmocexe" = "x" ; then
        result "$qtmocexe"
        if test "x$platform" = "xwin32"; then
            qtmocexe="$top_srcdir/build/win/qtmoc.sh $qtmocexe"
        fi
    else
        result "no"
    fi

    if test "x$qtincdir" = "x" || test "x$qtlib" = "x" || \
       test "x$qtmocexe" = "x" || test $qtvers -eq 0 ; then
        enable_qt="no"
        enable_qtgsi="no"
    fi
fi
check_explicit "$enable_qt" "$enable_qt_explicit" \
     "Explicitly required Qt dependencies not fulfilled"

######################################################################
#
### echo %%% RFIO Support - Third party libraries
#
# (See http://savannah.cern.ch/files/?group=castor)
#
# Check for rfio_api.h of CASTOR 2 and librfio, libdpm 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:+$RFIO/include} \
        ${RFIO:+$RFIO/include/shift} ${RFIO:+$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 libdpm libcastorrfio libshift shiftmd shift" "$enable_shared" \
        "$shiftlibdir" \
        $RFIO ${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 $shiftlib in
            *dpm)        shiftlib="$shiftlib -llcgdm" ;;
            *castorrfio) shiftlib="$shiftlib -lcastorcommon" ;;
        esac
        case $platform in
           linux | macosx)
                for i in "" -ladns ; do
                    check_link "$shiftlib $i" "$shiftlibdir" rfio_fchmod
                    if test $link_result -eq 1 ; then
                        shiftlib="$shiftlib $i" ;
                        break ;
                    fi
                done
                message "Checking for symbol rfio_fchmod"
                if test $link_result -ne 1 ; then
                    enable_rfio="no"
                    echo "no, disabling rfio"
                else
                    echo "yes"
                fi
                ;;
           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:+$CASTOR/include} \
        ${CASTOR:+$CASTOR/include/shift} ${CASTOR:+$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:+$CASTOR/include} \
        ${CASTOR:+$CASTOR/include/shift} ${CASTOR:+$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.0
        message "Checking for Castor version being >= 2.1.0"
        castor_version=`grep "define BASEVERSION" $castorincdir/patchlevel.h | sed 's/^.*"\([0-9]\.[0-9]\.[0-9]*\)"/\1/' | awk 'BEGIN { FS="." } { printf "%d", $1 * 1000000 + $2 * 1000 + $3}'`
        if test $castor_version -lt 2001000; then
            base_vers=`grep "define BASEVERSION" $castorincdir/patchlevel.h | sed 's/^.*"\([0-9]\.[0-9]\.[0-9]*\)"/\1/' | awk '{ printf $1}'`
            patch_level=`grep "define PATCHLEVEL" $castorincdir/patchlevel.h | awk '{ printf $3}'`
            result "no, $base_vers-$patch_level"
            castorincdir=""
        else
            result "ok"
        fi
    fi

    check_library "libcastorrfio libshift shiftmd shift" "$enable_shared" "$castorlibdir" \
        $CASTOR ${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 $castorlib in
            *castorrfio) castorlib="$castorlib -lcastorclient -lcastorns -lcastorcommon" ;;
        esac
        case $platform in
           linux | macosx)
                for i in "" -ladns ; do
                    check_link "$castorlib $i" "$castorlibdir" rfio_fchmod
                    if test $link_result -eq 1 ; then
                        castorlib="$castorlib $i" ;
                        break ;
                    fi
                done
                message "Checking for symbol rfio_fchmod"
                if test $link_result -ne 1 ; then
                    enable_castor="no"
                    echo "no, disabling castor"
                else
                    echo "yes"
                fi
                ;;
           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:+$GFAL/include} \
        /opt/lcg/include /opt/gfal/include /usr/local/lcg/include \
        /usr/local/gfal/include
    gfalinc=$found_hdr
    gfalincdir=$found_dir

    if test ! "x$gfalincdir" = "x" && grep GFAL2 $gfalincdir/gfal_api.h > /dev/null 2>&1 ; then
        check_library "libgfal2" "$enable_shared" "$gfallibdir" \
            $GFAL ${GFAL:+$GFAL/lib} \
            /opt/lcg/lib /opt/gfal2/lib /usr/local/lcg/lib \
            /usr/local/gfal2/lib
    else
        check_library "libgfal" "$enable_shared" "$gfallibdir" \
            $GFAL ${GFAL:+$GFAL/lib} \
            /opt/lcg/lib /opt/gfal/lib /usr/local/lcg/lib \
            /usr/local/gfal/lib
    fi
    gfallib=$found_lib
    gfallibdir=$found_dir

    check_header "gfal_srm_ifce_types.h" "$srmifceincdir" \
        /opt/lcg/include /opt/srm-ifce/include /usr/local/lcg/include \
        /usr/local/srm-ifce/include
    srmifceinc=$found_hdr
    srmifceincdir=$found_dir

    # check if we have pkg-config
    glib2incdir=
    if `$cwhich pkg-config > /dev/null 2>&1` ; then
        if pkg-config --exists glib-2.0 ; then
            glib2incdir=`pkg-config --cflags-only-I glib-2.0 | sed 's/-I//g'`
        fi
    fi

    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 %%% 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
    check_header "ApMon.h" "$monalisaincdir" \
        $MONALISA ${MONALISA:+$MONALISA/include} \
        /usr/local/include /opt/alien/api/include /opt/monalisa/include \
        /usr/include
    monalisainc=$found_hdr
    monalisaincdir=$found_dir

    check_library "libapmoncpp" "$enable_shared" "$monalisalibdir" \
        $MONALISA ${MONALISA:+$MONALISA/lib} ${MONALISA:+$MONALISA/.libs} \
        /usr/local/lib /opt/alien/api/lib /opt/monalisa/lib /usr/lib
    monalisalib=$found_lib
    monalisalibdir=$found_dir

    if test "x$monalisaincdir" = "x" || test "x$monalisalib" = "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:+$FFTW3/include} ${FFTW3:+$FFTW3/api} \
        ${finkdir:+$finkdir/include} \
        /usr/local/include /usr/include /opt/fftw3/include
    fftw3inc=$found_hdr
    fftw3incdir=$found_dir

    # At this time, libfftw3.a should always be prefered over .so,
    # to avoid forcing users to install fftw3.
    check_library "libfftw3 libfftw3-3" "no" "$fftw3libdir" \
        $FFTW3 ${FFTW3:+$FFTW3/lib} ${FFTW3:+$FFTW3/.libs} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib /opt/fftw3/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 %%% FITSIO Support - Third party libraries
#
# (See http://heasarc.gsfc.nasa.gov/fitsio/)
#
# If the user has set the flags "--disable-fitsio", we don't check for
# FITSIO at all.
#
if test ! "x$enable_fitsio" = "xno"; then
    # Check for cfitsio include and library
    check_header "fitsio.h" "$cfitsioincdir" \
        $CFITSIO ${CFITSIO:+$CFITSIO/include} \
        ${finkdir:+$finkdir/include} \
        /usr/local/include /usr/include /usr/include/cfitsio \
        /opt/cfitsio/include
    cfitsioinc=$found_hdr
    cfitsioincdir=$found_dir

    # At this time, libcfitsio.a should always be prefered over .so,
    # to avoid forcing users to install cfitsio.
    check_library "libcfitsio cfitsio" "no" "$cfitsiolibdir" \
        $CFITSIO ${CFITSIO:+$CFITSIO/lib} ${CFITSIO:+$CFITSIO/.libs} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib /opt/cfitsio/lib
    cfitsiolib=$found_lib
    cfitsiolibdir=$found_dir

    if test "x$cfitsioincdir" = "x" || test "x$cfitsiolib" = "x"; then
        enable_fitsio="no"
    else
        case $platform in
            linux)     cfitsiolib="$cfitsiolib -lpthread -lz"    ;;
        esac
    fi
fi
check_explicit "$enable_fitsio" "$enable_fitsio_explicit" \
     "Explicitly required cfitsio dependencies not fulfilled"

######################################################################
#
### echo %%% graphviz Support - Third party libraries
#
# (See http://www.graphviz.org/)
#
# If the user has set the flags "--disable-gviz", we don't check for
# graphviz at all.
#
if test ! "x$enable_gviz" = "xno"; then
    # Check for graphviz include and library
    check_header "gvc.h" "$gvizincdir" \
        $GVIZ ${GVIZ:+$GVIZ/include/graphviz} ${GVIZ:+$GVIZ/include} \
        ${finkdir:+$finkdir/include/graphviz} \
        /usr/local/include/graphviz /usr/include/graphviz
    gvizinc=$found_hdr
    gvizincdir=$found_dir

    # At this time, libgvplugin_core.a should always be prefered over .so,
    # to avoid forcing users to install graphviz.
    check_library "libgvc gvc" "no" "$gvizlibdir" \
        $GVIZ ${GVIZ:+$GVIZ/lib/graphviz} ${GVIZ:+$GVIZ/lib} ${GVIZ:+$GVIZ/.libs} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib
    gvizlib1=$found_lib
    gvizlib1raw=$found_raw_lib
    gvizlibir=$found_dir
    check_library "libgraph graph libcgraph cgraph" "no" "$gvizlibdir" \
        $GVIZ ${GVIZ:+$GVIZ/lib/graphviz} ${GVIZ:+$GVIZ/lib} ${GVIZ:+$GVIZ/.libs} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib
    gvizlib2=$found_lib
    check_library "libcdt cdt" "no" "$gvizlibdir" \
        $GVIZ ${GVIZ:+$GVIZ/lib/graphviz} ${GVIZ:+$GVIZ/lib} ${GVIZ:+$GVIZ/.libs} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib
    gvizlib3=$found_lib
    check_library "libpathplan pathplan" "no" "$gvizlibdir" \
        $GVIZ ${GVIZ:+$GVIZ/lib/graphviz} ${GVIZ:+$GVIZ/lib} ${GVIZ:+$GVIZ/.libs} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib
    gvizlib4=$found_lib
    check_library "libexpat expat" "$enable_shared" "$gvizlibdir" \
        $GVIZ ${GVIZ:+$GVIZ/lib/graphviz} ${GVIZ:+$GVIZ/lib} ${GVIZ:+$GVIZ/.libs} \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib
    gvizlib5=$found_lib
    gvizlibdir5=$found_dir

    # the plugin libraries are in the directory "$gvizlibdir"/graphviz
    gvizlibpdir=""
    if test "x$gvizlibdir" != "x" ; then
        gvizlibpdir="$gvizlibdir"/graphviz
    fi
    if test "x$platform" = "xwin32"; then
        gvizlibpdir="$gvizlibdir"
    fi
    check_library "libgvplugin_dot_layout gvplugin_dot_layout" "no" "$gvizlibpdir" \
        $GVIZ ${GVIZ:+$GVIZ/lib/graphviz} ${GVIZ:+$GVIZ/lib} ${GVIZ:+$GVIZ/.libs} \
        ${finkdir:+$finkdir/lib/graphviz} \
        /usr/local/lib/graphviz /usr/lib/graphviz
    gvizlibp1=$found_lib
    gvizlibpdir=$found_dir

    if test "x$gvizincdir" = "x" || test "x$gvizlib1"  = "x" ||
       test "x$gvizlib2"   = "x" || test "x$gvizlib3"  = "x" ||
       test "x$gvizlib4"   = "x" ; then
        enable_gviz="no"
    else
       for gvsharedext in .so .sl .dylib .dll.a; do
           gvizshared="$gvizshared`echo $gvizlib1raw | grep '\\'$gvsharedext'\$'`"
       done
       if test "x$gvizshared" = "x" ; then
           if test "x$gvizlibp1" = "x" ; then
               enable_gviz="no"
           else
               gvizcflags=-DGVIZ_STATIC
               gvizlib="$gvizlibp1 $gvizlib1 $gvizlib2 $gvizlib3 $gvizlib4 $gvizlibdir5 $gvizlib5 -lz"
           fi
       else
           gvizlib="$gvizlibir $gvizlib1 $gvizlib2 $gvizlib3 $gvizlib4 $gvizlibdir5 $gvizlib5 -lz"
       fi
       if test "x$platform" = "xwin32"; then
           gvizcflags=
           gvizlib="$gvizlibp1 $gvizlib1 $gvizlib2 $gvizlib3 $gvizlib4"
       else
           if test "x$gvizlib5" = "x" ; then
               enable_gviz="no"
               gvizlib=
               gvizcflags=
           fi
       fi
    fi
fi
check_explicit "$enable_gviz" "$enable_gviz_explicit" \
     "Explicitly required graphviz 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:+$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 %%% Pythia8  Usage - Third party libraries
#
# (See http://root.cern.ch and Lund)
#
# Check for libpythia8 >= 8180
#
if test ! "x$enable_pythia8" = "xno" ; then
    # Check for PYTHIA8 include and library
    check_header "Pythia8/Pythia.h" "$pythia8incdir" \
        $PYTHIA8 ${PYTHIA8:+$PYTHIA8/include} \
        /opt/pythia8/include /usr/local/include /usr/include /usr/include/pythia
    pythia8incdir=$found_dir

    check_library "libpythia8" "$enable_shared" "$pythia8libdir" \
       $PYTHIA8 ${PYTHIA8:+$PYTHIA8/lib} \
       /opt/pythia8/lib /usr/local/lib /usr/lib
    pythia8lib=$found_lib
    pythia8libdir=$found_dir

    if test "x$pythia8incdir" = "x" || test "x$pythia8lib" = "x"; then
       enable_pythia8=no
    fi
fi
check_explicit "$enable_pythia8" "$enable_pythia8_explicit" \
     "Explicitly required Pythia8 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:+$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:+$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_setClientActive "$dcaplib" "$dcaplibdir"
        if test  $found_symbol -eq 0 ; then
            result "### Need dc_setClientActive 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 %%% DavIx Support - Third party libraries
#
useoldwebfile="yes"
if test ! "x$enable_davix" = "xno" ; then
    check_header "davix.hpp" "$davixincdir" \
        $DAVIX ${DAVIX:+$DAVIX/include/davix} \
        /usr/local/include/davix \
        /usr/include/davix
    davixincdir=$found_dir

    check_library "libdavix" "$enable_shared" "$davixlibdir" \
        $DAVIX ${DAVIX:+$DAVIX/lib} ${DAVIX:+$DAVIX/lib64} \
        /usr/lib /usr/local
    davixlib=$found_lib
    davixlibdir=$found_dir

    if test ! "x$davixlib" = "x" ; then
        check_symbol davix_logger "$davixlib" "$davixlibdir"
        if test  $found_symbol -eq 0 ; then
            result "### Need davix_posix_stat in libdavix"
            davixlib=
            davixlibdir=
            davixincdir=
        fi
    fi

    if test "x$davixincdir" = "x" || test "x$davixlib" = "x"; then
        enable_davix="no"
    else
        useoldwebfile="no"
    fi
fi
check_explicit "$enable_davix" "$enable_davix_explicit" \
     "Explicitly required DavIx dependencies not fulfilled"

######################################################################
#
### echo %%% Chirp Support - Third party libraries
#
# (See http://www.cse.nd.edu/~ccl/software/chirp)
#
# Check for libchirp
#
if test ! "x$enable_chirp" = "xno" ; then
    check_header "chirp_reli.h" "$chirpincdir" \
        $CHIRP ${CHIRP:+$CHIRP/include} ${CHIRP:+$CHIRP/include/cctools} \
        /opt/cctools/include /opt/cctools/include/cctools \
        /usr/include /usr/include/cctools \
        /usr/local/cctools/include /usr/local/cctools/include/cctools
    chirpincdir=$found_dir

    check_library "libchirp_client" "no" "$chirplibdir" \
        $CHIRP ${CHIRP:+$CHIRP/lib} \
        /opt/cctools/lib /usr/local/lib /usr/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 %%% HDFS Support - Third party libraries
#
# (See http://hadoop.apache.org/hdfs)
#
# Check for hdfs.h of HDFS and libhdfs
#
if test ! "x$enable_hdfs" = "xno" ; then
    # Check for hdfs include and library
    keepincdir=$hdfsincdir
    check_header "hdfs.h" "$hdfsincdir" \
        $HDFS ${HDFS:+$HDFS/include} ${HDFS:+$HDFS/src/c++/libhdfs} \
        $HADOOP_HOME ${HADOOP_HOME:+$HADOOP_HOME/src/c++/libhdfs} \
        /usr/include /usr/local/include
    hdfsinc=$found_hdr
    hdfsincdir=$found_dir

    if test "x$platform" = "xmacosx" && test -z $JAVA_HOME; then
       JAVA_HOME=`/usr/libexec/java_home`
    fi

    keepincdir=$jniincdir
    check_header "jni.h" "$jniincdir" \
        ${JAVA_HOME:+$JAVA_HOME/include} \
        /usr/java/default/include /usr/include /usr/local/include
    jniinc=$found_hdr
    jniincdir=$found_dir

    check_library "libhdfs" "$enable_shared" "$hdfslibdir" \
        $HDFS ${HDFS:+$HDFS/lib} ${HDFS:+$HDFS/build/libhdfs} \
        $HADOOP_HOME ${HADOOP_HOME:+$HADOOP_HOME/build/libhdfs} \
        /usr/lib /usr/local/lib
    hdfslib=$found_lib
    hdfslibdir=$found_dir

    check_library "libjvm" "$enable_shared" "$jvmlibdir" \
        ${JAVA_HOME:+$JAVA_HOME/jre/lib/amd64/server} \
        ${JAVA_HOME:+$JAVA_HOME/jre/lib/i386/server} \
        ${JAVA_HOME:+$JAVA_HOME/../Libraries} \
        /usr/java/default/jre/lib/amd64/server \
        /usr/java/default/jre/lib/i386/server /usr/lib /usr/local/lib
    jvmlib=$found_lib
    jvmlibdir=$found_dir

    if test "x$hdfsincdir" = "x" || test "x$hdfslib" = "x" || test "x$jniincdir" = "x" || test "x$jvmlib" = "x"; then
        enable_hdfs="no"
    else
        case $platform in
            linux)
                check_link "$hdfslib $jvmlib" "$hdfslibdir $jvmlibdir" hdfsConnect
                if test $link_result -eq 0 ; then
                    enable_hdfs="no"
                fi

                check_link $jvmlib "$jvmlibdir" JNI_CreateJavaVM
                if test $link_result -eq 0 ; then
                    enable_hdfs="no"
                fi
                ;;
        esac
        if test "x$enable_hdfs" = "xno"; then
            echo "HDFS disabled due to failed compile and link test"
        fi
    fi
fi
check_explicit "$enable_hdfs" "$enable_hdfs_explicit" \
     "Explicitly required HDFS dependencies not fulfilled"

######################################################################
#
### echo %%% Bonjour Support - Third party libraries
#
# (See http://developer.apple.com/networking/bonjour/index.html)
#
# By default available on MacOS X and on Linux via the Avahi package.
#
# Check for libdns_sd
#
bonjourcppflags=
case $platform in
    linux|macosx|ios)
        ;;
    *)
        if test "x$enable_bonjour" = "xyes" ; then
            message "Checking whether Bonjour/Avahi is supported"
            result "no (currently only for Linux/MacOSX/iOS)"
        fi
        enable_bonjour=no
        ;;
esac
if test ! "x$enable_bonjour" = "xno" ; then
    case $arch in
        *icc)
            if test "x$enable_bonjour" = "xyes" ; then
               message "Checking whether Bonjour/Avahi is supported"
               result "no (currently not for the icc compiler)"
            fi
            enable_bonjour=no
            ;;
        *)
            ;;
    esac
fi
if test ! "x$enable_bonjour" = "xno" ; then
    # Bonjour is built-in on MacOS X / iOS (i.e. available in libSystem)
    if test ! "x$platform" = "xmacosx" && test ! "x$platform" = "xios" ; then
        check_header "dns_sd.h" "$dnssdincdir" \
            $DNSSD ${DNSSD:+$DNSSD/include} \
            /opt/dnssd/include /usr/include /usr/local/include
        dnssdincdir=$found_dir

        check_library "libdns_sd" "$enable_shared" "$dnssdlibdir" \
            $DNSSD ${DNSSD:+$DNSSD/lib} /opt/dnssd/lib /usr/lib /usr/local/lib
        dnssdlib=$found_lib
        dnssdlibdir=$found_dir

        if test "x$dnssdincdir" = "x" || test "x$dnssdlib" = "x"; then
            enable_bonjour="no"
        fi
    fi

    # If we are on Linux, we must check also for the Avahi libraries.
    if test ! "x$enable_bonjour" = "xno" && test "x$platform" = "xlinux"; then
        # The compatibility layer is needed for the Bonjour record management.
        check_header "avahi-client/client.h" "$avahiincdir" \
            $DNSSD ${DNSSD:+$DNSSD/include} \
            /opt/include /usr/include /usr/local/include
        avahiincdir=$found_dir

        check_header "avahi-common/strlst.h" "$avahiincdir" \
            $DNSSD ${DNSSD:+$DNSSD/include} \
            /opt/include /usr/include /usr/local/include
        avahiincdir=$found_dir

        check_header "avahi-core/core.h" "$avahiincdir" \
            $DNSSD ${DNSSD:+$DNSSD/include} \
            /opt/include /usr/include /usr/local/include
        avahiincdir=$found_dir

        # Also, the library is needed, as in Mac OS X. When found the compat
        # layer, also the other libraries must be in the same location.
        check_library "libavahi-client" "$enable_shared" "$avahilibdir" \
            $DNSSD ${DNSSD:+$DNSSD/lib} /opt/lib /usr/lib /usr/local/lib
        dnssdlib="$dnssdlib $found_lib"
        avahilibdir=$found_dir

        check_library "libavahi-common" "$enable_shared" "$avahilibdir" \
            $DNSSD ${DNSSD:+$DNSSD/lib} /opt/lib /usr/lib /usr/local/lib
        dnssdlib="$dnssdlib $found_lib"
        avahilibdir=$found_dir

        check_library "libavahi-core" "$enable_shared" "$avahilibdir" \
            $DNSSD ${DNSSD:+$DNSSD/lib} /opt/lib /usr/lib /usr/local/lib
        dnssdlib="$dnssdlib $found_lib"
        avahilibdir=$found_dir

        if test "x$dnssdincdir" = "x" || test "x$dnssdlib" = "x"; then
            enable_bonjour="no"
        fi

        if test "x$avahiincdir" = "x"; then
            enable_bonjour="no"
        fi
    fi
    if test ! "x$enable_bonjour" = "xno" ; then
       bonjourcppflags="-DBUILD_BONJOUR"
    fi
fi
check_explicit "$enable_bonjour" "$enable_bonjour_explicit" \
     "Explicitly required Bonjour dependencies not fulfilled"


######################################################################
#
### echo %%% gLite Support - Third party libraries
#
# (See https://subversion.gsi.de/trac/dgrid/wiki)
#
# Check for libglite-api-wrapper
#
if test ! "x$enable_glite" = "xno" ; then
    check_library "libglite-api-wrapper" "$enable_shared" "$glitelibdir" \
      $GAW_LOCATION $GLITE ${GLITE:+$GLITE/lib} \
      ~/GAW/lib /usr/local/lib /usr/lib
    glitelib=$found_lib
    glitelibdir=$found_dir
    gaw_cppflags="${GAW_CPPFLAGS}"

    if  test "x$glitelib" = "x"; then
        enable_glite="no"
    fi
fi
check_explicit "$enable_glite" "$enable_glite_explicit" \
     "Explicitly required gLite 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:+$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:+$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 -lt 1020 ; then
             result "WARNING: System libAfterImage is too old, 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.
    # For Cocoa backend force libAfterImage builtin jpeg and png libs
    # to avoid system versions based on X11.
    if test "x$enable_builtin_afterimage" = "xyes" && test ! "x$enable_cocoa" = "xyes"; then
       check_header "jpeglib.h" "" \
          ${LIBJPEG:+$LIBJPEG/include} \
          $ASIMAGE ${ASIMAGE:+$ASIMAGE/include} \
          ${finkdir:+$finkdir/include} \
          /usr/local/include /usr/include /opt/include
       asjpegincdir=$found_dir
       check_header "png.h" "" \
          ${LIBPNG:+$LIBPNG/include} \
          $ASIMAGE ${ASIMAGE:+$ASIMAGE/include} \
          ${ASPNG:+$ASPNG/include} \
          ${finkdir:+$finkdir/include} \
          /usr/local/include /usr/X11/include /usr/include \
          /usr/local/include/libpng /opt/include
       aspngincdir=$found_dir
       if test ! "x$enable_astiff" = "xno" ; then
           check_header "tiffio.h" "" \
               ${LIBTIFF:+$LIBTIFF/include} \
               $ASIMAGE ${ASIMAGE:+$ASIMAGE/include} \
               ${finkdir:+$finkdir/include} \
               /usr/local/include /usr/include /opt/include
           astiffincdir=$found_dir
       else
           astiffincdir="--with-tiff=no"
       fi

       asextralib=""
       asextralibdir=""
       found_libz=""
       found_dirz=""
       # libz must be before libpng, if libz is not found don't
       # add libpng which needs libz
       if test ! "x$enable_astiff" = "xno" ; then
           aslibs="libjpeg libtiff libz libpng"
       else
           aslibs="libjpeg libz libpng"
       fi
       for k in $aslibs ; do
           check_library $k "$enable_shared" "" \
               ${LIBJPEG:+$LIBJPEG/lib} ${LIBPNG:+$LIBPNG/lib} \
               ${LIBTIFF:+$LIBTIFF/lib} ${ZLIB:+$ZLIB/lib} \
               $ASIMAGE ${ASIMAGE:+$ASIMAGE/lib} ${ASPNG:+$ASPNG/lib} \
               ${finkdir:+$finkdir/lib} \
               /usr/local/lib /usr/X11/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$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=""
       else
           asextralib="$asextralib $found_libz"
           asextralibdir="$asextralibdir $found_dirz"
       fi
   fi
   message "Checking whether to build included libAfterImage"
   result "$enable_builtin_afterimage"
else
   enable_astiff="no"
   enable_builtin_afterimage="no"
fi
check_explicit "$enable_asimage" "$enable_asimage_explicit" \
     "Explicitly required AfterImage dependencies not fulfilled"

######################################################################
#
### echo %%% GEOCAD Library - Contributed library
#
# (See http://www.opencascade.org/)
#
# If the user has set the flags "--disable-geocad", we don't check for
# OpenCascade at all.
#
if test ! "x$enable_geocad" = "xno"; then
    # Check for OpenCascade include and library
    check_header "XCAFApp_Application.hxx" "$occincdir" \
        $CASROOT ${CASROOT:+$CASROOT/inc} /usr/include/opencascade \
        /usr/include
    occinc=$found_hdr
    occincdir=$found_dir

    check_library "libTKXCAF" "$enable_shared" "$occlibdir" \
       $CASROOT ${CASROOT:+$CASROOT/lib} /usr/lib
    occlib=$found_lib
    occlibdir=$found_dir

    if test ! "x$occlib" = "x" ; then
       occlib="-lTKPrim -lTKBRep -lTKOffset -lTKGeomBase -lTKShHealing -lTKTopAlgo -lTKSTEP -lTKG2d -lTKBool -lTKBO -lTKXCAF -lTKXDESTEP -lTKLCAF -lTKernel -lTKXSBase -lTKG3d -lTKMath"
    fi

    if test "x$occincdir" = "x" || test "x$occlib" = "x"; then
        enable_geocad="no"
    fi
fi
check_explicit "$enable_geocad" "$enable_geocad_explicit" \
     "Explicitly required GeoCad 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:+$LDAP/include} \
        ${finkdir:+$finkdir/include} \
        /usr/include/openldap /usr/include /usr/local/include \
        /usr/local/ldap/include /usr/include/ldap /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

    ldaplibdir1="$ldaplibdir"
    ldaplib=""
    ldaplibdir=""

    for i in libldap liblber ; do
        check_library $i "$enable_shared" "$ldaplibdir1" \
            $LDAP ${LDAP:+$LDAP/lib} \
            ${finkdir:+$finkdir/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
    # PyROOT depends on cling
    message "Checking for PyROOT prerequisites"
    result "yes"
fi
if test ! "x$enable_python" = "xno" ; then
    # Check for Python include and library
    if test ! "x$pythonexe" = "x" && test -x "$pythonexe" ; then
       pythonvers=`$pythonexe -c 'import sys; sys.stdout.write(sys.version[:3])'`
       pythonsysincdir=`$pythonexe -c 'import sys; sys.stdout.write(sys.prefix + "/include/python" + sys.version[:3])'`
       pythonsyslibdir=`$pythonexe -c 'import sys; sys.stdout.write(sys.prefix + "/lib")'`
       pythonsyslibdir2=
       if test "x$platform" = "xmacosx"; then
          pythonsyslibdir2=`$pythonexe -c 'import sys; sys.stdout.write(sys.prefix)'`
       fi
    fi
    check_header "Python.h" "$pythonincdir" \
        $PYTHONDIR ${PYTHONDIR:+$PYTHONDIR/include} \
        ${PYTHONDIR:+$PYTHONDIR/include/python} $pythonsysincdir
    pythoninc=$found_hdr
    pythonincdir=$found_dir
    pysuffix=""
    if test "x$platform" = "xwin32"; then
       if test ! "x$pythonexe" = "x" && test -x "$pythonexe" ; then
          pythonvers=`$pythonexe -c 'import sys; sys.stdout.write(sys.version[:3].replace(".",""))' | tr -d '\r'`
          if test ! "x$pythonincdir" = "x" ; then
             pythonincdir=`cygpath -m $pythonincdir`
          fi
       fi
       if test "x$enable_winrtdebug" = "xyes"; then
          pysuffix="_d"
       fi
    fi

    check_library "python${pythonvers}${pysuffix} libpython${pythonvers}${pysuffix} \
                   libpython${pysuffix} python${pysuffix} Python${pysuffix}" \
        "$enable_shared" "$pythonlibdir" \
        ${PYTHONDIR:+$PYTHONDIR/libs} ${PYTHONDIR:+$PYTHONDIR/lib} \
        $PYTHONDIR $pythonsyslibdir $pythonsyslibdir2 \
        /usr/local/lib /usr/lib $pythonsyslibdir/config
    pythonlib=$found_lib
    pythonlibdir=$found_dir

    if test "x$pythonincdir" = "x" || test "x$pythonlib" = "x"; then
        enable_python="no"
        if test "x$platform" = "xwin32" && test "x$enable_winrtdebug" = "xyes" && \
           test "x$pythonlib" = "x" && test ! "x$pythonincdir" = "x"; then
               echo "INFO: Debug version of Python (python${pythonvers}${pysuffix}.lib) " \
                    "not found! Disabling Python support. If you need it, install the " \
                    "debug version or use --disable-winrtdebug"
        fi
    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 RbConfig::CONFIG["rubyhdrdir"]'`
       rubysysarchdir=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]'`
       rubysyslibdir=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["libdir"]'`
       rubysysarch=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["arch"]'`

       if test "x$rubysysincdir" = "xnil" ; then
          rubysysincdir=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["includedir"]'`
       fi
    fi
    rubysysarchdir2=
    if test "x$platform" = "xmacosx" ; then
       rubysysarchdir2=`echo $rubysysarchdir | sed -e 's/powerpc/universal/'`
    fi
    check_header "ruby.h" "$rubyincdir" \
        $RUBYDIR ${RUBYDIR:+$RUBYDIR/include} \
        $rubysysincdir $rubysysarchdir $rubysysarchdir2 \
        /usr/local/include/ruby /usr/include/ruby
    rubyinc=$found_hdr
    rubyincdir=$found_dir
    check_header "ruby/config.h" "" $rubysysincdir/$rubysysarch
    if test "x$found_hdr" != "x" ; then
        rubyincdir="$rubyincdir $found_dir"
    fi

    rubylib=""
    if test ! "x$myruby" = "x" && test -x "$myruby" ; then
       if test "x$arch" = "xwin32" || \
          test "x$enable_shared" = "xno" ; then
           check_library_options=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_A"]' | sed 's|\.a.*||'`
        else
           check_library_options=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY"]' | sed 's|\.so.*||'`
        fi
        check_library "$check_library_options" \
           "$enable_shared" "$rubylibdir" \
           $RUBYDIR ${RUBYDIR:+$RUBYDIR/lib} \
           $rubysyslibdir \
           /usr/local/lib /usr/lib
        rubylib=$found_lib
        rubylibdir=$found_dir
    fi

    if test "x$rubyincdir" = "x" || test "x$rubylib" = "x"; then
        enable_ruby="no"
    else
        # Ruby support requires the explicitlink option
        enable_explicitlink="yes"
        if test ! "x$platform" = "xwin32"; then
            issue_explicitlink_warning="yes"
        fi
    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
    if test "x$platform" = "xmacosx"; then
        # prefer native libxml2 over the one in Fink (/sw)
        PATH=/usr/bin:$PATH
    fi
    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" && test "x$host" = "x" && \
       test "x$xmlincdir" = "x" && test "x$xmllibdir" = "x"; 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:+$XMLDIR/include} \
           ${finkdir:+$finkdir/include/libxml2} \
           /opt/include/libxml2 /usr/local/include/libxml2 /usr/include/libxml2
       xmlincdir=$found_dir

       keeplibdir=$xmllibdir
       check_library "libxml2_a libxml2" "$enable_shared" "$xmllibdir" \
           $XMLDIR ${XMLDIR:+$XMLDIR/lib} ${XMLDIR:+$XMLDIR/.libs} \
           ${finkdir:+$finkdir/lib} \
           /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:+$ICONVDIR/include} \
              $XMLDIR ${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:+$ICONVDIR/lib} \
              $XMLDIR ${XMLDIR:+$XMLDIR/lib} ${XMLDIR:+$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"            ;;
             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
#
if test "x$enable_xrootd" = "xyes" ; then
   xrdcomm=""
   vercomm=""
   extraxrdflags=""

   # Localize the version header; priority to specific inc and lib settings,
   # followed by global dir setting and standard paths
   xrdincone=""
   xrdinctwoa=""
   xrdinctwob=""
   xrdinctmp=""
   if test ! "x$xrdlibdir" = "x" && test ! "x$xrdincdir" = "x"; then
      xrdincone="$xrdincdir/XrdVersion.hh"
      xrdlibone="$xrdlibdir"
      xrdinctmp="$xrdincdir $xrdinctmp"
   elif test ! "x$xrootddir" = "x"; then
      xrdlibtwo="$xrootddir"
      xrdinctwoa="$xrootddir/include/xrootd/XrdVersion.hh"
      xrdinctwob="$xrootddir/src/XrdVersion.hh"
      xrdinctmp="$xrootddir/include/xrootd $xrootddir/src $xrdinctmp"
   else
      # Standard paths
      xrdpaths="$XRDSYS /opt/xrootd /usr/local /usr"
      for stdp in $xrdpaths ; do
         if test -d "$stdp/lib" || test -d "$stdp/lib64" ; then
            xrdlibthree="$xrdlibthree $stdp/lib"
            xrdinctmp="$xrdinctmp $stdp/include/xrootd $stdp/include"
         fi
      done
   fi
   # Run the search now
   check_header "XrdVersion.hh" "" "$xrdinctmp"
   if test ! "x$found_hdr" = "x" ; then
      xrdinc="$found_dir/$found_hdr"
      # Find out which path was the good one
      if test "x$xrdinc" = "x$xrdincone" ; then
         xrdincdir="$found_dir"
         xrdlibdir="$xrdlibone"
      elif test "x$xrdinc" = "x$xrdinctwoa" ; then
         xrdincdir="$xrdlibtwo/include/xrootd"
         xrdlibdir="$xrdlibtwo/lib"
      elif test "x$xrdinc" = "x$xrdinctwob" ; then
         xrdincdir="$xrdlibtwo/src"
         xrdlibdir="$xrdlibtwo/lib"
      else
         for ll in $xrdlibthree ; do
            rdir=`dirname $ll`
            xinca="$rdir/include/xrootd/XrdVersion.hh"
            xincb="$rdir/include/XrdVersion.hh"
            if test "x$xrdinc" = "x$xinca" ; then
               xrdincdir="$rdir/include/xrootd"
               xrdlibdir="$ll"
            elif test "x$xrdinc" = "x$xincb" ; then
               xrdincdir="$rdir/include"
               xrdlibdir="$ll"
            fi
            if test ! "x$xrdincdir" = "x" ; then
               break
            fi
         done
         # Only here if something inconsistent was found
         if test "x$xrdincdir" = "x" ; then
            enable_xrootd="no"
            xrdincdir=""
            xrdlibdir=""
         fi
      fi
   else
      enable_xrootd="no"
      xrdincdir=""
      xrdlibdir=""
   fi
fi

# Decode version
xrdver=
decver=0
if test "x$enable_xrootd" = "xyes" ; then

   message "Checking for xrootd version"

   verh=$xrdincdir/XrdVersion.hh

   xrdver=`grep XrdVERSION $verh`
   if test $? -eq 0 ; then
      set $xrdver
      xrdver=$3
   else
      xrdver="unknown"
   fi
   if test "x$xrdver" = "x\"unknown\"" ; then
      xrdver="unknown"
   fi
   if test ! "x$xrdver" = "xunknown"; then
      tmpver=`echo $xrdver | sed -e 's|"\(.*\)"|\1|' -e 's|^v||' -e 's|-.*||'`
      if test "x$tmpver" = "xuntagged" ; then
         decver=9999999999
      else
         oldver="no"
         hasdash=`echo $tmpver | grep '-'`
         hasdot=`echo $tmpver | grep '\.'`
         if test ! "x$hasdash" = "x" || test "x$hasdot" = "x"; then
            oldver="yes"
         fi
         if test "x$oldver" = "xno" ; then
            if test ! "x$hasdot" = "x" ; then
               ver1=`echo $tmpver | cut -d . -f 1`
               ver2=`echo $tmpver | cut -d . -f 2`
               if test "x$ver1.$ver2" = "x$tmpver" ; then
                  oldver="yes"
               else
                  ver3=`echo $tmpver | cut -d . -f 3`
                  decver=`expr $ver1 \* 100000000 + $ver2 \* 10000 + $ver3`
               fi
            fi
         fi
         if test "x$oldver" = "xyes" ; then
            decver=`echo $tmpver | sed 's|[^0-9]||g' | cut -c1-8`
         fi
      fi
   fi
   if test "x$xrdver" = "xunknown" ; then
      decver=9999999999
      xrdver="unknown"
   fi
   # Protect against 3.3.0, first version with 'include/xrootd/private'
   if [ $decver -eq 300030000 ] ; then
      echo "Cannot build against version $xrdver (missing headers)"
      enable_xrootd="no"
   else
      echo "$xrdver ($decver)"
   fi
fi

xrdincprivate="no"
buildxproofd="yes"
buildxrdclt="no"
if test "x$enable_xrootd" = "xyes" ; then

   extraxrdflags="-DROOTXRDVERS=$decver"
   vercomm="setting $extraxrdflags"

   #
   # Check libraries now
   hasxrdutils="no"
   libxrdoucbjr=""
   #
   # Release date of version 3.1.0 containing the new lib packaging
   decreftre=300000000
   decrefutils=300010000
   decreffour=400000000
   if [ $decver -lt $decreftre ] ; then
      decrefutils=20111021
   fi
   decrefnetut=20100729
   if [ $decver -ge $decreffour ] ; then
      xrdlibs="libXrdUtils libXrdClient"
      hasxrdutils="yes"
      buildxproofd="no"
   elif [ $decver -ge $decrefutils ] ; then
      xrdlibs="libXrdMain libXrdUtils libXrdClient"
      hasxrdutils="yes"
   elif [ $decver -ge $decrefnetut ] ; then
      xrdlibs="libXrdNet libXrdNetUtil libXrdOuc libXrdSys libXrdClient libXrd"
   else
      xrdlibs="libXrdNet libXrdOuc libXrdSys libXrdClient libXrd"
   fi
   tmpxrdlibdir=""
   xrdlibext=""
   for ll in $xrdlibs ; do
      #
      # Check if packaging has libXrdUtils or the old libXrdOuc, libXrdSys, ...
      check_library $ll "$enable_shared" "$xrdlibdir" "$xrdlibdir"
      if test "x$found_lib" = "x" ; then
         if test "x$ll" = "xlibXrdClient" ; then
            buildxrdclt="yes"
         else
            enable_xrootd="no"
            xrdincdir=""
            xrdlibdir=""
         fi
         break
      else
         xrdlibext="$found_ext"
         tmpxrdlibdir="$found_dir"
         if test "x$ll" = "xlibXrdUtils" || test "x$ll" = "xlibXrdOuc"; then
            libxrdoucbjr="$found_lib"
         fi
      fi
   done

   #
   # If not 'so' or 'a', comunicate the extension for the library loadings
   # in XrdProofd. This may be temporary, as xrootd may do it automatically,
   # one day ...
   if test ! "x$xrdlibext" = "x" && test ! "x$xrdlibext" = "xso" && test ! "x$xrdlibext" = "xa"; then
      # The \'s are needed to produce -DLT_MODULE_EXT=\".ext\" in Makefile.config
      extraxrdflags="$extraxrdflags -DLT_MODULE_EXT=\\\\\".$xrdlibext\\\\\""
   fi

   #
   # Check also if 'include/private' exists: we need to signal this to the build modules
   # for correct location of some headers available form the dlevel packages for version >= 3.3.x
   if test "x$enable_xrootd" = "xyes"; then
      if test -d "$xrdincdir/private"; then
         xrdincprivate="yes"
      fi
   fi

   #
   # Check if bonjour is available for code potentially using it ...
   if test "x$enable_xrootd" = "xyes"; then
      xrdlibdir="$tmpxrdlibdir"
      if test "x$enable_bonjour" = "xyes"; then
         check_symbol XrdOucBonjour "$libxrdoucbjr" "$xrdlibdir"
         if test  $found_symbol -eq 0 ; then
            bonjourcppflags=
         fi
      fi
   fi

   #
   # Build the new client interface (libNetxNG) only for xrootd >= 3.3.5
   decrefng=300030005
   buildnetxng="no"
   useoldnetx="yes"
   message "Checking whether new xrootd client (libNetxNG) should be build"
   if [ $decver -ge $decrefng ] ; then
      buildnetxng="yes"
      useoldnetx="no"
   fi
   result $buildnetxng
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
       if test ! "x$globusdir" = "x" ; then
          globusincdir=$globusdir/include
       else
          globusincdir=/usr/include
       fi
    fi
    searchincdir="$globusincdir/gcc32 $globusincdir/gcc32dbg \
                  $globusincdir/gcc32pthr $globusincdir/gcc32dbgpthr \
                  $globusincdir/gcc64 $globusincdir/gcc64dbg \
                  $globusincdir/gcc64pthr $globusincdir/gcc64dbgpthr \
                  $globusincdir/globus $globusincdir"

    # Found the reference dir first
    # Used to check for openssl/x509.h, but since we might be using
    # the system default, we have replaced this with globus_gss_assist.h
    check_header "globus_gss_assist.h" "" "$searchincdir"
    if test "x$found_hdr" = "x" ; then
       globusinc=""
       globusincdir=""
       enable_globus="no"
    else
       flavour=`basename $found_dir`
       if test "x$flavour" = "xglobus" ; then
          flavour=
          flavour_suf=
       else
          flavour_suf=_${flavour}
       fi

       globusinc="$globusinc $found_hdr"
       globusincdir=$found_dir

       # The other headers now
       # Used to search for openssl/pem.h and globus_gss_assist.h here,
       # but those are removed, because we might be using the openssl of the
       # system, and we already checked for globus_gss_assist.h
       inclist="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
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

   if test "x$globuslibdir" = "x" ; then
       if test ! "x$globusdir" = "x" ; then
          globuslibdir=$globusdir/lib
       else
          globuslibdir=/usr/lib
       fi
    fi

   globuslib=""
   searchlibdir=$globuslibdir
   globuslibdir=""
   extra_inc=

   globuslibs="libglobus_gss_assist${flavour_suf}
              libglobus_gssapi_gsi${flavour_suf}
              libglobus_gsi_credential${flavour_suf}
              libglobus_common${flavour_suf}
              libglobus_gsi_callback${flavour_suf}
              libglobus_proxy_ssl${flavour_suf}
              libglobus_gsi_sysconfig${flavour_suf}
              libglobus_openssl_error${flavour_suf}
              libglobus_gssapi_gsi${flavour_suf}
              libglobus_gsi_callback${flavour_suf}
              libglobus_oldgaa${flavour_suf}
              libglobus_gsi_cert_utils${flavour_suf}
              libglobus_openssl${flavour_suf}
              libglobus_gsi_proxy_core${flavour_suf}
              libglobus_callout${flavour_suf}
              libltdl${flavour_suf}
              libssl${flavour_suf}
              libcrypto${flavour_suf}"

   for i in $globuslibs ; do
      check_library $i "$enable_shared" "$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
      if test "x$extra_inc" = "x" && test ! "x$found_raw_dir" = "x" ; then
         extra_inc=$found_raw_dir/globus/include
      fi
   done

   if test ! "x$extra_inc" = "x" ; then
      message "Checking whether $extra_inc should be added to header path"
      if test -d $extra_inc ; then
         globusincdir="$globusincdir $extra_inc"
         result "yes"
      else
         result "no"
      fi
   fi
fi

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

   # Need to source this before init proxies (when not in default path)
   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"
   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"
   elif which grid-proxy-init > /dev/null 2>&1 ; then
      initpath=`which grid-proxy-init`
      initpath=`dirname $initpath`
   fi
   if test "x$initpath" = "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=""

   message "Checking for globus-gsi-credential version"

   # check if we have pkg-config
   if `$cwhich pkg-config > /dev/null 2>&1` ; then
      if pkg-config --exists globus-gsi-credential ; then
         version=`pkg-config --modversion globus-gsi-credential`
         result "$version"
      fi
   fi

   if test "x$version" = "x" ; then

   # 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
      if test ! "x$packfileinfo" = "x" ; then
         packfiletmp=`basename $packfileinfo`
         echo "Checking for $packfiletmp ... $packdir"
         versionstr=`grep Aging_Version $packfileinfo`
         majorversion=`echo $versionstr | sed 's!.*Major="\([0-9]*\)".*!\1!'`
         minorversion=`echo $versionstr | sed 's!.*Minor="\([0-9]*\)".*!\1!'`
         version=$majorversion.$minorversion
         result "$version"
      fi
   fi

   fi

   if test ! "x$version" = "x" ; then
      versionmajor=`echo $version | cut -d. -f1`
      versionminor=`echo $version | cut -d. -f2`
      if test ! "x$versionmajor" = "x0" || (
         test ! "x$versionminor" = "x5" &&
         test ! "x$versionminor" = "x7" &&
         test ! "x$versionminor" = "x8" &&
         test ! "x$versionminor" = "x9" ) ; 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 "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

     #
     # dirs: --with-ssl-incdir and --with-ssl-libdir have priority on --with-ssl-dir
     #       in both cases we link statically unless --with-ssl-shared is 'yes'
     #
     if test ! "x$ssldir" = "x" ; then
        if test "x$sslincdir" = "x" ; then
           sslincdir=$ssldir/include
        fi
        if test "x$ssllibdir" = "x" ; then
           ssllibdir=$ssldir/lib
        fi
        if test "x$sslshared" = "x" ; then
           sslshared=no
        fi
     else
        if test ! "x$ssllibdir" = "x" ; then
           if test "x$sslshared" = "x" ; then
              sslshared=no
           fi
        fi
     fi
     if test "x$sslshared" = "x" ; then
        sslshared="$enable_shared"
     fi
     #
     # libssl
     #
     if test "x$platform" = "xwin32"; then
        if test "x$enable_winrtdebug" = "xyes"; then
           libssl="libssl ssleay32 ssleay32MDd"
        else
           libssl="libssl ssleay32 ssleay32MD"
        fi
     else
        libssl="libssl"
     fi
     tmpssllibdir=""
     check_library "$libssl" "$sslshared" "$ssllibdir" \
         $SSL ${SSL:+$SSL/lib} \
         ${finkdir:+$finkdir/lib} \
         /usr/lib /usr/local/lib /opt/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$sslshared" = "xno" ; then
               sslshared=no
            fi
         else
            ssllibdir="$found_dir"
            tmpssllibdir=`echo $ssllibdir | cut -c3-`
         fi

         #
         # libcrypto, in the same dir
         #
         if test "x$platform" = "xwin32"; then
            if test "x$enable_winrtdebug" = "xyes"; then
               libcrypto="libcrypto libeay32 libeay32MDd"
            else
               libcrypto="libcrypto libeay32 libeay32MD"
            fi
         else
            libcrypto="libcrypto"
         fi
         check_library "$libcrypto" "$sslshared" "$tmpssllibdir" \
             $SSL ${SSL:+$SSL/lib} \
             ${finkdir:+$finkdir/lib} \
             /usr/lib /opt/lib /usr/local/lib
         cryptolib=$found_lib
         cryptolibdir=$found_dir
         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

    if test "x$sslshared" = "xno" ; then
       echo "Using OpenSSL static libraries"
    fi

    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:+$SSL/include} \
           ${finkdir:+$finkdir/include} \
           /usr/include /usr/local/include /opt/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:+$SRP/include} ${SRP:+$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:+$SRP/lib} ${SRP:+$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:+$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
#
afsextracflags=""
if test ! "x$enable_afs" = "xno" ; then

    if test ! "x$afsdir" = "x" ; then
       # Set the search paths, giving priority to explicit settings
       if test "x$afslibdir" = "x" ; then
          afslibdir="$afsdir/lib"
       fi
       if test "x$afsincdir" = "x" ; then
          afsincdir="$afsdir/include"
       fi
       if test "x$afsshared" = "x" ; then
          # With external libs, default is static
          afsshared="no"
       fi
    fi

    if test "x$afsshared" = "x" ; then
       # Use global default if none set
       afsshared=$enable_shared
    fi

    hasafserrormessage="no"
    afssearchlibdirs="${afsdir:+$afsdir/afs} ${AFS:+$AFS/lib} \
                      ${finkdir:+$finkdir/lib} \
                      /usr/lib /usr/local/lib /opt/lib"
    afslibs="libafsrpc libafsauthent"
    if test "x$afsshared" = "xyes" ; then

       # We try to use the shared version of the libraries; however, for OpenAFS
       # versions <= 1.4.6 these were inconsistent, some needed symbols not being
       # exported. We need to check the symbols first
       echo "Checking for shared AFS libs:"
       check_library libafsrpc "$afsshared" "$afslibdir" $afssearchlibdirs
       if test ! "x$found_lib" = "x"; then
         afslib="$found_lib"
         afslibdirs="$found_dir"
         #
         # Check symbols
         #
         afssymbols="afs_add_to_error_table strcompose stolower ucstring lcstring AssertionFailed"
         for s in $afssymbols ; do
            check_symbol $s "$found_lib" "$found_dir"
            if test  $found_symbol -eq 0 ; then
               afslib=""
               afslibdirs=""
               afsshared="no"
               break
            fi
         done
         #
         # Save lib, if OK
         if test "x$afsshared" = "xyes" ; then
            # Check for afs_error_message, if needed
            if test "x$hasafserrormessage" = "xno" ; then
               check_symbol afs_error_message "$found_lib" "$found_dir"
               if test  $found_symbol -eq 1 ; then
                  hasafserrormessage="yes"
               fi
            fi
            check_library libafsauthent "$afsshared" "$afslibdir" $afssearchlibdirs
            if test ! "x$found_lib" = "x" ; then
               check_symbol ka_GetAFSTicket "$found_lib" "$found_dir"
               if test  $found_symbol -eq 0 ; then
                  afslib=""
                  afslibdirs=""
                  afsshared="no"
                  break
               else
                  afslib="$afslib $found_lib"
                  havedir="no"
                  for l in $afslibdirs ; do
                     if test "x$l" = "x$found_dir" ; then
                        havedir="yes"
                     fi
                  done
                  if test "x$havedir" = "xno" ; then
                     afslibdirs="$afslibdirs $found_dir"
                  fi
               fi
            else
               afslib=""
               afslibdirs=""
               afsshared="no"
            fi
         fi
       else
         afsshared="no"
       fi
    fi

    if test "x$enable_afs" = "xyes" && test "x$afsshared" = "xno" ; then
       #
       # Static Libraries
       echo "Checking for static AFS libs:"
       #
       for i in $afslibs ; do
          check_library "$i" "$afsshared" "$afslibdir" $afssearchlibdirs
          if test "x$found_lib" = "x" ; then
             afslib=""
             afslibdirs=""
             enable_afs="no"
             break
          fi
          afslib="$found_lib $afslib"

          # Check for afs_error_message, if needed
          if test "x$hasafserrormessage" = "xno" ; then
             check_symbol afs_error_message "$afslib" "$afslibdir"
             if test  $found_symbol -eq 1 ; then
                hasafserrormessage="yes"
             fi
          fi
       done
    fi
    #
    # header files
    #
    if test "x$enable_afs" = "xyes" ; then

       check_header "afs/kautils.h" "$afsincdir" \
          ${finkdir:+$finkdir/include} \
          /usr/include /usr/local/include /opt/include
       if test ! "x$found_hdr" = "x" ; then
          afsincdir="-I$found_dir"
          tmpincdir=$found_dir
          otherincafs="stds.h com_err.h"
          for i in $otherincafs ; do
             if test ! -f "$tmpincdir/afs/$i" ; then
                echo "Checking for afs/$i ... no"
                afsincdir=""
                enable_afs="no"
                break
             else
                echo "Checking for afs/$i ... $tmpincdir"
             fi
          done
       else
          afsincdir=""
          enable_afs="no"
       fi
    fi

    if test "x$afslib" = "x" ; then
        enable_afs="no"
    else
        afsextracflags="-DR__AFS"
        # flag for error_message prototype
        if test "x$hasafserrormessage" = "xno" ; then
           afsextracflags="$afsextracflags -DR__AFSOLDCOMERR"
        fi
        # Warn about usage of static libs to build a shared object
        if test "x$afsshared" = "xno" ; then
            echo "### WARNING: AFS enabled using static libraries: this may lead to relocation-related"
            echo "### errors or warnings if the static libraries are not compiled with the correct options;"
            echo "### if this happens, please re-run with --enable-shared or rebuild the AFS static libs "
            echo "### with the '-fPIC' option."
        fi
    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
    krb5heff=
    check_header "krb5.h" "$krb5incdir" /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
        krb5heff=$found_dir/$found_hdr
        krb5inc=$found_hdr
        krb5incdir=$found_dir
    fi

    if test ! "x$enable_krb5" = "xno" ; then
       #
       # Check if 'krb5heff' is the real one or if it re-directs
       # to <krb5/krb5.h>
       message "Checking for krb5.h redirect"
       redir=`grep "krb5\/krb5\.h" $krb5heff 2> /dev/null`
       if test ! "x$redir" = "x" ; then
          krb5heff=`dirname $krb5heff`/krb5/krb5.h
       fi
       result $krb5heff

       #
       # Check for prototypes in krb5.h
       hask5vcstproto=`grep krb5_c_valid_cksumtype $krb5heff 2> /dev/null`
       if test ! "x$hask5vcstproto" = "x" ; then
          echo "Checking for krb5_c_valid_cksumtype in krb5.h ... yes"
          hask5vcstproto="yes"
       else
          echo "Checking for krb5_c_valid_cksumtype in krb5.h ... no"
          hask5vcstproto="no"
       fi
       hasvcstproto=`grep valid_cksumtype $krb5heff | grep -v krb5_c_valid_cksumtype 2> /dev/null`
       if test ! "x$hasvcstproto" = "x" ; then
          echo "Checking for valid_cksumtype in krb5.h ... yes"
          hasvcstproto="yes"
       else
          echo "Checking for valid_cksumtype in krb5.h ... no"
          hasvcstproto="no"
       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/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"
    fi

    # Only MIT kerberos is currently supported
    if test ! "x$enable_krb5" = "xno"  && test "x$krb5mit" = "xyes" ; then

      # Check for 'valid_cksumtype' symbols
      check_symbol krb5_c_valid_cksumtype $krb5lib "$krb5libdir"
      if test $found_symbol -eq 1 ; then
         hask5vcstsymbol="yes"
      fi
      check_symbol valid_cksumtype $krb5lib "$krb5libdir"
      if test $found_symbol -eq 1 ; then
         hasvcstsymbol="yes"
      fi

      if test "x$hask5vcstsymbol" = "xyes" && test "x$hask5vcstproto" = "xno" ; then
         needsvcstproto="-DR__KRB5_NEED_VCST_PROTO"
      elif test ! "x$hask5vcstsymbol" = "xyes" ; then
         if test "x$hasvcstsymbol" = "xyes" ; then
            needsvcstdefine="-DR__KRB5_NEED_VCST_DEFINE"
            if test "x$hasvcstproto" = "xno" ; then
               needsvcstproto="-DR__KRB5_NEED_VCST_PROTO"
            fi
         else
            echo "Either 'krb5_c_valid_cksumtype' or 'valid_cksumtype' are available; disabling krb5"
               enable_krb5=no
         fi
      fi

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

         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/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
       fi
    else
       enable_krb5=no
    fi

    if test ! "x$enable_krb5" = "xyes" ; then
        krb5incdir=""
        krb5lib=""
        krb5libdir=""
    else
        krb5extracflags="-DR__KRB5 $needsvcstproto $needsvcstdefine"
        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/lib"
    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" \
        "$afssearchlibdirs $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 %%% check for Vc Library compile flags
#
avxcxxflag=""
ssecxxflags=""
abiversioncxxflag=""
vcflags=""
if test "x$enable_vc" = "xyes"; then
    message "Checking required compiler/assembler workarounds"
    # with GCC and Open64 check the binutils version. If it's less than 2.18.93 the assembler doesn't know xgetbv
    case $arch in
    macos*)
       ;;
    linuxppc*)
       enable_vc="no"
       ;;
    *)
       as=`${altcxx} -print-prog-name=as`
       as_version=`${as} --version|head -n1|sed -e 's/^.*)//' -e 's/^.* \([0-9]\+\.[0-9]\+\.[0-9]\+\).*$/\1/'|awk -F. '{print ($1*1000+$2)*1000+$3}'`
       if test $as_version -lt 2018093; then
          vcflags="$vcflags -DVC_NO_XGETBV"
       fi
       ;;
    esac
    invoke_preprocessor <<EOF
#define _MAKE_VERSION(A, B, C) A##.##B##.##C
#define MAKE_VERSION(A, B, C) _MAKE_VERSION(A, B, C)
#ifdef __INTEL_COMPILER
ICC
__INTEL_COMPILER_BUILD_DATE
#elif defined(__OPENCC__)
Open64
#elif defined(__clang__)
clang
MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
#elif defined(__GNUC__)
GCC
MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#elif defined(_MSC_VER)
MSVC
_MSC_FULL_VER
#else
UNSUPPORTED_COMPILER
#endif
EOF
    compiler=`echo "$preprocessor_output"|sed '1!d'`
    compiler_version=`echo "$preprocessor_output"|sed '2!d'|awk -F. '{ print ($1*100+$2)*100+$3 }'`
    avx_broken=false
    sse_broken=false
    xop_broken=false
    fma4_broken=false
    case $compiler in
        ICC)
            vcflags="$vcflags -diag-disable 913"
            ;;
        Open64)
            avx_broken=true
            ;;
        clang)
            if test $compiler_version -lt 30100; then
                echo
                echo "Clang before version 3.1 is unable to compile Vc correctly. Please update clang or disable Vc."
                exit 1
            fi
            ;;
        GCC)
            vcflags="$vcflags -Wno-unused-function"
            if test $compiler_version -lt 40500; then
                vcflags="$vcflags -Wno-parentheses  -Wno-strict-aliasing -Wno-uninitialized"
                if test $compiler_version -lt 40406; then
                    avx_broken=true
                    if test $compiler_version -lt 40300; then
                        sse_broken=true
                        if test $compiler_version -lt 40200; then
                            vcflags="$vcflags -fno-strict-aliasing"
                        fi
                    fi
                fi
            elif test $compiler_version -eq 40600; then
                avx_broken=true
            elif test $compiler_version -eq 40700; then
                vcflags="$vcflags -fno-predictive-commoning"
            fi
            if test "x$platform" = "xmacosx" ; then
                avx_broken=true
                vcflags="$vcflags -DVC_NO_XGETBV"
            fi
            ;;
        MSVC)
            vcflags="$vcflags -DNOMINMAX"
            xop_broken=true
            fma4_broken=true
            ;;
        UNSUPPORTED_COMPILER)
            ;;
    esac

    test -n "$vcflags" && result "$vcflags" || result ''

    # check for SIMD compiler flags
    message "Checking SIMD specific compiler flags"
    $avx_broken || for flag in '-xAVX' '-mavx' '/arch:AVX'; do
        check_cxxopt $flag
        if test $cxxopt_result -eq 1; then
            avxcxxflag=$flag
            break;
        fi
    done
    $sse_broken || for tuples in '-xSSE4.1;-msse4.1' '-xSSSE3;-mssse3' '-xSSE3;-msse3' '-xSSE2;-msse2;/arch:SSE2'; do
        save_IFS="$IFS"
        IFS=';'
        for flag in $tuples; do
            IFS="$save_IFS"
            check_cxxopt $flag
            if test $cxxopt_result -eq 1; then
                ssecxxflags="$ssecxxflags $flag"
                break;
            fi
        done
    done
    if test -n "$avxcxxflag" && ! $xop_broken && ! $fma4_broken; then
        for flag in '-mxop -mfma4'; do
            check_cxxopt $flag
            if test $cxxopt_result -eq 1; then
                flag=`echo $flag|tr ' ' '~'`
                ssecxxflags="$ssecxxflags -DVC_IMPL=SSE+XOP+FMA4~$flag $avxcxxflag~$flag"
                break;
            fi
        done
    fi
    ssecxxflags="${ssecxxflags# }"
    result "$avxcxxflag $ssecxxflags"

    # check for ABI version compiler flags
    case $compiler in
    GCC)
       message "Checking ABI version compiler flags"
       abiversioncxxflag=""
       for flag in '-fabi-version=0' '-fabi-version=4'; do
          check_cxxopt $flag
          if test $cxxopt_result -eq 1; then
             abiversioncxxflag="$flag"
             break;
          fi
       done
       test -n "$abiversioncxxflag" && result "$abiversioncxxflag" || result 'N/A'
    esac
fi

sed -e "s|@avxcxxflag@|$avxcxxflag|"               \
    -e "s|@ssecxxflags@|$ssecxxflags|"             \
    -e "s|@abiversioncxxflag@|$abiversioncxxflag|" \
    -e "s|@vcflags@|$vcflags|"                     \
    < Makefile.tmp > Makefile.tmpp
mv Makefile.tmpp Makefile.tmp

######################################################################
#
### echo %%% MathMore Library - Contributed library
#
if test ! "x$enable_mathmore" = "xno"; then
    # Check for GSL include and library
    gslskip=
    hasmathmore="define"
    # by default use now static GSL library everywhere unless configure
    # was run with --enable-gsl-shared option
    # before the global --enable-shared was used:
    # enable_gsl_shared=$enable_shared"

    check_header "gsl/gsl_version.h" "$gslincdir" \
        $GSL ${GSL:+$GSL/include} ${GSL:+$GSL/api} \
        ${finkdir:+$finkdir/include} \
        /usr/local/include /usr/include /opt/gsl/include

    # check for gsl version >= 1.10
    if test ! "x$found_dir" = "x"; then
        message "Checking for GSL version >= 1.10"
        gsl_version=`grep "define GSL_VERSION" $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 1010; then
            gslskip="skip"
            result "no"
            enable_mathmore="no"
        else
            result "ok"
            gslinc=$found_hdr
            gslincdir=$found_dir
            gslflags=-I$gslincdir
            gslversion=$gsl_version
        fi
    fi

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

        if test "x$checklibcompat" = "xyes" ; then
            if test $is_libnotcompat -eq 1 ; then
                # on OSX if libgsl exists but is not compatible
                gslskip="skip"
                enable_mathmore="no"
            fi
        fi

        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 or in ../cblas/
            #if test ! "x$gsllibdir" = "x"; then
                if test ! "x$gsllibdir0" = "x"; then
                    gsllibdir1=$gsllibdir0/../cblas/.libs
                fi
                check_library "libgslcblas gslcblasML gslcblas cblas" \
                    "$enable_gsl_shared" "" \
                    $gsllibdir0 $gsllibdir1 \
                    $GSL ${GSL:+$GSL/lib} ${GSL:+$GSL/.libs} \
                    ${GSL:+$GSL/cblas/.libs} \
                    ${finkdir:+$finkdir/lib} \
                    /usr/local/lib \
                    /usr/lib /opt/gsl/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, or when x-compiling, so lets skip it
    if test "x$platform" = "xsolaris" || test ! "x$host" = "x"; 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
        if `$cwhich gsl-config > /dev/null 2>&1` ; 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
    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`
                if test "x$enable_gsl_shared" = "xyes"; then
                    gsllibs=`gsl-config --libs`
                else
                    # use static libs
                    gslprefix=`gsl-config --prefix`
                    gsllibs="$gslprefix/lib/libgsl.a $gslprefix/lib/libgslcblas.a"
                fi
                gsllibdir=""
                gslversion=$gsl_version
            fi
        else
            enable_mathmore="no"
            result "not found"
        fi
    fi
    if test "x$enable_mathmore" = "xyes" && \
       test "x$enable_gsl_shared" = "xno" ; then
        for gslalib in $gsllibs; do
            if `basename $gslalib > /dev/null 2>&1`; then
                if [ "x`basename $gslalib .a`" != "x`basename $gslalib`" ]; then
                    message "Checking whether $gslalib is compiled with -fPIC"
                    check_libpic $gslalib
                    if test $is_libpic -eq 0 ; then
                        result "no"
                        enable_mathmore="no"
                    else
                        result "yes"
                    fi
                fi
           fi
        done
        if `$cwhich gsl-config > /dev/null 2>&1` && \
           test "x$enable_mathmore" = "xno" ; then
            message "Checking for shared library versions using gsl-config"
            gslflags=`gsl-config --cflags`
            gsllibs=`gsl-config --libs`
            gsllibdir=""
            enable_mathmore="yes"
            result "yes"
        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 %%% GenVector Library - Contributed library
#
message "Checking whether to build libGenVector"
if test ! "x$enable_genvector" = "xno"; then
    enable_genvector="yes"
    result "yes"
else
    enable_genvector=""
    result "no"
fi
check_explicit "$enable_genvector" "$enable_genvector_explicit" \
      "Explicitly required GenVector dependencies not fulfilled"

######################################################################
#
### 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 %%% Vc Library - Contributed library
#
message "Checking whether to build libVc"
if test "x$enable_vc" = "xyes" || test ! "x$VC" = "x"; then
    enable_vc="yes"
    result "yes"
    hasvc="define"
else
    enable_vc=""
    result "no"
    hasvc="undef"
fi
######################################################################
#
### echo %%% VDT Library - Contributed library
#
message "Checking whether to install VDT"
if test "x$enable_vdt" = "xyes" || test ! "x$VC" = "x"; then
    enable_vdt="yes"
    result "yes"
    hasvdt="define"
else
    enable_vdt=""
    result "no"
    hasvdt="undef"
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 %%% TMVA Library - Contributed library
#
message "Checking whether to build libTMVA"
if test "x$enable_tmva" = "xyes" ; then
    enable_tmva="yes"
    result "yes"
else
    enable_tmva=""
    result "no"
fi

######################################################################
#
### echo %%% HTTP Server Library - Contributed library
#
message "Checking whether to build libRHTTP"
if test ! "x$enable_http" = "xno"; then
    enable_http="yes"
    result "yes"
    check_header "fcgiapp.h" "$fastcgiincdir" \
        ${finkdir:+$finkdir/include/fastcgi} \
        /usr/local/include /usr/local/include/fastcgi \
        /usr/local/fastcgi /usr/local/fastcgi/include \
        /opt/fastcgi /opt/fastcgi/include \
        /usr/include /usr/include/fastcgi /usr/fastcgi /usr/fastcgi/include
    fastcgiinc=$found_hdr
    fastcgiincdir=$found_dir
    check_library "libfcgi" "$enable_shared" "$fastcgilibdir" \
        ${finkdir:+$finkdir/lib} \
        /usr/local/lib /usr/lib /usr/lib/fastcgi \
        /usr/local/lib/fastcgi /usr/fastcgi/lib /usr/local/fastcgi/lib
    fastcgilib=$found_lib
    fastcgilibdir=$found_dir
    if ! test "x$fastcgiinc" = "x" && ! test "x$fastcgilib" = "x" ; then
        use_fastcgi="yes"
    else
        use_fastcgi="no"
    fi
else
    enable_http=""
    use_fastcgi="no"
    result "no"
fi

######################################################################
#
### echo %%% MemStat Library - check for memory leaks in application.
#
message "Checking whether to build libMemStat"
if test "x$enable_memstat" = "xyes" || test ! "x$MEMSTAT" = "x"; then
    case $arch in
    linux*|macos*)
       enable_memstat="yes" ;;
    *)
       enable_memstat="no" ;;
    esac
else
    enable_memstat="no"
fi
result $enable_memstat

######################################################################
#
### echo %%% Check for afdsmgrd support
#
# afdsmgrd -- Dataset manager for PROOF-based analysis facilities
# by Dario Berzano <dario.berzano@cern.ch>
# See http://code.google.com/p/afdsmgrd/
#
message "Checking whether to build afdsmgrd"
if test "x$enable_afdsmgrd" = "xyes" ; then
    afdsmgrd_cmake=`$cwhich cmake`
    if test "x$afdsmgrd_cmake" = "x" ; then
        result "`basename $0`: cmake MUST be in \$PATH in order to build afdsmgrd"
        exit 1
    fi
    if test "x$arch" = "xwin32" ; then
        result "`basename $0`: afdsmgrd can't be enabled on Windows"
        exit 1
    fi

    if test ! "x$monalisalibdir" = "x" ; then
        afdsmgrdapmondir=`dirname -- "${monalisalibdir#-L}"`
    elif test ! "x$alienlibdir" = "x" ; then
        afdsmgrdapmondir=`dirname -- "${alienlibdir#-L}"`
    else
        afdsmgrdapmondir=""
    fi

    if test ! "x$afdsmgrdapmondir" = "x" ; then
        afdsmgrdapmon="$afdsmgrdapmondir"
        afdsmgrdapmonmsg=", using ApMon at $afdsmgrdapmondir"
    else
        afdsmgrdapmon=""
        afdsmgrdapmonmsg=", ApMon support disabled"
    fi
else
    enable_afdsmgrd="no"
fi
result "$enable_afdsmgrd$afdsmgrdapmonmsg"

######################################################################
#
### 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_python"   = "xyes" && pl="$pl libroot-bindings-python"
    test "x$enable_ruby"     = "xyes" && pl="$pl libroot-bindings-ruby"
    test "x$enable_opengl"   = "xyes" && pl="$pl libroot-graf3d-gl"
    test "x$enable_xml"      = "xyes" && pl="$pl libroot-io-xmlparser"
    test "x$enable_mathmore" = "xyes" && pl="$pl libroot-math-mathmore"
    test "x$enable_unuran"   = "xyes" && pl="$pl libroot-math-unuran"
    test "x$enable_vc"       = "xyes" && pl="$pl libroot-math-vc"
    test "x$enable_vdt"      = "xyes" && pl="$pl libroot-math-vdt"
    test "x$enable_table"    = "xyes" && pl="$pl libroot-misc-table"
    test "x$enable_ldap"     = "xyes" && pl="$pl libroot-net-ldap"
    test "x$enable_roofit"   = "xyes" && pl="$pl libroot-roofit"
    test "x$enable_asimage"  = "xyes" && pl="$pl root-plugin-graf2d-asimage"
    test "x$enable_gdml"     = "xyes" && pl="$pl root-plugin-geom-gdml"
    test "x$enable_geocad"   = "xyes" && pl="$pl root-plugin-geom-geocad"
    test "x$enable_qt"       = "xyes" && pl="$pl root-plugin-gui-qt root-plugin-graf2d-qt"
    test "x$enable_castor"   = "xyes" && pl="$pl root-plugin-io-castor"
    test "x$enable_chirp"    = "xyes" && pl="$pl root-plugin-io-chirp"
    test "x$enable_dcache"   = "xyes" && pl="$pl root-plugin-io-dcache"
    test "x$enable_davix"    = "xyes" && pl="$pl root-plugin-io-davix"
    test "x$enable_gfal"     = "xyes" && pl="$pl root-plugin-io-gfal"
    test "x$enable_hdfs"     = "xyes" && pl="$pl root-plugin-io-hdfs"
    test "x$enable_rfio"     = "xyes" && pl="$pl root-plugin-io-rfio"
    test "x$enable_fftw3"    = "xyes" && pl="$pl root-plugin-math-fftw3"
    test "x$enable_fitsio"   = "xyes" && pl="$pl root-plugin-graf2d-fitsio"
    test "x$enable_gviz"     = "xyes" && pl="$pl root-plugin-graf2d-gviz"
    test "x$enable_minuit2"  = "xyes" && pl="$pl root-plugin-math-minuit2"
    test "x$enable_pythia6"  = "xyes" && pl="$pl root-plugin-montecarlo-pythia6"
    test "x$enable_alien"    = "xyes" && pl="$pl root-plugin-net-alien"
    test "x$enable_bonjour"  = "xyes" && pl="$pl root-plugin-net-bonjour"
    test "x$enable_globus"   = "xyes" && pl="$pl root-plugin-net-globus"
    test "x$enable_krb5"     = "xyes" && pl="$pl root-plugin-net-krb5"
    test "x$enable_monalisa" = "xyes" && pl="$pl root-plugin-net-monalisa"
    test "x$enable_srp"      = "xyes" && pl="$pl root-plugin-net-srp"
    test "x$enable_mysql"    = "xyes" && pl="$pl root-plugin-sql-mysql"
    test "x$enable_odbc"     = "xyes" && pl="$pl root-plugin-sql-odbc"
    test "x$enable_oracle"   = "xyes" && pl="$pl root-plugin-sql-oracle"
    test "x$enable_pgsql"    = "xyes" && pl="$pl root-plugin-sql-pgsql"
    test "x$enable_sapdb"    = "xyes" && pl="$pl root-plugin-sql-maxdb"
    test "x$enable_sqlite"   = "xyes" && pl="$pl root-plugin-sql-sqlite"
    test "x$enable_xrootd"   = "xyes" && pl="$pl root-system-xrootd root-plugin-net-netx root-plugin-net-xrootd"

    pl="$pl \
        libroot-geom \
        libroot-graf2d-gpad \
        libroot-graf2d-graf \
        libroot-graf2d-postscript \
        libroot-graf3d-eve \
        libroot-graf3d-g3d \
        libroot-gui \
        libroot-gui-ged \
        libroot-hist \
        libroot-hist-spectrum \
        libroot-io \
        libroot-math-foam \
        libroot-math-genvector \
        libroot-math-mathcore \
        libroot-math-matrix \
        libroot-math-minuit \
        libroot-math-mlp \
        libroot-math-physics \
        libroot-math-quadp \
        libroot-math-smatrix \
        libroot-math-splot \
        libroot-misc-minicern \
        libroot-montecarlo-eg \
        libroot-montecarlo-vmc \
        libroot-net \
        libroot-net-auth \
        libroot-proof \
        libroot-tmva \
        libroot-tree \
        libroot-tree-treeplayer \
        root-plugin-geom-geombuilder \
        root-plugin-geom-geompainter \
        root-plugin-graf2d-x11 \
        root-plugin-graf3d-x3d \
        root-plugin-gui-fitpanel \
        root-plugin-gui-guibuilder \
        root-plugin-gui-sessionviewer \
        root-plugin-hist-hbook \
        root-plugin-hist-histpainter \
        root-plugin-hist-spectrumpainter \
        root-plugin-io-sql \
        root-plugin-io-xml \
        root-plugin-math-fumili \
        root-plugin-proof-proofplayer \
        root-plugin-proof-xproof \
        root-plugin-tree-treeviewer \
        root-system-proofd \
        root-system-rootd \
        root-system-doc \
        root-system-bin \
        libroot-core \
        root-system-common \
        ttf-root-installer"
    pl=`echo $pl | tr -s ' '`

    # If we're called from the package preparation script, then
    # print out the package list and exit
    result "packages: $pl"
    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
macosx*|freebsd*|openbsd|aix*|win32*|linux*)
    enable_explicitlink="yes"
    issue_explicitlink_warning="no"
    ;;
esac
if test "x$enable_explicitlink" = "xyes" && test ! "x$platform" = "xwin32"; 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
if test -d cint ; then
   rm -rf cint
fi
if test -d include/cint ; then
   rm -rf include/cint
fi
if test -d include/Cintex ; then
   rm -rf include/Cintex
fi
if test -d include/Reflex ; then
   rm -rf include/Reflex
fi
if test -d graf2d/freetype/src/freetype-2.3.5 ; then
   rm -rf graf2d/freetype/src/freetype-2.3.5
fi
if test -d pcre/src/pcre-6.4 ; then
   rm -rf pcre/src/pcre-6.4
fi
if test -d core/pcre/src/pcre-7.4 ; then
   rm -rf core/pcre/src/pcre-7.4
fi
if test -d math/unuran/src/unuran-1.3.0-root ; then
   rm -rf math/unuran/src/unuran-1.3.0-root
fi
if test -d math/unuran/src/unuran-1.5.0-root ; then
   rm -rf math/unuran/src/unuran-1.5.0-root
fi
if test -d math/unuran/src/unuran-1.5.1-root ; then
   rm -rf math/unuran/src/unuran-1.5.1-root
fi
if test -d math/unuran/src/unuran-1.7.1-root ; then
   rm -rf math/unuran/src/unuran-1.7.1-root
fi
if test -d math/unuran/src/unuran-1.7.2-root ; then
   rm -rf math/unuran/src/unuran-1.7.2-root
fi
if test -d cint/cint7 ; then
   rm -rf cint/cint7
fi
if test -d core/editline ; then
   rm -rf core/editline
fi
if test -d core/globals ; then
   rm -rf core/globals
fi
if test -d net/xrootd ; then
   rm -rf net/xrootd
fi
if test -d build/unix/drop_from_path ; then
   rm -rf build/unix/drop_from_path
fi
if test ! "x$macosx106" = "x"; then
   rm -f bin/python64 bin/ruby64
fi
rm -f lib/libRXML* bin/libRXML* etc/system.rootmap \
 etc/svninfo.txt lib/libProofGui* bin/libProofGui* \
 lib/libMySQL* bin/libMySQL* lib/libGedOld* bin/libGedOld* \
 lib/libSQL.* bin/libSQL.* core/utils/src/rootcint_tmp \
 lib/libASPluginGS.* bin/g2rootold* bin/ptest main/src/ptest.* \
 math/mathcore/src/G__MathCore32.* \
 xrootd/src/headers.d include/Xpm.h \
 asimage/src/headers.d asimage/src/G__ASImageGS.* \
 core/utils/src/rootcint7.cxx core/utils/src/RStl7.cxx \
 core/metautils/src/TClassEdit7.cxx \
 core/metautils/src/RConversionRuleParser7.cxx \
 core/meta/src/G__TCint.h core/meta/src/G__TCint.cxx \
 core/thread/src/TLockFile.* proof/proofplayer/src/TFileMerger.* \
 core/base/src/ManualBase4.* tree/tree/src/ManualTree2.* \
 graf2d/graf/src/G__Graf1.h graf2d/graf/src/G__Graf1.cxx \
 graf2d/graf/src/G__Graf2.h graf2d/graf/src/G__Graf2.cxx \
 core/base/src/G__Base1.h core/base/src/G__Base2.h \
 core/base/src/G__Base3.h core/clib/src/G__Clib.h \
 core/cont/src/G__Cont.h core/macosx/src/G__Macosx.h \
 core/meta/src/G__Meta.h core/metautils/src/G__MetaUtils.h \
 core/textinput/src/G__TextInput.h core/unix/src/G__Unix.h \
 core/zip/src/G__Zip.h geom/geom/src/G__Geom1.h \
 geom/geom/src/G__Geom2.h graf3d/g3d/src/G__G3D.h \
 graf3d/gl/src/G__GL.h gui/gui/src/G__Gui1.h \
 gui/gui/src/G__Gui2.h gui/gui/src/G__Gui3.h \
 graf2d/x11ttf/src/G__X11TTF.h graf2d/x11/src/G__X11.cxx \
 graf3d/x3d/src/G__X3D.h \
 hist/spectrumpainter/src/G__Spectrum2Painter.h \
 io/io/src/G__IO.h io/sql/src/G__SQL.h io/xml/src/G__XML.h \
 math/mathcore/src/G__Math.h math/mathcore/src/G__MathFit.h \
 net/ldap/src/G__LDAP.h core/winnt/src/G__WinNT.h \
 graf3d/eve/src/G__Eve1.h graf3d/eve/src/G__Eve2.h \
 tmva/src/G__TMVA1.h tmva/src/G__TMVA2.h tmva/src/G__TMVA3.h \
 tmva/src/G__TMVA4.h roofit/roofitcore/src/G__RooFitCore1.h \
 roofit/roofitcore/src/G__RooFitCore2.h roofit/roofitcore/src/G__RooFitCore3.h \
 roofit/roofitcore/src/G__RooFitCore4.h \
 core/base/src/G__Base1.cxx core/base/src/G__Base2.cxx \
 core/base/src/G__Base3.cxx core/clib/src/G__Clib.cxx \
 core/cont/src/G__Cont.cxx core/macosx/src/G__Macosx.cxx \
 core/meta/src/G__Meta.cxx core/metautils/src/G__MetaUtils.cxx \
 core/textinput/src/G__TextInput.cxx core/unix/src/G__Unix.cxx \
 core/zip/src/G__Zip.cxx geom/geom/src/G__Geom1.cxx \
 geom/geom/src/G__Geom2.cxx graf3d/g3d/src/G__G3D.cxx \
 graf3d/gl/src/G__GL.cxx gui/gui/src/G__Gui1.cxx \
 gui/gui/src/G__Gui2.cxx gui/gui/src/G__Gui3.cxx \
 hist/spectrumpainter/src/G__Spectrum2Painter.cxx \
 io/io/src/G__IO.cxx io/sql/src/G__SQL.cxx io/xml/src/G__XML.cxx \
 math/mathcore/src/G__Math.cxx math/mathcore/src/G__MathFit.cxx \
 net/ldap/src/G__LDAP.cxx core/winnt/src/G__WinNT.cxx \
 graf3d/eve/src/G__Eve1.cxx graf3d/eve/src/G__Eve2.cxx \
 graf2d/x11ttf/src/G__X11TTF.cxx graf2d/x11/src/G__X11.cxx \
 graf3d/x3d/src/G__X3D.cxx \
 roofit/roofitcore/src/G__RooFitCore1.cxx \
 roofit/roofitcore/src/G__RooFitCore2.cxx \
 roofit/roofitcore/src/G__RooFitCore3.cxx \
 roofit/roofitcore/src/G__RooFitCore4.cxx \
 tmva/src/G__TMVA1.cxx tmva/src/G__TMVA2.cxx tmva/src/G__TMVA3.cxx \
 tmva/src/G__TMVA4.cxx \
 net/net/src/TAS3File.* net/net/src/TGSFile.* net/net/src/THTTPMessage.* \
 etc/daemons/olbd.rc.d etc/daemons/cmsd.rc.d etc/daemons/xrootd.rc.d \
 bin/cmsd bin/xprep bin/xrd bin/xrdcp bin/xrdgsiproxy bin/xrdpwdadmin \
 bin/xrdsssadmin bin/xrdstagetool bin/xrootd lib/libXrd* \
 bin/drop_from_path bin/genreflex bin/genreflex.bat bin/genreflex-rootcint \
 bin/genreflex-rootcint.bat \
 include/TListOfTypes.h lib/*_RootCling.rootmap bin/rlibmap

# if previous build was in non-c++11 mode, run "make maintainer-clean" first
run_maintainer_clean="no"
if `grep '#undef R__USE_CXX11' $CONFIGUREOUT > /dev/null  2>&1` ; then
   run_maintainer_clean="yes"
fi

######################################################################
#
### echo %%% Fleshin out paths
#
# First win32 does not support -L in ldflags, so remove @ldflags@.
#
if test "x$platform" = "xwin32" ; 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
          ;;
       solarisgcc* | linux* | freebsd* | openbsd*)
          sed -e "s|@ldflags@|-Wl,-rpath,$globusdir/lib @ldflags@|" \
                 < Makefile.tmp > Makefile.tmpp
          ;;
       macosx*)
          if test ! "x$macosx105" = "x"; then
             sed -e "s|@ldflags@|-Wl,-rpath,$globusdir/lib @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
          fi
          ;;
    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=$prefix/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$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
             ;;
          solarisgcc* | linux* | freebsd* | openbsd*)
             sed -e "s|@ldflags@|-Wl,-rpath,$libdir @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
             ;;
          macosx*)
             if test ! "x$macosx105" = "x"; then
                sed -e "s|@ldflags@|-Wl,-rpath,$libdir @ldflags@|" \
                       < Makefile.tmp > Makefile.tmpp
             fi
             ;;
       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
    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 the build product is not relocatable
    # except for macosx 10.5 where we build relative to the location of
    # the executable
    if test "x$enable_rpath" = "xyes" ; then
       case "$arch" in
          solarisCC5)
             sed -e "s|@ldflags@|-R$libdir @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
             ;;
          solarisgcc* | linux* | freebsd* | openbsd*)
             sed -e "s|@ldflags@|-Wl,-rpath,$libdir @ldflags@|" \
                    < Makefile.tmp > Makefile.tmpp
             ;;
          macosx*)
             if test ! "x$macosx105" = "x"; then
                sed -e "s|@ldflags@|-Wl,-rpath,@loader_path/../lib @ldflags@|" \
                       < Makefile.tmp > Makefile.tmpp
             fi
             ;;
       esac
       if test -f Makefile.tmpp ; then
          mv Makefile.tmpp Makefile.tmp
       fi
    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@|$afslibdirs|"             \
    -e "s|@afsincdir@|$afsincdir|"              \
    -e "s|@afsextracflags@|$afsextracflags|"    \
    -e "s|@afsshared@|$afsshared|"              \
    -e "s|@alienincdir@|$alienincdir|"          \
    -e "s|@alienlib@|$alienlib|"                \
    -e "s|@alienlibdir@|$alienlibdir|"          \
    -e "s|@alloclibdir@|$alloclibdir|"          \
    -e "s|@alloclib@|$alloclib|"                \
    -e "s|@architecture@|$arch|"                \
    -e "s|@host@|$host|"                        \
    -e "s|@asextralib@|$asextralib|"            \
    -e "s|@asextralibdir@|$asextralibdir|"      \
    -e "s|@asjpegincdir@|$asjpegincdir|"        \
    -e "s|@aspngincdir@|$aspngincdir|"          \
    -e "s|@astiffincdir@|$astiffincdir|"        \
    -e "s|@asimageincdir@|$asimageincdir|"      \
    -e "s|@asimagelib@|$asimagelib|"            \
    -e "s|@asimagelibdir@|$asimagelibdir|"      \
    -e "s|@bindir@|$bindir|"                    \
    -e "s|@bonjourcppflags@|$bonjourcppflags|"  \
    -e "s|@buildasimage@|$enable_asimage|"      \
    -e "s|@builtinafterimage@|$enable_builtin_afterimage|"  \
    -e "s|@buildftgl@|$enable_builtin_ftgl|"    \
    -e "s|@buildglew@|$enable_builtin_glew|"    \
    -e "s|@builtinfreetype@|$enable_builtin_freetype|"      \
    -e "s|@builtinpcre@|$enable_builtin_pcre|"  \
    -e "s|@builtinllvm@|$enable_builtin_llvm|"  \
    -e "s|@hasxrd@|$enable_xrootd|"             \
    -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|@cppunit@|$cppunit|"                  \
    -e "s|@datadir@|$datadir|"                  \
    -e "s|@davixincdir@|$davixincdir|"          \
    -e "s|@dcapincdir@|$dcapincdir|"            \
    -e "s|@comerrlib@|$comerrlib|"              \
    -e "s|@comerrlibdir@|$comerrlibdir|"        \
    -e "s|@cryptolib@|$cryptolib|"              \
    -e "s|@cryptolibdir@|$cryptolibdir|"        \
    -e "s|@davixlib@|$davixlib|"                \
    -e "s|@davixlibdir@|$davixlibdir|"          \
    -e "s|@dcaplib@|$dcaplib|"                  \
    -e "s|@dcaplibdir@|$dcaplibdir|"            \
    -e "s|@docdir@|$docdir|"                    \
    -e "s|@elispdir@|$elispdir|"                \
    -e "s|@buildgenvector@|$enable_genvector|"  \
    -e "s|@buildmathmore@|$enable_mathmore|"    \
    -e "s|@ftglincdir@|$ftglincdir|"            \
    -e "s|@ftgllibdir@|$ftgllibdir|"            \
    -e "s|@ftgllibs@|$ftgllibs|"                \
    -e "s|@glewincdir@|$glewincdir|"            \
    -e "s|@glewlibdir@|$glewlibdir|"            \
    -e "s|@glewlibs@|$glewlibs|"                \
    -e "s|@gslflags@|$gslflags|"                \
    -e "s|@gsllibdir@|$gsllibdir|"              \
    -e "s|@gsllibs@|$gsllibs|"                  \
    -e "s|@gslversion@|$gslversion|"            \
    -e "s|@builtinzlib@|$enable_builtin_zlib|"  \
    -e "s|@zlibincdir@|$zlibincdir|"            \
    -e "s|@zliblib@|$zliblib|"                  \
    -e "s|@zliblibdir@|$zliblibdir|"            \
    -e "s|@builtinlzma@|$enable_builtin_lzma|"  \
    -e "s|@lzmaincdir@|$lzmaincdir|"            \
    -e "s|@lzmalib@|$lzmalib|"                  \
    -e "s|@lzmalibdir@|$lzmalibdir|"            \
    -e "s|@buildroofit@|$enable_roofit|"        \
    -e "s|@buildminuit2@|$enable_minuit2|"      \
    -e "s|@buildunuran@|$enable_unuran|"        \
    -e "s|@buildvc@|$enable_vc|"                \
    -e "s|@buildvdt@|$enable_vdt|"              \
    -e "s|@buildgdml@|$enable_gdml|"            \
    -e "s|@buildgeocad@|$enable_geocad|"        \
    -e "s|@buildmonalisa@|$enable_monalisa|"    \
    -e "s|@buildtable@|$enable_table|"          \
    -e "s|@buildtmva@|$enable_tmva|"            \
    -e "s|@buildmemstat@|$enable_memstat|"      \
    -e "s|@enable_thread@|$enable_thread|"      \
    -e "s|@etcdir@|$etcdir|"                    \
    -e "s|@explicitlink@|$enable_explicitlink|" \
    -e "s|@gfalincdir@|$gfalincdir|"            \
    -e "s|@srmifceincdir@|$srmifceincdir|"      \
    -e "s|@glib2incdir@|$glib2incdir|"          \
    -e "s|@gfallib@|$gfallib|"                  \
    -e "s|@gfallibdir@|$gfallibdir|"            \
    -e "s|@enable_xft@|$enable_xft|"            \
    -e "s|@glitelib@|$glitelib|"                \
    -e "s|@glitelibdir@|$glitelibdir|"          \
    -e "s|@gaw_cppflags@|$gaw_cppflags|"        \
    -e "s|@ctorsinitarray@|$ctorsinitarray|"    \
        < 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|@hdfsincdir@|$hdfsincdir|"            \
    -e "s|@hdfslib@|$hdfslib|"                  \
    -e "s|@hdfslibdir@|$hdfslibdir|"            \
    -e "s|@iossdk@|$iossdk|"                    \
    -e "s|@iosvers@|$iosvers|"                  \
    -e "s|@iconpath@|$iconpath|"                \
    -e "s|@incdir@|$incdir|"                    \
    -e "s|@jniincdir@|$jniincdir|g"             \
    -e "s|@jvmlibdir@|$jvmlibdir|g"             \
    -e "s|@jvmlib@|$jvmlib|g"                   \
    -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|@llvmconfig@|$llvmconfig|"            \
    -e "s|@macosxvers@|$macosxvers|"            \
    -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|@fftw3incdir@|$fftw3incdir|"          \
    -e "s|@fftw3lib@|$fftw3lib|"                \
    -e "s|@fftw3libdir@|$fftw3libdir|"          \
    -e "s|@gvizincdir@|$gvizincdir|"            \
    -e "s|@gvizlib@|$gvizlib|"                  \
    -e "s|@gvizlibdir@|$gvizlibdir|"            \
    -e "s|@gvizcflags@|$gvizcflags|"            \
    -e "s|@dnssdincdir@|$dnssdincdir|"          \
    -e "s|@dnssdlib@|$dnssdlib|"                \
    -e "s|@dnssdlibdir@|$dnssdlibdir|"          \
    -e "s|@avahilibdir@|$avahilibdir|"          \
    -e "s|@mysqlincdir@|$mysqlincdir|"          \
    -e "s|@mysqllib@|$mysqllib|"                \
    -e "s|@mysqllibdir@|$mysqllibdir|"          \
    -e "s|@occincdir@|$occincdir|"              \
    -e "s|@occlib@|$occlib|"                    \
    -e "s|@occlibdir@|$occlibdir|"              \
    -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|@osxsdk@|$osxsdk|"                    \
    -e "s|@pgsqlincdir@|$pgsqlincdir|"          \
    -e "s|@pgsqllib@|$pgsqllib|"                \
    -e "s|@pgsqllibdir@|$pgsqllibdir|"          \
    -e "s|@sqliteincdir@|$sqliteincdir|"        \
    -e "s|@sqlitelib@|$sqlitelib|"              \
    -e "s|@sqlitelibdir@|$sqlitelibdir|"        \
    -e "s|@pythia6lib@|$pythia6lib|"            \
    -e "s|@pythia6libdir@|$pythia6libdir|"      \
    -e "s|@pythia6cppflags@|$pythia6cppflags|"  \
    -e "s|@pythia8lib@|$pythia8lib|"            \
    -e "s|@pythia8incdir@|$pythia8incdir|"      \
    -e "s|@pythia8libdir@|$pythia8libdir|"      \
    -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|@qtvers@|$qtvers|"                    \
    -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@|$ac_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|@sslshared@|$sslshared|"              \
    -e "s|@sslextracflags@|$sslextracflags|"    \
    -e "s|@testdir@|$testdir|"                  \
    -e "s|@threadflag@|$threadflag|"            \
    -e "s|@threadlib@|$threadlib|"              \
    -e "s|@threadlibdir@|$threadlibdir|"        \
    -e "s|@top_builddir@|$top_builddir|"        \
    -e "s|@top_srcdir@|$top_srcdir|"            \
    -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|@buildx11@|$enable_x11|"              \
    -e "s|@x11incdir@|$x11incdir|"              \
    -e "s|@x11libdir@|$x11libdir|"              \
    -e "s|@xpmlib@|$xpmlib|"                    \
    -e "s|@xpmlibdir@|$xpmlibdir|"              \
    -e "s|@xrdlibdir@|$xrdlibdir|"              \
    -e "s|@xrdincdir@|$xrdincdir|"              \
    -e "s|@xrdincprivate@|$xrdincprivate|"      \
    -e "s|@xrdversion@|$decver|"                \
    -e "s|@hasxrdutils@|$hasxrdutils|"          \
    -e "s|@cfitsioincdir@|$cfitsioincdir|"      \
    -e "s|@cfitsiolib@|$cfitsiolib|"            \
    -e "s|@cfitsiolibdir@|$cfitsiolibdir|"      \
    -e "s|@buildfitsio@|$enable_fitsio|"        \
    -e "s|@buildgl@|$enable_opengl|"            \
    -e "s|@buildldap@|$enable_ldap|"            \
    -e "s|@buildmysql@|$enable_mysql|"          \
    -e "s|@buildpgsql@|$enable_pgsql|"          \
    -e "s|@buildsqlite@|$enable_sqlite|"        \
    -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|@builddavix@|$enable_davix|"          \
    -e "s|@buildfftw3@|$enable_fftw3|"          \
    -e "s|@buildgviz@|$enable_gviz|"            \
    -e "s|@buildgfal@|$enable_gfal|"            \
    -e "s|@buildbonjour@|$enable_bonjour|"      \
    -e "s|@buildchirp@|$enable_chirp|"          \
    -e "s|@buildhdfs@|$enable_hdfs|"            \
    -e "s|@buildhttp@|$enable_http|"            \
    -e "s|@usefastcgi@|$use_fastcgi|"           \
    -e "s|@fastcgiincdir@|$fastcgiincdir|"      \
    -e "s|@buildalien@|$enable_alien|"          \
    -e "s|@buildasimage@|$enable_asimage|"      \
    -e "s|@buildpythia6@|$enable_pythia6|"      \
    -e "s|@buildpythia8@|$enable_pythia8|"      \
    -e "s|@buildpython@|$enable_python|"        \
    -e "s|@buildruby@|$enable_ruby|"            \
    -e "s|@buildxml@|$enable_xml|"              \
    -e "s|@extraxrdflags@|$extraxrdflags|"      \
    -e "s|@buildsrputil@|$enable_srputil|"      \
    -e "s|@buildkrb5@|$enable_krb5|"            \
    -e "s|@buildglobus@|$enable_globus|"        \
    -e "s|@buildafdsmgrd@|$enable_afdsmgrd|"    \
    -e "s|@afdsmgrdapmon@|$afdsmgrdapmon|"      \
    -e "s|@buildglite@|$enable_glite|"          \
    -e "s|@buildcocoa@|$enable_cocoa|"          \
    -e "s|@buildxproofd@|$buildxproofd|"        \
    -e "s|@buildxrdclt@|$buildxrdclt|"          \
    -e "s|@buildnetxng@|$buildnetxng|"          \
    -e "s|@c++11@|$enable_cxx11|"               \
    -e "s|@libc++@|$enable_libcxx|"             \
    -e "s|@werror@|$enable_werror|"             \
    < 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"

#---------------------------------------------------------------------
# config/Makefile.comp
#
message "Writing $MAKECOMPOUT"
sed -e "s|@altcc@|$altcc|"     \
    -e "s|@altcxx@|$altcxx|"   \
    -e "s|@altf77@|$altf77|"   \
    -e "s|@altld@|$altld|"     \
    -e "s|@gcctoolchain@|$gcctoolchain|" \
    < Makefile-comp.tmp > $MAKECOMPOUT
rm -f Makefile-comp.tmp

result "done"

#---------------------------------------------------------------------
# include/RConfigure.h
#
message "Writing $CONFIGUREOUT"
sed \
    -e "s|@architecture@|$arch|"           \
    -e "s|@bindir@|$bindir|"               \
    -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|@tutdir@|$tutdir|"               \
    -e "s|@setresuid@|$setresuid|"         \
    -e "s|@hasmathmore@|$hasmathmore|"     \
    -e "s|@haspthread@|$haspthread|"       \
    -e "s|@hasxft@|$hasxft|"               \
    -e "s|@hascocoa@|$hascocoa|"           \
    -e "s|@hasvc@|$hasvc|"                 \
    -e "s|@usec++11@|$usecxx11|"           \
    -e "s|@uselibc++@|$uselibcxx|"         \
    -e "s|@hasllvm@|$hasllvm|"             \
    -e "s|@llvmdir@|$llvmdir|"             \
    < RConfigure.tmp > RConfigure-out.tmp
rm -f RConfigure.tmp

# only update $CONFIGUREOUT when different
if test -f $CONFIGUREOUT; then
   diff RConfigure-out.tmp $CONFIGUREOUT > /dev/null; status=$?;
   if [ "$status" -ne "0" ] && [ "x$run_maintainer_clean" = "xno" ]; then
      mv -f RConfigure-out.tmp $CONFIGUREOUT
   else
      rm -f RConfigure-out.tmp
   fi
else
   mv -f RConfigure-out.tmp $CONFIGUREOUT
fi

result "done"

#---------------------------------------------------------------------
# include/RConfigOptions.h
#
message "Writing $CONFIGOPTOUT"

features=""
for f in $options ; do
    bar="$`echo $f`"
    if test "x`eval echo $bar`" = "xyes" ; then
       feat=`echo $f | sed 's/enable_//'`
       if test -z "$features"; then
          features="$feat"
       else
          features="$features $feat"
       fi
    fi
done
# threads are now always enabled
features="$features thread"

sed \
    -e "s|@configoptions@|$configoptions|" \
    -e "s|@configfeatures@|$features|"     \
    < RConfigOptions.tmp > RConfigOptions-out.tmp
rm -f RConfigOptions.tmp

if test ! "x$enable_ruby" = "xno"; then
   echo "" >> RConfigOptions-out.tmp
   RUBY_MAJOR=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["MAJOR"]'`
   RUBY_MINOR=`ruby -rrbconfig -e 'puts RbConfig::CONFIG["MINOR"]'`
   echo "#define R__RUBY_MAJOR $RUBY_MAJOR" >> RConfigOptions-out.tmp
   echo "#define R__RUBY_MINOR $RUBY_MINOR" >> RConfigOptions-out.tmp
fi

# only update $CONFIGOPTOUT when different
if test -f $CONFIGOPTOUT; then
   diff RConfigOptions-out.tmp $CONFIGOPTOUT > /dev/null; status=$?;
   if [ "$status" -ne "0" ]; then
      mv -f RConfigOptions-out.tmp $CONFIGOPTOUT
   else
      rm -f RConfigOptions-out.tmp
   fi
else
   mv -f RConfigOptions-out.tmp $CONFIGOPTOUT
fi

result "done"

#---------------------------------------------------------------------
# bin/root-config
#
message "Writing $RCONFOUT"
prefix2=$prefix
bindir2=$bindir
libdir2=$libdir
incdir2=$incdir
etcdir2=$etcdir
mandir2=$mandir
if test "$prefix2" = "\$(ROOTSYS)" ; then
    prefix2=\$ROOTSYS
    bindir2=\$ROOTSYS/bin
    libdir2=\$ROOTSYS/lib
    incdir2=\$ROOTSYS/include
    etcdir2=\$ROOTSYS/etc
    mandir2=\$ROOTSYS/man/man1
fi

if test ! "x$altccorg" = "x" ; then
    altcc2="$altccorg"
else
    altcc2="$altcc"
fi
if test ! "x$altcxxorg" = "x" ; then
    altcxx2="$altcxxorg"
else
    altcxx2="$altcxx"
fi
if test ! "x$altf77org" = "x" ; then
    altf772="$altf77org"
else
    altf772="$altf77"
fi
if test ! "x$altldorg" = "x" ; then
    altld2="$altldorg"
else
    altld2="$altld"
fi

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|@etcdir@|$etcdir2|"              \
    -e "s|@features@|$features|"           \
    -e "s|@winrtdebug@|$enable_winrtdebug|"\
    -e "s|@configargs@|$configargs|"       \
    -e "s|@pythonvers@|$pythonvers|"       \
    -e "s|@alloclibdir@|$alloclibdir|"     \
    -e "s|@alloclib@|$alloclib|"           \
    -e "s|@altcc@|$altcc2|"                \
    -e "s|@altcxx@|$altcxx2|"              \
    -e "s|@altf77@|$altf772|"              \
    -e "s|@altld@|$altld2|"                \
   < 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|@plugindir@|$etcdir/plugins|"    \
    -e "s|@bindir@|$bindir|"               \
    -e "s|@etcdir@|$etcdir|"               \
    -e "s|@ttffontdir@|$fontdir|"          \
    -e "s|@iconpath@|$iconpath|"           \
    -e "s|@hasxrd@|$hasxrd|"               \
    -e "s|@hasnotxrd@|$hasnotxrd|"         \
    -e "s|@useoldwebfile@|$useoldwebfile|" \
    -e "s|@useoldnetx@|$useoldnetx|"       \
   < 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 "x$platform" = "xwin32" ; 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@|$bindir2|" \
    < rootd.tmp > $ROOTDOUT
chmod a+x $ROOTDOUT
rm -f rootd.tmp
result "done"

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

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

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

#---------------------------------------------------------------------
# main/src/proofserv.sh
#
message "Writing $PROOFSERVOUT"
sed -e "s|@bindir@|$bindir2|" \
    < proofserv.tmp > $PROOFSERVOUT
chmod a+x $PROOFSERVOUT
rm -f proofserv.tmp
result "done"

#---------------------------------------------------------------------
# config/xproofd.in
#
if test "x$buildxproofd" = "xno" ; then
   message "Writing $XPROOFDOUT"
   sed -e "s|@libdir@|$libdir2|" \
       -e "s|@bindir@|$bindir2|" \
        < xproofd.tmp > $XPROOFDOUT
   chmod a+x $XPROOFDOUT
   result "done"
fi
rm -f xproofd.tmp

#---------------------------------------------------------------------
# main/src/roots.sh
#
message "Writing $ROOTSOUT"
sed -e "s|@bindir@|$bindir2|" \
    < roots.tmp > $ROOTSOUT
chmod a+x $ROOTSOUT
rm -f roots.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="-e s|@altf77@|$altf772|"
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"
sed -e "s|@bindir@|$bindir2|"           \
    -e "s|@libdir@|$libdir2|"           \
    -e "s|@mandir@|$mandir2|"           \
    < $THISROOTSHIN > $THISROOTSHOUT
result "done"
message "Writing $THISROOTCSHOUT"
sed -e "s|@bindir@|$bindir2|"           \
    -e "s|@libdir@|$libdir2|"           \
    -e "s|@mandir@|$mandir2|"           \
    < $THISROOTCSHIN > $THISROOTCSHOUT
result "done"
if test "x$platform" = "xwin32"; then
    message "Writing $THISROOTBATOUT"
    cp -f $THISROOTBATIN $THISROOTBATOUT
    result "done"
else
    # bin/setxrd.sh and bin/setxrd.csh
    message "Writing $SETXRDSHOUT"
    cp -f $SETXRDSHIN $SETXRDSHOUT
    result "done"
    message "Writing $SETXRDCSHOUT"
    cp -f $SETXRDCSHIN $SETXRDCSHOUT
    result "done"
fi

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

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

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

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

gnumake=`echo $gnumake | sed 's,--no-print-directory,,'`

result ""
result "To build ROOT type:"
result ""
result "   $gnumake"
if test ! "x$haveconfig" = "x" ; then
    result "   $gnumake install"
fi
result ""
if test "x$issue_explicitlink_warning" = "xyes"; then
    result "*** Explicit linking is required for Ruby support."
    result "*** If lib/*.so's exist created without explicit linking,"
    result "*** please remove them first using: rm -f lib/*.so."
    result ""
fi
if [ "x$run_maintainer_clean" = "xyes" ]; then
   result "*** Cleaning up previous non-C++11 build products, using:"
   result "*** $gnumake maintainer-clean;$0 `cat config.status 2>/dev/null`"
   $gnumake maintainer-clean
   $0 `cat config.status 2>/dev/null`
fi

exit 0
back to top