#!/bin/bash


mkdir /tmp/sikor
cd /tmp/sikor
wget www.kt.agh.edu.pl/~msikora/clip/savi1.4.2-release.tar.gz
wget www.kt.agh.edu.pl/~msikora/clip/geomview_1.9.4-1_i386.deb
sudo apt-get install -y tk8.4-dev
sudo apt-get install -y nvidia-glx-dev
sudo apt-get install -y lesstif2-dev
sudo dpkg -i geomview_1.9.4-1_i386.deb

tar -xzf savi1.4.2-release.tar.gz

sudo mkdir /usr/local/savi
cd savi1.4.2
sed -i s/"^# TCL_INCLUDES ="/"TCL_INCLUDES ="/ ./src/Makefile_defs_linux
sed -i  s/"^# SAVI="/"SAVI="/ ./savi
sed -i s/"TCL_LIBRARY=\/usr\/local"/"TCL_LIBRARY=\/usr"/ ./savi
sed -i s/"TK_LIBRARY=\/usr\/local"/"TK_LIBRARY=\/usr"/ ./savi
sudo cp /tmp/sikor/savi1.4.2/savi /usr/local/bin/.
sudo cp -R * /usr/local/savi

cd /usr/local/savi
sudo ./configure
sudo make ARCH=linux

echo "(emodule-define "SaVi" "savi -geomview")" >/tmp/sikor/aa 
sudo cp /tmp/sikor/aa /usr/libexec/geomview/.geomview-savi
rm -rf /tmp/sikor/aa

cd /tmp
rm -rf sikor
