UMN CDMS Wiki archive
start › cdms › k100 › k100_simulation › centos_installation › geant4-centos-env.sh
#!/bin/bash

###############################################################################
# geant4-centos-env.sh
#   Bash source script meant to connect up the dependencies needed to build
#   and run Geant4 on a CentOS machine.
#
# It is a hassle to change the gcc version because all of the other
# libraries could change versions. This means when we want to change
# the gcc version, you must go through the cvmfs directory tree and
# input the versions of these other libraries that we need. There is
# almost certainly an intelligent bash script that could do this for
# us, but I am not writing one write now.
# You also need to touch these library directories so that they
# appear when cmake looks for them.
#
#   Assumptions:
#     - cvmfs is mounted on the current CentOS (==slc7) machine
###############################################################################


# location of cms shared libraries
# use this to specifiy which gcc should be used in compilation
_cvmfs_dir="/cvmfs/cms.cern.ch/slc7_amd64_gcc820"
export XERCESDIR="$_cvmfs_dir/external/xerces-c/3.1.3"
export GCCDIR="$_cvmfs_dir/external/gcc/8.2.0"

# Setup the input package
#   we assume we are given a path to cvmfs package 
#     and source the corresponding init.sh
__cvmfs_source() {
  _file_to_source=$1/etc/profile.d/init.sh
  
  if ! source $_file_to_source
  then
    echo "Could not source '$_we_good'! (Most likely cvmfs has been disconnected.)"
    return 1
  fi
  return 0
}

## Initialize libraries/programs from cvmfs
# all of these init scripts add their library paths to LD_LIBRARY_PATH
__cvmfs_source $XERCESDIR                        #xerces-c
__cvmfs_source $_cvmfs_dir/external/cmake/3.17.2 #cmake
__cvmfs_source $_cvmfs_dir/external/bz2lib/1.0.6 #bz2lib
__cvmfs_source $_cvmfs_dir/external/zlib/1.0     #zlib
__cvmfs_source $GCCDIR                           #gcc

# UNCOMMENT AFTER SUCCESSFUL GEANT4 BUILD!
#export G4DIR="full/path/to/where/geant4/is/installed"
#source $G4DIR/bin/geant4.sh || echo "Failure when setting up Geant4."