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

PortSystem          1.0

name                p0f
version             3.08b
set major           [lindex [split ${version} .] 0]
categories          net security
platforms           darwin
maintainers         nomaintainer
license             LGPL-2.1

description         versatile passive OS fingerprinting, masquerade detection tool

long_description    p0f is a versatile passive OS fingerprinting and \
                    masquerade detection utility, to be used for evidence or \
                    information gathering on servers, firewalls, IDSes, and \
                    honeypots, for pen-testing, or just for the fun of it.

homepage            http://lcamtuf.coredump.cx/p0f3/
master_sites        ${homepage}releases/ \
                    ${homepage}releases/old/${major}.x/
extract.suffix      .tgz

checksums           rmd160  9aee741e742d12c285febb0b1653ab68ebf3271a \
                    sha256  da89a7fe4ba5db3704207f4bde231643bedd4fe8653ab8111c65766c8c768aec

depends_build       port:gmake

depends_lib         port:libpcap

set datadir         ${prefix}/share/${name}

post-patch  {
    reinplace "s|\"p0f.fp\"|\"${datadir}/p0f.fp\"|g" ${worksrcpath}/config.h
}

use_configure       no

variant universal {}

build.args          CC="${configure.cc} [get_canonical_archflags cc]"

post-build {
    # build tools not handled by the build.sh script separately
    system -W ${worksrcpath}/tools "${build.cmd} [join ${build.args}]"
}

destroot {
    xinstall -m 755 -s -W ${worksrcpath} \
        ${name} \
        tools/${name}-client \
        tools/${name}-sendsyn \
        tools/${name}-sendsyn6 \
        ${destroot}${prefix}/bin
    # the manpage is unavailable in version 3.05b, uncomment when provided again
    #xinstall -m 644 ${worksrcpath}/p0f.1 ${destroot}${prefix}/share/man/man1
    xinstall -m 755 -d ${destroot}${datadir} ${destroot}${prefix}/share/doc
    xinstall -m 644 ${worksrcpath}/p0f.fp ${destroot}${datadir}
    copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath}/tools README-TOOLS \
        ${destroot}${prefix}/share/doc/${name}
}

livecheck.regex     ${name}-(\[0-9.\]+b?)${extract.suffix}
livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]