#!/bin/sh -f

#
# File produced by the obuild tool version 1.0
# for the package snova with version v2r0p0.
#

#////////////////////////////////////////////////
# Usage :
#   UNIX> cd some_path/pack/version/obuild
# ( UNIX> chmod a+x sh/check_foreigns )
#   UNIX> sh/check_foreigns
#
#////////////////////////////////////////////////

# Binary directory is needed to create the obuild_plaform program.

if [  "${OBUILD_PLATFORM}" = "" ] ; then
  obuild_platform=`uname`
else
  obuild_platform=${OBUILD_PLATFORM}
fi

if [ "${obuild_platform}" = "" ] ; then
  echo "obuild_platform variable not defined."
  exit
fi

if [  "${OBUILD_DIR_BIN}" = "" ] ; then
  obuild_dir_bin=bin_obuild
else
  obuild_dir_bin=${OBUILD_DIR_BIN}
fi

if [ "${obuild_dir_bin}" = "" ] ; then
  echo "obuild_dir_bin variable not defined."
  exit
fi

obuild_pwd=`pwd`
obuild_snova_path=`dirname "${obuild_pwd}"`
unset obuild_pwd

# Create the bin directory :
/bin/mkdir -p "${obuild_snova_path}/${obuild_dir_bin}"

obuild_check_what=$1
if [ "${obuild_check_what}" = "" ] ; then
  echo "check_foreigns : no argument given"
  exit 1
fi

if [ ! -e "${obuild_snova_path}/${obuild_dir_bin}/obuild_platform" ] ; then
  if [ ! -e "${obuild_snova_path}/obuild/cpp/obuild_platform.cpp" ] ; then
    echo "Program source obuild_platform.cpp not found."
    exit
  fi
  if [ "${obuild_cxx_command}" = "" ] ; then 
    if [  "${OBUILD_CXX}" != "" ] ; then
      obuild_platform_compiler=${OBUILD_CXX}
    else
      obuild_platform_compiler=c++ 
    fi
  else
    obuild_platform_compiler=${obuild_cxx_command} 
  fi
  ${obuild_platform_compiler} -o "${obuild_snova_path}/${obuild_dir_bin}/obuild_platform" "${obuild_snova_path}/obuild/cpp/obuild_platform.cpp"
  unset obuild_platform_compiler
  if [ ! -e "${obuild_snova_path}/${obuild_dir_bin}/obuild_platform" ] ; then
    echo "Program obuild_platform not found."
    exit
  fi
fi
obuild_platform_exe="${obuild_snova_path}/${obuild_dir_bin}/obuild_platform"
if [ "${obuild_platform_exe}" = "" ] ; then
  echo "Variable obuild_platform_exe not defined."
  exit
fi
obuild_platform_result=`"${obuild_platform_exe}" ${obuild_platform} 'UNIX'`
if [ ${obuild_platform_result} = yes ] ; then
CLHEP_home="/usr/local/CLHEP/2.0.3.1"
fi
unset obuild_platform_result
if [ "${obuild_platform_exe}" = "" ] ; then
  echo "Variable obuild_platform_exe not defined."
  exit
fi
obuild_platform_result=`"${obuild_platform_exe}" ${obuild_platform} 'UNIX'`
if [ ${obuild_platform_result} = yes ] ; then
Geant4_home="/usr/local/geant4/8.2"
fi
unset obuild_platform_result
if [ "${obuild_platform_exe}" = "" ] ; then
  echo "Variable obuild_platform_exe not defined."
  exit
fi
obuild_platform_result=`"${obuild_platform_exe}" ${obuild_platform} 'UNIX'`
if [ ${obuild_platform_result} = yes ] ; then
HDF5_home="/usr/local/HDF5/1.6.5"
fi
unset obuild_platform_result
if [ "${obuild_platform_exe}" = "" ] ; then
  echo "Variable obuild_platform_exe not defined."
  exit
fi
obuild_platform_result=`"${obuild_platform_exe}" ${obuild_platform} 'UNIX'`
if [ ${obuild_platform_result} = yes ] ; then
zlib_home="/usr"
fi
unset obuild_platform_result
if [ "${obuild_platform_exe}" = "" ] ; then
  echo "Variable obuild_platform_exe not defined."
  exit
fi
obuild_platform_result=`"${obuild_platform_exe}" ${obuild_platform} 'UNIX'`
if [ ${obuild_platform_result} = yes ] ; then
if [ "${obuild_check_what}" = "CLHEP" ] ; then
  if [ ! -d "${CLHEP_home}" ] ; then
    echo "WARNING : CLHEP not found under ${CLHEP_home}"
    exit 1
  fi
fi
fi
unset obuild_platform_result
if [ "${obuild_platform_exe}" = "" ] ; then
  echo "Variable obuild_platform_exe not defined."
  exit
fi
obuild_platform_result=`"${obuild_platform_exe}" ${obuild_platform} 'UNIX'`
if [ ${obuild_platform_result} = yes ] ; then
if [ "${obuild_check_what}" = "Geant4" ] ; then
  if [ ! -d "${Geant4_home}" ] ; then
    echo "WARNING : Geant4 not found under ${Geant4_home}"
    exit 1
  fi
fi
fi
unset obuild_platform_result
if [ "${obuild_platform_exe}" = "" ] ; then
  echo "Variable obuild_platform_exe not defined."
  exit
fi
obuild_platform_result=`"${obuild_platform_exe}" ${obuild_platform} 'UNIX'`
if [ ${obuild_platform_result} = yes ] ; then
if [ "${obuild_check_what}" = "HDF5" ] ; then
  if [ ! -d "${HDF5_home}" ] ; then
    echo "WARNING : HDF5 not found under ${HDF5_home}"
    exit 1
  fi
fi
fi
unset obuild_platform_result

