build.rtems.4.12.sh 3.88 KB
Newer Older
1 2
#!/bin/bash
#
3
# This script builds the RTEMS/SPARC cross-compiler and the
4
# LEON2/GR712/GR740 BSPs.
5
#
6
# The call to sb-check below will stop the build if your environment
7 8 9 10
# is missing the necessary dependencies. Note that in addition to these,
# the build depends on GCC7 AND GNAT7 - otherwise the creation of the
# toolchain will fail.
#
11
# If you want to get a pre-made toolchain that was built by this script,
12 13 14 15 16 17 18 19 20 21
# you can download it in standalone form from:
#
#   http://download.tuxfamily.org/taste/RTEMS/rtems-4.12-2017.07.17.tar.bz2
#
# This compiler is also automatically installed in the TASTE VM 
# (available from https://taste.tuxfamily.org/ - navigate to the Download
# Area, and get the .ova file - which you then import in VirtualBox).
# Upon entering the VM, call Update-TASTE (as indicated in the help
# screen shown upon boot) and the RTEMS toolchain will be installed.

22 23 24 25 26

# Stop on any error
set -e

DATE=$(date +"%Y.%m.%d")
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
27 28
mkdir -p $HOME/rtems.build.logs
BUILD_LOG=$HOME/rtems.build.logs/${DATE}.log
29 30 31 32 33 34 35 36 37 38
[ -f ${BUILD_LOG} ] && {
    echo "There's already a build log:"
    echo "    " ${BUILD_LOG}
    echo Remove it to continue.
    exit 1
}

# Record the output in $BUILD_LOG (see matching brace)
{
    # Begin by checking out the RTEMS Source Builder
39

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
40 41 42
    RSBPARENT=$HOME/development/rtems/src
    mkdir -p $RSBPARENT
    RSB=$RSBPARENT/rtems-source-builder-${DATE}
43
    RTPREFIX=/opt/rtems-4.12-${DATE}
44 45
    rm -rf ${RTPREFIX}
    [ ! -d $RSB ] && {
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
46
        cd $RSBPARENT
47
        git clone https://github.com/RTEMS/rtems-source-builder.git rtems-source-builder-${DATE}
48 49
    }
    cd $RSB
50

51 52 53
    # What tag/branch to work on? By default this will be in the master branch,
    # but you can switch - to e.g. 4.11.2:
    #
54 55 56 57
    #     git checkout -f 4.11.2
    #
    # RSB commit ID recommended by Embedded Brains for using RTEMS/SMP:
    git checkout -f e2952bb185c1f40027caa76cfd9e4a45b17a8886-modified
58 59 60 61

    # Verify that we have all we need to build
    source-builder/sb-check

62 63
    cd rtems

64 65 66
    # Your network firewall may or may not be an issue at this point:
    # Many of the source tarballs needed by the RSB are fetched over
    # PASV-enabled FTP servers.
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
67
    #
68 69 70
    # If your network is like the one in ESA/ESTEC and this is forbidden,
    # you'll have to fetch these tarballs and hardlink to them each time
    # (so no FTP action is triggered by the RTEMS RSB builder).
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
71 72 73 74
    # The sed invocation below also replaces ftp: with http:
    # (since this needs no PASV port meddling - which some firewalls object to)
    #
    # This is the way I do it - adapt it according to your needs:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
75
    #
76 77 78
    # [ ! -d sources ] && {
    #     mkdir -p sources
    #     cd sources
79
    #     cp -al ~/development/rtems/pkg_sources_cache/* .
80
    #     cd ..
81 82 83
    #     for i in config/tools/*cfg ; do
    #         cat "$i" | sed 's,ftp://ftp.gnu.org,http://ftp.gnu.org,;s,ftp://gcc.gnu.org,http://gcc.gnu.org,;' > "$i".new && mv "$i".new "$i"
    #     done
84 85
    # }

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
86
    # Build the cross compiling toolchain
87
    # (we're in the master branch, which is currently the "unofficial" 4.12)
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
88
    ../source-builder/sb-set-builder --with-ada --log=stage1.log --prefix=${RTPREFIX} 4.12/rtems-sparc 
89 90 91 92 93 94

    # Add the cross compiler to the PATH and checkout RTEMS
    export PATH=${RTPREFIX}/bin:$PATH
    cd ..
    [ ! -d rtems-git ] && {
        git clone https://github.com/RTEMS/rtems.git rtems-git
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
95
        cd rtems-git
96 97 98

        # RTEMS commit ID recommended by Embedded Brains for using RTEMS/SMP
        git checkout -f 96ce1ec743a1fcf27593ee72cf1695d9eb0290de
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
99
        cd ..
100
    }
101

102 103
    # Build RTEMS
    cd rtems-git
104 105 106 107 108 109
    ./bootstrap
    cd ..
    rm -rf build.${DATE}
    mkdir build.${DATE}
    cd build.${DATE}
    ../rtems-git/configure \
110
        --target=sparc-rtems4.12 --prefix=${RTPREFIX} \
111
        --enable-rtemsbsp="leon2 leon3 ngmp" --enable-posix --enable-ada \
112
        --enable-smp --enable-cxx --enable-networking
113 114 115
    make all
    make install
} |& tee ${BUILD_LOG}