#!/bin/sh
if [ ! -n "$SETHEOHOME" ]; then
	SETHEOHOME="/home/setheo/bin.sun4"
fi

INWASM="$SETHEOHOME/inwasm"
INWASM_FLAGS=""
WASM="$SETHEOHOME/wasm"
WASM_FLAGS=""
LOP_FILENAME=""
if [ $# -lt 1 ]; then
	echo "*** Error: wrong number of arguments";
	echo "*** Usage: clop <flags> <lop-file-basename>";
	exit 1;
else 
	LOP_FILENAME=$1;
	while test $2; do 
		INWASM_FLAGS="$INWASM_FLAGS $1";
		shift;
		LOP_FILENAME=$1;
	done;
	if [ ! -f $LOP_FILENAME.lop ]; then 
		echo "*** Error: file $1.lop does not exist";
		echo "*** Usage: setheo <lop-file-basename>";
		exit 1;
	else
		$INWASM $INWASM_FLAGS $LOP_FILENAME;
		if [ $? -eq 0 ]; then
			$WASM $WASM_FLAGS $LOP_FILENAME;
			exit $?
		else
			exit 1;
		fi
	fi
fi
