#!/bin/sh
#
# Copyright 2004 Dagmar d'Surreal <rivyqntzne@tznvy.pbz>
# Available under the terms of the GNU GPL.
#
# Most of the oddball things in this definition are straight from the spec
# file jwz ships with the source code... otherwise these would be a pain.
# This package should be built sometime after gdm is built.

NAME="xscreensaver"
VERSION="4.22"
REVISION="1"

PKG_SOURCEURL='http://www.jwz.org/$NAME/$NAME-$VERSION.tar.gz'
PKG_PATCH[0]="xscreensaver-4.1.5-menu.patch"
PKG_DESTDIRVAR=install_prefix

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

configfile /etc/pam.d/xscreensaver

cflags
cxxflags
prepare

applypatch 0 1

analyzesource
# Many of these are redundant, but I don't have time to triple check
# everything right now.  --Dagmar
configure --with-gtk2 \
        --without-shadow \
        --with-pam \
        --without-kerberos \
        --with-gl \
        --with-dpms-ext \
        --with-xinerama-ext 
make

# Somewhat hacked up PAM support/workarounds.
PAM_DIR=$PKG_SYSCONFDIR/pam.d
spewdo "createdir $PKG_STAGEROOT$PAM_DIR"
if [ -r $PKG_SYSCONFDIR/pam.d/xdm ]; then
  spewdo "cp $PAM_DIR/xdm $PKG_STAGEROOT$PAM_DIR/xdm"
elif [ -r $PKG_SYSCONFDIR/pam.d/login ]; then
  spewdo "cp $PAM_DIR/login $PKG_STAGEROOT$PAM_DIR/xdm"
fi
unset PAM_DIR
makeinstall install-strip
loggedcommand install-2 "( cd $PKG_SRCROOT ; install -m 4755 driver/xscreensaver $PKG_STAGEROOT$PKG_PREFIX/bin )"
spewdo "rm $PKG_STAGEROOT$PKG_SYSCONFDIR/pam.d/xdm"
#loggedcommand install-pam "( cd $PKG_SRCROOT/driver ; mkdir -p $PKG_STAGEROOT$PKG_SYSCONFDIR/pam.d ; make install_prefix=$PKG_STAGEROOT PAM_DIR=$PKG_SYSCONFDIR/pam.d install-pam )"
spewdo "chmod -R a+r,u+w,og-w $PKG_STAGEROOT"
spewdo "rm $PKG_STAGEROOT$PKG_SYSCONFDIR/xdm"

obtainfile location XScreenSaver.ad
if [ ! -z "$location" ]; then
  spewdo "cp $location $PKG_STAGEROOT$PKG_PREFIX/X11R6/lib/X11/app-defaults/XScreenSaver"
fi


tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
