#!/bin/sh
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-orbit

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

cd $TMP
tar xzvf $CWD/ORBit-0.5.8.tar.gz
cd ORBit-0.5.8
./configure --prefix=/opt/gnome \
            --sysconfdir=/etc/opt/gnome \
            sparc-slackware-linux
make CFLAGS=-O2
make DESTDIR=$PKG CFLAGS=-O2 install
mkdir -p $PKG/usr/doc/ORBit-0.5.8
cp -a  AUTHORS COPYING NEWS README TODO \
   libIDL/COPYING libIDL/AUTHORS \
   libIDL/README* libIDL/NEWS libIDL/BUGS libIDL/tstidl.c \
   $PKG/usr/doc/ORBit-0.5.8
chown -R root.root $PKG/usr/doc/ORBit-0.5.8

# Build the package:
cd $PKG
echo "y
n" | makepkg $TMP/orbit.tgz

# Warn of zero-length files:
for file in `find . -type f -print` ; do
 if [ "`filesize $file`" = "0" ]; then
  echo "WARNING: zero length file $file"
 fi
 if [ "`filesize $file`" = "20" ]; then
  echo "WARNING: possible empty gzipped file $file"
 fi
done

# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP/ORBit-0.5.8
  rm -rf $PKG
fi
