# -*- 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                p0f
version             3.09b
set major           [lindex [split ${version} .] 0]
categories          net security
maintainers         {grimreaper @grimreaper}
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            https://lcamtuf.coredump.cx/p0f3/
master_sites        ${homepage}/releases/
extract.suffix      .tgz

checksums           rmd160  802ec272b5447a6a551de4fe191b409e79612cc6 \
                    sha256  543b68638e739be5c3e818c3958c3b124ac0ccb8be62ba274b4241dbdec00e7f \
                    size    92896

depends_lib         port:libpcap

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

patchfiles          build.sh.patch \
                    tools_Makefile.patch

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

use_configure       no

variant universal {}

build.env          CC=${configure.cc} \
                   CFLAGS=[get_canonical_archflags cc] \
                   "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]" \
                   MAKE=${build.cmd}

destroot {
    xinstall -m 0755 -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 0755 -d ${destroot}${datadir} ${destroot}${prefix}/share/doc
    xinstall -m 0644 ${worksrcpath}/p0f.fp ${destroot}${datadir}
    copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 -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]
