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

Subversion Repositories openrisc_2011-10-31

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

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 490 jeremybenn
    linux_dir="linux-2.6.37"
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 490 jeremybenn
    Specify the languages to be built (default c,c++).
361 427 jeremybenn
 
362 404 jeremybenn
--prefix <dir>
363 490 jeremybenn
    Specify the install directory (default /opt/or32-new)
364 404 jeremybenn
 
365
--prefix-tmp <dir>
366 490 jeremybenn
    Specify the temporary install directory (default /tmp/or32-tmp-${USER}).
367 404 jeremybenn
    Incorporating the user name avoid name clashes with other users
368
 
369
--unisrc-dir <dir>
370 490 jeremybenn
    Specify the unified source directory (default unisrc)
371 404 jeremybenn
 
372
--build-dir-elf <dir>
373
    Specify the build directory for the newlib (or32-elf) tool chain
374 490 jeremybenn
    (default bd-elf).
375 404 jeremybenn
 
376
--build-dir-elf-gdb <dir>
377
    Specify the build directory for the newlib (or32-elf) GDB (default
378 490 jeremybenn
    bd-elf-gdb).
379 404 jeremybenn
 
380
--build-dir-linux <dir>
381
    Specify the build directory for the uClibc (or32-linux) tool chain
382 490 jeremybenn
    (default bd-linux)
383 404 jeremybenn
 
384
--build-dir-linux-gdb <dir>
385
    Specify the build directory for the uClibc (or32-linux) GDB (default
386 490 jeremybenn
    bd-linux-gdb)
387 404 jeremybenn
 
388
--or1ksim-dir <dir>
389
    Specify the Or1ksim installation directory. Used by GDB, which links in
390 490 jeremybenn
    the Or1ksim simulator (default /opt/or1ksim-new)
391 404 jeremybenn
 
392
--binutils-dir
393 490 jeremybenn
    Source directory for binutils (default binutils-2.20.1)
394 404 jeremybenn
 
395
--gcc-dir
396 490 jeremybenn
    Source directory for gcc (default gcc-4.5.1')
397 404 jeremybenn
 
398
--newlib-dir
399 490 jeremybenn
    Source directory for newlib (default newlib-1.18.0)
400 404 jeremybenn
 
401 459 julius
--uclibc-dir
402 490 jeremybenn
    Source directory for uClibc (default uclibc-0.9.31)
403 404 jeremybenn
 
404 459 julius
--gdb-dir
405 490 jeremybenn
    Source directory for gdb (default  gdb-7.2)
406 404 jeremybenn
 
407 459 julius
--linux-dir
408 490 jeremybenn
    Source directory for Linux (default linux-2.6.35)
409 404 jeremybenn
 
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 490 jeremybenn
            case `dirname $0` in
538
              '.') ;;
539
              *)
540
                case srcdir in
541
                /* | [A-Za-z]:[\\/]*) ;;
542
                *) srcdir="`dirname $0`/${srcdir}" ;;
543
                esac ;;
544
            esac
545 404 jeremybenn
            echo "Component: $srcdir"
546
            case srcdir
547
                in
548
                /* | [A-Za-z]:[\\/]*)
549
                    ;;
550
 
551
                *)
552
                    srcdir="${unisrc_prefix}/${srcdir}"
553
                    ;;
554
            esac
555
 
556
            files=`ls -a ${srcdir}`
557
 
558
            for f in ${files}
559
            do
560
                found=
561
 
562
                for i in ${ignore_list}
563
                do
564
                    if [ "$f" = "$i" ]
565
                    then
566
                        found=yes
567
                    fi
568
                done
569
 
570
                if [ -z "${found}" ]
571
                then
572
                    echo "$f            ..linked"
573
                    ln -s ${srcdir}/$f .
574
                fi
575
            done
576
 
577
            ignore_list="${ignore_list} ${files}"
578
        done
579
 
580
        if [ $? != 0 ]
581
        then
582
            echo "failed to create ${unisrc_dir}"
583
            exit 1
584
        fi
585
 
586
        unset component_dirs
587
        unset ignore_list
588 421 julius
        cd -
589 404 jeremybenn
    fi
590
}       # link_unified
591
 
592
 
593
# ------------------------------------------------------------------------------
594
# Conditionally configure a GNU source directory (could be the unified
595
# directory, or GDB)
596
 
597
# @param[in] $1       "true" if we should execute this function
598
# @param[in] $2       The prefix to use for installation.
599
# @param[in] $3       The build directory to configure in.
600
# @param[in] $4       The source directory containing configure (relative to $1)
601
# @param[in] $5       The languages to configure for.
602
# @param[in] $6, ...  Additional configure args.
603
function gnu_config {
604
    cond=$1
605
    shift
606
 
607
    if [ "true" == ${cond} ]
608
    then
609
        this_prefix=$1
610
        shift
611
        top_builddir=$1
612
        shift
613
        top_srcdir=$1
614
        shift
615
        langs=$1
616
        shift
617
 
618 473 jeremybenn
        echo -n "bld-all.sh: gnu_config ${this_prefix} ${top_builddir} "
619
        echo    "${top_srcdir} ${langs} $*"
620 404 jeremybenn
 
621
        verstr="OpenRISC 32-bit toolchain for ${target} (built `date +%Y%m%d`)"
622
 
623
        mkdir -p ${top_builddir} &&                                   \
624
            cd ${top_builddir} &&                                     \
625
            ${top_srcdir}/configure --target=${target}                \
626 427 jeremybenn
                --with-pkgversion="${verstr}" --disable-shared        \
627 404 jeremybenn
                --with-bugurl=http://www.opencores.org/               \
628
                --with-or1ksim=${or1ksim_dir}                         \
629
                --enable-fast-install=N/A --disable-libssp            \
630
                --enable-languages=${langs} --prefix=${this_prefix} $*
631
 
632
        if [ $? != 0 ]
633
        then
634
            echo "configure failed."
635
            exit 1
636
        fi
637
 
638 421 julius
        cd -
639 404 jeremybenn
 
640
        unset verstr
641
        unset langs
642
        unset top_srcdir
643
        unset top_builddir
644
        unset this_prefix
645
    fi
646
 
647
    unset cond
648
 
649
}       # gnu_config
650
 
651
 
652
# ------------------------------------------------------------------------------
653
# Conditionally run make and check the result.
654
 
655
# @param[in] $1       "true" if we should execute this function
656
# @param[in] $2      The build directory to make in
657
# @param[in] $3, ... The targets to make
658
function gnu_make {
659
    cond=$1
660
    shift
661
 
662
    if [ "true" == ${cond} ]
663
    then
664
        echo "bld-all.sh: gnu_make $*"
665
 
666
        cd $1
667
        shift
668
 
669
        make $make_load $*
670
 
671
        if [ $? != 0 ]
672
        then
673
            echo "make ($*) failed."
674
            exit 1
675
        fi
676
 
677 421 julius
        cd -
678 404 jeremybenn
    fi
679
 
680
    unset cond
681
 
682
}       # gnu_make
683
 
684
 
685
# ------------------------------------------------------------------------------
686 490 jeremybenn
# Change directory to $1 as seen from $0.
687
 
688
function cd_0rel {
689
  case "$1" in
690
    /*) cd "$1" ;;
691
    *) cd "`dirname $0`/$1" ;;
692
  esac
693
}
694
 
695
# ------------------------------------------------------------------------------
696 404 jeremybenn
# Conditionally configure and install the Linux headers
697
 
698
# @param[in] $1       The prefix to use for installation.
699
function install_linux_headers {
700
    this_prefix=$1
701
 
702 490 jeremybenn
    cd_0rel  $linux_dir
703 404 jeremybenn
 
704
    if [ "true" == "${config_flag}" ]
705
    then
706
        echo "bld-all.sh: Configuring Linux headers"
707
 
708 448 jeremybenn
        make ARCH=openrisc defconfig
709 404 jeremybenn
 
710
        if [ $? != 0 ];
711
        then
712
            echo "Linux configure failed"
713
            exit 1
714
        fi
715
    fi
716
 
717
    # This is a bit iffy. We do rely on the headers being installed for uClibc
718
    # to build, so not installing the first time would be a bit dodgy.
719
    if [ "true" == "${install_flag}" ]
720
    then
721
        echo "bld-all.sh: Installing Linux headers"
722
 
723
        make INSTALL_HDR_PATH=${this_prefix}/or32-linux headers_install
724
 
725
        if [ $? != 0 ];
726
        then
727
            echo "Linux header installation failed"
728
            exit 1
729
        fi
730
 
731
        unset this_prefix
732
    fi
733
 
734 421 julius
    cd -
735 404 jeremybenn
 
736
}       # install_linux_headers
737
 
738
 
739
# ------------------------------------------------------------------------------
740 427 jeremybenn
# Conditionally configure uClibc. Clean before configuring.
741 404 jeremybenn
 
742
# @param[in] $1       The prefix to use for installation.
743
function uclibc_config {
744
 
745
    if [ "true" == "${config_flag}" ]
746
    then
747
        this_prefix=$1
748
        echo "bld-all.sh: Configuring uClibc"
749
 
750 490 jeremybenn
        cd_0rel ${uclibc_dir}
751 404 jeremybenn
 
752
        kheaders="KERNEL_HEADERS=\\\"${this_prefix}\\/or32-linux\\/include\\\""
753
        devprefix="DEVEL_PREFIX=\\\"${this_prefix}\\/or32-linux\\\""
754
        ccprefix="CROSS_COMPILER_PREFIX=\\\"or32-linux-\\\""
755
 
756
        sed -i extra/Configs/defconfigs/or32     \
757
            -e "s|KERNEL_HEADERS.*|${kheaders}|g"  \
758
            -e "s|DEVEL_PREFIX.*|${devprefix}|g" \
759
            -e "s|CROSS_COMPILER_PREFIX.*|${ccprefix}|g"
760
 
761
        if [ $? != 0 ];
762
        then
763
            echo "uClibc sed failed"
764
            exit 1
765
        fi
766
 
767 427 jeremybenn
        make ARCH=or32 clean
768
 
769
        if [ $? != 0 ];
770
        then
771
            echo "uClibc clean failed"
772
            exit 1
773
        fi
774
 
775 404 jeremybenn
        make ARCH=or32 defconfig
776
 
777
        if [ $? != 0 ];
778
        then
779
            echo "uClibc configure failed"
780
            exit 1
781
        fi
782
 
783
        unset this_prefix
784
        unset ccprefix
785
        unset devprefix
786
        unset kheaders
787
 
788 421 julius
        cd -
789 404 jeremybenn
    fi
790
}       # uclibc_config
791
 
792
 
793
# ------------------------------------------------------------------------------
794
# Conditionally build and install uClibc
795
function uclibc_build_install {
796 490 jeremybenn
    cd_0rel ${uclibc_dir}
797 404 jeremybenn
 
798
    if [ "true" == "${build_flag}" ]
799
    then
800
        echo "bld-all.sh: Building uClibc"
801
 
802
        make ARCH=or32 all
803
 
804
        if [ $? != 0 ];
805
        then
806
            echo "uClibc build failed"
807
            exit 1
808
        fi
809
    fi
810
 
811
    if [ "true" == "${install_flag}" ]
812
    then
813
        echo "bld-all.sh: Installing uClibc"
814
 
815
        make ARCH=or32 install
816
 
817
        if [ $? != 0 ];
818
        then
819
            echo "uClibc install failed"
820
            exit 1
821
        fi
822
    fi
823
 
824 421 julius
    cd -
825 404 jeremybenn
 
826
}       # uclibc_build_install
827
 
828
 
829
# ------------------------------------------------------------------------------
830
# Main program
831
set_defaults
832
parse_args $*
833
sanity_check
834
 
835 422 jeremybenn
# --force always blows away the link directory. It only blows away build
836
# directories we are actually building (see below).
837 404 jeremybenn
if [ "true" == "${force_flag}" ]
838
then
839 473 jeremybenn
    echo "bld-all.sh: removing ${unisrc_dir}"
840 422 jeremybenn
    rm -rf ${unisrc_dir}
841 404 jeremybenn
fi
842
 
843
link_unified
844
 
845
# Build the newlib (or32-elf) tool chain.
846
if [ "true" == "${or32_elf_flag}" ]
847
then
848
    target="or32-elf"
849
    echo "bld-all.sh: or32-elf toolchain"
850
 
851 422 jeremybenn
    # --force only applies to build directories we are using!
852
    if [ "true" == "${force_flag}" ]
853
    then
854 473 jeremybenn
        echo "bld-all.sh: removing ${bd_elf} ${bd_elf_gdb}"
855 422 jeremybenn
        rm -rf ${bd_elf} ${bd_elf_gdb}
856
    fi
857
 
858 404 jeremybenn
    # Configure all
859 427 jeremybenn
    gnu_config ${config_flag} ${prefix} ${bd_elf} ../${unisrc_dir} \
860
        "${languages}" "${newlib_config}"
861 490 jeremybenn
    # ??? should handle absolute pathnames.
862
    gnu_config ${config_flag} ${prefix} ${bd_elf_gdb} \
863
        ../`dirname $0`/${gdb_dir} "${languages}"
864 404 jeremybenn
 
865
    # Build all
866
    gnu_make ${build_flag} ${bd_elf} all-build all-binutils all-gas all-ld
867
    gnu_make ${build_flag} ${bd_elf} all-gcc
868
    gnu_make ${build_flag} ${bd_elf} all-target-libgcc all-target-libstdc++-v3 \
869
        ${newlib_build}
870
    gnu_make ${build_flag} ${bd_elf_gdb} all-build all-sim all-gdb
871
 
872
    # Check all
873
    gnu_make ${check_flag} ${bd_elf} check-binutils check-gas check-ld \
874
        check-gcc check-target-libgcc check-target-libstdc++-v3 ${newlib_check}
875
    gnu_make ${check_flag} ${bd_elf_gdb} check-sim check-gdb
876
 
877
    # Install all
878
    gnu_make ${install_flag} ${bd_elf} install-binutils install-gas install-ld \
879
        install-gcc install-target-libgcc install-target-libstdc++-v3 \
880
        ${newlib_install}
881
    gnu_make ${install_flag} ${bd_elf_gdb} install-sim install-gdb
882
fi
883
 
884
# Build the uClibc (or32-linux) tool chain
885
if [ "true" == "${or32_linux_flag}" ]
886
then
887
    target="or32-linux"
888
    echo "bld-all.sh: or32-linux toolchain"
889
 
890 422 jeremybenn
    # --force only applies to build directories we are using!
891
    if [ "true" == "${force_flag}" ]
892
    then
893 473 jeremybenn
        echo "bld-all.sh: removing ${bd_linux} ${bd_linux_gdb}"
894 422 jeremybenn
        rm -rf ${bd_linux} ${bd_linux_gdb}
895
    fi
896
 
897 404 jeremybenn
    # Stage 1 binutils/GCC build uses no headers and only C
898
    # language. This is just to create the libc headers, which we put in the
899
    # temporary prefix directory.
900
    if [ "true" == "${uclibc_stage1_flag}" ]
901
    then
902
        echo "bld-all.sh: uClibc GCC stage 1"
903
 
904
        # Make a clean temporary install directory.
905
        rm -rf ${prefix_tmp}
906
        mkdir ${prefix_tmp}
907
 
908 454 jeremybenn
        # For header building we use just single threads, or we don't find
909
        # pthread.h.
910
        thread_config="--enable-threads=single --disable-tls"
911
 
912 427 jeremybenn
        # To create the headers we only use C
913 404 jeremybenn
        gnu_config ${config_flag} ${prefix_tmp} ${bd_linux} ../${unisrc_dir} \
914 454 jeremybenn
            "c" "--without-headers ${thread_config}"
915 404 jeremybenn
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
916
        gnu_make ${build_flag} ${bd_linux} all-gcc
917
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
918
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
919
            install-ld
920
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
921
 
922
        # Create the headers using our temporary tool chain
923
        save_path="${PATH}"
924
        export PATH="${prefix_tmp}/bin:${PATH}"
925
        install_linux_headers ${prefix_tmp}
926
        uclibc_config ${prefix_tmp}
927
        uclibc_build_install
928
        PATH="${save_path}"
929
        unset save_path
930
    fi
931
 
932
    # If we are doing both stage 1 and stage 2, then we need to completely
933
    # clean gcc and target libraries. Just blow the entire directory away.
934
    if [ "truetrue" == "${uclibc_stage1_flag}${uclibc_stage2_flag}" ]
935
    then
936
        echo "bld-all.sh: uClibc GCC inter-stage cleaning"
937
        rm -rf ${bd_linux}/gcc ${bd_linux}/or32-linux
938
    fi
939
 
940
    # Stage 2 GCC uses the headers installed from stage 1.
941
    if [ "true" == "${uclibc_stage2_flag}" ]
942
    then
943
        echo "bld-all.sh: uClibc GCC stage 2"
944
 
945 473 jeremybenn
        # uClibc now supports POSIX threads, but not TLS. uClibc
946
        # linuxthreads.old is a POSIX98 compliant implementation.
947 454 jeremybenn
        thread_config="--enable-threads=posix --disable-tls"
948 404 jeremybenn
 
949
        gnu_config ${config_flag} ${prefix} ${bd_linux} ../${unisrc_dir} \
950 427 jeremybenn
            "${languages}" \
951 454 jeremybenn
            "--with-headers=${prefix_tmp}/or32-linux/include ${thread_config}"
952 404 jeremybenn
        gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
953
        gnu_make ${build_flag} ${bd_linux} all-gcc
954
        gnu_make ${build_flag} ${bd_linux} all-target-libgcc
955
        gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
956
            install-ld
957
        gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
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 490 jeremybenn
    # ??? should handle absolute pathnames.
974
    gnu_config ${config_flag} ${prefix} ${bd_linux_gdb} \
975
        ../`dirname $0`/${gdb_dir} "${languages}"
976 404 jeremybenn
    gnu_make ${build_flag} ${bd_linux_gdb} all-build all-sim all-gdb
977
    gnu_make ${install_flag} ${bd_linux_gdb} install-sim install-gdb
978
fi

powered by: WebSVN 2.1.0

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