#!/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-1.1 |"
echo "+===========+"
cd $TMP
tar xvzf $CWD/xfstt-1.1.tar.gz
cd xfstt-1.1
mkdir -p $PKG/usr/doc/xfstt-1.1
chown root.root $PKG/usr/doc/xfstt-1.1
chmod 755 $PKG/usr/doc/xfstt-1.1
cp CHANGES COPYING FAQ INSTALL README.txt THANKS.txt ttfont.html xfstt.lsm \
  font.properties $PKG/usr/doc/xfstt-1.1
chmod 644 $PKG/usr/doc/xfstt-1.1/*
chown root.root $PKG/usr/doc/xfstt-1.1/*
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-1.1
   rm -rf $PKG
fi
