#!/bin/sh
# Heavily based on the Slackware 11.0 SlackBuild
# http://freehackers.org/~tnagy/kdissert.html
# Packager baldelario ~at~ gmail ~dot~ com
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-$HOME/tgz}
PKG=$TMP/package-kdissert
NAME=kdissert
VERSION=1.0.7
ARCH=${ARCH:-i486}
BUILD=1bj

if [ $UID -eq 0 ]; then
   echo "Bisogna essere user per eseguire questo script!"
   exit 1
fi

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

cd $TMP
tar xvjf $CWD/$NAME-$VERSION.tar.bz2
cd $NAME-$VERSION
CFLAGS="-O2 -march=i486 -mtune=i686"
./waf configure --prefix=/opt/kde \
--qtincludes=/usr/lib/qt/include \
--kdeincludes=/opt/kde/include \
--kdedir=/opt/kde
./waf build -j3
echo "Digita la password di root per avviare la creazione del pacchetto."

su -c "./waf install --destdir=$PKG
strip --strip-unneeded $PKG/opt/kde/lib/kde3/*.so
strip $PKG/opt/kde/bin/*
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a AUTHORS COPYING ROADMAP INSTALL README $PKG/usr/doc/$NAME-$VERSION
cp -a $CWD/{*.SlackBuild,slack-desc} $PKG/usr/doc/$NAME-$VERSION
mkdir -p $PKG/install  
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG ; chown -R root:root .
requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz
rm -rf $TMP
"
