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

# echo a warning if iptables was not build with development support and
# libnetfilter_queue is not available
if [ "$SDECFG_PKG_IPTABLES_DEVEL" != "1" ] && ! pkginstalled libnetfilter_queue ; then
	echo_warning "NuFW daemon WON'T be compiled: neither libipq nor nfqueue"
	echo_warning "found! Please recompile iptables with development support"
	echo_warning "or install libnetfilter_queue alternatively to get the"
	echo_warning "NuFW daemon build!"
fi

# Compile for NFQUEUE instead of QUEUE
if pkginstalled libnetfilter_queue ; then
	pkgprefix -t libnetfilter_queue
	var_append confopt ' ' "--with-nfqueue"
	echo_status "NuFW: libnetfilter_queue support"
else
	var_append confopt ' ' "--without-nfqueue"
fi

# Compile with netfilter_conntrack
if pkginstalled libnetfilter_conntrack ; then
	pkgprefix -t libnetfilter_conntrack
	var_append confopt ' ' "--with-nfconntrack"
	echo_status "NuFW: libnetfilter_conntrack support"
fi

# Support user activity logging in Prelude
if pkginstalled libprelude ; then
	pkgprefix -t libprelude
	var_append confopt ' ' "--with-prelude-log"
	var_append CPPFLAGS ' ' "-I$root$( pkgprefix includedir libprelude )/libprelude"
	var_append CFLAGS ' ' "-I$root$( pkgprefix includedir libprelude )/libprelude"
	var_append LDFLAGS ' ' "-L$root$( pkgprefix libdir libprelude )"
	export CPPFLAGS CFLAGS LDFLAGS
fi

# Support user activity logging in Mysql database
if pkginstalled mysql ; then
	pkgprefix -t mysql
	var_append confopt ' ' "--with-mysql-log"
	var_append GCC_WRAPPER_APPEND ' ' "-I$(pkgprefix -r includedir mysql)"
	var_append GCC_WRAPPER_APPEND ' ' "-L$(pkgprefix -r libdir mysql)"
fi

# Support user activity logging in PostgreSQL database
if pkginstalled postgresql ; then
	pkgprefix -t postgresql
	var_append confopt ' ' "--with-pgsql-log"
	var_append CPPFLAGS ' ' "-I$root$( pkgprefix includedir postgresql )"
	var_append CFLAGS ' ' "-I$root$( pkgprefix includedir postgresql )"
	var_append LDFLAGS ' ' "-L$root$( pkgprefix libdir postgresql )"
	export CPPFLAGS CFLAGS LDFLAGS
fi

# Support user activity logging in syslog
var_append confopt ' ' "--with-syslog-log"

# Support LDAP directory for users and acl lookup
if pkginstalled openldap ; then
	var_append confopt ' ' "--with-ldap"
fi