#!/bin/bash
export LC_ALL=C

echo "This script downloads all precompiled dependencies (apt-get, debian/ubuntu only). It needs root access"


echo "Check which version of vtk is installed..."
dpkg -s libvtk9-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk9-dev
else
dpkg -s libvtk8-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk8-dev
else
dpkg -s libvtk7-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk7-dev
else
dpkg -s libvtk6-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk6-dev
else
dpkg -s libvtk5.8 &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk5.8
else
echo "No version installed."
echo "Check which version of vtk is available..."
apt-cache show libvtk9-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk9-dev
else
apt-cache show libvtk8-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk8-dev
else
apt-cache show libvtk7-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk7-dev
else
apt-cache show libvtk6-dev &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk6-dev
else
apt-cache show libvtk5.8 &> /dev/null
if [ $? -eq 0 ];
then
VTK=libvtk5.8
else
VTK=""
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
if [ $VTK ];
then
echo $VTK
else
echo "No vtk package installed or available."
fi

echo "Check which version of python is installed..."
dpkg -s python &> /dev/null
if [ $? -eq 0 ];
then
PYTHON=python
else
dpkg -s python3 &> /dev/null
if [ $? -eq 0 ];
then
PYTHON=python3
else
echo "Check which version of python is available..."
apt-cache show python &> /dev/null
if [ $? -eq 0 ];
then
PYTHON=python
else
apt-cache show python3 &> /dev/null
if [ $? -eq 0 ];
then
PYTHON=python3
fi
fi
fi
fi

echo "Checking / Installing dependencies"
dpkg -s gfortran $PYTHON $PYTHON-dev libocct-foundation-dev libocct-modeling-algorithm-dev libocct-modeling-data-dev libpcl-dev cmake cmake-curses-gui subversion libblas-dev liblapack-dev mpi-default-dev mpi-default-bin libboost-dev libboost-iostreams-dev libann-dev libxi-dev libxmu-dev git libfltk1.3-dev $VTK &> /dev/null
if [ $? -ne 0 ];
then
sudo apt-get install g++ gfortran $PYTHON $PYTHON-dev libocct-foundation-dev libocct-modeling-algorithms-dev libocct-modeling-data-dev libpcl-dev cmake cmake-curses-gui subversion libblas-dev liblapack-dev mpi-default-dev mpi-default-bin libboost-dev libboost-iostreams-dev libann-dev libxi-dev libxmu-dev git libfltk1.3-dev $VTK
fi


