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

PortSystem          1.0
PortGroup           boost 1.0
PortGroup           legacysupport 1.1
PortGroup           openssl 1.0

boost.version       1.76
# fmemopen
legacysupport.newest_darwin_requires_legacy 16

# 5.x are broken by rust: https://github.com/PowerDNS/pdns/issues/16437
# Unless rustc is fixed, stay at this version.
name                pdns-recursor
version             4.9.1
revision            1
categories          net
maintainers         {l2dy @l2dy} openmaintainer
license             {GPL-2 OpenSSLException}

description         High-end, high-performance resolving name server

long_description    The PowerDNS Recursor is a high-end, high-performance \
                    resolving name server which powers the DNS resolution of \
                    at least a hundred million subscribers. Utilizing multiple \
                    processors and supporting the same powerful scripting ability \
                    of the Authoritative Server, the Recursor delivers top performance \
                    while retaining the flexibility modern DNS deployments require.

homepage            https://www.powerdns.com/recursor.html
master_sites        https://downloads.powerdns.com/releases/
use_bzip2           yes

checksums           rmd160  fb9fa2bca8133178ae7c403c6b30b02d0abeabad \
                    sha256  0a1edc13e8f2bd661f39e316387d941e22de6a03b8a7a2fc662fdf8b942ea2be \
                    size    1566613

# https://github.com/PowerDNS/pdns/issues/15956
patchfiles          patch-fix-types.diff

post-patch {
    reinplace "s|PDNS_CHECK_TIME_T||" ${worksrcpath}/configure.ac
}

use_autoreconf      yes

depends_build-append \
                    path:bin/pkg-config:pkgconfig
depends_lib-append  port:lua

compiler.cxx_standard 2017
compiler.thread_local_storage yes

configure.args-append \
                    --disable-silent-rules \
                    --enable-reproducible \
                    --sysconfdir=${prefix}/etc/powerdns \
                    --with-lua=lua \
                    --without-libsodium

post-destroot {
    move ${destroot}${prefix}/etc/powerdns/recursor.conf-dist ${destroot}${prefix}/etc/powerdns/recursor.conf.sample
}

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/pdns_recursor

post-activate {
    if {![file exists ${prefix}/etc/powerdns/recursor.conf]} {
        copy ${prefix}/etc/powerdns/recursor.conf.sample ${prefix}/etc/powerdns/recursor.conf
    }
}

livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
