# $Id: Portfile,v 1.68 2006/06/23 19:44:38 mww Exp $
PortSystem		1.0

name			vim
set vim_version		7.0
set vim_patchlevel	17
revision 		0
version			${vim_version}.${vim_patchlevel}
categories		editors
maintainers		mij@opendarwin.org
description		Vi "workalike" with many additional features
long_description	Vim is a virtually compatible, extremely \
					enhanced version of the vi editor.
homepage		http://www.vim.org/
platforms		darwin freebsd

distfiles	${name}-${vim_version}.tar.bz2:vim \
            ${name}-${vim_version}-extra.tar.gz:extra \
            ${name}-${vim_version}-lang.tar.gz:extra
use_bzip2   yes

master_sites    ftp://ftp.vim.org/pub/vim/unix/:vim \
                ftp://ftp.us.vim.org/pub/vim/unix/:vim \
                ftp://ftp2.us.vim.org/pub/vim/unix/:vim \
                ftp://ftp3.us.vim.org/pub/vim/unix/pub/mirrors/ftp.vim.org/vim/:vim \
                ftp://ftp.is.co.za/applications/editors/vim/unix/:vim \
                ftp://ftp.prz.tu-berlin.de/pub/unix/editors/vim/unix/:vim \
                ftp://ftp.mirror.ac.uk/sites/ftp.vim.org/pub/vim/unix/:vim \
                ftp://ftp.vim.org/pub/vim/extra/:extra\
                ftp://ftp.us.vim.org/pub/vim/extra/:extra \
                ftp://ftp2.us.vim.org/pub/vim/extra/:extra \
                ftp://ftp3.us.vim.org/pub/vim/extra/pub/mirrors/ftp.vim.org/vim/:extra \
                ftp://ftp.is.co.za/applications/editors/vim/extra/:extra \
                ftp://ftp.prz.tu-berlin.de/pub/unix/editors/vim/extra/:extra \
                ftp://ftp.mirror.ac.uk/sites/ftp.vim.org/pub/vim/extra/:extra

patch_sites     [strsed [strsed ${master_sites} g/unix/patches\/${vim_version}/] g/:vim//]

dist_subdir		vim
distname		vim[strsed ${vim_version} {g/[.]//}]

eval {
    set low 1
    while {$low <= $vim_patchlevel} {
        set high [expr $low + 99];
        if {$high < $vim_patchlevel} {
            patchfiles-append [format "%s.%03d-%03d.gz" $vim_version $low $high]
            incr low 100
        } else {
            patchfiles-append [format "%s.%03d" $vim_version $low]
            incr low 1
        }
    }
}

configure.args		--enable-gui=no --without-x --disable-gpm \
					--mandir=${prefix}/share/man

extract.only	${name}-${vim_version}${extract.suffix}
post-extract {
	system "gnutar xvfz ${distpath}/${name}-${vim_version}-extra.tar.gz -C ${workpath}"
	system "gnutar xvfz ${distpath}/${name}-${vim_version}-lang.tar.gz -C ${workpath}"
}

variant aqua {
	master_sites-append	http://www.douglas.stebila.ca/code/vim/app/:app_aqua \
						http://www.douglas.stebila.ca/code/vim/doc/:doc_aqua
	distfiles-append	app-bm.tar.gz:app_aqua \
						doc.tar.gz:doc_aqua
	configure.args-delete	--enable-gui=no
	configure.args-append	--enable-gui=carbon
	post-extract {
		system "gnutar xvfz ${distpath}/app-bm.tar.gz -C ${workpath}"
		system "gnutar xvfz ${distpath}/doc.tar.gz -C ${workpath}"
	}
	post-destroot {
		set appPath /Applications/DarwinPorts
		xinstall -d -m 755 ${destroot}${appPath}
		system "gnutar xvfz ${filespath}/GVim_app.tar.gz \
			-C ${destroot}${appPath}"
		xinstall -m 644 ${workpath}/app.icns \
			${destroot}${appPath}/GVim.app/Contents/Resources/appIcon.icns
		xinstall -d -m 755 ${destroot}${appPath}/Vim
		system "rm -f ${worksrcpath}/src/Vim.app/Contents/Resources/vim/runtime"
		system "cp -R ${worksrcpath}/runtime \
			${worksrcpath}/src/Vim.app/Contents/Resources/vim"
		system "cp -R ${worksrcpath}/src/Vim.app \
			${destroot}${appPath}/Vim/Vim.app"
		xinstall -m 644 ${filespath}/gvimrc \
			${destroot}${appPath}/Vim/Vim.app/
		xinstall -m 644 ${filespath}/vimrc \
			${destroot}${appPath}/Vim/Vim.app/
		xinstall -m 644 ${workpath}/doc-txt.icns \
			${destroot}${appPath}/Vim/Vim.app/Contents/Resources/
		xinstall -m 644 ${workpath}/app.icns \
			${destroot}${appPath}/Vim/Vim.app/Contents/Resources/gui_mac.icns
		system "ln -s -f ${appPath}/Vim/Vim.app/Contents/MacOS/Vim \
			${destroot}/${prefix}/bin/vim"
		xinstall -m 755 ${filespath}/gvim.sh ${destroot}/${prefix}/bin/gvim
	}
}

variant gtk1 {
	configure.args-delete	--enable-gui=no --without-x
	configure.args-append	--enable-gui=gtk --with-x --disable-darwin
	depends_lib-append		lib:libgtk.1:gtk1
}
variant gtk2 {
	configure.args-delete	--enable-gui=no --without-x
	configure.args-append	--enable-gui=gtk2 --with-x --disable-darwin
	depends_lib-append		lib:libgtk.2:gtk2
}
#variant gnome {
#	configure.args-delete	--enable-gui=no --without-x
#	configure.args-append	--enable-gui=gnome --with-x --disable-darwin
# What for depends?
#}
#variant gnome2 {
#	configure.args-delete	--enable-gui=no --without-x
#	configure.args-append	--enable-gui=gnome2 --with-x --disable-darwin
# What for depends?
#}
variant motif {
	configure.args-delete	--enable-gui=no --without-x
	configure.args-append	--enable-gui=motif --with-x --disable-darwin
	depends_lib-append		lib:libXm:openmotif
}
variant athena {
	configure.args-delete	--enable-gui=no --without-x
	configure.args-append	--enable-gui=athena --with-x --disable-darwin
	depends_lib-append		lib:libX11:XFree86
}
variant xim			{ configure.args-append --with-xim }
variant tiny		{ configure.args-append	--with-features=tiny }
variant small		{ configure.args-append	--with-features=small }
variant big			{ configure.args-append	--with-features=big }
variant huge		{ configure.args-append	--with-features=huge }
variant multibyte	{ configure.args-append	--enable-multibyte }
variant ncurses		{ configure.args-append --with-tlib=ncurses }

variant ruby {
	configure.args-append	--enable-rubyinterp
	depends_lib-append		bin:ruby:ruby
}
variant tcl {
	configure.args-append	--enable-tclinterp
	depends_lib-append		bin:tclsh:tcl
}
variant perl {
	configure.args-append	--enable-perlinterp
	depends_lib-append		bin:perl:perl5.8
}
variant python {
	configure.args-append	--enable-pythoninterp
	depends_lib-append		bin:python:python23
}

variant darwin x86 {
	configure.args-append	--disable-darwin
}

include dist_checksums
include patch_checksums
