# $Id: Portfile,v 1.4 2006/02/09 07:56:52 blb Exp $
PortSystem		1.0

name			bincimap
version			1.2.13final
categories		mail
maintainers		darwinports@opendarwin.org
description		modular, secure, stable, and fast IMAP server for Maildir
long_description	Binc IMAP is a well designed, modular IMAP server \
					for  Maildir. Its goals are to be secure, stable, \
					and fast, yet flexible and easy to maintain.
homepage		http://www.bincimap.org
master_sites	${homepage}/dl/tarballs/1.2/
checksums		md5 6d64d556eb3b786ad727e250f884a432
use_bzip2		yes
platforms		darwin

patchfiles		patch-Makefile.in \
				patch-conf \
				patch-service

depends_lib		lib:libssl:openssl
depends_run		bin:checkpassword-pam:checkpassword-pam

configure.args	--sysconfdir=${prefix}/etc/${name} \
				--mandir=${prefix}/share/man \
				--without-optimization \
				--with-ssl

# If you prefer the DJB daemontools setup, use this variant,
# otherwise, it will assume xinetd will be used.
variant djb {
	depends_run-append	bin:supervise:daemontools \
						bin:tcpserver:ucspi-tcp
}

variant no_ssl {
	depends_lib-delete		lib:libssl:openssl
	configure.args-delete	--with-ssl
	configure.args-append	--without-ssl
}

post-destroot {
	cd ${worksrcpath}
	set confdir "${destroot}${prefix}/etc/${name}"
	xinstall -d -m 0755 ${confdir}
	xinstall -m 0644 conf/bincimap.conf ${confdir}/bincimap.conf.sample
	xinstall -d -m 0755 ${confdir}/pam
	xinstall -m 0644 ${filespath}/pam-bincimap ${confdir}/pam/bincimap.sample
	xinstall -d -m 0755 ${confdir}/xinetd
	xinstall -m 0644 conf/xinetd-bincimap ${confdir}/xinetd/imap.sample
	if {![variant_isset no_ssl]} {
		xinstall -m 0644 conf/xinetd-bincimaps ${confdir}/xinetd/imaps.sample
	}
	if {[variant_isset djb]} {
		xinstall -d -m 0755 ${confdir}/service
		xinstall -d -m 0755 ${confdir}/service/imap.sample
		xinstall -m 0644 service/run ${confdir}/service/imap.sample
		xinstall -d -m 0755 ${confdir}/service/imap.sample/log
		xinstall -m 0644 service/log/run ${confdir}/service/imap.sample/log
		if {![variant_isset no_ssl]} {
			xinstall -d -m 0755 ${confdir}/service/imaps.sample
			xinstall -m 0644 service/run-ssl ${confdir}/service/imaps.sample
			xinstall -d -m 0755 ${confdir}/service/imaps.sample/log
			xinstall -m 0644 service/log/run-ssl ${confdir}/service/imaps.sample/log
		}
	}
	set docdir "${destroot}${prefix}/share/doc/${name}"
	xinstall -m 0644 ${filespath}/README.MACOSX.in ${docdir}/README.MACOSX
	reinplace "s|@prefix@|${prefix}|" ${docdir}/README.MACOSX
	xinstall -m 0644 README.SSL ${docdir}
	xinstall -d -m 0755 ${docdir}/contrib
	xinstall -m 0644 contrib/README \
		contrib/authenticators/bincimap-auth-teapop.sh \
		${docdir}/contrib
}

