#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi

VERSION=6.2.4
ARCH=i486
BUILD=1

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

cd $TMP
tar xjvf $CWD/fetchmail-$VERSION.tar.bz2
cd fetchmail-$VERSION

# this is the sloppiest source tarball ever
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="-O2 -march=i486 -mcpu=i686" LDFLAGS=-s ./configure \
  --prefix=/usr \
  --enable-nls \
  --with-ssl \
  i486-slackware-linux
make
make install
mkdir -p /usr/doc/fetchmail-$VERSION
cp -a \
  ABOUT-NLS COPYING FAQ FEATURES INSTALL MANIFEST NEWS NOTES README README.NTLM README.SSL TODO \
  *.html contrib *.lsm \
  /usr/doc/fetchmail-$VERSION
rm -rf /usr/doc/fetchmail-$VERSION/RCS /usr/doc/fetchmail-$VERSION/contrib/RCS
mkdir -p /install
cat $CWD/slack-desc > /install/slack-desc