# $Id: Portfile 75452 2011-01-25 15:01:18Z jmr@macports.org $

PortSystem 1.0

name            tmux
version         1.4
revision        2
categories      sysutils
maintainers     toby
description     terminal multiplexer
long_description \
    tmux is a \"terminal multiplexer\", it enables a number of terminals \
    (or windows) to be accessed and controlled from a single terminal. \
    tmux is intended to be a simple, modern, BSD-licensed alternative \
    to programs such as GNU screen.
homepage        http://tmux.sourceforge.net/
platforms       darwin
license         BSD
master_sites    sourceforge
checksums       md5 0bfc7dd9a5bab192406167589c716a21 \
                sha1 c0cb9b01aee9b2b5c939bacccd5c78cf6fa6773e \
                rmd160 d8d09ccac7c1c79244f96beccbd6d52f1cc50d1b

depends_lib     port:libevent port:ncurses

patchfiles      GNUmakefile.diff \
                tmux.1.diff \
                tmux.h.diff

post-configure {
    reinplace "s|__PREFIX__|${prefix}|g" "${worksrcpath}/GNUmakefile" "${worksrcpath}/tmux.1" "${worksrcpath}/tmux.h"
    reinplace "s|__CC__|${configure.cc}|" "${worksrcpath}/GNUmakefile"
    reinplace "s|__CFLAGS__|${configure.cflags}|" "${worksrcpath}/GNUmakefile"
    reinplace "s|__LDFLAGS__|${configure.ldflags}|" "${worksrcpath}/GNUmakefile"
}

post-destroot {
    xinstall -m 0755 -d ${destroot}${prefix}/share/doc/tmux
    foreach file [glob ${worksrcpath}/examples/*.conf] {
        xinstall -m 0644 $file ${destroot}${prefix}/share/doc/tmux
    }
    xinstall -m 0755 -d ${destroot}${prefix}/share/vim/vimfiles/syntax
    xinstall -m 0644 ${worksrcpath}/examples/tmux.vim ${destroot}${prefix}/share/vim/vimfiles/syntax
    xinstall -m 0755 -d ${destroot}${prefix}/share/vim/vimfiles/ftdetect
    xinstall -m 0644 ${filespath}/tmux.vim ${destroot}${prefix}/share/vim/vimfiles/ftdetect
}

variant screen description "behave more like screen" {
    post-destroot {
        xinstall -m 0644 ${worksrcpath}/examples/screen-keys.conf ${destroot}${prefix}/etc/tmux.conf
    }
}

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex tmux-(\[0-9\]+\\.\[0-9\]+)\\.tar\\.gz
