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 477

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 473 jeremybenn
        echo -n "bld-all.sh: gnu_config ${this_prefix} ${top_builddir} "
611
        echo    "${top_srcdir} ${langs} $*"
612 404 jeremybenn
 
613
        verstr="OpenRISC 32-bit toolchain for ${target} (built `date +%Y%m%d`)"
614
 
615
        mkdir -p ${top_builddir} &&                                   \
616
            cd ${top_builddir} &&                                     \
617
            ${top_srcdir}/configure --target=${target}                \
618 427 jeremybenn
                --with-pkgversion="${verstr}" --disable-shared        \
619 404 jeremybenn
                --with-bugurl=http://www.opencores.org/               \
620
                --with-or1ksim=${or1ksim_dir}                         \
621
                --enable-fast-install=N/A --disable-libssp            \
622
                --enable-languages=${langs} --prefix=${this_prefix} $*
623
 
624
        if [ $? != 0 ]
625
        then
626
            echo "configure failed."
627
            exit 1
628
        fi
629
 
630 421 julius
        cd -
631 404 jeremybenn
 
632
        unset verstr
633
        unset langs
634
        unset top_srcdir
635
        unset top_builddir
636
        unset this_prefix
637
    fi
638
 
639
    unset cond
640
 
641
}       # gnu_config
642
 
643
 
644
# ------------------------------------------------------------------------------
645
# Conditionally run make and check the result.
646
 
647
# @param[in] $1       "true" if we should execute this function
648
# @param[in] $2      The build directory to make in
649
# @param[in] $3, ... The targets to make
650
function gnu_make {
651
    cond=$1
652
    shift
653
 
654
    if [ "true" == ${cond} ]
655
    then
656
        echo "bld-all.sh: gnu_make $*"
657
 
658
        cd $1
659
        shift
660
 
661
        make $make_load $*
662
 
663
        if [ $? != 0 ]
664
        then
665
            echo "make ($*) failed."
666
            exit 1
667
        fi
668
 
669 421 julius
        cd -
670 404 jeremybenn
    fi
671
 
672
    unset cond
673
 
674
}       # gnu_make
675
 
676
 
677
# ------------------------------------------------------------------------------
678
# Conditionally configure and install the Linux headers
679
 
680
# @param[in] $1       The prefix to use for installation.
681
function install_linux_headers {
682
    this_prefix=$1
683
 
684
    cd $linux_dir
685
 
686
    if [ "true" == "${config_flag}" ]
687
    then
688
        echo "bld-all.sh: Configuring Linux headers"
689
 
690 448 jeremybenn
        make ARCH=openrisc defconfig
691 404 jeremybenn
 
692
        if [ $? != 0 ];
693
        then
694
            echo "Linux configure failed"
695
            exit 1
696
        fi
697
    fi
698
 
699
    # This is a bit iffy. We do rely on the headers being installed for uClibc
700
    # to build, so not installing the first time would be a bit dodgy.
701
    if [ "true" == "${install_flag}" ]
702
    then
703
        echo "bld-all.sh: Installing Linux headers"
704
 
705
        make INSTALL_HDR_PATH=${this_prefix}/or32-linux headers_install
706
 
707
        if [ $? != 0 ];
708
        then
709
            echo "Linux header installation failed"
710
            exit 1
711
        fi
712
 
713
        unset this_prefix
714
    fi
715
 
716 421 julius
    cd -
717 404 jeremybenn
 
718
}       # install_linux_headers
719
 
720
 
721
# ------------------------------------------------------------------------------
722 427 jeremybenn
# Conditionally configure uClibc. Clean before configuring.
723 404 jeremybenn
 
724
# @param[in] $1       The prefix to use for installation.
725
function uclibc_config {
726
 
727
    if [ "true" == "${config_flag}" ]
728
    then
729
        this_prefix=$1
730
        echo "bld-all.sh: Configuring uClibc"
731
 
732
        cd ${uclibc_dir}
733
 
734
        kheaders="KERNEL_HEADERS=\\\"${this_prefix}\\/or32-linux\\/include\\\""
735
        devprefix="DEVEL_PREFIX=\\\"${this_prefix}\\/or32-linux\\\""
736
        ccprefix="CROSS_COMPILER_PREFIX=\\\"or32-linux-\\\""
737
 
738
        sed -i extra/Configs/defconfigs/or32     \
739
            -e "s|KERNEL_HEADERS.*|${kheaders}|g"  \
740
            -e "s|DEVEL_PREFIX.*|${devprefix}|g" \
741
            -e "s|CROSS_COMPILER_PREFIX.*|${ccprefix}|g"
742
 
743
        if [ $? != 0 ];
744
        then
745
            echo "uClibc sed failed"
746
            exit 1
747
        fi
748
 
749 427 jeremybenn
        make ARCH=or32 clean
750
 
751
        if [ $? != 0 ];
752
        then
753
            echo "uClibc clean failed"
754
            exit 1
755
        fi
756
 
757 404 jeremybenn
        make ARCH=or32 defconfig
758
 
759
        if [ $? != 0 ];
760
        then
761
            echo "uClibc configure failed"
762
            exit 1
763
        fi
764
 
765
        unset this_prefix
766
        unset ccprefix
767
        unset devprefix
768
        unset kheaders
769
 
770 421 julius
        cd -
771 404 jeremybenn
    fi
772
}       # uclibc_config
773
 
774
 
775
# ------------------------------------------------------------------------------
776
# Conditionally build and install uClibc
777
function uclibc_build_install {
778
    cd ${uclibc_dir}
779
 
780
    if [ "true" == "${build_flag}" ]
781
    then
782
        echo "bld-all.sh: Building uClibc"
783
 
784
        make ARCH=or32 all
785
 
786
        if [ $? != 0 ];
787
        then
788
            echo "uClibc build failed"
789
            exit 1
790
        fi
791
    fi
792
 
793
    if [ "true" == "${install_flag}" ]
794
    then
795
        echo "bld-all.sh: Installing uClibc"
796
 
797
        make ARCH=or32 install
798
 
799
        if [ $? != 0 ];
800
        then
801
            echo "uClibc install failed"
802
            exit 1
803
        fi
804
    fi
805
 
806 421 julius
    cd -
807 404 jeremybenn
 
808
}       # uclibc_build_install
809
 
810
 
811
# ------------------------------------------------------------------------------
812
# Main program
813
set_defaults
814
parse_args $*
815
sanity_check
816
 
817 422 jeremybenn
# --force always blows away the link directory. It only blows away build
818
# directories we are actually building (see below).
819 404 jeremybenn
if [ "true" == "${force_flag}" ]
820
then
821 473 jeremybenn
    echo "bld-all.sh: removing ${unisrc_dir}"
822 422 jeremybenn
    rm -rf ${unisrc_dir}
823 404 jeremybenn
fi
824
 
825
link_unified
826
 
827
# Build the newlib (or32-elf) tool chain.
828
if [ "true" == "${or32_elf_flag}" ]
829
then
830
    target="or32-elf"
831
    echo "bld-all.sh: or32-elf toolchain"
832
 
833 422 jeremybenn
    # --force only applies to build directories we are using!
834
    if [ "true" == "${force_flag}" ]
835
    then
836 473 jeremybenn
        echo "bld-all.sh: removing ${bd_elf} ${bd_elf_gdb}"
837 422 jeremybenn
        rm -rf ${bd_elf} ${bd_elf_gdb}
838
    fi
839
 
840 404 jeremybenn
    # Configure all
841 427 jeremybenn
    gnu_config ${config_flag} ${prefix} ${bd_elf} ../${unisrc_dir} \
842
        "${languages}" "${newlib_config}"
843
    gnu_config ${config_flag} ${prefix} ${bd_elf_gdb} ../${gdb_dir} \
844
        "${languages}"
845 404 jeremybenn
 
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
fi
864
 
865
# Build the uClibc (or32-linux) tool chain
866
if [ "true" == "${or32_linux_flag}" ]
867
then
868
    target="or32-linux"
869
    echo "bld-all.sh: or32-linux toolchain"
870
 
871 422 jeremybenn
    # --force only applies to build directories we are using!
872
    if [ "true" == "${force_flag}" ]
873
    then
874 473 jeremybenn
        echo "bld-all.sh: removing ${bd_linux} ${bd_linux_gdb}"
875 422 jeremybenn
        rm -rf ${bd_linux} ${bd_linux_gdb}
876
    fi
877
 
878 404 jeremybenn
    # Stage 1 binutils/GCC build uses no headers and only C
879
    # language. This is just to create the libc headers, which we put in the
880
    # temporary prefix directory.
881
    if [ "true" == "${uclibc_stage1_flag}" ]
882
    then
883
        echo "bld-all.sh: uClibc GCC stage 1"
884
 
885
        # Make a clean temporary install directory.
886
        rm -rf ${prefix_tmp}
887
        mkdir ${prefix_tmp}
888
 
889 454 jeremybenn
        # For header building we use just single threads, or we don't find
890
        # pthread.h.
891
        thread_config="--enable-threads=single --disable-tls"
892
 
893 427 jeremybenn
        # To create the headers we only use C
894 404 jeremybenn
        gnu_config ${config_flag} ${prefix_tmp} ${bd_linux} ../${unisrc_dir} \
895 454 jeremybenn
            "c" "--without-headers ${thread_config}"
896 404 jeremybenn
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
897
        gnu_make ${build_flag} ${bd_linux} all-gcc
898
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
899
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
900
            install-ld
901
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
902
 
903
        # Create the headers using our temporary tool chain
904
        save_path="${PATH}"
905
        export PATH="${prefix_tmp}/bin:${PATH}"
906
        install_linux_headers ${prefix_tmp}
907
        uclibc_config ${prefix_tmp}
908
        uclibc_build_install
909
        PATH="${save_path}"
910
        unset save_path
911
    fi
912
 
913
    # If we are doing both stage 1 and stage 2, then we need to completely
914
    # clean gcc and target libraries. Just blow the entire directory away.
915
    if [ "truetrue" == "${uclibc_stage1_flag}${uclibc_stage2_flag}" ]
916
    then
917
        echo "bld-all.sh: uClibc GCC inter-stage cleaning"
918
        rm -rf ${bd_linux}/gcc ${bd_linux}/or32-linux
919
    fi
920
 
921
    # Stage 2 GCC uses the headers installed from stage 1.
922
    if [ "true" == "${uclibc_stage2_flag}" ]
923
    then
924
        echo "bld-all.sh: uClibc GCC stage 2"
925
 
926 473 jeremybenn
        # uClibc now supports POSIX threads, but not TLS. uClibc
927
        # linuxthreads.old is a POSIX98 compliant implementation.
928 454 jeremybenn
        thread_config="--enable-threads=posix --disable-tls"
929 404 jeremybenn
 
930
        gnu_config ${config_flag} ${prefix} ${bd_linux} ../${unisrc_dir} \
931 427 jeremybenn
            "${languages}" \
932 454 jeremybenn
            "--with-headers=${prefix_tmp}/or32-linux/include ${thread_config}"
933 404 jeremybenn
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
934
        gnu_make ${build_flag} ${bd_linux} all-gcc
935
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
936
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
937
            install-ld
938
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
939
 
940
        # We need to build uClibc before building the C++ libraries, which in
941
        # turn needs the Linux headers
942
        export PATH=${prefix}/bin:${PATH}
943
        install_linux_headers ${prefix}
944
        uclibc_config ${prefix}
945
        uclibc_build_install
946
 
947
        # Finish building the C++ library
948
        gnu_make ${build_flag} ${bd_linux} all-target-libstdc++-v3
949
        gnu_make ${install_flag} ${bd_linux} install-target-libstdc++-v3
950
    fi
951
 
952
    # Configure, build and install GDB (note we need to reconfigure in case
953
    # only stage1 has been run previously).
954 427 jeremybenn
    gnu_config ${config_flag} ${prefix} ${bd_linux_gdb} ../${gdb_dir} \
955
        "${languages}"
956 404 jeremybenn
    gnu_make ${build_flag} ${bd_linux_gdb} all-build all-sim all-gdb
957
    gnu_make ${install_flag} ${bd_linux_gdb} install-sim install-gdb
958
fi

powered by: WebSVN 2.1.0

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