#!/bin/sh
PKGNAM=xscreensaver
VERSION=5.07
BUILD=${BUILD:-2}

. /etc/pkghelpers
pkghelpers_env

rm -rf $PKG
cd $TMP
rm -rf xscreensaver-$VERSION
tar xjvf $CWD/xscreensaver-$VERSION.tar.bz2
cd xscreensaver-$VERSION

# Allow xscreensaver to work setgid shadow.  I'd rather avoid requiring
# setuid root on this if at all possible...
zcat $CWD/xscreensaver.setuid.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1

# Solve problem with RANDR reporting screens with 0x0 size
zcat $CWD/randr-nosize.patch.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1

pkghelpers_permissions
xml_config=/usr/bin/xml-config xml2_config=/usr/bin/xml2-config \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
	--libdir=/usr/lib$LIBSUFFIX \
  --mandir=/usr/man \
  --with-x-app-defaults=/etc/X11/app-defaults \
  --with-shadow \
  --with-jpeg \
  --with-gl \
  --build=$ARCH-$DISTRO-linux
# We use '-i' because xscreensaver's NLS support has always been horribly broken
make -i -j3
make -i install_prefix=$PKG install-strip
gzip -9 $PKG/usr/man/man?/*
chown root:shadow $PKG/usr/bin/xscreensaver
chmod 2751 $PKG/usr/bin/xscreensaver
# This is needed for the menus:
mkdir -p $PKG/usr/share/pixmaps
mkdir -p $PKG/etc
mkdir -p $PKG/usr/doc/xscreensaver-$VERSION
cp -a \
  README* \
  $PKG/usr/doc/xscreensaver-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
pkghelpers_fixup
pkghelpers_makepkg


