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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [toolchain_script/] [MOF_ORSOC_TCHN_v5c_or32-elf.sh] - Blame information for rev 1778

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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