# -*- 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
# $Id: Portfile 118985 2014-04-14 19:01:23Z macsforever2000@macports.org $

PortSystem 1.0
PortGroup cmake 1.0

name            quassel
version         0.10.0
categories      irc
license         GPL-3
platforms       darwin
maintainers     sicherha.de:macports openmaintainer
homepage        http://quassel-irc.org
master_sites    ${homepage}/pub

checksums       rmd160  def5056e088a709dba09c78db9ad369d7b1f4e28 \
                sha256  68228ce23aa3a992add3d00cb1e8b4863d8ca64bea99c881edf6d16ff9ec7c23

depends_lib     port:qt4-mac

use_bzip2       yes

# Do not use git to find out the program version - there is no ".git" directory
# in the source tarball
patchfiles      patch-scripts-build-macosx_makebundle.py.diff

post-patch {
    reinplace "s|@@VERSION@@|${version}|" \
        ${worksrcpath}/scripts/build/macosx_makebundle.py
}

configure.args  -DWANT_CORE=OFF \
                -DWANT_QTCLIENT=OFF \
                -DWANT_MONO=OFF \
                -DWITH_CRYPT=OFF \
                -DWITH_DBUS=OFF \
                -DWITH_KDE=OFF \
                -DWITH_PHONON=OFF \
                -DWITH_OPENSSL=OFF

if {${name} == ${subport}} {

    description \
        Qt4 IRC client
    long_description \
        Quassel IRC is a modern, cross-platform IRC client. This port installs \
        the monolithic variant, which does not require a separate Quassel core.

    configure.args-replace -DWANT_MONO=OFF -DWANT_MONO=ON

    destroot {
        copy "${worksrcpath}/Quassel.app" "${destroot}${applications_dir}"
    }
}

subport ${name}-client {

    description \
        Qt4 IRC client - client component
    long_description \
        Quassel IRC is a modern, cross-platform, distributed IRC client, \
        meaning that one (or multiple) client(s) can attach to and detach from \
        a central core - much like the popular combination of screen and a \
        text-based IRC client such as WeeChat, but graphical.

    depends_lib-append port:qt4-mac-sqlite3-plugin

    if {[variant_isset crypt]} {
        depends_run-append port:qca-ossl
    }

    configure.args-replace -DWANT_QTCLIENT=OFF -DWANT_QTCLIENT=ON

    destroot {
        copy "${worksrcpath}/Quassel Client.app" \
             "${destroot}${applications_dir}"
    }
}

variant crypt description \
    {Support per-channel and per-query blowfish encryption via qca} {
    depends_lib-append      port:qca
    configure.args-replace  -DWITH_CRYPT=OFF -DWITH_CRYPT=ON
}

variant dbus description {Enable dbus support} {
    depends_lib-append      port:dbusmenu-qt
    configure.args-replace  -DWITH_DBUS=OFF -DWITH_DBUS=ON
}

variant openssl description {Enable OpenSSL support} {
    depends_lib-append      port:openssl
    configure.args-replace  -DWITH_OPENSSL=OFF -DWITH_OPENSSL=ON
}

variant phonon description {Enable support for audio notifications via phonon} {
    depends_lib-append      port:phonon
    configure.args-replace  -DWITH_PHONON=OFF -DWITH_PHONON=ON
}

default_variants    +crypt +dbus +phonon +openssl

livecheck.type  regex
livecheck.url   http://quassel-irc.org/pub/
livecheck.regex "${name}-(\[0-9\.\]+)\.tar\.bz2"
