abinfo "Unsetting SRCDIR to work around variable name conflict ..."
_SRCDIR="$SRCDIR"
unset SRCDIR

abinfo "Setting STRIP environment variable to : (shell no-op) to supress internal strip ..."
export STRIP=":"

if ab_match_archgroup mainline ; then
	CONFIG_ARGS=(
		"--prefix=/usr"
		"--localstatedir=/var/lib/vim"
		"--with-features=huge"
		"--with-compiledby=Anthon Open Source Community"
		"--enable-gpm"
		"--enable-acl"
		"--with-x=yes"
		"--with-wayland=yes"
		"--enable-gui=no"
		"--enable-multibyte"
		"--enable-cscope"
		"--enable-netbeans"
		"--enable-perlinterp=dynamic"
		"--enable-pythoninterp=no"
		"--enable-python3interp=dynamic"
		"--enable-rubyinterp=dynamic"
		"--enable-luainterp=dynamic"
		"--enable-tclinterp=dynamic"
		"--enable-xim"
		"--enable-fontset"
	)
else
	# Maintainer note: Please enable full featureset.
	# Otherwise it will be very difficult to work with...
	# Note: It is okay without something like `"+y' (copy to X11
	# clipboard).
	CONFIG_ARGS=(
		"--prefix=/usr"
		"--localstatedir=/var/lib/vim"
		"--with-features=huge"
		"--with-compiledby=Anthon Open Source Community"
		"--enable-gpm"
		"--enable-acl"
		"--with-x=no"
		"--with-wayland=no"
		"--enable-gui=no"
		"--enable-multibyte"
		"--disable-cscope"
		"--disable-netbeans"
		"--enable-perlinterp=no"
		"--enable-pythoninterp=no"
		"--enable-python3interp=no"
		"--enable-rubyinterp=no"
		"--enable-luainterp=no"
		"--enable-tclinterp=no"
		"--disable-xim"
		"--disable-fontset"
	)
fi


abinfo "Configuring Vim ..."
"$_SRCDIR"/configure \
	"${CONFIG_ARGS[@]}"

abinfo "Re-setting SRCDIR ..."
SRCDIR="$_SRCDIR"

abinfo "Building Vim ..."
make V=1

abinfo "Installing Vim ..."
make install \
    -j1 \
    VIMRCLOC=/etc \
    V=1 \
    DESTDIR="$PKGDIR"

abinfo "Removing ex, view symlinks ..."
rm -v "$PKGDIR"/usr/bin/{ex,view}

abinfo "Removing ex, view man pages ..."
find "$PKGDIR"/usr/share/man -type d -name 'man1' 2>/dev/null | \
    while read _mandir; do
        cd ${_mandir}
        rm -fv ex.1 view.1
    done

abinfo "Removing gvim desktop entry..."
rm -v "$PKGDIR"/usr/share/applications/gvim.desktop

abinfo "Creating symbolic link for gvim manuals ..."
for mandir in $(ls "$PKGDIR"/usr/share/man) ; do
	# The manual page of vim and gvim are IDENTICAL to each other, even though it is weird that
	# we left gvim manual in non-gtk vim.
	ln -sfv vim.1 "$PKGDIR"/usr/share/man/$mandir/gvim.1
done
