#!/bin/bash

##  Set up environment for Mint
##

# Load this file directly or indirectly only once
if [ -n "$MINT_LOADED_CONFIG" ] ; then
   return
fi
export MINT_LOADED_CONFIG=true
export MINT_ORIG_CLASSPATH=$CLASSPATH


show_usage() {
    echo "Mint Environment Setup Script"
    echo "Usage: . bashrc"
    echo "      ^^^ Make sure you have the '.' "
    echo ""
    return 0
}

# Determine client OS
cygwin=false;
darwin=false;
case "`uname`" in
  CYGWIN*) cygwin=true ;;
  Darwin*) darwin=true ;;
esac

# if [ -f "${HOME}/.mintrc" ] ; then
#   . ${HOME}/.mintrc
# fi

# Make sure we load this in the current environment
# basename "-bash" doesnt work in darwin: "-" is parsed for a flag
if ! $darwin && [ $(basename ${0}) == 'bashrc' ]; then show_usage; exit 0; fi

## Set Mint Home

## the conditional stuff below resembles the ones in bin/
## b/c we dont need to load bashrc, but simply need to make sure 
## MINT_HOME is correctly defined
if [ -n "$MINT_HOME" ] && [ -f "${MINT_HOME}/langtools/etc/bashrc" ] ; then
  MINT=$MINT_HOME
else 
  # no easy way to determine path manually.
  echo "Set MINT_HOME to the root directory of your Mint installation"
  return
fi

if $cygwin ; then
   MINT=`cygpath --unix "$MINT"`
fi


MINT_CLASSPATH_PREFIX=${MINT}/langtools/dist/lib/classes.jar
CLASSPATH=$MINT_CLASSPATH_PREFIX:$CLASSPATH

if $cygwin ; then
   CLASSPATH=`cygpath -p -w "${CLASSPATH}"`
fi 

export CLASSPATH
export MINT_CLASSPATH_PREFIX
