#!/bin/sh

PREFIX=/usr
DOCPREFIX=${DOCPREFIX:-/usr/share/doc}

ORIGVER=0.12
PKGVER=P1

PACKAGE=gtk_engines1-$ORIGVER-i386-$PKGVER.tgz
SRCURL1=http://ftp.gnome.org/pub/GNOME/sources/gtk-engines/0.12/gtk-engines-0.12.tar.gz
SRC1=gtk-engines-$ORIGVER.tar.gz
SRCDIR1=gtk-engines-$ORIGVER

TMPDIR=`pwd`
SRCROOT=`pwd`
BUILDROOT=$TMPDIR/.work
PKGROOT=$BUILDROOT/pkgroot
PKGPREFIX=$PKGROOT$PREFIX

if [ ! -f $SRC1 ]; then
    wget -O $SRC1 $SRCURL1
fi

mkdir -p $BUILDROOT
chown 0.0 $BUILDROOT
chmod 0755 $BUILDROOT
cd $BUILDROOT
tar zxf $SRCROOT/$SRC1

cd $SRCDIR1
./configure --prefix=$PREFIX || exit 1
make || exit 1
make install DESTDIR=$PKGROOT || exit 1
mkdir -p $PKGROOT$DOCPREFIX/$SRCDIR1/build
cp AUTHORS COPYING ChangeLog INSTALL README README.win32 $PKGROOT$DOCPREFIX/$SRCDIR1
cp $SRCROOT/$0 $PKGROOT$DOCPREFIX/$SRCDIR1/build

gzip $PKGROOT$DOCPREFIX/$SRCDIR1/*
(
    cd $PKGPREFIX/lib/gtk/themes/engines
    rm -f *.la
    strip *
)

cd $PKGROOT
makepkg $PACKAGE

cp -f $PACKAGE $SRCROOT
cd $SRCROOT
rm -rf $BUILDROOT
