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

name                stunnel
version             5.74
revision            0
set major           [lindex [split ${version} .] 0]
categories          security net
maintainers         {mps @Schamschula} openmaintainer
license             GPL-2+

description         SSL tunneling program

long_description    Stunnel is a program that allows you to encrypt arbitrary \
                    TCP connections inside SSL (Secure Sockets Layer) available \
                    on both Unix and Windows. Stunnel can allow you to secure \
                    non-SSL aware daemons and protocols (like POP, IMAP, LDAP, \
                    etc) by having Stunnel provide the encryption, requiring no \
                    changes to the daemon's code.

homepage            http://www.stunnel.org/
master_sites        https://www.stunnel.org/downloads/archive/${major}.x/ \
                    http://www.usenix.org.uk/mirrors/stunnel/archive/${major}.x/ \
                    http://ftp.nluug.nl/pub/networking/stunnel/archive/${major}.x/ \
                    http://stunnel.cybermirror.org/archive/${major}.x/

checksums           rmd160  e5e5c8430de2865960e280e9c5ea99f029c6afa1 \
                    sha256  9bef235ab5d24a2a8dff6485dfd782ed235f4407e9bc8716deb383fc80cd6230 \
                    size    904360

openssl.branch      no_version

patchfiles          patch-configure \
                    patch-src-client.c.diff

configure.args      --disable-libwrap \
                    --disable-silent-rules \
                    ac_cv_search_mi_malloc=no

variant openssl1 conflicts openssl3 description (Use openssl 1.1.1) {
    openssl.branch  1.1
    configure.args-append \
                    --with-ssl=[openssl::install_area]
}

variant openssl3 conflicts openssl1 description (Use openssl 3) {
    openssl.branch  3
    configure.args-append \
                    --with-ssl=[openssl::install_area]
}

default_variants    +openssl3

# libwrap has been reported to introduce some problems with stunnel 4.18.
# See: https://trac.macports.org/ticket/11028
variant libwrap description {Include libwrap support} {
    depends_lib-append      port:tcp_wrappers
    configure.args-delete   --disable-libwrap
}

variant mimalloc description {Build with mimalloc support} {
    depends_lib-append      port:mimalloc
    configure.args-delete   ac_cv_search_mi_malloc=no
}

if {${os.arch} ne "powerpc"} {
    default_variants-append  \
                    +libwrap
}

livecheck.type      regex
livecheck.url       ${homepage}downloads.html
livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}