# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../lighttpd/lighttpd.conf
# Copyright (C) 2006 - 2008 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
        prefix="opt/lighttpd"
        set_confopt
fi

var_append confopt ' ' "--enable-fastcgi"

if pkginstalled bzip2; then
	var_append confopt ' ' "--with-bzip2"
else
	var_append confopt ' ' "--without-bzip2"
fi

if pkginstalled openssl; then
	var_append confopt ' ' "--with-openssl"
fi

if pkginstalled openldap; then
	pkgprefix -t openldap
	var_append confopt ' ' "--with-ldap"
	var_append LDFLAGS ' ' "-L$( pkgprefix libdir openldap )"
	var_append CFLAGS  ' ' "-I$( pkgprefix includedir openldap )"
	export LDFLAGS CFLAGS
fi

if pkginstalled mysql; then
        var_append confopt ' ' "--with-mysql"
fi

if pkginstalled gdbm; then
        var_append confopt ' ' "--with-gdbm"
fi

if pkginstalled fam; then
        var_append confopt ' ' "--with-fam"
fi

if pkginstalled libmemcache; then
        var_append confopt ' ' "--with-memcache"
fi

if pkginstalled lua; then
        var_append confopt ' ' "--with-lua"
fi

# copy default config file
lighttpd_dotconf() {
	sed	-e "s,^server.document-root .*,server.document-root	= \"/var/empty\"," \
		-e "s,^server.errorlog .*,server.errorlog	= \"$localstatedir/log/error.log\"," \
		-e "s,^accesslog.filename .*,accesslog.filename	= \"$localstatedir/log/access.log\"," \
		doc/lighttpd.conf > $root$sysconfdir/lighttpd.conf-dist
}

hook_add postmake 5 "lighttpd_dotconf"