# -*- 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                dibbler
version             1.0.0RC1
categories          net
platforms           darwin
license             GPL-2
maintainers         free.fr:fclaire

installs_libs       no

description         A portable DHCPv6
long_description    Dibbler is a portable DHCPv6 implementation. It \
                    supports stateful (i.e. IPv6 address granting and \
                    IPv6 prefix delegation) as well as stateless (i.e. \
                    option granting) autoconfiguration for IPv6.
homepage            http://klub.com.pl/dhcpv6/

master_sites        http://klub.com.pl/dhcpv6/dibbler/
checksums           rmd160  5f8a70f46e9497b9cceab6cf04a2e05259ab075e \
                    sha256  4d29b5436cd97e5e5c7afb2278ec608bf5adb9c451e9628066f2e943164d3f74

patch.pre_args      -p1
patchfiles          0-enable-prefix.patch \
                    1-correct-man-pages.patch
post-patch {
    reinplace "s|__PREFIX__|${prefix}|g" \
        Misc/Portable.h \
        Port-bsd/lowlevel-bsd.c \
        doc/examples/client.conf \
        doc/examples/server.conf \
        doc/man/dibbler-client.8 \
        doc/man/dibbler-relay.8 \
        doc/man/dibbler-server.8 \
        scripts/notify-scripts/server-notify.sh
}

# TODO: Fix libc++ build.
configure.cxx_stdlib libstdc++

post-destroot {
    xinstall -d -m 0755 ${destroot}${prefix}/share/examples
    move ${destroot}${prefix}/share/doc/dibbler/examples \
        ${destroot}${prefix}/share/examples/${name}

    xinstall -d -m 0755 ${destroot}${prefix}/etc/dibbler
    foreach conf {client.conf relay.conf server.conf} {
        ln -s ../../../share/examples/${name}/${conf} \
            ${destroot}${prefix}/etc/dibbler/${conf}.sample
    }
}
destroot.keepdirs       ${destroot}${prefix}/var/lib/dibbler \
                        ${destroot}${prefix}/var/log/dibbler

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/dibbler-server run

livecheck.type          regex
livecheck.url           ${master_sites}
livecheck.regex         ${name}-(\[\[\:alnum:\].\]+)\\.tar\\.gz

notes "
Before using Dibbler, make copies of the appropriate sample\
configuration files and edit as necessary.

    sudo ditto ${prefix}/etc/${name}/client.conf{.sample,}
    sudo ditto ${prefix}/etc/${name}/server.conf{.sample,}
    sudo ditto ${prefix}/etc/${name}/relay.conf{.sample,}
"