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 424

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

powered by: WebSVN 2.1.0

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