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

name                rubberband
version             3.3.0
revision            0
checksums           rmd160  f66b37145a8adc7291cc12da9de62718b658851b \
                    sha256  d9ef89e2b8ef9f85b13ac3c2faec30e20acf2c9f3a9c8c45ce637f2bc95e576c \
                    size    223408

categories          audio
maintainers         {ryandesign @ryandesign} openmaintainer
license             GPL-2+

description         audio time-stretching and pitch-shifting library and utility program

long_description    Rubber Band is a library and utility program that permits \
                    changing the tempo and pitch of an audio recording \
                    independently of one another.

homepage            https://breakfastquay.com/rubberband/
master_sites        https://breakfastquay.com/files/releases/
use_bzip2           yes

depends_build-append \
                    port:cctools \
                    port:pkgconfig

depends_lib-append  port:libsamplerate \
                    port:libsndfile

patchfiles          arch.patch

# /usr/bin/../lib/c++/v1/atomic:535:2: error: <atomic> is not implemented
# https://hg.sr.ht/~breakfastquay/rubberband/rev/812a666b042abf0e41465bee9924c7ffc8532bbf
compiler.cxx_standard 2014

configure.args      -Dauto_features=disabled \
                    -Dcmdline=enabled \
                    -Dfft=builtin \
                    -Dresampler=libsamplerate

if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
    configure.ldflags-append -stdlib=${configure.cxx_stdlib}
}

if {[string match *gcc* ${configure.compiler}]} {
    # ___atomic_is_lock_free, ___atomic_load_8, ___atomic_store_8
    # https://todo.sr.ht/~breakfastquay/rubberband/28
    configure.ldflags-append -latomic
}

post-destroot {
    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        CHANGELOG \
        COPYING \
        README.md \
        ${destroot}${docdir}
}

platform darwin {
    configure.args-replace -Dfft=builtin -Dfft=vdsp

    # meson.build sets -mmacosx-version-min to a value we didn't ask for
    # unless we set it ourselves.
    configure.cxxflags-append -mmacosx-version-min=${macosx_deployment_target}
}

livecheck.type      regex
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
