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 636

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

powered by: WebSVN 2.1.0

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