#!/bin/bash
# Heavily based on the Slackware 12.0 SlackBuild
# http://www.insilmaril.de/vym/

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-vym
NAME=vym
VERSION=1.10.0
ARCH=i686
BUILD=1pfb

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

echo "+================+"
echo "| $NAME-$VERSION |"
echo "+================+"
cd $TMP
tar xjvf $CWD/$NAME-$VERSION.tar.bz2
cd $NAME-$VERSION
chown -R root:root .
sed -i "s|/usr/share/doc/packages/vym/doc/vym.pdf|/usr/doc/vym-1.10.0/vym.pdf|g" mainwindow.cpp
/opt/qt4/bin/qmake
make
mkdir -p $PKG/usr/bin
cp vym $PKG/usr/bin
mkdir -p $PKG/usr/share/vym
cp -ar demos  icons  lang  scripts  styles $PKG/usr/share/vym
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a doc/* LICENSE $PKG/usr/doc/$NAME-$VERSION
strip $PKG/usr/bin/*
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
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

