#!/bin/sh
# Script for building GNOKII package
# Written by Pawe Kot <pkot@linuxnews.pl>

# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-xgnokii

VERSION=0.6.5
ARCH=${ARCH:-i486}
BUILD=1

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
rm -rf $PKG
mkdir -p $PKG

cd $TMP
rm -rf gnokii-$VERSION
tar xzvf $CWD/gnokii-$VERSION.tar.gz
cd gnokii-$VERSION
chown -R root.root .
./configure \
  --prefix=/usr \
  --sysconfdir=/etc \
  --program-prefix="" \
  --program-suffix="" \
  --enable-security \
  --with-x \
  --with-xgnokiidir=/usr/X11R6 \
  $ARCH-slackware-linux
make
# File permissions will be set by doinst.sh
make install-strip DESTDIR=$PKG
make install-docs DESTDIR=$PKG

gzip -9 $PKG/usr/man/man?/*
# Default config
mkdir -r $PKG/etc
cp Docs/sample/gnokiirc $PKG/etc/gnokiirc.new
mkdir -p $PKG/install
cat $CWD/slack-desc-xgnokii > $PKG/install/slack-desc
cat $CDW/doinst-xgnokii.sh > $PKG/install/doinst.sh

# Build the package:
cd $PKG
makepkg -l y -c n $TMP/xgnokii-$VERSION-$ARCH-$BUILD.tgz

# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP/gnokii-$VERSION
  rm -rf $PKG
fi
