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

name                    flow-tools
version                 0.68
revision                3
categories              net
maintainers             nomaintainer
platforms               darwin
license                 BSD

description             Suite of tools and library to work with netflow data
long_description        ${description}

homepage                http://www.splintered.net/sw/flow-tools/
master_sites            ftp://ftp.eng.oar.net/pub/flow-tools/
checksums               md5 c9e0a8b53c79611b6bffcb9d510a5a38

patchfiles              patch-configs_Makefile \
                        patch-flow-header.c \
                        patch-ftpaths.h \
                        patch-lib_ftchash.c \
                        patch-lib_ftio.c \
                        patch-lib_ftsym.c \
                        patch-lib_fttlv.c \
                        patch-lib_Makefile.in \
                        patch-lib_support.c \
                        patch-lib-ftfile.c \
                        patch-src_flow-fanout.c \
                        patch-src_Makefile.in

depends_lib             path:lib/libssl.dylib:openssl \
                        port:zlib

post-patch {
        reinplace "s|__PREFIX__|${prefix}|g" \
                ${worksrcpath}/lib/ftpaths.h

        reinplace "s|\$WHERE_MYSQL/lib/mysql|\$WHERE_MYSQL/lib/mysql5|g" \
                ${worksrcpath}/configure
        reinplace "s|\$WHERE_MYSQL/include/mysql|\$WHERE_MYSQL/include/mysql5|g" \
                ${worksrcpath}/configure

        reinplace -q "s|@localstatedir@/sym/|${prefix}/share/flow-tools/|g" \
                {*}[glob ${worksrcpath}/docs/flow-*.1.in] \
                {*}[glob ${worksrcpath}/docs/flow-*.html.in]

        reinplace -q "s|@localstatedir@/cfg/|${prefix}/etc/flow-tools/|g" \
                {*}[glob ${worksrcpath}/docs/flow-*.1.in] \
                {*}[glob ${worksrcpath}/docs/flow-*.html.in]

        # http://trac.macports.org/ticket/34358
        reinplace {/CFLAGS="-g -Wall"/d} ${worksrcpath}/configure
}

# http://trac.macports.org/ticket/34358
configure.cflags-append -std=gnu89

configure.args          --with-openssl=${prefix} \
                        --localstatedir=${prefix} \
                        --mandir=${prefix}/share/man

post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
        xinstall -m 644 -W ${worksrcpath} INSTALL README ChangeLog TODO \
                ${destroot}${prefix}/share/doc/${name}
}

variant mysql5 {
        configure.args-append   --with-mysql=${prefix}
        depends_lib-append      path:bin/mysql_config5:mysql5
}

livecheck.type          regex
livecheck.regex         ${name}-(\[0-9.\]+)\\.tar