pkgname=vim
_srcver=7.2
_patchlevel=266
pkgver=${_srcver}.${_patchlevel}
pkgrel=3
pkgdesc='Vi Improved, a highly configurable, improved version of the vi text editor'
arch=('i686' 'x86_64')
license=('custom:vim')
groups=('base')
url="http://www.vim.org"
depends=('gpm' 'coreutils')
makedepends=('wget' 'sed' 'grep' 'gettext' 'perl')
optdepends=('perl:    the runtime provides a view useful perl scripts')
backup=('etc/vimrc')
install="${pkgname}.install"
# we need the extra-stuff to get all patches applied smoothly
source=("ftp://ftp.vim.org/pub/vim/unix/vim-${_srcver}.tar.bz2"
        "ftp://ftp.vim.org/pub/vim/extra/vim-${_srcver}-extra.tar.gz"
        "ftp://ftp.vim.org/pub/vim/extra/vim-${_srcver}-lang.tar.gz"
        'fetch_patches.sh'
        'fetch_runtime.sh'
        'vimrc'
        'archserver.vim')
md5sums=('f0901284b338e448bfd79ccca0041254'
         '35e04482f07c57221c9a751aaa3b8dac'
         'd8884786979e0e520c112faf2e176f05'
         '6d7e8d7868e8bfaa9a5880cd9c439320'
         '45c1c3c6aff7de0d8fc2a9d8cd5cec7d'
         '94861d33bedf350122cf442a4770df7f'
         '10353a61aadc3f276692d0e17db1478e')

build(){
  _versiondir="vim"$(echo ${_srcver} | sed "s/\.//")
  
  # pull in patches from vim.org (or the src cache alternatively)
  source ${srcdir}/fetch_patches.sh
  source ${srcdir}/fetch_runtime.sh

  get_patches || return 1

  cd ${srcdir}/${_versiondir}
  sed -i 's|^.*\(#define SYS_.*VIMRC_FILE.*"\) .*$|\1|' src/feature.h
  sed -i 's|^.*\(#define VIMRC_FILE.*"\) .*$|\1|' src/feature.h
  
  # build party
  ./configure \
    --prefix=/usr \
    --localstatedir=/var/lib/vim \
    --mandir=/usr/share/man \
    --with-compiledby=ArchServer \
    --with-features=big \
    --enable-gpm \
    --enable-acl \
    --with-x=no \
    --disable-gui \
    --enable-multibyte \
    --enable-cscope \
    --enable-perlinterp || return 1
    #--with-global-runtime=/usr/share/vim --with-vim-name=vim \
  
  make || return 1
}

package() {
  _versiondir="vim"$(echo ${_srcver} | sed "s/\.//")
  cd ${srcdir}/${_versiondir}

  # pull in patches from vim.org (or the src cache alternatively)
  source ${srcdir}/fetch_patches.sh
  source ${srcdir}/fetch_runtime.sh

  make VIMRCLOC=/etc DESTDIR=${pkgdir} install

  cd ${pkgdir}/usr/bin || return 1
  #rm ex view          # provided by (n)vi in core
  mv vim vim-normal || return 1   # we create a vim-symlink on post_install
  ln -sf vim-normal vim || return 1
  # ... make g* related symlinks point directly to the actual binary
  ln -sf vim-normal rview || return 1
  ln -sf vim-normal rvim || return 1
  ln -sf vim-normal vimdiff || return 1
  ln -sf vim-normal vi || return 1
  
  # delete some manpages
  find ${pkgdir}/usr/share/man -type d -name 'man1' 2> /dev/null | \
   while read mandir; do
    cd ${mandir} || return 1
    rm -f ex.1 view.1 || return 1       # provided by (n)vi
    rm -f evim.1 || return 1            # this does not make sense in the console version
  done
  
  _runtimedir="${pkgdir}/usr/share/vim/${_versiondir}/"
  update_runtime || return 1
  cd ${srcdir}/${_versiondir} || return 1
  install -Dm644 ${srcdir}/vimrc ${pkgdir}/etc/vimrc || return 1
  install -Dm644 ${srcdir}/archserver.vim ${pkgdir}/usr/share/vim/vimfiles/archserver.vim || return 1
  install -dm755 ${pkgdir}/usr/share/licenses/vim || return 1
  cd ${pkgdir}/usr/share/licenses/vim || return 1
  ln -s ../../vim/${_versiondir}/doc/uganda.txt license.txt || return 1
}

# vim:set ts=2 sw=2 et:
