--- Portfile-orig	Mon Nov 10 02:57:56 2003
+++ Portfile	Mon Nov 24 22:07:36 2003
@@ -1,6 +1,6 @@
 PortSystem 1.0
 name		courier-imap
-version	 	2.0.0	
+version	 	2.2.0	
 categories	mail
 maintainers	bchesneau@mac.com
 description	IMAP server
@@ -13,72 +13,88 @@
 platforms	darwin
 master_sites	sourceforge:courier
 use_bzip2	yes
-checksums	courier-imap-2.0.0.tar.bz2 md5 636816de2338eac4ad66d9d406020cba
+checksums	courier-imap-2.2.0.tar.bz2 md5 95e1f563a0c27330991820046d4d65d1
+
+
+
 depends_lib    	lib:libssl.0.9:openssl
 depends_run 	path:/Library/StartupItems/DarwinPortsStartup:DarwinPortsStartup
 
 set authdaemondir ${prefix}/var/run/authdaemon.courier-imap
+	
 
-configure.env	CFLAGS=-no-cpp-precomp \
-		LANG=C
  
 configure.args	--bindir=${prefix}/bin --mandir=${prefix}/share/man \
-		--sysconfdir=${prefix}/etc/courier \
+		--sysconfdir=${prefix}/etc/courier-imap \
 		--localstatedir=${prefix}/var/run \
 		--datadir=${prefix}/share/courier \
 		--with-piddir=${prefix}/var/run \
 		--with-authdaemonvar=${authdaemondir} \
-		--enable-workarounds-for-imap-client-bugs \
-		--enable-unicode=iso-8859-1,utf-8 --disable-root-check
+		--enable-unicode --disable-root-check
+
 
-variant darwin {
+platform darwin 6 {
 	depends_lib-append      lib:libdl.1:dlcompat
 	patchfiles      	patch-rfc1035_res.h
-	configure.args-append	--with-waitfunc=wait3
+	configure.args-append	--with-waitfunc=wait3 --with-authpam
+	configure.env	LDFLAGS=-L${prefix}/lib \
+					CPPFLAGS="-I${prefix}/include -no-cpp-precomp \
+					LANG=C
+	
 }
 
+
+platform darwin 7 {
+	patchfiles      	patch-rfc1035_res.h
+	configure.args-append	--with-waitfunc=wait3 --with-authshadow --with-authpam
+	
+	configure.env	LDFLAGS=-L${prefix}/lib \
+					CPPFLAGS="-I${prefix}/include -I${workpath}/paminclude -no-cpp-precomp" \
+					CFLAGS="-I${prefix}/include -I${workpath}/paminclude -no-cpp-precomp" \
+					LANG=C
+	
+	post-extract	{
+		system "rm '${worksrcpath}/INSTALL'"
+		system "mkdir -p ${workpath}/paminclude"
+		system "ln -s /usr/include/pam ${workpath}/paminclude/security"
+	}
+}
+
+
 variant mysql {
 	depends_lib-append      lib:libmysqlclient:mysql
-	configure.env-append	LDFLAGS=-L${prefix}/lib/mysql \
-				CPPFLAGS=-I${prefix}/include/mysql
 }
 
+variant mysql4 {
+	depends_lib-append      lib:libmysqlclient:mysql4
+}
+
+
 variant postgres { 
-	configure.env-append    LDFLAGS=-L${prefix}/lib -L${prefix}/pgsql/lib \
-				CPPFLAGS=-I${prefix}/include/ -I${prefix}/pgsql/include
-        depends_lib-append      lib:plpgsql:postgresql
+	depends_lib-append      lib:plpgsql:postgresql
+	
 } 
 
-variant berkdb { 
-	depends_lib-append	lib:libdb-4.1:db4	
-	configure.env-append	CPPFLAGS=-I${prefix}/include/db4
+variant ldap { 
+	configure.args-append	--with-authldap
 }
 
 pre-configure {
 	
-	if { ![variant_isset mysql]} {
+	if { ![variant_isset mysql] && ![variant_isset mysql4] } {
 		configure.args-append --without-authmysql
 	}
 	if { ![variant_isset ldap]} {
                 configure.args-append --without-authldap
-        }
-	if { ![variant_isset pam]} { 
-                configure.args-append --without-authpam 
-        }
+	}
+	
 	if { ![variant_isset postgres]} { 
-                configure.args-append --without-authpostgresql 
-        }
-	if { [variant_isset berkdb]} { 
-		configure.args-append --with-db=db
+		configure.args-append --without-authpostgresql 
 	}
+	
 }
 
-
-destroot {
-	system "cd ${workpath}/${worksrcdir}"
-	system "make install DESTDIR=${destroot}"
-	system "make install-configure DESTDIR=${destroot}"
-}
+destroot.target install install-configure
 
 post-destroot {
 	file mkdir ${destroot}${prefix}/var/run
@@ -86,9 +102,9 @@
 	file mkdir ${destroot}${authdaemondir} 
 	system "touch ${destroot}${authdaemondir}/.turd"
 
-	system "install -o root -m 755 -c \
-                      ${portpath}/files/*.sh ${destroot}${prefix}/etc/rc.d"
+	system "install -o root -m 755 -c ${portpath}/files/*.sh ${destroot}${prefix}/etc/rc.d"
 	reinplace "s|__PREFIX|${prefix}|g" ${destroot}${prefix}/etc/rc.d/imapd.sh
+	reinplace "s|__PREFIX|${prefix}|g" ${destroot}${prefix}/etc/rc.d/imapd-ssl.sh
 	reinplace "s|ulimit|#ulimit|g" ${destroot}${prefix}/libexec/imapd.rc
 	reinplace "s|ulimit|#ulimit|g" ${destroot}${prefix}/libexec/imapd-ssl.rc
 }
