# -*- 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

name                portaudio
set major           19
set minor           6
set reldate         20161030
set distversion     ${major}[format %04d [expr {$minor * 100}]]_${reldate}
version             ${major}.${reldate}
categories          audio devel
platforms           darwin macosx
maintainers         nomaintainer
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            http://www.portaudio.com/
master_sites        ${homepage}archives

distname            pa_stable_v${distversion}
extract.suffix      .tgz

checksums           rmd160  e6e5cd3f3cb7469aa17549c189e445d573567e13 \
                    sha256  f5a21d7dcd6ee84397446fa1fa1a0675bb2e8a4a6dceb4305a8404698d8d1513 \
                    size    1450572

worksrcdir          ${name}

# 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


# 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

platform darwin {
    if {${os.major} >= 10} {
        patchfiles-append patch-src__hostapi__coreaudio__pa_mac_core.c.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}
    }
}

use_parallel_build  no

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
        README.txt \
        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
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.version   ${distversion}
livecheck.regex     pa_stable_v(\[0-9._\]+)\\.