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

# configure script checks endianness.
PortGroup           muniversal 1.0

github.setup        thestk stk 5.0.1
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
checksums           rmd160  7e42221365e6dc9f71feb0e7fbce88ae5a670068 \
                    sha256  afc35faea3bb8baacacb8d9db3fa745e4f7d8dd46f36aac5436ca377d565a184 \
                    size    2786068

categories          audio
maintainers         {ryandesign @ryandesign} openmaintainer
license             MIT

description         open source audio signal processing and algorithmic \
                    synthesis classes

long_description    The Synthesis ToolKit in C++ (STK) is a set of open source \
                    audio signal processing and algorithmic synthesis classes \
                    written in the C++ programming language. \
                    STK was designed to facilitate rapid development of music \
                    synthesis and audio processing software, with an emphasis \
                    on cross-platform functionality, realtime control, ease of \
                    use, and educational example code. \
                    The Synthesis ToolKit is extremely portable (it's mostly \
                    platform-independent C and C++ code), and it's completely \
                    user-extensible (all source included, no unusual \
                    libraries, and no hidden drivers). \
                    We like to think that this increases the chances that our \
                    programs will still work in another 5-10 years. \
                    In fact, the ToolKit has been working continuously for \
                    nearly 20 years now. \
                    STK currently runs with realtime support (audio and MIDI) \
                    on Linux, macOS, and Windows computer platforms. \
                    Generic, non-realtime support has been tested under \
                    NeXTStep, Sun, and other platforms and should work with \
                    any standard C++ compiler.

homepage            https://ccrma.stanford.edu/software/stk/
master_sites        ${homepage}release/

set rawwave_path    ${prefix}/share/stk/rawwaves/

post-extract {
    file attributes ${worksrcpath} -permissions a+rx
}

patchfiles          library-name.patch \
                    CXXFLAGS.patch

# configure: error: *** A compiler with support for C++11 language features is required.
compiler.cxx_standard 2011

# Rebuild configure after patching configure.ac above.
use_autoreconf      yes

# configure: WARNING: unrecognized options: --disable-dependency-tracking
configure.universal_args-delete --disable-dependency-tracking

# Project Makefiles have $(LDFLAGS) before local -L paths.
# Project doesn't use other libraries so just delete our library path.
configure.ldflags-delete -L${prefix}/lib

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

configure.args      --disable-static \
                    --enable-shared \
                    RAWWAVE_PATH="${rawwave_path}"

# TODO: The library gets rebuilt in the destroot phase.
# TODO: The demo and examples get built but not installed.

post-destroot {
    xinstall -d ${destroot}${rawwave_path}
    copy {*}[glob ${worksrcpath}/rawwaves/*] ${destroot}${rawwave_path}
}

livecheck.type      regex
livecheck.url       ${homepage}download.html
livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
