# -*- 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           xcode 1.0
PortGroup           xcode_workaround 1.0

github.setup        ExistentialAudio BlackHole 0.4.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          audio
maintainers         {@adarshp arizona.edu:adarsh} openmaintainer
license             GPL-3

description         macOS virtual audio driver.

long_description    BlackHole is a modern macOS virtual audio driver that \
                    allows applications to pass audio to other applications \
                    with zero additional latency.

checksums           rmd160  3b66df95db5970211a63c318460b5866c0ae9bdd \
                    sha256  f5c44e931bcea67cf281745258426e8ce38c5aa8c197a2c8a748bb26070474b9 \
                    size    446075

xcode.configuration Release
xcode.build.settings CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO XCODEFLAGS="CACHE_ROOT=${workpath}/caches -UseNewBuildSystem=NO"
xcode.destroot.settings {*}${xcode.build.settings}
xcode.destroot.path /Library/Audio/Plug-Ins/HAL

post-activate {
    system "sudo launchctl kickstart -kp system/com.apple.audio.coreaudiod"
}

# BlackHole violates the mtree layout by placing the driver in
# /Library/Audio/Plug-Ins/HAL
destroot.violate_mtree yes

compiler.blacklist-append {clang < 600}

variant ch8 conflicts ch16 description "Enable 8 channels" {
    post-patch {
        reinplace "s|kNumber_Of_Channels                 2|kNumber_Of_Channels                 8|" ${worksrcpath}/BlackHole/BlackHole.h
    }
}

variant ch16 conflicts ch8 description "Enable 16 channels" {
    post-patch {
        reinplace "s|kNumber_Of_Channels                 2|kNumber_Of_Channels                 16|" ${worksrcpath}/BlackHole/BlackHole.h
    }
}

notes "\
To fully uninstall BlackHole, you will need to run the following command after\
running 'port uninstall blackhole':

    sudo launchctl kickstart -kp system/com.apple.audio.coreaudiod
"
