Skip to content
Snippets Groups Projects
pre_req 5.32 KiB
Newer Older
Pietro Incardona's avatar
Pietro Incardona committed
#! /bin/bash

function pre_req()
{
Pietro Incardona's avatar
Pietro Incardona committed
source script/discover_package_manager
incardon's avatar
incardon committed
source script/discover_os
source script/solve_autoconf
source script/solve_gpp
source script/solve_cmake
source script/solve_git
source script/solve_wget
source script/solve_automake
source script/solve_brew
source script/solve_libtool
source script/detect_gcc
source script/detect_osx
incardon's avatar
incardon committed
discover_os
Pietro Incardona's avatar
Pietro Incardona committed
discover_package_manager $platform
Incardona Pietro's avatar
Incardona Pietro committed
pcman=$discover_package_manager_ret
Incardona Pietro's avatar
Incardona Pietro committed
if [ x"$platform" = x"osx" -a x"$pcman" = x""  ]; then
  echo -e "\033[30;43;5;1m WARNING \033[0m No package manager has been found on this system"
  solve_brew $platform
Incardona Pietro's avatar
Incardona Pietro committed

  discover_package_manager $platform
  pcman=$discover_package_manager_ret
  if [ x"$pcman" != x"brew" ]; then
    echo -e "brew \033[91;5;1m FAILED \033[0m"
  fi
incardon's avatar
incardon committed
command -v cmake >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo >&2
incardon's avatar
incardon committed
  echo -e "cmake\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require cmake but it's not installed, searching a solution... "
  solve_cmake $platform
incardon's avatar
incardon committed
  command -v cmake >/dev/null 2>&1
  if [ $? -ne 0 ]; then
incardon's avatar
incardon committed
    echo -e "cmake\033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
    echo -e "cmake\033[92;1m SUCCESS \033[0m"
incardon's avatar
incardon committed
  echo -e "cmake\033[92;1m SUCCESS \033[0m"
Pietro Incardona's avatar
Pietro Incardona committed
command -v wget >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo >&2
  echo -e "wget\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require wget but it's not installed, searching a solution... "
  solve_wget $platform
Pietro Incardona's avatar
Pietro Incardona committed
  command -v wget >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo -e "wget\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "wget\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "wget \033[92;1m SUCCESS \033[0m"
fi

Pietro Incardona's avatar
Pietro Incardona committed
command -v git >/dev/null 2>&1
if [ $? -ne 0 ]; then 
  echo >&2
  echo -e "git\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require git but it's not installed, searching a solution... "
  solve_git $platform
Pietro Incardona's avatar
Pietro Incardona committed
  command -v git >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo -e "git\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "git\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "git \033[92;1m SUCCESS \033[0m"
fi

command -v autoconf >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo >&2
  echo -e "autoconf\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require autoconf but it's not installed, searching a solution..."
  solve_autoconf $platform
Pietro Incardona's avatar
Pietro Incardona committed
  command -v autoheader >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo -e "autoconf\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "autoconf\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "autoconf\033[92;1m SUCCESS \033[0m"
fi

command -v automake >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo >&2
  echo -e "automake\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require automake but it's not installed, searching a solution..."
  solve_automake $platform
Pietro Incardona's avatar
Pietro Incardona committed
  command -v automake >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo "automake\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "automake\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "automake\033[92;1m SUCCESS \033[0m"
fi

Incardona Pietro's avatar
Incardona Pietro committed

command -v libtoolize  >/dev/null 2>&1
opt1=$?
command -v glibtoolize  >/dev/null 2>&1
opt2=$?
Pietro Incardona's avatar
Pietro Incardona committed
if [ $opt1 -ne 0 -a $opt2 -ne 0 ]; then
Pietro Incardona's avatar
Pietro Incardona committed
  echo >&2
  echo -e "libtool\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require libtool but it's not installed, searching a solution..."
  solve_libtool $platform
Incardona Pietro's avatar
Incardona Pietro committed
  command -v libtoolize  >/dev/null 2>&1
  opt1=$?
  command -v glibtoolize  >/dev/null 2>&1
  opt2=$?
Pietro Incardona's avatar
Pietro Incardona committed
  if [ $opt1 -ne 0 -a $opt2 -ne 0 ]; then
Pietro Incardona's avatar
Pietro Incardona committed
    echo -e "libtool\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "libtool\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "libtool\033[92;1m SUCCESS \033[0m"
fi

#### Detecting g++

detect_gcc_or_clang gcc
if [ $dgc_ret -eq 0 ]; then
  solve_gpp $platform
  detect_gcc_or_clang gcc-4.9
  if [ $dgc_ret -eq 0 ]; then
    exit 1
elif [ $dgc_ret -eq 2 ]; then
  detect_osx $platform
  if [ $dosx_ret -eq 1 ]; then
    echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
    echo "g++ seem to be present, but we failed to detect the version. Your system $dosx_major.$dosx_middle.$dosx_minor seem to be recent enough, so we will continue the installation"
    sleep 10    
command -v mpirun >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo -e "No MPI"
else
  major=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
  middle=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
  minor=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
  if [ $major -gt 1 ]; then
    echo -e "mpirun $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
  elif [ $major -lt 1 ]; then
    echo -e "mpirun $major.$middle.$minor \033[91;5;1m FAILED \033[0m is too old, 1.8.1 at least required"
Pietro Incardona's avatar
Pietro Incardona committed
    MPI_installation_required=yes
  elif [ $middle -gt 8  ]; then
    echo -e "mpirun $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
  elif [ $middle -lt 8 ]; then
    echo -e "mpirun $major.$middle.$minor \033[91;5;1m FAILED \033[0m is too old, 1.8.1 at least required"
Pietro Incardona's avatar
Pietro Incardona committed
    MPI_installation_required=yes
  elif [ $minor -gt 0  ]; then
    echo -e "mpirun $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
  else
    echo -e "mpirun $major.$middle.$minor \033[91;5;1m FAILED \033[0m is too old, 1.8.1 at least required"
Pietro Incardona's avatar
Pietro Incardona committed
    MPI_installation_required=yes