# $Id: Portfile 30856 2007-11-08 16:21:58Z jberry@macports.org $
PortSystem		1.0

name			junkbuster
version			2.0.2p1.1
revision		1
categories		net www
platforms		darwin
maintainers		nomaintainer
description		Internet Junkbuster Proxy with zlib compression support
long_description	This is a port of The Internet Junkbuster Proxy(TM). \
					An excelent way to enhance your privacy while \
					browsing the web.  And it also happens to do a great \
					job of filtering out all those annoying banner ads! \
					This modified version allows one to specify \
					appearance of blocked GIFs.  It can automatically \
					compress text/html and text/plain documents for \
					clients which support Accept-Encoding: gzip (e.g. \
					Netscape 4.7, Internet Explorer 5, Lynx 2.8.3) to \
					save downstream modem/network bandwidth.  It uses \
					the zlib compression library to perform on-the-fly \
					compression of HTML documents.
homepage		http://f2.org/products/ijb-zlib/ \
				http://internet.junkbuster.com/
master_sites	http://f2.org/download/
distname		ijb-zlib-11
extract.suffix	.tgz
checksums		md5 891f4a1a475b24b35b33baefd51dac2c
depends_lib		port:zlib \
				port:gnuregex

startupitem.create     yes
startupitem.name       junkbuster
startupitem.executable ${prefix}/sbin/junkbuster


pre-patch {
	foreach  file [glob ${worksrcpath}/*.ini] { reinplace "s%\r%%g" $file }
}
patchfiles		patch-Makefile \
				patch-acl.c \
				patch-bind.c \
				patch-conn.c \
				patch-encode.c \
				patch-filters.c \
				patch-jcc.c \
				patch-jcc.h \
				patch-junkbstr.ini \
				patch-junkbuster.1 \
				patch-loaders.c \
				patch-loaders.h \
				patch-parsers.c \
				patch-socks4.c \
				patch-ssplit.c \
				patch-win32.c
post-patch {
	reinplace "s%__PREFIX%${prefix}%g" ${worksrcpath}/junkbstr.ini
}

use_configure	no

build.args		PREFIX=${prefix}

destroot.keepdirs	${destroot}${prefix}/var/log \
					${destroot}${prefix}/var/run/junkbuster
destroot {
	xinstall -m 0755 ${worksrcpath}/junkbuster ${destroot}${prefix}/sbin
	
	xinstall -m 0755 ${worksrcpath}/junkbuster.1 ${destroot}${prefix}/share/man/man1
	
	set etcpath ${destroot}${prefix}/etc/junkbuster
	xinstall -d -m 0755 ${etcpath}
	xinstall -m 0644 ${worksrcpath}/junkbstr.ini ${etcpath}/configfile.sample
	xinstall -m 0644 ${worksrcpath}/sblock.ini ${etcpath}/blockfile.sample
	xinstall -m 0644 ${worksrcpath}/saclfile.ini ${etcpath}/aclfile.sample
	xinstall -m 0644 ${worksrcpath}/scookie.ini ${etcpath}/cookiefile.sample
	xinstall -m 0644 ${worksrcpath}/sforward.ini ${etcpath}/forwardfile.sample
	xinstall -m 0644 ${worksrcpath}/strust.ini ${etcpath}/trustfile.sample
	
	set rcddir ${destroot}${prefix}/etc/rc.d
	xinstall -d -m 0755 ${rcddir}
	xinstall -m 0755 ${filespath}/junkbuster.sh.in ${rcddir}/junkbuster.sh
	
	set docdir ${destroot}${prefix}/share/doc/junkbuster
	xinstall -d -m 0755 ${docdir}
	xinstall -m 0644 README gpl.html ijbman.html ijbfaq.html ${docdir}
	foreach blockfile [glob ${filespath}/blockfile.*] {
		xinstall -m 0644 ${blockfile} ${docdir}
	}
	
#	reinplace "s%__PREFIX%${prefix}%g" \
#		${rcddir}/junkbuster.sh \
#		${etcdir}/configfile.sample
	
	xinstall -o nobody -g nobody -d -m 0755 \
		${destroot}${prefix}/var/run/junkbuster
}

post-activate {
	# Make sure initial log file is present
	if ![file exists ${prefix}/var/log/junkbuster.log] {
		xinstall -m 0644 -o nobody -g nobody /dev/null \
			${prefix}/var/log/junkbuster.log
	}
	# Make sure initial config files are present
	foreach conf {configfile blockfile cookiefile} {
		if ![file exists ${prefix}/etc/junkbuster/${conf}] {
			xinstall -m 0644 ${prefix}/etc/junkbuster/${conf}.sample \
				${prefix}/etc/junkbuster/${conf}
		}
	}
}

platform darwin 8 powerpc {
	post-patch { reinplace "s|^CC.*|CC=/usr/bin/gcc-3.3|g" ${worksrcpath}/Makefile }
}

platform darwin 8 i386 {
	depends_build-append port:apple-gcc33
	post-patch { reinplace "s|^CC.*|CC=${prefix}/bin/gcc-apple-3.3|g" ${worksrcpath}/Makefile }
}

platform darwin 9 powerpc {
	post-patch { reinplace "s|^CC.*|CC=/usr/bin/gcc-3.3|g" ${worksrcpath}/Makefile }
}

platform darwin 9 i386 {
	depends_build-append port:apple-gcc33
	post-patch { reinplace "s|^CC.*|CC=${prefix}/bin/gcc-apple-3.3|g" ${worksrcpath}/Makefile }
}

