# -*- 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           legacysupport 1.1
PortGroup           makefile 1.0

# getline
legacysupport.newest_darwin_requires_legacy 10

name                chuck
version             1.5.1.0
revision            0
categories          audio
maintainers         {gmail.com:slewsys @slewsys} openmaintainer
license             GPL-2+

description         Chuck is a strongly-timed, concurrent, and on-the-fly \
                    music programming language.

long_description    ChucK is a programming language for real-time \
                    sound synthesis and music creation. It presents \
                    a time-based, concurrent programming model \
                    that's precise and expressive (we call this \
                    strongly-timed), along with dynamic control rates, \
                    and the ability to add and modify code \
                    on-the-fly. In addition, ChucK supports MIDI, \
                    OpenSoundControl, HID device, and multi-channel \
                    audio.

homepage            https://chuck.cs.princeton.edu/
master_sites        ${homepage}release/files/
extract.suffix      .tgz

checksums           rmd160  efc4bb281b7a2d7b1a8d4e73ad4e87899bb99118 \
                    sha256  28989b36624848f6a18883d12b757c7c623338f066b16618960efdf1cfa7588b \
                    size    17156621

depends_build-append \
                    port:bison \
                    port:flex

depends_lib-append  port:libsndfile

# Keep this above build args.
compiler.cxx_standard 2011

patchfiles          patch-makefile.mac.diff \
                    patch-makefiles.diff

post-patch {
    reinplace "s|@TARGET@|${macosx_deployment_target}|" ${worksrcpath}/src/core/makefile.x/makefile.mac
    reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/src/makefile
    reinplace "s|@CC@|${configure.cc}|" ${worksrcpath}/src/makefile ${worksrcpath}/src/core/makefile
    reinplace "s|@CXX@|${configure.cxx}|g" ${worksrcpath}/src/makefile ${worksrcpath}/src/core/makefile
    reinplace "s|@CXXFLAGS@|${configure.cxxflags}|" ${worksrcpath}/src/makefile
}

use_configure       no

variant universal   {}

build.dir           ${worksrcpath}/src
build.args-append   ARCHS="[get_canonical_archs]" \
                    CC="${configure.cc}" \
                    CXX="${configure.cxx}" \
                    LD="${configure.cxx}"

destroot {
    xinstall -m 755 ${worksrcpath}/src/chuck ${destroot}${prefix}/bin
    xinstall -d ${destroot}${prefix}/share/doc/${name} ${destroot}${prefix}/share/examples
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS DEVELOPERS LICENSE QUICKSTART \
        README.md THANKS VERSIONS \
        ${destroot}${prefix}/share/doc/${name}
    copy ${worksrcpath}/examples ${destroot}${prefix}/share/examples/${name}
}

platform darwin {
    build.target    osx
}

livecheck.regex     {^\s+(\d+\.\d+\.\d+\.\d+)\s+\(.*\)$}
livecheck.type      regex
livecheck.url       ${homepage}release/