# $Id: Portfile,v 1.6 2004/01/30 06:12:19 pguyot Exp $

PortSystem 1.0
name				qpopper
version				4.0.5
revision			4
categories			mail
maintainers			pguyot@kallisys.net
description			Eudora POP3 mail server
long_description	popper is Eudora's POP3 mail server. It does not include a mail \
					transfer agent or an SMTP server, it just let you get your mail stored \
					on the machine via POP3.
homepage			http://www.eudora.com/qpopper/
distfiles			${name}${version}${extract.suffix}
master_sites		ftp://ftp.qualcomm.com/eudora/servers/unix/popper/ \
					http://core.ring.gr.jp/archives/net/mail/qpopper/ \
					http://www.ring.gr.jp/archives/net/mail/qpopper/ \
					ftp://ftp.nctu.edu.tw/network/mail/qpopper/
checksums			md5 e00853280c9e899711f0b0239d3d8f86
worksrcdir			${portname}${portversion}
patchfiles			patch-Makefile.in patch-pop_pass.c

configure.args		--mandir=${prefix}/share/man
destroot.destdir	prefix=${destroot}/${prefix} mandir=${destroot}/${prefix}/share/man

pre-destroot {
	xinstall -d ${destroot}${prefix}/etc/xinetd.d
	xinstall -o root -m 755 -c ${portpath}/files/qpopper-dist \
		${destroot}${prefix}/etc/xinetd.d/
	reinplace "s|@@PREFIX@@|${prefix}|g" \
		${destroot}${prefix}/etc/xinetd.d/qpopper-dist
}

# Tell the user that the server needs to be used through (x)inetd
post-install {
	ui_msg "\nTo use qpopper, you'll need to add it to inetd.conf/xinetd.d depending on"
	ui_msg "what you use on your system.\n"
	ui_msg "For inetd, something like:"
	ui_msg "pop3  stream  tcp  nowait  root  /usr/libexec/tcpd  ${prefix}/sbin/popper"
	ui_msg "should do it.\n"
	ui_msg "For xinetd (the default on MacOS X), you'll find in ${prefix}/etc/xinetd.d/"
	ui_msg "a file called qpopper-dist that you should edit and copy to /etc/xinetd.d/\n"
	ui_msg "In both cases, don't forget to tell (x)inetd to reload their configuration.\n"
}

variant darwin {
	configure.args-append --enable-specialauth
	patchfiles-append patch-configure

	post-extract	{
		system "rm '${worksrcpath}/INSTALL'"
	}
}

variant ssl {
	configure.args-append	--with-openssl=${prefix}
	depends_lib-append	lib:libssl.0:openssl
	
	post-install {
		ui_msg "To get TLS/SSL working, you need to setup certificates."
		ui_msg "Cf: http://www.eudora.com/qpopper/faq.html#tls"		
	}
}

variant pam {
	configure.env	CPPFLAGS="-I${workpath}/paminclude" CFLAGS="-I${workpath}/paminclude"
	configure.args-append	--with-pam=pop3
	post-install {
		ui_msg "Additionally, for PAM, you need to copy /etc/pam.d/sshd to"
		ui_msg " /etc/pam.d/pop3, or use another config with pam_securityserver.so."
	}

	post-extract	{
		system "mkdir -p ${workpath}/paminclude"
		system "ln -s /usr/include/pam ${workpath}/paminclude/security"
	}
}
