# -*- 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

PortSystem          1.0
PortGroup           github 1.0

github.setup        syslog-ng syslog-ng 3.38.1 syslog-ng-
revision            0
categories          sysutils
license             {GPL-2+ OpenSSLException}
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            https://www.syslog-ng.com
github.tarball_from releases
checksums           rmd160  cd6e9b67b73a68b126dce8653dbf696583b8d86b \
                    sha256  5491f686d0b829b69b2e0fc0d66a62f51991aafaee005475bfa38fab399441f7 \
                    size    5405048

depends_build       path:bin/pkg-config:pkgconfig

depends_lib         port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:json-c \
                    port:libnet \
                    path:lib/libssl.dylib:openssl \
                    port:pcre

patchfiles          clock_gettime_compat.patch \
                    MAP_ANONYMOUS.patch \
                    80e97634cb75878ee94b23ebf35cebc92481fbfc.patch

if {${os.platform} eq "darwin" && ${os.major} > 22} {
    patchfiles-append   patch-sonoma.diff
}

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/syslog-ng
startupitem.pidfile clean ${prefix}/var/syslog-ng.pid

configure.args      --enable-dynamic-linking \
                    --disable-sql \
                    --disable-mongodb \
                    --disable-amqp \
                    --disable-smtp \
                    --disable-mqtt \
                    --disable-http \
                    --disable-redis \
                    --disable-geoip2 \
                    --disable-riemann \
                    --disable-python \
                    --disable-kafka \
                    --disable-java \
                    --disable-afsnmp \
                    --without-compile-date \
                    --disable-silent-rules

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} README.md AUTHORS COPYING NEWS.md \
        GPL.txt LGPL.txt ${destroot}${prefix}/share/doc/${name}
    move ${destroot}${prefix}/etc/syslog-ng.conf ${destroot}${prefix}/etc/syslog-ng.conf-dist
}

post-activate {
    if {![file exists ${prefix}/etc/syslog-ng.conf]} {
        copy ${prefix}/etc/syslog-ng.conf-dist ${prefix}/etc/syslog-ng.conf
    }
}

notes \
"To use syslog-ng, first unload OS X's built-in syslog daemon:

    sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.syslogd.plist

Then customize ${prefix}/etc/syslog-ng.conf,
and load syslog-ng."