# $Id: Portfile 105626 2013-04-28 09:14:29Z raimue@macports.org $

PortSystem          1.0

name                MacVim
set vim_version     7.3
set snapshot        66
set gitcommit       snapshot-${snapshot}
version             ${vim_version}.snapshot${snapshot}
revision            3
categories          editors
platforms           darwin
license             Vim GPL-2+
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://github.com/b4winckler/macvim/zipball/${gitcommit}
checksums           rmd160  7837828c4ca5ee4bbbd36be724fc3029de989885 \
                    sha256  f8e317393a2cb78e459f8a430d392bcba85b89e19afc5e9692b1b239aee8b8fe
use_zip             yes
worksrcdir          ${name}

# 7.3.snapshot66 had a stealth update
dist_subdir         ${name}/${version}_1


depends_build       bin:gnutar:gnutar \
                    bin:grep:grep \
                    bin:autoconf:autoconf \
                    port:python27
depends_lib         port:ncurses \
                    port:gettext \
                    port:libiconv

if ![variant_isset python27] {
    # python is only used for build scripts, no linking
    license_noconflict  python27
}

patchfiles          patch-src-MacVim-icons-python.diff \
                    patch-reverse-7.3.245.diff \
                    patch-MacVim-GCC-VERSION.diff

pre-fetch {
    if {${os.platform} == "darwin" && ${os.major} < 10} {
        ui_error "${name} only runs on Mac OS X 10.6 or greater."
        return -code error "incompatible Mac OS X version"
    }
}

# does not run correctly when build with older clang releases, see #30985
compiler.blacklist macports-clang-2.9 macports-clang-3.0
if {[vercmp ${xcodeversion} 4.4] < 0} {
    compiler.blacklist-append clang
}

post-extract {
    # github zipball has root folder including commitish, renaming for ease of use
    file rename [glob ${workpath}/b4winckler-*] ${worksrcpath}

    # create cache directory
    file mkdir ${workpath}/caches
}

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

autoconf.dir ${worksrcpath}/src

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

# Old pre-compiled headers could influence build, #26723
build.args          XCODEFLAGS="CACHE_ROOT=${workpath}/caches" \
                    PYTHON=${prefix}/bin/python2.7

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

if {![variant_isset big] && ![variant_isset huge]} {
    default_variants +huge
}

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 python27 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

    use_autoconf yes
}
variant python26 conflicts python25 python27 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

    use_autoconf yes
}
variant python27 conflicts python25 python26 description {Enable Python scripting} {
    configure.args-append   --enable-pythoninterp --with-python=${prefix}/bin/python2.7
    patchfiles-append       patch-python.diff
    depends_lib-append      port:python27

    use_autoconf yes
}
variant python31 conflicts python32 python33 description {Enable Python scripting} {
    configure.args-append   --enable-python3interp --with-python3=${prefix}/bin/python3.1
    patchfiles-append       patch-python3.diff
    depends_lib-append      port:python31

    use_autoconf yes
}
variant python32 conflicts python31 python33 description {Enable Python scripting} {
    configure.args-append   --enable-python3interp --with-python3=${prefix}/bin/python3.2
    patchfiles-append       patch-python3.diff
    depends_lib-append      port:python32

    use_autoconf yes
    # Overwriting autoconf.cmd above removes dependency, add it again
    depends_build-append port:autoconf
}
variant python33 conflicts python31 python32 description {Enable Python scripting} {
    configure.args-append   --enable-python3interp --with-python3=${prefix}/bin/python3.3
    patchfiles-append       patch-python3.diff
    depends_lib-append      port:python33

    use_autoconf yes
    # Overwriting autoconf.cmd above removes dependency, add it again
    depends_build-append port:autoconf
}
variant ruby requires ruby18 description {Compatibility variant, requires +ruby18} {}
variant ruby18 conflicts ruby19 description {Enable Ruby scripting} {
    configure.args-append   --enable-rubyinterp
    configure.args-append   --with-ruby-command=${prefix}/bin/ruby1.8
    depends_lib-append      port:ruby
}
variant ruby19 conflicts ruby description {Enable Ruby scripting} {
    configure.args-append   --enable-rubyinterp
    configure.args-append   --with-ruby-command=${prefix}/bin/ruby1.9
    depends_lib-append      port:ruby19
}
variant tcl description {Enable Tcl scripting} {
    configure.args-append   --enable-tclinterp
    patchfiles-append       patch-tcl.diff
    depends_lib-append      port:tcl

    use_autoconf yes
}

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

livecheck.type          regex
livecheck.version       ${snapshot}
livecheck.regex         snapshot-(\\d+)
