#!/bin/bash 



echo "Example script for installing syfi."
echo "Notice that the versions of SWIG, CLN, GiNaC, swiginac, mercurial are"
echo "not necessarily the newest"

# default installation path, modify PREFIX 
# if it is not appropriate 
PREFIX=$HOME/local 


# set some enviroment variables. 
# .bashrc must be modified accordingly afterwards
export PATH=$PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PREFIX/lib
VERSION=`python -c 'import sys; print sys.version[:3]'`
export PYTHONPATH=$PYTHONPATH:$PREFIX/lib:$PREFIX/lib/python$VERSION/site-packages




mkdir -p $PREFIX/src  
cd $PREFIX/src 


#SWIG 
lwp-download http://prdownloads.sourceforge.net/swig/swig-1.3.31.tar.gz
tar xzvf swig-1.3.31.tar.gz 
cd swig-1.3.31
./configure  --prefix=$PREFIX
make 
make install 
cd .. 

# CLN 
lwp-download ftp://ftpthep.physik.uni-mainz.de/pub/gnu/cln-1.1.13.tar.bz2
bunzip2 cln-1.1.13.tar.bz2
tar xvf cln-1.1.13.tar
cd cln-1.1.13
./configure --prefix=$PREFIX
make
make install
cd ..

# GiNaC 
lwp-download http://www.ginac.de/ginac-1.3.7.tar.bz2
bunzip2 ginac-1.3.7.tar.bz2
tar xvf ginac-1.3.7.tar
cd ginac-1.3.7
./configure --prefix=$PREFIX
make
make install
cd ..

# swiginac 
lwp-download http://download.berlios.de/swiginac/swiginac-0.9.5.tgz
gunzip swiginac-0.9.5.tgz
tar xvf swiginac-0.9.5.tar
cd swiginac-0.9.5
python setup.py build
python setup.py install --prefix=$PREFIX 
cd .. 

# mercurial 
lwp-download http://www.selenic.com/mercurial/release/mercurial-0.9.3.tar.gz
tar -xzf mercurial-0.9.3.tar.gz
cd mercurial-0.9.3
python setup.py install --prefix=$PREFIX 
cd ..

# SyFi 
hg clone http://www.fenics.org/hg/syfi
cd syfi
./configure --prefix=$PREFIX
make
make install
cd ..

echo "" 
echo "" 
echo 'Put the following lines in your .bashrc file (if you do not have them already).' 
echo "" 
echo "" 
echo "PREFIX=$PREFIX" 
echo 'export PATH=\$PATH:$PREFIX/bin'
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PREFIX/lib'
echo "VERSION=`python -c 'import sys; print sys.version[:3]'`"
echo 'export PYTHONPATH=$PYTHONPATH:$PREFIX/lib:$PREFIX/lib/python$VERSION/site-packages'
echo "" 
echo "" 


echo ""
echo ""

echo "Example script for installing syfi."
echo "Notice that the versions of SWIG, CLN, GiNaC, swiginac, mercurial are"
echo "not necessarily the newest"










