1#!/bin/bash 2 3if [ -z "$SDKDIR" ]; then 4 SDKDIR="/emsdk" 5fi 6 7ENVSCRIPT="$SDKDIR/emsdk_env.sh" 8if [ ! -f "$ENVSCRIPT" ]; then 9 echo "ERROR: This script expects the Emscripten SDK to be in '$SDKDIR'." 1>&2 10 echo "ERROR: Set the \$SDKDIR environment variable to override this." 1>&2 11 exit 1 12fi 13 14TARBALL="$1" 15if [ -z $1 ]; then 16 TARBALL=sdl-emscripten.tar.xz 17fi 18 19cd `dirname "$0"` 20cd .. 21SDLBASE=`pwd` 22 23if [ -z "$MAKE" ]; then 24 OSTYPE=`uname -s` 25 if [ "$OSTYPE" == "Linux" ]; then 26 NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l` 27 let NCPU=$NCPU+1 28 elif [ "$OSTYPE" = "Darwin" ]; then 29 NCPU=`sysctl -n hw.ncpu` 30 elif [ "$OSTYPE" = "SunOS" ]; then 31 NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'` 32 else 33 NCPU=1 34 fi 35 36 if [ -z "$NCPU" ]; then 37 NCPU=1 38 elif [ "$NCPU" = "0" ]; then 39 NCPU=1 40 fi 41 42 MAKE="make -j$NCPU" 43fi 44 45echo "\$MAKE is '$MAKE'" 46 47echo "Setting up Emscripten SDK environment..." 48source "$ENVSCRIPT" 49 50echo "Setting up..." 51set -x 52cd "$SDLBASE" 53rm -rf buildbot 54mkdir buildbot 55pushd buildbot 56 57echo "Configuring..." 58emconfigure ../configure --host=wasm-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $? 59 60echo "Building..." 61emmake $MAKE || exit $? 62 63echo "Moving things around..." 64emmake $MAKE install || exit $? 65 66# Fix up a few things to a real install path 67perl -w -pi -e "s#$PWD/emscripten-sdl2-installed#/usr/local#g;" ./emscripten-sdl2-installed/lib/libSDL2.la ./emscripten-sdl2-installed/lib/pkgconfig/sdl2.pc ./emscripten-sdl2-installed/bin/sdl2-config 68mkdir -p ./usr 69mv ./emscripten-sdl2-installed ./usr/local 70tar -cJvvf $TARBALL usr 71popd 72 73exit 0 74 75# end of emscripten-buildbot.sh ... 76 77