#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
   TMP=/tmp
fi
PKG=$TMP/package-vr-glide

if [ ! -d $TMP ]; then
   mkdir -p $TMP # location to build the source
fi
if [ ! -d $PKG ]; then
   mkdir -p $PKG # place for the package to be built
fi

# explode the package framework
cd $PKG
tar xvzf $CWD/_vr-glide.tar.gz

echo "+=====================+"
echo "| Glide - Voodoo Rush |"
echo "+=====================+"
( cd $PKG/usr/bin ; ln -sf testGlide2x test3Dfx )
( cd $PKG/usr/lib ; ln -sf libglide.so.2.46 libglide.so.2 )
( cd $PKG/usr/lib ; ln -sf libglide.so.2 libglide.so )
( cd $PKG/usr/lib ; ln -sf libglide.so.2.46 libglide2x.so.2 )
( cd $PKG/usr/lib ; ln -sf libglide2x.so.2 libglide2x.so )
( cd $PKG/usr/lib ; ln -sf libtexus.so.1.1 libtexus.so.1 )
( cd $PKG/usr/lib ; ln -sf libtexus.so.1 libtexus.so )
strip $PKG/usr/bin/*

# make the package
cd $PKG
echo "y
n" | makepkg $TMP/vr-glide.tgz

# clean up the extra stuff
if [ "$1" = "--cleanup" ]; then
   rm -rf $PKG
fi
