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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [toolchain_script/] [MOF_ORSOC_TCHN_v5b_or32-elf.sh] - Blame information for rev 1776

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

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

powered by: WebSVN 2.1.0

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