1#!/bin/bash 2 3# This is the script buildbot.libsdl.org uses to cross-compile SDL2 from 4# amd64 Linux to NaCl. 5 6# PLEASE NOTE that we have reports that SDL built with pepper_49 (current 7# stable release as of November 10th, 2016) is broken. Please retest 8# when something newer becomes stable and then decide if this was SDL's 9# bug or NaCl's bug. --ryan. 10export NACL_SDK_ROOT="/nacl_sdk/pepper_47" 11 12TARBALL="$1" 13if [ -z $1 ]; then 14 TARBALL=sdl-nacl.tar.xz 15fi 16 17OSTYPE=`uname -s` 18if [ "$OSTYPE" != "Linux" ]; then 19 # !!! FIXME 20 echo "This only works on x86 or x64-64 Linux at the moment." 1>&2 21 exit 1 22fi 23 24if [ "x$MAKE" == "x" ]; then 25 NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l` 26 let NCPU=$NCPU+1 27 MAKE="make -j$NCPU" 28fi 29 30BUILDBOTDIR="nacl-buildbot" 31PARENTDIR="$PWD" 32 33set -e 34set -x 35rm -f $TARBALL 36rm -rf $BUILDBOTDIR 37mkdir -p $BUILDBOTDIR 38pushd $BUILDBOTDIR 39 40# !!! FIXME: ccache? 41export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang" 42export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl" 43export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar" 44export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar" 45export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib" 46 47../configure --host=pnacl --prefix=$PWD/nacl-sdl2-installed 48$MAKE 49$MAKE install 50# Fix up a few things to a real install path 51perl -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 52mkdir -p ./usr 53mv ./nacl-sdl2-installed ./usr/local 54 55popd 56tar -cJvvf $TARBALL -C $BUILDBOTDIR usr 57rm -rf $BUILDBOTDIR 58 59set +x 60echo "All done. Final installable is in $TARBALL ..."; 61 62