CWD=`pwd`

VERSION=2.6.1
ARCH=${ARCH:-i486}

if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2"
fi

cd /tmp
tar xjvf $CWD/gnome-games-$VERSION.tar.bz2
cd gnome-games-$VERSION
chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --with-ncurses=/usr \
  --sysconfdir=/etc \
  --localstatedir=/var/lib \
  --enable-static=no \
  --with-scores-group=games \
  --with-scores-user=root \
  $ARCH-slackware-linux
make -j3
make install
mkdir -p /usr/doc/gnome-games-$VERSION
cp -a \
  AUTHORS COPYING COPYING-DOCS HACKING MAINTAINERS NEWS README TODO \
  /usr/doc/gnome-games-$VERSION
mkdir -p /install
cat << EOF > /install/doinst.sh
if [ -d var/lib/games/tmp ]; then
  ( cd var/lib/games/tmp
    for file in * ; do
      if [ ! -r ../\$file ]; then
        mv \$file ..
      fi
    done )
  rm -rf var/lib/games/tmp
fi
EOF
zcat $CWD/doinst.sh.gz >> /install/doinst.sh
# Fix directory perms:
chown root:games /var/lib/games
chmod 775 /var/lib/games
cat $CWD/../scrollkeeper/doinst.sh >> /install/doinst.sh
cat $CWD/slack-desc > /install/slack-desc
( cd /var/lib/games
  mkdir tmp
  mv --verbose *.* tmp )
( cd /usr/bin
  chown root:bin blackjack gataxx gnect iagno sol
)
cat << EOF


Check these dir perms!

drwxrwxr-x    3 root     games        4096 Jan 22 15:21 /var/lib/games/


EOF
