# -*- 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           github 1.0
PortGroup           compiler_blacklist_versions 1.0

github.setup        ARMmbed mbedtls 2.28.4 mbedtls-
revision            0

conflicts           mbedtls3

categories          devel
license             Apache-2
maintainers         {mps @Schamschula} openmaintainer
description         An open source, portable, easy to use, readable and flexible SSL \
                    library.
long_description    {*}${description}

homepage            https://tls.mbed.org
github.tarball_from archive

checksums           rmd160  8752e12b97a626bf506ef051d9922a33e3c8f884 \
                    sha256  504bd29af6e7f9f3de1f0f7b7e16c73987a4194338681acd72b82383a49d55d5 \
                    size    3993515

variant python38 conflicts python39 python310 python311 description {Use Python 3.8} {}
variant python39 conflicts python38 python310 python311 description {Use Python 3.9} {}
variant python310 conflicts python38 python39 python311 description {Use Python 3.10} {}
variant python311 conflicts python38 python39 python310 description {Use Python 3.11} {}

if {![variant_isset python38] && ![variant_isset python39] && ![variant_isset python310]} {
    default_variants +python311
}

foreach pv {311 310 39 38} {
    if {[variant_isset python${pv}]} {
        set python.branch "[string index ${pv} 0].[string range ${pv} 1 end]"
        depends_build-append \
                    port:python${pv}
        break
    }
}

depends_build-append \
                    port:perl5

# library/bignum.c:1435:9: error: cannot compile this unexpected cast lvalue yet
# For related discussion see https://trac.macports.org/ticket/62185
compiler.blacklist-append {clang < 900}

configure.args-append \
                    -DENABLE_TESTING=ON \
                    -DPERL_EXECUTABLE=${prefix}/bin/perl \
                    -DMBEDTLS_PYTHON_EXECUTABLE:FILEPATH=${prefix}/bin/python${python.branch} \
                    -DUSE_SHARED_MBEDTLS_LIBRARY=ON \
                    -DMBEDTLS_FATAL_WARNINGS=OFF

# error: /usr/bin/ranlib: unknown option character `n' in: -no_warning_for_no_symbols
# see: https://trac.macports.org/ticket/60762
if {${os.platform} eq "darwin" && ${os.major} < 13} {
    depends_build-append \
                    port:cctools
    configure.args-append \
                    -DCMAKE_RANLIB=${prefix}/bin/ranlib
}

# platform_builtin_keys.c: error: ‘for’ loop initial declaration used outside C99 mode
configure.cflags-append \
                    -std=c99

test.run            yes

github.livecheck.regex  {(2\.\d+(\.\d+)?(?!a))}
