#!/bin/sh
#
# mkcompdate
# usage: mkcompdate SRCDIR
# (e.g. mkcompdate $(SRC) in Imakefile)
# updates $SRCDIR/compdate.C if necessary
#
# created: jschipf, mpichler, 19960618
# changed: mpichler, 19960618
#
# $Id: mkcompdate,v 1.1 1996/06/19 13:34:47 mpichler Exp $

SRC="$1"
if [ ! -d "$SRC" ]
then
  echo "usage: mkcompdate SRCDIR"
  exit 1
fi

# "pretty" date format (as pretty as you can)
case "$CPU" in
  SUN4* | PMAX* )
    DATEFORMAT='+%a %d %h %y'
  ;;
  * )
    DATEFORMAT='+%a %e %b %Y'
  ;;
esac

tmpfile=.compdate."$CPU"

# date format for control file (supported on all machines)
date '+%y%m%d' > $tmpfile

if diff $tmpfile $SRC/.compdate >&2 2> /dev/null && [ -f $SRC/compdate.C ]
then
  echo "compdate unchanged:" `cat $SRC/.compdate`
  rm $tmpfile
else
  mv $tmpfile $SRC/.compdate
  echo '#include "compdate.h"' > $SRC/compdate.C
  echo 'const char* compDate () { return "'`date "$DATEFORMAT"`'"; }' >> $SRC/compdate.C
  echo "upgraded compdate:" `cat $SRC/.compdate`
fi
