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 1777

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

powered by: WebSVN 2.1.0

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