# $Id: Portfile,v 1.15 2005/06/12 20:20:26 jberry Exp $

PortSystem 1.0

name				bind9
version				9.3.1
revision			1

categories			net
maintainers			bchesneau@mac.com jberry@opendarwin.org
platforms			darwin freebsd sunos

description			Domain Name System server
long_description  	The BIND DNS Server is used on the vast majority of name \
					serving machines on the Internet, providing a robust \
					and stable \
					architecture on top of which an organization's naming architecture \
					can be built.  The resolver library included in the BIND distribution \
					provides the standard APIs for translation between domain names \
					and Internet addresses and is intended to be linked with applications \
					requiring name service.
homepage			http://www.isc.org

distname			bind-${version}
master_sites		isc:${portname}/${version}
checksums			md5 9ff3204eea27184ea0722f37e43fc95d

configure.args		--mandir=${prefix}/share/man --enable-libbind

post-patch {
	# Put bind includes in ${prefix}/include/bind
	reinplace "s|/bind/include|/include/bind|" \
		${worksrcpath}/lib/bind/configure
	# Put bind libs in ${prefix}/lib/bind
	reinplace "s|/bind/lib|/lib/bind|" \
		${worksrcpath}/lib/bind/configure
}

post-destroot	{
	# Ensure needed directories
	xinstall -m 755 -d \
		${destroot}${prefix}/etc/rc.d \
		${destroot}${prefix}/var/named \
		${destroot}${prefix}/var/run
	
	# Install the startup script
	xinstall -o root -m 755 ${filespath}/bind.sh \
		${destroot}${prefix}/etc/rc.d
	reinplace "s|%%PREFIX%%|${prefix}|g" \
		${destroot}${prefix}/etc/rc.d/bind.sh

	# Install the conf file as a sample
	xinstall -o root -m 644 ${filespath}/named.conf \
		${destroot}${prefix}/etc/named.conf.dist
	reinplace "s|%%PREFIX%%|${prefix}|g" \
		${destroot}${prefix}/etc/named.conf.dist
	
	# Install the db files as samples
	foreach f "db.127.0.0.1 db.cache db.localhost" {
		xinstall -o root -m 644 ${filespath}/${f} \
			${destroot}${prefix}/var/named/${f}.dist
	}

	destroot.keepdirs ${destroot}${prefix}/var/run
}

platform darwin 6 { depends_lib-append lib:libdl:dlcompat }

variant darwin {
	depends_run-append	path:/Library/StartupItems/DarwinPortsStartup:DarwinPortsStartup
}

variant ipv6 {
	configure.args-append 	--enable-ipv6
}

variant ssl {
	depends_lib-append      lib:libssl.0.9:openssl
	configure.args-append	--with-openssl
}

variant threads {
	configure.args-append	--enable-threads
}