#! /bin/sh
# Make GCC diff for GPC
# J.J. van der Heijden <J.J.vanderHeijden@student.utwente.nl>
# Last modified: 29 Jan 1998 for gcc-2.8.0
# Peter Gerwinski <peter@gerwinski.de>
# Last modified: 20 Jun 1999

if [ $1x == x ]; then
  echo
  echo "usage: $0 <GCC version number>"
  echo
  echo "examples: $0 2.8.1"
  echo "          $0 egcs-2.91.60"
  echo
  exit 1
fi

GCC_VERSION=$1
GPC_VERSION=2.1

ln -s ../.. gcc-$GCC_VERSION

cat > gcc-$GCC_VERSION.diff << EOF
Changes for GCC version $GCC_VERSION for GNU Pascal $GPC_VERSION

Before applying these diffs, go to the directory gcc-$GCC_VERSION
and use the command

    patch -p1

feeding it the following diffs as input.

EOF

case "$GCC_VERSION" in
  2.95*)
    GCC_PATCHED="expr.c stor-layout.c tree.c tree.h tree.def"
    ;;
  gcc-2.95*)
    GCC_PATCHED="expr.c stor-layout.c tree.c tree.h tree.def"
    ;;
  egcs-2.93*)
    GCC_PATCHED="Makefile.in convert.c dbxout.c expr.c fold-const.c \
	    function.c optabs.c prefix.c stor-layout.c toplev.c \
	    gcc.c tree.c config/i386/go32.h"
    ;;
  egcs-2.92*)
    GCC_PATCHED="Makefile.in convert.c dbxout.c expr.c fold-const.c \
	    function.c optabs.c prefix.c stor-layout.c toplev.c \
	    gcc.c tree.c config/i386/go32.h"
    ;;
  egcs-2.91*)
    # Create empty `.orig' versions of files to be created by
    # this diff.  (`diff -N' is not sufficient.)
    rm -f gcc-$GCC_VERSION/mbchar.c.orig
    touch gcc-$GCC_VERSION/mbchar.c.orig
    GCC_PATCHED="Makefile.in convert.c dbxout.c expr.c fold-const.c \
	    function.c optabs.c prefix.c stor-layout.c toplev.c \
	    gcc.c tree.c config/i386/go32.h mbchar.c"
    ;;
  *)
    # Create empty `.orig' versions of files to be created by
    # this diff.  (`diff -N' is not sufficient.)
    rm -f gcc-$GCC_VERSION/ansidecl.h.orig \
          gcc-$GCC_VERSION/system.h.orig \
          gcc-$GCC_VERSION/mbchar.c.orig
    touch gcc-$GCC_VERSION/ansidecl.h.orig \
          gcc-$GCC_VERSION/system.h.orig \
          gcc-$GCC_VERSION/mbchar.c.orig
    GCC_PATCHED="Makefile.in convert.c dbxout.c expr.c fold-const.c \
	    function.c optabs.c prefix.c stor-layout.c toplev.c \
	    gcc.c tree.c config/i386/go32.h \
	    ansidecl.h gansidecl.h system.h demangle.h mbchar.c"
esac

for f in $GCC_PATCHED
do
  diff -p -N -C3 gcc-$GCC_VERSION/$f.orig gcc-$GCC_VERSION/$f >> gcc-$GCC_VERSION.diff
done

rm gcc-$GCC_VERSION

exit 0
