# -*- 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.6.1 v

github.tarball_from archive
categories          audio
maintainers         {hotmail.com:amtor @RobK88} 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  109a01cf9b6c385be458f5acfe9b1a8032cc749a \
                    sha256  d4af31394c002bc495735f8339e1dd86fee68111fc78bb0d65c2685677aff7c6 \
                    size    633033

xcode.configuration Release
xcode.build.settings CODE_SIGN_IDENTITY= CODE_SIGNING_ALLOWED=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 ch64 description "Enable 8 channels" {
    post-patch {
        reinplace "s|kNumber_Of_Channels                 2|kNumber_Of_Channels                 8|" ${worksrcpath}/BlackHole/BlackHole.c
    }
}

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

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

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
"
