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

name                openconnect
version             9.21
revision            0
categories          net
maintainers         nomaintainer
license             LGPL-2.1

description         OpenConnect is a client for Cisco's AnyConnect SSL VPN
long_description    {*}${description}, which is supported by the ASA5500 Series, \
                    by IOS 12.4(9)T or later on Cisco SR500, 870, 880, 1800, \
                    2800, 3800, 7200 Series and Cisco 7301 Routers, and \
                    probably others.

homepage            http://www.infradead.org/openconnect/

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

depends_lib         port:gettext-runtime \
                    port:libiconv \
                    port:libxml2 \
                    port:lz4 \
                    port:p11-kit \
                    port:vpnc-scripts \
                    port:zlib

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    set py_v        3.12
    set py_v_nodot  [string map {. {}} ${py_v}]
    depends_build-append \
                    port:python${py_v_nodot}
    configure.python \
                    ${prefix}/bin/python${py_v}
}

master_sites        https://www.infradead.org/openconnect/download/ \
                    ftp://ftp.infradead.org/pub/openconnect/

checksums           rmd160  33cc40a9f43559dd4b189ad4418cdfc98ea2423c \
                    sha256  5b32369467db6e5f317aa1ed12cfcbb81ed00bdbc765450b6bfcbdc300944a58 \
                    size    3079316

patchfiles          TARGET_OS.patch

configure.args      --disable-silent-rules \
                    --with-vpnc-script=${prefix}/etc/vpnc-scripts/vpnc-script \
                    --without-gnutls \
                    --without-gssapi \
                    --without-libpcsclite \
                    --without-libproxy \
                    --without-libpskc \
                    --without-openssl \
                    --without-stoken

variant ssl conflicts gnutls description {Allow secure connections using OpenSSL} {
    depends_lib-append      path:lib/libssl.dylib:openssl
    configure.args-replace  --without-openssl --with-openssl
}

variant gnutls conflicts ssl description {Allow secure connections using GNUTLS} {
    depends_lib-append      path:lib/pkgconfig/gnutls.pc:gnutls
    configure.args-replace  --without-gnutls --with-gnutls
}

variant kerberos description {Enable Kerberos support} {
    depends_lib-append      port:kerberos5
    configure.args-replace  --without-gssapi --with-gssapi
}

variant libproxy description {Enable libproxy automatic proxy configuration management} {
    depends_lib-append      port:libproxy
    configure.args-replace  --without-libproxy --with-libproxy
}

variant libpskc description {Allow RFC6030 PSKC file storage of HOTP/TOTP keys} {
    depends_lib-append      port:oath-toolkit
    configure.args-replace  --without-libpskc --with-libpskc
}

# Since Openconnect 5.00, GnuTLS is the default instead of OpenSSL
if {![variant_isset ssl]} {
    default_variants +gnutls
}

post-destroot {
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS \
        COPYING.LGPL \
        TODO \
        ${docdir}
}

livecheck.url       ftp://ftp.infradead.org/pub/openconnect/
livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}

test.run            yes
test.cmd            make
test.target         check
