OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [utils/] [setup/] [minsoc-install.sh] - Blame information for rev 171

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 76 rfajardo
#!/bin/bash
2 141 rfajardo
# Author: Constantinos Xanthopoulos & Raul Fajardo
3 76 rfajardo
# This script install MinSOC tree
4
# under a specific directory.
5
 
6
# ===== CONFIGURATIONS =====
7
# ==========================
8 141 rfajardo
MINSOC_SVN_URL=http://opencores.org/ocsvn/minsoc/minsoc/trunk
9
export SCRIPT_DIR="$( cd -P "$( dirname "$0" )" && pwd )"
10
export DIR_TO_INSTALL=`pwd`
11 76 rfajardo
 
12
# Debug ?
13
export DEBUG=0;
14 141 rfajardo
. ${SCRIPT_DIR}/beautify.sh
15 76 rfajardo
 
16
function testtool
17
{
18
    #    is_missing=`which $1 2>&1 | grep no`
19
    is_missing=`whereis -b $1 2>&1 | grep :$`
20
    if [ -z "$is_missing" ]
21
    then
22
        cecho "$1 is installed, pass"
23
    else
24
        errormsg "$1 is not installed, install it and re-run this installation script."
25
    fi
26
}
27
 
28 106 rfajardo
 
29
#Setting environment
30
ENV=`uname -o`
31
if [ "$ENV" != "GNU/Linux" ] && [ "$ENV" != "Cygwin" ]
32
then
33
    errormsg "Environment $ENV not supported by this script."
34
fi
35
cecho "Building tools for ${ENV} system"
36
 
37
is_arch64=`uname -m | grep 64`
38
if [ -z $is_arch64 ]
39
then
40
    KERNEL_ARCH="32"
41
else
42
    KERNEL_ARCH="64"
43
fi
44
 
45
 
46 76 rfajardo
# User check!
47
if [ `whoami` = "root" ];
48
then
49
    errormsg "You shouldn't be root for this script to run.";
50
fi;
51
 
52
 
53 168 rfajardo
# Selecting automated or advanced intallation modes
54
# Wizard
55
if [ -z "${AUTO}" ]
56
then
57
        while [ "${AUTO}" != "R" ] &&  [ "${AUTO}" != "A" ]
58
        do
59
            cecho "Select installation mode.";
60
                cnecho "        Enter R for Resumed or A for Advanced mode or H for Help: "
61
            read AUTO;
62
                if [ ${AUTO} == "H" ]
63
                then
64
                        cecho "Advanced mode:"
65
                        cecho "         the script only downloads and installs the required tools. Dependency libraries and tools are checked during individual tool compilation. Furthermore, the install directory is not added to the system PATH. You have to do it yourself. Libusb, libftdi and Icarus Verilog are supposed to be installed by the user.\n"
66
                        cecho "Resumed mode:"
67
                        cecho "         the script checks if the dependency libraries and tools are installed before doing anything. It also adds the installation directory to the system PATH variable for bash shells on HOME/.bashrc. Libusb, libftdi and Icarus Verilog are automatically installed for you.\n"
68
                fi
69
        done
70
    if [ "${AUTO}" == "R" ]
71
    then
72
        cecho "Resumed mode selected";
73
        else
74
                cecho "Advanced mode selected";
75
    fi
76
fi
77
 
78
 
79 76 rfajardo
# Testing necessary tools
80 168 rfajardo
if [ "${AUTO}" == "R" ]
81 76 rfajardo
then
82 168 rfajardo
        cecho "Testing if necessary tools are installed, program "whereis" is required."
83
        testtool wget
84
        testtool svn
85
        testtool bzip2
86
        testtool tar
87
        testtool sed
88
        testtool patch
89
        testtool gcc
90
        testtool make
91
        testtool makeinfo
92
        testtool libncurses
93
        testtool flex
94
        testtool bison
95
        testtool libz
96
        if [ "$ENV" == "Cygwin" ]
97
        then
98
                testtool ioperm
99
                testtool libusb
100
        fi
101 76 rfajardo
fi
102
 
103 81 rfajardo
# Wizard
104
if [ -z "${ALTDIR}" ]
105 76 rfajardo
then
106 81 rfajardo
    cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
107
    read ALTDIR;
108
    if [ ! -z "${ALTDIR}" ]
109
    then
110
        DIR_TO_INSTALL=${ALTDIR}
111
    fi
112
    cecho "${DIR_TO_INSTALL} selected";
113 76 rfajardo
fi
114
 
115 81 rfajardo
if [ ! -d ${DIR_TO_INSTALL} ]
116 76 rfajardo
then
117 141 rfajardo
     cecho "Directory ${DIR_TO_INSTALL} doesn't exist."
118
     execcmd "Creating directory ${DIR_TO_INSTALL}" "mkdir -p ${DIR_TO_INSTALL}"
119
     if [ $? -ne 0 ]
120
     then
121
          errormsg "Connot create ${DIR_TO_INSTALL}";
122
     fi
123 81 rfajardo
fi;
124 76 rfajardo
 
125
 
126 81 rfajardo
#Creating directory structure
127
cecho "\nCreating directory structure"
128
cd ${DIR_TO_INSTALL}
129
execcmd "Creating directory ./download for downloaded packages" "mkdir -p download"
130
execcmd "Creating directory ./tools for package binaries" "mkdir -p tools"
131
 
132 170 ConX.
#FIXME we should create an archive file of all the dependencies use a single wget
133 81 rfajardo
#Downloading everything we need
134
cecho "\nDownloading packages"
135
cd ${DIR_TO_INSTALL}
136
cecho "Download MinSoC"
137 141 rfajardo
svn co -q ${MINSOC_SVN_URL} minsoc      #user need to input password, execcmd omits command output and should be this way
138 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download"
139 76 rfajardo
if [ "$ENV" == "Cygwin" ]
140
then
141 170 ConX.
    execcmd "Downloading GNU Toolchain" "wget http://minsoc.com/dep/trunk/or32-elf-cygwin-1.7.tar.bz2";
142 76 rfajardo
else
143
    if [ $KERNEL_ARCH == "32" ];
144
    then
145 170 ConX.
        execcmd "Downloading GNU Toolchain" "wget http://minsoc.com/dep/trunk/or32-elf-linux-x86.tar.bz2";
146 76 rfajardo
    elif [ $KERNEL_ARCH == "64" ];
147
    then
148 170 ConX.
        execcmd "Downloading GNU Toolchain" "wget http://minsoc.com/dep/trunk/or32-elf-linux-x86_64.tar.bz2";
149 76 rfajardo
    fi
150
fi
151 170 ConX.
execcmd "Downloading GDB" "wget http://minsoc.com/dep/trunk/gdb-6.8a.tar.bz2"
152
execcmd "wget http://minsoc.com/dep/trunk/or32-gdb-6.8-patch-2.4.bz2"
153
execcmd "wget http://minsoc.com/dep/trunk/gdb-6.8-bz436037-reg-no-longer-active.patch"
154 168 rfajardo
if [ "${AUTO}" == "R" ]
155 81 rfajardo
then
156 168 rfajardo
        if [ "$ENV" != "Cygwin" ]
157
        then
158 170 ConX.
                execcmd "Downloading libusb-0.1 for Advanced Debug System" "wget http://minsoc.com/dep/trunk/libusb-0.1.12.tar.gz"
159 168 rfajardo
        fi
160 170 ConX.
        execcmd "Downloading libftdi for Advanced Debug System" "wget http://minsoc.com/dep/trunk/libftdi-0.19.tar.gz"
161
        execcmd "Downloading Icarus Verilog" "wget http://minsoc.com/dep/trunk/verilog-0.9.4.tar.gz"
162 81 rfajardo
fi
163 76 rfajardo
 
164
 
165 81 rfajardo
#Uncompressing everything
166
cecho "\nUncompressing packages"
167
if [ "$ENV" == "Cygwin" ]
168
then
169
    execcmd "tar xf or32-elf-cygwin-1.7.tar.bz2";
170
else
171
    if [ $KERNEL_ARCH == "32" ];
172
    then
173
        execcmd "tar xf or32-elf-linux-x86.tar.bz2";
174
    elif [ $KERNEL_ARCH == "64" ];
175
    then
176
        execcmd "tar xf or32-elf-linux-x86_64.tar.bz2";
177
    fi
178
fi
179 103 rfajardo
execcmd "tar -jxf gdb-6.8a.tar.bz2"
180 81 rfajardo
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
181 168 rfajardo
if [ "${AUTO}" == "R" ]
182 81 rfajardo
then
183 168 rfajardo
        if [ "$ENV" != "Cygwin" ]
184
        then
185
                execcmd "tar zxf libusb-0.1.12.tar.gz"
186
        fi
187
        execcmd "tar zxf libftdi-0.19.tar.gz"
188
        execcmd "tar zxf verilog-0.9.4.tar.gz"
189 81 rfajardo
fi
190 76 rfajardo
 
191
 
192 81 rfajardo
#Compiling and Installing all packages
193
cecho "\nCompiling and installing packages"
194
# Installing the GNU Toolchain
195 82 rfajardo
if [ "$ENV" == "Cygwin" ]
196
then
197
    execcmd "Installing GNU Toolchain" "tar xf or32-elf-cygwin-1.7.tar.bz2 -C $DIR_TO_INSTALL/tools";
198
else
199
    if [ $KERNEL_ARCH == "32" ];
200
    then
201
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86.tar.bz2 -C $DIR_TO_INSTALL/tools";
202
    elif [ $KERNEL_ARCH == "64" ];
203
    then
204
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86_64.tar.bz2 -C $DIR_TO_INSTALL/tools";
205
    fi
206
fi
207 167 rfajardo
PATH="$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin"
208 76 rfajardo
 
209
 
210 81 rfajardo
#Installing GDB
211
execcmd "cd gdb-6.8"
212
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
213
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
214 76 rfajardo
 
215 81 rfajardo
execcmd "mkdir -p build"
216
execcmd "cd build"
217
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
218
execcmd "Compiling GDB" "make"
219 141 rfajardo
make install 1>>${SCRIPT_DIR}/progress.log 2>>${SCRIPT_DIR}/error.log   #avoid Fedora failing due to missing Makeinfo
220 167 rfajardo
PATH="$PATH:${DIR_TO_INSTALL}/tools/bin"
221 76 rfajardo
 
222
 
223 81 rfajardo
#Installing Advanced JTAG Bridge support libraries
224 168 rfajardo
if [ "${AUTO}" == "R" ]
225 76 rfajardo
then
226 168 rfajardo
        if [ "$ENV" != "Cygwin" ]
227
        then
228
                execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
229
                execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
230
                execcmd "Installing libusb-0.1" "make"
231
                execcmd "make install"
232
        fi
233
 
234
        execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
235
        execcmd "PATH=\"$PATH:${DIR_TO_INSTALL}/tools/bin\" ./configure --prefix=${DIR_TO_INSTALL}/tools CPPFLAGS=-I${DIR_TO_INSTALL}/tools/include"
236
        execcmd "Compiling libftdi" "make"
237
        execcmd "make install"
238 76 rfajardo
fi
239
 
240
 
241 81 rfajardo
#Installing Advanced JTAG Bridge
242
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
243 154 nyawn
execcmd "./autogen.sh"
244 166 rfajardo
execcmd "./configure --enable-jsp-server=yes --prefix=${DIR_TO_INSTALL}/tools CFLAGS=-I${DIR_TO_INSTALL}/tools/include LIBS=-L${DIR_TO_INSTALL}/tools/lib LDFLAGS=-Wl,-R${DIR_TO_INSTALL}/tools/lib"
245 81 rfajardo
execcmd "Compiling Advanced JTAG Bridge" "make"
246
execcmd "make install"
247 76 rfajardo
 
248
 
249 81 rfajardo
#Installing Icarus Verilog
250 168 rfajardo
if [ "${AUTO}" == "R" ]
251
then
252
        execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
253
        execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
254
        execcmd "Compiling Icarus Verilog" "make"
255
        execcmd "make install"
256
fi
257 76 rfajardo
 
258
 
259 141 rfajardo
#Configuring MinSoC, Advanced Debug System and patching OpenRISC
260
bash ${SCRIPT_DIR}/configure.sh
261 81 rfajardo
 
262
 
263
#Setting-up new variables
264 168 rfajardo
if [ "${AUTO}" == "R" ]
265
then
266
        cecho "\nSystem configurations"
267
        execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\"\\\$PATH:$DIR_TO_INSTALL/tools/bin\\\"\" >> /home/$(whoami)/.bashrc;";
268
        execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\"\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\\\"\" >> /home/$(whoami)/.bashrc;";
269 81 rfajardo
 
270 168 rfajardo
        cecho "\nInstallation Complete!"
271
        cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
272
        cecho "You may remove the ${DIR_TO_INSTALL}/download directory if you wish."
273
else
274
        cecho "\nInstallation Complete!\n"
275
        cecho "Remember to add the two following directories in the following order to the PATH system variable."
276
        cecho "1) $DIR_TO_INSTALL/tools/bin "
277
        cecho "2) $DIR_TO_INSTALL/tools/or32-elf/bin "
278
        cecho "You may remove the ${DIR_TO_INSTALL}/download directory if you wish."
279
fi
280
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.