ctools-setup.in
4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#! /bin/sh
# Filename: ctools-setup(.in)
# Description: Writes an initialization script for ctools software
# which is custom fit to the user and the particular
# software installation. Note that this script is
# designed to be invoked by ctools-init.csh/ctools-init.sh,
# and should not normally be invoked directly by user.
# Author/Date: Juergen Knoedlseder, IRAP, July 16, 2011
#-------------------------------------------------------------------------------
#
# Set fixed parameters
# ====================
this_script=`echo $0 | sed 's:.*/::'`
ctools_info="$this_script:"
ctools_error="$ctools_info ERROR --"
#
# Extract argument
# ================
flavor=$1
if [ "x$flavor" != xcsh -a "x$flavor" != xsh ]; then
echo "$ctools_info usage $this_script csh|sh" >&2
exit 3
fi
#
# Set parameters
# ==============
prefix="@prefix@"
exec_prefix="@exec_prefix@"
ctools_bin="@bindir@"
ctools_lib="@libdir@"
uname_system=`uname`
python_dir="@pythondir@"
python_exec_dir="@pyexecdir@"
pkgconfig_dir="@libdir@/pkgconfig"
man_dir="@datadir@/doc/ctools/man"
caldb_dir="@datadir@/caldb"
#
# Make pfiles available (this is needed for an installation where the
# ctools reside in a directory different from GammaLib, as the
# system does not know in this case where the syspfiles directory is
# ===================================================================
if [ -d $prefix/syspfiles/. ]; then
# make sure local parameter file directory exists
if [ ! -w $HOME/pfiles/. ]; then
mkdir $HOME/pfiles
if [ $? -ne 0 ]; then
echo "$ctools_error cannot create local pfiles directory $HOME/pfiles" >&2
exit 3
fi
fi
# use PFILES (if set) to set initial values for locpfiles and syspfiles
if [ "x$PFILES" != x ]; then
syspfiles=`echo $PFILES | sed "s%.*;%%"`
locpfiles=`echo $PFILES | sed "s%;*$syspfiles$%%"`
fi
# move $HOME/pfiles to front of locpfiles and weed out redundancies
if [ "x$locpfiles" = x ]; then
locpfiles="$HOME/pfiles"
else
locpfiles=`echo ":$locpfiles:" | \
sed "s%:$HOME/pfiles:%:%g" | sed "s%::*$%%"`
locpfiles="$HOME/pfiles$locpfiles"
fi
# move $prefix/syspfiles to front of syspfiles and weed out redundancies
if [ "x$syspfiles" = x ]; then
syspfiles="$prefix/syspfiles"
else
syspfiles=`echo ":$syspfiles:" | \
sed "s%:$prefix/syspfiles:%:%g" | sed "s%::*$%%"`
syspfiles="$prefix/syspfiles$syspfiles"
fi
# Set PFILES and PFCLOBBER environment variable
PFILES="$locpfiles;$syspfiles"
PFCLOBBER=1
fi
#
# Set PYTHONPATH
# ==============
if [ -z "${PYTHONPATH}" ]; then
PYTHONPATH=$python_dir:$python_exec_dir
else
PYTHONPATH=$python_dir:$python_exec_dir:$PYTHONPATH
fi
#
# Set PKG_CONFIG_PATH
# ===================
if [ -z "${PKG_CONFIG_PATH}" ]; then
PKG_CONFIG_PATH=$pkgconfig_dir
else
PKG_CONFIG_PATH=$pkgconfig_dir:$PKG_CONFIG_PATH
fi
#
# Set PATH
# ========
if [ -z "${PATH}" ]; then
PATH=$ctools_bin
else
PATH=$ctools_bin:$PATH
fi
#
# Set MANPATH
# ==============
if [ -z "${MANPATH}" ]; then
if `which manpath > /dev/null 2>&1` ; then
default_manpath=`manpath`
else
default_manpath=`man -w 2> /dev/null`
fi
fi
if [ -z "${MANPATH}" ]; then
MANPATH=$man_dir:${default_manpath}; export MANPATH
else
MANPATH=$man_dir:$MANPATH; export MANPATH
fi
#
# Set CALDB (if not yet set)
# ==========================
if [ -z "${CALDB}" ]; then
CALDB=$caldb_dir
fi
#
# List of variables needed in initialization script
# =================================================
varlist="PATH"
varlist="$varlist PYTHONPATH PKG_CONFIG_PATH MANPATH"
varlist="$varlist PFILES PFCLOBBER CALDB"
#
# Set LD_LIBRARY_PATH
# ===================
case $uname_system in
Darwin*)
;;
*)
if [ -z "${LD_LIBRARY_PATH}" ]; then
LD_LIBRARY_PATH=$ctools_lib
else
LD_LIBRARY_PATH=$ctools_lib:$LD_LIBRARY_PATH
fi
varlist="$varlist LD_LIBRARY_PATH"
;;
esac
#
# Save values in output initialization shell scripts
# ==================================================
# Name of temporary config script
HOST_NAME=`hostname`
ctools_config="$HOME/ctools-config-$HOST_NAME"
# Bourne Shell version, write only for sh flavor initialization
if [ $flavor = sh ]; then
rm -f $ctools_config$$.sh
touch $ctools_config$$.sh
for var in $varlist; do
eval "if [ \"x\$$var\" != x ]; then
echo \"\$var=\\\"\$$var\\\"; export \$var\" >> $ctools_config$$.sh;
fi"
done
echo "$ctools_config$$.sh"
# C Shell version, write only for csh flavor initialization
elif [ $flavor = csh ]; then
rm -f $ctools_config$$.csh
touch $ctools_config$$.csh
for var in $varlist; do
eval "if [ \"x\$$var\" != x ]; then
echo setenv \$var \\\"\$$var\\\" >> $ctools_config$$.csh;
fi"
done
echo "$ctools_config$$.csh"
fi