Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 07:51:52

0001 #!/bin/bash
0002 # Source this script to set up the DD4Hep installation that this script is part of.
0003 #
0004 # This script if for the csh like shells, see thisdd4hep.csh for csh like shells.
0005 #
0006 # Author: Pere Mato. F. Gaede, M.Frank
0007 #-------------------------------------------------------------------------------
0008 #
0009 #echo " ### thisdd4hep.sh:   initialize the environment for DD4hep ! " 
0010 #
0011 #-----------------------------------------------------------------------------
0012 dd4hep_parse_this()   {
0013     local SOURCE=${1}
0014     local package=${2};
0015     if [ "x${SOURCE}" = "x" ]; then
0016         if [ -f bin/this${package}.sh ]; then
0017             THIS="$PWD"; export THIS
0018         elif [ -f ./this${package}.sh ]; then
0019             THIS=$(cd ..  > /dev/null; pwd); export THIS
0020         else
0021             echo ERROR: must "cd where/${package}/is" before calling ". bin/this${package}.sh" for this version of bash!
0022             THIS=; export THIS
0023             return 1
0024         fi
0025     else
0026         # get param to "."
0027         local thisroot=$(dirname ${SOURCE})
0028         THIS=$(cd ${thisroot}/.. > /dev/null;pwd); export THIS
0029     fi
0030 }
0031 #-----------------------------------------------------------------------------
0032 dd4hep_add_path()   {
0033     local path_name=${1}
0034     local path_prefix=${2}
0035     eval path_value=\$$path_name
0036     # Prevent duplicates
0037     path_value=`echo ${path_value} | tr : '\n' | (grep -v "^${path_prefix}$" || true) | tr '\n' : | sed 's|:$||'`
0038     path_value="${path_prefix}${path_value:+:${path_value}}"
0039     eval export ${path_name}='${path_value}'
0040     unset path_value
0041 }
0042 #-----------------------------------------------------------------------------
0043 dd4hep_add_library_path()    {
0044     local p=${1};
0045     if [ @APPLE@ ]; then
0046         # Do not prepend system library locations on macOS. Stuff will break.
0047         [[ "$p" = "/usr/lib" || "$p" = "/usr/local/lib" ]] && return
0048         dd4hep_add_path DYLD_LIBRARY_PATH     "$p"
0049         dd4hep_add_path DD4HEP_LIBRARY_PATH   "$p"
0050     else
0051         dd4hep_add_path LD_LIBRARY_PATH       "$p"
0052     fi
0053     dd4hep_add_path ROOT_LIBRARY_PATH "$p"
0054 }
0055 #-----------------------------------------------------------------------------
0056 #
0057 SOURCE=${BASH_ARGV[0]}
0058 if [ "x$SOURCE" = "x" ]; then
0059     SOURCE=${(%):-%N} # for zsh
0060 fi
0061 
0062 dd4hep_parse_this $SOURCE  dd4hep;
0063 #
0064 # These 3 are the main configuration variables: ROOT, Geant4 and XercesC
0065 # --> LCIO & Co. are handled elsewhere!
0066 
0067 if [ -z $ROOTSYS ]; then
0068     export ROOTSYS=`dirname @ROOT_DIR@`
0069 fi;
0070 export Geant4_DIR=@Geant4_DIR@;
0071 export XERCESCINSTALL=@XERCESC_ROOT_DIR@;
0072 #
0073 #----DD4hep installation directory--------------------------------------------
0074 export DD4hepINSTALL=${THIS};
0075 export DD4hep_DIR=${THIS};
0076 export DD4hep_ROOT=${THIS};
0077 #
0078 #----------- source the ROOT environment first ------------------------------
0079 ROOTENV_INIT=${ROOTSYS}/bin/thisroot.sh;
0080 test -r ${ROOTENV_INIT} && { cd $(dirname ${ROOTENV_INIT}); . ./$(basename ${ROOTENV_INIT}) ; cd $OLDPWD ; }
0081 #
0082 #----Geant4 LIBRARY_PATH------------------------------------------------------
0083 if [ ${Geant4_DIR} ]; then
0084     G4LIB_DIR=`dirname ${Geant4_DIR} | sed 's@/cmake\$@@'`;
0085     export G4INSTALL=`dirname ${G4LIB_DIR}`;
0086     export G4ENV_INIT=${G4INSTALL}/bin/geant4.sh
0087     # ---------- initialze geant4 environment
0088     test -r ${G4ENV_INIT} && { cd $(dirname ${G4ENV_INIT}) ; . ./$(basename ${G4ENV_INIT}) ; cd $OLDPWD ; }
0089     #---- if geant4 was built with external CLHEP we have to extend the dynamic search path
0090     if [ @GEANT4_USE_CLHEP@ ] ; then
0091         dd4hep_add_library_path @CLHEP_LIBRARY_PATH@;
0092     fi;
0093     export CLHEP_DIR=@CLHEP_INCLUDE_DIR@/../;
0094     export CLHEP_ROOT_DIR=@CLHEP_INCLUDE_DIR@/../;
0095     export CLHEP_INCLUDE_DIR=@CLHEP_INCLUDE_DIR@;
0096     unset G4ENV_INIT;
0097     unset G4LIB_DIR;
0098 fi;
0099 #
0100 #----XercesC LIBRARY_PATH-----------------------------------------------------
0101 if [ ${XERCESCINSTALL} ]; then
0102     dd4hep_add_library_path ${XERCESCINSTALL}/lib;
0103 fi;
0104 #
0105 #----PATH---------------------------------------------------------------------
0106 dd4hep_add_path PATH       ${THIS}/bin;
0107 #----LIBRARY_PATH-------------------------------------------------------------
0108 dd4hep_add_library_path    ${THIS}/lib;
0109 #----PYTHONPATH---------------------------------------------------------------
0110 dd4hep_add_path PYTHONPATH ${THIS}/@DD4HEP_PYTHON_INSTALL_DIR@;
0111 #----ROOT_INCLUDE_PATH--------------------------------------------------------
0112 dd4hep_add_path ROOT_INCLUDE_PATH ${THIS}/include;
0113 #-----------------------------------------------------------------------------
0114 if [ @APPLE@ ];
0115 then
0116     export DD4HEP_LIBRARY_PATH=${DYLD_LIBRARY_PATH};
0117 else
0118     export DD4HEP_LIBRARY_PATH=${LD_LIBRARY_PATH};
0119 fi;
0120 #-----------------------------------------------------------------------------
0121 #
0122 unset ROOTENV_INIT;
0123 unset THIS;
0124 unset SOURCE;
0125 #-----------------------------------------------------------------------------