#!/bin/sh
# $Id: start_opennap,v 1.1 2002/08/14 21:38:07 leodav Exp $

# subdir to back up copies of gprof output and opennap executable
BACKUPDIR=profile

# start up opennap with the command line args given to the shell script
./opennap $@

if [ -f gmon.out ]; then
	echo Backing up opennap and gmon.out to $BACKUPDIR
	if [ ! -d $BACKUPDIR ]; then
		mkdir $BACKUPDIR
	fi
# save the last 5 copies for later inspection
	mv -f $BACKUPDIR/gmon.out-4 $BACKUPDIR/gmon.out-5
	mv -f $BACKUPDIR/gmon.out-3 $BACKUPDIR/gmon.out-4
	mv -f $BACKUPDIR/gmon.out-2 $BACKUPDIR/gmon.out-3
	mv -f $BACKUPDIR/gmon.out-1 $BACKUPDIR/gmon.out-2
	mv gmon.out $BACKUPDIR/gmon.out-1
	mv -f $BACKUPDIR/opennap-4 $BACKUPDIR/opennap-5
	mv -f $BACKUPDIR/opennap-3 $BACKUPDIR/opennap-4
	mv -f $BACKUPDIR/opennap-2 $BACKUPDIR/opennap-3
	mv -f $BACKUPDIR/opennap-1 $BACKUPDIR/opennap-2
	cp opennap $BACKUPDIR/opennap-1
fi
