#! /bin/sh -e

# DP: Updates from gpc-20030820.

pdir=gcc
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="$3/gcc"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi

gpc_gcc_patch=debian/patches/gpc-update27i.diff

case "$1" in
    -patch)
	# keep the backup files ... to regenerate p/diffs/${gpc_gcc_patch}
	# dan@debian.org: no, don't.  Apply it by hand if you need to regen.
	# get the patch from the gpc source
	echo Using patch file ${gpc_gcc_patch}
	patch -d $pdir -f -p1 < ${gpc_gcc_patch}
	#pf=`echo $0 | sed 's/\.dpatch/.diff/'`
	#patch -d $pdir -f -p1 < $pf
	;;
    -unpatch)
	# get the patch from the gpc source
	echo Using patch file ${gpc_gcc_patch}
	patch -d $pdir -f -R -p1 < ${gpc_gcc_patch}
	#pf=`echo $0 | sed 's/\.dpatch/.diff/'`
	#patch -d $pdir -f -R -p1 < $pf
	;;
    *)
	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
	exit 1
esac
exit 0
