#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://www.quitte.de/dsp/caps.html
# Packagers Andrea Sciucca Gohanz ( gohanz@infinito.it)
# http://www.slacky.eu
# Required: LadSpa

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-caps
NAME=caps
VERSION=0.4.2
ARCH=i686
BUILD=2as

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

echo "+---------------------------------+"
echo "| Starting SlackBuild  $NAME-$VERSION |"
echo "+---------------------------------+"

cd $NAME-$VERSION

find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;

make

mkdir -p $PKG/usr/lib/ladspa/rdf
install -m 644 caps.so $PKG/usr/lib/ladspa
cp -a *.rdf $PKG/usr/lib/ladspa/rdf

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a CHANGES COPYING README* $PKG/usr/doc/$NAME-$VERSION
mkdir -p $PKG/install
cp -a *.html $PKG/usr/doc/$NAME-$VERSION

cat $CWD/slack-desc > $PKG/install/slack-desc
cd $CWD
cp -a *.SlackBuild slack-desc $PKG/usr/doc/$NAME-$VERSION

cd $PKG
chown -R root:root .
ADD="ladspa >= 1.13-i686-1sl" \
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
