Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:24

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}$" | 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 }
0054 #-----------------------------------------------------------------------------
0055 #
0056 SOURCE=${BASH_ARGV[0]}
0057 if [ "x$SOURCE" = "x" ]; then
0058     SOURCE=${(%):-%N} # for zsh
0059 fi
0060 
0061 dd4hep_parse_this $SOURCE  dd4hep;
0062 #
0063 # These 3 are the main configuration variables: ROOT, Geant4 and XercesC
0064 # --> LCIO & Co. are handled elsewhere!
0065 
0066 if [ -z $ROOTSYS ]; then
0067     export ROOTSYS=`dirname @ROOT_DIR@`
0068 fi;
0069 export Geant4_DIR=@Geant4_DIR@;
0070 export XERCESCINSTALL=@XERCESC_ROOT_DIR@;
0071 #
0072 #----DD4hep installation directory--------------------------------------------
0073 export DD4hepINSTALL=${THIS};
0074 export DD4hep_DIR=${THIS};
0075 export DD4hep_ROOT=${THIS};
0076 #
0077 #----------- source the ROOT environment first ------------------------------
0078 ROOTENV_INIT=${ROOTSYS}/bin/thisroot.sh;
0079 test -r ${ROOTENV_INIT} && { cd $(dirname ${ROOTENV_INIT}); . ./$(basename ${ROOTENV_INIT}) ; cd $OLDPWD ; }
0080 #
0081 #----Geant4 LIBRARY_PATH------------------------------------------------------
0082 if [ ${Geant4_DIR} ]; then
0083     G4LIB_DIR=`dirname ${Geant4_DIR} | sed 's@/cmake\$@@'`;
0084     export G4INSTALL=`dirname ${G4LIB_DIR}`;
0085     export G4ENV_INIT=${G4INSTALL}/bin/geant4.sh
0086     # ---------- initialze geant4 environment
0087     test -r ${G4ENV_INIT} && { cd $(dirname ${G4ENV_INIT}) ; . ./$(basename ${G4ENV_INIT}) ; cd $OLDPWD ; }
0088     #---- if geant4 was built with external CLHEP we have to extend the dynamic search path
0089     if [ @GEANT4_USE_CLHEP@ ] ; then
0090         dd4hep_add_library_path @CLHEP_LIBRARY_PATH@;
0091     fi;
0092     export CLHEP_DIR=@CLHEP_INCLUDE_DIR@/../;
0093     export CLHEP_ROOT_DIR=@CLHEP_INCLUDE_DIR@/../;
0094     export CLHEP_INCLUDE_DIR=@CLHEP_INCLUDE_DIR@;
0095     unset G4ENV_INIT;
0096     unset G4LIB_DIR;
0097 fi;
0098 #
0099 #----XercesC LIBRARY_PATH-----------------------------------------------------
0100 if [ ${XERCESCINSTALL} ]; then
0101     dd4hep_add_library_path ${XERCESCINSTALL}/lib;
0102 fi;
0103 #
0104 #----PATH---------------------------------------------------------------------
0105 dd4hep_add_path PATH       ${THIS}/bin;
0106 #----LIBRARY_PATH-------------------------------------------------------------
0107 dd4hep_add_library_path    ${THIS}/lib;
0108 #----PYTHONPATH---------------------------------------------------------------
0109 dd4hep_add_path PYTHONPATH ${THIS}/@DD4HEP_PYTHON_INSTALL_DIR@;
0110 #----ROOT_INCLUDE_PATH--------------------------------------------------------
0111 dd4hep_add_path ROOT_INCLUDE_PATH ${THIS}/include;
0112 #-----------------------------------------------------------------------------
0113 if [ @APPLE@ ];
0114 then
0115     export DD4HEP_LIBRARY_PATH=${DYLD_LIBRARY_PATH};
0116 else
0117     export DD4HEP_LIBRARY_PATH=${LD_LIBRARY_PATH};
0118 fi;
0119 #-----------------------------------------------------------------------------
0120 #
0121 unset ROOTENV_INIT;
0122 unset THIS;
0123 unset SOURCE;
0124 #-----------------------------------------------------------------------------