Commit 46ddfb242cdbeab15e5884c9cf90a3c35bc05ced

Authored by knodlseder
1 parent 2f839a12

initial version

src/ctatools-init.csh 0 โ†’ 100755
  1 +# Filename: ctatools-init.csh
  2 +# Description: C-shell flavor initialization for ctatools
  3 +# runs ctatools-setup to generate a temporary csh script
  4 +# tailored specifically to this user and ctatools
  5 +# installation, then source that.
  6 +# Author/Date: Juergen Knoedlseder, IRAP, July 16, 2011
  7 +#
  8 +if(${?CTATOOLS} == 0) then
  9 + echo "ctatools-init.csh: ERROR -- set CTATOOLS before sourcing ctatools-init.csh"
  10 +else if(-x "$CTATOOLS/bin/ctatools-setup") then
  11 + set ctatools_init=`$CTATOOLS/bin/ctatools-setup csh`
  12 + if($status == 0 && "x$ctatools_init" != x) then
  13 + if(-f "$ctatools_init") then
  14 + source $ctatools_init
  15 + endif
  16 + \rm -f $ctatools_init
  17 + endif
  18 + unset ctatools_init
  19 +else
  20 + echo "ctatools-init.csh: ERROR -- cannot execute $CTATOOLS/bin/ctatools-setup"
  21 +endif
... ...
src/ctatools-init.sh 0 โ†’ 100755
  1 +# Filename: ctatools-init.sh
  2 +# Description: Bourne-shell flavor initialization for ctatools.
  3 +# Runs ctatools-setup to generate a sh script tailored
  4 +# specifically to this user and ctatools installation,
  5 +# then source that.
  6 +# Author/Date: Juergen Knoedlseder, IRAP, July 16, 2011
  7 +#
  8 +if [ "x$CTATOOLS" = x ]; then
  9 + echo "ctatools-init.sh: ERROR -- set CTATOOLS before sourcing ctatools-init.sh"
  10 +elif [ -x "$CTATOOLS/bin/ctatools-setup" ]; then
  11 + ctatools_init=`$CTATOOLS/bin/ctatools-setup sh`
  12 + if [ $? -eq 0 -a "x$ctatools_init" != x ]; then
  13 + if [ -f "$ctatools_init" ]; then
  14 + . $ctatools_init
  15 + fi
  16 + rm -f $ctatools_init
  17 + fi
  18 + unset ctatools_init
  19 +else
  20 + echo "ctatools-init.sh: ERROR -- cannot execute $CTATOOLS/bin/ctatools-setup"
  21 +fi
... ...
src/ctatools-setup.in 0 โ†’ 100644
  1 +#! /bin/sh
  2 +# Filename: ctatools-setup(.in)
  3 +# Description: Writes an initialization script for ctatools 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 ctatools-init.csh/ctatools-init.sh,
  7 +# and should not normally be invoked directly by user.
  8 +# Author/Date: Juergen Knoedlseder, IRAP, July 16, 2011
  9 +#-------------------------------------------------------------------------------
  10 +#
  11 +# Set fixed parameters
  12 +# ====================
  13 +this_script=`echo $0 | sed 's:.*/::'`
  14 +ctatools_info="$this_script:"
  15 +
  16 +#
  17 +# Extract argument
  18 +# ================
  19 +flavor=$1
  20 +if [ "x$flavor" != xcsh -a "x$flavor" != xsh ]; then
  21 + echo "$ctatools_info usage $this_script csh|sh" >&2
  22 + exit 3
  23 +fi
  24 +
  25 +#
  26 +# Set parameters
  27 +# ==============
  28 +prefix="@prefix@"
  29 +ctatools_bin="@prefix@/bin"
  30 +ctatools_lib="@prefix@/lib"
  31 +uname_system=`uname`
  32 +python_dir="@pythondir@"
  33 +pkgconfig_dir="@prefix@/lib/pkgconfig"
  34 +man_dir="@prefix@/share/doc/ctatools/man"
  35 +
  36 +#
  37 +# Set LD_LIBRARY_PATH
  38 +# ===================
  39 +if [ "x$LD_LIBRARY_PATH" = x ]; then
  40 + LD_LIBRARY_PATH="$ctatools_lib"
  41 +else
  42 + LD_LIBRARY_PATH=`echo ":$LD_LIBRARY_PATH:" | \
  43 + sed "s%:$ctatools_lib:%:%g" | sed "s%::*$%%"`
  44 + LD_LIBRARY_PATH="$ctatools_lib$LD_LIBRARY_PATH"
  45 +fi
  46 +
  47 +#
  48 +# Set DYLD_LIBRARY_PATH if required
  49 +# =================================
  50 +case $uname_system in
  51 + Darwin*)
  52 + if [ "x$DYLD_LIBRARY_PATH" = x ]; then
  53 + DYLD_LIBRARY_PATH="$ctatools_lib"
  54 + else
  55 + DYLD_LIBRARY_PATH=`echo ":$DYLD_LIBRARY_PATH:" | \
  56 + sed "s%:$ctatools_lib:%:%g" | sed "s%::*$%%"`
  57 + DYLD_LIBRARY_PATH="$ctatools_lib$DYLD_LIBRARY_PATH"
  58 + fi
  59 + ;;
  60 + CYGWIN*)
  61 + if [ "x$PATH" = x ]; then
  62 + PATH="$ctatools_lib"
  63 + else
  64 + PATH=`echo ":$PATH:" | sed "s%:$ctatools_lib:%:%g" | sed "s%::*$%%"`
  65 + PATH="$ctatools_lib$PATH"
  66 + fi
  67 + ;;
  68 +esac
  69 +
  70 +#
  71 +# Set PYTHONPATH
  72 +# ==============
  73 +if [ "x$PYTHONPATH" = x ]; then
  74 + PYTHONPATH="$python_dir"
  75 +else
  76 + PYTHONPATH=`echo ":$PYTHONPATH:" | \
  77 + sed "s%:$python_dir:%:%g" | sed "s%::*$%%"`
  78 + PYTHONPATH="$python_dir$PYTHONPATH"
  79 +fi
  80 +
  81 +#
  82 +# Set PKG_CONFIG_PATH
  83 +# ===================
  84 +if [ "x$PKG_CONFIG_PATH" = x ]; then
  85 + PKG_CONFIG_PATH="$pkgconfig_dir"
  86 +else
  87 + PKG_CONFIG_PATH=`echo ":$PKG_CONFIG_PATH:" | \
  88 + sed "s%:$pkgconfig_dir:%:%g" | sed "s%::*$%%"`
  89 + PKG_CONFIG_PATH="$pkgconfig_dir$PKG_CONFIG_PATH"
  90 +fi
  91 +
  92 +#
  93 +# Set PATH
  94 +# ========
  95 +if [ "x$PATH" = x ]; then
  96 + PATH="$ctatools_bin"
  97 +else
  98 + PATH=`echo ":$PATH:" | \
  99 + sed "s%:$ctatools_bin:%:%g" | sed "s%::*$%%"`
  100 + PATH="$ctatools_bin$PATH"
  101 +fi
  102 +
  103 +#
  104 +# Set MANPATH
  105 +# ==============
  106 +if [ "x$MANPATH" = x ]; then
  107 + MANPATH="$man_dir"
  108 +else
  109 + MANPATH=`echo ":$MANPATH:" | \
  110 + sed "s%:$man_dir:%:%g" | sed "s%::*$%%"`
  111 + MANPATH="$man_dir$MANPATH"
  112 +fi
  113 +
  114 +#
  115 +# List of variables needed in initialization script
  116 +# =================================================
  117 +varlist="PATH PYTHONPATH PKG_CONFIG_PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH MANPATH"
  118 +
  119 +#
  120 +# Save values in output initialization shell scripts
  121 +# ==================================================
  122 +# Name of temporary config script
  123 +HOST_NAME=`hostname`
  124 +ctatools_config="$HOME/ctatools-config-$HOST_NAME"
  125 +
  126 +# Bourne Shell version, write only for sh flavor initialization
  127 +if [ $flavor = sh ]; then
  128 + rm -f $ctatools_config$$.sh
  129 + touch $ctatools_config$$.sh
  130 + for var in $varlist; do
  131 + eval "if [ \"x\$$var\" != x ]; then
  132 + echo \"\$var=\\\"\$$var\\\"; export \$var\" >> $ctatools_config$$.sh;
  133 + fi"
  134 + done
  135 + echo "$ctatools_config$$.sh"
  136 +# C Shell version, write only for csh flavor initialization
  137 +elif [ $flavor = csh ]; then
  138 + rm -f $ctatools_config$$.csh
  139 + touch $ctatools_config$$.csh
  140 + for var in $varlist; do
  141 + eval "if [ \"x\$$var\" != x ]; then
  142 + echo setenv \$var \\\"\$$var\\\" >> $ctatools_config$$.csh;
  143 + fi"
  144 + done
  145 + echo "$ctatools_config$$.csh"
  146 +fi
... ...