#!/bin/ksh 

PATCHDIR=`echo $PATCHDIR`
if [ -z $PATCHDIR ]; then
  echo "Please set the env var PATCHDIR. See docs/README for details."
  exit 1
fi

if [ ! -x name ]; then
  echo "I cannot execute name, thus I cannot get the release level."
  echo "Try setting env var PATCHDIR and SOURCE and type make solaris."
  echo "If this does not work look at docs/README for details."
  exit 1
fi

SRC_RELEASE=`name`

if [ $? -ne 0 ]; then
  echo "WOAH! name failed! Cannot continue."
  exit 1
fi

if [ ! -x $PATCHDIR/Server/name ]; then
  echo "I cannot execute $PATCHDIR/Server/name, thus I cannot get the"
  echo "release level."
  echo ""
  echo "Try setting env var PATCHDIR and SOURCE and type make solaris."
  echo "If this does not work look at docs/README for details."
  exit 1
fi

PATCH_RELEASE=`$PATCHDIR/Server/name`

if [ $? -ne 0 ]; then
  echo "WOAH! $PATCHDIR/Server/name failed! Cannot continue."
  exit 1
fi

PATCH=$SRC_RELEASE\-$PATCH_RELEASE

echo ""	
echo "Making Server$PATCH.diffs"
rm -f Server$PATCH.diffs

if [ ! -r manifest ]; then
  echo "I cannot find the manifest file. Are you sure you are in the"
  echo "SOURCE directory?"
  exit 1
fi
for f in `cat manifest` ; do 
  if [ ! -L ../$f ] ; then 
    if [ ! -f $PATCHDIR/$f ] ; then 
      touch $PATCHDIR/$f 
    fi 
    diff -c $PATCHDIR/$f ../$f >> Server$PATCH.diffs 
  fi 
done 
