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

# clock_gettime
legacysupport.newest_darwin_requires_legacy 10

github.setup        BelledonneCommunications bctoolbox 5.4.66
revision            0

categories          devel multimedia
license             GPL-3
maintainers         nomaintainer

description         Library written in C that allows you to create and run audio and video streams.
long_description    {*}${description}. Utilities library used by Belledonne Communications software \
                    like belle-sip, mediastreamer2 and liblinphone.

checksums           rmd160  ca72f8a76ba829ecaaa7c52b42c6fe643efd405e \
                    sha256  08f27003e14fd39c0bc45e212b676972eca73498a363a6b76aa67e60d442401a \
                    size    211674
github.tarball_from archive

depends_build-append \
                    port:bcunit
depends_lib         port:libiconv

patchfiles          patch-fix-Frameworks-path.diff

# https://github.com/BelledonneCommunications/bctoolbox/pull/26
patchfiles-append   0001-ios_utils.hh-add-a-missing-memory-include.patch \
                    0002-port.c-define-AI_NUMERICSERV-if-undefined.patch \
                    0003-BcToolboxCMakeUtils.cmake-fix-flags-for-Apple.patch

if {${os.platform} eq "darwin" && ${os.major} <= 10} {
    # Nothing in fact links to AVFoundation, it can just be dropped.
    patchfiles-append \
                    patch-fix-10.6.diff
}

compiler.cxx_standard \
                    2017

# FIXME: build with mbedtls3 is broken:
# https://github.com/BelledonneCommunications/bctoolbox/issues/19
# Build with -Werror fails against OpenSSL:
# https://github.com/BelledonneCommunications/bctoolbox/issues/31
configure.args-append \
                    -DENABLE_DECAF=YES \
                    -DENABLE_MBEDTLS=NO \
                    -DENABLE_OPENSSL=YES \
                    -DENABLE_STRICT=NO \
                    -DENABLE_TESTS_COMPONENT=NO

# This workaround is needed for "ortp" to work correctly. Ideally,
# BelledonneCommunications projects need a less hardcoded way to locate
# frameworks libs.
post-destroot {
    ln -s ${frameworks_dir}/bctoolbox.framework \
        ${destroot}${prefix}/lib/bctoolbox.framework
}

github.livecheck.regex  {([0-9.]+)}
