build.rtems.4.12.sh 3 KB
Newer Older
1 2
#!/bin/bash
#
3 4
# This script builds the RTEMS/SPARC cross-compiler and the
# Leon2/Leon3/NGMP BSPs.
5
#
6 7 8
# To have a reproducible setup, it would be prudent if you
# executed this script under a Debian jessie chroot,
# bootstrapped via the following:
9 10 11 12 13 14 15 16 17 18 19 20 21 22
#
#     mkdir /opt/jessie-chroot
#     debootstrap jessie /opt/jessie-chroot
#     mount -t proc none /opt/jessie-chroot/proc/
#     mount -t sysfs none /opt/jessie-chroot/sys/
#     mount -o bind /dev /opt/jessie-chroot/dev/
#     mount -o bind /dev/pts /opt/jessie-chroot/dev/pts/
#     chroot /opt/jessie-chroot
#     apt-get update
#     apt-get build-dep binutils gcc g++ gdb unzip git python2.7-dev pax
#
# Then chroot inside it and run this script:
#
#     chroot /opt/jessie-chroot
23
#     /path/to/build.rtems.4.12.sh
24 25 26 27 28 29


# Stop on any error
set -e

DATE=$(date +"%Y.%m.%d")
30 31
mkdir -p ~/rtems.build.logs
BUILD_LOG=~/rtems.build.logs/${DATE}.log
32 33 34 35 36 37 38 39 40 41
[ -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
42 43 44 45

    mkdir -p ~/development/rtems/src
    RSB=~/development/rtems/src/rtems-source-builder-${DATE}
    RTPREFIX=/opt/rtems-4.12-${DATE}
46 47
    rm -rf ${RTPREFIX}
    [ ! -d $RSB ] && {
48
        cd ~/development/rtems/src/
49 50 51
        git clone git://git.rtems.org/rtems-source-builder.git rtems-source-builder-${DATE}
    }
    cd $RSB
52
    git checkout -f 5ff2c0aa94a6fdb8b2b93fd7b16ea4284f6df5bf
53 54 55 56 57 58 59 60 61 62

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

    # 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.
    # 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).
63 64
    #
    # This is one way to do it - adapt it according to your needs:
65 66 67 68 69
    #
    # cd rtems
    # [ ! -d sources ] && {
    #     mkdir -p sources
    #     cd sources
70
    #     cp -al ~/development/rtems/pkg_sources/* .
71 72 73 74
    #     cd ..
    # }

    # Build the cross compiler
75 76
    # (we're in the master branch, which is currently the "unofficial" 4.12)
    ../source-builder/sb-set-builder --log=stage1.log --prefix=${RTPREFIX} 4.12/rtems-sparc 
77 78 79 80 81 82 83 84

    # 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
    }
    cd rtems-git
85
    git checkout -f c6556e2ecc6b80f981bb210d541544f24b7f59df
86 87 88 89 90 91
    ./bootstrap
    cd ..
    rm -rf build.${DATE}
    mkdir build.${DATE}
    cd build.${DATE}
    ../rtems-git/configure \
92 93 94
        --target=sparc-rtems4.12 --prefix=${RTPREFIX} \
        --enable-rtemsbsp="leon2 leon3 ngmp" --enable-posix \
        --enable-smp --enable-cxx --enable-networking
95 96 97
    make all
    make install
} |& tee ${BUILD_LOG}