--- Portfile.orig	2012-06-15 04:30:31.000000000 +0200
+++ Portfile	2012-06-17 14:01:52.000000000 +0200
@@ -1,48 +1,67 @@
+# -*- 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 94315 2012-06-15 02:24:31Z ryandesign@macports.org $
 
-PortSystem 1.0
+PortSystem       1.0
 
-name		  p0f
-version		  2.0.8
-categories	  net security
-platforms	  darwin
-maintainers	  nomaintainer
-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/p0f.shtml
-master_sites	  http://lcamtuf.coredump.cx/p0f/
-extract.suffix	  .tgz
-checksums	  sha1 7b4d5b2f24af4b5a299979134bc7f6d7b1eaf875 \
-		  rmd160 87d5b30d2d5e156b9fdcb026160155f413ce13d3
+name             p0f
+version          3.05b
+categories       net security
+platforms        darwin
+license          GNU LGPLv2.1
+maintainers      nomaintainer
+description      versatile passive OS fingerprinting, masquerade detection tool
 
-depends_build	  port:gmake
+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.
 
-worksrcdir	  ${name}
-patchfiles	  p0f.c.patch p0fq.c.patch
+homepage         http://lcamtuf.coredump.cx/p0f3/
+master_sites     http://lcamtuf.coredump.cx/p0f3/releases/
 
-post-patch	{
-	reinplace "s|/etc/p0f|${prefix}/share/p0f|g" ${worksrcpath}/config.h
+extract.suffix   .tgz
+
+checksums        sha1    e6f39c3811e681272e772f33588aa46b75975708 \
+                 rmd160  9cafc9668bee3e358f1f1775210cc9855e6a2946
+
+depends_build    port:gmake
+
+worksrcdir       ${distname}
+
+post-patch {
+    reinplace "s|\"p0f.fp\"|\"${prefix}/share/${name}/p0f.fp\"|g" \
+        ${worksrcpath}/config.h
 }
 
-use_configure	no
+use_configure    no
+
+build.args       CC=${configure.cc}
 
-build.args	CC=${configure.cc}
+post-build {
+    # build tools not handled by the build.sh script separately
+    system "cd ${worksrcpath}/tools && make"
+}
 
-destroot	{
-	xinstall -m 755 -s ${worksrcpath}/p0f ${destroot}${prefix}/bin
-	xinstall -m 644 ${worksrcpath}/p0f.1 ${destroot}${prefix}/share/man/man1
-	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name} \
-		${destroot}${prefix}/share/${name}
-	xinstall -m 644 -W ${worksrcpath} p0f.fp p0fa.fp p0fr.fp p0fo.fp \
-		${destroot}${prefix}/share/${name}
-	xinstall -m 644 -W ${worksrcpath}/doc COPYING CREDITS ChangeLog KNOWN_BUGS \
-		README TODO ${destroot}${prefix}/share/doc/${name}
+destroot {
+    xinstall -m 755 -s ${worksrcpath}/${name} ${destroot}${prefix}/bin
+    xinstall -m 755 -s ${worksrcpath}/tools/${name}-client \
+        ${destroot}${prefix}/bin
+    xinstall -m 755 -s ${worksrcpath}/tools/${name}-sendsyn \
+        ${destroot}${prefix}/bin
+    xinstall -m 755 -s ${worksrcpath}/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}${prefix}/share/doc/${name} \
+        ${destroot}${prefix}/share/${name}
+    xinstall -m 644 -W ${worksrcpath} p0f.fp ${destroot}${prefix}/share/${name}
+    xinstall -m 644 -W ${worksrcpath}/docs COPYING ChangeLog README TODO \
+        existential-notes.txt extra-sigs.txt \
+        ${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   http://lcamtuf.coredump.cx/p0f3/releases/
+livecheck.url   [lindex ${master_sites} 0]
