#! /bin/csh -f

# set echo = 1

# This shell script automatically runs upon a 'gmake commit'.  
# It updates the micro release version number of TCA.
#  Adapted by Reid Simmons from a version used for TCX
#  Extended by Reid Simmons to work for all the TCA programs and tools
#  Abstracted to use parameters $3 and $4 by Richard Goodwin.

# Argument
# $1 install directory
# $2 module directory
# $3 file to update
# $4 program prefix.

echo "Automatically updating micro version number in " $3
echo "If you abort the commit, restore " $3 "from .#"$3".BAK"

rm -f $1/$2/.\#$3.BAK
cp $1/$2/$3 $1/$2/.\#$3.BAK

awk '/'$4'_VERSION_MICRO/ { print "#define '$4'_VERSION_MICRO  " $3+1 } \
     /'$4'_VERSION_DATE/ { print "#define '$4'_VERSION_DATE \"" date "\""} \
    !($2 ~ /'$4'_VERSION_MICRO|VERSION_DATE/) { print }' \
  date=`date '+%h-%d-%y'` $1/$2/.\#$3.BAK >! $1/$2/$3
##############################################################################
