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 115

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 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
testtool libncurses
64 77 rfajardo
testtool flex
65
testtool bison
66 76 rfajardo
if [ "$ENV" == "Cygwin" ]
67
then
68
    testtool ioperm
69
    testtool libusb
70
fi
71
 
72
 
73 81 rfajardo
# Wizard
74
if [ -z "${ALTDIR}" ]
75 76 rfajardo
then
76 81 rfajardo
    cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
77
    read ALTDIR;
78
    if [ ! -z "${ALTDIR}" ]
79
    then
80
        DIR_TO_INSTALL=${ALTDIR}
81
    fi
82
    cecho "${DIR_TO_INSTALL} selected";
83 76 rfajardo
fi
84
 
85 81 rfajardo
if [ ! -d ${DIR_TO_INSTALL} ]
86 76 rfajardo
then
87 81 rfajardo
    errormsg "Directory doesn't exist. Please create it";
88
fi;
89 76 rfajardo
 
90
 
91 81 rfajardo
#Creating directory structure
92
cecho "\nCreating directory structure"
93
cd ${DIR_TO_INSTALL}
94
execcmd "Creating directory ./download for downloaded packages" "mkdir -p download"
95
execcmd "Creating directory ./tools for package binaries" "mkdir -p tools"
96
 
97
 
98
#Downloading everything we need
99
cecho "\nDownloading packages"
100
cd ${DIR_TO_INSTALL}
101
cecho "Download MinSoC"
102 110 rfajardo
svn co -q ${MINSOC_SVN_URL} minsoc      #user need to input password, execcmd omits command output and should be this way
103 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download"
104 76 rfajardo
if [ "$ENV" == "Cygwin" ]
105
then
106 81 rfajardo
    execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-cygwin-1.7.tar.bz2";
107 76 rfajardo
else
108
    if [ $KERNEL_ARCH == "32" ];
109
    then
110 81 rfajardo
        execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86.tar.bz2";
111 76 rfajardo
    elif [ $KERNEL_ARCH == "64" ];
112
    then
113 81 rfajardo
        execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86_64.tar.bz2";
114 76 rfajardo
    fi
115
fi
116 102 rfajardo
execcmd "Downloading GDB" "wget ftp://anonymous:anonymous@ftp.gnu.org/gnu/gdb/gdb-6.8a.tar.bz2"
117 81 rfajardo
execcmd "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-gdb-6.8-patch-2.4.bz2"
118
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"
119
if [ "$ENV" != "Cygwin" ]
120
then
121
    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"
122
fi
123
execcmd "Downloading libftdi for Advanced Debug System" "wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.19.tar.gz"
124
execcmd "Downloading Icarus Verilog" "wget ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.4.tar.gz"
125 76 rfajardo
 
126
 
127 81 rfajardo
#Uncompressing everything
128
cecho "\nUncompressing packages"
129
if [ "$ENV" == "Cygwin" ]
130
then
131
    execcmd "tar xf or32-elf-cygwin-1.7.tar.bz2";
132
else
133
    if [ $KERNEL_ARCH == "32" ];
134
    then
135
        execcmd "tar xf or32-elf-linux-x86.tar.bz2";
136
    elif [ $KERNEL_ARCH == "64" ];
137
    then
138
        execcmd "tar xf or32-elf-linux-x86_64.tar.bz2";
139
    fi
140
fi
141 103 rfajardo
execcmd "tar -jxf gdb-6.8a.tar.bz2"
142 81 rfajardo
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
143
if [ "$ENV" != "Cygwin" ]
144
then
145
    execcmd "tar zxf libusb-0.1.12.tar.gz"
146
fi
147
execcmd "tar zxf libftdi-0.19.tar.gz"
148
execcmd "tar zxf verilog-0.9.4.tar.gz"
149 76 rfajardo
 
150
 
151 81 rfajardo
#Compiling and Installing all packages
152
cecho "\nCompiling and installing packages"
153
# Installing the GNU Toolchain
154 82 rfajardo
if [ "$ENV" == "Cygwin" ]
155
then
156
    execcmd "Installing GNU Toolchain" "tar xf or32-elf-cygwin-1.7.tar.bz2 -C $DIR_TO_INSTALL/tools";
157
else
158
    if [ $KERNEL_ARCH == "32" ];
159
    then
160
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86.tar.bz2 -C $DIR_TO_INSTALL/tools";
161
    elif [ $KERNEL_ARCH == "64" ];
162
    then
163
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86_64.tar.bz2 -C $DIR_TO_INSTALL/tools";
164
    fi
165
fi
166 81 rfajardo
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
167 76 rfajardo
 
168
 
169 81 rfajardo
#Installing GDB
170
execcmd "cd gdb-6.8"
171
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
172
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
173 76 rfajardo
 
174 81 rfajardo
execcmd "mkdir -p build"
175
execcmd "cd build"
176
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
177
execcmd "Compiling GDB" "make"
178 115 rfajardo
make install 1>>${SCRIPT_DIR}/progress.log 2>>${SCRIPT_DIR}/error.log   #avoid Fedora failing due to missing Makeinfo
179 81 rfajardo
PATH=$PATH:${DIR_TO_INSTALL}/tools/bin
180 76 rfajardo
 
181
 
182 81 rfajardo
#Installing Advanced JTAG Bridge support libraries
183 76 rfajardo
if [ "$ENV" != "Cygwin" ]
184
then
185 81 rfajardo
    execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
186 76 rfajardo
    execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
187 81 rfajardo
    execcmd "Installing libusb-0.1" "make"
188 76 rfajardo
    execcmd "make install"
189
fi
190
 
191 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
192 76 rfajardo
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
193 81 rfajardo
execcmd "Compiling libftdi" "make"
194 76 rfajardo
execcmd "make install"
195
 
196
 
197 81 rfajardo
#Installing Advanced JTAG Bridge
198
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
199 76 rfajardo
if [ `grep "INCLUDE_JSP_SERVER=true" Makefile` != "" ]
200
then
201 81 rfajardo
    #Switching off the adv_jtag_bridge JSP_SERVER option
202 76 rfajardo
    sed 's/INCLUDE_JSP_SERVER=true/INCLUDE_JSP_SERVER=false/' Makefile > TMPFILE && mv TMPFILE Makefile
203
fi
204
 
205
if [ "${ENV}" == "GNU/Linux" ]
206
then
207 81 rfajardo
    #Setting the right build environment
208 76 rfajardo
    sed 's/BUILD_ENVIRONMENT=cygwin/BUILD_ENVIRONMENT=linux/' Makefile > TMPFILE && mv TMPFILE Makefile
209
fi
210
 
211 81 rfajardo
#preparing the Makefile to find and link libraries
212 76 rfajardo
sed "s%prefix = /usr/local%prefix = ${DIR_TO_INSTALL}/tools%" Makefile > TMPFILE && mv TMPFILE Makefile
213
sed "s%\$(CC) \$(CFLAGS)%\$(CC) \$(CFLAGS) \$(INCLUDEDIRS)%" Makefile > TMPFILE && mv TMPFILE Makefile
214
sed "s%INCLUDEDIRS =%INCLUDEDIRS = -I${DIR_TO_INSTALL}/tools/include%" Makefile > TMPFILE && mv TMPFILE Makefile
215 79 rfajardo
sed "s%LIBS =%LIBS = -L${DIR_TO_INSTALL}/tools/lib -Wl,-R${DIR_TO_INSTALL}/tools/lib%" Makefile > TMPFILE && mv TMPFILE Makefile
216 76 rfajardo
 
217 81 rfajardo
#properly installing Advanced JTAG Bridge
218
execcmd "Compiling Advanced JTAG Bridge" "make"
219
execcmd "make install"
220 76 rfajardo
 
221
 
222 81 rfajardo
#Installing Icarus Verilog
223
execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
224 76 rfajardo
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
225 81 rfajardo
execcmd "Compiling Icarus Verilog" "make"
226 76 rfajardo
execcmd "make install"
227
 
228
 
229 110 rfajardo
#Configuring MinSoC, Advanced Debug System and patching OpenRISC
230 113 rfajardo
bash ${SCRIPT_DIR}/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-2020 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.