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

github.setup                andrewrk libsoundio 2.0.1-7
revision                    0
checksums                   rmd160  c5317c70bcf5d1e15f61ed53c80ec1f83e25386e \
                            sha256  941f1347dabab02c88ef57e225b04587c3f69824e550e1045e4a9119cd657a4e \
                            size    126199
github.tarball_from         archive

license                     MIT
categories                  audio
maintainers                 nomaintainer
platforms                   {darwin >= 10}
homepage                    http://libsound.io

description                 Cross-platform audio input and output
long_description            ${name} is a lightweight abstraction \
                            over various sound drivers. It provides \
                            a well-documented API that operates consistently \
                            regardless of the sound driver it connects to. \
                            It performs no buffering or processing \
                            on your behalf\; instead exposing the raw power \
                            of the underlying backend.

# https://github.com/andrewrk/libsoundio/pull/272
patchfiles-append           0001-os.c-use-NOTE_TRIGGER-conditionally-use-EV_TRIGGER.patch
# https://github.com/andrewrk/libsoundio/pull/292
patchfiles-append           0002-coreaudio-add-fallback-aliases-for-10.8.patch

# uses C11
compiler.c_standard         2011

# in addition, have to blacklist the following clangs due to
# fatal error: 'stdatomic.h' file not found
compiler.blacklist-append   {clang < 601}

configure.args-append       -DBUILD_EXAMPLE_PROGRAMS=OFF \
                            -DBUILD_TESTS=OFF \
                            -DENABLE_ALSA=OFF \
                            -DENABLE_COREAUDIO=ON \
                            -DENABLE_JACK=OFF \
                            -DENABLE_PULSEAUDIO=OFF \
                            -DENABLE_WASAPI=OFF

variant pulseaudio description {Enable PulseAudio support} {
    depends_lib-append      port:pulseaudio
    configure.args-replace  -DENABLE_PULSEAUDIO=OFF -DENABLE_PULSEAUDIO=ON
}

variant jack description {Enable Jack support} {
    depends_lib-append      port:jack
    configure.args-replace  -DENABLE_JACK=OFF -DENABLE_JACK=ON
}

variant tests description {Enable testing} {
    configure.args-replace  -DBUILD_TESTS=OFF -DBUILD_TESTS=ON

    test.run                yes
    test.dir                ${cmake.build_dir}
    # To ensure it does not pick libsoundio which may be installed in the prefix:
    test.env                DYLD_LIBRARY_PATH=${test.dir}
    test.cmd                "./unit_tests && ./overflow && ./underflow"
    test.target
}
