#!/bin/bash -e
echo "Running the prepare script for phaser.";

if [[ $(uname) == "Linux" ]]; then
  sudo apt-get install -y doxygen liblapack-dev libblas-dev autotools-dev \
    dh-autoreconf libboost-all-dev python-setuptools git g++ cppcheck \
    default-jre libreadline-dev libgtest-dev libglew-dev python-git pylint \
    checkstyle python-termcolor liblog4cplus-dev cimg-dev python-wstool \
    python-catkin-tools libssh2-1-dev libatlas3-base libv4l-dev python-scipy \
    libnlopt-dev wget

  if lsb_release -c 2> /dev/null | grep trusty > /dev/null ; then
    # Ubuntu 14.04 / ROS Indigo.
    sudo apt-get install -y clang-format-3.4 ros-indigo-camera-info-manager* \
      ros-indigo-rviz-animated-view-controller
  elif lsb_release -c 2> /dev/null | grep xenial > /dev/null ; then
    # Ubuntu 16.04 / ROS Kinetic.
    sudo apt-get install -y clang-format-3.8 ros-kinetic-camera-info-manager* \

  elif lsb_release -c 2> /dev/null | grep bionic > /dev/null ; then
    # Ubuntu 18.04 / ROS Melodic.
    sudo apt-get install -y clang-format-6.0 ros-melodic-pcl-conversions \
      libpcl-dev libvtk6-dev libvtk6-qt-dev libvtk6-java \
      libvtk6-jni
  else
    echo "Unknown Ubuntu version. Couldn't install all necessary dependencies."
  fi
else
  echo "Platform not supported by the prepare script."
  echo "Please ensure that all necessary dependencies are installed."
fi
