#!/usr/bin/env bash
# Install everything required for ./test
travis=false
y=
while getopts t OPT; do
  case "$OPT" in
    t)
      travis=true
      y=-y
      ;;
  esac
done
shift $(($OPTIND - 1))
if "$travis"; then
  sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
fi
sudo apt-get update $y
cmd="sudo apt-get install ${y} \
build-essential \
gfortran \
libncurses5-dev \
parallel \
scons \
"
if "$travis"; then
  cmd="${cmd} \
gcc-7 \
g++-7 \
"
else
  cmd="${cmd} \
gcc \
g++ \
"
fi
echo "$cmd"
eval "$cmd"
if "$travis"; then
  sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 50
  sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 50
fi
