IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

# main source
VERSION=2.0.6
# plugins
PLUGVER=2.0.1
# libfribidi
FRIBVER=0.10.4
# libwpd
WPDVER=0.6.6
PROGNAME="AbiWord Personal $VERSION"
DESC="\
abiword (AbiWord Personal)                                             \n\
                                                                       \n\
AbiWord Personal is a lean and fast full-featured word processor.      \n\
It can import many formats including Word97/2000 and RTF, Palm, Psion, \n\
DocBook and XHTML documents, and can export to RTF, Palm, Psion,       \n\
XHTML, Text, and LaTeX formats.                                        \n\
                                                                       \n\
Linux Journal calls it \"an elegant, open source word processor that   \n\
delivers the Word functionality most people use.\""

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://www.abisource.com/download/
PKGNAME=abiword-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   tar -yxvf $CWD/fribidi-$FRIBVER.tar.bz2
   cd fribidi-$FRIBVER
   chown -R root.root .
   CFLAGS=-O2 \
   ./configure --prefix=/usr \
               --enable-shared=no \
               --with-pic
   make
   # Man, I hate to do this.
   make install

   cd $TMP
   tar -yxvf $CWD/libwpd-$WPDVER.tar.bz2
   cd libwpd-$WPDVER
   chown -R root.root .
   find . -perm 664 -exec chmod 644 {} \;
   CFLAGS=-O2 \
   ./configure --prefix=/usr \
               --enable-shared=no \
               --enable-static \
               --with-pic
   make
   # This too.
   make install

   cd $TMP
   tar -yxvf $CWD/abiword-$VERSION.tar.bz2
   cd abiword-$VERSION/
   tar -yxvf $CWD/abiword-plugins-$PLUGVER.tar.bz2
   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/
   CFLAGS=-O2 CXXFLAGS=-O2 \
   ./configure --prefix=/usr \
               --build=s390-slackware-linux \
               --host=s390-slackware-linux \
               --target=s390-slackware-linux
   make
   cd ../abiword-plugins
   ./configure --prefix=/usr
   make
}

install() {
   cd $TMP/fribidi-$FRIBVER
   make install DESTDIR=/package-abiword

   mkdir -p /package-abiword/usr/doc/fribidi-$FRIBVER
   cp -a ANNOUNCE AUTHORS COPYING NEWS README THANKS TODO \
       /package-abiword/usr/doc/fribidi-$FRIBVER

   cd $TMP/libwpd-$WPDVER
   make install DESTDIR=/package-abiword

   mkdir -p /package-abiword/usr/doc/libwpd-$WPDVER
   cp -a CHANGES COPYING INSTALL TODO \
       /package-abiword/usr/doc/libwpd-$WPDVER

   cd $TMP/abiword-$VERSION/abi
   make install DESTDIR=/package-abiword

   mkdir -p /package-abiword/usr/doc/abiword-$VERSION/docs
   cp -a BUILD.TXT BiDiReadme.txt COPYING COPYRIGHT.TXT CREDITS.TXT README.TXT \
       /package-abiword/usr/doc/abiword-$VERSION
   cp -a docs/*.abw /package-abiword/usr/doc/abiword-$VERSION/docs/

   ( cd ../abiword-plugins
     make install DESTDIR=/package-abiword
   )

   mkdir -p /package-abiword/usr/share/gnome/apps/Applications/
   cp -p src/pkg/linux/rpm/data/abiword.desktop /package-abiword/usr/share/gnome/apps/Applications/

   mkdir -p /package-abiword/usr/man/man8/
   cat ../abiword-docs/man/abiword.8 | gzip -9c > /package-abiword/usr/man/man8/abiword.8.gz

   cp -a ../abiword-docs/Manual/en/Abiword_Manual.abw /package-abiword/usr/doc/abiword-$VERSION/docs/
}

attributes() {
   chown -R root.bin $PKG/package-abiword/usr/bin
}

special() {
   cd $PKG
   mv package-abiword/* ./
   rmdir package-abiword

   cd $CTL
   cat $CWD/slack-desc > slack-desc
   sed -e 's%package-abiword/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

