OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

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

powered by: WebSVN 2.1.0

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