# -*- 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 90951 2012-03-19 10:13:34Z yeled@macports.org $

PortSystem          1.0

name                bitlbee
version             3.0.5
categories          irc net
platforms           darwin
maintainers         yeled
description         An IRC to other chat networks gateway
long_description    bitlbee is an IRC server that can connect to IM \
                    networks such as AIM and MSN. Its intention is you \
                    only have to use one client application for all your \
                    instant messaging.

homepage            http://www.bitlbee.org/
master_sites        http://get.bitlbee.org/src/
checksums           md5     9ff97260a2a7f3a7d102db158a8d9887 \
                    sha1    74afdff87be49ce060771a6ae10d7643cd57b9b6 \
                    rmd160  4e3ac7d396c400328300b9c43581bdb890190814

depends_build       port:pkgconfig
depends_lib         port:gnutls \
                    port:gettext \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libgcrypt \
                    port:libgpg-error \
                    port:libiconv 

patchfiles          patch-configure.diff
configure.args      --config=${prefix}/var/lib/bitlbee/ --ssl=gnutls --otr=0
configure.universal_args

destroot.target     install install-etc

# see #27598
# this block is taken from the nodejs port
pre-configure {
    foreach {badport badfile} "libproxy ${prefix}/include/proxy.h" {
        if {[file exists ${badfile}]} {
            ui_error "${name} cannot be built while ${badport} is active."
            ui_error "Please deactivate ${badport} and try again."
            ui_error "You can reactivate ${badport} again later."
            return -code error "${badport} is installed"
        }
    }
}

post-destroot {
    destroot.keepdirs ${destroot}${prefix}/var/lib/bitlbee
    set etcdir ${destroot}${prefix}/etc/bitlbee
    move ${etcdir}/bitlbee.conf ${etcdir}/bitlbee.conf.sample
    move ${etcdir}/motd.txt ${etcdir}/motd.txt.sample
}

post-activate {
    ui_msg "To complete installation, run"
    ui_msg "sudo cp ${prefix}/etc/bitlbee/bitlbee.conf.sample ${prefix}/etc/bitlbee/bitlbee.conf"
    ui_msg "and edit ${prefix}/etc/bitlbee/bitlbee.conf to taste"
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"

default_variants +otr

variant otr description {Off-the-Record messaging} {
    configure.args-delete --otr=0
    configure.args-append --otr=1
    depends_lib-append    port:libotr
}
