# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../root/root.conf
# Copyright (C) 2008 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

if [ $prefix_auto = 1 ] ; then
        prefix="opt/root"
        set_confopt
fi

#var_append CXX_WRAPPER_INSERT ' ' "-fpermissive"

# -Os/-s would remove necessary symbols, instead use -O2 as default
var_remove_regex GCC_WRAPPER_REMOVE " " "-Os"
var_remove_regex GCC_WRAPPER_INSERT " " "-Os"
var_remove_regex GCC_WRAPPER_APPEND " " "-s"

var_append GCC_WRAPPER_INSERT " " "-O2"

# defaults
rootconfopt="--enable-rpath --enable-soversion --enable-explicitlink --enable-shadowpw"

#FIXME --with-mysql-{incdir,libdir}
#FIXME --with-ldap-{incdir,libdir}
#FIXME --with-pgsql-{incdir,libdir}
#FIXME --with-krb5-{incdir,libdir}
#FIXME --with-sys-iconpath

# use QT as graphics backend
pkginstalled qt3 && var_append rootconfopt ' ' "--enable-qt"

# various stuff
var_append rootconfopt ' ' "--enable-table"
var_append rootconfopt ' ' "--enable-xml"

# root v5 specific
var_append rootconfopt ' ' "--enable-mathcore"
var_append rootconfopt ' ' "--enable-reflex"
var_append rootconfopt ' ' "--enable-roofit"
var_append rootconfopt ' ' "--enable-cintex"

cust_ROOT() {
	# configure
	case "$arch_machine" in
		i?86)     trg=linux ;;
		x86_64)   trg=linuxx8664gcc ;;
		# FIXME ppc, ppc64 etal
		*)        trg=linux ;;
	esac

	eval ./configure $trg \
		--prefix=$root/$prefix \
		--libdir=$root/$prefix/lib \
		--mandir=$root/usr/share/man/man1 \
		--docdir=$root/usr/share/doc/packages/${pkg} \
		--aclocaldir=$root/usr/share/aclocal \
		$rootconfopt

	# build
	eval $MAKE ; eval $MAKE install

	# profile.d for root
	cat > $root/etc/profile.d/root <<-EOP
ROOTSYS=/$prefix
PATH="\$PATH:\$ROOTSYS/bin"
MANPATH="\$MANPATH:\$ROOTSYS/man"
export ROOTSYS PATH MANPATH
EOP
}

custmain=cust_ROOT