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 459

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

powered by: WebSVN 2.1.0

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