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

Subversion Repositories minsoc

[/] [minsoc/] [branches/] [verilator/] [utils/] [setup/] [minsoc-install.sh] - Blame information for rev 159

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

Line No. Rev Author Line
1 76 rfajardo
#!/bin/bash
2 110 rfajardo
# Author: Constantinos Xanthopoulos & Raul Fajardo
3 76 rfajardo
# This script install MinSOC tree
4
# under a specific directory.
5
 
6
# ===== CONFIGURATIONS =====
7
# ==========================
8 153 rfajardo
MINSOC_SVN_URL=http://opencores.org/ocsvn/minsoc/minsoc/branches/verilator
9 114 rfajardo
export SCRIPT_DIR="$( cd -P "$( dirname "$0" )" && pwd )"
10 112 rfajardo
export DIR_TO_INSTALL=`pwd`
11 76 rfajardo
 
12
# Debug ?
13
export DEBUG=0;
14 114 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
# Testing necessary tools
54
cecho "Testing if necessary tools are installed, program "whereis" is required."
55
testtool wget
56
testtool svn
57 83 rfajardo
testtool bzip2
58 76 rfajardo
testtool tar
59
testtool sed
60
testtool patch
61
testtool gcc
62
testtool make
63 136 rfajardo
testtool makeinfo
64 76 rfajardo
testtool libncurses
65 77 rfajardo
testtool flex
66
testtool bison
67 76 rfajardo
if [ "$ENV" == "Cygwin" ]
68
then
69
    testtool ioperm
70
    testtool libusb
71
fi
72
 
73
 
74 81 rfajardo
# Wizard
75
if [ -z "${ALTDIR}" ]
76 76 rfajardo
then
77 81 rfajardo
    cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
78
    read ALTDIR;
79
    if [ ! -z "${ALTDIR}" ]
80
    then
81
        DIR_TO_INSTALL=${ALTDIR}
82
    fi
83
    cecho "${DIR_TO_INSTALL} selected";
84 76 rfajardo
fi
85
 
86 81 rfajardo
if [ ! -d ${DIR_TO_INSTALL} ]
87 76 rfajardo
then
88 138 ConX.
     cecho "Directory ${DIR_TO_INSTALL} doesn't exist."
89
     execcmd "Creating directory ${DIR_TO_INSTALL}" "mkdir -p ${DIR_TO_INSTALL}"
90
     if [ $? -ne 0 ]
91
     then
92
          errormsg "Connot create ${DIR_TO_INSTALL}";
93
     fi
94 81 rfajardo
fi;
95 76 rfajardo
 
96
 
97 81 rfajardo
#Creating directory structure
98
cecho "\nCreating directory structure"
99
cd ${DIR_TO_INSTALL}
100
execcmd "Creating directory ./download for downloaded packages" "mkdir -p download"
101
execcmd "Creating directory ./tools for package binaries" "mkdir -p tools"
102
 
103
 
104
#Downloading everything we need
105
cecho "\nDownloading packages"
106
cd ${DIR_TO_INSTALL}
107
cecho "Download MinSoC"
108 110 rfajardo
svn co -q ${MINSOC_SVN_URL} minsoc      #user need to input password, execcmd omits command output and should be this way
109 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download"
110 76 rfajardo
if [ "$ENV" == "Cygwin" ]
111
then
112 81 rfajardo
    execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-cygwin-1.7.tar.bz2";
113 76 rfajardo
else
114
    if [ $KERNEL_ARCH == "32" ];
115
    then
116 81 rfajardo
        execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86.tar.bz2";
117 76 rfajardo
    elif [ $KERNEL_ARCH == "64" ];
118
    then
119 81 rfajardo
        execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86_64.tar.bz2";
120 76 rfajardo
    fi
121
fi
122 102 rfajardo
execcmd "Downloading GDB" "wget ftp://anonymous:anonymous@ftp.gnu.org/gnu/gdb/gdb-6.8a.tar.bz2"
123 81 rfajardo
execcmd "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-gdb-6.8-patch-2.4.bz2"
124
execcmd "svn export -q http://opencores.org/ocsvn/adv_debug_sys/adv_debug_sys/trunk/Patches/GDB6.8/gdb-6.8-bz436037-reg-no-longer-active.patch"
125
if [ "$ENV" != "Cygwin" ]
126
then
127
    execcmd "Downloading libusb-0.1 for Advanced Debug System" "wget http://sourceforge.net/projects/libusb/files/libusb-0.1%20%28LEGACY%29/0.1.12/libusb-0.1.12.tar.gz"
128
fi
129
execcmd "Downloading libftdi for Advanced Debug System" "wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.19.tar.gz"
130
execcmd "Downloading Icarus Verilog" "wget ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.4.tar.gz"
131 76 rfajardo
 
132
 
133 81 rfajardo
#Uncompressing everything
134
cecho "\nUncompressing packages"
135
if [ "$ENV" == "Cygwin" ]
136
then
137
    execcmd "tar xf or32-elf-cygwin-1.7.tar.bz2";
138
else
139
    if [ $KERNEL_ARCH == "32" ];
140
    then
141
        execcmd "tar xf or32-elf-linux-x86.tar.bz2";
142
    elif [ $KERNEL_ARCH == "64" ];
143
    then
144
        execcmd "tar xf or32-elf-linux-x86_64.tar.bz2";
145
    fi
146
fi
147 103 rfajardo
execcmd "tar -jxf gdb-6.8a.tar.bz2"
148 81 rfajardo
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
149
if [ "$ENV" != "Cygwin" ]
150
then
151
    execcmd "tar zxf libusb-0.1.12.tar.gz"
152
fi
153
execcmd "tar zxf libftdi-0.19.tar.gz"
154
execcmd "tar zxf verilog-0.9.4.tar.gz"
155 76 rfajardo
 
156
 
157 81 rfajardo
#Compiling and Installing all packages
158
cecho "\nCompiling and installing packages"
159
# Installing the GNU Toolchain
160 82 rfajardo
if [ "$ENV" == "Cygwin" ]
161
then
162
    execcmd "Installing GNU Toolchain" "tar xf or32-elf-cygwin-1.7.tar.bz2 -C $DIR_TO_INSTALL/tools";
163
else
164
    if [ $KERNEL_ARCH == "32" ];
165
    then
166
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86.tar.bz2 -C $DIR_TO_INSTALL/tools";
167
    elif [ $KERNEL_ARCH == "64" ];
168
    then
169
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86_64.tar.bz2 -C $DIR_TO_INSTALL/tools";
170
    fi
171
fi
172 81 rfajardo
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
173 76 rfajardo
 
174
 
175 81 rfajardo
#Installing GDB
176
execcmd "cd gdb-6.8"
177
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
178
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
179 76 rfajardo
 
180 81 rfajardo
execcmd "mkdir -p build"
181
execcmd "cd build"
182
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
183
execcmd "Compiling GDB" "make"
184 115 rfajardo
make install 1>>${SCRIPT_DIR}/progress.log 2>>${SCRIPT_DIR}/error.log   #avoid Fedora failing due to missing Makeinfo
185 81 rfajardo
PATH=$PATH:${DIR_TO_INSTALL}/tools/bin
186 76 rfajardo
 
187
 
188 81 rfajardo
#Installing Advanced JTAG Bridge support libraries
189 76 rfajardo
if [ "$ENV" != "Cygwin" ]
190
then
191 81 rfajardo
    execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
192 76 rfajardo
    execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
193 81 rfajardo
    execcmd "Installing libusb-0.1" "make"
194 76 rfajardo
    execcmd "make install"
195
fi
196
 
197 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
198 76 rfajardo
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
199 81 rfajardo
execcmd "Compiling libftdi" "make"
200 76 rfajardo
execcmd "make install"
201
 
202
 
203 81 rfajardo
#Installing Advanced JTAG Bridge
204
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
205 76 rfajardo
if [ `grep "INCLUDE_JSP_SERVER=true" Makefile` != "" ]
206
then
207 81 rfajardo
    #Switching off the adv_jtag_bridge JSP_SERVER option
208 76 rfajardo
    sed 's/INCLUDE_JSP_SERVER=true/INCLUDE_JSP_SERVER=false/' Makefile > TMPFILE && mv TMPFILE Makefile
209
fi
210
 
211
if [ "${ENV}" == "GNU/Linux" ]
212
then
213 81 rfajardo
    #Setting the right build environment
214 76 rfajardo
    sed 's/BUILD_ENVIRONMENT=cygwin/BUILD_ENVIRONMENT=linux/' Makefile > TMPFILE && mv TMPFILE Makefile
215
fi
216
 
217 81 rfajardo
#preparing the Makefile to find and link libraries
218 76 rfajardo
sed "s%prefix = /usr/local%prefix = ${DIR_TO_INSTALL}/tools%" Makefile > TMPFILE && mv TMPFILE Makefile
219
sed "s%\$(CC) \$(CFLAGS)%\$(CC) \$(CFLAGS) \$(INCLUDEDIRS)%" Makefile > TMPFILE && mv TMPFILE Makefile
220
sed "s%INCLUDEDIRS =%INCLUDEDIRS = -I${DIR_TO_INSTALL}/tools/include%" Makefile > TMPFILE && mv TMPFILE Makefile
221 79 rfajardo
sed "s%LIBS =%LIBS = -L${DIR_TO_INSTALL}/tools/lib -Wl,-R${DIR_TO_INSTALL}/tools/lib%" Makefile > TMPFILE && mv TMPFILE Makefile
222 76 rfajardo
 
223 81 rfajardo
#properly installing Advanced JTAG Bridge
224
execcmd "Compiling Advanced JTAG Bridge" "make"
225
execcmd "make install"
226 76 rfajardo
 
227
 
228 81 rfajardo
#Installing Icarus Verilog
229
execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
230 76 rfajardo
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
231 81 rfajardo
execcmd "Compiling Icarus Verilog" "make"
232 76 rfajardo
execcmd "make install"
233
 
234
 
235 110 rfajardo
#Configuring MinSoC, Advanced Debug System and patching OpenRISC
236 113 rfajardo
bash ${SCRIPT_DIR}/configure.sh
237 81 rfajardo
 
238
 
239
#Setting-up new variables
240
cecho "\nSystem configurations"
241 76 rfajardo
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
242
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
243 81 rfajardo
 
244
cecho "\nInstallation Complete!"
245 76 rfajardo
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
246 81 rfajardo
cecho "You may remove the ${DIR_TO_INSTALL}/download directory if you wish."

powered by: WebSVN 2.1.0

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