OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

powered by: WebSVN 2.1.0

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