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 43

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

powered by: WebSVN 2.1.0

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