#! /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 Aug 2000

if [ $1x == x ]; then
  echo
  echo "usage: $0 <GCC version number>"
  echo
  echo "examples: $0 2.95"
  echo "          $0 egcs-20000821"
  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-2.95* | egcs-20000821)
    GCC_PATCHED="expr.c fold-const.c stor-layout.c tree.c tree.h tree.def"
    ;;
  egcs-2.93*)
    GCC_PATCHED="Makefile.in convert.c expr.c fold-const.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 expr.c fold-const.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 expr.c fold-const.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-$GCC_VERSION/dwarfout.h.orig \
          gcc-$GCC_VERSION/toplev.h.orig
    GCC_PATCHED="Makefile.in acconfig.h aclocal.m4 ansidecl.h \
            config.in configure.in convert.c demangle.h \
            dwarfout.h expr.c fold-const.c gansidecl.h \
            gcc.c mbchar.c optabs.c prefix.c rtl.h stor-layout.c \
            system.h toplev.c toplev.h tree.c tree.h \
            config/i386/go32.h"
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
