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 74

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

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

powered by: WebSVN 2.1.0

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