# -*- 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.4 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  381735e44525259ccb485431468357e92abfd4ac \
                    sha256  64893e823ae146cabd3ad7f9a9a9c5332746abe7847c557b99b2577afa8a607c \
                    size    263225

# 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          patch-CMakeLists.txt.diff

# The author forgot to bump the version
post-patch {
    reinplace "s|2.0.3|${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}
}