-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvMDT.sh
86 lines (70 loc) · 1.94 KB
/
envMDT.sh
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
#!/bin/bash
drop_from_path()
{
# Assert that we got enough arguments
if test $# -ne 2 ; then
echo "drop_from_path: needs 2 arguments"
return 1
fi
local p=$1
local drop=$2
newpath=`echo $p | sed -e "s;:${drop}:;:;g" \
-e "s;:${drop}\$;;g" \
-e "s;^${drop}:;;g" \
-e "s;^${drop}\$;;g"`
}
### main ###
## clean old environment
if [ -n "${MDTROOT}" ] ; then
old_mdtroot=${MDTROOT}
if [ -n "${LD_LIBRARY_PATH}" ]; then
drop_from_path "$LD_LIBRARY_PATH" "${old_mdtroot}/cpp"
LD_LIBRARY_PATH=$newpath
drop_from_path "$LD_LIBRARY_PATH" "${WCSIMROOTDIR}"
LD_LIBRARY_PATH=$newpath
drop_from_path "$LD_LIBRARY_PATH" "${WCRDROOT}"
LD_LIBRARY_PATH=$newpath
fi
fi
if [ "x${BASH_ARGV[0]}" = "x" ]; then
MDTROOT="$PWD"; export MDTROOT
else
# get param to "."
thismdtroot=$(dirname ${BASH_ARGV[0]})
MDTROOT=$(cd ${thismdtroot} > /dev/null;pwd); export MDTROOT
fi
if [[ -z "${LD_LIBRARY_PATH}" ]]; then
export LD_LIBRARY_PATH=$MDTROOT/cpp
else
export LD_LIBRARY_PATH=${MDTROOT}/cpp:${LD_LIBRARY_PATH}
fi
#--- ROOT
if ! [ -x "$(command -v root-config)" ]; then
echo 'root-config could not be found, consider setup ROOT first'
return
else
ROOTDIR=$(root-config --prefix)
echo "Using ROOT installed in $ROOTDIR"
fi
#--- WCSim
if [[ -z "${WCSIMDIR}" ]]; then
echo "WCSIMDIR not set. Exit!"
return
else
echo "Using WCSIM installed in $WCSIMDIR"
#export LD_LIBRARY_PATH=${WCSIMDIR}:$LD_LIBRARY_PATH
if [[ -z "${WCSIMROOTDIR}" ]]; then
WCSIMROOTDIR=$WCSIMDIR
fi
echo "Using libWCSimRoot.so installed in $WCSIMROOTDIR"
export LD_LIBRARY_PATH=${WCSIMROOTDIR}:$LD_LIBRARY_PATH
fi
#--- MDT's utility
export WCRDROOT=$MDTROOT/app/utilities/WCRootData
export LD_LIBRARY_PATH=${WCRDROOT}:$LD_LIBRARY_PATH
echo "Setup complete!"
echo "MDTROOT=$MDTROOT"
echo "WCRDROOT=$WCRDROOT"
unset old_mdtroot
unset thismdtroot
unset -f drop_from_path