#!/bin/sh
# Build script for vim
# Vi IMproved text editor

set -e

echo "Building vim..."

cd vim-9.1.0000

# On illumos, use GNU make
MAKE=gmake
if [ "$(uname -s)" != "SunOS" ]; then
    MAKE=make
fi

# Configure with minimal features for testing
# (Full vim would have more options)
./configure \
    --prefix=/usr \
    --with-features=normal \
    --enable-multibyte \
    --disable-gui \
    --without-x \
    --disable-netbeans \
    --enable-cscope

# Build
$MAKE ${MAKEFLAGS}

# Install to DESTDIR
echo "Installing to ${DESTDIR}..."
$MAKE DESTDIR="${DESTDIR}" install

# Create vi symlink
cd "${DESTDIR}/usr/bin"
ln -sf vim vi 2>/dev/null || true

echo "Build complete!"
