# $Id: Portfile 50984 2009-05-14 21:08:43Z and.damore@macports.org $

PortSystem 1.0

name			cclient
version			2007d
categories		mail
maintainers		kallisys.net:pguyot openmaintainer
description		UW IMAP c-client library
long_description	\
				C-client is a common API for accessing mailboxes. It is \
				used internally by the popular PINE mail reader as well as the \
				University of Washington's IMAP server.
homepage		http://www.washington.edu/imap/
platforms		darwin
master_sites	ftp://ftp.cac.washington.edu/imap/ \
				ftp://ftp.cac.washington.edu/imap/old/ \
				macports:pguyot
distname		imap-${version}	
dist_subdir		imap-uw
worksrcdir		imap-${version}
checksums           md5     ec27cd4c5972b981bb96e9da0430af53 \
                    sha1    c77a3feaa68fa8a73eea85718e66eba9ae3e222c \
                    rmd160  d403678f83e761237cbdf62b4bcde466cdf85123

depends_lib		port:openssl \
				lib:libz:zlib \
				lib:libgssapi_krb5:kerberos5

use_configure	no

post-patch {
	reinplace "s|/System/Library/OpenSSL SSLINCLUDE=/usr/include/openssl SSLLIB=/usr/lib|${prefix}/etc/openssl SSLINCLUDE=${prefix}/include SSLLIB=${prefix}/lib|g" ${worksrcpath}/Makefile
	reinplace "s| -Wno-pointer-sign||g" ${worksrcpath}/src/osdep/unix/Makefile
}

build.target	oxp
build.args		EXTRACFLAGS=-fno-common CC=${configure.cc}

variant ssl_plaintext description {Allow plaintext passwords over SSL} {
	patchfiles patch-Makefile
	build.args-append SSLTYPE=unix
}

variant universal {
	build.args-delete EXTRACFLAGS="-fno-common"
	build.args-append EXTRACFLAGS="${configure.universal_cflags}" EXTRALDFLAGS="${configure.universal_ldflags}"
}

destroot {
	xinstall -m 755 -d ${destroot}${prefix}/include/c-client
	xinstall -m 644 -W ${worksrcpath}/c-client \
		c-client.h dummy.h env.h env_unix.h fdstring.h flockcyg.h flocksim.h \
		flstring.h fs.h ftl.h imap4r1.h linkage.c linkage.h mail.h \
		misc.h netmsg.h newsrc.h nl.h nntp.h osdep.h \
		pseudo.h rfc822.h smtp.h sslio.h tcp.h tcp_unix.h unix.h \
		utf8.h utf8aux.h \
		${destroot}${prefix}/include/c-client
	xinstall -m 644 ${worksrcpath}/c-client/c-client.a \
		${destroot}${prefix}/lib/libc-client4.a
	system "cd ${destroot}${prefix}/lib/ && ranlib libc-client4.a"
}

livecheck.check regex
livecheck.url   http://ftp.ntua.gr/pub/net/mail/imap/?C=M&O=D
livecheck.regex {imap-(\d+(?:[a-z]\d*)?)\.tar}
