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 454

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

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

powered by: WebSVN 2.1.0

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