#!/bin/sh -

#	Create a tar file containing the extra files required by
#	bounds checking & the diffs to the main sources.
#	By Richard W.M. Jones.

# GCC directories.
# Assume:
#  GCC in $HOME/$GCC
#  original GCC in $HOME/GCC_ORIG

GCC=gcc-2.7.2
GCC_ORIG=gcc-2.7.2-orig

# Place to put the packed file.

INST_DIR=$HOME

# Final tar file name. Contains the GCC and BC version numbers.

TARFILE=bounds-checking-2.7.2-1.02.tgz

# Files and directories that are not in the GCC distribution go here.

EXTRA_FILES="c-bounds.c c-bounds.h cp/bounds.c bounds"

# Files that have been changed in bounds checking GCC.

CHANGED_FILES="\
	c-common.c\
	c-decl.c\
	c-lang.c\
	c-parse.in\
	c-tree.h\
	c-typeck.c\
	calls.c\
	extend.texi\
	flags.h\
	fold-const.c\
	function.c\
	gcc.1\
        gcc.c\
        ginclude/stdarg.h\
        ginclude/va-alpha.h\
        ginclude/va-clipper.h\
        ginclude/va-h8300.h\
        ginclude/va-i860.h\
        ginclude/va-i960.h\
        ginclude/va-m88k.h\
        ginclude/va-mips.h\
        ginclude/va-pa.h\
        ginclude/va-ppc.h\
        ginclude/va-pyr.h\
        ginclude/va-sparc.h\
        ginclude/va-spur.h\
        ginclude/varargs.h\
	invoke.texi\
	libgcc2.c\
	optabs.c\
	print-tree.c\
	stmt.c\
	toplev.c\
	varasm.c\
	Makefile.in\
	cp/Makefile.in"

#-----

# Some programs you may like to change.

TAR="tar"
GZIP="gzip"
DIFF="diff"
ECHO="echo"
MAKE="make"
RM="rm -f"
LS="ls -l"

#-----

cd $HOME/$GCC

# We need to make GCC (so we can make the test results files).

$MAKE

# Pack up the diffs into one file ...

cd $HOME

$RM $GCC/bounds-checking.diff
$ECHO -n "Packing up diffs:"
for f in $CHANGED_FILES; do
	$ECHO -n " $f"
	$DIFF -c $GCC_ORIG/$f $GCC/$f >> $GCC/bounds-checking.diff
done

cd $HOME/$GCC

$ECHO; $LS bounds-checking.diff

$ECHO "---------- Making bounds/lib clean. ----------"
(cd bounds/lib; $MAKE srcdir=$HOME/$GCC distclean)

$ECHO "---------- Making bounds/tests clean and creating results files. ----------"
(cd bounds/tests; $MAKE results; $MAKE distclean)

$ECHO "---------- Making bounds/tools clean. ----------"
(cd bounds/tools; $MAKE distclean)

$ECHO "---------- Cleaning up bounds/ and subdirectories. ----------"
for d in `find bounds -type d -print`; do
	(cd $d; $RM *~ *.BAK *.bak core *.o *.orig *.rej *.old)
done

$ECHO "---------- Packing up tar file. ----------"
tarfiles="$GCC/bounds-checking.diff"
for f in $EXTRA_FILES; do
  tarfiles="$tarfiles $GCC/$f"
done
cd $HOME
$TAR cf - $tarfiles | $GZIP > $INST_DIR/$TARFILE
cd $HOME/$GCC

$ECHO "---------- Result file: ----------"
$LS $INST_DIR/$TARFILE
