# -*- Mode: Tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

name                portaudio
categories          audio devel
platforms           darwin macosx
maintainers         {ra1nb0w @ra1nb0w} openmaintainer
license             MIT

description         PortAudio is a free, cross platform, open-source, audio I/O library.

long_description    PortAudio is a free, cross platform, open-source, audio I/O library. \
                    It lets you write simple audio programs in 'C' or C++ that will \
                    compile and run on many platforms including Windows, \
                    Macintosh OS X, and Unix (OSS/ALSA). \
                    It is intended to promote the exchange of audio \
                    software between developers on different platforms. \
                    Many applications use PortAudio for Audio I/O.

homepage            https://www.portaudio.com

github.setup        Portaudio portaudio 88ab584e7bf4358599744cd662cfbc978f41efbf
version             20240308-[string range ${github.version} 0 7]
checksums           rmd160  2cadf558fea9eee4f3887dc043827e3106c2eab5 \
                    sha256  f5be535d62cab5f1becd4f19207466c813fbcf51d9057e72f7d57544a9e9ee03 \
                    size    1491142
revision            0
github.tarball_from archive

# fatal error: 'stdatomic.h' file not found
compiler.blacklist-append {clang < 700}
compiler.c_standard 2011

# By default, PortAudio is built as a universal binary.
# To build a non-universal library for the host architecture,
# simply use the --disable-mac-universal option with configure.
# http://www.portaudio.com/trac/wiki/TutorialDir/Compile/MacintoshCoreAudio
configure.args      --disable-mac-universal \
                    --enable-cxx \
                    --enable-option-checking \
                    --without-alsa \
                    --without-jack \
                    --without-oss \
                    --without-asihpi \
                    --without-winapi

use_parallel_build  no

# patch-configure removes -Werror, and adds -DNDEBUG.
patchfiles          patch-configure.diff \
                    patch-ltmain.sh.diff \
                    patch-src__common__pa_types.h.diff \
                    patch-audacity-portmixer.diff \
                    patch-Restore-support-for-10.5.diff

variant jack description {Enable JACK support} {
    depends_lib-append \
                    port:jack
    configure.args-replace \
                    --without-jack \
                    --with-jack
}

variant tools description {Install the example and test utilities to ${prefix}/libexec/${name}} {
    post-destroot {
        set utildir ${destroot}${prefix}/libexec/${name}
        xinstall -m 755 -d ${utildir}
        # avoid installing any .dSYM directories that might have been created
        xinstall -m 755 {*}[glob -type f ${build.dir}/bin/.libs/pa*] ${utildir}
    }
}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
        README.md \
        LICENSE.txt \
        ${destroot}${prefix}/share/doc/${name}
    # The build of PyAudio requires pa_mac_core.h.
    xinstall -m 644 ${worksrcpath}/include/pa_mac_core.h \
        ${destroot}${prefix}/include
}
