OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [bld-all.sh] - Blame information for rev 448

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

Line No. Rev Author Line
1 404 jeremybenn
#!/bin/bash
2
 
3
# Copyright (C) 2009, 2010 Embecosm Limited
4
# Copyright (C) 2010 ORSoC AB
5
 
6
# Contributor Joern Rennecke <joern.rennecke@embecosm.com>
7
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
# Contributor Julius Baxter <julius.baxter@orsoc.se>
9
 
10
# This file is a script to build key elements of the OpenRISC tool chain
11
 
12
# This program is free software; you can redistribute it and/or modify it
13
# under the terms of the GNU General Public License as published by the Free
14
# Software Foundation; either version 3 of the License, or (at your option)
15
# any later version.
16
 
17
# This program is distributed in the hope that it will be useful, but WITHOUT
18
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
20
# more details.
21
 
22
# You should have received a copy of the GNU General Public License along
23
# with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 
25
# ------------------------------------------------------------------------------
26
# This script builds two GNU C/C++ tool chains:
27
 
28
# 1. With target or32-elf (fully or32-unknown-elf-newlib) for use on bare
29
#    metal targets
30
 
31
# 2. With target or32-linux (fully or32-unknown-linux-uclibc) for use with
32
#    OpenRISC linux.
33
 
34
# In both cases the binutils, gcc and C/C++ libraries are built using a
35
# unified source directory created by linking the top level directories from
36
# binutils and gcc. For the first tool chain, newlib and libgloss are also
37
# linked into the unified source directory.
38
 
39
# GDB 7.2 does not have fully compatible binutils directories, so is built
40
# separately.
41
 
42
# For the or32-linux tool chain, the system headers are needed to bootstrap
43
# the building of libgcc. This is achieved by a 2 stage process
44
 
45
# 1. Configure, build and install gcc for C only for or32-linux using the host
46
#    system's headers, installing into a temporary prefix.
47
 
48
# 2. Clean the gcc build directory and reconfigure, build and install gcc for
49
#    C and C++ using the headers from the temporary prefix.
50
 
51
# Once this is complete, the Linux headers are installed and uClibc can be
52
# built.
53
 
54
# The following arguments control how the script runs:
55
 
56
# --force
57 422 jeremybenn
#     Ensure the unified source directory and build directories are
58
#     recreated. Only build directories of targets being built are removed.
59 404 jeremybenn
 
60 427 jeremybenn
# --languages <str>
61
#     Specify the languages to be built (default c,c++).
62
 
63 404 jeremybenn
# --prefix <dir>
64
#     Specify the install directory (default /opt/or32-new)
65
 
66
# --prefix-tmp <dir>
67
#     Specify the temporary install directory (default /tmp/or32-tmp-${USER}).
68
#     Incorporating the user name avoid name clashes with other users
69
 
70
# --unisrc-dir <dir>
71
#     Specify the unified source directory (default unisrc)
72
 
73
# --build-dir-elf <dir>
74
#     Specify the build directory for the newlib (or32-elf) tool chain
75
#     (default bd-elf).
76
 
77
# --build-dir-elf-gdb <dir>
78
#     Specify the build directory for the newlib (or32-elf) GDB (default
79
#     bd-elf-gdb).
80
 
81
# --build-dir-linux <dir>
82
#     Specify the build directory for the uClibc (or32-linux) tool chain
83
#     (default bd-linux)
84
 
85
# --build-dir-linux-gdb <dir>
86
#     Specify the build directory for the uClibc (or32-linux) GDB (default
87
#     bd-linux-gdb)
88
 
89
# --or1ksim-dir <dir>
90
#     Specify the Or1ksim installation directory. Used by GDB, which links in
91
#     the Or1ksim simulator (default /opt/or1ksim-new)
92
 
93
# --binutils-dir
94
#     Source directory for binutils (default binutils-2.20.1)
95
 
96
# --gcc-dir
97
#     Source directory for gcc (default gcc-4.5.1')
98
 
99
# --newlib-dir
100
#     Source directory for newlib (default newlib-1.18.0)
101
 
102 421 julius
# --uclibc-dir
103 404 jeremybenn
#     Source directory for uClibc (default uclibc-0.9.31)
104
 
105 421 julius
# --gdb-dir
106 404 jeremybenn
#     Source directory for gdb (default  gdb-7.2)
107
 
108 421 julius
# --linux-dir
109 404 jeremybenn
#     Source directory for Linux (default linux-2.6.35)
110
 
111
# --no-or32-elf
112
#     Don't configure, build and install the newlib (or32-elf) tool chain.
113
 
114
# --no-or32-linux
115
#     Don't configure, build and install the uClibc (or32-linux) tool chain.
116
 
117
# --nolink
118
#     Don't build the unified source directory (default is to build it)
119
 
120
# --noconfig
121
#     Don't run configure. Note that this will break the two stage build of
122
#     gcc for Linux, so it should only be used if at least one of the uClibc
123
#     stages is being omitted (default is to configure)
124
 
125
# --nobuild
126
#     Don't build any tools. Useful just to reinstall stuff (default is to
127
#     build).
128
 
129
# --check
130
#     Run DejaGnu tests using the or32-elf tool chain (default do not run).
131
 
132
# --noinstall
133
#     Don't run install. Beware that this will omit the installation of Linux
134
#     headers, required for uClibc building and the installation of headers
135
#     from stage1 of gcc for Linux, required for stage2 of gcc for Linux. So
136
#     only use if at least one of the uClibc stages is being omitted (default
137
#     is to install).
138
 
139
# --no-newlib
140
#     Don't build newlib (default is to build newlib)
141
 
142
# --no-uclibc
143
#     Don't build uClibc (default is to build uClibc)
144
 
145
# --no-uclibc-stage1
146
#     Don't do the stage1 build of gcc for Linux (default is to build stage1).
147
 
148
# --no-uclibc-stage2
149
#     Don't do the stage2 build of gcc for Linux (default is to build stage2).
150
 
151
# --help
152
#     List these options and exit
153
 
154
# In general global variables track each of these options. In addition the
155
# following global variables are used:
156
 
157
# target - the current target (or32-elf or or32-linux).
158
 
159
 
160
# ------------------------------------------------------------------------------
161
# Set the default values of all parameters
162
function set_defaults {
163
    # Public params
164
    force_flag="false"
165 427 jeremybenn
    languages="c,c++"
166 404 jeremybenn
    prefix="/opt/or32-new"
167
    prefix_tmp="/tmp/or32-tmp-${USER}"
168
    unisrc_dir="unisrc"
169
    bd_elf="bd-elf"
170
    bd_elf_gdb="bd-elf-gdb"
171
    bd_linux="bd-linux"
172
    bd_linux_gdb="bd-linux-gdb"
173
    or1ksim_dir="/opt/or1ksim-new"
174
    binutils_dir="binutils-2.20.1"
175
    gcc_dir="gcc-4.5.1"
176
    newlib_dir="newlib-1.18.0"
177
    uclibc_dir="uclibc-0.9.31"
178
    gdb_dir="gdb-7.2"
179 427 jeremybenn
    linux_dir="linux-2.6.36"
180 404 jeremybenn
    or32_elf_flag="true"
181
    or32_linux_flag="true"
182
    link_flag="true"
183
    config_flag="true"
184
    build_flag="true"
185
    check_flag="false"
186
    install_flag="true"
187
    newlib_flag="true"
188
    uclibc_flag="true"
189
    uclibc_stage1_flag="true"
190
    uclibc_stage2_flag="true"
191
 
192
    # Consequential params
193
    newlib_config="--with-newlib"
194
    newlib_build="all-target-newlib all-target-libgloss"
195
    newlib_check="check-target-newlib check-target-libgloss"
196
    newlib_install="install-target-newlib install-target-libgloss"
197
 
198
    # Determine how many processes to use in parallel building. If
199
    # /proc/cpuinfo is avaliable, limit load to launch extra jobs to number of
200
    # processors + 1. If /proc/cpuinfo is not available, we use a constant of
201
    # 2.
202
    make_n_jobs=`(echo processor;cat /proc/cpuinfo 2>/dev/null || \
203
        echo processor) | grep -c processor`
204
    make_load="-j $make_n_jobs -l $make_n_jobs"
205
    unset make_n_jobs
206
 
207
}       # set_defaults ()
208
 
209
 
210
# ------------------------------------------------------------------------------
211
# Parse the arguments
212
function parse_args {
213
    until
214
    opt=$1
215
    case ${opt}
216
        in
217
        --force)
218
            force_flag="true";
219
            ;;
220
 
221 427 jeremybenn
        --languages)
222
            languages=$2;
223
            shift;
224
            ;;
225
 
226 404 jeremybenn
        --prefix)
227
            prefix=$2;
228
            shift;
229
            ;;
230
 
231
        --prefix-tmp)
232
            prefix_tmp=$2;
233
            shift;
234
            ;;
235
 
236
        --unisrc_dir)
237
            unisrc_dir=$2;
238
            shift;
239
            ;;
240
 
241
        --bd-elf)
242
            bd_elf=$2;
243
            shift;
244
            ;;
245
 
246
        --bd-elf-gdb)
247
            bd_elf_gdb=$2;
248
            shift;
249
            ;;
250
 
251
        --bd-linux)
252
            bd_linux=$2;
253
            shift;
254
            ;;
255
 
256
        --bd-linux-gdb)
257
            bd_linux_gdb=$2;
258
            shift;
259
            ;;
260
 
261
        --or1ksim-dir)
262
            or1ksim_dir=$2;
263
            shift;
264
            ;;
265
 
266
        --binutils-dir)
267
            binutils_dir=$2;
268
            shift;
269
            ;;
270
 
271
        --gcc-dir)
272
            gcc_dir=$2;
273
            shift;
274
            ;;
275
 
276
        --newlib-dir)
277
            newlib_dir=$2;
278
            shift;
279
            ;;
280
 
281
        --uclibc-dir)
282
            uclibc_dir=$2;
283
            shift;
284
            ;;
285
 
286
        --gdb-dir)
287
            gdb_dir=$2;
288
            shift;
289
            ;;
290
 
291
        --linux-dir)
292
            linux_dir=$2;
293
            shift;
294
            ;;
295
 
296
        --no-or32-elf)
297
            or32_elf_flag="false"
298
            ;;
299
 
300
        --no-or32-linux)
301
            or32_linux_flag="false"
302
            ;;
303
 
304
        --nolink)
305
            link_flag="false";
306
            ;;
307
 
308
        --noconfig)
309
            config_flag="false";
310
            ;;
311
 
312
        --nobuild)
313
            build_flag="false";
314
            ;;
315
 
316
        --check)
317
            check_flag="true";
318
            ;;
319
 
320
        --noinstall)
321
            install_flag="false";
322
            ;;
323
 
324
        --no-newlib)
325
            newlib_flag="false";
326
 
327
            newlib_config="";
328
            newlib_build="";
329
            newlib_check="";
330
            newlib_install="";
331
            ;;
332
 
333
        --no-uclibc)
334
            uclibc_flag="false";
335
            ;;
336
 
337
        --no-uclibc-stage1)
338
            uclibc_stage1_flag="false";
339
            ;;
340
 
341
        --no-uclibc-stage2)
342
            uclibc_stage2_flag="false";
343
            ;;
344
 
345
        --help)
346
            cat <<EOF;
347
--force
348 422 jeremybenn
    Ensure the unified source directory and build directories are
349
    recreated. Only build directories of targets being built are removed.
350 404 jeremybenn
 
351 427 jeremybenn
--languages <str>
352
    Specify the languages to be built (default c,c++).
353
 
354 404 jeremybenn
--prefix <dir>
355
    Specify the install directory (default /opt/or32-new)
356
 
357
--prefix-tmp <dir>
358
    Specify the temporary install directory (default /tmp/or32-tmp-${USER}).
359
    Incorporating the user name avoid name clashes with other users
360
 
361
--unisrc-dir <dir>
362
    Specify the unified source directory (default unisrc)
363
 
364
--build-dir-elf <dir>
365
    Specify the build directory for the newlib (or32-elf) tool chain
366
    (default bd-elf).
367
 
368
--build-dir-elf-gdb <dir>
369
    Specify the build directory for the newlib (or32-elf) GDB (default
370
    bd-elf-gdb).
371
 
372
--build-dir-linux <dir>
373
    Specify the build directory for the uClibc (or32-linux) tool chain
374
    (default bd-linux)
375
 
376
--build-dir-linux-gdb <dir>
377
    Specify the build directory for the uClibc (or32-linux) GDB (default
378
    bd-linux-gdb)
379
 
380
--or1ksim-dir <dir>
381
    Specify the Or1ksim installation directory. Used by GDB, which links in
382
    the Or1ksim simulator (default /opt/or1ksim-new)
383
 
384
--binutils-dir
385
    Source directory for binutils (default binutils-2.20.1)
386
 
387
--gcc-dir
388
    Source directory for gcc (default gcc-4.5.1')
389
 
390
--newlib-dir
391
    Source directory for newlib (default newlib-1.18.0)
392
 
393
--uclibc_dir
394
    Source directory for uClibc (default uclibc-0.9.31)
395
 
396
--gdb_dir
397
    Source directory for gdb (default  gdb-7.2)
398
 
399
--linux_dir
400
    Source directory for Linux (default linux-2.6.35)
401
 
402
--no-or32-elf
403
    Don't configure, build and install the newlib (or32-elf) tool chain.
404
 
405
--no-or32-linux
406
    Don't configure, build and install the uClibc (or32-linux) tool chain.
407
 
408
--nolink
409
    Don't build the unified source directory (default is to build it)
410
 
411
--noconfig
412
    Don't run configure. Note that this will break the two stage build of
413
    gcc for Linux, so it should only be used if at least one of the uClibc
414
    stages is being omitted (default is to configure)
415
 
416
--nobuild
417
    Don't build any tools. Useful just to reinstall stuff (default is to
418
    build).
419
 
420
--check
421
    Run DejaGnu tests using the or32-elf tool chain (default do not run).
422
 
423
--noinstall
424
    Don't run install. Beware that this will omit the installation of Linux
425
    headers, required for uClibc building and the installation of headers
426
    from stage1 of gcc for Linux, required for stage2 of gcc for Linux. So
427
    only use if at least one of the uClibc stages is being omitted (default
428
    is to install).
429
 
430
--no-newlib
431
    Don't build newlib (default is to build newlib)
432
 
433
--no-uclibc
434
    Don't build uClibc (default is to build uClibc)
435
 
436
--no-uclibc-stage1
437
    Don't do the stage1 build of gcc for Linux (default is to build stage1).
438
 
439
--no-uclibc-stage2
440
    Don't do the stage2 build of gcc for Linux (default is to build stage2).
441
 
442
--help
443
    List these options and exit
444
EOF
445
            exit 0
446
            ;;
447
 
448
        --*)
449
            echo "unrecognized option \"$1\""
450
            exit 1
451
            ;;
452
 
453
        *)
454
            opt=""
455
            ;;
456
    esac;
457
    [ -z "${opt}" ]
458
    do
459
        shift
460
    done
461
 
462
}       # parse_args
463
 
464
 
465
# ------------------------------------------------------------------------------
466
# Sanity check argument values
467
function sanity_check {
468
    # Check unified source directory is meaningful if we are linking and that
469
    # we can create it.
470
    if [ "true" == "${link_flag}" ]
471
    then
472
        # Is it meaninful
473
        case ${unisrc_dir}
474
            in
475
            "")
476
                unisrc_prefix='.'
477
                ;;
478
 
479
            */*)
480
                echo "/ in unified source directory not implemented"
481
                exit 1
482
                ;;
483
 
484
            *..*)
485
                echo ".. in unified source directory not implemented"
486
                exit 1
487
                ;;
488
            *)
489
                unisrc_prefix='..'
490
                ;;
491
        esac
492
 
493
        # Check it's a directory, and if it doesn't exist that we can create
494
        # it.
495
        if [ -n "${unisrc_dir}" ]
496
        then
497
            if [ ! -d ${unisrc_dir} ]
498
            then
499
                if [ -e ${unisrc_dir} ]
500
                then
501
                    echo "${unisrc_dir} is not a directory";
502
                    exit 1
503
                fi
504
 
505
                mkdir ${unisrc_dir}
506
            fi
507
        fi
508
    fi
509
}       # sanity_check
510
 
511
 
512
# ------------------------------------------------------------------------------
513
# Conditionally build the unified source directory. We know by now it's a
514
# viable and extant directory.
515
function link_unified {
516
    if [ "true" == "${link_flag}" ]
517
    then
518
        mkdir -p ${unisrc_dir}
519
        cd ${unisrc_dir}
520
        ignore_list=". .. CVS .svn"
521
        component_dirs="${binutils_dir} ${gcc_dir} ${newlib_dir}"
522
 
523
        for srcdir in ${component_dirs}
524
        do
525
            echo "Component: $srcdir"
526
            case srcdir
527
                in
528
                /* | [A-Za-z]:[\\/]*)
529
                    ;;
530
 
531
                *)
532
                    srcdir="${unisrc_prefix}/${srcdir}"
533
                    ;;
534
            esac
535
 
536
            files=`ls -a ${srcdir}`
537
 
538
            for f in ${files}
539
            do
540
                found=
541
 
542
                for i in ${ignore_list}
543
                do
544
                    if [ "$f" = "$i" ]
545
                    then
546
                        found=yes
547
                    fi
548
                done
549
 
550
                if [ -z "${found}" ]
551
                then
552
                    echo "$f            ..linked"
553
                    ln -s ${srcdir}/$f .
554
                fi
555
            done
556
 
557
            ignore_list="${ignore_list} ${files}"
558
        done
559
 
560
        if [ $? != 0 ]
561
        then
562
            echo "failed to create ${unisrc_dir}"
563
            exit 1
564
        fi
565
 
566
        unset component_dirs
567
        unset ignore_list
568 421 julius
        cd -
569 404 jeremybenn
    fi
570
}       # link_unified
571
 
572
 
573
# ------------------------------------------------------------------------------
574
# Conditionally configure a GNU source directory (could be the unified
575
# directory, or GDB)
576
 
577
# @param[in] $1       "true" if we should execute this function
578
# @param[in] $2       The prefix to use for installation.
579
# @param[in] $3       The build directory to configure in.
580
# @param[in] $4       The source directory containing configure (relative to $1)
581
# @param[in] $5       The languages to configure for.
582
# @param[in] $6, ...  Additional configure args.
583
function gnu_config {
584
    cond=$1
585
    shift
586
 
587
    if [ "true" == ${cond} ]
588
    then
589
        this_prefix=$1
590
        shift
591
        top_builddir=$1
592
        shift
593
        top_srcdir=$1
594
        shift
595
        langs=$1
596
        shift
597
 
598
        echo "bld-all.sh: gnu_config ${top_builddir} ${top_srcdir} ${langs} $*"
599
 
600
        verstr="OpenRISC 32-bit toolchain for ${target} (built `date +%Y%m%d`)"
601
 
602
        mkdir -p ${top_builddir} &&                                   \
603
            cd ${top_builddir} &&                                     \
604
            ${top_srcdir}/configure --target=${target}                \
605 427 jeremybenn
                --with-pkgversion="${verstr}" --disable-shared        \
606 404 jeremybenn
                --with-bugurl=http://www.opencores.org/               \
607
                --with-or1ksim=${or1ksim_dir}                         \
608
                --enable-fast-install=N/A --disable-libssp            \
609
                --enable-languages=${langs} --prefix=${this_prefix} $*
610
 
611
        if [ $? != 0 ]
612
        then
613
            echo "configure failed."
614
            exit 1
615
        fi
616
 
617 421 julius
        cd -
618 404 jeremybenn
 
619
        unset verstr
620
        unset langs
621
        unset top_srcdir
622
        unset top_builddir
623
        unset this_prefix
624
    fi
625
 
626
    unset cond
627
 
628
}       # gnu_config
629
 
630
 
631
# ------------------------------------------------------------------------------
632
# Conditionally run make and check the result.
633
 
634
# @param[in] $1       "true" if we should execute this function
635
# @param[in] $2      The build directory to make in
636
# @param[in] $3, ... The targets to make
637
function gnu_make {
638
    cond=$1
639
    shift
640
 
641
    if [ "true" == ${cond} ]
642
    then
643
        echo "bld-all.sh: gnu_make $*"
644
 
645
        cd $1
646
        shift
647
 
648
        make $make_load $*
649
 
650
        if [ $? != 0 ]
651
        then
652
            echo "make ($*) failed."
653
            exit 1
654
        fi
655
 
656 421 julius
        cd -
657 404 jeremybenn
    fi
658
 
659
    unset cond
660
 
661
}       # gnu_make
662
 
663
 
664
# ------------------------------------------------------------------------------
665
# Conditionally relocate the newlib headers and libraries.
666
function relocate_newlib {
667
    if [ "true" == "${newlib_flag}" ]
668
    then
669 438 jeremybenn
        echo "bld-all.sh: Relocating newlib (no-op)"
670 404 jeremybenn
    fi
671
}       # relocate_newlib
672
 
673
 
674
# ------------------------------------------------------------------------------
675
# Conditionally configure and install the Linux headers
676
 
677
# @param[in] $1       The prefix to use for installation.
678
function install_linux_headers {
679
    this_prefix=$1
680
 
681
    cd $linux_dir
682
 
683
    if [ "true" == "${config_flag}" ]
684
    then
685
        echo "bld-all.sh: Configuring Linux headers"
686
 
687 448 jeremybenn
        make ARCH=openrisc defconfig
688 404 jeremybenn
 
689
        if [ $? != 0 ];
690
        then
691
            echo "Linux configure failed"
692
            exit 1
693
        fi
694
    fi
695
 
696
    # This is a bit iffy. We do rely on the headers being installed for uClibc
697
    # to build, so not installing the first time would be a bit dodgy.
698
    if [ "true" == "${install_flag}" ]
699
    then
700
        echo "bld-all.sh: Installing Linux headers"
701
 
702
        make INSTALL_HDR_PATH=${this_prefix}/or32-linux headers_install
703
 
704
        if [ $? != 0 ];
705
        then
706
            echo "Linux header installation failed"
707
            exit 1
708
        fi
709
 
710
        unset this_prefix
711
    fi
712
 
713 421 julius
    cd -
714 404 jeremybenn
 
715
}       # install_linux_headers
716
 
717
 
718
# ------------------------------------------------------------------------------
719 427 jeremybenn
# Conditionally configure uClibc. Clean before configuring.
720 404 jeremybenn
 
721
# @param[in] $1       The prefix to use for installation.
722
function uclibc_config {
723
 
724
    if [ "true" == "${config_flag}" ]
725
    then
726
        this_prefix=$1
727
        echo "bld-all.sh: Configuring uClibc"
728
 
729
        cd ${uclibc_dir}
730
 
731
        kheaders="KERNEL_HEADERS=\\\"${this_prefix}\\/or32-linux\\/include\\\""
732
        devprefix="DEVEL_PREFIX=\\\"${this_prefix}\\/or32-linux\\\""
733
        ccprefix="CROSS_COMPILER_PREFIX=\\\"or32-linux-\\\""
734
 
735
        sed -i extra/Configs/defconfigs/or32     \
736
            -e "s|KERNEL_HEADERS.*|${kheaders}|g"  \
737
            -e "s|DEVEL_PREFIX.*|${devprefix}|g" \
738
            -e "s|CROSS_COMPILER_PREFIX.*|${ccprefix}|g"
739
 
740
        if [ $? != 0 ];
741
        then
742
            echo "uClibc sed failed"
743
            exit 1
744
        fi
745
 
746 427 jeremybenn
        make ARCH=or32 clean
747
 
748
        if [ $? != 0 ];
749
        then
750
            echo "uClibc clean failed"
751
            exit 1
752
        fi
753
 
754 404 jeremybenn
        make ARCH=or32 defconfig
755
 
756
        if [ $? != 0 ];
757
        then
758
            echo "uClibc configure failed"
759
            exit 1
760
        fi
761
 
762
        unset this_prefix
763
        unset ccprefix
764
        unset devprefix
765
        unset kheaders
766
 
767 421 julius
        cd -
768 404 jeremybenn
    fi
769
}       # uclibc_config
770
 
771
 
772
# ------------------------------------------------------------------------------
773
# Conditionally build and install uClibc
774
function uclibc_build_install {
775
    cd ${uclibc_dir}
776
 
777
    if [ "true" == "${build_flag}" ]
778
    then
779
        echo "bld-all.sh: Building uClibc"
780
 
781
        make ARCH=or32 all
782
 
783
        if [ $? != 0 ];
784
        then
785
            echo "uClibc build failed"
786
            exit 1
787
        fi
788
    fi
789
 
790
    if [ "true" == "${install_flag}" ]
791
    then
792
        echo "bld-all.sh: Installing uClibc"
793
 
794
        make ARCH=or32 install
795
 
796
        if [ $? != 0 ];
797
        then
798
            echo "uClibc install failed"
799
            exit 1
800
        fi
801
    fi
802
 
803 421 julius
    cd -
804 404 jeremybenn
 
805
}       # uclibc_build_install
806
 
807
 
808
# ------------------------------------------------------------------------------
809
# Main program
810
set_defaults
811
parse_args $*
812
sanity_check
813
 
814 422 jeremybenn
# --force always blows away the link directory. It only blows away build
815
# directories we are actually building (see below).
816 404 jeremybenn
if [ "true" == "${force_flag}" ]
817
then
818 423 jeremybenn
    echo -n "bld-all.sh: removing ${unisrc_dir}"
819 422 jeremybenn
    rm -rf ${unisrc_dir}
820 404 jeremybenn
fi
821
 
822
link_unified
823
 
824
# Build the newlib (or32-elf) tool chain.
825
if [ "true" == "${or32_elf_flag}" ]
826
then
827
    target="or32-elf"
828
    echo "bld-all.sh: or32-elf toolchain"
829
 
830 422 jeremybenn
    # --force only applies to build directories we are using!
831
    if [ "true" == "${force_flag}" ]
832
    then
833
        echo -n "bld-all.sh: removing ${bd_elf} ${bd_elf_gdb} "
834
        rm -rf ${bd_elf} ${bd_elf_gdb}
835
    fi
836
 
837 404 jeremybenn
    # Configure all
838 427 jeremybenn
    gnu_config ${config_flag} ${prefix} ${bd_elf} ../${unisrc_dir} \
839
        "${languages}" "${newlib_config}"
840
    gnu_config ${config_flag} ${prefix} ${bd_elf_gdb} ../${gdb_dir} \
841
        "${languages}"
842 404 jeremybenn
 
843
    # Build all
844
    gnu_make ${build_flag} ${bd_elf} all-build all-binutils all-gas all-ld
845
    gnu_make ${build_flag} ${bd_elf} all-gcc
846
    gnu_make ${build_flag} ${bd_elf} all-target-libgcc all-target-libstdc++-v3 \
847
        ${newlib_build}
848
    gnu_make ${build_flag} ${bd_elf_gdb} all-build all-sim all-gdb
849
 
850
    # Check all
851
    gnu_make ${check_flag} ${bd_elf} check-binutils check-gas check-ld \
852
        check-gcc check-target-libgcc check-target-libstdc++-v3 ${newlib_check}
853
    gnu_make ${check_flag} ${bd_elf_gdb} check-sim check-gdb
854
 
855
    # Install all
856
    gnu_make ${install_flag} ${bd_elf} install-binutils install-gas install-ld \
857
        install-gcc install-target-libgcc install-target-libstdc++-v3 \
858
        ${newlib_install}
859
    gnu_make ${install_flag} ${bd_elf_gdb} install-sim install-gdb
860
    relocate_newlib
861
fi
862
 
863
# Build the uClibc (or32-linux) tool chain
864
if [ "true" == "${or32_linux_flag}" ]
865
then
866
    target="or32-linux"
867
    echo "bld-all.sh: or32-linux toolchain"
868
 
869 422 jeremybenn
    # --force only applies to build directories we are using!
870
    if [ "true" == "${force_flag}" ]
871
    then
872
        echo -n "bld-all.sh: removing ${bd_linux} ${bd_linux_gdb} "
873
        rm -rf ${bd_linux} ${bd_linux_gdb}
874
    fi
875
 
876 404 jeremybenn
    # Stage 1 binutils/GCC build uses no headers and only C
877
    # language. This is just to create the libc headers, which we put in the
878
    # temporary prefix directory.
879
    if [ "true" == "${uclibc_stage1_flag}" ]
880
    then
881
        echo "bld-all.sh: uClibc GCC stage 1"
882
 
883
        # Make a clean temporary install directory.
884
        rm -rf ${prefix_tmp}
885
        mkdir ${prefix_tmp}
886
 
887 427 jeremybenn
        # To create the headers we only use C
888 404 jeremybenn
        gnu_config ${config_flag} ${prefix_tmp} ${bd_linux} ../${unisrc_dir} \
889
            "c" "--without-headers --enable-threads=single"
890
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
891
        gnu_make ${build_flag} ${bd_linux} all-gcc
892
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
893
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
894
            install-ld
895
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
896
 
897
        # Create the headers using our temporary tool chain
898
        save_path="${PATH}"
899
        export PATH="${prefix_tmp}/bin:${PATH}"
900
        install_linux_headers ${prefix_tmp}
901
        uclibc_config ${prefix_tmp}
902
        uclibc_build_install
903
        PATH="${save_path}"
904
        unset save_path
905
    fi
906
 
907
    # If we are doing both stage 1 and stage 2, then we need to completely
908
    # clean gcc and target libraries. Just blow the entire directory away.
909
    if [ "truetrue" == "${uclibc_stage1_flag}${uclibc_stage2_flag}" ]
910
    then
911
        echo "bld-all.sh: uClibc GCC inter-stage cleaning"
912
        rm -rf ${bd_linux}/gcc ${bd_linux}/or32-linux
913
    fi
914
 
915
    # Stage 2 GCC uses the headers installed from stage 1.
916
    if [ "true" == "${uclibc_stage2_flag}" ]
917
    then
918
        echo "bld-all.sh: uClibc GCC stage 2"
919
 
920
        # FIXME: uclibc is supposed to provide thread support, but doesn't.
921
        thread_hack="--disable-threads --disable-libgomp"
922
 
923
        gnu_config ${config_flag} ${prefix} ${bd_linux} ../${unisrc_dir} \
924 427 jeremybenn
            "${languages}" \
925 404 jeremybenn
            "--with-headers=${prefix_tmp}/or32-linux/include $thread_hack"
926
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
927
        gnu_make ${build_flag} ${bd_linux} all-gcc
928
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
929
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
930
            install-ld
931
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
932
 
933
        unset thread_hack
934
 
935
        # We need to build uClibc before building the C++ libraries, which in
936
        # turn needs the Linux headers
937
        export PATH=${prefix}/bin:${PATH}
938
        install_linux_headers ${prefix}
939
        uclibc_config ${prefix}
940
        uclibc_build_install
941
 
942
        # Finish building the C++ library
943
        gnu_make ${build_flag} ${bd_linux} all-target-libstdc++-v3
944
        gnu_make ${install_flag} ${bd_linux} install-target-libstdc++-v3
945
    fi
946
 
947
    # Configure, build and install GDB (note we need to reconfigure in case
948
    # only stage1 has been run previously).
949 427 jeremybenn
    gnu_config ${config_flag} ${prefix} ${bd_linux_gdb} ../${gdb_dir} \
950
        "${languages}"
951 404 jeremybenn
    gnu_make ${build_flag} ${bd_linux_gdb} all-build all-sim all-gdb
952
    gnu_make ${install_flag} ${bd_linux_gdb} install-sim install-gdb
953
fi

powered by: WebSVN 2.1.0

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