CWD=`pwd`
PKG=/tmp/package-xine-lib
rm -rf $PKG
mkdir -p $PKG/usr

VERSION=1.0
PKGVER=1.0
# I would use "-march=i486 -mcpu=i686" here as usual, but with XINE it's all or nothing.
# I'd rather have it work well for the i686/Athlon crowd than suck for everyone.
# (obviously, this won't apply to the SPARC architecture --JMD)
ARCH=${ARCH:-sparc}
TARGET=${TARGET:-$ARCH-pc-linux-gnu}
BUILD=0

cd /tmp
rm -rf xine-lib-$VERSION
tar xjvf $CWD/xine-lib-$VERSION.tar.bz2
cd xine-lib-$VERSION

zcat $CWD/patches-splack/xine_lib-1.0-configuretailfix-1.diff.gz | \
  patch -p0 --verbose

chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
XINE_BUILD=$TARGET \
./configure --prefix=/usr
make -j3
make install DESTDIR=$PKG
chown -R root.bin $PKG/usr/bin
( cd $PKG
  find . | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
)
( cd $PKG/usr/man
  find . -name "*.?" | xargs gzip -9
)
mkdir -p $PKG/usr/doc/xine-lib-$VERSION
cp -a \
  ABOUT-NLS AUTHORS COPYING CREDITS NEWS README TODO \
  doc \
  $PKG/usr/doc/xine-lib-$VERSION
# redundant
rm -rf $PKG/usr/share/doc
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd /tmp/package-xine-lib
makepkg -l y -c n ../xine-lib-$PKGVER-$ARCH-$BUILD.tgz

