#!/bin/sh

# SlackBuild script for dbus-qt3 bindings

# Written by Robby Workman <http://rlworkman.net>

# I realize that this is a very generic script, but PiterPunk deserves
# credit for it, as I just took his and changed a few things to be
# more consistent with my usual style...

# In case you're curious as to why we're not using the qt bindings 
# on the dbus.freedesktop.org page, it's because they were back-ported
# from the qt4 bindings, and they won't compile against kde-3.5.x
# See Comment #'s 5 and 6 of http://bugs.kde.org/show_bug.cgi?id=131035
# for more information. 

# Source obtained from the Gentoo repository
# http://ftp.osuosl.org/pub/gentoo/distfiles/dbus-qt3-0.70.tar.bz2

PRGNAM=dbus-qt3
VERSION=0.70
ARCH=${ARCH:-i486}
BUILD=${BUILD:-2}

CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=${TMP}/package-$PRGNAM

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
fi

rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xjf $CWD/$PRGNAM-$VERSION.tar.bz2 || true
cd $PRGNAM-$VERSION || true
chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;

CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --enable-static=no \
  --build=$ARCH-slackware-linux

make -j6 || exit 1
make install DESTDIR=$PKG

( 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/usr/doc/$PRGNAM-$VERSION
cp -a AUTHORS COPYING INSTALL NEWS README $PKG/usr/doc/$PRGNAM-$VERSION

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $TMP/$PRGNAM-$VERSION-$ARCH-$BUILD.tgz