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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [toolchain_install_scripts/] [MOF_ORSOC_TCHN_v5c_or32-elf.sh] - Blame information for rev 368

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

Line No. Rev Author Line
1 22 ocadmin
#!/bin/bash
2
 
3 72 julius
# Copyright (C) 2008,2009,2010 www.meansoffreedom.org, www.orsoc.se
4 22 ocadmin
# This file is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
# General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 
18 72 julius
##Date: 11/03/2010
19 22 ocadmin
##Title: MOF_ORSOC_TCN_v5c_or32-elf.sh
20
##Purpose: Complete Toolchain Builder from MOF & ORSoC.
21
##initial rgd, mse
22
##updated jb
23
 
24
#Changelog
25
# 090306 - jb
26
#        - added exit code checking after each make and patch
27
#        - changed download method to instead generate a script and run it in
28
#          kermit (requiring single ftp logon per host)
29
# 090309 - jb
30
#        - changed download of GNU tools so they occurr from the GNU.org ftp
31
#          (except binutils-2.18.50, it's not there)
32
#        - changed download of Linux kernel so it's now from ftp.kernel.org
33
#        - changed patch for binutils (fixes gcc-4.3.2 compilation problem
34
#          caused by non-string literals in printf)
35
#        - changed or1ksim version from 0.3.0rc2 to 0.3.0
36
#        - changed Linux kernel version from 2.6.19 to 2.6.24
37
#        - changed Linux kernel patch version for this new kernel version
38
#          generated new patch for Linux kernel, based on one from MOF
39
#          (www.meansoffreedom.net) which contains a more complete config file.
40
#          removing need for user input during "make oldconfig"
41
#        - changed organisation so that all the packages are not copied into
42
#          the build directory before they are extracted, instead it's done
43
#          from where they are.
44
#        - changed gdb-6.8 patch version due to stricter gcc-4.3.2 checking
45
#          return types.
46
#        - included better or1ksim config file in Linux sources patch, now
47
#          named "or1ksim_linux.cfg"
48
# 100309 - jb
49
#        - changed back to wget for file retrieval
50
#        - changed introduction readme
51
#        - changed install destination checking and setup
52
#        - added md5sum checking of any existing downloaded files, removing
53
#          need for redownloading things every time
54
#        - added debug build mode - run script with -d at command line
55
#          note: not everything in this mode has been tested, may not work
56
#          in certain combinations!
57
# 120309 - jb
58
#        - New OS X version - busybox doesn't work (removed from script),
59
#          nor does ors1ksim (compiles but segfaults somewhere during test).
60
# 140309 - Added ability to change target name. Included some sed commands to
61
#          change or32-uclinux to whatever $TARGET is set to in some scripts
62
#          (mainly for uClibc install, the are set at configure time)
63
# 160309 - (v5a) Replaced busybox sources in download list (removed for OS X
64
#          version and forgot to replace it when running on Linux again.)
65
# 270309 - Changed the declaration of the check_exit_code function to be without
66
#          the preceeding "function" as this isn't valid in sh, and the new way
67
#          appears to be valid in bash.
68
#        - Changed the link in the error output to the new OpenCores forum.
69
# 210409 - Changed linux kernel and uClibc patch versions to latest
70
#        - Changed output to all be piped to appropriate files, makes things neater
71
# 260409 - Added Cygwin exports section
72
#        - Hopefully now runs on Cygwin with new patch for uClibc
73
# 300409 - New Binutils patch - fixes objdump instruction decode issue
74
# 110509 - (v5c) Put in check for required build tools before building
75 37 julius
# 260509 - Changed gcc's package download to gcc-core as we only use the
76
#          c-language compiler and libraries right now.
77 39 julius
# 030609 - Fixed odd problem with uClibc build on latest Cygwin where it tried
78
#          to run the INSTALL script file instead of the systems install binary
79
#          by adding a suffix to the text file.
80 43 julius
# 290609 - Changed linux patch to 2.3 - is a patch derived from revision 42 of
81
#          OpenRISC repository's kernel.
82 59 julius
# 301109 - Changed GCC patch to one with single precision floating point as
83
#          default
84
# 021209 - Added --disable-werror flag to gdb-6.8 configure line to fix issue
85
#          with gcc-4.4.1
86 72 julius
# 110310 - Moved or1ksim to its own directory in the chosen install directory
87 73 julius
# 140310 - Fixed problem with mkdir command
88 74 julius
# 140310 - Fixed ncurses header checking
89 75 julius
# 010410 - Fixed ncurses header checking on Cygwin (added -I path to gcc cmd)
90 136 julius
# 270610 - Updated or1ksim version to 0.4.0
91 59 julius
 
92 22 ocadmin
# TODO: OS X build things - need an "elf.h" from some Linux machine's
93
#       /usr/local/include dir and put in Mac's /usr/local/include dir -
94
#       this solves issue with Linux compilation
95
# TODO: OS X build things - add HOST_LOADLIBES="lintl" to make line of uClibc
96
# TODO: OS X build things - must remove the -Werror line in $GDB_VER/gdb/Makefile,
97
#       sed command:
98
#       sed 's/WERROR\_CFLAGS\ \=\ \-Werror/WERROR\_CFLAGS\ \=/' $GDB_VER/gdb/Makefile
99
#       Can also just change the gdb-6.8/gdb/Makefile.in and remove the Werror= thing
100
# TODO: OS X build things - or1ksim, in or1ksim-0.3.0/peripheral/atadevice.c, it
101
#       includes byteswap.h - actually it's abstract.h that defines #LE_16() bswap_16(),
102
#       so in abstract.h we put in defines for bswap_16 as
103
#       #define bswap_16(value) ((((value) & 0xff) << 8) | ((value) >> 8))
104
# TODO: OS X Build things - or1ksim strndup.c, in or1k-0.3.0/port/strndup.c strndup function,
105
#       types not exist etc. Need to include sys/types.h and string.h to this file to fix
106
#       a few problems.
107
# TODO: OS X build things - or1ksim - or1ksim-0.3.0/sim-cmd.c passes one of our functions
108
#       to a readline function, rl_event_hook, but this is not defined in the OS X (BSD)
109
#       readline package, so the GNU readline package must be used.
110
# TODO: OS X build things - or1ksim segfaults when run for some reason.
111
 
112
## A function we'll call throughout the setup process to check if the previous
113
## command finished without error
114
check_exit_code()
115
{
116
    if [ $? -ne 0 ]
117
    then
118
        echo
119
        echo "############################ERROR#############################"
120
        echo
121
        echo "Error during toolchain installation."
122
        echo
123
        echo "Please report this to the script maintainers."
124
        echo
125 45 julius
        echo "A useful report would contain information such as the tool"
126
        echo "being built/\"make\"d when the error occurred and the relevant"
127
        echo "lines of console output or log file relating to the error. It"
128
        echo "also helps to include information about your the host OS and"
129
        echo "version of GCC."
130
        echo "A good place to look for solutions, and report any bugs, is at"
131
        echo "the OpenRISC project's bug tracker on OpenCores.org:"
132 22 ocadmin
        echo
133 45 julius
        echo "           http://opencores.org/openrisc,bugtracker"
134
        echo
135 22 ocadmin
        exit $?
136
    fi
137
}
138
 
139
REQUIRED_TOOL_LIST="
140
make
141
patch
142
gcc
143
g++
144
bzip2
145
wget
146
makeinfo
147
"
148 74 julius
header_check() {
149
    # Compile a simple program, including the header we're checking for
150
    echo "#include <$1.h>" > header_check.c
151
    echo "int main () { return 0; }" >> header_check.c
152 75 julius
    gcc header_check.c -I/usr/include/$1
153 74 julius
}
154
 
155 22 ocadmin
check_essential_build_tools()
156
{
157 74 julius
 
158
    echo "#########################Checking for required build tools######################"
159
    echo
160
    for TOOL in $REQUIRED_TOOL_LIST
161
    do
162
        echo -n "Checking for $TOOL    "
163
        WHICHTOOL=`which $TOOL`
164
        echo "$WHICHTOOL"
165
        if [ -z $WHICHTOOL ]
166
        then
167 22 ocadmin
            echo
168 74 julius
            echo "\t$TOOL not found"
169
            echo
170
            echo "Please install $TOOL and re-run this script"
171
            echo
172 22 ocadmin
            exit 2
173
        fi
174 74 julius
    done
175
 
176
    echo "Checking for libncurses-dev (headers)"
177
    header_check "ncurses"
178
    # Now check the return value of that function
179
    if [ $? -ne 0 ]; then
180
        echo
181
        echo "\tlibncurses-dev not found"
182
        echo ; echo "Please install libncurses-dev and re-run this script"; echo
183
        rm -f header_check.c a.out
184
        exit 2
185
    fi
186
    rm -f header_check.c a.out
187
 
188 22 ocadmin
# Todo: somehow inform the user that if we're checking for makeinfo they need to install texinfo package
189 74 julius
    echo
190 22 ocadmin
}
191
 
192
## SCRIPT VERSION ##
193
SCRIPT_VERSION="v5c"
194
 
195
## Beginning globals ##
196
 
197
## ORSoC FTP download settings ##
198
ORSOC_FTP_HOST="195.67.9.12"
199
ORSOC_FTP_USER="ocuser"
200
ORSOC_FTP_PASSWD="oc"
201
ORSOC_FTP_DIR="toolchain"
202
 
203
## GNU FTP download settings ##
204
GNU_FTP_HOST="ftp.gnu.org"
205
GNU_FTP_USER="anonymous"
206
#GNU_FTP_BINUTILS_DIR="gnu/binutils"
207
GNU_FTP_GCC_DIR="gnu/gcc/gcc-4.2.2"
208
GNU_FTP_GDB_DIR="gnu/gdb"
209
 
210
## Linux kernel download settings ##
211
KERNEL_FTP_HOST="ftp.kernel.org"
212
KERNEL_FTP_USER="anonymous"
213
KERNEL_FTP_PASSWD="anonymous"
214
KERNEL_FTP_DIR="pub/linux/kernel/v2.6"
215
 
216
## Local directory variables ##
217
START_DIR=`pwd`
218
DN="n"
219
DIR=`pwd`
220
 
221 72 julius
## Makedir command we'll use ##
222 73 julius
MKDIR='mkdir -p'
223 22 ocadmin
## Versions of the toolchain components ##
224
BINUTILS_VER=binutils-2.18.50
225 37 julius
GCC_VER_NUM=4.2.2
226
GCC_VER=gcc-$GCC_VER_NUM
227 22 ocadmin
GDB_VER=gdb-6.8
228
UCLIB_VER=uClibc-0.9.29
229
LINUX_VER=linux-2.6.24
230
BUSY_VER=busybox-1.7.5
231 136 julius
SIM_VER=or1ksim-0.4.0
232 22 ocadmin
 
233
## Patches ##
234
BINUTILS_PATCH="$BINUTILS_VER.or32_fixed_patch-v2.1.bz2"
235 59 julius
GCC_PATCH=$GCC_VER-or32-fp.patch.bz2
236 43 julius
LINUX_PATCH="linux_2.6.24_or32_unified_v2.3.bz2"
237 22 ocadmin
UCLIBC_PATCH="uClibc-0.9.29-or32-patch-1.1.bz2"
238
GDB_PATCH="or32-gdb-6.8-patch-2.4.bz2"
239
 
240
## MD5sum file ##
241
MD5SUM_FILE=md5sums
242
 
243
## Configs ##
244
#CONFIG1="rgd_uc_29dotconfig" ## Now changed to rgd_uc_29v5dotconfig as it uses paths to the 2.6.24 kernel ##
245
CONFIG1="rgd_uc_29v5dotconfig"
246
CONFIG2="rgd_bb_1.75dotconfig"
247
 
248
## Ramdisk name ##
249
RAMDISK_FILE=initrd-fb-03.ext2.last.work.1.7.5
250
LINUX_RAMDISK_FILE=arch/or32/support/initrd-fb-03.ext2 ## The location and name of the ramdisk that Linux wants when it compiles
251
 
252
## Toolchain prefix ##
253
TARGET=or32-elf
254
 
255
 
256
## Tarballs ##
257
ZBALL1=$BINUTILS_VER.tar.bz2
258
TBALL1=$BINUTILS_VER.tar
259 37 julius
ZBALL2=gcc-core-$GCC_VER_NUM.tar.bz2
260 22 ocadmin
TBALL2=$GCC_VER.tar
261
ZBALL3=$UCLIB_VER.tar.bz2
262
TBALL3=$UCLIB_VER.tar
263
ZBALL4=$LINUX_VER.tar.bz2
264
TBALL4=$LINUX_VER.tar
265
ZBALL5=$BUSY_VER.tar.bz2
266
TBALL5=$BUSY_VER.tar
267
ZBALL6=$SIM_VER.tar.bz2
268
TBALL6=$SIM_VER.tar
269
ZBALL7=$RAMDISK_FILE.bz2
270
ZBALL8=$GDB_VER.tar.bz2
271
TBALL8=$GDB_VER.tar
272
 
273
ORSOC_FTP_FILE_LIST="$ZBALL1
274 74 julius
    $ZBALL3
275
    $ZBALL5
276
    $ZBALL6
277
    $ZBALL7
278
    $BINUTILS_PATCH
279
    $GCC_PATCH
280
    $LINUX_PATCH
281
    $UCLIBC_PATCH
282
    $GDB_PATCH
283
    $CONFIG1
284
    $CONFIG2"
285
 
286 22 ocadmin
GNU_FTP_FILE_LIST="$ZBALL2
287
$ZBALL8"
288
 
289
KERNEL_FTP_FILE_LIST=$ZBALL4
290
 
291
 
292
 
293
## Check if we've been given the debug mode flag ##
294
## We won't clear away all the directories if run with the -d or -D options ##
295
DBG_BUILD=0
296
while getopts d OPT; do
297
    case "$OPT" in
298
        d)
299 74 julius
            DBG_BUILD=1
300
            ;;
301 22 ocadmin
    esac
302
done
303
 
304
##Welcome message
305
echo
306
echo "The OpenRISC toolchain install script - Provided by ORSoC & MeansOfFreedom.net"
307
echo "Version $SCRIPT_VERSION"
308
echo
309
echo "#####################################README#####################################"
310
echo
311
echo "This script will install tools required for development on the OpenRISC platform"
312
echo "This version ($SCRIPT_VERSION) includes: "
313
echo "        $GCC_VER, $BINUTILS_VER, $UCLIB_VER"
314
echo "        $LINUX_VER, $GDB_VER, $BUSY_VER and $SIM_VER"
315
echo
316
echo "Please follow the prompts to select the install location."
317
echo
318
echo "Note: Two new directories, or32-build and or32-download, will be created in the"
319
echo "current directory for storing downloaded files and building the tools."
320
echo "Also: This script attempts to mount a ramdisk image in a local directory to copy"
321
echo "in the freshly built busybox. This requires root user privileges - if they are"
322
echo "not deteceted the existing busybox binaries will remain in the ramdisk image."
323
echo
324
echo "#####################################README#####################################"
325
echo
326
 
327
echo "Install the toolchain under current directory?"
328
echo "Current directory: [$DIR]"
329
echo "Tools will be installed in [$DIR/$TARGET]"
330
echo [Y/n]:
331
read YN
332
 
333 72 julius
 
334 22 ocadmin
## $YN will be zero length string if user just pressed enter ##
335
if [ -z $YN ]
336 74 julius
then
337 22 ocadmin
    VAL="y"
338
else
339
    VAL=$(echo $YN | tr [:upper:] [:lower:])
340
fi
341
 
342
if [ $VAL = "n" ]
343 74 julius
then
344 22 ocadmin
    # Optional install path
345
    echo "Enter the path the toolchain will be installed in:"
346
    read DIR
347
 
348
    # Check if the path exists and ask the user to verify it
349
    until [ $DN = "y" ]
350 74 julius
    do
351
 
352 22 ocadmin
        #Check the path exists
353
        if [ -d $DIR ]
354 74 julius
        then
355 22 ocadmin
            # The path entered is OK
356
            echo "Chosen directory is [$DIR]"
357 72 julius
            echo "Tools will be installed in [$DIR/$TARGET], or1ksim in [$DIR/or1ksim]"
358 22 ocadmin
            echo "[y/n]:"
359
            read DN
360
 
361
            if [ -z $DN ]
362 74 julius
            then
363 22 ocadmin
                # Presume yes here
364
                DN="y"
365
            fi
366
 
367
            VAL=$(echo $DN | tr [:upper:] [:lower:])
368
        else
369
            echo
370
            #echo "Path does not exist. Please create it and ensure user has correct permissions."
371
            echo "Path does not exist. Create $DIR now?"
372
            echo "[y/N]:"
373
            read MKPATH
374
            if [ -z $MKPATH ]
375 74 julius
            then
376 22 ocadmin
                ## $MKPATH was zero, so user probably just pressed enter without entering anything, which we'll interpret as "n" ##
377
                MKPATHYN="n"
378
            else
379
                MKPATHYN=$(echo $MKPATH | tr [:upper:] [:lower:])
380
            fi
381
 
382
            if [ $MKPATHYN = "y" ]
383 74 julius
            then
384 72 julius
                `mkdir -p $DIR`
385 22 ocadmin
 
386
                # Check we made it successfully
387
                if [ $? -ne 0 ]
388 74 julius
                then
389 22 ocadmin
                    DN="n"
390
                else
391
                    DN="x" # Set this so we do go back through and ask the user to verify
392
                fi
393
 
394
            else
395
                DN="n"
396
            fi
397
        fi
398
 
399
        if [ $DN = "n" ]
400 74 julius
        then
401 22 ocadmin
            echo "Enter the path the toolchain should be installed in:"
402
            read DIR
403
        fi
404
 
405
    done
406
    cd $DIR
407
#    echo "loop done"
408
#    echo "Working in " `pwd`
409
fi
410
 
411
## Now check that the required tools to build the toolchain are installed
412
check_essential_build_tools
413
 
414
BUILD_TOP=$START_DIR/or32-build
415
export BUILD_TOP
416
 
417
## Set donload directory to be under the current directory ##
418
DOWNLOAD_DIR=$START_DIR/or32-download
419
 
420
## Setup the target tool installation directory ##
421
INSTALL_DIR=$DIR
422
 
423 72 julius
$MKDIR $INSTALL_DIR
424 22 ocadmin
 
425
####################################################################################################
426
## Now check which sources have already been downloaded, if any ##
427 39 julius
DO_DOWNLOADS="y" ## Default is to NOT do downloads
428 22 ocadmin
 
429
if [ $DBG_BUILD -eq 1 ]
430 74 julius
then
431 22 ocadmin
    ## Ask if we should do downloads ##
432
    echo "Do downloads?"
433
    echo "[y/N]:"
434
    read DO_DOWNLOADS
435
    ## $YN will be zero length string if user just pressed enter ##
436
    if [ -z $DO_DOWNLOADS ]
437 74 julius
    then
438 22 ocadmin
        DO_DOWNLOADS="n"
439
    else
440 39 julius
        DO_DOWNLOADS=$(echo $DO_DOWNLOADS | tr [:upper:] [:lower:])
441 22 ocadmin
    fi
442
 
443
fi
444
 
445
if [ $DO_DOWNLOADS = "y" ]
446
then
447
## Check if download directory exists, if not create it ##
448 39 julius
    if [ ! -d $DOWNLOAD_DIR ]; then
449 72 julius
        $MKDIR $DOWNLOAD_DIR
450 22 ocadmin
    fi
451
 
452 39 julius
    cd $DOWNLOAD_DIR
453
 
454 22 ocadmin
## We'll need the md5sum file ##
455
## This is a file stored on the ORSoC FTP server, containing checksums of all the files we need ##
456
    rm -f $MD5SUM_FILE
457
    wget ftp://$ORSOC_FTP_USER:$ORSOC_FTP_PASSWD@$ORSOC_FTP_HOST/$ORSOC_FTP_DIR/$MD5SUM_FILE
458
## Make sure we got that OK ##
459
    check_exit_code
460
 
461
## We have lists of what to get from each FTP let's create a loop for each ##
462
 
463
## ORSoC FTP server downloads ##
464
    for CURRENT_FILE in $ORSOC_FTP_FILE_LIST
465 74 julius
    do
466 22 ocadmin
  # Check if we've already got the file
467 74 julius
        if [ -e $CURRENT_FILE ]
468
        then
469
            echo "File $CURRENT_FILE exists locally."
470
            echo "Verifying MD5 checksum:"
471 22 ocadmin
      ## Verify it's right by checking the MD5 checksum ##
472
      ## First we get the line for $CURRENT_FILE out of the $MD5SUM_FILE, then feed it to "md5sum -c"
473
      ## which checks it and sets the return code, $? to 0 if OK, 1 if problem ##
474 74 julius
            cat $MD5SUM_FILE | grep $CURRENT_FILE | md5sum -c
475
            if [ $? -ne 0 ]
476
            then
477 22 ocadmin
          #MD5sum of $CURRENT_FILE differs from expected value - we'll download it again
478 74 julius
                echo "MD5 checksum of $CURRENT_FILE differs from expected value. Re-downloading."
479
                rm -f $CURRENT_FILE
480
                wget ftp://$ORSOC_FTP_USER:$ORSOC_FTP_PASSWD@$ORSOC_FTP_HOST/$ORSOC_FTP_DIR/$CURRENT_FILE
481
                check_exit_code
482
            fi
483
        else
484 22 ocadmin
      # File doesn't exist locally - we'll download it
485 74 julius
            echo "Downloading $CURRENT_FILE"
486
            wget ftp://$ORSOC_FTP_USER:$ORSOC_FTP_PASSWD@$ORSOC_FTP_HOST/$ORSOC_FTP_DIR/$CURRENT_FILE
487
            check_exit_code
488
        fi
489
        echo
490 22 ocadmin
    done
491
 
492
## GNU FTP server downloads ##
493
    for CURRENT_FILE in $GNU_FTP_FILE_LIST
494 74 julius
    do
495 22 ocadmin
  ## Check if we've already got the file ##
496 74 julius
        if [ -e $CURRENT_FILE ]
497
        then
498
            echo "File $CURRENT_FILE exists locally."
499
            echo "Verifying MD5 checksum:"
500 22 ocadmin
      ## Verify it's right by checking the MD5 checksum ##
501
      ## First we get the line for $CURRENT_FILE out of the $MD5SUM_FILE, then feed it to "md5sum -c"
502
      ## which checks it and sets the return code, $? to 0 if OK, 1 if problem ##
503 74 julius
            cat $MD5SUM_FILE | grep $CURRENT_FILE | md5sum -c
504
            if [ $? -ne 0 ]
505
            then
506 22 ocadmin
          ## MD5sum of present one is incorrect - we'll download it again ##
507 74 julius
                echo "MD5 checksum of $CURRENT_FILE differs from expected value. Re-downloading."
508
                rm -f $CURRENT_FILE
509 22 ocadmin
          ## Depending on the file, we need a specific path ##
510
          ## gcc's path on ftp ##
511 74 julius
                if [ $CURRENT_FILE = $ZBALL2 ]; then
512
                    GNU_FTP_DIR=$GNU_FTP_GCC_DIR
513
                fi
514 22 ocadmin
          ## gdb's path on ftp ##
515 74 julius
                if [ $CURRENT_FILE = $ZBALL8 ]; then
516
                    GNU_FTP_DIR=$GNU_FTP_GDB_DIR
517
                fi
518
                wget ftp://$GNU_FTP_USER:$GNU_FTP_USER@$GNU_FTP_HOST/$GNU_FTP_DIR/$CURRENT_FILE
519
                check_exit_code
520
            fi
521
        else
522 22 ocadmin
      # File doesn't exist - we'll download it
523 74 julius
            echo "Downloading $CURRENT_FILE"
524 22 ocadmin
      ## Depending on the file, we need a specific path ##
525
      ## gcc's path on ftp ##
526 74 julius
            if [ $CURRENT_FILE = $ZBALL2 ]; then
527
                GNU_FTP_DIR=$GNU_FTP_GCC_DIR
528
            fi
529 22 ocadmin
      ## gdb's path on ftp ##
530 74 julius
            if [ $CURRENT_FILE = $ZBALL8 ]; then
531
                GNU_FTP_DIR=$GNU_FTP_GDB_DIR
532
            fi
533
            wget ftp://$GNU_FTP_USER:$GNU_FTP_USER@$GNU_FTP_HOST/$GNU_FTP_DIR/$CURRENT_FILE
534
            check_exit_code
535
        fi
536
        echo
537 22 ocadmin
    done
538
 
539
## Kernel.org FTP server downloads ##
540
    CURRENT_FILE=$KERNEL_FTP_FILE_LIST
541
## Usually just a single file from the kernel.org ftp site ##
542
    if [ -e $CURRENT_FILE ]
543
    then
544
        echo "File $CURRENT_FILE exists locally."
545
        echo "Verifying MD5 checksum:"
546
    ## Verify it's right by checking the MD5 checksum ##
547
    ## First we get the line for $CURRENT_FILE out of the $MD5SUM_FILE, then feed it to "md5sum -c"
548
    ## which checks it and sets the return code, $? to 0 if OK, 1 if problem ##
549
        cat $MD5SUM_FILE | grep $CURRENT_FILE | md5sum -c
550
        if [ $? -ne 0 ]
551 74 julius
        then
552 22 ocadmin
        #MD5sum of present one is incorrect - we'll download it again
553
            echo "MD5 checksum of $CURRENT_FILE differs from expected value. Re-downloading."
554
            rm -f $CURRENT_FILE
555
            wget ftp://$KERNEL_FTP_USER:$KERNEL_FTP_USER@$KERNEL_FTP_HOST/$KERNEL_FTP_DIR/$CURRENT_FILE
556
            check_exit_code
557
        fi
558
    else
559
    ## Download it ##
560
        echo "Downloading $CURRENT_FILE"
561
        wget ftp://$KERNEL_FTP_USER:$KERNEL_FTP_PASSWD@$KERNEL_FTP_HOST/$KERNEL_FTP_DIR/$CURRENT_FILE
562 74 julius
        check_exit_code
563 22 ocadmin
    fi
564
 
565 74 julius
    echo
566 22 ocadmin
fi # if [ $DO_DOWNLOADS = "y" ]
567 74 julius
 
568 22 ocadmin
####################################################################################################
569
 
570
## Cygwin exports ##
571
ON_CYGWIN=`set | grep -i mach|grep -i -c cygwin`
572
if [ $ON_CYGWIN -ge 1 ]
573 74 julius
then
574 22 ocadmin
    echo
575 39 julius
    echo "Cygwin host detected"
576
    echo "Platform specific exports:"
577 22 ocadmin
    echo  "export HOST_LOADLIBES=\"-lcurses -lintl\" "
578
    echo
579 39 julius
    export ON_CYGWIN=1
580 22 ocadmin
    export HOST_LOADLIBES="-lcurses -lintl"
581
fi
582
 
583
####################################################################################################
584
 
585
cd $START_DIR
586
 
587
## if not debug building, let's remove all the old stuff ##
588
 
589
if [ $DBG_BUILD -eq 0 ]
590 74 julius
then
591 22 ocadmin
## Always start with a clean build dir ##
592
    rm -fr $BUILD_TOP
593 72 julius
    $MKDIR $BUILD_TOP
594 22 ocadmin
    chmod 777 $BUILD_TOP
595
 
596 72 julius
    $MKDIR $BUILD_TOP/b-gcc
597
    $MKDIR $BUILD_TOP/b-b
598 22 ocadmin
fi
599
 
600
## default build option is yes ##
601
BUILD_THIS="y"
602
 
603
if [ $DBG_BUILD -eq 1 ]
604 74 julius
then
605 22 ocadmin
    ## Ask if we should build binutils ##
606
    echo "Re-build $BINUTILS_VER ?"
607
    echo "[y/N]:"
608
    read YN
609
    ## $YN will be zero length string if user just pressed enter ##
610
    if [ -z $YN ]
611 74 julius
    then
612 22 ocadmin
        BUILD_THIS="n"
613
    else
614
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
615
    fi
616
 
617
    if [ $BUILD_THIS = "y" ]
618 74 julius
    then
619 22 ocadmin
        ## Delete and recreate the binutils directory ##
620
        rm -rf $BUILD_TOP/b-b
621
        rm -rf $BUILD_TOP/$BINUTILS_VER
622 72 julius
        $MKDIR $BUILD_TOP/b-b
623 22 ocadmin
 
624
    fi
625
fi
626
 
627
##########################Building Binutils#######################
628
if [ $BUILD_THIS = "y" ]
629 74 julius
then
630 22 ocadmin
 
631
    echo "############################## Building binutils ###############################"
632
    echo
633
    echo "Decompressing source"
634
    cd $BUILD_TOP
635
 
636
## Extract sources ##
637
    tar xjf $DOWNLOAD_DIR/$ZBALL1
638
 
639
    echo
640
    echo "Patching binutils with $BINUTILS_PATCH"
641
 
642
    cd $BINUTILS_VER
643
 
644
    bzip2 -dc $DOWNLOAD_DIR/$BINUTILS_PATCH | patch -p1 > $BINUTILS_VER-patch.log 2>&1
645
 
646
## Make sure that patched ok ##
647
    check_exit_code
648
 
649
    cd ..
650
    cd $BUILD_TOP/b-b
651
 
652
    echo
653
    echo "Configuring $BINUTILS_VER: --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --disable-checking"
654
    echo "Logging output to $BINUTILS_VER-configure.log"
655
    $BUILD_TOP/$BINUTILS_VER/configure --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --disable-checking > $BINUTILS_VER-configure.log 2>&1
656
 
657
    echo
658
    echo "Making and installing $BINUTILS_VER"
659
    echo "Logging output to $BINUTILS_VER-make.log "
660
    make all install > $BINUTILS_VER-make.log 2>&1
661
 
662
## Make sure that built ok ##
663
    check_exit_code
664
 
665
    cd $BUILD_TOP
666
 
667
fi
668
#######################Finish Building Binutils#####################
669
 
670
## Export the path to the new or32 binaries directory, used by the rest of this script ##
671
echo
672
echo "Adding $INSTALL_DIR/$TARGET/bin to the PATH variable"
673
export PATH=$INSTALL_DIR/$TARGET/bin:$PATH
674
 
675
## default build option is yes ##
676
BUILD_THIS="y"
677
 
678
if [ $DBG_BUILD -eq 1 ]
679 74 julius
then
680 22 ocadmin
    ## Ask if we should do the initial builds of GCC and Linux ##
681
    echo "Re-do initial $GCC_VER and $LINUX_VER builds (note if you choose to do this then it's EXTREMELY likely that you will have to do the rest of the script, particularly the re-build of gcc that occurs later)?"
682
    echo "[y/N]:"
683
    read YN
684
    ## $YN will be zero length string if user just pressed enter ##
685
    if [ -z $YN ]
686 74 julius
    then
687 22 ocadmin
        BUILD_THIS="n" # default is no
688
    else
689
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
690
    fi
691
 
692
    if [ $BUILD_THIS = "y" ]
693 74 julius
    then
694 22 ocadmin
        ## Delete and recreate the gcc directory ##
695
        rm -rf $BUILD_TOP/b-gcc
696
        rm -rf $BUILD_TOP/$GCC_VER
697
        rm -rf $BUILD_TOP/$LINUX_VER
698
 
699 72 julius
        $MKDIR $BUILD_TOP/b-gcc
700 22 ocadmin
 
701
        ## Undo everything done in the next part
702
        rm -rf $INSTALL_DIR/$TARGET/include
703
        unlink $INSTALL_DIR/$TARGET/sys-include
704
 
705
    fi
706
fi
707
 
708
##########################Building GCC and Linux############################
709
if [ $BUILD_THIS = "y" ]
710 74 julius
then
711 22 ocadmin
 
712
    echo
713
    echo "####################### Building or32 gcc and Linux ############################"
714
    echo
715
    echo "Decompressing source"
716
 
717
    cd $BUILD_TOP
718
 
719
## Extract sources ##
720
    tar xjf $DOWNLOAD_DIR/$ZBALL2 ## gcc sources ##
721
 
722
    tar xjf $DOWNLOAD_DIR/$ZBALL4 ## Linux kernel sources ##
723
 
724
    echo
725
    echo "Patching $LINUX_VER with patch file $LINUX_PATCH"
726
 
727
    cd $LINUX_VER
728
 
729
## Apply patch to linux kernel sources ##
730
    bzip2 -dc $DOWNLOAD_DIR/$LINUX_PATCH | patch -p1 > $LINUX_VER-patch.log 2>&1
731
 
732
## Make sure that patched ok ##
733
    check_exit_code
734 39 julius
## Copy our preconfigured configuration file into place ##
735 22 ocadmin
    cp rgd_dot_config .config
736
 
737
    echo
738
    echo "Making Linux oldconfig"
739
 
740
    make oldconfig > $LINUX_VER-make-oldconfig.log 2>&1
741
 
742
## Make sure that built ok ##
743
    check_exit_code
744
 
745
    cd $BUILD_TOP
746
 
747 72 julius
    $MKDIR $INSTALL_DIR/$TARGET/include
748
    $MKDIR $INSTALL_DIR/$TARGET/include/asm
749
    $MKDIR $INSTALL_DIR/$TARGET/include/linux
750 22 ocadmin
 
751
    cp -f -dR $LINUX_VER/include/linux/* $INSTALL_DIR/$TARGET/include/linux
752
    cp -f -dR $LINUX_VER/include/asm-or32/* $INSTALL_DIR/$TARGET/include/asm
753
 
754
    cd $INSTALL_DIR/$TARGET
755
    ln -s include sys-include
756
    cd $BUILD_TOP
757
 
758
    cd $GCC_VER
759
 
760
## Patch gcc ##
761
    echo
762
    echo "Patching $GCC_VER with $GCC_PATCH"
763
 
764
    bzip2 -dc $DOWNLOAD_DIR/$GCC_PATCH | patch -p1 > $GCC_VER-patch.log 2>&1
765
 
766
## Make sure that patched ok ##
767
    check_exit_code
768
 
769
    cd $BUILD_TOP
770
    cd b-gcc
771
 
772
    # configure GCC
773
    echo
774
    echo "Configuring $GCC_VER: --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --with-local-prefix=$INSTALL_DIR/$TARGET/$TARGET --with-gnu-as --with-gnu-ld --disable-libssp --enable-languages=c"
775
    echo "Logging output to $GCC_VER-configure.log"
776
    $BUILD_TOP/$GCC_VER/configure --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --with-local-prefix=$INSTALL_DIR/$TARGET/$TARGET --with-gnu-as --with-gnu-ld --disable-libssp --enable-languages=c > $GCC_VER-configure.log 2>&1
777
 
778
    echo
779
    echo "Making and installing $GCC_VER"
780
    echo "Logging output to $GCC_VER-make.log"
781
    make all install > $GCC_VER-make.log 2>&1
782
 
783
## Make sure that built ok ##
784
    check_exit_code
785
 
786
    cd $BUILD_TOP
787
 
788
    echo
789
    echo "Making vmlinux image"
790
    echo "Logging output to vmlinux-make.log"
791
 
792
    cd $LINUX_VER
793
    make vmlinux ARCH=or32 CROSS_COMPILE=$INSTALL_DIR/$TARGET/bin/$TARGET- > vmlinux-make.log 2>&1
794
 
795
## Make sure that built ok ##
796
    check_exit_code
797
fi
798
##########################Finish Building GCC and Linux############################
799
 
800
 
801
## default build option is yes ##
802
BUILD_THIS="y"
803
 
804
if [ $DBG_BUILD -eq 1 ]
805 74 julius
then
806 22 ocadmin
    ## Ask if we should rebuild uClibc ##
807
    echo "Re-build $UCLIB_VER ?"
808
    echo "[y/N]:"
809
    read YN
810
    ## $YN will be zero length string if user just pressed enter ##
811
    if [ -z $YN ]
812 74 julius
    then
813 22 ocadmin
        BUILD_THIS="n" # default is no
814
    else
815
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
816
    fi
817
 
818
    if [ $BUILD_THIS = "y" ]
819 74 julius
    then
820 22 ocadmin
        ## Delete the uClibc directory ##
821
        rm -rf $BUILD_TOP/$UCLIB_VER
822
    fi
823
fi
824
 
825
##########################Building uClibc#########################
826
if [ $BUILD_THIS = "y" ]
827 74 julius
then
828 22 ocadmin
 
829
    echo
830
    echo "############################## Building uClibc #################################"
831
    echo
832
    echo "Decompressing source"
833
 
834
    cd $BUILD_TOP
835
    tar xjf $DOWNLOAD_DIR/$ZBALL3 ## uClibc sources ##
836
 
837
    echo
838
    echo "Patching $UCLIB_VER with $UCLIBC_PATCH"
839
 
840
    cd $UCLIB_VER
841
 
842
## Patch uClibc sources ##
843
    bzip2 -dc $DOWNLOAD_DIR/$UCLIBC_PATCH  | patch -p1 > $UCLIB_VER-patch.log 2>&1
844
 
845
## Make sure that patched ok ##
846
    check_exit_code
847
 
848
    export CC=$TARGET-gcc
849
    export BUILD_TOP
850
    #cp $DOWNLOAD_DIR/$CONFIG1  $BUILD_TOP/$UCLIB_VER/.config
851
    #cp $DOWNLOAD_DIR/$CONFIG1  $BUILD_TOP/$UCLIB_VER/.config.old
852
 
853
    ## $TARGET name implementation into config script ##
854
    ## First get the second part of the target name, after the "-", the "elf" in "or32-elf", for example ##
855
    TARGET_SECOND_PART=`echo $TARGET | cut -f 2 -d "-"`
856
    ## First change any references to the uclinux target ##
857
    ## And delete the line saying DEVEL_PREFIX so we can put our $INSTALL_DIR path in ##
858
    sed "s/or32\-uclinux/\or32\-$TARGET_SECOND_PART/" $DOWNLOAD_DIR/$CONFIG1 | sed "/DEVEL\_PREFIX\=/d"  > $BUILD_TOP/$UCLIB_VER/.config  ## Output to the .config ##
859
    ## Now output the new DEVEL_PATH= value ##
860
    echo "DEVEL_PREFIX=\"$INSTALL_DIR/$TARGET\"" >> $BUILD_TOP/$UCLIB_VER/.config
861
    ## copy it to .config.old ##
862
    cp $BUILD_TOP/$UCLIB_VER/.config $BUILD_TOP/$UCLIB_VER/.config.old
863
    ## Do the configuration ##
864
 
865
## Change the cross compiler name in the Config.or32 file
866
## First get the second part of the target name, after the "-" ##
867
    TARGET_SECOND_PART=`echo $TARGET | cut -f 2 -d "-"`
868
## Removes the uclinux line and changes to whatever our current target is ##
869
    sed "s/or32\-uclinux/\or32\-$TARGET_SECOND_PART/" $BUILD_TOP/$UCLIB_VER/extra/Configs/Config.or32  > $BUILD_TOP/$UCLIB_VER/extra/Configs/Config.or32.newtarget
870
    mv $BUILD_TOP/$UCLIB_VER/extra/Configs/Config.or32.newtarget $BUILD_TOP/$UCLIB_VER/extra/Configs/Config.or32
871
 
872 74 julius
    if [ $ON_CYGWIN -ge 1 ]
873 39 julius
    then
874
## If on Cygwin, fix strange error where 'install' command by the makefile ##
875
## results in it trying to execute the INSTALL text file in the root of the ##
876
## package ##
877 74 julius
        mv INSTALL INSTALL.txt
878
    fi
879 39 julius
 
880 22 ocadmin
    echo
881
    echo "Making uClibc oldconfig"
882
 
883
    HOST_LOADLIBES="-lcurses -lintl" HOSTCC=`which gcc` make oldconfig > $UCLIB_VER-make-oldconfig.log 2>&1
884
 
885
## Make sure that built ok ##
886
    check_exit_code
887
 
888
    ln -s extra/Configs/Config.or32 Config
889
 
890
    echo
891
    echo "Making and install $UCLIB_VER"
892
    echo "Logging output to $UCLIB_VER-make.log"
893
    make all install > $UCLIB_VER-make.log 2>&1
894
 
895
## Make sure that built ok ##
896
    check_exit_code
897
 
898
    unset CC
899
fi
900
##########################Finish Building uClibc#########################
901
 
902 74 julius
 
903 22 ocadmin
## default build option is yes ##
904
BUILD_THIS="y"
905
 
906
if [ $DBG_BUILD -eq 1 ]
907 74 julius
then
908 22 ocadmin
    ## Ask if we should rebuild gcc ##
909
    echo "Perform $GCC_VER re-build? - YES (y) if you rebuilt GCC and Linux previously, otherwise definitely NO (n)."
910
    echo "[y/N]:"
911
    read YN
912
    ## $YN will be zero length string if user just pressed enter ##
913
    if [ -z $YN ]
914 74 julius
    then
915 22 ocadmin
        BUILD_THIS="n" # default is no
916
    else
917
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
918
    fi
919
 
920
    if [ $BUILD_THIS = "y" ]
921 74 julius
    then
922 22 ocadmin
        ## Undo some things we did before after doing this compile ##
923
        unlink $INSTALL_DIR/$TARGET/$TARGET/sys-include
924
        rm -rf $INSTALL_DIR/$TARGET/$TARGET/lib/*
925
    fi
926
fi
927
 
928
 
929
##########################re-Building GCC########################
930
if [ $BUILD_THIS = "y" ]
931 74 julius
then
932 22 ocadmin
 
933
    echo
934
    echo "############################## Re-building or-32 gcc ###########################"
935
    echo
936
    echo "Re-building $GCC_VER"
937
 
938
    cd $BUILD_TOP
939
 
940
    cd b-gcc
941
 
942
    echo
943
    echo "Re-configuring $GCC_VER: --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --with-local-prefix=$INSTALL_DIR/$TARGET/$TARGET --with-gnu-as --with-gnu-ld --disable-libssp --enable-languages=c"
944
    echo "Logging output to $GCC_VER-rebuild-configure.log"
945
 
946
    $BUILD_TOP/$GCC_VER/configure --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --with-local-prefix=$INSTALL_DIR/$TARGET/$TARGET --with-gnu-as --with-gnu-ld --disable-libssp --enable-languages=c > $GCC_VER-rebuild-configure.log 2>&1
947
 
948
 
949
 
950
    echo
951
    echo "Re-building and re-installing $GCC_VER"
952
    echo "Logging output to $GCC_VER-rebuild-make.log"
953
    make all install > $GCC_VER-rebuild-make.log 2>&1
954
 
955
## Make sure that built ok ##
956
    check_exit_code
957
 
958
    cd $INSTALL_DIR/$TARGET/$TARGET
959
    ln -s ../include sys-include
960
    cd lib
961
    cp -f -dR ../../lib/* .
962
    cd $BUILD_TOP
963
 
964
fi
965 74 julius
 
966 22 ocadmin
##########################finish re-Building GCC########################
967
 
968
 
969
## default build option is yes ##
970
BUILD_THIS="y"
971
 
972
if [ $DBG_BUILD -eq 1 ]
973 74 julius
then
974 22 ocadmin
    ## Ask if we should rebuild gdb ##
975
    echo "Rebuild $GDB_VER?"
976
    echo "[y/N]:"
977
    read YN
978
    ## $YN will be zero length string if user just pressed enter ##
979
    if [ -z $YN ]
980 74 julius
    then
981 22 ocadmin
        BUILD_THIS="n" # default is no
982
    else
983
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
984
    fi
985
 
986
    if [ $BUILD_THIS = "y" ]
987 74 julius
    then
988 22 ocadmin
        ## Delete existing gdb dir ##
989
        rm -rf $BUILD_TOP/$GDB_VER
990
    fi
991
fi
992
 
993
 
994
########################## GDB build ################
995
if [ $BUILD_THIS = "y" ]
996 74 julius
then
997 22 ocadmin
 
998
    echo
999
    echo "############################## Building GDB ####################################"
1000
    echo
1001
    echo "Decompressing source"
1002
 
1003
 
1004
    cd $BUILD_TOP
1005
 
1006
    tar xjf $DOWNLOAD_DIR/$ZBALL8
1007
 
1008
    echo
1009
    echo "Patching $GDB_VER with $GDB_PATCH"
1010 59 julius
    echo "Logging output to $GDB_VER-patch.log"
1011 22 ocadmin
    cd $GDB_VER
1012
 
1013
    bzcat -dc $DOWNLOAD_DIR/$GDB_PATCH | patch -p1 > $GDB_VER-patch.log 2>&1
1014
 
1015
## Make sure that patched ok ##
1016
    check_exit_code
1017
 
1018
    echo
1019 59 julius
    echo "Configuring $GDB_VER: --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --disable-werror"
1020
    echo "Logging output to $GDB_VER-configure.log"
1021 22 ocadmin
 
1022 59 julius
    ./configure --target=$TARGET --prefix=$INSTALL_DIR/$TARGET --disable-werror > $GDB_VER-configure.log 2>&1
1023 22 ocadmin
 
1024
    echo
1025
    echo "Making and installing $GDB_VER"
1026 59 julius
    echo "Logging output to $GDB_VER-make.log"
1027 22 ocadmin
    make all install > $GDB_VER-make.log 2>&1
1028
 
1029
## Make sure that built ok ##
1030
    check_exit_code
1031
 
1032
    cd $BUILD_TOP
1033
 
1034
fi
1035
########################## finish GDB build ################
1036
 
1037
## default build option is yes ##
1038
BUILD_THIS="y"
1039
 
1040
if [ $DBG_BUILD -eq 1 ]
1041 74 julius
then
1042 22 ocadmin
    ## Ask if we should rebuild busybox ##
1043
    echo "Rebuild $BUSY_VER?"
1044
    echo "[y/N]:"
1045
    read YN
1046
    ## $YN will be zero length string if user just pressed enter ##
1047
    if [ -z $YN ]
1048 74 julius
    then
1049 22 ocadmin
        BUILD_THIS="n" # default is no
1050
    else
1051
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
1052
    fi
1053
 
1054
    if [ $BUILD_THIS = "y" ]
1055 74 julius
    then
1056 22 ocadmin
        ## Delete existing busybox stuff ##
1057
        rm -rf $BUILD_TOP/$BUSY_VER
1058
    fi
1059
fi
1060
 
1061
##########################Building Busybox########################
1062
if [ $BUILD_THIS = "y" ]
1063 74 julius
then
1064 22 ocadmin
 
1065
    echo
1066
    echo "############################## Building BusyBox ################################"
1067
    echo
1068
    echo "Decompressing source"
1069
 
1070
 
1071
    cd $BUILD_TOP
1072
 
1073
    tar xjf $DOWNLOAD_DIR/$ZBALL5
1074
 
1075
 
1076
    cd $BUSY_VER
1077
    cp $DOWNLOAD_DIR/$CONFIG2  $BUILD_TOP/$BUSY_VER/.config
1078
    cp $DOWNLOAD_DIR/$CONFIG2  $BUILD_TOP/$BUSY_VER/.config.old
1079
 
1080
    echo
1081
    echo "Making $BUSY_VER oldconfig"
1082
    make oldconfig > $BUSY_VER-make-oldconfig.log 2>&1
1083
 
1084
## Make Sure that built ok ##
1085
    check_exit_code
1086
 
1087
## Put the Linux headers in BusyBox's include dir ##
1088
 
1089
    ln -s $BUILD_TOP/$LINUX_VER/include/linux $BUILD_TOP/$BUSY_VER/include/.
1090
    ln -s $BUILD_TOP/$LINUX_VER/include/asm $BUILD_TOP/$BUSY_VER/include/.
1091
 
1092
    echo
1093
    echo "Making $BUSY_VER"
1094
    echo "Logging output to $BUSY_VER-make.log"
1095
    make ARCH=or32 CROSS_COMPILE=$INSTALL_DIR/$TARGET/bin/$TARGET- > $BUSY_VER-make.log 2>&1
1096
 
1097
## Make sure that built ok ##
1098
    check_exit_code
1099
 
1100
    echo
1101
    echo "Installing $BUSY_VER"
1102
    echo "Logging output to $BUSY_VER-install.log"
1103
    make install ARCH=or32 CROSS_COMPILE=$INSTALL_DIR/$TARGET/bin/$TARGET- > $BUSY_VER-install.log 2>&1
1104
 
1105
## Make sure that built ok ##
1106
    check_exit_code
1107
 
1108
    cd $BUILD_TOP
1109
 
1110
## Copy and extract the ramdisk image file
1111
 
1112
    cp $DOWNLOAD_DIR/$ZBALL7 . ## Ramdisk file ##
1113
 
1114
    bunzip2 $RAMDISK_FILE.bz2
1115
 
1116
## We can only play with the ext2 image if we're not on Cygwin ##
1117
    if [ -z $ON_CYGWIN ]
1118 74 julius
    then
1119 22 ocadmin
 
1120
        RT=`whoami`
1121
        if [ $RT = "root" ];then
1122 72 julius
            $MKDIR rd_mount
1123 22 ocadmin
            chmod 777 rd_mount
1124
            mount -t ext2 -o loop $RAMDISK_FILE rd_mount
1125
            cp -f -dR $BUILD_TOP/busy_out.1.7.5/* $BUILD_TOP/rd_mount
1126
            umount rd_mount
1127
            cp -f $RAMDISK_FILE $LINUX_VER/$LINUX_RAMDISK_FILE
1128
        else
1129
            echo
1130
            echo "User is not root. Unable to mount Linux ramdisk."
1131
            echo "Note that this program built BusyBox but did not"
1132
            echo "install it on the ramdisk. Defaults are used."
1133
            cp -f $RAMDISK_FILE $LINUX_VER/$LINUX_RAMDISK_FILE
1134
        fi
1135
 
1136
    fi ## if [ -z $ON_CYGWIN ]
1137
 
1138
    cd $BUILD_TOP
1139
fi
1140
 
1141
########################## Finish BusyBox build ################
1142
 
1143
## default build option is yes ##
1144
BUILD_THIS="y"
1145
 
1146
if [ $DBG_BUILD -eq 1 ]
1147 74 julius
then
1148 22 ocadmin
    ## Ask if we should rebuild linux again##
1149
    echo "Rebuild the $LINUX_VER rebuild (only ever yes (y) if performed previous linux rebuild)?"
1150
    echo "[y/N]:"
1151
    read YN
1152
    ## $YN will be zero length string if user just pressed enter ##
1153
    if [ -z $YN ]
1154 74 julius
    then
1155 22 ocadmin
        BUILD_THIS="n" # default is no
1156
    else
1157
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
1158
    fi
1159
 
1160
fi
1161
 
1162
#echo "Start Building Linux kernel?"
1163
#read Q
1164
##########################Final Linux kernel build################
1165
if [ $BUILD_THIS = "y" ]
1166 74 julius
then
1167 22 ocadmin
 
1168
    echo
1169
    echo "########################### Linux image generation #############################"
1170
    cd $BUILD_TOP
1171
    cd $LINUX_VER
1172
 
1173
    echo
1174
    echo "Making vmlinux"
1175
    echo "Logging output to vmlinux-remake.log"
1176
    make vmlinux ARCH=or32 CROSS_COMPILE=$INSTALL_DIR/$TARGET/bin/$TARGET- > vmlinux-remake.log 2>&1
1177
 
1178
## Make sure that built ok ##
1179
    check_exit_code
1180
 
1181
    cd $BUILD_TOP
1182
fi
1183
##########################Finished Final Linux kernel build################
1184
 
1185
BUILD_THIS="y"
1186
 
1187
if [ $DBG_BUILD -eq 1 ]
1188 74 julius
then
1189 22 ocadmin
    ## Ask if we should rebuild or1ksim##
1190
    echo "Rebuild $SIM_VER ?"
1191
    echo "[y/N]:"
1192
    read YN
1193
    ## $YN will be zero length string if user just pressed enter ##
1194
    if [ -z $YN ]
1195 74 julius
    then
1196 22 ocadmin
        BUILD_THIS="n" # default is no
1197
    else
1198
        BUILD_THIS=$(echo $YN | tr [:upper:] [:lower:])
1199
    fi
1200
 
1201
    if [ $BUILD_THIS = "y" ]
1202 74 julius
    then
1203 22 ocadmin
        ## Clean previous or1ksim directories ##
1204
        rm -rf $BUILD_TOP/$SIM_VER
1205
    fi
1206
fi
1207
 
1208
 
1209
##########################Simulator build#########################
1210
if [ $BUILD_THIS = "y" ]
1211 74 julius
then
1212 22 ocadmin
 
1213
    echo
1214
    echo "############################## Building or1ksim ################################"
1215
    echo
1216
    echo "Decompressing source"
1217
 
1218
    cd $BUILD_TOP
1219
 
1220
    tar xjf $DOWNLOAD_DIR/$ZBALL6
1221
 
1222
    cd $SIM_VER
1223
 
1224
    echo
1225 72 julius
    echo "Configuring $SIM_VER: --target=$TARGET --prefix=$INSTALL_DIR/$SIM_VER"
1226 22 ocadmin
 
1227 72 julius
    ./configure --target=$TARGET --prefix=$INSTALL_DIR/$SIM_VER > $SIM_VER-configure.log 2>&1
1228 22 ocadmin
 
1229
    echo
1230
    echo "Making and installing $SIM_VER"
1231
    echo "Logging output to $SIM_VER-make.log"
1232
    make all install > $SIM_VER-make.log 2>&1
1233 72 julius
 
1234 22 ocadmin
## Make sure that built ok ##
1235
    check_exit_code
1236 72 julius
 
1237
## Setup symbolic link from or1ksim-x.y.z to simply or1ksim
1238
 
1239
    echo "Symbolically linking $INSTALL_DIR/$SIM_VER to $INSTALL_DIR/or1ksim"
1240
    if [ -e $INSTALL_DIR/or1ksim ]; then
1241
        echo "Symlink $INSTALL_DIR/or1ksim already exists. Updating to this version"
1242
        unlink $INSTALL_DIR/or1ksim;
1243
        check_exit_code
1244
    fi
1245
    echo "ln -s $INSTALL_DIR/$SIM_VER $INSTALL_DIR/or1ksim"
1246
    ln -s $INSTALL_DIR/$SIM_VER $INSTALL_DIR/or1ksim
1247 74 julius
 
1248 22 ocadmin
    cd $BUILD_TOP
1249
fi
1250
##########################Finish Simulator build#########################
1251
 
1252
 
1253
##########################Code Test###############################
1254
cd $BUILD_TOP
1255
echo "Launch the simulator with the newly compiled Linux image and BusyBox apps?"
1256
echo "[y/N]:"
1257
read SI
1258
 
1259
if [ -z $SI ]
1260 74 julius
then
1261 22 ocadmin
    SVAL="n" ## Default is no ##
1262
else
1263
    SVAL=$(echo $SI | tr [:upper:] [:lower:])
1264
fi
1265
 
1266
if [ $SVAL = "y" ];then
1267
 
1268
    ## Check for X's xterm, if we find it, and a valid $DISPLAY variable, we'll open the simulator with an xterm tty ##
1269
    which xterm
1270
 
1271
 
1272
    if [ $? -eq 0 ]
1273 74 julius
    then
1274 22 ocadmin
        # Xterm exists, check if the $DISPLAY variable is set
1275
        # Get the display variable
1276
        DISPLAY=`printenv DISPLAY`
1277
        echo "DISPLAY variable is set to $DISPLAY"
1278
        if [ -n $DISPLAY ]
1279 74 julius
        then
1280 22 ocadmin
            ## It appears display is set, let's set the or1ksim_linux.cfg file to use an xterm instead of telnet ##
1281
            cd $LINUX_VER
1282
            ## Rename the original script, adding .orig to the end ##
1283
            mv or1ksim_linux.cfg or1ksim_linux.cfg.orig
1284
            ## Now use sed to comment the line specifiying a telnet tty and uncomment the xterm line, restoring the original script ##
1285
            sed 's/channel\ \=\ \"tcp\:10084\"/\/\*\ channel\ \=\ \"tcp\:10084\"\ \*\//' or1ksim_linux.cfg.orig | sed 's/\/\*\ channel\ \=\ \"xterm\:\"\ \*\//\ channel\ \=\ \"xterm\:\"\ /' > or1ksim_linux.cfg
1286
            echo "########################## or1ksim ###############################"
1287
            echo
1288
            echo "or1ksim will open an xterm for console output as Linux is booting."
1289
            echo
1290
            echo "########################## or1ksim ###############################"
1291
            cd $BUILD_TOP
1292
        fi
1293
 
1294
    else
1295
        echo "########################## or1ksim ###############################"
1296
        echo
1297
        echo "     To connect to the simulator run: telnet 127.0.0.1 10084"
1298
        echo
1299
        echo "########################## or1ksim ###############################"
1300
 
1301
    fi
1302
 
1303
 
1304
    cd $BUILD_TOP/$LINUX_VER
1305 72 julius
    $INSTALL_DIR/or1ksim/bin/$TARGET-sim -f or1ksim_linux.cfg vmlinux
1306 22 ocadmin
 
1307
else
1308
    ## User didn't run the sim, but tell them how to anyway ##
1309
    echo "The compiled linux image is found in $BUILD_TOP/$LINUX_VER/vmlinux"
1310
    echo "To run it in the simulator, cd to $BUILD_TOP/$LINUX_VER"
1311
    echo "and run:"
1312
    echo "$TARGET-sim -f or1ksim_linux.cfg vmlinux"
1313
    echo
1314
 
1315
fi
1316
 
1317
echo
1318
echo "OpenRISC toolchain and architectural simulator build is complete!"
1319
echo
1320
echo "Your tools are installed in: $INSTALL_DIR/$TARGET"
1321 72 julius
echo "or1ksim has been installed in: $INSTALL_DIR/$SIM_VER"
1322 22 ocadmin
echo
1323 72 julius
echo "Please add the paths:"
1324
echo "\t$INSTALL_DIR/$TARGET/bin"
1325
echo "\t$INSTALL_DIR/or1ksim/bin"
1326
echo "to your PATH variable, for example, in most systems add the line"
1327
echo "below to your ~/.bashrc file:"
1328 22 ocadmin
echo
1329 72 julius
echo "\texport PATH=\$PATH:$INSTALL_DIR/$TARGET/bin:$INSTALL_DIR/or1ksim/bin"
1330
echo
1331
echo "For further support please visit the OpenRISC forum at OpenCores"
1332
echo "http://opencores.org/forum,OpenRISC"
1333
echo
1334 22 ocadmin
exit 0
1335
 
1336
##########################End Script##############################

powered by: WebSVN 2.1.0

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