# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../vim/vim.conf
# Copyright (C) 2006 - 2007 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

# apply the patches defined in the vim.desc
for x in $( match_source_file -p patch ); do
	var_append patchfiles ' ' "$x"
done

vim_postmake() {
	if [ "$SDECFG_PKG_VIM_TWO_BINARIES" ] ; then
	  rm -fv $root$bindir/{gvim,gvimdiff,evim,rgvim}
	  mv -fv $root$bindir/vim $root$bindir/gvim
	  ln -sf gvim $root$bindir/gvimdiff
	  ln -sf gvim $root$bindir/evim
	  ln -sf gvim $root$bindir/rgvim

	  var_append confopt ' ' "--enable-gui=no --without-x"

	  echo "Running ./configure $confopt ..."
	  eval_config_command $( echo $confopt )
	  echo "Running $MAKE $makeopt ..."
	  eval $MAKE $makeopt
	  cp -v src/vim $root$bindir/vim
	fi

	if [ "$SDECFG_PKG_VIM_IS_VI_REPLACEMENT" = 1 ] ; then
          rm -f $root$bindir/vi
	  ln -sf vim $root$bindir/vi
	fi

	# now hopefully all are happy ;-)
	cp -fv $confdir/vimrc* $root/$prefix/share/vim/
}

var_append extraconfopt ' ' "--with-features=$SDECFG_PKG_VIM_FEATURES"
var_append extraconfopt ' ' "--enable-gui=$SDECFG_PKG_VIM_GUI"
[ "$SDECFG_PKG_VIM_PERLINTERP" = 1 ] && \
	var_append extraconfopt ' ' "--enable-perlinterp"
[ "$SDECFG_PKG_VIM_PYTHONINTERP" = 1 ] && \
	var_append extraconfopt ' ' "--enable-pythoninterp"
[ "$SDECFG_PKG_VIM_RUBYINTERP" = 1 ] && \
	var_append extraconfopt ' ' "--enable-rubyinterp"
[ "$SDECFG_PKG_VIM_TCLINTERP" = 1 ] && \
	var_append extraconfopt ' ' "--enable-tclinterp --with-tclsh=tclsh"
hook_add postmake 5 "vim_postmake"