build-scripts/nacl-buildbot.sh
author Ryan C. Gordon <icculus@icculus.org>
Fri, 20 Jun 2014 22:38:36 -0400
changeset 8881 eb48568ecabb
child 8882 4fc9e98413c3
permissions -rwxr-xr-x
Added script for buildbot to use on NaCl target.
icculus@8881
     1
#!/bin/bash
icculus@8881
     2
icculus@8881
     3
# This is the script buildbot.libsdl.org uses to cross-compile SDL2 from
icculus@8881
     4
#  amd64 Linux to NaCl.
icculus@8881
     5
icculus@8881
     6
# The final tarball can be unpacked in the root directory of a RPi,
icculus@8881
     7
#  so the SDL2 install lands in /usr/local. Run ldconfig, and then
icculus@8881
     8
#  you should be able to build and run SDL2-based software on your
icculus@8881
     9
#  Pi. Standard configure scripts should be able to find SDL and
icculus@8881
    10
#  build against it, and sdl2-config should work correctly on the
icculus@8881
    11
#  actual device.
icculus@8881
    12
icculus@8881
    13
export NACL_SDK_ROOT="/nacl_sdk/pepper_35"
icculus@8881
    14
icculus@8881
    15
TARBALL="$1"
icculus@8881
    16
if [ -z $1 ]; then
icculus@8881
    17
    TARBALL=sdl-nacl.tar.xz
icculus@8881
    18
fi
icculus@8881
    19
icculus@8881
    20
OSTYPE=`uname -s`
icculus@8881
    21
if [ "$OSTYPE" != "Linux" ]; then
icculus@8881
    22
    # !!! FIXME
icculus@8881
    23
    echo "This only works on x86 or x64-64 Linux at the moment." 1>&2
icculus@8881
    24
    exit 1
icculus@8881
    25
fi
icculus@8881
    26
icculus@8881
    27
if [ "x$MAKE" == "x" ]; then
icculus@8881
    28
    NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
icculus@8881
    29
    let NCPU=$NCPU+1
icculus@8881
    30
    MAKE="make -j$NCPU"
icculus@8881
    31
fi
icculus@8881
    32
icculus@8881
    33
BUILDBOTDIR="nacl-buildbot"
icculus@8881
    34
PARENTDIR="$PWD"
icculus@8881
    35
icculus@8881
    36
set -e
icculus@8881
    37
set -x
icculus@8881
    38
rm -f $TARBALL
icculus@8881
    39
rm -rf $BUILDBOTDIR
icculus@8881
    40
mkdir -p $BUILDBOTDIR
icculus@8881
    41
pushd $BUILDBOTDIR
icculus@8881
    42
icculus@8881
    43
# !!! FIXME: ccache?
icculus@8881
    44
export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
icculus@8881
    45
export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
icculus@8881
    46
export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
icculus@8881
    47
export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
icculus@8881
    48
export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
icculus@8881
    49
icculus@8881
    50
../configure --host=pnacl --prefix=$PWD/nacl-sdl2-installed
icculus@8881
    51
$MAKE
icculus@8881
    52
$MAKE install
icculus@8881
    53
# Fix up a few things to a real install path on a real Raspberry Pi...
icculus@8881
    54
perl -w -pi -e "s#$PWD/nacl-sdl2-installed#/usr/local#g;" ./nacl-sdl2-installed/lib/libSDL2.la ./nacl-sdl2-installed/lib/pkgconfig/sdl2.pc ./nacl-sdl2-installed/bin/sdl2-config
icculus@8881
    55
mkdir -p ./usr
icculus@8881
    56
mv ./nacl-sdl2-installed ./usr/local
icculus@8881
    57
icculus@8881
    58
popd
icculus@8881
    59
tar -cJvvf $TARBALL -C $BUILDBOTDIR usr
icculus@8881
    60
rm -rf $BUILDBOTDIR
icculus@8881
    61
icculus@8881
    62
set +x
icculus@8881
    63
echo "All done. Final installable is in $TARBALL ...";
icculus@8881
    64