#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-abiword
VERSION=2.2.2
FVER=0.10.4
WVER=0.7.2
EVER=1.1.5
ARCH=alpha
BUILD=1
TARGET=$ARCH-slackware-linux

( cd $TMP
rm -rf fribidi-$FVER
tar xjf $CWD/fribidi-$FVER.tar.bz2
cd fribidi-$FVER
chown -R root.root .
./configure --prefix=/usr --enable-shared=no --with-pic $TARGET
make
make install DESTDIR=$PKG
make install
strip -g $PKG/usr/lib/libfribidi.a
mkdir -p $PKG/usr/doc/fribidi-$FVER
cp -a ANNOUNCE AUTHORS COPYING NEWS README THANKS TODO $PKG/usr/doc/fribidi-$FVER

cd $TMP
rm -rf libwpd-$WVER
tar xzf $CWD/libwpd-$WVER.tar.gz
cd libwpd-$WVER
chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
./configure --prefix=/usr --enable-shared=no --enable-static --with-pic $TARGET
make
make install DESTDIR=$PKG
make install
strip -g $PKG/usr/lib/libwpd-1.a
mkdir -p $PKG/usr/doc/libwpd-$WVER
cp -a CHANGES COPYING INSTALL TODO $PKG/usr/doc/libwpd-$WVER

cd $TMP
rm -rf enchant-$EVER
tar xzf $CWD/enchant-$EVER.tar.gz
cd enchant-$EVER
chown -R root.root .
./configure --prefix=/usr --enable-shared=no --with-pic $TARGET
make
make install DESTDIR=$PKG
make install
mkdir -p $PKG/usr/doc/enchant-$EVER
cp -a COPYING.LIB NEWS README TODO $PKG/usr/doc/enchant-$EVER

cd $TMP
rm -rf abiword-$VERSION
tar xjf $CWD/abiword-$VERSION.tar.bz2
cd abiword-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
cd abi
./configure --prefix=/usr $TARGET
make
make install DESTDIR=$PKG
mkdir -p $PKG/usr/doc/abiword-$VERSION/docs
cp -a BUILD.TXT BiDiReadme.txt COPYING COPYRIGHT.TXT CREDITS.TXT README.TXT $PKG/usr/doc/abiword-$VERSION
cp -a docs/*.abw $PKG/usr/doc/abiword-$VERSION/docs
cd ../abiword-docs/man
# 8?
mkdir -p $PKG/usr/man/man1
cat abiword.1 | gzip -9c > $PKG/usr/man/man1/abiword.1.gz
cd ..
cp -a Manual/en/Abiword_Manual.abw $PKG/usr/doc/abiword-$VERSION/docs
cd ../abiword-plugins
./configure --prefix=/usr --without-ots --without-gda --without-aiksaurus --without-psion --without-magick $TARGET
make
make install DESTDIR=$PKG
strip --strip-unneeded $PKG/usr/bin/* $PKG/usr/lib/AbiWord-2.2/plugins/*.so
gzip -9 $PKG/usr/man/man?/*
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/abiword-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/abiword.build.log
