# $Id: Portfile,v 1.4 2005/12/23 13:03:06 mww Exp $
PortSystem		1.0

name			djbdns
version			1.05
categories		net
maintainers		darwinports@opendarwin.org
description		D.J. Bernstein's DNS tools
long_description	DJBDNS is a collection of Domain Name System tools. It \
					includes several components: \
					- The dnscache program is a local DNS cache. It \
					accepts recursive DNS queries from local clients \
					such as web browsers. It collects responses from \
					remote DNS servers. \
					- The tinydns program is a fast, UDP-only DNS \
					server. It makes local DNS information available to \
					the Internet. \
					- The pickdns program is a load-balancing DNS \
					server. It points clients to a dynamic selection of \
					IP addresses. \
					- The walldns program is a reverse DNS wall. It \
					provides matching reverse and forward records while \
					hiding local host information. \
					- The dns library handles outgoing and incoming DNS \
					packets. It can be used by clients such as web \
					browsers to look up host addresses, host names, MX \
					records, etc. It supports asynchronous resolution. \
					- The dnsfilter program is a parallel \
					IP-address-to-host-name converter. \
					- The dnsip, dnsipq, dnsname, dnstxt, and dnsmx \
					programs are simple command-line interfaces to DNS. \
					- The dnsq and dnstrace programs are DNS debugging \
					tools.
homepage		http://cr.yp.to/djbdns/
master_sites	${homepage} \
				http://smarden.org/pape/djb/manpages/:man
distfiles-append	${distname}-man-20031023.tar.gz:man
extract.only	${distname}.tar.gz \
				${distname}-man-20031023.tar.gz
checksums		${distname}.tar.gz md5 3147c5cd56832aa3b41955c7a51cbeb2 \
				${distname}-man-20031023.tar.gz md5 14d7329cff69f604fac607436eb8485e
platforms		darwin

depends_run		bin:setuidgid:daemontools \
				bin:tcpserver:ucspi-tcp

patchfiles		patch-Makefile \
				patch-dnscache-conf.c \
				patch-hier.c

configure {
	reinplace "s%/usr/local%${prefix}%" ${worksrcpath}/conf-home
	reinplace "s%__DESTROOT%${destroot}%" ${worksrcpath}/hier.c
	reinplace "s%__PREFIX%${prefix}%" ${worksrcpath}/hier.c
	reinplace "s%/etc/dnsrewrite%${prefix}&%" ${worksrcpath}/dns_rcrw.c
}

build.target	default

destroot.target	setup check
post-destroot {
	xinstall -d -m 0755 ${destroot}${prefix}/share/man/man1
	foreach man [glob ${workpath}/${name}-man/*.1] {
		xinstall -m 0644 $man ${destroot}${prefix}/share/man/man1
	}
	xinstall -d -m 0755 ${destroot}${prefix}/share/man/man8
	foreach man [glob ${workpath}/${name}-man/*.8] {
		xinstall -m 0644 $man ${destroot}${prefix}/share/man/man8
	}
	xinstall -m 0755 -d ${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 -W ${worksrcpath} CHANGES README TINYDNS TODO \
		${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 -W ${workpath}/${name}-man README \
		${destroot}${prefix}/share/doc/${name}/README_MAN
}

set ipv6_diff			${distname}-test14.diff
variant ipv6 {
	master_sites-append	http://www.fefe.de/dns/:ipv6
	distfiles-append	${ipv6_diff}.bz2:ipv6
	checksums-append	${ipv6_diff}.bz2 md5 52bec93d7ce6226281082367e49157d3
	post-patch {
		ui_info "$UI_PREFIX Applying ${ipv6_diff}"
		system "cd ${worksrcpath} && (bunzip2 -c ${distpath}/${ipv6_diff}.bz2 | patch -p1)"
	}
}

set dumpcache_diff		patch-dnscache-dumpcache-v4.txt
variant dumpcache {
	master_sites-append	http://efge.free.fr/djbdns/:dumpcache
	distfiles-append	${dumpcache_diff}:dumpcache \
						prettycache.pl:dumpcache
	checksums-append	${dumpcache_diff} md5 61441dec12dd627a7fea7c3059cc2542 \
						prettycache.pl md5 6318e8e866c78adf9b411b58f5088fc2
	post-patch {
		if {[variant_isset ipv6]} {
			ui_error "The ipv6 and dumpcache variants currently conflict.\n\
				You can only specify one of them."
			exit 1
		} else {
			ui_info "$UI_PREFIX Applying ${dumpcache_diff}"
			system "cd ${worksrcpath} && patch -p1 < ${distpath}/${dumpcache_diff}"
		}
	}
	post-destroot {
		xinstall -m 0755 ${distpath}/prettycache.pl ${destroot}${prefix}/bin
		reinplace "s%^#!.*/perl%#![binaryInPath perl]%" \
			${destroot}${prefix}/bin/prettycache.pl
	}
}

set ignoreip_diff		${distname}-ignoreip2.patch
variant ignoreip {
	master_sites-append	http://tinydns.org/:ignoreip
	distfiles-append	${ignoreip_diff}:ignoreip
	checksums-append	${ignoreip_diff} md5 c032250b209d055847a763c8d9c7e865
	post-patch {
		ui_info "$UI_PREFIX Applying ${ignoreip_diff}"
		system "cd ${worksrcpath} && patch -p1 < ${distpath}/${ignoreip_diff}"
	}
}

set persistmmap_diff	tinydns-persistmmap-20040418.patch
variant persistmmap {
	master_sites-append	http://people.FreeBSD.org/~roam/ports/patches/dns/:persistmmap
	distfiles-append	${persistmmap_diff}:persistmmap
	checksums-append	${persistmmap_diff} md5 c721977364502180f9563b85cecf133b
	post-patch {
		ui_info "$UI_PREFIX Applying ${persistmmap_diff}"
		system "cd ${worksrcpath} && patch -p1 < ${distpath}/${persistmmap_diff}"
	}
}

