#!/bin/bash
# Build domino 0.4 LZM module

# Contributor: Alexander Markov <apsheronets@gmail.com>
# Domino is a style with a soft look. It allows to fine adjust the shininess of the widgets by customizable color gradients.
# http://www.kde-look.org/content/show.php?content=42804

pkgname=kdestyle-domino
pkgver=0.4
pkgrel=3
arch=i486
startdir=`pwd`

# Make temporary directories
mkdir src/
mkdir pkg/

# Download sources
wget -c "http://www.kde-look.org/CONTENT/content-files/42804-domino-${pkgver}.tar.bz2"
# Downloading patches (ArchLinux AUR :)
wget -c \
"http://aur.archlinux.org/packages/kdestyle-domino/kdestyle-domino/domino-0.4_indicate_focus_on_qtoolbuttons.patch" \
"http://aur.archlinux.org/packages/kdestyle-domino/kdestyle-domino/domino-0.4_reset_global_config_group.patch"

tar -xf 42804-domino-${pkgver}.tar.bz2 -C src/
cd ${startdir}/src/domino-${pkgver}

# Build
cd ${startdir}/src/domino-${pkgver}/
patch -p0 -i ${startdir}/domino-0.4_indicate_focus_on_qtoolbuttons.patch
patch -p0 -i ${startdir}/domino-0.4_reset_global_config_group.patch
[ "$QTDIR" = "" ] && source /etc/profile.d/qt3.sh
[ "$KDEDIR" = "" ] && source /etc/profile.d/kde.sh
CFLAGS="-O3 -march=i486 -mtune=i686" ./configure --prefix=/usr --build=i486-Slackware-linux
make || exit
make DESTDIR=${startdir}/pkg/ install
cd ${startdir}/

# Copy slaxbuild
mkdir -p ${startdir}/pkg/usr/src/slaxbuilds/
cp $0 ${startdir}/pkg/usr/src/slaxbuilds/

# Clean
find ${startdir}/pkg/ -type d | xargs chmod -v 755;
find ${startdir}/pkg/usr/man/ -type l -name "*.gz" | xargs -r gunzip -f
find ${startdir}/pkg/usr/man/ ! -type l -name "*.gz" | xargs -r gunzip
find ${startdir}/pkg/ | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded

# Make module
dir2lzm ${startdir}/pkg/ ${startdir}/${pkgname}-${pkgver}-${arch}-${pkgrel}.lzm && echo || exit

echo 'Remove temporary files (pkg/ and src/)'
rm -r ${startdir}/pkg/ ${startdir}/src/
