# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../bacula/bacula.conf
# Copyright (C) 2010 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# 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
	if [ ! -z $SDECFG_PKG_BACULA_PREFIX ] ; then
		prefix="$SDECFG_PKG_BACULA_PREFIX"
	else
		prefix="opt/bacula"
	fi
	set_confopt
fi

# smartalloc is highly recommended
var_append confopt " " "--enable-smartalloc"
var_append confopt " " "--enable-conio"
var_append confopt " " "--with-working-dir=$root/$prefix/working"

# wxwidgets gui
pkginstalled wxwidgets && var_append confopt " " "--enable-wx-console --enable-tray-monitor"

# ssl encryption support
if pkginstalled openssl; then
        var_append extraconfopt " " "--with-openssl"
fi

if [ "$SDECFG_PKG_BACULA_DB" = "mysql" ] ; then
	# checking for mysql support
	if pkginstalled mysql ; then
		pkgprefix -t mysql
		var_append extraconfopt " " "--with-mysql=$root/$( pkgprefix mysql )"
	fi
elif [ "$SDECFG_PKG_BACULA_DB" = "postgresql" ] ; then
	# checking for postgresql support
	if pkginstalled postgresql ; then
        	pkgprefix -t postgresql
	        var_append extraconfopt " " "--with-postgresql=$root/$( pkgprefix postgresql )"
	fi
elif [ "$SDECFG_PKG_BACULA_DB" = "sqlite" ] ; then
	# checking for sqlite3 support
	if pkginstalled sqlite ; then
		pkgprefix -t sqlite
		var_append extraconfopt " " "--with-sqlite3=$root/$( pkgprefix sqlite )"
	fi
elif [ "$SDECFG_PKG_BACULA_DB" = "sqlite2" ] ; then
	# checking for sqlite2 support
	if pkginstalled sqlite2 ; then
		pkgprefix -t sqlite2
		var_append extraconfopt " " "--with-sqlite=$root/$( pkgprefix sqlite2 )"
	fi
else
	var_append extraconfopt " " "--enable-client-only"
	echo "Bacula: no database selected, build bacula client only"
fi