# -*- 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           cmake 1.1
PortGroup           boost 1.0
PortGroup           legacysupport 1.1

# On macOS <10.13 built-in libc++ has no support for std::variant
legacysupport.newest_darwin_requires_legacy 16
legacysupport.use_mp_libcxx yes

name                znc
version             1.9.1
revision            3
categories          irc
maintainers         nomaintainer
license             Apache-2
description         An advanced IRC bouncer
long_description    ZNC is an IRC bounce/proxy with many advanced features \
                    like detaching, multiple users, multiple clients per \
                    user, channel/query playback buffers, SSL, IPv6, \
                    transparent DCC bouncing, C++/Perl/Tcl module support, \
                    party line, and Web administration.

homepage            https://znc.in/
master_sites        ${homepage}releases/archive/

checksums           rmd160  7db73779a80d464da0f78885cd50419b3c3dcaa0 \
                    sha256  e8a7cf80e19aad510b4e282eaf61b56bc30df88ea2e0f64fadcdd303c4894f3c \
                    size    2236498

universal_variant   no

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

depends_lib-append  path:lib/libssl.dylib:openssl \
                    port:tcl \
                    port:perl5 \
                    port:cyrus-sasl2 \
                    port:argon2 \
                    path:lib/pkgconfig/icu-uc.pc:icu

configure.args-append \
                        -DWANT_PERL=true \
                        -DWANT_PYTHON=false \
                        -DWANT_TCL=true

# Translation.h:22:10: fatal error: 'variant'
# file not found on macOS <10.14
compiler.cxx_standard   2017
compiler.blacklist-append \
                    {clang < 1001}
if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
    configure.ldflags-append -stdlib=${configure.cxx_stdlib}
}

set python_versions {310 311 312 313}

# declare all +python* variants, with conflicts
foreach pyver ${python_versions} {
    # Conflicting python versions
    set other_python_versions {}
    foreach other_pyver ${python_versions} {
        if {${other_pyver} ne ${pyver}} {
            if {${other_pyver} ni ${other_python_versions}} {
                lappend other_python_versions python${other_pyver}
            }
        }
    }

    set python_branch "[string index ${pyver} 0].[string range ${pyver} 1 end]"

    variant python${pyver} conflicts {*}${other_python_versions} description "Enable Python modules, using ${python_branch}" {
        configure.args-replace -DWANT_PYTHON=false -DWANT_PYTHON=true
        depends_lib-append port:python${pyver}
        configure.pkg_config_path ${frameworks_dir}/Python.framework/Versions/${python_branch}/lib/pkgconfig/
    }
}

# Fails regardless due to gtest
test.run            no

livecheck.type      regex
livecheck.url       ${homepage}releases/
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
