#!/bin/bash

# If you want to set the path to mmpcdir in this file, uncomment the line below
# mmpcdir=/path/to/mmpcdir

if [ $# == 0 ]; then
	echo -e "Usage: vpc [SOURCE] [OPTIONS...]\nPlease specify a source file or -h for help"
	exit 1
fi

# Try to cope with $mmpcdir not being set
if [ -z $mmpcdir ]; then
	if [ -f `dirname $0`/mmpc.jar ]; then
		mmpcdir=`dirname $0`
	elif [ -f $MMPCDIR/mmpc.jar ]; then
			mmpcdir=$MMPCDIR
	elif [ -f `pwd`/mmpc.jar ]; then
		mmpcdir=`pwd`
	else
		echo -e "ERROR: Environment variable \"\$mmpcdir\" is not defined and couldn't be found.\nTo define it use \"export mmpcdir=/path/to/mmpc\""
		exit 2;
	fi
elif ! [ -f $mmpcdir/mmpc.jar ]; then
	echo -e "ERROR: \"\$mmpcdir\" does not contain the file mmpc.jar, required for execution\n\$mmpcdir is currently \"$mmpcdir\"\n Possibly try reinstalling to fix the problem"
	exit 2
fi


echo java -Xmx250m -jar $mmpcdir/mmpc.jar $1 -felf  $2 $3 $4 $5 

java -Xmx250m -Dmmpcdir=$mmpcdir -jar $mmpcdir/mmpc.jar $1 -felf -U -o$1 -opt1 -cpugnuPentium  $2 $3 $4 $5 

