#!/bin/bash

debug=1;

# debug function
function debug() {
  if [[ $debug == 1 ]]
    then
      echo $1
  fi
}

# prints usage information and exits
function usage() {
  echo "Usage: makeMRGjar name";
  echo;
  exit;
}

if [[ ! -n $1 ]]
  then
    usage;
fi

debug "Trying to create .jar for $1...";

# run camelot to compile .cmlt file to .class; -J builds the .jar file at the end!
camelot -J -C -D -lfd -n -olhs 4 $1

# # create MANIFEST
# #echo "Main-Class: MRGOnly" > MANIFEST
# echo "MRG-ClassName: $1" > MANIFEST
# echo "MRG-CertificateName: $1Certificate" >> MANIFEST

# # create jar
# jar -cmf MANIFEST $1.jar $1Certificate.thy *.class

if [[ -f $1.jar ]]
  then
    debug "Successfully created $1.jar";
  else
    debug "Unable to create $1.jar";
fi


