#!/bin/sh

SPTKDIR=`pwd`

echo Starting in $SPTKDIR
echo Generating HTML documentation
doxygen sptk3.doxygen
if [ $? != 0 ]; then
  echo Errors during HTML docs generation.
  echo Exiting..
  exit 1
fi

echo Compressing generated documentation
cd $SPTKDIR/docs/html
tar jcf ../sptk3_reference.html.tbz2 *

cd $SPTKDIR/docs/latex
if [ $? = 0 ]; then
  echo Generating PDF reference
  make > /dev/null
  if [ $? = 0 ]; then
    mv refman.pdf ../sptk3_reference.pdf
  else
    echo Error generating PDF reference
    exit 1
  fi
fi

cd $SPTKDIR

echo Removing intermediate files
rm -f $SPTKDIR/html/*.html $SPTKDIR/html/*.png
mv $SPTKDIR/docs/html/* $SPTKDIR/html/
rm -rf $SPTKDIR/docs/latex $SPTKDIR/docs/html

