# $Id: Portfile,v 1.7 2006/02/17 18:46:44 olegb Exp $
PortSystem 1.0
name		fetchmail
version		6.2.5
revision	2
categories	mail
maintainers	darwinports@opendarwin.org
description	Batch mail retrieval utility for IMAP, POP2, POP3, \
		APOP, KPOP, ETRN, or ODMR
long_description	Fetchmail is a full-featured IMAP, POP2, POP3, \
			APOP, KPOP, ETRN, ODMR client with easy \
			configuration, daemon mode, forwarding via SMTP \
			or local MDA, and superior reply handling.  It \
			is used to handle intermittent email connections \
			by acting as a coupling that seamlessly batch \
			forwards fetched mail from your mail server to \
			your local delivery system, allowing you to read \
			your it with your favourite mail user agent. \
			Fetchmail also includes useful spam filtering \
			and multi-user functions.  \
			A typical use of fetchmail is to connect to your \
			ISP's POP3 server, downloading your mail into \
			the INBOX on your local computer.  You may then \
			read the mail, offline if you want, using Pine, \
			mutt, or any standard mail user agent.   \
			Fetchmail is the lineal descendant of and \
			replacement for the old popclient program.
homepage	http://www.catb.org/~esr/fetchmail/
master_sites	http://www.catb.org/~esr/fetchmail/ \
		ftp://ftp.ccil.org/pub/esr/fetchmail/
checksums	md5 9956b30139edaa4f5f77c4d0dbd80225
platforms	darwin
depends_lib	lib:libintl.3:gettext
depends_run	path:/Library/StartupItems/DarwinPortsStartup:DarwinPortsStartup
patchfiles	fetchmail.patch

patch.args	-p1

# autoheader is very whiny. warnings cause it to exit with a non 0 status.
# 
post-patch      { cd ${worksrcpath}
		  reinplace "s|lock_release|fm_lock_release|g" fetchmail.c
		  reinplace "s|lock_release|fm_lock_release|g" fetchmail.h
		  reinplace "s|lock_release|fm_lock_release|g" lock.c 
		  system "aclocal -I ${prefix}/share/aclocal"
                  system "autoconf" 
                  system "autoheader || true" }

pre-configure	{ cd ${worksrcpath}
		  reinplace "s|@l@||g" intl/Makefile.in
		  reinplace "s|@GT_NO@||g" intl/Makefile.in
		  reinplace "s|@GT_YES@|#|g" intl/Makefile.in }

configure.env	CFLAGS="-I${prefix}/include" LDFLAGS="-L${prefix}/lib" \
		LIBS="-lintl"

configure.args	--mandir=${prefix}/share/man \
		--without-ssl --disable-inet6 --with-kerberos5 --with-gssapi

post-configure	{ cd ${worksrcpath}
		  reinplace "s|^#define HAVE_ARPA_NAMESER_H.*$|&\\\n#define BIND_8_COMPAT 1|" config.h }

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

variant ipv6	{ configure.args-delete	--disable-inet6
		  configure.args-append	--enable-inet6 }

post-build	{ file copy -force ${portpath}/files/fetchmail.sh ${worksrcpath}/
		  reinplace "s|__PREFIX|${prefix}|g" ${worksrcpath}/fetchmail.sh }

post-destroot	{ system "install -m 755 -d ${destroot}${prefix}/etc/rc.d"
		  system "install -m 755 -c ${worksrcpath}/fetchmail.sh ${destroot}${prefix}/etc/rc.d/" }

