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 45

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

powered by: WebSVN 2.1.0

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