-
Notifications
You must be signed in to change notification settings - Fork 9
/
setenv.sh
executable file
·124 lines (114 loc) · 4.09 KB
/
setenv.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
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
#!/bin/bash
#
# \file setenv.sh
#
# Sets up necessary environment variable for ReconOS
#
# The respective environment variables are:
#
# * RECONOS -- the top-level directory of the ReconOS repository
# * RECONOS_VER -- current version to use (format: vX_YY_Z)
# * ECOS_REPOSITORY -- points to the 'packages' dir of patched eCos
# * ECOS_EXTRA -- used by eCos as additional include dir
# * EDK_LIB -- precompiled EDK simulation models
# * ISE_LIB -- precompiled ISE simulation models
# * MODELSIM -- modelsim.ini with ReconOS references
# * PATH -- ReconOS tools directory
# * PYTHONPATH -- Path to ReconOS python script library
#
# This script needs to be sourced to take effect:
#
# . <path_to_reconos>/setenv.sh [-v]
#
# When "-v" is specified, the current ReconOS environment is printed.
#
# \author Enno Luebbers <[email protected]>
# \date 11.08.2010
#
#---------------------------------------------------------------------------
# %%%RECONOS_COPYRIGHT_BEGIN%%%
#
# This file is part of ReconOS (http://www.reconos.de).
# Copyright (c) 2006-2010 The ReconOS Project and contributors (see AUTHORS).
# All rights reserved.
#
# ReconOS is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# ReconOS is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with ReconOS. If not, see <http://www.gnu.org/licenses/>.
#
# %%%RECONOS_COPYRIGHT_END%%%
#---------------------------------------------------------------------------
#
# check whether we've been sourced correctly
if [ "$0" != "-bash" ] && [ `basename $0` = "setenv.sh" ]; then
echo "You need to source 'setenv.sh', not execute it."
echo "Try:"
echo " . <path_to_reconos>/setenv.sh"
exit 1
fi
# check whether environment has already been set
if [ -n "$RECONOS" ]; then
echo -n "RECONOS environment already set. Continue [y|N]? "
read RETVAL
if [ "$RETVAL" != 'y' ]; then
return
fi
fi
# get directory this script is residing in
# found on http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-in
SCRIPT_PATH="${BASH_SOURCE[0]}";
if([ -h "${SCRIPT_PATH}" ]) then
while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done
fi
pushd . > /dev/null
cd `dirname ${SCRIPT_PATH}` > /dev/null
SCRIPT_PATH=`pwd`;
popd > /dev/null
# set variables to default values
RECONOS="$SCRIPT_PATH"
if [ ! -f "$RECONOS/current_version" ]; then
echo "'current_version' not found. Your ReconOS install seems broken.'"
return
fi
read RECONOS_VER < "$RECONOS/current_version"
if [ -z $OSIF_VER ]; then
OSIF_VER=$RECONOS_VER
fi
ECOS_REPOSITORY="$RECONOS/core/ecos/ecos-patched/ecos/packages"
ECOS_EXTRA="$RECONOS/core/ecos/include"
MODELSIM="$RECONOS/support/modelsim.ini"
# only add path if not already present
PATH_TO_ADD="$RECONOS/tools:$RECONOS/tools/python"
if echo $PATH | grep -v "$PATH_TO_ADD" > /dev/null; then
PATH="$PATH_TO_ADD:$PATH"
else
PATH="$PATH"
fi
# check if EDK and ISE libs exist
# TODO
EDK_LIB="/Xilinx/EDK_Lib"
ISE_LIB="/Xilinx/ISE_Lib"
# add ReconOS python scripts to PYTHONPATH
PYTHONPATH="$RECONOS/tools/python:$PYTHONPATH"
export RECONOS RECONOS_VER OSIF_VER ECOS_REPOSITORY ECOS_EXTRA MODELSIM PATH EDK_LIB ISE_LIB PYTHONPATH
# print environment, if requested
if [ "$1" = '-v' ]; then
echo " RECONOS: '$RECONOS'"
echo " RECONOS_VER: '$RECONOS_VER'"
echo " ECOS_REPOSITORY: '$ECOS_REPOSITORY'"
echo " ECOS_EXTRA: '$ECOS_EXTRA'"
echo " MODELSIM: '$MODELSIM'"
echo " PATH: '$PATH'"
echo " EDK_LIB: '$EDK_LIB'"
echo " ISE_LIB: '$ISE_LIB'"
echo " PYTHONPATH: '$PYTHONPATH'"
fi