--- _orig/sysutils/syslog-ng/Portfile	2014-09-25 11:00:31.000000000 -0400
+++ sysutils/syslog-ng/Portfile	2015-04-06 18:08:13.000000000 -0400
@@ -1,70 +1,213 @@
-# $Id: Portfile 125738 2014-09-25 14:43:03Z mf2k@macports.org $
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
+# $Id: Portfile 104019 2013-03-13 01:05:06Z jmr@macports.org $
 
 PortSystem 1.0
 
-name			syslog-ng
-version			3.0.8
-revision		2
-categories		sysutils
-license			{GPL-2 OpenSSLException}
-platforms		darwin
-maintainers		nomaintainer
-description		Highly configurable syslog replacement.
-long_description	syslog-ng is the world's most flexible and scalable audit \
-					trail processing tool for organizations of any size. It \
-					provides a centralised, securely stored log of all devices \
-					on your network, whatever platform they run on. And \
-					syslog-ng also incorporates a host of powerful features, \
-					including filtering based on message content, as well as \
-					customisable data mining and analysis capabilities.
-
-homepage			http://www.balabit.com/products/syslog_ng/
-master_sites			http://www.balabit.com/downloads/files/syslog-ng/open-source-edition/${version}/source/
-checksums			md5 7107f5758dec4b774136f0f827b35258
-distfiles			${name}_${version}${extract.suffix}
-patchfiles			patch-src-Makefile.in.diff
-
-depends_build			path:bin/pkg-config:pkgconfig
-depends_lib			port:eventlog \
-				port:libnet11 \
-				path:lib/pkgconfig/glib-2.0.pc:glib2
+PortGroup           github 1.0 
 
-startupitem.create      yes
-startupitem.executable  ${prefix}/sbin/syslog-ng
+github.setup        balabit syslog-ng 3.6.2
+categories          sysutils
+license             {LGPL+GPL-2 OpenSSLException}
+platforms           darwin
+maintainers	        nomaintainer
+description         Highly configurable syslog replacement.
+long_description    syslog-ng is the world's most flexible and scalable audit \
+                    trail processing tool for organizations of any size. It \
+                    provides a centralised, securely stored log of all devices \
+                    on your network, whatever platform they run on. And \
+                    syslog-ng also incorporates a host of powerful features, \
+                    including filtering based on message content, as well as \
+                    customisable data mining and analysis capabilities.
+homepage            http://www.balabit.com/products/syslog_ng/
+#master_sites        http://www.balabit.com/downloads/files/syslog-ng/open-source-edition/${version}/source/
+
+distname            ${name}_${version}
+#patchfiles           patch-src-Makefile.in.diff
+## FIXME! https://bugzilla.balabit.com/show_bug.cgi?id=155
+## https://github.com/Homebrew/homebrew/issues/22030
+## https://github.com/balabit/syslog-ng/issues/173
+patchfiles           patch-configure.ac.diff
+
+depends_build        path:bin/pkg-config:pkgconfig port:gmake port:bison
+depends_lib          port:eventlog port:libnet11 port:pcre \
+                     path:lib/pkgconfig/glib-2.0.pc:glib2
+
+startupitem.create   yes
+startupitem.executable ${prefix}/sbin/syslog-ng
 startupitem.pidfile clean ${prefix}/var/syslog-ng.pid
 
-configure.args		--mandir=${prefix}/share/man \
-			--enable-dynamic-linking \
-			--sysconfdir=${prefix}/etc
+configure.args       --mandir=${prefix}/share/man \
+                     --enable-dynamic-linking \
+                     --sysconfdir=${prefix}/etc \
+                     --enable-tcp-wrapper --enable-spoof-source \
+                     --enable-pcre \
+                     --disable-mongodb --disable-json
+
+## "ld: unknown option: --whole-archive" => same w clang or mp-gcc49 :(
+#configure.compiler  macports-gcc-4.9
+build.env            MAKE=${prefix}/bin/gmake
+
+if {${subport} eq ${name}} {
+
+    checksums           rmd160  8562f1494d384125113c6ad6777f7e68edd345f1 \
+                        sha256  ef47fada52981e09af570457a5af30f815f5d5b6c2e33754cedd4ca9780d8261
+#    livecheck.type     regex
+#    livecheck.url       http://www.balabit.com/downloads/files/syslog-ng/open-source-edition
+#    livecheck.regex     "/downloads/files/syslog-ng/open-source-edition/(\\d+(?:\\.\\d+)*)\""
+}
+
+subport ${name}30 {
+    version             3.0.8
+    distname            ${name}_${version}
+    master_sites        http://www.balabit.com/downloads/files/syslog-ng/open-source-edition/${version}/source/
+    checksums           rmd160  5eceefb35c8afbda82605d742cbdf4ba2a22cd3a \
+                        sha256  ba93e53768f53d1fa2f753327e4b7f7aae46cc48274a9475effe14c722e314b2
+
+    livecheck.type      none
+}
+
+## Test latest work in progress
+subport ${name}-devel {
+    version             20150405
+    distname            950f046c592395efde94c4de8ed30fdd30d479de
+    master_sites        https://github.com/${github.author}/${github.project}/archive/
+    checksums           rmd160  b48ef66920326f8f6374ea932b9338960a129df8 \
+                        sha256  6fb8875009a62314351736afb7f4d1245c06e1c38d97e6420127a31902a0f8ed
+    worksrcdir          ${github.project}-${distname}
+
+    depends_build-append port:libtool
+## configure: error: Building with system librabbitmq is not supported yet.
+#                        port:rabbitmq-c
+    depends_lib-append  port:libivykis \
+                        port:json-c \
+                        port:libmongo-client
+
+    patchfiles-delete           patch-configure.ac.diff
+
+    pre-configure {
+        reinplace "s|^SUBMODULES=.*$|SUBMODULES=''|" ${worksrcpath}/autogen.sh
+        reinplace "s|^libtoolize|${prefix}/bin/glibtoolize|" ${worksrcpath}/autogen.sh
+        system -W ${worksrcpath} "./autogen.sh"
+    }
+
+    configure.cflags        -D__sun
+    configure.args-append   --with-ivykis=system \
+                            --with-libmongo-client=system \
+                            --with-jsonc=system \
+                            --with-python=2.7 \
+                            --disable-java
+#                            --with-librabbitmq-client=system
+
+    livecheck.type      none
+}
+
+subport ${name}-develgreg {
+    github.setup        gregory094 syslog-ng 3.6.2
+    version             20150224
+    distname            3e5f42b1d638063ed8a8e8699182935f8be4167e
+    checksums           rmd160  5e839dfb916b6202606b04683ad31d2ed2a43fdf \
+                        sha256  622d22c829518b03961a560d4935f7d3d98fdd14a298e88c16fa8217b58e886c
+    master_sites        https://github.com/${github.author}/${github.project}/archive/
+    worksrcdir          ${github.project}-${distname}
+
+    depends_build-append port:libtool
+## configure: error: Building with system librabbitmq is not supported yet.
+#                        port:rabbitmq-c
+    depends_lib-append  port:libivykis \
+                        port:json-c \
+                        port:libmongo-client
+
+    patchfiles-delete           patch-configure.ac.diff
+
+    pre-configure {
+        reinplace "s|^SUBMODULES=.*$|SUBMODULES=''|" ${worksrcpath}/autogen.sh
+        reinplace "s|^libtoolize|${prefix}/bin/glibtoolize|" ${worksrcpath}/autogen.sh
+        system -W ${worksrcpath} "./autogen.sh"
+    }
+
+    configure.cflags        -D__sun
+    configure.args-append   --with-ivykis=system \
+                            --with-libmongo-client=system \
+                            --with-jsonc=system \
+                            --with-python=2.7 \
+                            --disable-java
+#                            --with-librabbitmq-client=system
+
+    livecheck.type      none
+}
 
-platform powerpc	{
-	configure.args-append		--host=powerpc
+platform powerpc    {
+    configure.args-append        --host=powerpc
 }
 
 pre-destroot {
 # Append the major.minor version number to the top of the sample config
-	set major_minor [join [lrange [split ${version} .] 0 1] .]
-	system "echo version $major_minor >> ${worksrcpath}/doc/examples/header"
-	system "cat ${worksrcpath}/doc/examples/header ${worksrcpath}/doc/examples/syslog-ng.conf.sample \
-		> ${worksrcpath}/doc/examples/syslog-ng.conf-dist"
+    set major_minor [join [lrange [split ${version} .] 0 1] .]
+    system "echo version $major_minor >> ${worksrcpath}/doc/examples/header"
+    system "cat ${worksrcpath}/doc/examples/header ${worksrcpath}/doc/examples/syslog-ng.conf.sample \
+        > ${worksrcpath}/doc/examples/syslog-ng.conf-dist"
 }
 
-post-destroot	{
-	xinstall -m 644 ${worksrcpath}/doc/examples/syslog-ng.conf-dist \
-		${destroot}${prefix}/etc
-	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
-	xinstall -m 644 -W ${worksrcpath} ChangeLog README AUTHORS COPYING NEWS \
-		${destroot}${prefix}/share/doc/${name}
-	reinplace "s|/dev/log|/var/run/syslog|g" \
-		${destroot}${prefix}/etc/syslog-ng.conf-dist
+post-destroot    {
+    xinstall -m 755 -d ${destroot}${prefix}/share/examples/${name}
+    xinstall -m 644 ${worksrcpath}/doc/examples/syslog-ng.conf-dist \
+        ${destroot}${prefix}/share/examples/${name}/
+    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
+    xinstall -m 644 -W ${worksrcpath} ChangeLog README AUTHORS COPYING NEWS \
+        ${destroot}${prefix}/share/doc/${name}
+    reinplace "s|/dev/log|/var/run/syslog|g" \
+        ${destroot}${prefix}/etc/syslog-ng.conf-dist
+}
+
+post-activate {
+    if ![file exists ${prefix}/etc/syslog-ng.conf ] {
+        copy ${prefix}/share/examples/${name}/syslog-ng.conf.dist ${prefix}/etc/
+    }
 }
 
 notes \
-"To use syslog-ng, first unload OS X's built-in syslog daemon:
+"
+*** Latest 3.6.x not compiling on MacOS X, use subport for 3.0.8 ***
+
+To use syslog-ng, first unload OS X's built-in syslog daemon:
 
-	sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.syslogd.plist
+    sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.syslogd.plist
 
 Then copy ${prefix}/etc/syslog-ng.conf-dist to ${prefix}/etc/syslog-ng.conf,
 customize, and load syslog-ng:
 
-	sudo launchctl load -w /Library/LaunchDaemons/org.macports.syslog-ng.plist"
+    sudo launchctl load -w /Library/LaunchDaemons/org.macports.syslog-ng.plist
+"
+
+default_variants +ssl +ipv6 +sql +geoip
+
+variant ssl description { ssl support } {
+    depends_lib-append  port:openssl
+    configure.args-append --enable-ssl
+}
+
+variant geoip description { geoip support } {
+    depends_lib-append  port:libgeoip
+    configure.args-append --enable-geoip
+}
+
+variant ipv6 description { ipv6 support } {
+    configure.args-append --enable-ipv6
+}
+
+variant sql description { sql support } {
+    depends_lib-append  port:libdbi
+    configure.args-append --enable-sql
+}
+
+variant mongodb description { mongodb support } {
+    configure.args-delete --disable-mongodb
+    configure.args-append --enable-mongodb
+}
+
+variant json description { json-c support } {
+    depends_lib-append  port:json-c
+    configure.args-delete --disable-json
+    configure.args-append --enable-json
+}
+
