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

# CLOCK_MONOTONIC
legacysupport.newest_darwin_requires_legacy 15

github.setup        Mbed-TLS mbedtls 3.6.7 mbedtls-
name                mbedtls3
revision            0

conflicts           hello mbedtls mbedtls4

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}
platforms           darwin

homepage            https://tls.mbed.org
github.tarball_from releases
# https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.1/mbedtls-3.6.1.tar.bz2

use_bzip2           yes

checksums           rmd160  6fb10c49f67b5708c794cceaacb351a70a811324 \
                    sha256  a7e8bcbec0e6f761b4af24f25677626b35f762f68eef79c08677a363212d11f6 \
                    size    5473689

set python.version  314
set python.branch   "[string index ${python.version} 0].[string range ${python.version} 1 end]"

depends_build-append \
                    port:perl5 \
                    port:python${python.version} \
                    port:py${python.version}-jsonschema

patchfiles          patch-CMakeLists.txt.diff

# 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=OFF \
                    -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
}

#test currently broken (can't find exisiting file path)
#test.run            yes

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