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 75

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

powered by: WebSVN 2.1.0

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