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

Subversion Repositories minsoc

[/] [minsoc/] [branches/] [rc-1.0/] [utils/] [setup/] [minsoc-install.sh] - Blame information for rev 110

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

powered by: WebSVN 2.1.0

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