# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../subversion/subversion.conf
# Copyright (C) 2006 - 2011 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 ---

# use the apache prefix
# . $base/package/*/apache/apache.conf

if [ $prefix_auto = 1 ]; then
	prefix="usr"
	set_confopt
fi

# APR is mandatory, so no additional test needed.
#
pkgprefix -t apr
var_append extraconfopt " " "--with-apr=$root/$( pkgprefix apr )"
pkgprefix -t apr-util
var_append extraconfopt " " "--with-apr-util=$root/$( pkgprefix apr-util )"

# all this is to build the apache server-side module and if so, no modification
# to httpd.conf are done ...
#
if pkginstalled apache; then
	var_append extraconfopt " " "--with-apxs=$root/$( pkgprefix sbindir apache )/apxs"
	var_append extraconfopt " " "--disable-mod-activation"
	# --with-berkeley-db=/usr/include/db40:/usr/lib
fi

# build and install perl bindings
svn_inst_pl() {
	make swig-pl-lib
	make install-swig-pl-lib
	pushd subversion/bindings/swig/perl/native
	perl Makefile.PL INSTALLDIRS='vendor'
	make install
	popd
}

# build and install python bindings
svn_inst_py() {
#	PYTHON_SITE=`python -c "import os,sys; print os.path.join(sys.prefix, 'lib','python'+sys.version[:3],'site-packages')"`
	# DESTDIR is used inside
	PYTHON_SITE=$(pkgprefix libdir python)/python$( pkgprefix ver python | cut -d. -f1-2 )
	make swig-py \
		swig_pydir=$PYTHON_SITE/libsvn \
		swig_pydir_extra=$PYTHON_SITE/svn
	make install-swig-py \
		swig_pydir=$PYTHON_SITE/libsvn \
		swig_pydir_extra=$PYTHON_SITE/svn
}

# build and install ruby bindings
svn_inst_rb() {
        make swig-rb
        make install-swig-rb
}

hook_add postmake 4 "cp -vrf tools $docdir"

# if swig is present build and install the perl and python bindings
if pkginstalled swig; then
	pkginstalled perl && hook_add postmake 5 "svn_inst_pl"
	pkginstalled python && hook_add postmake 5 "svn_inst_py"
	pkginstalled ruby && hook_add postmake 5 "svn_inst_rb"
fi

# use system wide neon
if pkginstalled neon; then
	pkgprefix -t neon
	var_append extraconfopt " " "--with-neon=$root/$( pkgprefix neon )"
	var_append extraconfopt " " "--disable-neon-version-check"
fi

# use bdb if available (it needs bdb 4.4)
if pkginstalled bdb; then
	var_append extraconfopt " " "--with-berkeley-db"
else
	var_append extraconfopt " " "--without-berkeley-db"
fi