#!/bin/bash
#########################################################
# This is bootstrap script for eclipse
#              (C)2003 Takashi Okamoto tora@debian.org
#                      Jan Schulz      default@katzien.de
# Default work space is $HOME/eclipse
#########################################################

# source basic functionality
. /usr/share/eclipse/start-functiones.sh

# setting initial values, as specified various sources
setConfigValues

## Prozess all options, for which we have settings in the rc file.
while [ "$1" ] ; do
	if [ "$1" = "-data" ] ; then
		shift 
		WORKSPACE=$1
		shift
        elif [ "$1" = "-h" -o "$1" = "--help" ] ; then 
	        usage
		exit 0
	elif [ "$1" = "-ws" ] ; then
		shift 
		WS_PARAM="-ws $1"
		shift
	elif [ "$1" = "-vm" ] ; then
		shift 
		JAVACMD="$1"
		shift
	elif [ "$1" = "-vmargs" ] ; then
		shift
		VMARGS_PARAM="$1"
		shift
		while [ "$1" ] ; do
			VMARGS_PARAM="${VMARGS} $1"
			shift
		done
        elif [ "$1" = "-debug" ] ; then
		shift 
		DEBUG_PARAM="-debug $1"
		shift
        elif [ "$1" = "-nosplash" ] ; then
		shift 
		SPLASH_PARAM="-nosplash"
	elif [  "$1" = "-addsite" ] ; then
		shift 
		ADDSITE_PARAM="$ADDSITE_PARAM -addsite $1"
		shift
	else
		ARGS="$ARGS $1"
		shift
	fi
done

# Add the default user.links file, if it exists... 
if [ -r $HOME/.eclipse/user.links ] ; then
        ADDSITE_PARAM="$ADDSITE_PARAM -addsite $HOME/.eclipse/user.links "
fi

# export GTK_USE_XFT if set. Makes swt-gtk faster...
if [ "GTK_USE_XFT" != "" ] ; then
      export GTK_USE_XFT
fi


# HACK... Should be replaced...
SO_FILES=/usr/lib/eclipse/
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/jni:$SO_FILES"

checkWorkspace
execWorkarounds

if [ "$DEBUG_PARAM" != "" ] ; then
    echo "Use kill -QUIT <PID of eclipse> to produce Thread dump"
fi

startEclipse
