#!/bin/bash

##export CMTCONFIG=x86_64-slc6-gcc49-opt
. /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_84/ROOT/6.06.02/x86_64-slc6-gcc49-opt/bin/thisroot.sh
. /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/4.9.3/x86_64-slc6/setup.sh
export GSL_DIR=/cvmfs/lhcb.cern.ch/lib/lcg/releases/GSL/2.1-36ee5/x86_64-slc6-gcc49-opt

if [ "$1" == '--clear' ] || [ "$1" == '-clear' ]; then
  echo "Cleaning up all cmake files to start over freshly"
  if [ -e 'CMakeFiles/' ]; then
    rm -r CMakeFiles/
  fi
  if [ -e 'CMakeCache.txt' ]; then
    rm CMakeCache.txt
  fi
fi

#build make files
cmake .
#using 4 cores. why not?
make -j8
#make

#export CMTCONFIG=x86_64-slc6-gcc49-opt
#. /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_84/ROOT/6.06.02/x86_64-slc6-gcc49-opt/bin/thisroot.sh
#. /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/4.9.3/x86_64-slc6/setup.sh
#export GSL_DIR=/cvmfs/lhcb.cern.ch/lib/lcg/releases/GSL/2.1-36ee5/x86_64-slc6-gcc49-opt

#export CMTCONFIG=x86_64-centos7-gcc9-opt
#. /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_97/ROOT/v6.20.02/x86_64-centos7-gcc9-opt/bin/thisroot.sh
#. /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/9.2.0/x86_64-centos7/setup.sh
#export GSL_DIR=/cvmfs/lhcb.cern.ch/lib/lcg/releases/GSL/2.6-ecdfc/x86_64-centos7-gcc9-opt
