-
Notifications
You must be signed in to change notification settings - Fork 490
/
setenv
66 lines (56 loc) · 2.35 KB
/
setenv
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
#!/usr/bin/env -S sh -c "echo >&2 \"Error: You are running this script instead of sourcing it. Make sure to use it as 'source setenv' or '. setenv', otherwise its settings won't take effect.\"; exit 1"
# first argument can be (e.g. 'source setenv -q'):
# -q : do not show banner text on configuration success
# -r : remove an already configured environment
# Get the directory where this script reside using a trick (works differently on bash and zsh)
# On bash, the current script's name is in 'BASH_SOURCE[0]'
if [ "$BASH_VERSION" != "" ]; then # for BASH
dir=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
elif [ "$ZSH_VERSION" != "" ]; then # on zsh the script name is in '$0'
dir=$(cd $(dirname $0) && pwd)
else # on any other SH compatible shell we assume that the current working directory is the OMNeT++ root directory
dir=$(pwd)
fi
# check if dir is really pointing to an omnet++ installation dir
if [ ! -f $dir/bin/inet ]; then
echo "Error: '$dir' does not look like an INET root directory"
return 1
fi
# remove previous environment to prevent the accumulation of path elements
if [ -n "$INET_ROOT" ]; then
if [ "$1" = "-r" ]; then
echo "Removed previous environment for '$INET_ROOT'."
dir=
else
echo "Warning: overwriting previous environment for '$INET_ROOT'."
fi
export PATH=${PATH#$INET_ROOT/bin:}
export PYTHONPATH=${PYTHONPATH#$INET_ROOT/python}
export INET_ROOT=
export INET_OMNETPP_OPTIONS=
export INET_GDB_OPTIONS=
export INET_VALGRIND_OPTIONS=
fi
# do not continue if removal was requested
if [ "$1" = "-r" ]; then
return 0
fi
export PATH=$dir/bin:$PATH
export PYTHONPATH=$dir/python:$PYTHONPATH && PYTHONPATH=${PYTHONPATH%:} # required because colon at the end causes issues on Windows
export INET_ROOT=$dir
export INET_OMNETPP_OPTIONS="--image-path=$INET_ROOT/images"
export INET_GDB_OPTIONS="-quiet -ex run --args"
export INET_VALGRIND_OPTIONS="-v --tool=memcheck --leak-check=yes --show-reachable=no --leak-resolution=high --num-callers=40 --freelist-vol=4000000"
dir=
if [ "$1" != "-q" ]; then
echo "Environment for INET $(inet_version) in directory '$INET_ROOT' is ready."
if [ ! -f $INET_ROOT/src/Makefile ]; then
cat <<__END__
Type "make makefiles" and then "make" to build INET.
__END__
fi
fi
# source user specific script if present
if [ -f "$INET_ROOT/setenv_local" ] ; then
source $INET_ROOT/setenv_local
fi