Print

Print


Commit in SimDist/scripts on MAIN
slic-ldpath.sh.in+42-411.1 -> 1.2
slight reorg and additional comments

SimDist/scripts
slic-ldpath.sh.in 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- slic-ldpath.sh.in	29 Jun 2011 21:19:43 -0000	1.1
+++ slic-ldpath.sh.in	30 Jun 2011 00:28:40 -0000	1.2
@@ -1,56 +1,57 @@
 #!/bin/sh
 #
-# This is a relocateable script for setting up the library load path for SimDist libraries
+# This is a relocatable script for setting up the library load path for SimDist libraries
 # on multiple platforms (Linux, OSX, Cygwin).  It must be processed by SimDist's configure
 # to produce ./scripts/slic-ldpath.sh which can then be sourced on the user's machine.
 #
 # It tries to find the local SimDist installation using two ways...
 #
-# --Check if it is the current directory and then proceed automatically if it appears okay.
-# --Check for user setting of SIM_HOME which is checked for validity.
+# --Check for user setting of the SIMDIST_HOME variable.
+# --Check if SimDist root appears to be the current directory.
 #
-# If neither works, an error message is printing requesting manual setting of SIM_HOME.
+# If neither works, the load path won't be set and the script exits with an error message.
+# It does NOT call exit, as this would kill the user's shell if the script is included
+# or sourced.
 #
-# The tricks used in ./scripts/slic.sh cannot be used here because this script is included
-# rather than run so information on the path is lost.
+# NOTE: The tricks used in ./scripts/slic.sh to find SimDist cannot be used here, 
+# because this script is included into the user environment rather than executed.
 #
 
-# Check if running from the SimDist base dir.
-if [ ! -d ./packages/slic ]; then
-    # Not in base dir, so check if SIM_HOME was set.
-    if [ -z "$SIM_HOME" ]; then
-        # Oops!  Need the user to tell us where SIM_HOME is located.
-        echo "ERROR:  This script doesn't know where SimDist is locally installed.  Please set SIM_HOME to point to the SimDist base dir."
-        exit 1
-    fi
-# Looks like curr dir is SimDist.
+# Check for user setting of SIMDIST_HOME variable.
+if [ -n "${1}" ]; then
+    SIMDIST_HOME=$1
 else
-    SIM_HOME=`pwd`
-fi
-
-# Check that the SIM_HOME var points to SimDist area.
-if [ ! -d $SIM_HOME/packages/slic ]; then
-    echo "ERROR: The SIM_HOME variable setting does not appear to point to a valid SimDist."
-    exit 1
+    # Check if in SimDist root area.
+    if [ -d ./packages/slic ]; then
+        SIMDIST_HOME=`pwd`
+    fi
 fi
 
-echo "SIM_HOME=${SIM_HOME}"
-
-# Figure out library paths for deps based on relative SimDist path.
-# FIXME: The relative paths should be figured out in configure, not here.  Then SIM_HOME dir can then be added in front here.
-CLHEP_LIB_DIR=${SIM_HOME}/packages/clhep/@CLHEP_VERSION@/lib
-G4_LIB_DIR=${SIM_HOME}/packages/geant4/@GEANT4_VERSION@/lib/@G4SYSTEM@
-GDML_LIB_DIR=${SIM_HOME}/packages/gdml/@GDML_VERSION@/CPPGDML/build/@G4SYSTEM@/lib
-XERCES_LIB_DIR=${SIM_HOME}/packages/xerces/@XERCES_VERSION@/lib
-LCIO_LIB_DIR=${SIM_HOME}/packages/lcio/@LCIO_VERSION@/lib
-LCDD_LIB_DIR=${SIM_HOME}/packages/lcdd/@LCDD_VERSION@/lib
-HEPPDT_LIB_DIR=${SIM_HOME}/packages/heppdt/@[log in to unmask]
-HEPPID_LIB_DIR=${SIM_HOME}/packages/heppdt/@[log in to unmask]
-SLIC_LIB_DIR=${SIM_HOME}/packages/slic/@SLIC_VERSION@/lib
+# Check that SIMDIST_HOME is setup and has a known sub-directory.  Messed up or incomplete
+# directory structure could get by this check, but it is probably good enough.
+if [ -d ${SIMDIST_HOME}/packages/slic ]; then
+
+    echo "SIMDIST_HOME=${SIMDIST_HOME}"
+
+    # Set library paths for packages.
+    CLHEP_LIB_DIR=${SIMDIST_HOME}/packages/clhep/@CLHEP_VERSION@/lib
+    G4_LIB_DIR=${SIMDIST_HOME}/packages/geant4/@GEANT4_VERSION@/lib/@G4SYSTEM@
+    GDML_LIB_DIR=${SIMDIST_HOME}/packages/gdml/@GDML_VERSION@/CPPGDML/build/@G4SYSTEM@/lib
+    XERCES_LIB_DIR=${SIMDIST_HOME}/packages/xerces/@XERCES_VERSION@/lib
+    LCIO_LIB_DIR=${SIMDIST_HOME}/packages/lcio/@LCIO_VERSION@/lib
+    LCDD_LIB_DIR=${SIMDIST_HOME}/packages/lcdd/@LCDD_VERSION@/lib
+    HEPPDT_LIB_DIR=${SIMDIST_HOME}/packages/heppdt/@[log in to unmask]
+    HEPPID_LIB_DIR=${SIMDIST_HOME}/packages/heppdt/@[log in to unmask]
+    SLIC_LIB_DIR=${SIMDIST_HOME}/packages/slic/@SLIC_VERSION@/lib
+    #QT_LIB_DIR=@QTHOME@/lib
+    
+    # FIXME: Variables with relative path set by configure would be better, e.g. CLHEP_LIB_RELDIR, etc.
+    
+    # Set the platform's load path variable.
+    unset @OS_SHARED_LIBS_VAR@
+    export @OS_SHARED_LIBS_VAR@=${CLHEP_LIB_DIR}:${G4_LIB_DIR}:${GDML_LIB_DIR}:${XERCES_LIB_DIR}:${LCIO_LIB_DIR}:${LCDD_LIB_DIR}:${HEPPDT_LIB_DIR}:${HEPPID_LIB_DIR}:${SLIC_LIB_DIR}
 
-#QT_LIB_DIR=@QTHOME@/lib
-
-unset @OS_SHARED_LIBS_VAR@
-export @OS_SHARED_LIBS_VAR@=${CLHEP_LIB_DIR}:${G4_LIB_DIR}:${GDML_LIB_DIR}:${XERCES_LIB_DIR}:${LCIO_LIB_DIR}:${LCDD_LIB_DIR}:${HEPPDT_LIB_DIR}:${HEPPID_LIB_DIR}:${SLIC_LIB_DIR}
-
-echo "@OS_SHARED_LIBS_VAR@=${@OS_SHARED_LIBS_VAR@}"
+    echo "@OS_SHARED_LIBS_VAR@=${@OS_SHARED_LIBS_VAR@}"
+else
+    echo "ERROR: $SIMDIST_HOME doesn't appear to point to a valid SimDist installation!"
+fi
CVSspam 0.2.8