#!/bin/sh

# Generate diff of two GPC source trees
#
# Authors: Jan-Jaap van der Heijden <J.J.vanderHeijden@student.utwente.nl>
#          Peter Gerwinski <peter@gerwinski.de>
#          Frank Heckenbach <frank@pascal.gnu.de>

if [ $# -ne 2 ]; then
  echo "Usage: `basename "$0"` old-dir new-dir" >&2
  exit 1
fi

if [ x"$GPC_SRCDIR" = x ]; then
  echo "GPC_SRCDIR must be set" >&2
  exit 1
fi

if [ -e "$GPC_SRCDIR/gcc/p/gpc.c" ]; then
  srcdir="$GPC_SRCDIR/gcc/p"
elif [ -e "$GPC_SRCDIR/p/gpc.c" ]; then
  srcdir="$GPC_SRCDIR/p"
else
  echo "Invalid GPC_SRCDIR" >&2
  exit 1
fi

# @@ These files are generated automatically. We should exclude them
#    from the diff, but diff's exclude feature considers only base
#    names, and there are README files in other directories that are
#    not generated automatically. So, we just remove them, and let
#    the next make run regenerate them...
rm -f "$srcdir/README" "$srcdir/test/README"

"`echo "$0" | sed -e 's,\(.\)/*[^/]*$,\1,'`/mkdiff" "$1"/p "$2"/p "$srcdir"/script/gpcdiff.exclude "$srcdir"/script/gpcdiff.intro
