#!/bin/sh

JAVA=/usr/bin/kaffe
ECLIPSE_HOME=`pwd`
MOZILLA_FIVE_HOME=/usr/lib/mozilla-firefox
JVM_OPTIONS="-Xms128m -Xmx512m -Xnative-big-math"
SWT_NATIVE_VERSION=3128

#########################################################################
# You should NOT need to modify anything below this line.               #
#########################################################################
if [ ! -x $JAVA -o ! -f $ECLIPSE_HOME/startup.jar ]; then
    echo "Error: 'java' command or Eclipse's startup.jar not found!"
    echo "  JAVA=$JAVA"
    echo "  ECLIPSE_HOME=$ECLIPSE_HOME"
    echo "  Check the directories in $0 script and try again!"
    exit 1
fi
 
JAVACMD="$JAVA -Dosgi.locking=none $JVM_OPTIONS"

NATIVE_ENUMS="atk-gtk gtk pi-gtk awt-gtk kde-gtk gnome-gtk mozilla-gtk"
JARBALL=$ECLIPSE_HOME/plugins/org.eclipse.swt.gtk_3.1.0.jar
if [ ! -d native ]; then
    echo "Extracting native libraries from $JARBALL..."
    mkdir -p native
    cd native
    for so in $NATIVE_ENUMS; do
        fastjar -x os/linux/x86/libswt-$so-$SWT_NATIVE_VERSION.so \
            -f $JARBALL
    done
    cd $ECLIPSE_HOME
fi

for one in `find $ECLIPSE_HOME -name \*.so | sed 's/^\(.*\)\/[^\/]*$/\1/g' |sort|uniq`; do
    LD_LIBRARY_PATH="$LD_LIBRARY_PATH":$one
done

LD_LIBRARY_PATH="$LD_LIBRARY_PATH":$MOZILLA_FIVE_HOME

export LD_LIBRARY_PATH JAVACMD ECLIPSE_HOME JAVA MOZILLA_FIVE_HOME
MAIN=org.eclipse.core.launcher.Main
exec $JAVACMD \
  -cp $ECLIPSE_HOME/startup.jar \
  $MAIN \
  -os linux -ws gtk -consolelog
