CWD=`pwd`
PKG=/tmp/package-aspell
rm -rf $PKG
mkdir -p $PKG/usr

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

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 xzvf $CWD/aspell-$VERSION.tar.gz
cd aspell-$VERSION
chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --enable-pkgdatadir=/usr/lib/aspell \
  --enable-data-dir=/usr/lib/aspell \
  --enable-pkglibdir=/usr/lib/aspell \
  --enable-dict-dir=/usr/lib/aspell
make
make install
ldconfig
make install DESTDIR=$PKG
chown -R root.bin $PKG/usr/bin
( cd $PKG
  find . | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
)
rm $PKG/usr/info/dir
## This looks like crap clutter to me
## ... turns out to be required.  How ugly...
#rm -f $PKG/usr/bin/pre*
gzip -9 $PKG/usr/info/*
gzip -9 $PKG/usr/man/man?/*.?
mkdir -p $PKG/usr/doc/aspell-$VERSION
cp -a \
  COPYING README TODO \
  $PKG/usr/doc/aspell-$VERSION
mv $PKG/usr/share/doc/aspell/*html $PKG/usr/doc/aspell-$VERSION
rm -rf $PKG/usr/share/doc
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd /tmp/package-aspell
makepkg -l y -c n ../aspell-$VERSION-$ARCH-$BUILD.tgz