# $NetBSD: Makefile.common,v 1.13 2004/07/14 20:07:07 jlam Exp $

DISTNAME?=	courier-${DIST_VERS}
CATEGORIES+=	mail
MASTER_SITES?=	${MASTER_SITE_SOURCEFORGE:=courier/}
EXTRACT_SUFX?=	.tar.bz2

MAINTAINER?=	jlam@NetBSD.org
HOMEPAGE?=	http://www.courier-mta.org/

# Version numbering scheme:
#
# DIST_VERS	version number on the distfile
# BASE_BERS	pkgsrc-manged version number
#
DIST_VERS=	0.45.6
BASE_VERS=	${DIST_VERS}

USE_GNU_TOOLS+=		make

PKG_SYSCONFSUBDIR?=	courier
DATADIR=		${PREFIX}/share/courier
LIBEXECDIR=		${PREFIX}/libexec/courier
AUTHLIBDIR=		${LIBEXECDIR}/authlib
DOCDIR=			${PREFIX}/share/doc/courier
HTMLDIR=		${PREFIX}/share/doc/html/courier
EGDIR=			${PREFIX}/share/examples/courier

SYSCONFTOOL=		${DATADIR}/sysconftool
FILES_SUBST+=		SYSCONFTOOL=${SYSCONFTOOL:Q}

.include "../../mk/bsd.prefs.mk"

GNU_CONFIGURE=		yes
CONFIGURE_ARGS+=	--datadir=${DATADIR}
CONFIGURE_ARGS+=	--libexecdir=${LIBEXECDIR}
CONFIGURE_ARGS+=	--localstatedir=${VARBASE}
CONFIGURE_ARGS+=	--sysconfdir=${PKG_SYSCONFDIR}

CONFIGURE_ARGS+=	--enable-unicode
CONFIGURE_ARGS+=	--with-authchangepwdir=${LIBEXECDIR}

CONFIGURE_ARGS+=	--with-db=db
CONFIGURE_ARGS+=	--with-userdb=${PKG_SYSCONFDIR}/userdb
CONFIGURE_ARGS+=	--with-makedatprog=${LIBEXECDIR}/makedatprog
CONFIGURE_ARGS+=	--disable-root-check

# Workaround a Solaris bug noted in:
#	http://www.inter7.com/courierimap/FAQ.html#solarisbug
#
.if ${OPSYS} == "SunOS"
CONFIGURE_ARGS+=	--with-waitfunc=wait3
.endif

# Build authdaemon, but explicitly disable certain methods (ldap, mysql,
# pgsql) that are built in separate packages.  We also disable authcustom
# since it's just a sample template authentication method, and authvchkpw
# since vpopmail is very explicitly *not* officially supported by the
# Courier author (though it's possible to work around this deficiency by
# using vchkpw2userdb(8)).
#
AUTHDAEMONVAR?=		${VARBASE}/authdaemon
FILES_SUBST+=		AUTHDAEMONVAR=${AUTHDAEMONVAR}
CONFIGURE_ARGS+=	--with-authdaemon
CONFIGURE_ARGS+=	--with-authdaemonvar=${AUTHDAEMONVAR}
CONFIGURE_ARGS+=	--without-authcustom
CONFIGURE_ARGS+=	--without-authldap
CONFIGURE_ARGS+=	--without-authmysql
CONFIGURE_ARGS+=	--without-authpgsql
CONFIGURE_ARGS+=	--without-authvchkpw

CONFIGURE_ENV+=		EXPECT=${LOCALBASE}/bin/expect
CONFIGURE_ENV+=		PERL=${PERL5}