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 427

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 relocate the newlib headers and libraries.
666
function relocate_newlib {
667
    if [ "true" == "${newlib_flag}" ]
668
    then
669
        echo "bld-all.sh: Relocating newlib"
670
 
671
        mkdir -p ${prefix}/or32-elf/newlib
672
        rm -rf ${prefix}/or32-elf/newlib-include
673
 
674
        if [ -d ${prefix}/or32-elf/include ]
675
        then
676
            mv ${prefix}/or32-elf/include \
677
                ${prefix}/or32-elf/newlib-include
678
        fi
679
 
680
        if [ -d ${prefix}/or32-elf/lib ]
681
        then
682
            afiles=`ls -1 ${prefix}/or32-elf/lib | grep '\.a' | head -1`
683
 
684
            if [ "x$afiles" != "x" ]
685
            then
686
                mv ${prefix}/or32-elf/lib/*.a ${prefix}/or32-elf/newlib
687
            fi
688
        fi
689
 
690
        if [ -f ${prefix}/or32-elf/lib/crt0.o ]
691
        then
692
            mv ${prefix}/or32-elf/lib/crt0.o ${prefix}/or32-elf/newlib
693
        fi
694
    fi
695
}       # relocate_newlib
696
 
697
 
698
# ------------------------------------------------------------------------------
699
# Conditionally configure and install the Linux headers
700
 
701
# @param[in] $1       The prefix to use for installation.
702
function install_linux_headers {
703
    this_prefix=$1
704
 
705
    cd $linux_dir
706
 
707
    if [ "true" == "${config_flag}" ]
708
    then
709
        echo "bld-all.sh: Configuring Linux headers"
710
 
711
        make ARCH=or32 defconfig
712
 
713
        if [ $? != 0 ];
714
        then
715
            echo "Linux configure failed"
716
            exit 1
717
        fi
718
    fi
719
 
720
    # This is a bit iffy. We do rely on the headers being installed for uClibc
721
    # to build, so not installing the first time would be a bit dodgy.
722
    if [ "true" == "${install_flag}" ]
723
    then
724
        echo "bld-all.sh: Installing Linux headers"
725
 
726
        make INSTALL_HDR_PATH=${this_prefix}/or32-linux headers_install
727
 
728
        if [ $? != 0 ];
729
        then
730
            echo "Linux header installation failed"
731
            exit 1
732
        fi
733
 
734
        unset this_prefix
735
    fi
736
 
737 421 julius
    cd -
738 404 jeremybenn
 
739
}       # install_linux_headers
740
 
741
 
742
# ------------------------------------------------------------------------------
743 427 jeremybenn
# Conditionally configure uClibc. Clean before configuring.
744 404 jeremybenn
 
745
# @param[in] $1       The prefix to use for installation.
746
function uclibc_config {
747
 
748
    if [ "true" == "${config_flag}" ]
749
    then
750
        this_prefix=$1
751
        echo "bld-all.sh: Configuring uClibc"
752
 
753
        cd ${uclibc_dir}
754
 
755
        kheaders="KERNEL_HEADERS=\\\"${this_prefix}\\/or32-linux\\/include\\\""
756
        devprefix="DEVEL_PREFIX=\\\"${this_prefix}\\/or32-linux\\\""
757
        ccprefix="CROSS_COMPILER_PREFIX=\\\"or32-linux-\\\""
758
 
759
        sed -i extra/Configs/defconfigs/or32     \
760
            -e "s|KERNEL_HEADERS.*|${kheaders}|g"  \
761
            -e "s|DEVEL_PREFIX.*|${devprefix}|g" \
762
            -e "s|CROSS_COMPILER_PREFIX.*|${ccprefix}|g"
763
 
764
        if [ $? != 0 ];
765
        then
766
            echo "uClibc sed failed"
767
            exit 1
768
        fi
769
 
770 427 jeremybenn
        make ARCH=or32 clean
771
 
772
        if [ $? != 0 ];
773
        then
774
            echo "uClibc clean failed"
775
            exit 1
776
        fi
777
 
778 404 jeremybenn
        make ARCH=or32 defconfig
779
 
780
        if [ $? != 0 ];
781
        then
782
            echo "uClibc configure failed"
783
            exit 1
784
        fi
785
 
786
        unset this_prefix
787
        unset ccprefix
788
        unset devprefix
789
        unset kheaders
790
 
791 421 julius
        cd -
792 404 jeremybenn
    fi
793
}       # uclibc_config
794
 
795
 
796
# ------------------------------------------------------------------------------
797
# Conditionally build and install uClibc
798
function uclibc_build_install {
799
    cd ${uclibc_dir}
800
 
801
    if [ "true" == "${build_flag}" ]
802
    then
803
        echo "bld-all.sh: Building uClibc"
804
 
805
        make ARCH=or32 all
806
 
807
        if [ $? != 0 ];
808
        then
809
            echo "uClibc build failed"
810
            exit 1
811
        fi
812
    fi
813
 
814
    if [ "true" == "${install_flag}" ]
815
    then
816
        echo "bld-all.sh: Installing uClibc"
817
 
818
        make ARCH=or32 install
819
 
820
        if [ $? != 0 ];
821
        then
822
            echo "uClibc install failed"
823
            exit 1
824
        fi
825
    fi
826
 
827 421 julius
    cd -
828 404 jeremybenn
 
829
}       # uclibc_build_install
830
 
831
 
832
# ------------------------------------------------------------------------------
833
# Main program
834
set_defaults
835
parse_args $*
836
sanity_check
837
 
838 422 jeremybenn
# --force always blows away the link directory. It only blows away build
839
# directories we are actually building (see below).
840 404 jeremybenn
if [ "true" == "${force_flag}" ]
841
then
842 423 jeremybenn
    echo -n "bld-all.sh: removing ${unisrc_dir}"
843 422 jeremybenn
    rm -rf ${unisrc_dir}
844 404 jeremybenn
fi
845
 
846
link_unified
847
 
848
# Build the newlib (or32-elf) tool chain.
849
if [ "true" == "${or32_elf_flag}" ]
850
then
851
    target="or32-elf"
852
    echo "bld-all.sh: or32-elf toolchain"
853
 
854 422 jeremybenn
    # --force only applies to build directories we are using!
855
    if [ "true" == "${force_flag}" ]
856
    then
857
        echo -n "bld-all.sh: removing ${bd_elf} ${bd_elf_gdb} "
858
        rm -rf ${bd_elf} ${bd_elf_gdb}
859
    fi
860
 
861 404 jeremybenn
    # Configure all
862 427 jeremybenn
    gnu_config ${config_flag} ${prefix} ${bd_elf} ../${unisrc_dir} \
863
        "${languages}" "${newlib_config}"
864
    gnu_config ${config_flag} ${prefix} ${bd_elf_gdb} ../${gdb_dir} \
865
        "${languages}"
866 404 jeremybenn
 
867
    # Build all
868
    gnu_make ${build_flag} ${bd_elf} all-build all-binutils all-gas all-ld
869
    gnu_make ${build_flag} ${bd_elf} all-gcc
870
    gnu_make ${build_flag} ${bd_elf} all-target-libgcc all-target-libstdc++-v3 \
871
        ${newlib_build}
872
    gnu_make ${build_flag} ${bd_elf_gdb} all-build all-sim all-gdb
873
 
874
    # Check all
875
    gnu_make ${check_flag} ${bd_elf} check-binutils check-gas check-ld \
876
        check-gcc check-target-libgcc check-target-libstdc++-v3 ${newlib_check}
877
    gnu_make ${check_flag} ${bd_elf_gdb} check-sim check-gdb
878
 
879
    # Install all
880
    gnu_make ${install_flag} ${bd_elf} install-binutils install-gas install-ld \
881
        install-gcc install-target-libgcc install-target-libstdc++-v3 \
882
        ${newlib_install}
883
    gnu_make ${install_flag} ${bd_elf_gdb} install-sim install-gdb
884
    relocate_newlib
885
fi
886
 
887
# Build the uClibc (or32-linux) tool chain
888
if [ "true" == "${or32_linux_flag}" ]
889
then
890
    target="or32-linux"
891
    echo "bld-all.sh: or32-linux toolchain"
892
 
893 422 jeremybenn
    # --force only applies to build directories we are using!
894
    if [ "true" == "${force_flag}" ]
895
    then
896
        echo -n "bld-all.sh: removing ${bd_linux} ${bd_linux_gdb} "
897
        rm -rf ${bd_linux} ${bd_linux_gdb}
898
    fi
899
 
900 404 jeremybenn
    # Stage 1 binutils/GCC build uses no headers and only C
901
    # language. This is just to create the libc headers, which we put in the
902
    # temporary prefix directory.
903
    if [ "true" == "${uclibc_stage1_flag}" ]
904
    then
905
        echo "bld-all.sh: uClibc GCC stage 1"
906
 
907
        # Make a clean temporary install directory.
908
        rm -rf ${prefix_tmp}
909
        mkdir ${prefix_tmp}
910
 
911 427 jeremybenn
        # To create the headers we only use C
912 404 jeremybenn
        gnu_config ${config_flag} ${prefix_tmp} ${bd_linux} ../${unisrc_dir} \
913
            "c" "--without-headers --enable-threads=single"
914
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
915
        gnu_make ${build_flag} ${bd_linux} all-gcc
916
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
917
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
918
            install-ld
919
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
920
 
921
        # Create the headers using our temporary tool chain
922
        save_path="${PATH}"
923
        export PATH="${prefix_tmp}/bin:${PATH}"
924
        install_linux_headers ${prefix_tmp}
925
        uclibc_config ${prefix_tmp}
926
        uclibc_build_install
927
        PATH="${save_path}"
928
        unset save_path
929
    fi
930
 
931
    # If we are doing both stage 1 and stage 2, then we need to completely
932
    # clean gcc and target libraries. Just blow the entire directory away.
933
    if [ "truetrue" == "${uclibc_stage1_flag}${uclibc_stage2_flag}" ]
934
    then
935
        echo "bld-all.sh: uClibc GCC inter-stage cleaning"
936
        rm -rf ${bd_linux}/gcc ${bd_linux}/or32-linux
937
    fi
938
 
939
    # Stage 2 GCC uses the headers installed from stage 1.
940
    if [ "true" == "${uclibc_stage2_flag}" ]
941
    then
942
        echo "bld-all.sh: uClibc GCC stage 2"
943
 
944
        # FIXME: uclibc is supposed to provide thread support, but doesn't.
945
        thread_hack="--disable-threads --disable-libgomp"
946
 
947
        gnu_config ${config_flag} ${prefix} ${bd_linux} ../${unisrc_dir} \
948 427 jeremybenn
            "${languages}" \
949 404 jeremybenn
            "--with-headers=${prefix_tmp}/or32-linux/include $thread_hack"
950
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
951
        gnu_make ${build_flag} ${bd_linux} all-gcc
952
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
953
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
954
            install-ld
955
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
956
 
957
        unset thread_hack
958
 
959
        # We need to build uClibc before building the C++ libraries, which in
960
        # turn needs the Linux headers
961
        export PATH=${prefix}/bin:${PATH}
962
        install_linux_headers ${prefix}
963
        uclibc_config ${prefix}
964
        uclibc_build_install
965
 
966
        # Finish building the C++ library
967
        gnu_make ${build_flag} ${bd_linux} all-target-libstdc++-v3
968
        gnu_make ${install_flag} ${bd_linux} install-target-libstdc++-v3
969
    fi
970
 
971
    # Configure, build and install GDB (note we need to reconfigure in case
972
    # only stage1 has been run previously).
973 427 jeremybenn
    gnu_config ${config_flag} ${prefix} ${bd_linux_gdb} ../${gdb_dir} \
974
        "${languages}"
975 404 jeremybenn
    gnu_make ${build_flag} ${bd_linux_gdb} all-build all-sim all-gdb
976
    gnu_make ${install_flag} ${bd_linux_gdb} install-sim install-gdb
977
fi

powered by: WebSVN 2.1.0

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