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 112

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 112 rfajardo
MINSOC_SVN_URL=http://opencores.org/ocsvn/minsoc/minsoc/branches/rc-1.0
9
export DIR_TO_INSTALL=`pwd`
10 76 rfajardo
 
11
# Debug ?
12
export DEBUG=0;
13
. beautify.sh
14
 
15
function testtool
16
{
17
    #    is_missing=`which $1 2>&1 | grep no`
18
    is_missing=`whereis -b $1 2>&1 | grep :$`
19
    if [ -z "$is_missing" ]
20
    then
21
        cecho "$1 is installed, pass"
22
    else
23
        errormsg "$1 is not installed, install it and re-run this installation script."
24
    fi
25
}
26
 
27 106 rfajardo
 
28
#Setting environment
29
ENV=`uname -o`
30
if [ "$ENV" != "GNU/Linux" ] && [ "$ENV" != "Cygwin" ]
31
then
32
    errormsg "Environment $ENV not supported by this script."
33
fi
34
cecho "Building tools for ${ENV} system"
35
 
36
is_arch64=`uname -m | grep 64`
37
if [ -z $is_arch64 ]
38
then
39
    KERNEL_ARCH="32"
40
else
41
    KERNEL_ARCH="64"
42
fi
43
 
44
 
45 76 rfajardo
# User check!
46
if [ `whoami` = "root" ];
47
then
48
    errormsg "You shouldn't be root for this script to run.";
49
fi;
50
 
51
 
52
# Testing necessary tools
53
cecho "Testing if necessary tools are installed, program "whereis" is required."
54
testtool wget
55
testtool svn
56 83 rfajardo
testtool bzip2
57 76 rfajardo
testtool tar
58
testtool sed
59
testtool patch
60
testtool gcc
61
testtool make
62
testtool libncurses
63 77 rfajardo
testtool flex
64
testtool bison
65 76 rfajardo
if [ "$ENV" == "Cygwin" ]
66
then
67
    testtool ioperm
68
    testtool libusb
69
fi
70
 
71
 
72 81 rfajardo
# Wizard
73
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
bash configure.sh
230 81 rfajardo
 
231
 
232
#Setting-up new variables
233
cecho "\nSystem configurations"
234 76 rfajardo
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
235
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
236 81 rfajardo
 
237
cecho "\nInstallation Complete!"
238 76 rfajardo
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
239 81 rfajardo
cecho "You may remove the ${DIR_TO_INSTALL}/download directory if you wish."

powered by: WebSVN 2.1.0

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