#!/bin/sh
# Heavily based on the Slackware 12.2 SlackBuild
# http://www.bottlenose.demon.co.uk/share/evolvotron/index.htm
# Packager Gohanz ( gohanz@infinito.it )
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-evolvotron
NAME=evolvotron
VERSION=0.5.1
BUILD=3as
ARCH=i686

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

cd $TMP
tar xvzf $CWD/$NAME-$VERSION.tar.gz
cd $NAME

chown -R root:root .
./configure
make

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a BUGS CHANGES LICENSE  README TODO USAGE $PKG/usr/doc/$NAME-$VERSION

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

mkdir -p $PKG/usr/bin
cp -f $TMP/$NAME/evolvotron/evolvotron  $PKG/usr/bin/evolvotron
cp -f $TMP/$NAME/evolvotron_render/evolvotron_render  $PKG/usr/bin/evolvotron_render
cp -f $TMP/$NAME/evolvotron_mutate/evolvotron_mutate  $PKG/usr/bin/evolvotron_mutate
cp -f $TMP/$NAME/evolvotron_match/evolvotron_match  $PKG/usr/bin/evolvotron_match
mkdir -p $PKG/usr/man/man1/
cp -f $TMP/$NAME/man/man1/* $PKG/usr/man/man1/
gzip $PKG/usr/man/man1/*
strip $PKG/usr/bin/*

cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
cd $PKG
requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP
fi
