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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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