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

github.setup        BelledonneCommunications bctoolbox 5.2.16
github.tarball_from archive
revision            0

categories          devel multimedia
license             GPL-3
maintainers         nomaintainer

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

checksums           rmd160 bbd9a9dd4318820299d5fec1b7819c2483745940 \
                    sha256 1869d04fadaa20c8f07d6781dfbd65aef01812fd681eb2961f7f0300f699031f \
                    size 194676

depends_build-append \
                    port:bcunit
depends_lib         port:libiconv \
                    port:mbedtls

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 \
                    2011

configure.args-append \
                    -DENABLE_SHARED=YES \
                    -DENABLE_STATIC=NO \
                    -DENABLE_TESTS=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.]+)}
