#!/bin/sh
# Build script for: WvDial
# BuildRequires: wvstreams
# Distribution: Slackware Linux 11.0
# Packager baldelario ~at~ gmail ~dot~ com
# http://www.slacky.it
# Source location: http://open.nit.ca/wiki/?page=WvDial

CWD=`pwd`
if ["$TMP" = ""]; then
 TMP=/tmp
fi

NAME=wvdial
VERSION=1.56
ARCH=${ARCH:-i686}
BUILD=2bj
PKG=$TMP/package-$NAME
rm -rf $PKG

cd $TMP
rm -rf $NAME-$VERSION
tar xzvf $CWD/$NAME-$VERSION.tar.gz
cd $NAME-$VERSION
chown -R root:root .
zcat $CWD/Makefile.diff.gz | patch -p1 -f --verbose
make
make install DESTDIR=$PKG

strip $PKG/usr/bin/*
find $PKG/usr/man -type f -exec gzip -9 {} \;

# Add a sample config file
cat << EOF > $PKG/etc/wvdial.conf-sample
[Dialer Defaults]
Modem = /dev/ttyS2
Baud = 57600
Init = ATZ
Init2 = AT S11=50
Phone = 555-4242
Username = apenwarr
Password = my-password

[Dialer phone2]
Phone = 555-4243

[Dialer shh]
Init3 = ATM0

[Dialer pulse]
Dial Command = ATDP
EOF

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a CHANGES ChangeLog FAQ README TODO $PKG/usr/doc/$NAME-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc >$PKG/install/slack-desc
cat $CWD/doinst.sh >$PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild

cd $PKG
requiredbuilder -y -v -s $CWD $PKG
makepkg -p -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP/$NAME-$VERSION
  rm -rf $PKG
fi
