# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 75458 2011-01-25 17:05:22Z snc@macports.org $

PortSystem          1.0
PortGroup           qt4 1.0

name                mumble
version             1.2.2
revision            3
categories          aqua audio
license             GPL
maintainers         snc openmaintainer
description         low-latency voice chat for gaming
long_description \
    Mumble is an open source, low-latency, high quality \
    voice chat software primarily intended for use while gaming.
homepage            http://mumble.sourceforge.net/
platforms           macosx
supported_archs     ppc i386

master_sites        sourceforge

checksums           sha1    b2a7fd50e70147b3ea2361cbc5a577b0e1ae45ea \
                    rmd160  501aa1c4c170fb5aad2841cdfe3421376e62a07b

livecheck.type      regex
livecheck.url       http://sourceforge.net/project/showfiles.php?group_id=147372&package_id=162594
livecheck.regex     "${name}-(\\d+\\.\\d+\\.\\d+)${extract.suffix}"

depends_lib-append \
    port:openssl \
    port:portaudio \
    port:ice-cpp \
    port:libsndfile \
    port:protobuf-cpp \
    lib:pkgconfig/speex.pc:speex

depends_build-append \
    port:boost

configure.args

variant debug description "Build as both release and debug" {}

post-patch {
    # when not doing debug ...
    if {![variant_isset debug]} {
        # ... build just the release version
        configure.args-append release
        foreach fixfile [exec find ${worksrcpath} -name "*.pr*"] {
            reinplace "s@debug_and_release@release@" ${fixfile}
        }
    } else {
        # else build both debug and release
        configure.args-append debug_and_release
    }

    # Fix LIBPATH -> QMAKE_LIBPATH per Qt 4.7's warnings
    foreach fixfile [exec find ${worksrcpath} -name "*.pr*"] {
        reinplace "s@LIBPATH@QMAKE_LIBDIR@" ${fixfile}
    }
}

configure.env-append QMAKESPEC=${qt_mkspecs_dir}/macx-g++
configure.cmd       ${qt_qmake_cmd}
configure.pre_args  CONFIG+=\"
configure.post_args \" DEFINES+=NO_UPDATE_CHECK main.pro
configure.args-append no-dbus no-universal no-server \
    no-embed-qt-translations no-bundled-speex no-g15 \
    no-update

variant dbus description {Build DBus support} {
    configure.args-delete no-dbus
}

variant universal {
    configure.args-delete no-universal
}

build.env-append    QMAKESPEC=${qt_mkspecs_dir}/macx-g++

destroot {
    file copy ${worksrcpath}/release/Mumble.app ${prefix}${applications_dir}/Mumble.app
    file copy ${worksrcpath}/release/plugins ${prefix}${applications_dir}/Mumble.app/Contents/Plugins
}
