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

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/_dev3dfx.tar.gz

echo "+============+"
echo "| Device3Dfx |"
echo "+============+"
cd $TMP
tar xvzf $CWD/Device3Dfx.tar.gz
cd Device3Dfx
cp -a * $PKG/usr/src/Device3Dfx
cd $PKG/usr/src
chown -R root.root *
chmod 644 Device3Dfx/*

# make the package
cd $PKG
echo "n" | makepkg $TMP/dev3dfx.tgz

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