#!/bin/sh

INSTALL_DIR=`pwd`
SOFTWARE=cronolog
VERSION=1.6.2

function cleanupandexit {
  echo "Installation failed.  Look above for errors."
  cd $INSTALL_DIR
  rm -rf ${SOFTWARE}-${VERSION}
  exit 1
}

tar xzf ${SOFTWARE}-${VERSION}.tar.gz || cleanupandexit
cd $INSTALL_DIR/${SOFTWARE}-${VERSION}

patch src/cronolog.c $INSTALL_DIR/patches/cronolog-large-file-patch.txt
./configure || cleanupandexit

make || cleanupandexit
make install || cleanupandexit

echo "Cronolog Installation Complete"

