# -*- 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 104704 2013-04-01 03:14:41Z jeremyhu@macports.org $

PortSystem  1.0
PortGroup   cmake 1.0

name        weechat
version     0.4.0
revision    1
categories  irc
maintainers otherware.org:nefar openmaintainer
license     GPL-3
description Fast, light & extensible IRC client
long_description    \
    WeeChat (Wee Enhanced Environment for Chat) is a fast and light IRC client\
     for many operating systems. Everything can be done with a keyboard.\
     It is customizable and extensible with plugins/scripts, and includes:\
      - nicklist\
      - smart hotlist\
      - infobar with highlight notification\
      - horizontal and vertical split\
      - double charset support (decode/encode)\
      - FIFO pipe for remote control\
      - and much more!
homepage    http://weechat.org/
platforms   darwin
master_sites    ${homepage}files/src

checksums           rmd160  70a3b67762227c8408b8ca880ea1af15fcc7fe81 \
                    sha256  1df12201d8b0ac25f62ddbfb675e8f3d978e52bc5b644d55ccf4c755956fa60d

depends_lib-append  port:gettext \
                    port:libgcrypt \
                    port:libiconv \
                    port:ncurses

patchfiles          patch-src_plugins_Makefile.diff

configure.args-append   -DENABLE_GNUTLS=OFF \
                        -DENABLE_LUA=OFF \
                        -DENABLE_GUILE=OFF \
                        -DENABLE_PERL=OFF \
                        -DENABLE_PYTHON=OFF \
                        -DENABLE_RUBY=OFF \
                        -DENABLE_ASPELL=OFF

use_bzip2   yes

variant aspell description {Support for aspell} {
    configure.args-delete   -DENABLE_ASPELL=OFF
    configure.args-append   -DENABLE_ASPELL=ON
    depends_lib-append      port:aspell
}

variant lua description {Bindings for lua plugins} {
    configure.args-delete -DENABLE_LUA=OFF
    configure.args-append -DENABLE_LUA=ON
    depends_lib-append    port:lua
}

variant scheme description {Bindings for Scheme (guile) plugins} {
    configure.args-delete -DENABLE_GUILE=OFF
    configure.args-append -DENABLE_GUILE=ON
    depends_lib-append    port:guile
}

variant perl description {Bindings for perl plugins} {
    configure.args-delete -DENABLE_PERL=OFF
    configure.args-append -DENABLE_PERL=ON
    depends_lib-append    path:bin/perl:perl5
}

variant python description {Bindings for python plugins} {
    configure.args-delete   -DENABLE_PYTHON=OFF
    configure.args-append   -DENABLE_PYTHON=ON
    depends_lib-append      path:bin/python:python26
}

variant ruby description {Bindings for ruby plugins} {
    configure.args-delete -DENABLE_RUBY=OFF
    configure.args-append -DENABLE_RUBY=ON
    depends_lib-append    port:ruby
}

variant tls description {Support for secure connecting} {
    configure.args-delete -DENABLE_GNUTLS=OFF
    configure.args-append -DENABLE_GNUTLS=ON
    depends_lib-append    port:gnutls
}

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING ChangeLog NEWS README \
        ${destroot}${prefix}/share/doc/${name}
    eval xinstall -m 644 -W ${worksrcpath} [glob doc/en/weechat*.txt] \
        ${destroot}${prefix}/share/doc/${name}
}

post-install {
    # if present then remove file previously installed outside destroot
    foreach file {include/weechat/weechat-plugin.h} {
        set filepath ${prefix}/${file}
        if {[file exists ${filepath}] && [registry_file_registered ${filepath}] == "0"} {
            if {[catch {delete ${filepath}}]} {
                ui_warn "Cannot delete ${filepath}; please remove it manually"
            }
        }
    }
}

