Index: files/patch-sieve-0.1.15-extern.diff
===================================================================
--- files/patch-sieve-0.1.15-extern.diff	(revision 0)
+++ files/patch-sieve-0.1.15-extern.diff	(revision 0)
@@ -0,0 +1,37 @@
+
+# HG changeset patch
+# User Stephan Bosch <stephan@rename-it.nl>
+# Date 1264449560 -3600
+# Node ID fe0b2ff5032670a84f3bc30b1ef1daa6142a4dac
+# Parent  939eb4311735179853a44f8d69098a0aae07ef2f
+Omitted 'extern' in two declarations of global variables in header files, causing compile failures on certain systems.
+
+--- a/src/lib-sieve-tool/sieve-tool.h	Mon Jan 25 18:42:30 2010 +0100
++++ b/src/lib-sieve-tool/sieve-tool.h	Mon Jan 25 20:59:20 2010 +0100
+@@ -10,12 +10,12 @@
+  * Sieve instance
+  */
+ 
+-struct sieve_instance *sieve_instance;
++extern struct sieve_instance *sieve_instance;
+ 
+ const char *sieve_tool_get_setting(void *context, const char *identifier);
+ const char *sieve_tool_get_homedir(void *context);
+ 
+-const struct sieve_environment sieve_tool_environment;
++extern const struct sieve_environment sieve_tool_environment;
+ 
+ /*
+  * Initialization
+--- a/src/lib-sieve/plugins/notify/ext-notify-common.h	Mon Jan 25 18:42:30 2010 +0100
++++ b/src/lib-sieve/plugins/notify/ext-notify-common.h	Mon Jan 25 20:59:20 2010 +0100
+@@ -41,7 +41,7 @@
+  * Actions 
+  */
+ 
+-const struct sieve_action_def act_notify_old;
++extern const struct sieve_action_def act_notify_old;
+ 
+ struct ext_notify_recipient {
+ 	const char *full;
+
Index: Portfile
===================================================================
--- Portfile	(revision 65110)
+++ Portfile	(working copy)
@@ -19,8 +19,10 @@
 
 homepage            http://dovecot.org/
 
-master_sites        ${homepage}releases/${branch}
-checksums           md5     b7d0081b17ff6afae85e8dc14157fa57 \
+master_sites        ${homepage}releases/${branch}:dovecot
+distfiles           ${distname}${extract.suffix}:dovecot
+checksums           ${distname}${extract.suffix} \
+                    md5     b7d0081b17ff6afae85e8dc14157fa57 \
                     sha1    b717de1ab63f3d521c93385cbd20c49293921079 \
                     rmd160  0b508502b7c2e9aecd274bf15f1ec5adbb1843a7
 
@@ -103,6 +105,72 @@
     depends_lib-append          port:openldap
 }
 
+variant sieve description {Enable LDA sieve extension} {
+    global sieve_version sieve_distname sieve_worksrcpath
+
+    set sieve_version           0.1.15
+    master_sites-append         http://www.rename-it.nl/dovecot/${branch}:sieve
+    set sieve_distname          ${name}-${branch}-sieve-${sieve_version}
+    distfiles-append            ${sieve_distname}${extract.suffix}:sieve
+
+    checksums-append            ${sieve_distname}${extract.suffix} \
+                                md5     2246fbbcf304d3ec1df0db2d091fe05a \
+                                sha1    2827df60028639ec15422a86f48a1c9b2a78431a \
+                                rmd160  7fd3d23d5ef93d443cdedc8512dab649b2a99694
+
+    set sieve_worksrcpath ${workpath}/${sieve_distname}
+
+    # There has been a compile problem with sieve 0.1.15, remove this on next version increment
+    post-patch {
+        system "cd ${sieve_worksrcpath} && patch -p1 < ${filespath}/patch-sieve-0.1.15-extern.diff"
+    }
+
+    post-configure {
+        global sieve_worksrcpath
+
+        # dovecot-sieve needs dovecot-config
+        system "cd ${worksrcpath} && make dovecot-config"
+
+        set configure_dir_save  ${configure.dir}
+        set configure_args_save ${configure.args}
+        configure.dir           ${sieve_worksrcpath}
+        configure.args          --with-dovecot=${worksrcpath}
+
+        if {[catch {command_exec configure} result]} {
+            return -code error "configure sieve failed: $result"
+        }
+
+        configure.dir           ${configure_dir_save}
+        configure.args          ${configure_args_save}
+    }
+
+    post-build {
+        global sieve_worksrcpath
+
+        set build_dir_save  ${build.dir}
+        build.dir           ${sieve_worksrcpath}
+
+        if {[catch {command_exec build} result]} {
+            return -code error "build sieve failed: $result"
+        }
+
+        build.dir           ${build_dir_save}
+    }
+
+    post-destroot {
+        global sieve_worksrcpath
+
+        set destroot_dir_save  ${destroot.dir}
+        destroot.dir           ${sieve_worksrcpath}
+
+        if {[catch {command_exec destroot} result]} {
+            return -code error "destroot sieve failed: $result"
+        }
+
+        destroot.dir           ${destroot_dir_save}
+    }
+}
+
 startupitem.create      yes
 startupitem.executable  ${prefix}/sbin/dovecot
 startupitem.pidfile     auto ${prefix}/var/run/dovecot/master.pid
