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

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

echo "+===========+"
echo "| amp-0.7.6 |"
echo "+===========+"
cd $TMP
tar xzvf $CWD/amp-0.7.6.tar.gz
cd amp-0.7.6
./configure --prefix=/usr
make
strip amp
cat amp > $PKG/usr/bin/amp
cat amp.1 | gzip -9c > $PKG/usr/man/man1/amp.1.gz
cp BUGS $PKG/usr/doc/amp-0.7.6
cp CHANGES $PKG/usr/doc/amp-0.7.6
cp README $PKG/usr/doc/amp-0.7.6
cp TODO $PKG/usr/doc/amp-0.7.6
cp doc/jukebox.txt $PKG/usr/doc/amp-0.7.6
cp doc/layer2.txt $PKG/usr/doc/amp-0.7.6
cp doc/linuxrealtime.txt $PKG/usr/doc/amp-0.7.6
cp doc/BeOS.txt $PKG/usr/doc/amp-0.7.6
chown root.root $PKG/usr/doc/amp-0.7.6/*
chmod 644 $PKG/usr/doc/amp-0.7.6/*

# Build the package:
cd $PKG
tar czvf $TMP/amp.tgz .

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