#!/bin/sh
#
#
#   linking the libranlib.a 
#   +++++++++++++++++++++++
#
cd ../lib

#   first check if the file libranlib.a is existing 
if [ -f libranlib.a ] ; then 
  echo " libranlib.a already linked"  
else
  echo "- linking the libranlib " 
	
  SYSTEM=`echo ${OSTYPE} | grep osf | wc | awk '{print $1}'`
  if [ $SYSTEM = 1 ]; then  
    echo "  --> SYSTEM = osf " 
    ln -s libranlib.a.osf1 libranlib.a
  fi

  SYSTEM=`echo ${OSTYPE} | grep linux | wc | awk '{print $1}'`
  if [ $SYSTEM = 1 ]; then  
    echo "  --> SYSTEM = linux " 
    ln -s libranlib.a.linux libranlib.a
  fi
fi

if [ -f libranlib.a ] ; then 
  echo " libranlib.a sucessfully linked"  
else
  echo " ERROR: no symoblic link for libranlib.a "
  exit
fi  
echo "" 
# 
#
#    Linking the qe.dat
#    +++++++++++++++++++++++++++
#
cd ../Data
#   first check if qe.dat is already existing
if [ -f qe.dat ] ; then 
  echo " qe.dat already linked"  
else
  echo "- linking qe.dat to qe-emi-coat.RFL.dat, which is QE for EMI PMTs" 
  ln -s qe-emi-coat.RFL.dat qe.dat
fi
# 
echo "" 
#
#    compilation
#    +++++++++++++++++++++++++++
#

cd ../../../Mars
make libmars.so
cd ../Simulation/Detector/Camera
make
cd ../StarResponse
make
cd ../Camera

echo "" 
echo " Now change the input card and run camera with  " 
echo "" 
echo "  camera < input.card "
echo ""
echo ""
#

