#!/bin/sh
if [ -d $1/.svn ]; then
  echo Generating revision.h
  PWD_SAVE=`pwd`
  cd $1
  SVNVERSION=`which svnversion`
  SVN=`which svn`
  RV_REVISION=`$SVNVERSION | cut -f 2 -d : | tr -d 'M'`
  RV_LAST_CHANGED_DATE=`$SVN log -q -r$RV_REVISION | awk '{print $5}' | tr -d '\\\n\\\ '`
  RV_LAST_CHANGED_DATE=`echo $RV_LAST_CHANGED_DATE | sed s/\ //g`
  cat $1/revision.h.in | sed s/@RV_REVISION@/$RV_REVISION/g | sed s/@RV_LAST_CHANGED_DATE@/$RV_LAST_CHANGED_DATE/g > $2/revision.h 
  cd $PWD_SAVE
fi
