#!/bin/sh
# Build Mutt for Slackware (by volkerdi@slackware.com)
# Patched by Alvaro Figueroa (fede2@fuerzag.ulatina.ac.cr) to make it work
# on Splack

CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-mutt

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi

cd $TMP
tar xzvf $CWD/mutt-1.2.5.1.tar.gz
cd mutt-1.2.5.1
CFLAGS=-O2 ./configure \
           --prefix=/usr \
           --sysconfdir=/etc/mutt \
           --with-mailpath=/var/spool/mail \
           --with-charmaps=/usr/share/i18n/charmaps \
           --enable-pop \
           --enable-imap \
           --enable-locales-fix \
           sparc-slackware-linux

make
make install prefix=$PKG/usr

# Build the package:
cd $PKG
echo "y
n" | makepkg $TMP/mutt.tgz


# Warn of zero-length files:
for file in `find . -type f -print` ; do
 if [ "`filesize $file`" = "0" ]; then
  echo "WARNING: zero length file $file"
 fi
 if [ "`filesize $file`" = "20" ]; then
  echo "WARNING: possible empty gzipped file $file"
 fi
done

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