#!/bin/sh

#
#	Copyright (C) 2011 seucolega
#
#	This program is free software: you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation, either version 3 of the License, or
#	(at your option) any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#	Author:
#		seucolega <gustavohss@gmail.com>
#
#
#	This script was inspired by this post:
#	http://cpbotha.net/2010/03/04/processing-gsvideo-nyartoolkit-on-linux-x86_64/
#

# Install dependencies
sudo apt-get install sun-java6-jdk libjogl-java libhighgui2.1 gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly

# Initialize variables
PROC_FILE='processing-1.5.1-linux.tgz'
GSVIDEO_FILE='GSVideo-0.9-linux.zip'

# Check if the package GSVideo was downloaded
if [ ! -f $GSVIDEO_FILE ]:
then
	echo ""
	echo "*** Note: You need to download the package $GSVIDEO_FILE in http://sourceforge.net/projects/gsvideo/files/gsvideo/0.9/GSVideo-0.9-linux.zip/download ***"
	echo ""
	exit 1
fi

# Get Processing
if [ ! -f $PROC_FILE ]; then
	wget -c http://processing.googlecode.com/files/processing-1.5.1-linux.tgz
fi

# Unpack Processing
tar xvf $PROC_FILE

# Unpack GSVideo
unzip -x $GSVIDEO_FILE -d processing-1.5.1/modes/java/libraries/

# Enter the unpacked folder Processing
cd processing-1.5.1

# Use Java installed on the system
rm -rf java
ln -s /usr/lib/jvm/java-6-sun/ java

# Use files installed on the system
ln -fs /usr/lib/jni/libgluegen-rt.so modes/java/libraries/opengl/library/linux32/
ln -fs /usr/lib/jni/libjogl_awt.so   modes/java/libraries/opengl/library/linux32/
ln -fs /usr/lib/jni/libjogl.so       modes/java/libraries/opengl/library/linux32/

exit 0

