#!/bin/bash
#
# startscript for TuxGuitar
# http://www.herac.com.ar/tuxguitar.html
#
# Copyright (c) 2006 oc2pus
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments to oc2pus@arcor.de
#
# Changelog:
# 08.04.2006 initial version (0.5)
# 28.05.2006 added itext.jar to classpath (0.6)
# 28.05.2006 added set_flags "-Xms128m -Xmx128m" (0.6)
# 02.09.2006 added /usr/lib to java.library.path (0.8)
# 27.09.2006 removed itext from classpath
# 30.01.2007 added 64bit paths
# 02.04.2009 added gervill to classpath
#            added -Dtuxguitar.share.path
# 21.10.2009 added a patch for GRE-detection, thx to Mike Henders

# activate for debugging
#set -x

# get xulrunner config per arch
LIBVERZ=lib
case $(uname -i) in
	*64)
		eval $(grep -h '^GRE_PATH=' /etc/gre.d/*-64bit.system.conf | sort)
		LIBVERZ=lib64
		;;
	*)
		eval $(grep -h '^GRE_PATH=' /etc/gre.d/*.system.conf | sort)
		LIBVERZ=lib
		;;
esac
export MOZILLA_FIVE_HOME=$GRE_PATH
export MOZ_PLUGIN_PATH=/usr/$LIBVERZ/browser-plugins
export LD_LIBRARY_PATH="$MOZILLA_FIVE_HOME:/usr/lib64/swt:/usr/lib64:/usr/lib/swt:/usr/lib:$LD_LIBRARY_PATH"
echo "using MOZILLA_FIVE_HOME=$GRE_PATH and MOZ_PLUGIN_PATH=/usr/$LIBVERZ/browser-plugins"

# base settings
echo ""
echo "configure java-environment ..."

VERBOSE=1

# source the jpackage helpers
. /usr/share/java-utils/java-functions

# set JAVA_* environment variables
set_javacmd
check_java_env
set_jvm_dirs

# set classpath
echo "configuring TuxGuitar ..."
CLASSPATH=`build-classpath TuxGuitar gervill swt`:/usr/share/TuxGuitar
# set jar-entry-class
MAIN_CLASS="org.herac.tuxguitar.gui.TGMain"
# path for neede shared libraries
set_options "-Djava.library.path="$MOZILLA_FIVE_HOME:/usr/lib64/swt:/usr/lib64:/usr/lib/swt:/usr/lib" -Dtuxguitar.share.path=usr/share/TuxGuitar"
set_flags "-Xms128m -Xmx128m"

# start application
echo "starting TuxGuitar application ..."

export LANG=C
run "$@"
