# -*- 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
PortGroup           cmake 1.1

epoch               1
github.setup        PortMidi portmidi 2.0.6 v
github.tarball_from archive
revision            0

categories          audio devel
maintainers         nomaintainer
license             MIT

description         Free, cross platform, open-source, real-time MIDI I/O library.
long_description    ${description}

checksums           rmd160  9b0d16020a16dc91c794832d99b06b61a08076d1 \
                    sha256  81d22b34051621cd56c8d5ef12908ef2a59764c9cdfba6dae47aabddb71ac914 \
                    size    193068

# Building the Java interface and pmdefaults is disabled. They could be
# added as separate ports, with a dependency on an appropriate openjdk
# port, if there is interest.

patchfiles-append   patch-CMakeLists.txt.diff

# can be removed as soon as it appears in upstream
patchfiles-append   patch-rename-coremidi-framework.diff

# The author forgot to bump the version
post-patch {
    reinplace "s|2.0.4|${version}|g" ${worksrcpath}/CMakeLists.txt
}

configure.args      -DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF \
                    -DBUILD_PORTMIDI_TESTS=ON

# pmmacosxcm.c: error: ‘for’ loop initial declaration used outside C99 mode
# Passing -std=c99 does not save though, the build then fails with numerous errors of the kind:
# readbinaryplist.c: error: ‘struct value_struct’ has no member named ‘integer’
compiler.blacklist-append *gcc-4.*

# There is no way to run the full test suite automatically.
# See pm_test/README.txt. So this just runs one of the tests
# that doesn't require manual MIDI input.
test.run            yes
test.env            DYLD_LIBRARY_PATH=.
test.cmd            ./qtest

post-destroot {
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        README.txt \
        license.txt \
        pm_mac/README_MAC.txt \
        ${docdir}
}
