Commit 3814409114f9420dca038996efb6ee9694e237fe
1 parent
b26032d7
initial version
Showing
3 changed files
with
164 additions
and
0 deletions
src/gammalib-init.csh
0 โ 100755
| 1 | +# Filename: gammalib-init.csh | |
| 2 | +# Description: C-shell flavor initialization for GammaLib | |
| 3 | +# runs gammalib-setup to generate a temporary csh script | |
| 4 | +# tailored specifically to this user and GammaLib | |
| 5 | +# installation, then source that. | |
| 6 | +# Author/Date: Juergen Knoedlseder, IRAP, February 1, 2011 | |
| 7 | +# | |
| 8 | +if(${?GAMMALIB} == 0) then | |
| 9 | + echo "gammalib-init.csh: ERROR -- set GAMMALIB before sourcing gammalib-init.csh" | |
| 10 | +else if(-x "$GAMMALIB/bin/gammalib-setup") then | |
| 11 | + set gammalib_init=`$GAMMALIB/bin/gammalib-setup csh` | |
| 12 | + if($status == 0 && "x$gammalib_init" != x) then | |
| 13 | + if(-f "$gammalib_init") then | |
| 14 | + source $gammalib_init | |
| 15 | + endif | |
| 16 | + \rm -f $gammalib_init | |
| 17 | + endif | |
| 18 | + unset gammalib_init | |
| 19 | +else | |
| 20 | + echo "gammalib-init.csh: ERROR -- cannot execute $GAMMALIB/bin/gammalib-setup" | |
| 21 | +endif | ... | ... |
src/gammalib-init.sh
0 โ 100755
| 1 | +# Filename: gammalib-init.sh | |
| 2 | +# Description: Bourne-shell flavor initialization for GammaLib. | |
| 3 | +# Runs gammalib-setup to generate a sh script tailored | |
| 4 | +# specifically to this user and GammaLib installation, | |
| 5 | +# then source that. | |
| 6 | +# Author/Date: Juergen Knoedlseder, IRAP, February 1, 2011 | |
| 7 | +# | |
| 8 | +if [ "x$GAMMALIB" = x ]; then | |
| 9 | + echo "gammalib-init.sh: ERROR -- set GAMMALIB before sourcing gammalib-init.sh" | |
| 10 | +elif [ -x "$GAMMALIB/bin/gammalib-setup" ]; then | |
| 11 | + gammalib_init=`$GAMMALIB/bin/gammalib-setup sh` | |
| 12 | + if [ $? -eq 0 -a "x$gammalib_init" != x ]; then | |
| 13 | + if [ -f "$gammalib_init" ]; then | |
| 14 | + . $gammalib_init | |
| 15 | + fi | |
| 16 | + rm -f $gammalib_init | |
| 17 | + fi | |
| 18 | + unset gammalib_init | |
| 19 | +else | |
| 20 | + echo "gammalib-init.sh: ERROR -- cannot execute $GAMMALIB/bin/gammalib-setup" | |
| 21 | +fi | ... | ... |
src/gammalib-setup.in
0 โ 100644
| 1 | +#! /bin/sh | |
| 2 | +# Filename: gammalib-setup(.in) | |
| 3 | +# Description: Writes an initialization script for GammaLib software | |
| 4 | +# which is custom fit to the user and the particular | |
| 5 | +# software installation. Note that this script is | |
| 6 | +# designed to be invoked by gammalib-init.csh/gammalib-init.sh, | |
| 7 | +# and should not normally be invoked directly by user. | |
| 8 | +# Author/Date: Juergen Knoedlseder, IRAP, February 1, 2011 | |
| 9 | +#------------------------------------------------------------------------------- | |
| 10 | +# | |
| 11 | +# Set fixed parameters | |
| 12 | +# ==================== | |
| 13 | +this_script=`echo $0 | sed 's:.*/::'` | |
| 14 | +gammalib_info="$this_script:" | |
| 15 | + | |
| 16 | +# | |
| 17 | +# Extract argument | |
| 18 | +# ================ | |
| 19 | +flavor=$1 | |
| 20 | +if [ "x$flavor" != xcsh -a "x$flavor" != xsh ]; then | |
| 21 | + echo "$gammalib_info usage $this_script csh|sh" >&2 | |
| 22 | + exit 3 | |
| 23 | +fi | |
| 24 | + | |
| 25 | +# | |
| 26 | +# Set parameters | |
| 27 | +# ============== | |
| 28 | +prefix="@prefix@" | |
| 29 | +gammalib_bin="@prefix@/bin" | |
| 30 | +gammalib_lib="@prefix@/lib" | |
| 31 | +uname_system=`uname` | |
| 32 | +python_dir="@pythondir@" | |
| 33 | + | |
| 34 | +# | |
| 35 | +# Set LD_LIBRARY_PATH | |
| 36 | +# =================== | |
| 37 | +if [ "x$LD_LIBRARY_PATH" = x ]; then | |
| 38 | + LD_LIBRARY_PATH="$gammalib_lib" | |
| 39 | +else | |
| 40 | + LD_LIBRARY_PATH=`echo ":$LD_LIBRARY_PATH:" | \ | |
| 41 | + sed "s%:$gammalib_lib:%:%g" | sed "s%::*$%%"` | |
| 42 | + LD_LIBRARY_PATH="$gammalib_lib$LD_LIBRARY_PATH" | |
| 43 | +fi | |
| 44 | + | |
| 45 | +# | |
| 46 | +# Set DYLD_LIBRARY_PATH if required | |
| 47 | +# ================================= | |
| 48 | +case $uname_system in | |
| 49 | + Darwin*) | |
| 50 | + if [ "x$DYLD_LIBRARY_PATH" = x ]; then | |
| 51 | + DYLD_LIBRARY_PATH="$gammalib_lib" | |
| 52 | + else | |
| 53 | + DYLD_LIBRARY_PATH=`echo ":$DYLD_LIBRARY_PATH:" | \ | |
| 54 | + sed "s%:$gammalib_lib:%:%g" | sed "s%::*$%%"` | |
| 55 | + DYLD_LIBRARY_PATH="$gammalib_lib$DYLD_LIBRARY_PATH" | |
| 56 | + fi | |
| 57 | + ;; | |
| 58 | + CYGWIN*) | |
| 59 | + if [ "x$PATH" = x ]; then | |
| 60 | + PATH="$gammalib_lib" | |
| 61 | + else | |
| 62 | + PATH=`echo ":$PATH:" | sed "s%:$gammalib_lib:%:%g" | sed "s%::*$%%"` | |
| 63 | + PATH="$gammalib_lib$PATH" | |
| 64 | + fi | |
| 65 | + ;; | |
| 66 | +esac | |
| 67 | + | |
| 68 | +# | |
| 69 | +# Set PYTHONPATH | |
| 70 | +# ============== | |
| 71 | +if [ "x$PYTHONPATH" = x ]; then | |
| 72 | + PYTHONPATH="$python_dir" | |
| 73 | +else | |
| 74 | + PYTHONPATH=`echo ":$PYTHONPATH:" | \ | |
| 75 | + sed "s%:$python_dir:%:%g" | sed "s%::*$%%"` | |
| 76 | + PYTHONPATH="$python_dir$PYTHONPATH" | |
| 77 | +fi | |
| 78 | + | |
| 79 | +# | |
| 80 | +# Set PATH | |
| 81 | +# ======== | |
| 82 | +if [ "x$PATH" = x ]; then | |
| 83 | + PATH="$gammalib_bin" | |
| 84 | +else | |
| 85 | + PATH=`echo ":$PATH:" | \ | |
| 86 | + sed "s%:$gammalib_bin:%:%g" | sed "s%::*$%%"` | |
| 87 | + PATH="$gammalib_bin$PATH" | |
| 88 | +fi | |
| 89 | + | |
| 90 | +# | |
| 91 | +# List of variables needed in initialization script | |
| 92 | +# ================================================= | |
| 93 | +varlist="PATH PYTHONPATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH" | |
| 94 | + | |
| 95 | +# | |
| 96 | +# Save values in output initialization shell scripts | |
| 97 | +# ================================================== | |
| 98 | +# Name of temporary config script | |
| 99 | +HOST_NAME=`hostname` | |
| 100 | +gammalib_config="$HOME/gammalib-config-$HOST_NAME" | |
| 101 | + | |
| 102 | +# Bourne Shell version, write only for sh flavor initialization | |
| 103 | +if [ $flavor = sh ]; then | |
| 104 | + rm -f $gammalib_config$$.sh | |
| 105 | + touch $gammalib_config$$.sh | |
| 106 | + for var in $varlist; do | |
| 107 | + eval "if [ \"x\$$var\" != x ]; then | |
| 108 | + echo \"\$var=\\\"\$$var\\\"; export \$var\" >> $gammalib_config$$.sh; | |
| 109 | + fi" | |
| 110 | + done | |
| 111 | + echo "$gammalib_config$$.sh" | |
| 112 | +# C Shell version, write only for csh flavor initialization | |
| 113 | +elif [ $flavor = csh ]; then | |
| 114 | + rm -f $gammalib_config$$.csh | |
| 115 | + touch $gammalib_config$$.csh | |
| 116 | + for var in $varlist; do | |
| 117 | + eval "if [ \"x\$$var\" != x ]; then | |
| 118 | + echo setenv \$var \\\"\$$var\\\" >> $gammalib_config$$.csh; | |
| 119 | + fi" | |
| 120 | + done | |
| 121 | + echo "$gammalib_config$$.csh" | |
| 122 | +fi | ... | ... |