#!/bin/sh
# Heavily based on the Slackware 12.0 SlackBuild
# Homepage http://recordmydesktop.iovar.org
# Packager Gabriele Inghirami - suonodelsilenzio a-7 tiscalinet dO.t it

CWD=$(pwd)
ARCH="i486"
VERSION="0.3.7.3"
TMP=/tmp
PKG=$TMP/package-recordmydesktop
NAME="recordmydesktop"
BUILD=1gi

#crea la directory /tmp e quella per costruire il pacchetto se non esistono
if [ ! -d $TMP ]; then
	 mkdir -p $TMP
 fi
 if [ ! -d $PKG ]; then
	  mkdir -p $PKG
  fi

cd $TMP
tar zxfv $CWD/$NAME-$VERSION.tar.gz
cd $NAME-$VERSION
chown -R root:root .

echo " "
echo " "
echo " "
echo " Start SlackBuild $NAME-$VERSION "
echo " "
echo " "
echo " "

CFLAGS="-march=i486 -mtune=i686" ./configure --prefix=/usr --mandir=/usr/man

make
make install DESTDIR=$PKG

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a AUTHORS COPYING ChangeLog INSTALL NEWS README TODO $PKG/usr/doc/$NAME-$VERSION
gzip $PKG/usr/man/man1/*
cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
rm -rf $TMP/$NAME-$VERSION
rm -rf $PKG
fi
