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 136

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