# -*- 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 114225 2013-12-03 08:01:45Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               python 1.0

name                    terminator
version                 0.97
categories              sysutils
platforms               darwin
maintainers             ryandesign openmaintainer
license                 GPL-2
supported_archs         noarch

description             multiple terminal emulator

long_description        ${name} lets you open multiple terminal emulators in \
                        a single window.

homepage                http://gnometerminator.blogspot.com/p/introduction.html
master_sites            http://launchpad.net/terminator/trunk/${version}/+download
dist_subdir             ${name}

checksums               rmd160  5b95e5705b0fe2bda6c70b39825f0e2381a62050 \
                        sha256  9131847023fa22f11cf812f6ceff51b5d66d140b6518ad41d7fa8b0742bfd3f7

if {![variant_isset python26] && ![variant_isset python27]} {
    if {[file exists ${frameworks_dir}/Python.framework/Versions/2.6/lib/python2.6/site-packages/gtk-2.0/vtemodule.so]} {
        default_variants +python26
    } else {
        default_variants +python27
        variant_set python27
    }
}

variant python26 conflicts python27 description {Use Python 2.6} {}
if {[variant_isset python26]} {
    python.default_version 26
}

variant python27 conflicts python26 description {Use Python 2.7} {}
if {[variant_isset python27]} {
    python.default_version 27
}

depends_build-append    port:intltool

depends_lib-append      port:vte \
                        port:hicolor-icon-theme \
                        port:py${python.version}-keybinder \
                        port:py${python.version}-notify-python

post-patch {
    reinplace -E "s|^#!/usr/bin/env python|#!${python.bin}|" ${worksrcpath}/${name}
}

pre-configure {
    if {![file exists ${python.pkgd}/gtk-2.0/vtemodule.so]} {
        ui_error "To install ${name} with the +python${python.version} variant, vte must be installed with the +python${python.version} variant."
        return -code error "incompatible vte installation"
    }
}

# no suffix since there are not multiple versions of this port
python.link_binaries_suffix

post-destroot {
    foreach manpage {man1/terminator.1 man5/terminator_config.5} {
        ln -s ${python.prefix}/share/man/${manpage} ${destroot}${prefix}/share/man/${manpage}
    }
    
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        COPYING \
        ChangeLog \
        README \
        ${docdir}
}

livecheck.type          regex
livecheck.url           http://launchpad.net/terminator/+download
livecheck.regex         /${name}\[-_\](\[0-9.\]+)${extract.suffix}
