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

name                libre
categories          net
platforms           darwin
maintainers         {db.org:aeh @alfredh}
license             BSD
description         Protocol library for real-time communications with async \
                    I/O support
long_description    ${name} is a ${description}.

github.setup        baresip re 2.0.1 v
checksums           rmd160  4f23053dd00938f9df6ffc91b08b54e3230f2872 \
                    sha256  2fadb30911d09cd7f8a3faee0672f3d03c16de9d7dcafeabd8dce41133563da0 \
                    size    342954
revision            1

depends_lib \
    port:zlib \
    path:lib/libssl.dylib:openssl

use_configure       no

build.args \
    CCACHE= \
    RELEASE=1 \
    PREFIX=${prefix} \
    SYSROOT="${configure.sdkroot}/usr" \
    SYSROOT_ALT=${prefix}

destroot.args \
    ${build.args}

if {[tbool configure.ccache]} {
    build.env-append CCACHE=ccache
}

if {![info exists universal_possible]} {
    set universal_possible [expr {${os.universal_supported} && [llength ${configure.universal_archs}] >= 2}]
}
if {${universal_possible} && [variant_isset universal]} {
    foreach arch ${configure.universal_archs} {
        lappend merger_build_env(${arch})    "CC=${configure.cc} -arch ${arch}"
        lappend merger_destroot_env(${arch}) "CC=${configure.cc} -arch ${arch}"
    }
} else {
    build.env-append    "CC=${configure.cc} ${configure.cc_archflags}"
    destroot.env-append "CC=${configure.cc} ${configure.cc_archflags}"
}

post-destroot {
    system "install_name_tool -id ${prefix}/lib/libre.dylib ${destroot}${prefix}/lib/libre.dylib"
}
