#!/usr/bin/env bash

if command -v dnf > /dev/null
then
  # Fedora

  dnf update -y
  dnf install -y \
    curl \
    make gcc gcc-c++ flex bison patch \
    gzip zlib-devel bzip2 bzip2-devel xz xz-devel \
    ncurses-devel readline-devel \
    libX11-devel libXt-devel \
    openssl-devel libuuid-devel libffi-devel  tk-devel tcl-devel $(: for python) \
    cairo-devel $(: for matplotlib) \
    perl perl-ExtUtils-MakeMaker gettext libcurl-devel expat-devel $(: for git) \
    rsync $(: used by eups package 'fftw') \
    cmake $(: used by mariadbclient)

elif command -v yum > /dev/null
then
  # Redhat

  yum update -y
  yum install -y \
    curl python-argparse \
    make gcc gcc-c++ flex bison patch \
    gzip zlib-devel bzip2 bzip2-devel xz xz-devel \
    ncurses-devel readline-devel \
    libX11-devel libXt-devel \
    openssl-devel libuuid-devel libffi-devel tk-devel tcl-devel $(: for python) \
    cairo-devel $(: for matplotlib) \
    perl perl-ExtUtils-MakeMaker gettext libcurl-devel expat-devel $(: for git) \
    rsync $(: used by eups package 'fftw') \
    cmake $(: used by mariadbclient)

elif command -v apt-get > /dev/null
then
  # Ubuntu 16 LTS is assumed
  apt-get install -y make gcc g++ flex bison patch \
    gzip zlib1g zlib1g-dev bzip2 libbz2-dev xz-utils liblzma-dev \
    libncurses5-dev libreadline-dev \
    libx11-dev libxt-dev \
    libssl-dev uuid-dev libffi-dev tk-dev tcl-dev $(: for python) \
    libcairo2-dev $(: for matplotlib) \
    perl gettext libcurl4-gnutls-dev libexpat1-dev $(: for git) \
    rsync $(: used by eups package 'fftw') \
    cmake $(: used by mariadbclient)
fi
