app=vim
version=8.1
build=1sml
homepage="https://www.vim.org/"
download="ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2"
desc="Vi IMproved UNIX text editor"
requires="netbsd-curses"

build() {
  mkandenterbuilddir
  rm -rf "$app""81"

  tar xf $srcdir/$app-$version.tar.?z*
  cd "$app""81"
  fixbuilddirpermissions

  CPPFLAGS="$CFLAGS -include stdlib.h -DHAVE_SETENV -DHAVE_PUTENV" \
  LIBS="-lcurses -lterminfo" \
  LDFLAGS="-static" \
  vim_cv_toupper_broken=no \
  vim_cv_terminfo=yes \
  vim_cv_tty_group=world \
  vim_cv_getcwd_broken=no \
  vim_cv_stat_ignores_slash=no \
  vim_cv_memmove_handles_overlap=yes \
  ./configure \
  --prefix="" \
  --sysconfdir=/etc \
  --disable-nls --disable-netbeans --disable-gui \
  --with-x=no --enable-multibyte --with-features=normal \
  --with-compiledby="<smlinux@pktsurf.in>" \
  --enable-terminal

  make
  make -j1 STRIP=true VIMRCLOC="$pkg"/etc install DESTDIR="$pkg" 

  cp *.md $pkgdocs/

  cd $pkg/bin
  ln -s vim vi

  mkfinalpkg
}

sha512sums="
0cd68de074962116b222dcbe918f36647fc0edc4c6e1520ec07ad837c868f502bd3f3d5c875570076d52fc335196014a42d9d7d860396c1f4aaeaf1ae1024267  vim-8.1.tar.lz
"
