#!/bin/bash
echo "**********************************************************"
echo "*                        MAGiC                           *"
echo "*                                                        *"
echo "*                        ERICCA                          *"
echo "*                                                        *"
echo "*         Departement de genie mecanique - UQTR          *"
echo "*                                                        *"
echo "*        Installation des modules Project Chrono         *"
echo "*                                                        *"
echo "**********************************************************"
echo ""
echo $(date)
echo ""
echo "Project Chrono installation"

echo "Checking / Installing dependencies"
tabdep=(freeglut3-dev)
echo "Dependance a verifier :"${#tabdep[*]}
for i in ${!tabdep[*]};
do
nomdep=${tabdep[i]}
dpkg -s $nomdep  >> /dev/null 2>&1
if [ $? == 1 ];
then
echo $nomdep...............FAIL
sudo apt-get -y install $nomdep  
else
echo $nomdep...............ok
fi

done
__DIR=`pwd`
mkdir ./project_chrono
cd ./project_chrono
wget http://ericca.uqtr.ca/chrono-develop.zip
wget http://ericca.uqtr.ca/irrlicht-1.8.4.zip
unzip chrono-develop.zip
unzip irrlicht-1.8.4.zip
cd ./irrlicht-1.8.4/source/Irrlicht
make sharedlib -j4 
sudo make install
cd $__DIR
cd ./project_chrono/chrono-develop
mkdir build
cd build
cmake .. -DENABLE_MODULE_IRRLICHT=ON 
make -j4
sudo make install
cd $__DIR

echo ""
echo $(date)
echo ""
echo "**********************************************************"
echo "*                        MAGiC                           *"
echo "*                                                        *"
echo "*                        ERICCA                          *"
echo "*                                                        *"
echo "*         Departement de genie mecanique - UQTR          *"
echo "*                                                        *"
echo "*        Installation des modules Project Chrono         *"
echo "*                                                        *"
echo "**********************************************************"


