# $Id: Portfile 55749 2009-08-18 09:05:10Z raimue@macports.org $

PortSystem          1.0

name                MacVim
set vim_version     7.2
set snapshot        49
set gitcommit       snapshot-${snapshot}
version             ${vim_version}.snapshot${snapshot}
categories          editors
platforms           darwin
maintainers         raimue
description         MacVim is a GUI version of vim for Mac OS X
long_description \
    MacVim is a port of the text editor Vim to Mac OS X that is meant to look \
    better and integrate more seamlessly with the Mac than vim-app.
homepage            http://code.google.com/p/macvim

master_sites        "http://repo.or.cz/w/MacVim.git?a=snapshot;h=${gitcommit};sf=zip;foo="
checksums           md5     e7b91287ff2441443c04b5d920284c65 \
                    sha1    f553e77dced02f4e1463e51e8789fe5237c3e636 \
                    rmd160  b127233ef2b67edbbf1df95dc01a645d2dda03e9
use_zip             yes
worksrcdir          ${name}

depends_build       bin:gnutar:gnutar \
                    bin:grep:grep \
                    bin:autoconf:autoconf
depends_lib         port:ncurses \
                    port:libiconv \
                    port:ctags

# Leave this in for variants adding a patch targeting configure.in
pre-configure {
    system "cd ${worksrcpath}/src && autoconf"
}

configure.args      --enable-gui=macvim \
                    --without-x \
                    --disable-gpm \
                    --disable-nls \
                    --with-tlib=ncurses \
                    --enable-multibyte

use_parallel_build  yes

post-patch {
    reinplace "s|^# VIM_APP_DIR=/Applications$|VIM_APP_DIR=${applications_dir}|" \
         ${worksrcpath}/src/MacVim/mvim
}

build.dir ${worksrcpath}/src
post-build {
    system "cd ${worksrcpath}/src/MacVim && xcodebuild"
}

destroot {
    copy ${worksrcpath}/src/MacVim/build/Release/MacVim.app ${destroot}${applications_dir}
    copy ${worksrcpath}/src/MacVim/mvim ${destroot}${prefix}/bin

    # Create MacVim vimdiff, view, ex equivalents
    ln -s mvim ${destroot}${prefix}/bin/mvimdiff
    ln -s mvim ${destroot}${prefix}/bin/mview
    # Link as mvimex as bin/mex conflicts with texlive
    ln -s mvim ${destroot}${prefix}/bin/mvimex
}

test.run            yes

variant big description {Build big feature set} conflicts huge {
    configure.args-append --with-features=big
}
variant huge description {Build huge feature set} conflicts big {
    configure.args-append --with-features=huge
}
variant xim description {Build with support for X Input Method} {
    configure.args-append --with-xim
}

variant perl description {Enable Perl scripting} {
    configure.args-append   --enable-perlinterp
    depends_lib-append      path:bin/perl:perl5
}
variant python requires python25 description {Compatibility variant, requires +python25} {}
variant python25 conflicts python26 description {Enable Python scripting} {
    configure.args-append   --enable-pythoninterp --with-python=${prefix}/bin/python2.5
    patchfiles-append       patch-python.diff
    depends_lib-append      port:python25
}
variant python26 conflicts python25 description {Enable Python scripting} {
    configure.args-append   --enable-pythoninterp --with-python=${prefix}/bin/python2.6
    patchfiles-append       patch-python.diff
    depends_lib-append      port:python26
}
variant ruby description {Enable Ruby scripting} {
    configure.args-append   --enable-rubyinterp
    depends_lib-append      port:ruby
}
variant tcl description {Enable Tcl scripting} {
    configure.args-append   --enable-tclinterp
    depends_lib-append      port:tcl
}

variant cscope description {Enable source code browsing with cscope} {
    configure.args-append   --enable-cscope
}

variant nls {
    configure.args-delete   --disable-nls
    depends_lib-append      port:gettext
}

livecheck.check         regex
livecheck.url           http://code.google.com/p/macvim/downloads/list
livecheck.version       ${snapshot}
livecheck.regex         MacVim-snapshot-(\\d+)
