#!/bin/sh
# Build HaXml for Slackware (by arossato@istitutocolli.org)
CWD=`pwd` 

VERSION=1.13.2
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1ar}


PKG=/tmp/package-HaXml
rm -rf $PKG
mkdir $PKG
cd /tmp
rm -rf HaXml
tar xzvf $CWD/HaXml-$VERSION.tar.gz
cd `basename HaXml-$VERSION i`

chown -R root:root .

runhaskell Setup.hs configure --prefix=/usr
runhaskell Setup.hs build
runhaskell Setup.hs copy --destdir=$PKG
runhaskell Setup.hs register --gen-script --with-hc-pkg=/usr/bin/ghc-pkg

( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
gzip -9 $PKG/usr/man/man?/*

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cat $CWD/slack-required > $PKG/install/slack-required
cat register.sh  > $PKG/install/register.sh

mkdir -p $PKG/usr/doc/HaXml-$VERSION
cp -a \
  LICENCE-GPL LICENCE-LGPL README \
  $PKG/usr/doc/HaXml-$VERSION
cp -ar examples $PKG/usr/doc/HaXml-$VERSION
cp -ar docs $PKG/usr/doc/HaXml-$VERSION

cd $PKG
makepkg -l y -c n ../HaXml-$VERSION-$ARCH-$BUILD.tgz

