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

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
explodepkg $CWD/_xfstt.tar.gz

echo "+==============+"
echo "| xfstt-0.9.99 |"
echo "+==============+"
cd $TMP
tar xvzf $CWD/xfstt-0.9.99.tar.gz
cd xfstt-0.9.99
mkdir -p $PKG/usr/doc/xfstt-0.9.99
chown root.root $PKG/usr/doc/xfstt-0.9.99
chmod 755 $PKG/usr/doc/xfstt-0.9.99
cp CHANGES COPYING FAQ INSTALL README.txt THANKS.txt ttfont.html xfstt.lsm \
  font.properties $PKG/usr/doc/xfstt-0.9.99
chmod 644 $PKG/usr/doc/xfstt-0.9.99/*
chown root.root $PKG/usr/doc/xfstt-0.9.99/*
make
strip xfstt
cat xfstt > $PKG/usr/X11R6/bin/xfstt
cat xfstt.1x | gzip -9c > $PKG/usr/X11R6/man/man1/xfstt.1.gz

# build the package
cd $PKG
echo "n" | makepkg $TMP/xfstt.tgz

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