#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-qstardict
VERSION=0.12.9
BUILD=rpz
ARCH=i686

rm -rf $PKG
mkdir -p $PKG/usr

# Avoid a version number in .la files:
if [ -d /opt/qt4 ]; then
  QTDIR=/opt/qt4
fi
cd $TMP

if [ ! -e $CWD/qstardict-$VERSION.tar.bz2 ]; then
    echo "Fetching qstardict"
    wget "http://qstardict.ylsoftware.com/files/qstardict-$VERSION.tar.bz2" -O $CWD/qstardict-$VERSION.tar.bz2
fi    

echo "Building qstardict-$VERSION.tar.bz2..."
tar xjvf $CWD/qstardict-$VERSION.tar.bz2

# I *hate* it when an "a" release blows off updating the directory name.  Grrrrrrrrrrrrrrrr.
# Commented out post 1.4.0a...
#cd amarok-1.4.0 || exit 1
cd qstardict-$VERSION


chown -R root:root .
$QTDIR/bin/qmake
make
export INSTALL_ROOT=$PKG && make install
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

( 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
)
if [ -d $PKG/usr/man ]; then
  gzip -9 $PKG/usr/man/man?/*
fi

cd $PKG
makepkg -l y -c n ../qstardict-$VERSION-$ARCH-$BUILD.tgz

