# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../freeradius/freeradius.conf
# Copyright (C) 2007 - 2013 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 [ "$SDECFG_PKG_FREERADIUS_PREFIX" ] ; then
	  prefix="$SDECFG_PKG_FREERADIUS_PREFIX"
	else
	  prefix="opt/freeradius"
	fi
	set_confopt
fi

if atstage cross; then
	# freeradius build system uses the 'R' variable for defining DESTDIR
	var_append makeinstopt ' ' "R=$root"
fi

var_append LDFLAGS ' ' "-L/lib"
export LDFLAGS

# build fails when using included libtool and libltdl
var_append extraconfopt ' ' "--with-system-libtool"
var_append extraconfopt ' ' "--with-system-libltdl"

var_append extraconfopt ' ' "--with-large-files --disable-ltdl-install --disable-static"

# always reply from the IP the request was sent to
var_append extraconfopt ' ' "--with-udpfromto"

if pkginstalled openldap; then
	pkgprefix -t openldap
	var_append extraconfopt ' ' "--with-rlm-ldap-lib-dir=$( pkgprefix libdir openldap )"
	var_append extraconfopt ' ' "--with-rlm-ldap-include-dir=$( pkgprefix includedir openldap )"
else
	var_append extraconfopt ' ' "--without-rlm-ldap"
fi

# --docdir is not supported
var_remove_regex confopt ' ' '--docdir=.*'

pkg_freeradius_postinstall()
{
	# installing .a and .la files for the modules makes no sense
	rm -f $root$libdir/rlm_*.{a,la}
}
hook_add postinstall 5 'pkg_freeradius_postinstall'