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 59

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

powered by: WebSVN 2.1.0

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