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

name                qjackctl
version             0.6.3
license             GPL-2+
categories          audio
maintainers         nomaintainer
homepage            https://qjackctl.sourceforge.net

description \
    QjackCtl is a simple Qt application to control the JACK sound server daemon.
long_description \
    Provides a simple GUI dialog for setting several JACK daemon parameters, \
    which are properly saved between sessions, and a way control of the status \
    of the audio server daemon. With time, this primordial interface has become \
    richer by including a enhanced patchbay and connection control features.

master_sites        http://downloads.sourceforge.net/qjackctl

checksums           rmd160  8ad5bd27fff8b615df194b415ff385019f88ace9 \
                    sha256  9db46376cfacb2e2ee051312245f5f7c383c9f5a958c0e3d661b9bd2a9246b7d \
                    size    1033664

universal_variant   no

patchfiles-append   0001-fix-compiler-choice.patch

post-patch {
    reinplace "s|__CXX__|${configure.cxx}|" ${worksrcpath}/src/src.pri.in
    reinplace "s|__CXXFLAGS__|${configure.cxxflags}|" ${worksrcpath}/src/src.pri.in
}

depends_lib-append  port:jack

compiler.cxx_standard 2011
configure.cxxflags-append \
    -std=c++11

post-patch {
    # fix jackd path
    reinplace "s|\"/Server\", \"jackd\"|\"/Server\", \"${prefix}/bin/jackd\"|" ${worksrcpath}/src/qjackctlSetup.cpp
}

configure.args-append \
    --with-jack=${prefix} \
    --disable-alsa-seq \
    --disable-debug

configure.args-delete \
    --disable-dependency-tracking

if {${os.platform} ne "darwin" || ${os.major} > 10} {
    PortGroup               qt5 1.0

    qt5.depends_component   qtbase \
                            qttools

    configure.args-append   --with-qt=${qt_dir}
} else {
    PortGroup               qt4 1.0

    patchfiles-append       0002-Restore-Qt4-support.patch

    use_autoreconf          yes

    configure.args-append   --enable-qt4 \
                            --with-qt4=${qt_dir}
}

variant debug description "Enable debugging" {}

if {[variant_isset debug]} {
    configure.args-append   --enable-debug
} else {
    configure.args-append   --disable-debug
}

variant portaudio description "enable PortAudio interface" {}

if {[variant_isset portaudio]} {
    depends_lib-append      port:portaudio
    configure.args-append   --enable-portaudio
} else {
    configure.args-append   --disable-portaudio
}

variant stacktrace description "enable debugger stack-trace" {}

if {[variant_isset stacktrace]} {
    configure.args-append   --enable-stacktrace
} else {
    configure.args-append   --disable-stacktrace
}

variant dbus description "enable D-Bus interface" {}

if {[variant_isset dbus]} {
    configure.args-append   --enable-dbus
} else {
    configure.args-append   --disable-dbus
}

post-destroot {
    # move the created .app to MacPorts' applications directory ...
    move ${destroot}${prefix}/bin/qjackctl.app ${destroot}${applications_dir}
    # ... and link the actual executable back to the bindir
    ln -s ${applications_dir}/qjackctl.app/Contents/MacOS/qjackctl ${destroot}${prefix}/bin/qjackctl
}

livecheck.url   http://sourceforge.net/projects/${name}/files/
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
