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

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [utils/] [setup/] [minsoc-install.sh] - Blame information for rev 149

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

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