#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)

ifeq ($(DEB_HOST_ARCH_OS), linux)
    CONFIGURE_ARGS+=--enable-epoll
else ifeq ($(DEB_HOST_ARCH_OS), kfreebsd)
    CONFIGURE_ARGS+=--enable-kqueue
else ifeq ($(DEB_HOST_ARCH_OS), solaris)
    CONFIGURE_ARGS+=--enable-ports
else
    CONFIGURE_ARGS+=--enable-poll
endif

ifdef DEB_DEBUG
   CONFIGURE_ARGS+=--enable-warnings --enable-iodebug
endif

# allow users to build with OpenSSL even if it possibly breaks the
# GPL, as we have no exception from all the authors of ircd
#
# this is not necessary in Wheezy, as there is an OpenSSL
# compatibility layer in GNUTLS
#
# for this to work, you need to manually install libssl-dev
export DEB_USE_OPENSSL

ifdef DEB_USE_OPENSSL
    CONFIGURE_ARGS+=--enable-openssl
else
    CONFIGURE_ARGS+=--disable-openssl
endif

ifdef DEB_NICKLEN
    CONFIGURE_ARGS+=--with-nicklen=$(DEB_NICKLEN)
endif

override_dh_auto_configure:
	autoconf
	./configure --prefix=/usr --with-confdir=/etc/charybdis \
		${CONFIGURE_ARGS} \
		--with-logdir=/var/log/charybdis \
		--with-moduledir=/usr/lib/charybdis/modules \
		--with-helpdir=/usr/share/doc/charybdis/help \
		--bindir=/usr/lib/charybdis \
		--enable-ipv6

%:
	dh $@ 
