# $Id$
PortSystem      1.0

name                    sancp
version                 1.6.1
categories              security
maintainers             nomaintainer
description             Security Analyst Network Connection Profiler
long_description        This is a network security tool designed to collect \
			statistical information regarding network traffic, \
			as well as, collect the traffic itself in pcap \
			format, all for the purpose of: auditing, historical \
			analysis, and network activity discovery.
homepage                http://www.metre.net/sancp.html
platforms               darwin
master_sites            sourceforge
checksums               ${distname}${extract.suffix} md5 b83e2f4abb2bf7b10fd874aa58f6324c \
			sancp-1.6.1.fix200511.a.patch md5 7b357ec3371fc399c7589261f0d8d11b \
			sancp-1.6.1.fix200511.b.patch md5 747aa31c477d726ce6a9b233e3e5f4ee

patch_sites		http://sancp.sourceforge.net
patchfiles		sancp-1.6.1.fix200511.a.patch \
			sancp-1.6.1.fix200511.b.patch
patch.pre_args		-p1

depends_build		port:libpcap

use_configure		no

build.env		CPPFLAGS=-I${prefix}/include \
			CFLAGS="-O3 -s -I${prefix}/include" \
			LDFLAGS=-L${prefix}/lib

post-patch {
# Hack to comment out CFLAGS line in Makefile
	reinplace "s|CFLAGS	=  -O3|#CFLAGS	=  -O3|g" \
		${worksrcpath}/Makefile
}

build.target		""

destroot {}

post-destroot {
	xinstall -m 755 -d ${destroot}${prefix}/bin
	xinstall -m 755 ${worksrcpath}/sancp ${destroot}${prefix}/bin
	xinstall -m 755 ${worksrcpath}/etc/sancp/sancp.conf ${destroot}${prefix}/etc/sancp.conf.sample

	xinstall -m 755 -d ${destroot}${prefix}/share/doc/sancp
	xinstall ${worksrcpath}/LICENSE ${destroot}${prefix}/share/doc/sancp
	foreach doc [glob ${worksrcpath}/docs/*] {
	xinstall ${doc} ${destroot}${prefix}/share/doc/sancp
	}
	xinstall -m 755 -d ${destroot}${prefix}/var/log/sancp
	destroot.keepdirs ${destroot}${prefix}/var/log/sancp

# Install startup script
	xinstall -m 755 -d ${destroot}${prefix}/share/sancp
	xinstall -m 755 ${portpath}/${filesdir}/sancp.init ${destroot}${prefix}/share/sancp
	reinplace "s|__PREFIX__|${prefix}|g" \
		${destroot}${prefix}/share/sancp/sancp.init
}

# Create a startupitem to start/stop the server
    startupitem.create    yes
    startupitem.start    "${prefix}/share/sancp/sancp.init"
    startupitem.stop     "killall -c sancp"

post-activate {

ui_msg "\n
Rename and configure the sample sancp.conf file in ${prefix}/etc.  If
you want to sniff an interface other than en0, edit the startup script
${prefix}/share/sancp/sancp.init.

\n"
}