# -*- 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$

PortSystem          1.0

name                ldns
subport             ldns-tools {}
subport             drill {}

version             1.6.17
categories          net devel
platforms           darwin
license             BSD
maintainers         nomaintainer

switch ${subport} {
"ldns" {
    description         DNS library in C
    long_description    ldns is a library with the aim of simplifying DNS \
                        programming in C. It is heavily based upon the Net::DNS module from \
                        Perl.
}
"ldns-tools" {
    description         Tools for working with dns and dnssec.
    long_description    Tools as examples to the ldns library. \
                        Useful for debugging/querying dns/dnssec servers.
}
"drill" {
    description         A dig-style dnssec-aware dns debugging tool
    long_description    Drill is a tool ala dig from BIND. \
                        It was designed with DNSSEC in mind and should be a useful \
                        debugging/query tool for DNSSEC.
}
}

homepage            http://www.nlnetlabs.nl/projects/ldns/
master_sites        http://www.nlnetlabs.nl/downloads/ldns/

checksums           rmd160  5382cfaafa7ec1fadcf390f804fbf14e04d7c03a \
                    sha256  8b88e059452118e8949a2752a55ce59bc71fa5bc414103e17f5b6b06f9bcc8cd

depends_build       bin:glibtool:libtool
depends_lib         path:lib/libssl.dylib:openssl

if {${subport} eq "ldns-tools"} {
    depends_lib-append  port:ldns \
                        port:libpcap
}
if {${subport} eq "drill"} {
    depends_lib-append  port:ldns
}

if {${subport} eq "ldns-tools"} {
    worksrcdir          ldns-${version}/examples
}
if {${subport} eq "drill"} {
    worksrcdir          ldns-${version}/drill
}
if {${subport} eq "ldns"} {
    configure.args      --mandir=${prefix}/share/man --with-ssl=${prefix}
} else {
    configure.args      --mandir=${prefix}/share/man --with-ldns=${prefix} --with-ssl=${prefix}
}
if {${subport} eq "ldns"} {
    configure.cppflags  -I${worksrcpath}/include
}
if {${subport} ne "drill"} {
    build.type          gnu
}

if {${subport} eq "ldns"} {
    pre-destroot {
        reinplace "s,defined(@\$also),@\$also," ${worksrcpath}/doc/doxyparse.pl
    }

    post-destroot {
        # Install pkg-config files not installed by the Makefile
        reinplace "s/-arch \[^ \]*//g" ${worksrcpath}/packaging/libldns.pc
        file mkdir ${destroot}${prefix}/lib/pkgconfig/
        file copy ${worksrcpath}/packaging/libldns.pc \
            ${destroot}${prefix}/lib/pkgconfig/libldns.pc
    }
}

livecheck.type      regex
livecheck.url       http://www.nlnetlabs.nl/projects/ldns/
livecheck.regex     "The latest release is (\\d+(?:\\.\\d+)*)"