summaryrefslogtreecommitdiff
path: root/packaging/nacl/ports
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-12-19 14:23:52 +0300
committerAndrei Karas <akaras@inbox.ru>2015-12-19 14:23:52 +0300
commitd3fe6cbd77ac51c6d62ac6fffaf72a7825e7f853 (patch)
tree2e3d31568a5cf4f56e9da81e7954b56d3eadbdda /packaging/nacl/ports
parentbc28a803b641cb7b33829a6bfd5f9a704cf21fbe (diff)
downloadplus-d3fe6cbd77ac51c6d62ac6fffaf72a7825e7f853.tar.gz
plus-d3fe6cbd77ac51c6d62ac6fffaf72a7825e7f853.tar.bz2
plus-d3fe6cbd77ac51c6d62ac6fffaf72a7825e7f853.tar.xz
plus-d3fe6cbd77ac51c6d62ac6fffaf72a7825e7f853.zip
Update nacl ports.
Diffstat (limited to 'packaging/nacl/ports')
-rw-r--r--packaging/nacl/ports/jpeg8d/build.sh36
-rw-r--r--packaging/nacl/ports/jpeg8d/pkg_info6
-rwxr-xr-xpackaging/nacl/ports/manaplus/build.sh35
-rw-r--r--packaging/nacl/ports/manaplus/pkg_info6
-rw-r--r--packaging/nacl/ports/openssl/build.sh75
-rw-r--r--packaging/nacl/ports/openssl/nacl.patch61
-rw-r--r--packaging/nacl/ports/openssl/pkg_info7
-rw-r--r--packaging/nacl/ports/regal/build.sh29
-rw-r--r--packaging/nacl/ports/regal/nacl.patch319
-rw-r--r--packaging/nacl/ports/regal/pkg_info8
-rwxr-xr-xpackaging/nacl/ports/sdl-gfx/build.sh39
-rw-r--r--packaging/nacl/ports/sdl-gfx/nacl.patch14
-rw-r--r--packaging/nacl/ports/sdl-net/build.sh9
-rw-r--r--packaging/nacl/ports/sdl-net/nacl.patch1813
-rw-r--r--packaging/nacl/ports/sdl-net/pkg_info3
-rw-r--r--packaging/nacl/ports/sdl/build.sh20
-rw-r--r--packaging/nacl/ports/sdl/nacl.patch6736
-rw-r--r--packaging/nacl/ports/sdl/pkg_info12
-rw-r--r--packaging/nacl/ports/zlib/build.sh76
-rw-r--r--packaging/nacl/ports/zlib/nacl.patch17
-rw-r--r--packaging/nacl/ports/zlib/pkg_info5
21 files changed, 2032 insertions, 7294 deletions
diff --git a/packaging/nacl/ports/jpeg8d/build.sh b/packaging/nacl/ports/jpeg8d/build.sh
deleted file mode 100644
index f37218c8d..000000000
--- a/packaging/nacl/ports/jpeg8d/build.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2011 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-if [ "${NACL_SHARED}" = "1" ]; then
- EXECUTABLES="rdjpgcom${NACL_EXEEXT} wrjpgcom${NACL_EXEEXT} \
- .libs/cjpeg${NACL_EXEEXT} .libs/djpeg${NACL_EXEEXT} \
- .libs/jpegtran${NACL_EXEEXT}"
-else
- EXECUTABLES="rdjpgcom${NACL_EXEEXT} wrjpgcom${NACL_EXEEXT} \
- cjpeg${NACL_EXEEXT} djpeg${NACL_EXEEXT} jpegtran${NACL_EXEEXT}"
-fi
-
-TestStep() {
-# export SEL_LDR_LIB_PATH=$PWD/.libs
-# if [ "${NACL_ARCH}" = "pnacl" ]; then
-# for arch in x86-32 x86-64; do
-# for exe in ${EXECUTABLES}; do
-# local exe_noext=${exe%.*}
-# WriteSelLdrScriptForPNaCl ${exe_noext} ${exe_noext}.${arch}.nexe ${arch}
-# done
-# make test
-# done
-# else
-# if [ "${NACL_SHARED}" = "1" ]; then
-# for exe in ${EXECUTABLES}; do
-# local script=$(basename ${exe%.*})
-# WriteSelLdrScript ${script} ${exe}
-# done
-# fi
-# make test
-# fi
- return 0
-}
diff --git a/packaging/nacl/ports/jpeg8d/pkg_info b/packaging/nacl/ports/jpeg8d/pkg_info
deleted file mode 100644
index 2a452b202..000000000
--- a/packaging/nacl/ports/jpeg8d/pkg_info
+++ /dev/null
@@ -1,6 +0,0 @@
-NAME=jpeg8d
-VERSION=8d
-ARCHIVE_ROOT=jpeg-8d
-URL=http://www.ijg.org/files/jpegsrc.v8d.tar.gz
-LICENSE=CUSTOM:README
-SHA1=f080b2fffc7581f7d19b968092ba9ebc234556ff
diff --git a/packaging/nacl/ports/manaplus/build.sh b/packaging/nacl/ports/manaplus/build.sh
index 5947f3b53..19f97cabd 100755
--- a/packaging/nacl/ports/manaplus/build.sh
+++ b/packaging/nacl/ports/manaplus/build.sh
@@ -3,40 +3,31 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-GitCloneStep() {
- if CheckKeyStamp clone "$URL" ; then
- Banner "Skipping git clone step"
- return
- fi
-
- local GIT_URL=${URL%@*}
- rm -rf ${SRC_DIR}
- mkdir ${SRC_DIR}
- git clone ${GIT_URL} ${SRC_DIR}
-
- TouchKeyStamp clone "$URL"
-}
-
ConfigureStep() {
Banner "Configuring ${PACKAGE_NAME}"
SetupCrossEnvironment
+
+ # export the nacl tools
export PKG_CONFIG_PATH=${NACLPORTS_LIBDIR}/pkgconfig
export PKG_CONFIG_LIBDIR=${NACLPORTS_LIBDIR}
+
export SDL_CONFIG=${NACLPORTS_LIBDIR}/../bin/sdl-config
SDL_CFLAGS=`$SDL_CONFIG --cflags`
- SDL_LIBS="-lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_gfx -lSDL_net `$SDL_CONFIG --libs` -lfreetype -ljpeg -lpng16 -lwebp -lvorbisfile -lvorbis -logg -lmikmod -lz -lbz2"
- export LIBS="-L${NACLPORTS_LIBDIR} ${SDL_LIBS} -lnacl_io -lppapi_cpp -lppapi -lpthread -lstdc++ -lRegal -lm -lc"
- autoreconf -i ${SRC_DIR}
- ${SRC_DIR}/configure \
+ SDL_LIBS="-lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_gfx -lSDL_net -lfreetype -ljpeg -lpng16 -lwebp -lvorbisfile -lvorbis -logg -lmikmod -lz -lbz2 -ltiff"
+ export LIBS="-L${NACLPORTS_LIBDIR} ${SDL_LIBS} -lnacl_io -lpthread -lRegal -lm"
+ export MANAPLUSDIR="${START_DIR}/src"
+
+# autoreconf -i ${SRC_DIR}
+ autoreconf -i ${MANAPLUSDIR}
+# ${SRC_DIR}/configure
+ ${MANAPLUSDIR}/configure \
--enable-naclbuild \
--disable-nls \
- --without-opengl \
+ --with-opengl \
--without-librt \
--without-mumble \
+ --without-dyecmd \
--host=nacl \
--prefix=${PREFIX}
}
-
-DefaultPackageInstall
-exit 0
diff --git a/packaging/nacl/ports/manaplus/pkg_info b/packaging/nacl/ports/manaplus/pkg_info
index 4b1f44ec2..aad0c16bd 100644
--- a/packaging/nacl/ports/manaplus/pkg_info
+++ b/packaging/nacl/ports/manaplus/pkg_info
@@ -1,6 +1,6 @@
NAME=manaplus
VERSION=1
-URL=git://gitorious.org/manaplus/manaplus.git
+#URL=https://gitlab.com/manaplus/manaplus.git@master
LICENSE=GPL
-DEPENDS=(sdl sdl-gfx sdl-mixer sdl-ttf sdl-image sdl-net physfs curl libxml2 libwebp)
-SHA1=ed2fe0e228a3d367017839a0cc4c548d526e516f
+DEPENDS=(sdl sdl-gfx sdl-mixer sdl-ttf sdl-image sdl-net physfs curl libxml2 libwebp zlib)
+SHA1=4178d0c709b34b811d1781fc6dc183ea4979c2b5
diff --git a/packaging/nacl/ports/openssl/build.sh b/packaging/nacl/ports/openssl/build.sh
deleted file mode 100644
index 3e0d973de..000000000
--- a/packaging/nacl/ports/openssl/build.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2012 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# The openssl build can fail when build with -jN.
-# TODO(sbc): Remove this if/when openssl is upgraded to a version that supports
-# parallel make.
-OS_JOBS=1
-BUILD_DIR=${SRC_DIR}
-INSTALL_TARGETS="install_sw INSTALL_PREFIX=${DESTDIR}"
-
-ConfigureStep() {
- if [ "${NACL_SHARED}" = "1" ] ; then
- local EXTRA_ARGS="shared"
- else
- local EXTRA_ARGS="no-dso"
- fi
-
- if [ "${NACL_LIBC}" = "newlib" ] ; then
- EXTRA_ARGS+=" -I${NACLPORTS_INCLUDE}/glibc-compat"
- # The default from MACHINE=i686 is linux-elf, which links things
- # with -ldl. However, newlib does not have -ldl. In that case,
- # make a fake machine where the build rule does not use -ldl.
- local machine="le32newlib"
- else
- local machine="i686"
- fi
-
- MACHINE=${machine} CC=${NACLCC} AR=${NACLAR} RANLIB=${NACLRANLIB} \
- LogExecute ./config \
- --prefix=${PREFIX} no-asm no-hw no-krb5 ${EXTRA_ARGS} -D_GNU_SOURCE
-
- HackStepForNewlib
-}
-
-
-HackStepForNewlib() {
- if [ "${NACL_SHARED}" = "1" ]; then
- git checkout apps/Makefile
- git checkout test/Makefile
- return
- fi
-
- # apps/Makefile links programs that require socket(), etc.
- # Stub it out until we link against nacl_io or something.
- echo "all clean install: " > apps/Makefile
- # test/Makefile is similar -- stub out, but keep the original for testing.
- git checkout test/Makefile
- mv test/Makefile test/Makefile.orig
- echo "all clean install: " > test/Makefile
-}
-
-
-BuildStep() {
- LogExecute make clean
- DefaultBuildStep
-}
-
-
-InstallStep() {
- DefaultInstallStep
- # openssl (for some reason) installs shared libraries with 555 (i.e.
- # not writable. This causes issues when create_nmf copies the libraries
- # and then tries to overwrite them later.
- if [ "${NACL_SHARED}" = "1" ] ; then
- LogExecute chmod 644 ${DESTDIR_LIB}/libssl.so.*
- LogExecute chmod 644 ${DESTDIR_LIB}/libcrypto.so.*
- fi
-}
-
-
-TestStep() {
- return 0
-}
diff --git a/packaging/nacl/ports/openssl/nacl.patch b/packaging/nacl/ports/openssl/nacl.patch
deleted file mode 100644
index 46b257ca4..000000000
--- a/packaging/nacl/ports/openssl/nacl.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-diff -Naur openssl-1.0.1e_old/config openssl-1.0.1e/config
---- openssl-1.0.1e_old/config 2013-02-11 07:26:04.000000000 -0800
-+++ openssl-1.0.1e/config 2013-10-23 13:04:35.247827139 -0700
-@@ -660,6 +660,7 @@
- #fi
- OUT="linux64-s390x"
- ;;
-+ le32newlib-*-linux?) OUT="linux-le32newlib" ;;
- x86_64-*-linux?) OUT="linux-x86_64" ;;
- *86-*-linux2) OUT="linux-elf"
- if [ "$GCCVER" -gt 28 ]; then
-diff -Naur openssl-1.0.1e_old/Configure openssl-1.0.1e/Configure
---- openssl-1.0.1e_old/Configure 2013-02-11 07:26:04.000000000 -0800
-+++ openssl-1.0.1e/Configure 2013-10-23 15:18:50.833411949 -0700
-@@ -362,6 +362,11 @@
- "linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
- "linux-x86_64", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
- "linux64-s390x", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-+
-+#### NaCl Newlib version (much like linux-elf, which NaCl Glibc uses)
-+#### Use linux-aout instead of linux-elf, since it's statically linked.
-+"linux-le32newlib", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out",
-+
- #### So called "highgprs" target for z/Architecture CPUs
- # "Highgprs" is kernel feature first implemented in Linux 2.6.32, see
- # /proc/cpuinfo. The idea is to preserve most significant bits of
-diff -Naur openssl-1.0.1e_old/crypto/rand/rand_unix.c openssl-1.0.1e/crypto/rand/rand_unix.c
---- openssl-1.0.1e_old/crypto/rand/rand_unix.c 2013-02-11 07:26:04.000000000 -0800
-+++ openssl-1.0.1e/crypto/rand/rand_unix.c 2013-10-23 13:00:36.981427165 -0700
-@@ -133,7 +133,30 @@
- # define FD_SETSIZE (8*sizeof(fd_set))
- #endif
-
--#if defined(OPENSSL_SYS_VOS)
-+#if defined(__native_client__)
-+#include <stdlib.h>
-+#include <irt.h>
-+/* TODO(sehr): remove this patch when nacl_io can handle /dev/urandom. */
-+int RAND_poll(void)
-+{
-+ unsigned char buf[ENTROPY_NEEDED];
-+ size_t n = 0;
-+ struct nacl_irt_random rand_intf;
-+ if (nacl_interface_query(NACL_IRT_RANDOM_v0_1, &rand_intf, sizeof(rand_intf))
-+ != sizeof(rand_intf))
-+ abort();
-+ while (n < sizeof(buf)) {
-+ size_t nread;
-+ if (rand_intf.get_random_bytes((unsigned char *)buf+n,
-+ ENTROPY_NEEDED-n, &nread) != 0)
-+ abort();
-+ n += nread;
-+ }
-+ RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
-+ memset(buf, 0, sizeof(buf));
-+ return 1;
-+}
-+#elif defined(OPENSSL_SYS_VOS)
-
- /* The following algorithm repeatedly samples the real-time clock
- (RTC) to generate a sequence of unpredictable data. The algorithm
diff --git a/packaging/nacl/ports/openssl/pkg_info b/packaging/nacl/ports/openssl/pkg_info
deleted file mode 100644
index b76b8a2ca..000000000
--- a/packaging/nacl/ports/openssl/pkg_info
+++ /dev/null
@@ -1,7 +0,0 @@
-NAME=openssl
-VERSION=1.0.1g
-URL=http://www.openssl.org/source/openssl-1.0.1g.tar.gz
-LICENSE=CUSTOM:LICENSE
-BUILD_OS=linux
-DEPENDS=(glibc-compat)
-SHA1=b28b3bcb1dc3ee7b55024c9f795be60eb3183e3c
diff --git a/packaging/nacl/ports/regal/build.sh b/packaging/nacl/ports/regal/build.sh
deleted file mode 100644
index 5ba6bd0bf..000000000
--- a/packaging/nacl/ports/regal/build.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2013 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-BUILD_DIR=${SRC_DIR}
-
-MAKE_ARGS="SYSTEM=nacl-${NACL_ARCH} NACL_LIBC=${NACL_LIBC} -j${OS_JOBS}"
-
-BuildStep() {
- LogExecute make ${MAKE_ARGS} clobber
- LogExecute make ${MAKE_ARGS} regal.lib
-}
-
-TestStep() {
-# LogExecute make ${MAKE_ARGS} test
- return 0
-}
-
-InstallStep() {
- MakeDir ${DESTDIR_LIB}
- MakeDir ${DESTDIR_INCLUDE}
- LogExecute cp -a lib/nacl-${NACL_ARCH}/libRegal*.a ${DESTDIR_LIB}/
- LogExecute cp -a lib/nacl-${NACL_ARCH}/libglslopt.a ${DESTDIR_LIB}/
- if [ "${NACL_SHARED}" = 1 ]; then
- LogExecute cp -a lib/nacl-${NACL_ARCH}/libRegal*.so* ${DESTDIR_LIB}/
- fi
- LogExecute cp -r include/GL ${DESTDIR_INCLUDE}/
-}
diff --git a/packaging/nacl/ports/regal/nacl.patch b/packaging/nacl/ports/regal/nacl.patch
deleted file mode 100644
index be592b3a7..000000000
--- a/packaging/nacl/ports/regal/nacl.patch
+++ /dev/null
@@ -1,319 +0,0 @@
-diff --git a/Makefile b/Makefile
-index 911a3c6..e45d3c4 100644
---- a/Makefile
-+++ b/Makefile
-@@ -39,6 +39,7 @@ include Makefile.dreamtorus
- include Makefile.dreamtorus_static
- include Makefile.alphatorus
- include Makefile.tiger
-+include Makefile.nacl
-
- # Testing
-
-diff --git a/Makefile.glu b/Makefile.glu
-index 9df0418..3043f07 100644
---- a/Makefile.glu
-+++ b/Makefile.glu
-@@ -36,7 +36,6 @@ GLU.OBJS := $(GLU.OBJS:.c=.o) $(GLU.OBJS:.cc=.o)
- GLU.OBJS := $(filter %.o,$(GLU.OBJS))
- GLU.DEPS := $(GLU.OBJS:.o=.d)
- GLU.LIBS := -Llib/$(SYSTEM) -lRegal
--GLU.LIBS += -lstdc++
- GLU.LIBS += -pthread -lm
-
- -include $(GLU.DEPS)
-diff --git a/Makefile.nacl b/Makefile.nacl
-index e5fa8f8..6a6cb90 100644
---- a/Makefile.nacl
-+++ b/Makefile.nacl
-@@ -36,8 +36,8 @@ NACL.SRCS.NAMES := $(notdir $(NACL.SRCS))
- NACL.OBJS := $(addprefix tmp/$(SYSTEM)/nacl/static/,$(NACL.SRCS.NAMES))
- NACL.OBJS := $(NACL.OBJS:.c=.o)
- NACL.CFLAGS := -Iinclude
--NACL.LIBS += -Llib/$(SYSTEM) -lRegal
--NACL.LIBS += -lpng -lz -lm -pthread -lppapi -lppapi_gles2 -lstdc++
-+NACL.LIBS += -Llib/$(SYSTEM) -lRegal -lglslopt
-+NACL.LIBS += -lpng -lz -lm -pthread -lppapi -lppapi_gles2
-
- -include $(NACL.DEPS)
-
-diff --git a/Makefile.regal b/Makefile.regal
-index 04a1c88..147a391 100644
---- a/Makefile.regal
-+++ b/Makefile.regal
-@@ -18,9 +18,9 @@ include build/regal.inc
- export:
- python scripts/Export.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir .
-
--# Shared library target not currently supported for NaCL or emscripten
-+# Shared library target not currently supported for emscripten
-
--ifneq ($(filter nacl% emscripten%,$(SYSTEM)),)
-+ifneq ($(filter emscripten%,$(SYSTEM)),)
- REGAL.SHARED :=
- endif
-
-@@ -35,7 +35,7 @@ all:: regal.lib
-
- clean:: regal.clean
-
--REGAL.LDFLAGS := -lstdc++ -pthread -lm
-+REGAL.LDFLAGS := -pthread -lm
- REGAL.LIBS :=
-
- ifeq ($(filter nacl%,$(SYSTEM)),)
-@@ -105,7 +105,7 @@ endif
-
- # Emscripten options
-
--ifneq ($(filter nacl% emscripten%,$(SYSTEM)),)
-+ifneq ($(filter emscripten%,$(SYSTEM)),)
- REGAL.CFLAGS += -DREGAL_SYS_EMSCRIPTEN=1 -DREGAL_SYS_EGL=1 -DREGAL_SYS_ES2=1
- REGAL.CFLAGS += -DREGAL_HTTP=0
- REGAL.CFLAGS += -DREGAL_STATISTICS=0
-@@ -196,12 +196,16 @@ REGAL.SDEPS := $(LIBS.SOBJS:.o=.d)
-
- REGAL.LIBS += $(LDFLAGS.X11)
-
--ifneq ($(filter linux%,$(SYSTEM)),)
-+ifneq ($(filter nacl% linux%,$(SYSTEM)),)
-+ifeq ($(NACL_LIBC),newlib)
-+REGAL.SHARED :=
-+else
- REGAL.SONAME := lib$(NAME).so.$(SO_MAJOR)
- REGAL.DEVLNK := lib$(NAME).so
- REGAL.SHARED := lib$(NAME).so.$(SO_VERSION)
- REGAL.LDFLAGS.SO := $(LDFLAGS.SO) $(LDFLAGS.DYNAMIC) -Wl,-soname=$(REGAL.SONAME)
- endif
-+endif
-
- ifneq ($(filter darwin%,$(SYSTEM)),)
- REGAL.SONAME := lib$(NAME).$(SO_MAJOR).dylib
-@@ -235,12 +239,6 @@ ifdef APITRACE.STATIC
- lib/$(SYSTEM)/$(REGAL.STATIC): lib/$(SYSTEM)/$(APITRACE.STATIC) lib/$(SYSTEM)/$(SNAPPY.STATIC)
- endif
-
--ifneq ($(filter nacl%,$(SYSTEM)),)
--ifeq ($(NACL_LIBC),glibc)
--regal.lib: lib/$(SYSTEM)/$(REGAL.SHARED)
--endif
--endif
--
- lib/$(SYSTEM)/$(REGAL.STATIC): lib/$(SYSTEM)/$(GLSLOPT.STATIC) lib/$(SYSTEM)/$(PCRE.STATIC) lib/$(SYSTEM)/$(LIBPNG.STATIC) lib/$(SYSTEM)/$(ZLIB.STATIC) $(REGAL.OBJS)
- @mkdir -p $(dir $@)
- $(LOG_AR)$(CCACHE) $(AR) cr $@ $(REGAL.OBJS)
-diff --git a/Makefile.regaltest b/Makefile.regaltest
-index fdebf3a..98a419f 100644
---- a/Makefile.regaltest
-+++ b/Makefile.regaltest
-@@ -7,7 +7,7 @@ include build/common.inc
-
- # Not supported for NaCL - Revisit
-
--ifeq ($(filter nacl% emscripten%,$(SYSTEM)),)
-+ifeq ($(filter emscripten%,$(SYSTEM)),)
-
- include build/regaltest.inc
-
-@@ -75,7 +75,7 @@ test: bin/$(SYSTEM)/regaltest$(BIN_EXTENSION)
- ifeq ($(filter nacl%,$(SYSTEM)),)
- $^
- else
-- "$(NACL_SEL_LDR)" -a -B "$(NACL_IRT)" -- $^
-+ "$(NACL_SDK_ROOT)/tools/sel_ldr.py" $^
- endif
- endif
-
-diff --git a/Makefile.regalw b/Makefile.regalw
-index 3577769..012938e 100644
---- a/Makefile.regalw
-+++ b/Makefile.regalw
-@@ -18,9 +18,9 @@ REGALW.SHARED ?= libRegal.so
-
- REGALW.STATIC :=
-
--# Shared library target not currently supported for NaCL or emscripten
-+# Shared library target not currently supported for emscripten
-
--ifneq ($(filter nacl% emscripten%,$(SYSTEM)),)
-+ifneq ($(filter emscripten%,$(SYSTEM)),)
- REGALW.SHARED :=
- endif
-
-@@ -31,7 +31,7 @@ all:: regalw.lib
-
- clean:: regalw.clean
-
--REGALW.LDFLAGS := -lstdc++ -pthread -lm
-+REGALW.LDFLAGS := -pthread -lm
- REGALW.LIBS :=
-
- REGALW.SRCS := $(REGAL.CXX)
-diff --git a/README.rst b/README.rst
-index a8d5d84..600c336 100644
---- a/README.rst
-+++ b/README.rst
-@@ -380,9 +380,7 @@ PPAPI and NaCl
-
- * NACL_SDK_ROOT needs to be set
-
--* NACL_LIBC=newlib is the default, specify NACL_LIBC=glibc as an alternative
--
--* regaltest requires pepper_26 or newer
-+* NACL_LIBC=newlib is the default, specify glibc or pnacl as alternatives
-
- Questions and Answers
- =====================
-diff --git a/build/common.inc b/build/common.inc
-index 6049b68..5ae16e0 100644
---- a/build/common.inc
-+++ b/build/common.inc
-@@ -51,12 +51,12 @@ OPT ?= $(CFLAGS.RELEASE)
- endif
-
- ifndef V
--LOG_CXX ?= @echo " [CXX] $@";
--LOG_CC ?= @echo " [CC] $@";
--LOG_LD ?= @echo " [LD] $@";
--LOG_AR ?= @echo " [AR] $@";
-+LOG_CXX ?= @echo " [CXX] $@";
-+LOG_CC ?= @echo " [CC] $@";
-+LOG_LD ?= @echo " [LD] $@";
-+LOG_AR ?= @echo " [AR] $@";
- LOG_RANLIB ?= @echo " [RANLIB] $@";
--LOG_STRIP ?= @echo " [STRIP] $@";
-+LOG_STRIP ?= @echo " [STRIP] $@";
- endif
-
- INCLUDE ?= -Iinclude
-diff --git a/build/glu.inc b/build/glu.inc
-index 3788977..f4dd54f 100644
---- a/build/glu.inc
-+++ b/build/glu.inc
-@@ -102,9 +102,10 @@ GLU.CXX += src/glu/libnurbs/nurbtess/searchTree.cc
- GLU.CFLAGS := -Isrc/glu/include -Isrc/glu/libnurbs/interface -Isrc/glu/libnurbs/internals -Isrc/glu/libnurbs/nurbtess
- GLU.CFLAGS += -DLIBRARYBUILD
-
--GLU.SHARED := libRegalGLU.so
--GLU.STATIC := libRegalGLUlib.a
-+GLU.STATIC := libRegalGLU.a
-
- ifneq ($(filter darwin%,$(SYSTEM)),)
- GLU.SHARED := libRegalGLU.dylib
-+else
-+GLU.SHARED := libRegalGLU.so
- endif
-diff --git a/build/pcre.inc b/build/pcre.inc
-index d253c38..7a941c6 100644
---- a/build/pcre.inc
-+++ b/build/pcre.inc
-@@ -65,7 +65,7 @@ PCRE.C += src/pcre/pcre_get.c
- PCRE.C += src/pcre/pcre_globals.c
- #PCRE.C += src/pcre/pcregrep.c
- PCRE.C += src/pcre/pcre_jit_compile.c
--PCRE.C += src/pcre/pcre_jit_test.c
-+#PCRE.C += src/pcre/pcre_jit_test.c
- PCRE.C += src/pcre/pcre_maketables.c
- PCRE.C += src/pcre/pcre_newline.c
- PCRE.C += src/pcre/pcre_ord2utf8.c
-diff --git a/build/regal.inc b/build/regal.inc
-index 32e7933..71ec2a6 100644
---- a/build/regal.inc
-+++ b/build/regal.inc
-@@ -153,5 +153,5 @@ ifeq ($(PROFILE_OS),Windows)
- REGAL.INCLUDE += -Isrc/glsl/include/c99
- endif
-
--REGAL.STATIC ?= libRegallib.a
-+REGAL.STATIC ?= libRegal.a
- REGAL.SHARED ?= libRegal.so
-diff --git a/config/Makefile.nacl-pnacl b/config/Makefile.nacl-pnacl
-index a0ee95c..9bfbe1d 100644
---- a/config/Makefile.nacl-pnacl
-+++ b/config/Makefile.nacl-pnacl
-@@ -2,7 +2,7 @@ NACL_ARCH := pnacl
-
- include config/nacl.inc
-
--NACL_TOOLCHAIN := $(NACL_SDK_ROOT)/toolchain/$(NACL_OS)_x86_pnacl/$(NACL_LIBC)
-+NACL_TOOLCHAIN := $(NACL_SDK_ROOT)/toolchain/$(NACL_OS)_pnacl
-
- CC := $(NACL_TOOLCHAIN)/bin/pnacl-clang
- CXX := $(NACL_TOOLCHAIN)/bin/pnacl-clang++
-@@ -13,7 +13,6 @@ STRIP ?=
-
- BIN_EXTENSION = .pexe
- EXT.DYNAMIC = so
--LDFLAGS.EXTRA =
- LIBDIR =
- CFLAGS.EXTRA +=
- LDFLAGS.EXTRA +=
-diff --git a/config/nacl.inc b/config/nacl.inc
-index d86d4e7..66a9b05 100644
---- a/config/nacl.inc
-+++ b/config/nacl.inc
-@@ -48,8 +48,12 @@ export CCACHE_COMPILERCHECK=echo $(SYSTEM)$(NACL_LIBC)$(NACL_SDK_ROOT)
- ifeq ($(NACL_ARCH),i686)
- NACL_LIBTYPE=$(NACL_LIBC)_x86_32
- else
-+ifeq ($(NACL_ARCH),pnacl)
-+NACL_LIBTYPE=$(NACL_ARCH)
-+else
- NACL_LIBTYPE=$(NACL_LIBC)_$(NACL_ARCH)
- endif
-+endif
-
- ifeq ($(MODE),debug)
- LDFLAGS.EXTRA += -L$(NACL_SDK_ROOT)/ports/lib/$(NACL_LIBTYPE)/Debug
-diff --git a/src/apitrace/common/os_posix.cpp b/src/apitrace/common/os_posix.cpp
-index 28abb97..b49fd40 100644
---- a/src/apitrace/common/os_posix.cpp
-+++ b/src/apitrace/common/os_posix.cpp
-@@ -123,7 +123,7 @@ getCurrentDir(void)
- size_t size = PATH_MAX;
- char *buf = path.buf(size);
-
-- getcwd(buf, size);
-+ buf = getcwd(buf, size);
- buf[size - 1] = 0;
-
- path.truncate();
-diff --git a/src/boost/boost/print/detail.hpp b/src/boost/boost/print/detail.hpp
-index 9cb3643..49aa043 100644
---- a/src/boost/boost/print/detail.hpp
-+++ b/src/boost/boost/print/detail.hpp
-@@ -325,7 +325,7 @@ inline size_t unsigned_length(const unsigned long val) { return unsigned_length(
- inline size_t unsigned_length(const unsigned long val) { return unsigned_length(static_cast<boost::uint32_t>(val)); }
- #endif
-
--#if defined(__native_client__) && (defined(__i386) || defined(__x86_64) || defined(__arm__))
-+#if defined(__native_client__)
- inline size_t unsigned_length(const unsigned long val) { return unsigned_length(static_cast<boost::uint32_t>(val)); }
- #endif
-
-diff --git a/src/regal/RegalShader.cpp b/src/regal/RegalShader.cpp
-index d59249f..65cceeb 100644
---- a/src/regal/RegalShader.cpp
-+++ b/src/regal/RegalShader.cpp
-@@ -233,7 +233,7 @@ namespace Shader {
- bool status;
- };
-
-- static inline void debug_print_ir (const char* name, exec_list* ir, _mesa_glsl_parse_state* state, void* memctx)
-+ static inline void REGAL_UNUSED debug_print_ir (const char* name, exec_list* ir, _mesa_glsl_parse_state* state, void* memctx)
- {
- //_mesa_print_ir (ir, state);
- Error( "GLSLOptimize debug **** ", name, ":",
-diff --git a/src/regal/RegalUtil.h b/src/regal/RegalUtil.h
-index 4bf9e75..0df4078 100644
---- a/src/regal/RegalUtil.h
-+++ b/src/regal/RegalUtil.h
-@@ -56,7 +56,7 @@
- #endif
-
- #ifndef REGAL_UNUSED
--#if defined(__GNUC__) && !defined(__clang__)
-+#if defined(__GNUC__)
- #define REGAL_UNUSED __attribute__((unused))
- #else
- #define REGAL_UNUSED
diff --git a/packaging/nacl/ports/regal/pkg_info b/packaging/nacl/ports/regal/pkg_info
deleted file mode 100644
index a76111b2f..000000000
--- a/packaging/nacl/ports/regal/pkg_info
+++ /dev/null
@@ -1,8 +0,0 @@
-NAME=regal
-VERSION=f106e4cd
-URL=https://github.com/p3/regal/archive/f106e4cd/Regal-f106e4cd.tar.gz
-ARCHIVE_ROOT=regal-f106e4cd0e780b0995a26498365dceb0ed025832
-DEPENDS=(libpng)
-DISABLED_ARCH=(pnacl)
-DISABLED_LIBC=(bionic)
-SHA1=6e8cd18c44a83e7eb17d123b5e0ec8cdceff9ea2
diff --git a/packaging/nacl/ports/sdl-gfx/build.sh b/packaging/nacl/ports/sdl-gfx/build.sh
index e1572c9a1..f7bfe8572 100755
--- a/packaging/nacl/ports/sdl-gfx/build.sh
+++ b/packaging/nacl/ports/sdl-gfx/build.sh
@@ -1,36 +1,11 @@
-#!/bin/bash
-# Copyright (c) 2011 The Native Client Authors. All rights reserved.
+# Copyright (c) 2014 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#source pkg_info
-#source ../../build_tools/common.sh
+# sdl2-config --libs includes -lppapi which cannot be linked
+# with shared libraries, so for now we disable the shared build.
+# In the future we could instead filter out this flag or remove
+# it and force SDL2 programs to add it themselves.
+EXTRA_CONFIGURE_ARGS="--enable-mmx=no --host=nacl --disable-shared"
+export RANLIB=${NACLRANLIB}
-ConfigureStep() {
- Banner "Configuring ${PACKAGE_NAME}"
-
- export SDL_CONFIG=${NACLPORTS_LIBDIR}/../bin/sdl-config
- SDL_CFLAGS=`$SDL_CONFIG --cflags`
- SDL_LIBS=`$SDL_CONFIG --libs`
-
- # export the nacl tools
- export CC=${NACLCC}
- export CXX=${NACLCXX}
- export AR=${NACLAR}
- export RANLIB=${NACLRANLIB}
- export PKG_CONFIG_PATH=${NACLPORTS_LIBDIR}/pkgconfig
- export PKG_CONFIG_LIBDIR=${NACLPORTS_LIBDIR}
- export CFLAGS="${NACLPORTS_CFLAGS} $SDL_CFLAGS"
- export CXXFLAGS="${NACLPORTS_CXXFLAGS} $SDL_CFLAGS"
- export LDFLAGS=${NACLPORTS_LDFLAGS}
- export PATH=${NACL_BIN_PATH}:${PATH};
- export LIBS="-L${NACLPORTS_LIBDIR} -lppapi -lppapi_gles2 -lppapi_cpp -lnacl_io -lpthread -lstdc++ -lm -lnosys $SDL_LIBS"
- ${SRC_DIR}/autogen.sh
- ${SRC_DIR}/configure \
- --enable-mmx=no \
- --host=nacl \
- --prefix=${PREFIX}
-}
-
-PackageInstall
-exit 0
diff --git a/packaging/nacl/ports/sdl-gfx/nacl.patch b/packaging/nacl/ports/sdl-gfx/nacl.patch
deleted file mode 100644
index e01d8e85c..000000000
--- a/packaging/nacl/ports/sdl-gfx/nacl.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- SDL_gfx-2.0.24/configure.in 2012-08-05 20:25:55.000000000 +0400
-+++ SDL_gfx-2.0.24-nacl/configure.in 2013-10-29 22:58:03.825301123 +0400
-@@ -117,10 +117,7 @@
- fi
-
- dnl Check for SDL
--AM_PATH_SDL($SDL_VERSION,
-- :,
-- AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
--)
-+
- CFLAGS="$CFLAGS $SDL_CFLAGS"
- # Remove dependencies from 'sdl-config' not meant for us libraries:
- SDL_LIBS=$(echo "$SDL_LIBS" | sed -e 's/-lmingw32//' -e 's/-lSDLmain//')
diff --git a/packaging/nacl/ports/sdl-net/build.sh b/packaging/nacl/ports/sdl-net/build.sh
new file mode 100644
index 000000000..781e4fcfc
--- /dev/null
+++ b/packaging/nacl/ports/sdl-net/build.sh
@@ -0,0 +1,9 @@
+# Copyright (c) 2014 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# sdl2-config --libs includes -lppapi which cannot be linked
+# with shared libraries, so for now we disable the shared build.
+# In the future we could instead filter out this flag or remove
+# it and force SDL2 programs to add it themselves.
+EXTRA_CONFIGURE_ARGS=--disable-shared
diff --git a/packaging/nacl/ports/sdl-net/nacl.patch b/packaging/nacl/ports/sdl-net/nacl.patch
index 8d7fd7e52..f07fdcffd 100644
--- a/packaging/nacl/ports/sdl-net/nacl.patch
+++ b/packaging/nacl/ports/sdl-net/nacl.patch
@@ -1,251 +1,1590 @@
-diff -urN SDL_net-1.2.7/SDL_net.h SDL_net-1.2.7-nacl/SDL_net.h
---- SDL_net-1.2.7/SDL_net.h 2007-07-15 09:59:03.000000000 +0400
-+++ SDL_net-1.2.7-nacl/SDL_net.h 2013-11-03 00:01:10.871933000 +0400
-@@ -30,7 +30,7 @@
- #include "SDL_version.h"
- #include "begin_code.h"
+diff -Naur a/Makefile.am b/Makefile.am
+--- a/Makefile.am 2007-07-21 09:26:47.000000000 +0400
++++ b/Makefile.am 2015-11-28 01:09:05.901015000 +0300
+@@ -8,7 +8,7 @@
+ libSDL_net_la_SOURCES = \
+ SDLnet.c \
+- SDLnetTCP.c \
++ SDLnetTCP.cpp \
+ SDLnetUDP.c \
+ SDLnetselect.c \
+ SDLnetsys.h
+diff -Naur a/Makefile.in b/Makefile.in
+--- a/Makefile.in 2007-07-21 11:55:27.000000000 +0400
++++ b/Makefile.in 2015-11-28 01:09:18.049151000 +0300
+@@ -244,7 +244,7 @@
+
+ libSDL_net_la_SOURCES = \
+ SDLnet.c \
+- SDLnetTCP.c \
++ SDLnetTCP.cpp \
+ SDLnetUDP.c \
+ SDLnetselect.c \
+ SDLnetsys.h
+diff -Naur a/SDLnetselect.c b/SDLnetselect.c
+--- a/SDLnetselect.c 2007-07-02 06:04:03.000000000 +0400
++++ b/SDLnetselect.c 2015-11-30 00:33:29.895731000 +0300
+@@ -111,109 +111,24 @@
+ first. This function returns the number of sockets ready for reading,
+ or -1 if there was an error with the select() system call.
+ */
+-#ifdef MACOS_OPENTRANSPORT
+-int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
+-{
+-Uint32 stop;
+-int numReady;
+-
+- /* Loop, polling the network devices */
+-
+- stop = SDL_GetTicks() + timeout;
+-
+- do
+- {
+- OTResult status;
+- size_t numBytes;
+- int i;
+-
+- numReady = 0;
+-
+- for (i = set->numsockets-1;i >= 0;--i)
+- {
+- status = OTLook( set->sockets[i]->channel );
+- if( status > 0 )
+- {
+- switch( status )
+- {
+- case T_UDERR:
+- OTRcvUDErr( set->sockets[i]->channel , nil);
+- break;
+- case T_DISCONNECT:
+- OTRcvDisconnect( set->sockets[i]->channel, nil );
+- break;
+- case T_ORDREL:
+- OTRcvOrderlyDisconnect(set->sockets[i]->channel );
+- break;
+- case T_CONNECT:
+- OTRcvConnect( set->sockets[i]->channel, nil );
+- break;
+-
+-
+- default:
+- set->sockets[i]->ready = 1;
+- ++numReady;
+- }
+- }
+- else if( OTCountDataBytes(set->sockets[i]->channel, &numBytes ) != kOTNoDataErr )
+- {
+- set->sockets[i]->ready = 1;
+- ++numReady;
+- }
+- else
+- set->sockets[i]->ready = 0;
+- }
+-
+- } while (!numReady && (SDL_GetTicks() < stop));
+
+- return(numReady);
+-}
+-#else
+ int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
+ {
+ int i;
+- SOCKET maxfd;
+ int retval;
+- struct timeval tv;
+- fd_set mask;
-
-+#define u_int32_t uint32_t
+- /* Find the largest file descriptor */
+- maxfd = 0;
+- for ( i=set->numsockets-1; i>=0; --i ) {
+- if ( set->sockets[i]->channel > maxfd ) {
+- maxfd = set->sockets[i]->channel;
+- }
+- }
+-
+- /* Check the file descriptors for available data */
+- do {
+- errno = 0;
+-
+- /* Set up the mask of file descriptors */
+- FD_ZERO(&mask);
+- for ( i=set->numsockets-1; i>=0; --i ) {
+- FD_SET(set->sockets[i]->channel, &mask);
+- }
+
+- /* Set up the timeout */
+- tv.tv_sec = timeout/1000;
+- tv.tv_usec = (timeout%1000)*1000;
++ retval = 0;
- /* Set up for C function definitions, even when using C++ */
- #ifdef __cplusplus
-
-diff -urN /dev/null SDL_net-1.2.7-nacl/inet_addr.c
---- /dev/null 2013-11-02 22:47:51.150226312 +0400
-+++ SDL_net-1.2.7-nacl/inet_addr.c 2013-11-02 23:59:09.523930000 +0400
-@@ -0,0 +1,201 @@
-+/* $KAME: inet_addr.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */
+- /* Look! */
+- retval = select(maxfd+1, &mask, NULL, NULL, &tv);
+- } while ( errno == EINTR );
+-
+- /* Mark all file descriptors ready that have data available */
+- if ( retval > 0 ) {
+- for ( i=set->numsockets-1; i>=0; --i ) {
+- if ( FD_ISSET(set->sockets[i]->channel, &mask) ) {
+- set->sockets[i]->ready = 1;
+- }
+- }
++ for (i = 0; i < set->numsockets; ++i) {
++ if (set->sockets[i]->ready)
++ retval++;
++ else
++#warning SDLNet_CheckSockets can work only with TCPsockets!
++ SDLNet_TCP_Recv (set->sockets[i], NULL, 0);
+ }
+- return(retval);
+
++ return retval;
+ }
+-#endif /* MACOS_OPENTRANSPORT */
+
+ /* Free a set of sockets allocated by SDL_NetAllocSocketSet() */
+ extern void SDLNet_FreeSocketSet(SDLNet_SocketSet set)
+diff -Naur a/SDLnetTCP.c b/SDLnetTCP.c
+--- a/SDLnetTCP.c 2007-07-15 09:55:42.000000000 +0400
++++ b/SDLnetTCP.c 1970-01-01 03:00:00.000000000 +0300
+@@ -1,953 +0,0 @@
+-/*
+- SDL_net: An example cross-platform network library for use with SDL
+- Copyright (C) 1997-2004 Sam Lantinga
+-
+- This library is free software; you can redistribute it and/or
+- modify it under the terms of the GNU Library General Public
+- License as published by the Free Software Foundation; either
+- version 2 of the License, or (at your option) any later version.
+-
+- This library is distributed in the hope that it will be useful,
+- but WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- Library General Public License for more details.
+-
+- You should have received a copy of the GNU Library General Public
+- License along with this library; if not, write to the Free
+- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-
+- Sam Lantinga
+- slouken@libsdl.org
+-*/
+-
+-/* $Id: SDLnetTCP.c 3280 2007-07-15 05:55:42Z slouken $ */
+-
+-#include "SDLnetsys.h"
+-#include "SDL_net.h"
+-
+-/* The network API for TCP sockets */
+-
+-/* Since the UNIX/Win32/BeOS code is so different from MacOS,
+- we'll just have two completely different sections here.
+-*/
+-
+-#ifdef MACOS_OPENTRANSPORT
+-
+-#include <Events.h>
+-#include <Threads.h>
+-#include <OpenTransport.h>
+-#include <OpenTptInternet.h>
+-#include <OTDebug.h>
+-
+-struct _TCPsocket {
+- int ready;
+- SOCKET channel;
+-
+- // These are taken from GUSI interface.
+- // I'm not sure if it's really necessary here yet
+- // ( masahiro minami<elsur@aaa.letter.co.jp> )
+- // ( 01/02/19 )
+- OTEventCode curEvent;
+- OTEventCode newEvent;
+- OTEventCode event;
+- OTEventCode curCompletion;
+- OTEventCode newCompletion;
+- OTEventCode completion;
+- OSStatus error;
+- TEndpointInfo info;
+- Boolean readShutdown;
+- Boolean writeShutdown;
+- Boolean connected;
+- OTConfigurationRef config; // Master configuration. you can clone this.
+- TCPsocket nextListener;
+- // ( end of new members --- masahiro minami<elsur@aaa.letter.co.jp>
+-
+- IPaddress remoteAddress;
+- IPaddress localAddress;
+- int sflag;
+-
+- // Maybe we don't need this---- it's from original SDL_net
+- // (masahiro minami<elsur@aaa.letter.co.jp>)
+- // ( 01/02/20 )
+- int rcvdPassConn;
+-};
+-
+-// To be used in WaitNextEvent() here and there....
+-// (010311 masahiro minami<elsur@aaa.letter.co.jp>)
+-EventRecord macEvent;
+-
+-#if TARGET_API_MAC_CARBON
+-/* for Carbon */
+-OTNotifyUPP notifier;
+-#endif
+-
+-/* Input: ep - endpointref on which to negotiate the option
+- enableReuseIPMode - desired option setting - true/false
+- Return: kOTNoError indicates that the option was successfully negotiated
+- OSStatus is an error if < 0, otherwise, the status field is
+- returned and is > 0.
+-
+- IMPORTANT NOTE: The endpoint is assumed to be in synchronous more, otherwise
+- this code will not function as desired
+-*/
+-
+-/*
+-NOTE: As this version is written async way, we don't use this function...
+-(010526) masahiro minami<elsur@aaa.letter.co.jp>
+-*/
+-/*
+-OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
+-
+-{
+- UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte Option size
+- TOption* opt; // option ptr to make items easier to access
+- TOptMgmt req;
+- TOptMgmt ret;
+- OSStatus err;
+-
+- if (!OTIsSynchronous(ep))
+- {
+- return (-1);
+- }
+- opt = (TOption*)buf; // set option ptr to buffer
+- req.opt.buf = buf;
+- req.opt.len = sizeof(buf);
+- req.flags = T_NEGOTIATE; // negotiate for option
+-
+- ret.opt.buf = buf;
+- ret.opt.maxlen = kOTFourByteOptionSize;
+-
+- opt->level = INET_IP; // dealing with an IP Level function
+- opt->name = IP_REUSEADDR;
+- opt->len = kOTFourByteOptionSize;
+- opt->status = 0;
+- *(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
+-
+- err = OTOptionManagement(ep, &req, &ret);
+-
+- // if no error then return the option status value
+- if (err == kOTNoError)
+- {
+- if (opt->status != T_SUCCESS)
+- err = opt->status;
+- else
+- err = kOTNoError;
+- }
+-
+- return err;
+-}
+-*/
+-
+-/* A helper function for Mac OpenTransport support*/
+-// This function is a complete copy from GUSI
+-// ( masahiro minami<elsur@aaa.letter.co.jp> )
+-// ( 01/02/19 )
+-static __inline__ Uint32 CompleteMask(OTEventCode code)
+-{
+- return 1 << (code & 0x1F);
+-}
+-
+-/* Notifier for async OT calls */
+-static pascal void AsyncTCPNotifier( TCPsocket sock, OTEventCode code,
+- OTResult result, void* cookie )
+-{
+-
+-#ifdef DEBUG_NET
+- printf("AsyncTCPNotifier got an event : 0x%8.8x\n", code );
+-#endif
+-
+- switch( code & 0x7f000000L)
+- {
+- case 0:
+- sock->newEvent |= code;
+- result = 0;
+- break;
+- case kCOMPLETEEVENT:
+- if(!(code & 0x00FFFFE0 ))
+- sock->newCompletion |= CompleteMask( code );
+- if( code == T_OPENCOMPLETE )
+- sock->channel = (SOCKET)(cookie);
+- break;
+- default:
+- if( code != kOTProviderWillClose )
+- result = 0;
+- }
+- // Do we need these ???? TODO
+- // sock->SetAsyncMacError( result );
+- // sock->Wakeup();
+-}
+-
+-/* Retrieve OT event */
+-// This function is taken from GUSI interface.
+-// ( 01/02/19 masahiro minami<elsur@aaa.letter.co.jp> )
+-static void AsyncTCPPopEvent( TCPsocket sock )
+-{
+- // Make sure OT calls are not interrupted
+- // Not sure if we really need this.
+- OTEnterNotifier( sock->channel );
+-
+- sock->event |= (sock->curEvent = sock->newEvent );
+- sock->completion |= ( sock->curCompletion = sock->newCompletion );
+- sock->newEvent = sock->newCompletion = 0;
+-
+- OTLeaveNotifier( sock->channel );
+-
+- if( sock->curEvent & T_UDERR)
+- {
+- // We just clear the error.
+- // Should we feed this back to users ?
+- // (TODO )
+- OTRcvUDErr( sock->channel, NULL );
+-
+-#ifdef DEBUG_NET
+- printf("AsyncTCPPopEvent T_UDERR recognized");
+-#endif
+- }
+-
+- // Remote is disconnecting...
+- if( sock->curEvent & ( T_DISCONNECT | T_ORDREL ))
+- {
+- sock->readShutdown = true;
+- }
+-
+- if( sock->curEvent &T_CONNECT )
+- {
+- // Ignore the info of remote (second parameter).
+- // Shoule we care ?
+- // (TODO)
+- OTRcvConnect( sock->channel, NULL );
+- sock->connected = 1;
+- }
+-
+- if( sock->curEvent & T_ORDREL )
+- {
+- OTRcvOrderlyDisconnect( sock->channel );
+- }
+-
+- if( sock->curEvent & T_DISCONNECT )
+- {
+- OTRcvDisconnect( sock->channel, NULL );
+- }
+-
+- // Do we need to ?
+- // (masahiro minami<elsur@aaa.letter.co.jp>)
+- //YieldToAnyThread();
+-}
+-
+-/* Create a new TCPsocket */
+-// Because TCPsocket structure gets bigger and bigger,
+-// I think we'd better have a constructor function and delete function.
+-// ( 01/02/25 masahiro minami<elsur@aaa.letter.co.jp> )
+-static TCPsocket AsyncTCPNewSocket()
+-{
+- TCPsocket sock;
+-
+- sock = (TCPsocket)malloc(sizeof(*sock));
+- if ( sock == NULL ) {
+- SDLNet_SetError("Out of memory");
+- return NULL;
+- }
+-
+- sock->newEvent = 0;
+- sock->event = 0;
+- sock->curEvent = 0;
+- sock->newCompletion = 0;
+- sock->completion = 0;
+- sock->curCompletion = 0;
+- //sock->info = NULL;
+- sock->readShutdown = sock->writeShutdown = sock->connected = false;
+- sock->error = 0;
+- sock->config = NULL;
+- sock->nextListener = NULL;
+- sock->sflag = 0;
+- return sock;
+-}
+-
+-// hmmm.... do we need this ???
+-// ( 01/02/25 masahiro minami<elsur@aaa.letter.co.jp>)
+-static void AsycnTCPDeleteSocket( TCPsocket sock )
+-{
+- SDLNet_TCP_Close( sock );
+-}
+-/* Open a TCP network socket
+- If 'remote' is NULL, this creates a local server socket on the given port,
+- otherwise a TCP connection to the remote host and port is attempted.
+- The newly created socket is returned, or NULL if there was an error.
+-
+- ( re-written by masahiro minami<elsur@aaa.letter.co.jp>
+- Now endpoint is created in Async mode.
+- 01/02/20 )
+-*/
+-TCPsocket SDLNet_TCP_Open(IPaddress *ip)
+-{
+- EndpointRef dummy = NULL;
+-
+- TCPsocket sock = AsyncTCPNewSocket();
+- if( ! sock)
+- return NULL;
+-
+- // Determin whether bind locally, or connect to remote
+- if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) )
+- {
+- // ######## Connect to remote
+- OTResult stat;
+- InetAddress inAddr;
+- TBind bindReq;
+-
+- // Open endpoint
+- sock->error = OTAsyncOpenEndpoint(
+- OTCreateConfiguration(kTCPName), NULL, &(sock->info),
+- (OTNotifyProcPtr)(AsyncTCPNotifier),
+- sock );
+-
+- AsyncTCPPopEvent( sock );
+- while( !sock->error && !( sock->completion & CompleteMask(T_OPENCOMPLETE)))
+- {
+- //SetThreadState( kCurrentThreadID, kReadyThreadState, kNoThreadID );
+- //YieldToAnyThread();
+- //WaitNextEvent(everyEvent, &macEvent, 1, NULL);
+- AsyncTCPPopEvent( sock );
+- }
+-
+- if( !sock->channel )
+- {
+- SDLNet_SetError("OTAsyncOpenEndpoint failed --- client socket could not be opened");
+- goto error_return;
+- }
+-
+- // Set blocking mode
+- // I'm not sure if this is a good solution....
+- // Check out Apple's sample code, OT Virtual Server
+- // ( 010314 masahiro minami<elsur@aaa.letter.co.jp>)
+-
+- sock->error = OTSetBlocking( sock->channel );
+- if( sock->error != kOTNoError )
+- {
+- SDLNet_SetError("OTSetBlocking() returned an error");
+- goto error_return;
+- }
+-
+- // Bind the socket
+- OTInitInetAddress(&inAddr, 0, 0 );
+- bindReq.addr.len = sizeof( InetAddress );
+- bindReq.addr.buf = (unsigned char*)&inAddr;
+- bindReq.qlen = 0;
+-
+- sock->error = OTBind( sock->channel, &bindReq, NULL );
+- AsyncTCPPopEvent(sock);
+- while( !sock->error && !( sock->completion & CompleteMask(T_BINDCOMPLETE)))
+- {
+- //YieldToAnyThread();
+- //WaitNextEvent(everyEvent, &macEvent, 1, NULL);
+- AsyncTCPPopEvent(sock);
+- }
+-
+-
+- switch( stat = OTGetEndpointState( sock->channel ))
+- {
+- InetAddress inAddr;
+- TCall sndCall;
+- OTResult res;
+-
+- case T_OUTCON:
+- SDLNet_SetError("SDLNet_Open() failed -- T_OUTCON");
+- goto error_return;
+- break;
+- case T_IDLE:
+- sock->readShutdown = false;
+- sock->writeShutdown = false;
+- sock->event &=~T_CONNECT;
+-
+- OTMemzero(&sndCall, sizeof(TCall));
+- OTInitInetAddress(&inAddr, ip->port, ip->host );
+- sndCall.addr.len = sizeof(InetAddress);
+- sndCall.addr.buf = (unsigned char*)&inAddr;
+- sock->connected = 0;
+- res = OTConnect( sock->channel, &sndCall, NULL );
+- AsyncTCPPopEvent(sock);
+- while( sock->error == kOTNoDataErr || !sock->connected )
+- AsyncTCPPopEvent(sock);
+- break;
+- default:
+- // What's to be done ? (TODO)
+- SDLNet_SetError("SDLNet_TCP_Open() failed -- EndpointState not good");
+- goto error_return;
+-
+- }
+- if( !(sock->event & (T_CONNECT|T_DISCONNECT)))
+- goto error_return;
+-
+- AsyncTCPPopEvent( sock );
+- while( !(sock->event & (T_CONNECT|T_DISCONNECT)))
+- {
+- AsyncTCPPopEvent( sock );
+- }
+- // OTConnect successfull
+- if( sock->event & T_CONNECT)
+- {
+- sock->remoteAddress.host = inAddr.fHost;
+- sock->remoteAddress.port = inAddr.fPort;
+- sock->sflag = false;
+- }
+- else
+- {
+- // OTConnect failed
+- sock->event &= ~T_DISCONNECT;
+- goto error_return;
+- }
+- }
+- else
+- {
+- // ######## Bind locally
+- TBind bindReq;
+- InetAddress inAddr;
+-
+- // First, get InetInterfaceInfo.
+- // I don't search for all of them.
+- // Does that matter ?
+-
+- sock->error = OTAsyncOpenEndpoint(
+- OTCreateConfiguration("tilisten, tcp"), NULL, &(sock->info),
+- (OTNotifyProcPtr)(AsyncTCPNotifier),
+- sock);
+- AsyncTCPPopEvent( sock );
+- while( !sock->error && !( sock->completion & CompleteMask( T_OPENCOMPLETE)))
+- {
+- AsyncTCPPopEvent( sock );
+- }
+-
+- if( ! sock->channel )
+- {
+- SDLNet_SetError("OTAsyncOpenEndpoint failed --- server socket could not be opened");
+- goto error_return;
+- }
+-
+- // Create a master OTConfiguration
+- sock->config = OTCreateConfiguration(kTCPName);
+- if( ! sock->config )
+- {
+- SDLNet_SetError("Could not create master OTConfiguration");
+- goto error_return;
+- }
+-
+- // Bind the socket
+- OTInitInetAddress(&inAddr, ip->port, 0 );
+- inAddr.fAddressType = AF_INET;
+- bindReq.addr.len = sizeof( InetAddress );
+- bindReq.addr.buf = (unsigned char*)&inAddr;
+- bindReq.qlen = 35; // This number is NOT well considered. (TODO)
+- sock->localAddress.host = inAddr.fHost;
+- sock->localAddress.port = inAddr.fPort;
+- sock->sflag = true;
+-
+- sock->error = OTBind( sock->channel, &bindReq, NULL );
+- AsyncTCPPopEvent(sock);
+- while( !sock->error && !( sock->completion & CompleteMask(T_BINDCOMPLETE)))
+- {
+- AsyncTCPPopEvent(sock);
+- }
+- if( sock->error != kOTNoError )
+- {
+- SDLNet_SetError("Could not bind server socket");
+- goto error_return;
+- }
+-
+- if( dummy )
+- OTCloseProvider( dummy );
+-
+- }
+-
+- sock->ready = 0;
+- return sock;
+-
+- error_return:
+- if( dummy )
+- OTCloseProvider( dummy );
+- SDLNet_TCP_Close( sock );
+- return NULL;
+-}
+-
+-/* Accept an incoming connection on the given server socket.
+- The newly created socket is returned, or NULL if there was an error.
+-*/
+-TCPsocket SDLNet_TCP_Accept(TCPsocket server)
+-{
+-
+- /* Only server sockets can accept */
+- if ( ! server->sflag ) {
+- SDLNet_SetError("Only server sockets can accept()");
+- return(NULL);
+- }
+- server->ready = 0;
+-
+- /* Accept a new TCP connection on a server socket */
+- {
+- InetAddress peer;
+- TCall peerinfo;
+- TCPsocket sock = NULL;
+- Boolean mustListen = false;
+- OTResult err;
+-
+- memset(&peerinfo, 0, (sizeof peerinfo ));
+- peerinfo.addr.buf = (Uint8 *) &peer;
+- peerinfo.addr.maxlen = sizeof(peer);
+-
+- while( mustListen || !sock )
+- {
+- // OTListen
+- // We do NOT block ---- right thing ? (TODO)
+- err = OTListen( server->channel, &peerinfo );
+-
+- if( err )
+- goto error_return;
+- else
+- {
+- mustListen = false;
+- sock = AsyncTCPNewSocket();
+- if( ! sock )
+- goto error_return;
+- }
+- }
+- if( sock )
+- {
+- // OTAsyncOpenEndpoint
+- server->error = OTAsyncOpenEndpoint( OTCloneConfiguration( server->config ),
+- NULL, &(sock->info), (OTNotifyProcPtr)AsyncTCPNotifier, sock );
+- AsyncTCPPopEvent( sock );
+- while( !sock->error && !( sock->completion & CompleteMask( T_OPENCOMPLETE)))
+- {
+- AsyncTCPPopEvent( sock );
+- }
+- if( ! sock->channel )
+- {
+- mustListen = false;
+- goto error_return;
+- }
+-
+- // OTAccept
+- server->completion &= ~(CompleteMask(T_ACCEPTCOMPLETE));
+- server->error = OTAccept( server->channel, sock->channel, &peerinfo );
+- AsyncTCPPopEvent( server );
+- while( !(server->completion & CompleteMask(T_ACCEPTCOMPLETE)))
+- {
+- AsyncTCPPopEvent( server );
+- }
+-
+- switch( server->error )
+- {
+- case kOTLookErr:
+- switch( OTLook(server->channel ))
+- {
+- case T_LISTEN:
+- mustListen = true;
+- break;
+- case T_DISCONNECT:
+- goto error_return;
+- }
+- break;
+- case 0:
+- sock->nextListener = server->nextListener;
+- server->nextListener = sock;
+- sock->remoteAddress.host = peer.fHost;
+- sock->remoteAddress.port = peer.fPort;
+- return sock;
+- // accept successful
+- break;
+- default:
+- free( sock );
+- }
+- }
+- sock->remoteAddress.host = peer.fHost;
+- sock->remoteAddress.port = peer.fPort;
+- sock->sflag = 0;
+- sock->ready = 0;
+-
+- /* The socket is ready */
+- return(sock);
+-
+- // Error; close the socket and return
+- error_return:
+- SDLNet_TCP_Close(sock);
+- return(NULL);
+- }
+-}
+-
+-/* Get the IP address of the remote system associated with the socket.
+- If the socket is a server socket, this function returns NULL.
+-*/
+-IPaddress *SDLNet_TCP_GetPeerAddress(TCPsocket sock)
+-{
+- if ( sock->sflag ) {
+- return(NULL);
+- }
+- return(&sock->remoteAddress);
+-}
+-
+-/* Send 'len' bytes of 'data' over the non-server socket 'sock'
+- This function returns the actual amount of data sent. If the return value
+- is less than the amount of data sent, then either the remote connection was
+- closed, or an unknown socket error occurred.
+-*/
+-int SDLNet_TCP_Send(TCPsocket sock, const void *datap, int len)
+-{
+- const Uint8 *data = (const Uint8 *)datap; /* For pointer arithmetic */
+- int sent, left;
+-
+- /* Server sockets are for accepting connections only */
+- if ( sock->sflag ) {
+- SDLNet_SetError("Server sockets cannot send");
+- return(-1);
+- }
+-
+- /* Keep sending data until it's sent or an error occurs */
+- left = len;
+- sent = 0;
+- errno = 0;
+- do {
+- len = OTSnd(sock->channel, (void *)data, left, 0);
+- if (len == kOTFlowErr)
+- len = 0;
+- if ( len > 0 ) {
+- sent += len;
+- left -= len;
+- data += len;
+- }
+- // Do we need to ?
+- // ( masahiro minami<elsur@aaa.letter.co.jp> )
+- // (TODO)
+- //WaitNextEvent(everyEvent, &macEvent, 1, NULL);
+- //AsyncTCPPopEvent(sock);
+- } while ( (left > 0) && (len > 0) );
+-
+- return(sent);
+-}
+-
+-/* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
+- and store them in the buffer pointed to by 'data'.
+- This function returns the actual amount of data received. If the return
+- value is less than or equal to zero, then either the remote connection was
+- closed, or an unknown socket error occurred.
+-*/
+-int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
+-{
+- int len = 0;
+- OSStatus res;
+- /* Server sockets are for accepting connections only */
+- if ( sock->sflag ) {
+- SDLNet_SetError("Server sockets cannot receive");
+- return(-1);
+- }
+-
+- do
+- {
+- res = OTRcv(sock->channel, data, maxlen-len, 0);
+- if (res > 0) {
+- len = res;
+- }
+-
+-#ifdef DEBUG_NET
+- if ( res != kOTNoDataErr )
+- printf("SDLNet_TCP_Recv received ; %d\n", res );
+-#endif
+-
+- AsyncTCPPopEvent(sock);
+- if( res == kOTLookErr )
+- {
+- res = OTLook(sock->channel );
+- continue;
+- }
+- } while ( (len == 0) && (res == kOTNoDataErr) );
+-
+- sock->ready = 0;
+- if ( len == 0 ) { /* Open Transport error */
+-#ifdef DEBUG_NET
+- printf("Open Transport error: %d\n", res);
+-#endif
+- return(-1);
+- }
+- return(len);
+-}
+-
+-/* Close a TCP network socket */
+-void SDLNet_TCP_Close(TCPsocket sock)
+-{
+- if ( sock != NULL ) {
+- if ( sock->channel != INVALID_SOCKET ) {
+- //closesocket(sock->channel);
+- OTSndOrderlyDisconnect( sock->channel );
+- }
+- free(sock);
+- }
+-}
+-
+-#else /* !MACOS_OPENTRANSPORT */
+-
+-struct _TCPsocket {
+- int ready;
+- SOCKET channel;
+- IPaddress remoteAddress;
+- IPaddress localAddress;
+- int sflag;
+-};
+-
+-/* Open a TCP network socket
+- If 'remote' is NULL, this creates a local server socket on the given port,
+- otherwise a TCP connection to the remote host and port is attempted.
+- The newly created socket is returned, or NULL if there was an error.
+-*/
+-TCPsocket SDLNet_TCP_Open(IPaddress *ip)
+-{
+- TCPsocket sock;
+- struct sockaddr_in sock_addr;
+-
+- /* Allocate a TCP socket structure */
+- sock = (TCPsocket)malloc(sizeof(*sock));
+- if ( sock == NULL ) {
+- SDLNet_SetError("Out of memory");
+- goto error_return;
+- }
+-
+- /* Open the socket */
+- sock->channel = socket(AF_INET, SOCK_STREAM, 0);
+- if ( sock->channel == INVALID_SOCKET ) {
+- SDLNet_SetError("Couldn't create socket");
+- goto error_return;
+- }
+-
+- /* Connect to remote, or bind locally, as appropriate */
+- if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) ) {
+-
+- // ######### Connecting to remote
+-
+- memset(&sock_addr, 0, sizeof(sock_addr));
+- sock_addr.sin_family = AF_INET;
+- sock_addr.sin_addr.s_addr = ip->host;
+- sock_addr.sin_port = ip->port;
+-
+- /* Connect to the remote host */
+- if ( connect(sock->channel, (struct sockaddr *)&sock_addr,
+- sizeof(sock_addr)) == SOCKET_ERROR ) {
+- SDLNet_SetError("Couldn't connect to remote host");
+- goto error_return;
+- }
+- sock->sflag = 0;
+- } else {
+-
+- // ########## Binding locally
+-
+- memset(&sock_addr, 0, sizeof(sock_addr));
+- sock_addr.sin_family = AF_INET;
+- sock_addr.sin_addr.s_addr = INADDR_ANY;
+- sock_addr.sin_port = ip->port;
+-
+-/*
+- * Windows gets bad mojo with SO_REUSEADDR:
+- * http://www.devolution.com/pipermail/sdl/2005-September/070491.html
+- * --ryan.
+- */
+-#ifndef WIN32
+- /* allow local address reuse */
+- { int yes = 1;
+- setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes));
+- }
+-#endif
+-
+- /* Bind the socket for listening */
+- if ( bind(sock->channel, (struct sockaddr *)&sock_addr,
+- sizeof(sock_addr)) == SOCKET_ERROR ) {
+- SDLNet_SetError("Couldn't bind to local port");
+- goto error_return;
+- }
+- if ( listen(sock->channel, 5) == SOCKET_ERROR ) {
+- SDLNet_SetError("Couldn't listen to local port");
+- goto error_return;
+- }
+-
+- /* Set the socket to non-blocking mode for accept() */
+-#if defined(__BEOS__) && defined(SO_NONBLOCK)
+- /* On BeOS r5 there is O_NONBLOCK but it's for files only */
+- {
+- long b = 1;
+- setsockopt(sock->channel, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
+- }
+-#elif defined(O_NONBLOCK)
+- {
+- fcntl(sock->channel, F_SETFL, O_NONBLOCK);
+- }
+-#elif defined(WIN32)
+- {
+- unsigned long mode = 1;
+- ioctlsocket (sock->channel, FIONBIO, &mode);
+- }
+-#elif defined(__OS2__)
+- {
+- int dontblock = 1;
+- ioctl(sock->channel, FIONBIO, &dontblock);
+- }
+-#else
+-#warning How do we set non-blocking mode on other operating systems?
+-#endif
+- sock->sflag = 1;
+- }
+- sock->ready = 0;
+-
+-#ifdef TCP_NODELAY
+- /* Set the nodelay TCP option for real-time games */
+- { int yes = 1;
+- setsockopt(sock->channel, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes));
+- }
+-#endif /* TCP_NODELAY */
+-
+- /* Fill in the channel host address */
+- sock->remoteAddress.host = sock_addr.sin_addr.s_addr;
+- sock->remoteAddress.port = sock_addr.sin_port;
+-
+- /* The socket is ready */
+- return(sock);
+-
+-error_return:
+- SDLNet_TCP_Close(sock);
+- return(NULL);
+-}
+-
+-/* Accept an incoming connection on the given server socket.
+- The newly created socket is returned, or NULL if there was an error.
+-*/
+-TCPsocket SDLNet_TCP_Accept(TCPsocket server)
+-{
+- TCPsocket sock;
+- struct sockaddr_in sock_addr;
+- int sock_alen;
+-
+- /* Only server sockets can accept */
+- if ( ! server->sflag ) {
+- SDLNet_SetError("Only server sockets can accept()");
+- return(NULL);
+- }
+- server->ready = 0;
+-
+- /* Allocate a TCP socket structure */
+- sock = (TCPsocket)malloc(sizeof(*sock));
+- if ( sock == NULL ) {
+- SDLNet_SetError("Out of memory");
+- goto error_return;
+- }
+-
+- /* Accept a new TCP connection on a server socket */
+- sock_alen = sizeof(sock_addr);
+- sock->channel = accept(server->channel, (struct sockaddr *)&sock_addr,
+-#ifdef USE_GUSI_SOCKETS
+- (unsigned int *)&sock_alen);
+-#else
+- &sock_alen);
+-#endif
+- if ( sock->channel == SOCKET_ERROR ) {
+- SDLNet_SetError("accept() failed");
+- goto error_return;
+- }
+-#ifdef WIN32
+- {
+- /* passing a zero value, socket mode set to block on */
+- unsigned long mode = 0;
+- ioctlsocket (sock->channel, FIONBIO, &mode);
+- }
+-#elif defined(O_NONBLOCK)
+- {
+- int flags = fcntl(sock->channel, F_GETFL, 0);
+- fcntl(sock->channel, F_SETFL, flags & ~O_NONBLOCK);
+- }
+-#endif /* WIN32 */
+- sock->remoteAddress.host = sock_addr.sin_addr.s_addr;
+- sock->remoteAddress.port = sock_addr.sin_port;
+-
+- sock->sflag = 0;
+- sock->ready = 0;
+-
+- /* The socket is ready */
+- return(sock);
+-
+-error_return:
+- SDLNet_TCP_Close(sock);
+- return(NULL);
+-}
+-
+-/* Get the IP address of the remote system associated with the socket.
+- If the socket is a server socket, this function returns NULL.
+-*/
+-IPaddress *SDLNet_TCP_GetPeerAddress(TCPsocket sock)
+-{
+- if ( sock->sflag ) {
+- return(NULL);
+- }
+- return(&sock->remoteAddress);
+-}
+-
+-/* Send 'len' bytes of 'data' over the non-server socket 'sock'
+- This function returns the actual amount of data sent. If the return value
+- is less than the amount of data sent, then either the remote connection was
+- closed, or an unknown socket error occurred.
+-*/
+-int SDLNet_TCP_Send(TCPsocket sock, const void *datap, int len)
+-{
+- const Uint8 *data = (const Uint8 *)datap; /* For pointer arithmetic */
+- int sent, left;
+-
+- /* Server sockets are for accepting connections only */
+- if ( sock->sflag ) {
+- SDLNet_SetError("Server sockets cannot send");
+- return(-1);
+- }
+-
+- /* Keep sending data until it's sent or an error occurs */
+- left = len;
+- sent = 0;
+- errno = 0;
+- do {
+- len = send(sock->channel, (const char *) data, left, 0);
+- if ( len > 0 ) {
+- sent += len;
+- left -= len;
+- data += len;
+- }
+- } while ( (left > 0) && ((len > 0) || (errno == EINTR)) );
+-
+- return(sent);
+-}
+-
+-/* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
+- and store them in the buffer pointed to by 'data'.
+- This function returns the actual amount of data received. If the return
+- value is less than or equal to zero, then either the remote connection was
+- closed, or an unknown socket error occurred.
+-*/
+-int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
+-{
+- int len;
+-
+- /* Server sockets are for accepting connections only */
+- if ( sock->sflag ) {
+- SDLNet_SetError("Server sockets cannot receive");
+- return(-1);
+- }
+-
+- errno = 0;
+- do {
+- len = recv(sock->channel, (char *) data, maxlen, 0);
+- } while ( errno == EINTR );
+-
+- sock->ready = 0;
+- return(len);
+-}
+-
+-/* Close a TCP network socket */
+-void SDLNet_TCP_Close(TCPsocket sock)
+-{
+- if ( sock != NULL ) {
+- if ( sock->channel != INVALID_SOCKET ) {
+- closesocket(sock->channel);
+- }
+- free(sock);
+- }
+-}
+-
+-#endif /* MACOS_OPENTRANSPORT */
+diff -Naur a/SDLnetTCP.cpp b/SDLnetTCP.cpp
+--- a/SDLnetTCP.cpp 1970-01-01 03:00:00.000000000 +0300
++++ b/SDLnetTCP.cpp 2015-11-30 00:34:59.378830000 +0300
+@@ -0,0 +1,483 @@
+/*
-+ * ++Copyright++ 1983, 1990, 1993
-+ * -
-+ * Copyright (c) 1983, 1990, 1993
-+ * The Regents of the University of California. All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ * 1. Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * 2. Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in the
-+ * documentation and/or other materials provided with the distribution.
-+ * 3. All advertising materials mentioning features or use of this software
-+ * must display the following acknowledgement:
-+ * This product includes software developed by the University of
-+ * California, Berkeley and its contributors.
-+ * 4. Neither the name of the University nor the names of its contributors
-+ * may be used to endorse or promote products derived from this software
-+ * without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-+ * SUCH DAMAGE.
-+ * -
-+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
-+ *
-+ * Permission to use, copy, modify, and distribute this software for any
-+ * purpose with or without fee is hereby granted, provided that the above
-+ * copyright notice and this permission notice appear in all copies, and that
-+ * the name of Digital Equipment Corporation not be used in advertising or
-+ * publicity pertaining to distribution of the document or software without
-+ * specific, written prior permission.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
-+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
-+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
-+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-+ * SOFTWARE.
-+ * -
-+ * --Copyright--
-+ */
-+
-+#if defined(LIBC_SCCS) && !defined(lint)
-+static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
-+#endif /* LIBC_SCCS and not lint */
-+#include <sys/cdefs.h>
-+#include <sys/types.h>
-+#include <machine/endian.h>
-+
-+#include <sys/param.h>
-+
-+#include <netinet/in.h>
-+#include <arpa/inet.h>
-+
-+#include <ctype.h>
-+#include <errno.h>
-+#include <string.h>
-+#include <stdlib.h>
++ SDL_net: An example cross-platform network library for use with SDL
++ Copyright (C) 1997-2004 Sam Lantinga
+
-+/*
-+ * ASCII internet address interpretation routine.
-+ * The value returned is in network order.
-+ */
-+in_addr_t /* XXX should be struct in_addr :( */
-+inet_addr(cp)
-+ const char *cp;
++ This library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Library General Public
++ License as published by the Free Software Foundation; either
++ version 2 of the License, or (at your option) any later version.
++
++ This library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Library General Public License for more details.
++
++ You should have received a copy of the GNU Library General Public
++ License along with this library; if not, write to the Free
++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++ Sam Lantinga
++ slouken@libsdl.org
++*/
++
++/* $Id: SDLnetTCP.c 3280 2007-07-15 05:55:42Z slouken $ */
++
++#include "SDLnetsys.h"
++#include "SDL_net.h"
++
++#include "ppapi_simple/ps.h"
++#include "ppapi/cpp/tcp_socket.h"
++#include "ppapi/cpp/instance_handle.h"
++#include "ppapi/cpp/message_loop.h"
++#include "ppapi/cpp/instance.h"
++#include "ppapi/c/ppb_net_address.h"
++#include "ppapi/cpp/var.h"
++#include "ppapi/utility/completion_callback_factory.h"
++
++#include "pthread.h"
++#include <condition_variable>
++#include <mutex>
++
++/* The network API for TCP sockets */
++
++#define BUFFER_SIZE 2000
++
++struct _TCPsocket {
++ int ready;
++ pp::TCPSocket channel;
++ IPaddress remoteAddress;
++ IPaddress localAddress;
++ int sflag;
++
++ bool readInProgress;
++ int bufferAmount;
++ int bufferOffset;
++ char buffer [BUFFER_SIZE];
++};
++
++class SDLNetSynchronizer {
++ public:
++ pp::CompletionCallbackFactory <SDLNetSynchronizer> factory;
++ pp::InstanceHandle handle;
++ pp::Instance instance;
++
++ static pp::MessageLoop loop;
++
++ pp::TCPSocket sock_result;
++ int32_t result;
++ bool ready;
++ std::condition_variable cv;
++ std::mutex mtx;
++
++ SDLNetSynchronizer () : factory (this), handle (PSGetInstanceId ()), instance (PSGetInstanceId ()) {
++ ready = false;
++ if (loop.is_null ())
++ loop = pp::MessageLoop::GetForMainThread ();
++ }
++
++ int32_t Connect (pp::TCPSocket &sock, IPaddress *ip_addr) {
++ int32_t code;
++ PP_NetAddress_IPv4 ipv4_addr;
++ IpToIpv4 (ip_addr, &ipv4_addr);
++
++ pp::CompletionCallback cb = factory.NewCallback (
++ &SDLNetSynchronizer::ConnectWork,
++ sock,
++ pp::NetAddress (handle, ipv4_addr)
++ );
++
++ loop.PostWork (cb, 0);
++ wait ();
++
++ return result;
++ }
++
++ int32_t Bind (pp::TCPSocket &sock, IPaddress *ip_addr) {
++ PP_NetAddress_IPv4 ipv4_addr;
++ IpToIpv4 (ip_addr, &ipv4_addr);
++
++
++ pp::CompletionCallback cb = factory.NewCallback (
++ &SDLNetSynchronizer::BindWork,
++ sock,
++ pp::NetAddress (handle, ipv4_addr)
++ );
++
++ loop.PostWork (cb, 0);
++
++ wait ();
++ return result;
++ }
++
++ int32_t Listen (pp::TCPSocket &sock, int32_t backlog) {
++
++ pp::CompletionCallback cb = factory.NewCallback (
++ &SDLNetSynchronizer::ListenWork,
++ sock, backlog
++ );
++
++ loop.PostWork (cb, 0);
++
++ wait ();
++ return result;
++ }
++
++ void WriteWork (int32_t result, pp::TCPSocket &sock, const char *data, size_t size) {
++ sock.Write (
++ data, size,
++ factory.NewCallback (&SDLNetSynchronizer::resultCallback)
++ );
++ }
++
++ int32_t Write (pp::TCPSocket &sock, const char *data, size_t size) {
++ pp::CompletionCallback cb = factory.NewCallback (
++ &SDLNetSynchronizer::WriteWork,
++ sock, data, size
++ );
++
++ loop.PostWork (cb, 0);
++
++ wait ();
++ return result;
++ }
++
++ void ReadAsyncCallback (int32_t result, TCPsocket sock) {
++ if (result <= 0)
++ return;
++
++ sock->bufferOffset = 0;
++ sock->bufferAmount = result;
++ sock->ready = 1;
++ sock->readInProgress = false;
++ }
++
++ void ReadAsyncWork (int32_t result, TCPsocket sock) {
++ sock->channel.Read (
++ sock->buffer, BUFFER_SIZE,
++ factory.NewCallback (&SDLNetSynchronizer::ReadAsyncCallback, sock)
++ );
++ }
++
++ void ReadAsync (TCPsocket sock) {
++ pp::CompletionCallback cb = factory.NewCallback (
++ &SDLNetSynchronizer::ReadAsyncWork,
++ sock
++ );
++
++ sock->readInProgress = true;
++ loop.PostWork (cb, 0);
++ }
++
++ void AcceptWork (int32_t result, pp::TCPSocket &sock) {
++ sock.Accept (
++ factory.NewCallbackWithOutput (&SDLNetSynchronizer::acceptCallback)
++ );
++ }
++
++ pp::TCPSocket Accept (pp::TCPSocket &sock, int32_t &out) {
++ pp::CompletionCallback cb = factory.NewCallback (
++ &SDLNetSynchronizer::AcceptWork,
++ sock
++ );
++
++ loop.PostWork (cb, 0);
++
++ wait ();
++ out = result;
++ return sock_result;
++ }
++
++ void IpToIpv4 (IPaddress *ip_addr, PP_NetAddress_IPv4 *ipv4_addr) {
++ ipv4_addr->port = ip_addr->port;
++ for (int i = 0; i < 4; ++i)
++ ipv4_addr->addr[i] = (ip_addr->host >> (8 * i)) & 0xFF;
++ }
++
++ void NetToIp (pp::NetAddress net_addr, IPaddress *ip_addr) {
++ PP_NetAddress_IPv4 ipv4_addr;
++ net_addr.DescribeAsIPv4Address (&ipv4_addr);
++ Ipv4ToIp (&ipv4_addr, ip_addr);
++ }
++
++ void Ipv4ToIp (PP_NetAddress_IPv4 *ipv4_addr, IPaddress *ip_addr) {
++ ip_addr->port = ipv4_addr->port;
++ ip_addr->host = 0;
++ for (int i = 0; i < 4; ++i)
++ ip_addr->host ^= (((uint32_t) ipv4_addr->addr[i]) << (8 * i));
++ }
++
++ void postMessage (std::string msg) {
++ instance.PostMessage (pp::Var (msg));
++ }
++
++ void postMessage (int32_t msg) {
++ instance.PostMessage (pp::Var (msg));
++ }
++
++ private:
++ void ConnectWork (int32_t result, pp::TCPSocket &sock, pp::NetAddress &addr) {
++ sock.Connect (
++ addr,
++ factory.NewCallback (&SDLNetSynchronizer::resultCallback)
++ );
++ }
++
++ void BindWork (int32_t result, pp::TCPSocket &sock, pp::NetAddress &addr) {
++ sock.Bind (
++ addr,
++ factory.NewCallback (&SDLNetSynchronizer::resultCallback)
++ );
++ }
++
++ void ListenWork (int32_t result, pp::TCPSocket &sock, int32_t backlog) {
++ sock.Listen (
++ backlog,
++ factory.NewCallback (&SDLNetSynchronizer::resultCallback)
++ );
++ }
++
++ void resultCallback (int32_t res) {
++ result = res;
++ unlock ();
++ }
++
++ void acceptCallback (int32_t res, pp::TCPSocket sock) {
++ result = res;
++ sock_result = sock;
++
++ unlock();
++ }
++
++ void wait () {
++ std::unique_lock <std::mutex> lck (mtx);
++ while (!ready)
++ cv.wait (lck);
++ ready = false;
++ }
++
++ void unlock () {
++ std::unique_lock <std::mutex> lck (mtx);
++ ready = true;
++ cv.notify_all ();
++ }
++};
++
++pp::MessageLoop SDLNetSynchronizer::loop = pp::MessageLoop ();
++
++SDLNetSynchronizer *__read_syncer = NULL;
++
++/* Open a TCP network socket
++ If 'remote' is NULL, this creates a local server socket on the given port,
++ otherwise a TCP connection to the remote host and port is attempted.
++ The newly created socket is returned, or NULL if there was an error.
++*/
++TCPsocket SDLNet_TCP_Open (IPaddress *ip)
+{
-+ struct in_addr val;
++ TCPsocket sock;
++ SDLNetSynchronizer syncer;
++
++ /* Allocate a TCP socket structure */
++ sock = (TCPsocket)malloc (sizeof (*sock));
++ if ( sock == NULL ) {
++ SDLNet_SetError ("Out of memory");
++ goto error_return;
++ }
++
++ sock->channel = pp::TCPSocket (syncer.handle);
++
++ /* Connect to remote, or bind locally, as appropriate */
++ if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) ) {
++
++ // ######### Connecting to remote
++
++ /* Connect to the remote host */
++ if ( syncer.Connect (sock->channel, ip) != PP_OK ) {
++ SDLNet_SetError("Couldn't connect to remote host");
++ goto error_return;
++ }
++ sock->sflag = 0;
++
++ } else {
++
++ // ########## Binding locally
++
++ /* Bind the socket for listening */
++ if ( syncer.Bind (sock->channel, ip) != PP_OK ) {
++ SDLNet_SetError("Couldn't bind to local port");
++ goto error_return;
++ }
++
++ if ( syncer.Listen (sock->channel, 5) != PP_OK ) {
++ SDLNet_SetError("Couldn't listen to local port");
++ goto error_return;
++ }
++
++ /* Set the socket to non-blocking mode for accept() */
++
++ {
++ /* In nacl O_NONBLOCK is defined */
++ // fcntl(sock->channel, F_SETFL, O_NONBLOCK);
++ }
++
++ sock->sflag = 1;
++ }
+
-+ if (inet_aton(cp, &val))
-+ return (val.s_addr);
-+ return (INADDR_NONE);
++ sock->readInProgress = 0;
++ sock->ready = 0;
++ sock->bufferOffset = sock->bufferAmount = 0;
++
++#ifdef TCP_NODELAY
++ /* Set the nodelay TCP option for real-time games */
++ { int yes = 1;
++ setsockopt(sock->channel, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes));
++ }
++#endif /* TCP_NODELAY */
++
++ /* Fill in the channel host address */
++ sock->remoteAddress = *ip;
++
++ /* The socket is ready */
++ return(sock);
++
++error_return:
++ SDLNet_TCP_Close(sock);
++ return(NULL);
+}
+
-+/*
-+ * Check whether "cp" is a valid ASCII representation
-+ * of an Internet address and convert to a binary address.
-+ * Returns 1 if the address is valid, 0 if not.
-+ * This replaces inet_addr, the return value from which
-+ * cannot distinguish between failure and a local broadcast address.
-+ */
-+int
-+inet_aton(cp, addr)
-+ const char *cp;
-+ struct in_addr *addr;
++/* Accept an incoming connection on the given server socket.
++ The newly created socket is returned, or NULL if there was an error.
++*/
++TCPsocket SDLNet_TCP_Accept(TCPsocket server)
+{
-+ u_long parts[4];
-+ in_addr_t val;
-+ char *c;
-+ char *endptr;
-+ int gotend, n;
-+
-+ c = (char *)cp;
-+ n = 0;
-+ /*
-+ * Run through the string, grabbing numbers until
-+ * the end of the string, or some error
-+ */
-+ gotend = 0;
-+ while (!gotend) {
-+ errno = 0;
-+ val = strtoul(c, &endptr, 0);
-+
-+ if (errno == ERANGE) /* Fail completely if it overflowed. */
-+ return (0);
-+
-+ /*
-+ * If the whole string is invalid, endptr will equal
-+ * c.. this way we can make sure someone hasn't
-+ * gone '.12' or something which would get past
-+ * the next check.
-+ */
-+ if (endptr == c)
-+ return (0);
-+ parts[n] = val;
-+ c = endptr;
-+
-+ /* Check the next character past the previous number's end */
-+ switch (*c) {
-+ case '.' :
-+ /* Make sure we only do 3 dots .. */
-+ if (n == 3) /* Whoops. Quit. */
-+ return (0);
-+ n++;
-+ c++;
-+ break;
-+
-+ case '\0':
-+ gotend = 1;
-+ break;
-+
-+ default:
-+ if (isspace((unsigned char)*c)) {
-+ gotend = 1;
-+ break;
-+ } else
-+ return (0); /* Invalid character, so fail */
-+ }
-+
-+ }
-+
-+ /*
-+ * Concoct the address according to
-+ * the number of parts specified.
-+ */
-+
-+ switch (n) {
-+ case 0: /* a -- 32 bits */
-+ /*
-+ * Nothing is necessary here. Overflow checking was
-+ * already done in strtoul().
-+ */
-+ break;
-+ case 1: /* a.b -- 8.24 bits */
-+ if (val > 0xffffff || parts[0] > 0xff)
-+ return (0);
-+ val |= parts[0] << 24;
-+ break;
-+
-+ case 2: /* a.b.c -- 8.8.16 bits */
-+ if (val > 0xffff || parts[0] > 0xff || parts[1] > 0xff)
-+ return (0);
-+ val |= (parts[0] << 24) | (parts[1] << 16);
-+ break;
-+
-+ case 3: /* a.b.c.d -- 8.8.8.8 bits */
-+ if (val > 0xff || parts[0] > 0xff || parts[1] > 0xff ||
-+ parts[2] > 0xff)
-+ return (0);
-+ val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-+ break;
-+ }
-+
-+ if (addr != NULL)
-+ addr->s_addr = htonl(val);
-+ return (1);
++ TCPsocket sock;
++ SDLNetSynchronizer syncer;
++ int acc_res;
++
++ /* Only server sockets can accept */
++ if ( ! server->sflag ) {
++ SDLNet_SetError("Only server sockets can accept()");
++ return(NULL);
++ }
++ server->ready = 0;
++
++ /* Allocate a TCP socket structure */
++ sock = (TCPsocket)malloc (sizeof (*sock));
++ if ( sock == NULL ) {
++ SDLNet_SetError("Out of memory");
++ goto error_return;
++ }
++
++ /* Accept a new TCP connection on a server socket */
++ sock->channel = syncer.Accept (server->channel, acc_res);
++
++ if ( acc_res != PP_OK ) {
++ SDLNet_SetError("accept() failed");
++ goto error_return;
++ }
++
++
++ {
++ /* int flags = fcntl(sock->channel, F_GETFL, 0);
++ fcntl(sock->channel, F_SETFL, flags & ~O_NONBLOCK); */
++ }
++
++ syncer.NetToIp ((sock->channel).GetRemoteAddress (), &sock->remoteAddress);
++
++ sock->sflag = 0;
++ sock->ready = 0;
++
++ /* The socket is ready */
++ return(sock);
++
++error_return:
++ SDLNet_TCP_Close(sock);
++ return(NULL);
+}
+
-+/*
-+ * Weak aliases for applications that use certain private entry points,
-+ * and fail to include <arpa/inet.h>.
-+ */
-+#undef inet_addr
-+__weak_reference(__inet_addr, inet_addr);
-+#undef inet_aton
-+__weak_reference(__inet_aton, inet_aton);
-
-diff -urN SDL_net-1.2.7/SDLnet.c SDL_net-1.2.7-nacl/SDLnet.c
---- SDL_net-1.2.7/SDLnet.c 2007-07-02 06:04:03.000000000 +0400
-+++ SDL_net-1.2.7-nacl/SDLnet.c 2013-11-03 00:43:36.859998000 +0400
-@@ -29,6 +29,8 @@
- #include "SDLnetsys.h"
- #include "SDL_net.h"
-
-+#include "inet_addr.c"
++/* Get the IP address of the remote system associated with the socket.
++ If the socket is a server socket, this function returns NULL.
++*/
++IPaddress *SDLNet_TCP_GetPeerAddress(TCPsocket sock)
++{
++ if ( sock->sflag ) {
++ return(NULL);
++ }
++ return(&sock->remoteAddress);
++}
+
-
- const SDL_version *SDLNet_Linked_Version(void)
- {
-@@ -344,7 +346,7 @@
-
- hp = gethostbyname(host);
- if ( hp ) {
-- memcpy(&address->host,hp->h_addr,hp->h_length);
-+ memcpy(&address->host,hp->h_addr_list[0],hp->h_length);
- } else {
- retval = -1;
- }
-@@ -368,8 +370,7 @@
- const char *SDLNet_ResolveIP(IPaddress *ip)
- {
- struct hostent *hp;
--
-- hp = gethostbyaddr((char *)&ip->host, 4, AF_INET);
-+ hp = NULL;
- if ( hp != NULL ) {
- return hp->h_name;
- }
-
++/* Send 'len' bytes of 'data' over the non-server socket 'sock'
++ This function returns the actual amount of data sent. If the return value
++ is less than the amount of data sent, then either the remote connection was
++ closed, or an unknown socket error occurred.
++*/
++int SDLNet_TCP_Send(TCPsocket sock, const void *datap, int len)
++{
++ SDLNetSynchronizer syncer;
++ Uint8 *data = (Uint8 *)datap; /* For pointer arithmetic */
++ int sent, left;
++
++ /* Server sockets are for accepting connections only */
++ if ( sock->sflag ) {
++ SDLNet_SetError("Server sockets cannot send");
++ return(-1);
++ }
++
++ /* Keep sending data until it's sent or an error occurs */
++ left = len;
++ sent = 0;
++ errno = 0;
++ do {
++ len = syncer.Write (sock->channel, (const char *) data, left);
++ if ( len > 0 ) {
++ sent += len;
++ left -= len;
++ data += len;
++ }
++ } while ( (left > 0) && (len >= 0 || errno == EINTR) );
++
++ return(sent);
++}
++
++/* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
++ and store them in the buffer pointed to by 'data'.
++ This function returns the actual amount of data received. If the return
++ value is less than or equal to zero, then either the remote connection was
++ closed, or an unknown socket error occurred.
++*/
++int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
++{
++ SDLNetSynchronizer syncer;
++ int len = 0;
++
++ /* Server sockets are for accepting connections only */
++ if ( sock->sflag ) {
++ SDLNet_SetError("Server sockets cannot receive");
++ return(-1);
++ }
++
++ if ( sock->ready && maxlen > 0 ) {
++ len = std::min (sock->bufferAmount - sock->bufferOffset, maxlen);
++ memcpy (data, sock->buffer + sock->bufferOffset, len);
++ sock->bufferOffset += len;
++ if ( sock->bufferOffset == sock->bufferAmount )
++ sock->ready = 0;
++ }
++
++ if ( sock->ready == 0 && sock->readInProgress == 0) {
++ if (__read_syncer == NULL)
++ __read_syncer = new SDLNetSynchronizer ();
++ __read_syncer->ReadAsync (sock);
++ }
++
++ return(len);
++}
++
++/* Close a TCP network socket */
++void SDLNet_TCP_Close(TCPsocket sock)
++{
++ SDLNetSynchronizer syncer;
++ if ( sock != NULL ) {
++ sock->channel.Close ();
++ free (sock);
++ }
++}
diff --git a/packaging/nacl/ports/sdl-net/pkg_info b/packaging/nacl/ports/sdl-net/pkg_info
index 2c64c8642..29f94bb20 100644
--- a/packaging/nacl/ports/sdl-net/pkg_info
+++ b/packaging/nacl/ports/sdl-net/pkg_info
@@ -4,6 +4,5 @@ ARCHIVE_ROOT=SDL_net-1.2.7
URL=http://www.libsdl.org/projects/SDL_net/release/SDL_net-1.2.7.tar.gz
LICENSE=LGPL2
DEPENDS=(sdl)
-# Disabled for bionic due to sdl.
-DISABLED_LIBC=(bionic)
SHA1=b46c7e3221621cc34fec1238f1b5f0ce8972274d
+DISABLED_TOOLCHAIN=(emscripten)
diff --git a/packaging/nacl/ports/sdl/build.sh b/packaging/nacl/ports/sdl/build.sh
index 036ec8ee6..ee30577d1 100644
--- a/packaging/nacl/ports/sdl/build.sh
+++ b/packaging/nacl/ports/sdl/build.sh
@@ -1,9 +1,8 @@
-#!/bin/bash
# Copyright (c) 2011 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-CONFIG_SUB=build-scripts/config.sub
+EXTRA_CONFIGURE_ARGS="--disable-assembly --disable-pthread-sem"
AutogenStep() {
ChangeDir ${SRC_DIR}
@@ -18,23 +17,8 @@ AutogenStep() {
cd -
}
-
ConfigureStep() {
AutogenStep
SetupCrossEnvironment
-
- local conf_host=${NACL_CROSS_PREFIX}
- if [ ${NACL_ARCH} = "pnacl" ]; then
- # The PNaCl tools use "pnacl-" as the prefix, but config.sub
- # does not know about "pnacl". It only knows about "le32-nacl".
- # Unfortunately, most of the config.subs here are so old that
- # it doesn't know about that "le32" either. So we just say "nacl".
- conf_host="nacl-pnacl"
- fi
-
- LogExecute ${SRC_DIR}/configure \
- --host=${conf_host} \
- --prefix=${PREFIX} \
- --disable-assembly \
- --disable-pthread-sem
+ DefaultConfigureStep
}
diff --git a/packaging/nacl/ports/sdl/nacl.patch b/packaging/nacl/ports/sdl/nacl.patch
index ddbb24d30..36846f48c 100644
--- a/packaging/nacl/ports/sdl/nacl.patch
+++ b/packaging/nacl/ports/sdl/nacl.patch
@@ -1,6362 +1,458 @@
-diff --git a/Makefile.in b/Makefile.in
-index e29dc6d..bb485dd 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -36,13 +36,13 @@ TARGET = libSDL.la
- SOURCES = @SOURCES@
- OBJECTS = @OBJECTS@
-
--SDLMAIN_TARGET = libSDLmain.a
-+SDLMAIN_TARGET = libSDLmain.la
- SDLMAIN_SOURCES = @SDLMAIN_SOURCES@
- SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
-
- DIST = acinclude autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS CWprojects.sea.bin docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in MPWmake.sea.bin README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualCE.zip VisualC.html VisualC.zip Watcom-OS2.zip Watcom-Win32.zip symbian.zip WhatsNew Xcode.tar.gz
-
--HDRS = SDL.h SDL_active.h SDL_audio.h SDL_byteorder.h SDL_cdrom.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_getenv.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_platform.h SDL_quit.h SDL_rwops.h SDL_stdinc.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
-+HDRS = SDL.h SDL_active.h SDL_audio.h SDL_byteorder.h SDL_cdrom.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_getenv.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_nacl.h SDL_opengl.h SDL_platform.h SDL_quit.h SDL_rwops.h SDL_stdinc.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
-
- LT_AGE = @LT_AGE@
- LT_CURRENT = @LT_CURRENT@
-@@ -68,9 +68,9 @@ depend:
- @SOURCES="$(SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \
- $(SHELL) $(auxdir)/makedep.sh
- @for src in $(SDLMAIN_SOURCES); do \
-- obj=`echo $$src | sed -e 's|.*/||' -e 's|\.[^\.]*$$|.o|'`; \
-+ obj=`echo $$src | sed -e 's|.*/||' -e 's|\.[^\.]*$$|.lo|'`; \
- echo "\$$(objects)/$$obj: $$src" >>$(depend); \
-- echo " \$$(CC) \$$(CFLAGS) \$$(EXTRA_CFLAGS) -c $$src -o \$$@" >>$(depend); \
-+ echo " \$$(LIBTOOL) --mode=compile \$$(CC) \$$(CFLAGS) \$$(EXTRA_CFLAGS) -c $$src -o \$$@" >>$(depend); \
- done
-
- include $(depend)
-@@ -79,8 +79,7 @@ $(objects)/$(TARGET): $(OBJECTS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
-
- $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
-- $(AR) cru $@ $(SDLMAIN_OBJECTS)
-- $(RANLIB) $@
-+ $(LIBTOOL) --mode=link $(CC) -o $@ $(SDLMAIN_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
-
- install: all install-bin install-hdrs install-lib install-data install-man
- install-bin:
-@@ -95,8 +94,7 @@ install-hdrs:
- install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET)
- $(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)
- $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET)
-- $(INSTALL) -m 644 $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
-- $(RANLIB) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
-+ $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
- install-data:
- $(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(datadir)/aclocal
- $(INSTALL) -m 644 $(srcdir)/sdl.m4 $(DESTDIR)$(datadir)/aclocal/sdl.m4
-@@ -120,7 +118,7 @@ uninstall-hdrs:
- -rmdir $(DESTDIR)$(includedir)/SDL
- uninstall-lib:
- $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(TARGET)
-- rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
-+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
- uninstall-data:
- rm -f $(DESTDIR)$(datadir)/aclocal/sdl.m4
- rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl.pc
diff --git a/configure.in b/configure.in
-index a7e9b18..ea62977 100644
+index ab0e314..93c79be 100644
--- a/configure.in
-+++ b/configure.in
-@@ -181,7 +181,8 @@ if test x$enable_libc = xyes; then
- AC_DEFINE(HAVE_MPROTECT)
- ]),
- )
-- AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf iconv sigaction setjmp nanosleep)
-+ # TODO(bradnelson): Add back in iconv once it builds on pnacl mac.
-+ AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep)
-
- AC_CHECK_LIB(iconv, libiconv_open, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
- AC_CHECK_LIB(m, pow, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
-@@ -885,6 +886,50 @@ CheckVisibilityHidden()
++++ b/configure.in
+@@ -957,7 +957,7 @@ AC_HELP_STRING([--enable-naclvideo], [enable the nacl video driver [[default=yes
+ AC_DEFINE(SDL_VIDEO_DRIVER_NACL)
+ SOURCES="$SOURCES $srcdir/src/video/nacl/*.c"
+ EXTRA_LDFLAGS="-lppapi_simple -l${NACL_CXX_LIB:-stdc++} $EXTRA_LDFLAGS"
+- SDL_LIBS="-Wl,-unacl_main -Wl,-undefined=PSUserMainGet -lSDLmain $SDL_LIBS -lppapi_gles2 -lcli_main -lnacl_spawn -ltar -lppapi_simple -lnacl_io -lppapi -lm -l${NACL_CXX_LIB:-stdc++}"
++ SDL_LIBS="-lSDLmain $SDL_LIBS -lppapi_gles2 -lcli_main -lnacl_spawn -ltar -lppapi_simple_cpp -lnacl_io -lppapi -lm -l${NACL_CXX_LIB:-stdc++} -lppapi_cpp"
+ SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
fi
- }
-
-+dnl Check for Native Client stuff
-+CheckNativeClient()
-+{
-+ AC_ARG_ENABLE(naclvideo,
-+AC_HELP_STRING([--enable-naclvideo], [enable the nacl video driver [[default=yes]]]),
-+ , enable_naclvideo=yes)
-+ if test x$enable_video = xyes -a x$enable_naclvideo = xyes; then
-+ AC_DEFINE(SDL_VIDEO_DRIVER_NACL)
-+ SOURCES="$SOURCES $srcdir/src/video/nacl/*.cc"
-+ EXTRA_LDFLAGS="-lnacl_io -l${NACL_CPP_LIB:-stdc++} $EXTRA_LDFLAGS"
-+ SDL_LIBS="$SDL_LIBS -lppapi -lSDLmain -ltar"
-+ fi
-+
-+ AC_ARG_ENABLE(naclaudio,
-+AC_HELP_STRING([--enable-naclaudio], [enable the nacl audio driver [[default=yes]]]),
-+ , enable_naclaudio=yes)
-+ if test x$enable_audio = xyes -a x$enable_naclaudio = xyes; then
-+ AC_DEFINE(SDL_AUDIO_DRIVER_NACL)
-+ SOURCES="$SOURCES $srcdir/src/audio/nacl/*.cc"
-+ fi
-+}
-+
-+dnl Find Regal OpenGL library
-+CheckOpenGLRegal()
-+{
-+ if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
-+ AC_MSG_CHECKING(for OpenGL (Regal) support)
-+ video_opengl=no
-+ AC_TRY_COMPILE([
-+ #include <GL/Regal.h>
-+ ],[
-+ ],[
-+ video_opengl=yes
-+ ])
-+ AC_MSG_RESULT($video_opengl)
-+ if test x$video_opengl = xyes; then
-+ AC_DEFINE(SDL_VIDEO_OPENGL)
-+ AC_DEFINE(SDL_VIDEO_OPENGL_REGAL)
-+ EXTRA_LDFLAGS="-lRegal -lglslopt -lppapi_gles2 ${EXTRA_LDFLAGS}"
-+ SDL_LIBS="-lRegal -lglslopt -lppapi_gles2 ${SDL_LIBS}"
-+ fi
-+ fi
-+}
-+
- dnl Do the iPod thing
- CheckIPod()
-@@ -2284,6 +2329,22 @@ case "$host" in
+@@ -2449,7 +2449,7 @@ case "$host" in
have_timers=yes
fi
+ CheckPTHREAD
+- SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c"
++ SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.cc"
;;
-+ *-nacl)
-+ ARCH=nacl
-+ CheckNativeClient
-+ CheckOpenGLRegal
-+ CheckDummyAudio
-+ CheckDummyVideo
-+ CheckInputEvents
-+ # Set up files for the timer library
-+ if test x$enable_timers = xyes; then
-+ AC_DEFINE(SDL_TIMER_UNIX)
-+ SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
-+ have_timers=yes
-+ fi
-+ CheckPTHREAD
-+ SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c"
-+ ;;
*-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
case "$host" in
- *-*-linux*) ARCH=linux ;;
-@@ -2838,9 +2899,9 @@ OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
- OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
- OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
-
--SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.o,g'`
--SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.o,g'`
--SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
-+SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
-+SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
-+SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
-
- # Set runtime shared library paths as needed
-
-@@ -2866,6 +2927,9 @@ case "$ARCH" in
- # Evil hack to allow static linking on Mac OS X
- SDL_STATIC_LIBS="\${libdir}/libSDLmain.a \${libdir}/libSDL.a $EXTRA_LDFLAGS"
- ;;
-+ nacl)
-+ SDL_STATIC_LIBS="-Wl,--start-group -lSDLmain $SDL_LIBS $EXTRA_LDFLAGS -lSDLmain -ltar -Wl,--end-group"
-+ ;;
- *)
- SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
- ;;
-diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
-index 58593ca..150097d 100644
---- a/include/SDL_config.h.in
-+++ b/include/SDL_config.h.in
-@@ -174,6 +174,7 @@
- #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
- #undef SDL_AUDIO_DRIVER_MINT
- #undef SDL_AUDIO_DRIVER_MMEAUDIO
-+#undef SDL_AUDIO_DRIVER_NACL
- #undef SDL_AUDIO_DRIVER_NAS
- #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
- #undef SDL_AUDIO_DRIVER_OSS
-@@ -265,6 +266,7 @@
- #undef SDL_VIDEO_DRIVER_GEM
- #undef SDL_VIDEO_DRIVER_GGI
- #undef SDL_VIDEO_DRIVER_IPOD
-+#undef SDL_VIDEO_DRIVER_NACL
- #undef SDL_VIDEO_DRIVER_NANOX
- #undef SDL_VIDEO_DRIVER_OS2FS
- #undef SDL_VIDEO_DRIVER_PHOTON
-@@ -295,6 +297,7 @@
- /* Enable OpenGL support */
- #undef SDL_VIDEO_OPENGL
- #undef SDL_VIDEO_OPENGL_GLX
-+#undef SDL_VIDEO_OPENGL_REGAL
- #undef SDL_VIDEO_OPENGL_WGL
- #undef SDL_VIDEO_OPENGL_OSMESA
- #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
diff --git a/include/SDL_main.h b/include/SDL_main.h
-index b7f6b2c..cdde128 100644
+index 067d15e..ae6a9a6 100644
--- a/include/SDL_main.h
-+++ b/include/SDL_main.h
-@@ -32,7 +32,7 @@
- #if defined(__WIN32__) || \
- (defined(__MWERKS__) && !defined(__BEOS__)) || \
- defined(__MACOS__) || defined(__MACOSX__) || \
-- defined(__SYMBIAN32__) || defined(QWS)
-+ defined(__SYMBIAN32__) || defined(QWS) || defined(__native_client__)
-
- #ifdef __cplusplus
- #define C_LINKAGE "C"
-diff --git a/include/SDL_nacl.h b/include/SDL_nacl.h
-new file mode 100644
-index 0000000..7bb5683
---- /dev/null
-+++ b/include/SDL_nacl.h
-@@ -0,0 +1,26 @@
-+#ifndef _SDL_nacl_h
-+#define _SDL_nacl_h
-+
-+#include "begin_code.h"
-+#include <ppapi/c/pp_instance.h>
-+#include <ppapi/c/pp_resource.h>
-+#include <ppapi/c/ppb.h>
-+
-+/* Set up for C function definitions, even when using C++ */
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+void SDL_NACL_SetInstance(PP_Instance instance, PPB_GetInterface get_interface,
-+ int width, int height);
-+void SDL_NACL_PushEvent(PP_Resource input_event);
-+void SDL_NACL_SetHasFocus(int has_focus);
-+void SDL_NACL_SetPageVisible(int is_visible);
-+
-+/* Ends C function definitions when using C++ */
-+#ifdef __cplusplus
-+}
-+#endif
-+#include "close_code.h"
-+
-+#endif /* _SDL_nacl_h */
-diff --git a/include/SDL_opengl.h b/include/SDL_opengl.h
-index c479a3a..a0f4962 100644
---- a/include/SDL_opengl.h
-+++ b/include/SDL_opengl.h
-@@ -33,7 +33,7 @@
- #endif
- #include <windows.h>
- #endif
--#ifndef NO_SDL_GLEXT
-+#if !defined(NO_SDL_GLEXT) && !defined(__native_client__)
- #define __glext_h_ /* Don't let gl.h include glext.h */
- #endif
- #if defined(__MACOSX__)
-@@ -42,6 +42,10 @@
- #elif defined(__MACOS__)
- #include <gl.h> /* Header File For The OpenGL Library */
- #include <glu.h> /* Header File For The GLU Library */
-+#elif defined(__native_client__)
-+#include <GL/Regal.h>
-+#define APIENTRY
-+#define APIENTRYP APIENTRY *
- #else
- #include <GL/gl.h> /* Header File For The OpenGL Library */
- #include <GL/glu.h> /* Header File For The GLU Library */
-diff --git a/include/SDL_platform.h b/include/SDL_platform.h
-index 11d8673..dd99403 100644
---- a/include/SDL_platform.h
-+++ b/include/SDL_platform.h
-@@ -63,10 +63,14 @@
- #undef __IRIX__
- #define __IRIX__ 1
- #endif
--#if defined(linux) || defined(__linux) || defined(__linux__)
-+#if defined(linux) || defined(__linux) || defined(__linux__) && !defined(__native_client__)
- #undef __LINUX__
- #define __LINUX__ 1
- #endif
-+#if defined(__native_client__)
-+#undef __NACL__
-+#define __NACL__ 1
-+#endif
- #if defined(__APPLE__)
- #undef __MACOSX__
- #define __MACOSX__ 1
-diff --git a/src/SDL_fatal.c b/src/SDL_fatal.c
-index 15c0be7..82ceeef 100644
---- a/src/SDL_fatal.c
-+++ b/src/SDL_fatal.c
-@@ -39,7 +39,11 @@ static void SDL_Parachute(int sig)
- {
- signal(sig, SIG_DFL);
- SDL_Quit();
-+#ifdef __native_client__
-+ exit(sig);
-+#else
- raise(sig);
-+#endif
- }
-
- static int SDL_fatal_signals[] = {
-diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
-index bdeacdc..ac43356 100644
---- a/src/audio/SDL_audio.c
-+++ b/src/audio/SDL_audio.c
-@@ -36,6 +36,9 @@
-
- /* Available audio drivers */
- static AudioBootStrap *bootstrap[] = {
-+#if SDL_AUDIO_DRIVER_NACL
-+ &NACLAUD_bootstrap,
-+#endif
- #if SDL_AUDIO_DRIVER_BSD
- &BSD_AUDIO_bootstrap,
- #endif
-diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
-index 50cf179..7b9a0a7 100644
---- a/src/audio/SDL_sysaudio.h
-+++ b/src/audio/SDL_sysaudio.h
-@@ -156,6 +156,9 @@ extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
- extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
- extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
- #endif
-+#if SDL_AUDIO_DRIVER_NACL
-+extern AudioBootStrap NACLAUD_bootstrap;
-+#endif
- #if SDL_AUDIO_DRIVER_DISK
- extern AudioBootStrap DISKAUD_bootstrap;
- #endif
-diff --git a/src/audio/nacl/SDL_naclaudio.cc b/src/audio/nacl/SDL_naclaudio.cc
-new file mode 100644
-index 0000000..7a02156
---- /dev/null
-+++ b/src/audio/nacl/SDL_naclaudio.cc
-@@ -0,0 +1,140 @@
-+#include "SDL_config.h"
-+#include "SDL_naclaudio.h"
-+
-+#include <assert.h>
-+
-+#include <ppapi/c/pp_instance.h>
-+#include <ppapi/c/ppb.h>
-+#include <ppapi/c/ppb_audio.h>
-+#include <ppapi/c/ppb_audio_config.h>
-+#include <ppapi/c/ppb_core.h>
-+
-+extern PP_Instance g_nacl_pp_instance;
-+extern PPB_GetInterface g_nacl_get_interface;
-+extern const PPB_Core_1_0* g_nacl_core_interface;
-+
-+const PPB_Audio_1_1* g_nacl_audio_interface;
-+const PPB_AudioConfig_1_1* g_nacl_audio_config_interface;
-+
-+extern "C" {
-+
-+#include "SDL_rwops.h"
-+#include "SDL_timer.h"
-+#include "SDL_audio.h"
-+#include "SDL_mutex.h"
-+#include "../SDL_audiomem.h"
-+#include "../SDL_audio_c.h"
-+#include "../SDL_audiodev_c.h"
-+
-+/* The tag name used by NACL audio */
-+#define NACLAUD_DRIVER_NAME "nacl"
-+
-+const uint32_t kSampleFrameCount = 4096u;
-+
-+/* Audio driver functions */
-+static int NACLAUD_OpenAudio(_THIS, SDL_AudioSpec* spec);
-+static void NACLAUD_CloseAudio(_THIS);
-+
-+static void AudioCallback(void* samples, uint32_t buffer_size, PP_TimeDelta,
-+ void* data);
-+
-+/* Audio driver bootstrap functions */
-+static int NACLAUD_Available(void) {
-+ return g_nacl_pp_instance && g_nacl_get_interface;
-+}
-+
-+static void NACLAUD_DeleteDevice(SDL_AudioDevice* device) {
-+ if (device->hidden->audio) {
-+ g_nacl_audio_interface->StopPlayback(device->hidden->audio);
-+ g_nacl_core_interface->ReleaseResource(device->hidden->audio);
-+ device->hidden->audio = 0;
-+ }
-+}
-+
-+static SDL_AudioDevice* NACLAUD_CreateDevice(int devindex) {
-+ SDL_AudioDevice* _this;
-+
-+ /* Initialize all variables that we clean on shutdown */
-+ _this = (SDL_AudioDevice*)SDL_malloc(sizeof(SDL_AudioDevice));
-+ if (_this) {
-+ SDL_memset(_this, 0, (sizeof *_this));
-+ _this->hidden =
-+ (struct SDL_PrivateAudioData*)SDL_malloc((sizeof *_this->hidden));
-+ }
-+ if ((_this == NULL) || (_this->hidden == NULL)) {
-+ SDL_OutOfMemory();
-+ if (_this) {
-+ SDL_free(_this);
-+ }
-+ return (0);
-+ }
-+ SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
-+
-+ _this->hidden->mutex = SDL_CreateMutex();
-+
-+ // TODO: Move audio device creation to NACLAUD_OpenAudio.
-+ g_nacl_audio_interface =
-+ (const PPB_Audio_1_1*)g_nacl_get_interface(PPB_AUDIO_INTERFACE_1_1);
-+ g_nacl_audio_config_interface =
-+ (const PPB_AudioConfig_1_1*)g_nacl_get_interface(
-+ PPB_AUDIO_CONFIG_INTERFACE_1_1);
-+
-+ _this->hidden->sample_frame_count =
-+ g_nacl_audio_config_interface->RecommendSampleFrameCount(
-+ g_nacl_pp_instance, PP_AUDIOSAMPLERATE_44100, kSampleFrameCount);
-+
-+ PP_Resource audio_config = g_nacl_audio_config_interface->CreateStereo16Bit(
-+ g_nacl_pp_instance, PP_AUDIOSAMPLERATE_44100,
-+ _this->hidden->sample_frame_count);
-+ _this->hidden->audio = g_nacl_audio_interface->Create(
-+ g_nacl_pp_instance, audio_config, AudioCallback, _this);
-+
-+ // Start audio playback while we are still on the main thread.
-+ g_nacl_audio_interface->StartPlayback(_this->hidden->audio);
-+
-+ /* Set the function pointers */
-+ _this->OpenAudio = NACLAUD_OpenAudio;
-+ _this->CloseAudio = NACLAUD_CloseAudio;
-+
-+ _this->free = NACLAUD_DeleteDevice;
-+
-+ return _this;
-+}
-+
-+AudioBootStrap NACLAUD_bootstrap = {
-+ NACLAUD_DRIVER_NAME, "SDL nacl audio driver",
-+ NACLAUD_Available, NACLAUD_CreateDevice
-+};
-+
-+static void NACLAUD_CloseAudio(_THIS) {
-+}
-+
-+static void AudioCallback(void* samples, uint32_t buffer_size, PP_TimeDelta,
-+ void* data) {
-+ SDL_AudioDevice* _this = reinterpret_cast<SDL_AudioDevice*>(data);
-+
-+ SDL_LockMutex(_this->hidden->mutex);
-+ /* Only do anything if audio is enabled and not paused */
-+ if (_this->enabled && !_this->paused) {
-+ SDL_memset(samples, _this->spec.silence, buffer_size);
-+ SDL_LockMutex(_this->mixer_lock);
-+ (*_this->spec.callback)(_this->spec.userdata, (Uint8*)samples, buffer_size);
-+ SDL_UnlockMutex(_this->mixer_lock);
-+ } else {
-+ SDL_memset(samples, 0, buffer_size);
-+ }
-+ SDL_UnlockMutex(_this->hidden->mutex);
-+
-+ return;
-+}
-+
-+static int NACLAUD_OpenAudio(_THIS, SDL_AudioSpec* spec) {
-+ // We don't care what the user wants.
-+ spec->freq = 44100;
-+ spec->format = AUDIO_S16LSB;
-+ spec->channels = 2;
-+ spec->samples = _this->hidden->sample_frame_count;
-+ return 1;
-+}
-+
-+} // extern "C"
-diff --git a/src/audio/nacl/SDL_naclaudio.h b/src/audio/nacl/SDL_naclaudio.h
++++ b/include/SDL_main.h
+@@ -54,7 +54,7 @@
+ #define main SDL_main
+
+ /** The prototype for the application's main() function */
+-extern C_LINKAGE int SDL_main(int argc, char *argv[]);
++extern C_LINKAGE int SDL_main(int argc, char *argv[]);
+
+
+ /** @name From the SDL library code -- needed for registering the app on Win32 */
+diff --git a/src/main/nacl/SDL_nacl_main.c b/src/main/nacl/SDL_nacl_main.c
+deleted file mode 100644
+index ef26120..0000000
+--- a/src/main/nacl/SDL_nacl_main.c
++++ /dev/null
+@@ -1,125 +0,0 @@
+-/*
+- Simple DirectMedia Layer
+- Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
+-
+- This software is provided 'as-is', without any express or implied
+- warranty. In no event will the authors be held liable for any damages
+- arising from the use of this software.
+-
+- Permission is granted to anyone to use this software for any purpose,
+- including commercial applications, and to alter it and redistribute it
+- freely, subject to the following restrictions:
+-
+- 1. The origin of this software must not be misrepresented; you must not
+- claim that you wrote the original software. If you use this software
+- in a product, an acknowledgment in the product documentation would be
+- appreciated but is not required.
+- 2. Altered source versions must be plainly marked as such, and must not be
+- misrepresented as being the original software.
+- 3. This notice may not be removed or altered from any source distribution.
+-*/
+-#include "SDL_config.h"
+-
+-#if SDL_VIDEO_DRIVER_NACL
+-
+-/* Include the SDL main definition header */
+-#include "SDL_main.h"
+-#include "../../SDL_trace.h"
+-
+-#include <errno.h>
+-#include <ppapi_simple/ps_main.h>
+-#include <ppapi_simple/ps_event.h>
+-#include <ppapi_simple/ps_interface.h>
+-#include <nacl_io/nacl_io.h>
+-#include <sys/mount.h>
+-#include <nacl_main.h>
+-#include <unistd.h>
+-
+-extern void NACL_SetScreenResolution(int width, int height);
+-
+-static int
+-ProcessArgs(int argc, char** argv) {
+- const char* arg = getenv("SDL_TAR_EXTRACT");
+- if (arg != NULL) {
+- const char* source;
+- const char* target = "/";
+- char* sep;
+- char buf[64];
+- int n;
+-
+- const char* q, *p = arg;
+- while (*p) {
+- while (*p && isspace((unsigned char)*p)) ++p;
+- if (!*p) break;
+- q = p;
+- while (*p && !isspace((unsigned char)*p)) ++p;
+-
+- n = sizeof(buf) - 1;
+- if (p - q < n) n = p - q;
+- strncpy(buf, q, n);
+- buf[n] = '\0';
+-
+- sep = strchr(buf, ':');
+- source = buf;
+- if (sep) {
+- target = sep + 1;
+- *sep = '\0';
+- }
+-
+- SDL_log("extracting tar file '%s' -> '%s'\n", source, target);
+- if (nacl_startup_untar(argv[0], source, target) != 0)
+- return 1;
+- }
+- }
+-
+- return 0;
+-}
+-
+-/* This is started in a worker thread by ppapi_simple! */
+-int
+-nacl_main(int argc, char *argv[])
+-{
+- SDL_TRACE("nacl_main\n");
+- PSEvent* ps_event;
+- PP_Resource event;
+- struct PP_Rect rect;
+- int ready = 0;
+- const PPB_View *ppb_view = PSInterfaceView();
+-
+- if (ProcessArgs(argc, argv) != 0) {
+- return 1;
+- }
+-
+- /* Wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before starting the app */
+- PSEventSetFilter(PSE_INSTANCE_DIDCHANGEVIEW);
+- /* Process all waiting events without blocking */
+- while (!ready) {
+- ps_event = PSEventWaitAcquire();
+- event = ps_event->as_resource;
+- switch(ps_event->type) {
+- /* From DidChangeView, contains a view resource */
+- case PSE_INSTANCE_DIDCHANGEVIEW:
+- ppb_view->GetRect(event, &rect);
+- NACL_SetScreenResolution(rect.size.width, rect.size.height);
+- ready = 1;
+- break;
+- default:
+- break;
+- }
+- PSEventRelease(ps_event);
+- }
+-
+- /*
+- * Startup in /mnt/http by default so resources hosted on the webserver
+- * are accessible in the current working directory.
+- */
+- if (getenv("PWD") == NULL) {
+- if (chdir("/mnt/http") != 0) {
+- SDL_log("chdir to /mnt/http failed: %s\n", strerror(errno));
+- }
+- }
+-
+- return SDL_main(argc, argv);
+-}
+-
+-#endif /* SDL_VIDEO_DRIVER_NACL */
+diff --git a/src/main/nacl/SDL_nacl_main.cc b/src/main/nacl/SDL_nacl_main.cc
new file mode 100644
-index 0000000..ab52848
+index 0000000..ee80b9a
--- /dev/null
-+++ b/src/audio/nacl/SDL_naclaudio.h
-@@ -0,0 +1,23 @@
++++ b/src/main/nacl/SDL_nacl_main.cc
+@@ -0,0 +1,129 @@
++/*
++ Simple DirectMedia Layer
++ Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
++
++ This software is provided 'as-is', without any express or implied
++ warranty. In no event will the authors be held liable for any damages
++ arising from the use of this software.
++
++ Permission is granted to anyone to use this software for any purpose,
++ including commercial applications, and to alter it and redistribute it
++ freely, subject to the following restrictions:
++
++ 1. The origin of this software must not be misrepresented; you must not
++ claim that you wrote the original software. If you use this software
++ in a product, an acknowledgment in the product documentation would be
++ appreciated but is not required.
++ 2. Altered source versions must be plainly marked as such, and must not be
++ misrepresented as being the original software.
++ 3. This notice may not be removed or altered from any source distribution.
++*/
+#include "SDL_config.h"
+
-+#ifndef _SDL_naclaudio_h
-+#define _SDL_naclaudio_h
-+
-+extern "C" {
-+#include "SDL_audio.h"
-+#include "../SDL_sysaudio.h"
-+#include "SDL_mutex.h"
-+}
-+
-+#include <ppapi/c/ppb_audio.h>
-+
-+/* Hidden "this" pointer for the video functions */
-+#define _THIS SDL_AudioDevice *_this
-+
-+struct SDL_PrivateAudioData {
-+ SDL_mutex* mutex;
-+ int sample_frame_count;
-+ PP_Resource audio;
-+};
-+
-+#endif /* _SDL_naclaudio_h */
-diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
-index 5c2d81f..7a757a3 100644
---- a/src/cpuinfo/SDL_cpuinfo.c
-+++ b/src/cpuinfo/SDL_cpuinfo.c
-@@ -53,6 +53,8 @@ static void illegal_instruction(int sig)
- }
- #endif /* HAVE_SETJMP */
-
-+
-+#if SDL_ASSEMBLY_ROUTINES
- static __inline__ int CPU_haveCPUID(void)
- {
- int has_CPUID = 0;
-@@ -280,6 +282,15 @@ done:
- return features;
- }
-
-+#else // SDL_ASSEMBLY_ROUTINES
-+
-+static __inline__ int CPU_haveCPUID(void) { return 0; }
-+static __inline__ int CPU_getCPUIDFeaturesExt(void) { return 0; }
-+static __inline__ int CPU_getCPUIDFeatures(void) { return 0; }
-+
-+#endif // SDL_ASSEMBLY_ROUTINES
++#if SDL_VIDEO_DRIVER_NACL
+
++/* Include the SDL main definition header */
++#include "SDL_main.h"
++#include "../../SDL_trace.h"
+
- static __inline__ int CPU_haveRDTSC(void)
- {
- if ( CPU_haveCPUID() ) {
-diff --git a/src/main/nacl/pepper_instance.c b/src/main/nacl/pepper_instance.c
-new file mode 100644
-index 0000000..7604d37
---- /dev/null
-+++ b/src/main/nacl/pepper_instance.c
-@@ -0,0 +1,355 @@
-+/*
-+ * Copyright (c) 2011 The Native Client Authors. All rights reserved.
-+ * Use of this source code is governed by a BSD-style license that can be
-+ * found in the LICENSE file.
-+ */
-+#include <assert.h>
+#include <errno.h>
-+#include <fcntl.h>
-+#include <libtar.h>
-+#include <pthread.h>
-+#include <stdio.h>
-+#include <string.h>
++#include <ppapi_simple/ps_main.h>
++#include <ppapi_simple/ps_event.h>
++#include <ppapi_simple/ps_interface.h>
++#include <nacl_io/nacl_io.h>
+#include <sys/mount.h>
++#include <nacl_main.h>
+#include <unistd.h>
+
-+#include <SDL.h>
-+#include <SDL_nacl.h>
-+#include <SDL_video.h>
-+#include <SDL_main.h>
-+
-+#include <ppapi/c/pp_errors.h>
-+#include <ppapi/c/pp_instance.h>
-+#include <ppapi/c/ppb.h>
-+#include <ppapi/c/ppb_input_event.h>
-+#include <ppapi/c/ppb_messaging.h>
-+#include <ppapi/c/ppb_var.h>
-+#include <ppapi/c/ppb_view.h>
-+#include <ppapi/c/ppp.h>
-+#include <ppapi/c/ppp_input_event.h>
-+#include <ppapi/c/ppp_instance.h>
-+#include <ppapi/c/pp_rect.h>
-+
-+#include "nacl_io/nacl_io.h"
-+#include "nacl_io/ioctl.h"
-+#include "nacl_io/log.h"
-+
-+static PP_Instance g_instance;
-+static PPB_GetInterface g_get_browser_interface;
-+static struct PPB_Messaging_1_0* g_messaging_interface;
-+static struct PPB_Var_1_1* g_var_interface;
-+static struct PPB_InputEvent_1_0* g_input_event_interface;
-+static struct PPB_View_1_1* g_view_interface;
-+static int g_width = 0;
-+static int g_height = 0;
-+static int g_argc;
-+static const char** g_argn;
-+static const char** g_argv;
-+static const char* g_tty_prefix;
-+static pthread_t g_sdl_thread;
-+
-+static void* sdl_thread_start(void*);
-+static void ProcessArgs();
-+
-+static PP_Bool Instance_DidCreate(PP_Instance instance, uint32_t argc,
-+ const char* argn[], const char* argv[]) {
-+ int i;
-+
-+ g_instance = instance;
-+ g_input_event_interface->RequestInputEvents(instance,
-+ PP_INPUTEVENT_CLASS_MOUSE);
-+ g_input_event_interface->RequestFilteringInputEvents(
-+ instance, PP_INPUTEVENT_CLASS_KEYBOARD);
-+
-+ nacl_io_init_ppapi(instance, g_get_browser_interface);
-+
-+ // Copy args so they can be processed later by the SDL thread.
-+ g_argc = argc;
-+ g_argn = (const char**)malloc(argc * sizeof(char*));
-+ g_argv = (const char**)malloc(argc * sizeof(char*));
-+ memset(g_argn, 0, argc * sizeof(char*));
-+ memset(g_argv, 0, argc * sizeof(char*));
-+
-+ for (i = 0; i < argc; i++) {
-+ if (argn[i]) g_argn[i] = strdup(argn[i]);
-+ if (argv[i]) g_argv[i] = strdup(argv[i]);
-+ }
-+
-+ return PP_TRUE;
-+}
-+
-+static void Instance_DidDestroy(PP_Instance instance) {}
-+
-+static void Instance_DidChangeView(PP_Instance instance,
-+ PP_Resource view_resource) {
-+ struct PP_Rect view_rect;
-+ if (g_width && g_height) return;
-+
-+ if (g_view_interface->GetRect(view_resource, &view_rect) == PP_FALSE) {
-+ fprintf(stderr, "SDL: Unable to get view rect!\n");
-+ return;
-+ }
-+
-+ if (view_rect.size.width == g_width && view_rect.size.height == g_height)
-+ return; // Size didn't change, no need to update anything.
-+
-+ g_width = view_rect.size.width;
-+ g_height = view_rect.size.height;
-+
-+ SDL_NACL_SetInstance(g_instance, g_get_browser_interface, g_width, g_height);
-+ pthread_create(&g_sdl_thread, NULL, sdl_thread_start, NULL);
-+}
-+
-+/*
-+ * Entry point for the main SDL thread. The job of this thread is to
-+ * run SDL_main, which in most cases is the application's main() function
-+ * re-defined by the pre-processor in SDL_main.h.
-+ */
-+static void* sdl_thread_start(void* arg) {
-+ char* argv[2];
-+ int rtn;
-+
-+ ProcessArgs();
-+ fprintf(stderr, "SDL: calling SDL_main\n");
-+ argv[0] = (char*)"SDL applicaiton";
-+ argv[1] = NULL;
-+ rtn = SDL_main(1, argv);
-+ fprintf(stderr, "SDL: SDL_main returned: %d\n", rtn);
-+ exit(rtn);
-+ return NULL;
-+}
-+
-+static ssize_t TtyOutputHandler(const char* buf, size_t count, void* user_data) {
-+ // We prepend the prefix_ to the data in buf, then package it up
-+ // and post it as a message to javascript.
-+ char* message = (char*)malloc(count + strlen(g_tty_prefix));
-+ strcpy(message, g_tty_prefix);
-+ memcpy(message + strlen(g_tty_prefix), buf, count);
-+ struct PP_Var var = g_var_interface->VarFromUtf8(message, count + strlen(g_tty_prefix));
-+ g_messaging_interface->PostMessage(g_instance, var);
-+ g_var_interface->Release(var);
-+ free(message);
-+ return count;
-+}
-+
-+static void ProcessArgs() {
-+ int i;
-+ int rtn;
-+ int mount_default = 1;
-+ nacl_io_log("SDL: ProcessArgs %d\n", g_argc);
-+
-+ // This could fail if the sdl_mount_http attributes
-+ // above created a mount on "/".
-+ fprintf(stderr, "SDL: creating memfs on root\n");
-+
-+ rtn = umount("/");
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: umount failed: %s\n", strerror(errno));
-+
-+ rtn = mount("", "/", "memfs", 0, "");
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: mount failed: %s\n", strerror(errno));
-+
-+ rtn = mkdir("/tmp", S_IRWXU | S_IRWXG);
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: mkdir /tmp failed: %s\n", strerror(errno));
-+
-+ rtn = mkdir("/home", S_IRWXU | S_IRWXG);
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: mkdir /home failed: %s\n", strerror(errno));
-+
-+ rtn = mount("", "/tmp", "html5fs", 0, "type=TEMPORARY");
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: mount /tmp failed: %s\n", strerror(errno));
-+
-+ for (i = 0; i < g_argc; i++) {
-+ if (!strcmp(g_argn[i], "ps_stdout")) {
-+ int fd1 = open(g_argv[i], O_WRONLY);
-+ dup2(fd1, 1);
-+ } else if (!strcmp(g_argn[i], "ps_stderr")) {
-+ int fd2 = open(g_argv[i], O_WRONLY);
-+ dup2(fd2, 2);
-+ } else if (!strcmp(g_argn[i], "ps_tty_prefix")) {
-+ g_tty_prefix = g_argv[i];
-+ struct tioc_nacl_output handler;
-+ handler.handler = TtyOutputHandler;
-+ handler.user_data = NULL;
-+ int tty_fd = open("/dev/tty", O_WRONLY);
-+ if (tty_fd != -1) {
-+ ioctl(tty_fd, TIOCNACLOUTPUT, &handler);
-+ close(tty_fd);
-+ }
-+ } else if (!strcmp(g_argn[i], "fs_pers")) {
-+ mount_default = 0;
-+ char *ptr;
-+ long sz = strtol(g_argv[i], &ptr, 10);
-+ fprintf(stderr, "SDL: adding html5fs mount size: %ld\n", sz);
-+ if (sz > 0) {
-+ char params[255];
-+ sprintf(params, "type=PERSISTENT,expected_size=%ld", sz);
-+ if (mount("", "/persistent", "html5fs", 0, params))
-+ fprintf (stderr, "mount failed");
-+ } else {
-+ fprintf (stderr, "zero fs size");
-+ }
-+ }
-+ else if (!strcmp(g_argn[i], "fs_http")) {
-+ mount_default = 0;
-+ mount(g_argv[i], "/http", "httpfs", 0, "");
-+ } else if (!strcmp(g_argn[i], "sdl_mount_http")) {
-+ const char* source;
-+ const char* target = "/";
-+ char* sep;
-+ char buf[64];
-+ int n;
-+
-+ const char* q, *p = g_argv[i];
-+ while (*p) {
-+ while (*p && isspace(*p)) ++p;
-+ if (!*p) break;
-+ q = p;
-+ while (*p && !isspace(*p)) ++p;
-+
-+ n = sizeof(buf) - 1;
-+ if (p - q < n) n = p - q;
-+ strncpy(buf, q, n);
-+ buf[n] = '\0';
-+
-+ sep = strchr(buf, ':');
-+ source = buf;
-+ if (sep) {
-+ target = sep + 1;
-+ *sep = '\0';
-+ }
-+
-+ mount_default = 0;
-+ fprintf(stderr, "SDL: adding http mount '%s' -> '%s'\n", source,
-+ target);
-+ rtn = mount(source, target, "httpfs", 0, "");
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: mount failed: %s\n", strerror(errno));
-+ }
-+ }
-+ }
-+
-+ if (mount_default) {
-+ // Create an http mount by default
-+ fprintf(stderr, "SDL: creating default http mount 1\n");
-+ rtn = chdir("/home");
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: chdir failed: %s\n", strerror(errno));
-+ rtn = mount(".", "/home", "httpfs", 0, "");
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: mount failed: %s\n", strerror(errno));
-+ }
-+
-+ for (i = 0; i < g_argc; i++) {
-+ nacl_io_log("SDL: arg=%s\n", g_argn[i]);
-+ if (!strcasecmp(g_argn[i], "PWD")) {
-+ int rtn = chdir(g_argv[i]);
-+ if (rtn != 0)
-+ nacl_io_log("SDL: chdir(%s) failed\n", g_argv[i]);
-+ else
-+ nacl_io_log("SDL: chdir(%s)\n", g_argv[i]);
-+ } else if (!strcmp(g_argn[i], "sdl_tar_extract")) {
-+ const char* source;
-+ const char* target = "/";
-+ char* sep;
-+ char buf[64];
-+ int n;
-+
-+ const char* q, *p = g_argv[i];
-+ while (*p) {
-+ while (*p && isspace(*p)) ++p;
-+ if (!*p) break;
-+ q = p;
-+ while (*p && !isspace(*p)) ++p;
-+
-+ n = sizeof(buf) - 1;
-+ if (p - q < n) n = p - q;
-+ strncpy(buf, q, n);
-+ buf[n] = '\0';
-+
-+ sep = strchr(buf, ':');
-+ source = buf;
-+ if (sep) {
-+ target = sep + 1;
-+ *sep = '\0';
-+ }
-+
-+ fprintf(stderr, "SDL: extracting tar file '%s' -> '%s'\n", source,
-+ target);
-+
-+ TAR* tar;
-+ rtn = tar_open(&tar, (char*)source, NULL, O_RDONLY, 0, 0);
-+ if (rtn != 0) {
-+ fprintf(stderr, "SDL: tar_open failed\n");
-+ assert(0);
-+ continue;
-+ }
-+
-+ rtn = mkdir(target, S_IRWXU | S_IRWXG);
-+ if (rtn != 0)
-+ fprintf(stderr, "SDL: mkdir failed: %s\n", strerror(errno));
-+
-+ rtn = tar_extract_all(tar, (char*)target);
-+ if (rtn != 0) {
-+ fprintf(stderr, "SDL: tar_extract_all failed\n");
-+ assert(0);
-+ }
-+
-+ rtn = tar_close(tar);
-+ if (rtn != 0) {
-+ fprintf(stderr, "SDL: tar_clone failed\n");
-+ assert(0);
++extern "C" void NACL_SetScreenResolution(int width, int height);
++
++static int
++ProcessArgs(int argc, char** argv) {
++ const char* arg = getenv("SDL_TAR_EXTRACT");
++ if (arg != NULL) {
++ const char* source;
++ const char* target = "/";
++ char* sep;
++ char buf[64];
++ int n;
++
++ const char* q, *p = arg;
++ while (*p) {
++ while (*p && isspace((unsigned char)*p)) ++p;
++ if (!*p) break;
++ q = p;
++ while (*p && !isspace((unsigned char)*p)) ++p;
++
++ n = sizeof(buf) - 1;
++ if (p - q < n) n = p - q;
++ strncpy(buf, q, n);
++ buf[n] = '\0';
++
++ sep = strchr(buf, ':');
++ source = buf;
++ if (sep) {
++ target = sep + 1;
++ *sep = '\0';
++ }
++
++ SDL_log("extracting tar file '%s' -> '%s'\n", source, target);
++ if (nacl_startup_untar(argv[0], source, target) != 0)
++ return 1;
+ }
-+ }
+ }
-+ }
-+}
-+
-+static void Instance_DidChangeFocus(PP_Instance instance, PP_Bool has_focus) {}
-+
-+static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance,
-+ PP_Resource url_loader) {
-+ return PP_FALSE;
-+}
-+
-+static PP_Bool InputEvent_HandleInputEvent(PP_Instance instance,
-+ PP_Resource input_event) {
-+ SDL_NACL_PushEvent(input_event);
-+ return PP_TRUE;
-+}
-+
-+PP_EXPORT int32_t
-+PPP_InitializeModule(PP_Module module, PPB_GetInterface get_browser) {
-+ g_get_browser_interface = get_browser;
-+ g_input_event_interface =
-+ (struct PPB_InputEvent_1_0*)get_browser(PPB_INPUT_EVENT_INTERFACE_1_0);
-+ g_messaging_interface =
-+ (struct PPB_InputEvent_1_0*)get_browser(PPB_MESSAGING_INTERFACE_1_0);
-+ g_var_interface = (struct PPB_Var_1_1*)get_browser(PPB_VAR_INTERFACE_1_1);
-+ g_view_interface = (struct PPB_View_1_1*)get_browser(PPB_VIEW_INTERFACE_1_1);
-+ return PP_OK;
-+}
-+
-+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
-+ if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) {
-+ static struct PPP_Instance_1_1 instance_interface = {
-+ &Instance_DidCreate,
-+ &Instance_DidDestroy,
-+ &Instance_DidChangeView,
-+ &Instance_DidChangeFocus,
-+ &Instance_HandleDocumentLoad,
-+ };
-+ return &instance_interface;
-+ } else if (strcmp(interface_name, PPP_INPUT_EVENT_INTERFACE_0_1) == 0) {
-+ static struct PPP_InputEvent_0_1 input_event_interface = {
-+ &InputEvent_HandleInputEvent,
-+ };
-+ return &input_event_interface;
-+ }
-+ return NULL;
-+}
+
-+PP_EXPORT void PPP_ShutdownModule() {}
-diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c
-index 479bf34..a3b9119 100644
---- a/src/thread/pthread/SDL_systhread.c
-+++ b/src/thread/pthread/SDL_systhread.c
-@@ -81,12 +81,15 @@ void SDL_SYS_SetupThread(void)
- int i;
- sigset_t mask;
-
-+ // NativeClient does not yet support signals.
-+#ifndef __NACL__
- /* Mask asynchronous signals for this thread */
- sigemptyset(&mask);
- for ( i=0; sig_list[i]; ++i ) {
- sigaddset(&mask, sig_list[i]);
- }
- pthread_sigmask(SIG_BLOCK, &mask, 0);
-+#endif
-
- #ifdef PTHREAD_CANCEL_ASYNCHRONOUS
- /* Allow ourselves to be asynchronously cancelled */
-diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
-index 1c72e09..9fc1a85 100644
---- a/src/video/SDL_sysvideo.h
-+++ b/src/video/SDL_sysvideo.h
-@@ -317,6 +317,9 @@ typedef struct VideoBootStrap {
- SDL_VideoDevice *(*create)(int devindex);
- } VideoBootStrap;
-
-+#if SDL_VIDEO_DRIVER_NACL
-+extern VideoBootStrap NACL_bootstrap;
-+#endif
- #if SDL_VIDEO_DRIVER_QUARTZ
- extern VideoBootStrap QZ_bootstrap;
- #endif
-diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
-index e84ef35..f8a5090 100644
---- a/src/video/SDL_video.c
-+++ b/src/video/SDL_video.c
-@@ -33,6 +33,9 @@
-
- /* Available video drivers */
- static VideoBootStrap *bootstrap[] = {
-+#if SDL_VIDEO_DRIVER_NACL
-+ &NACL_bootstrap,
-+#endif
- #if SDL_VIDEO_DRIVER_QUARTZ
- &QZ_bootstrap,
- #endif
-@@ -764,6 +767,8 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
- #define __SDL_NOGETPROCADDR__
- #elif defined(__MINT__)
- #define __SDL_NOGETPROCADDR__
-+#elif defined(__native_client__)
-+#define __SDL_NOGETPROCADDR__
- #endif
- #ifdef __SDL_NOGETPROCADDR__
- #define SDL_PROC(ret,func,params) video->func=func;
-diff --git a/src/video/nacl/SDL_naclevents.cc b/src/video/nacl/SDL_naclevents.cc
-new file mode 100644
-index 0000000..c9eaea8
---- /dev/null
-+++ b/src/video/nacl/SDL_naclevents.cc
-@@ -0,0 +1,320 @@
-+#include "SDL_config.h"
-+
-+#include "SDL_nacl.h"
-+
-+extern "C" {
-+#include "SDL.h"
-+#include "../../events/SDL_sysevents.h"
-+#include "../../events/SDL_events_c.h"
-+}
-+
-+#include "SDL_naclevents_c.h"
-+#include "eventqueue.h"
-+#include <ppapi/c/pp_point.h>
-+#include <ppapi/c/pp_var.h>
-+#include <ppapi/c/ppb_input_event.h>
-+#include <ppapi/c/ppb_var.h>
-+
-+#include <math.h>
-+
-+extern const PPB_InputEvent_1_0 *g_nacl_input_event_interface;
-+extern const PPB_MouseInputEvent_1_1 *g_nacl_mouse_input_event_interface;
-+extern const PPB_WheelInputEvent_1_0 *g_nacl_wheel_input_event_interface;
-+extern const PPB_KeyboardInputEvent_1_0 *g_nacl_keyboard_input_event_interface;
-+extern const PPB_Var_1_1 *g_nacl_var_interface;
-+
-+static EventQueue event_queue;
-+
-+static Uint8 translateButton(int32_t button) {
-+ switch (button) {
-+ case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
-+ return SDL_BUTTON_LEFT;
-+ case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
-+ return SDL_BUTTON_MIDDLE;
-+ case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
-+ return SDL_BUTTON_RIGHT;
-+ case PP_INPUTEVENT_MOUSEBUTTON_NONE:
-+ default:
-+ return 0;
-+ }
-+}
-+
-+// Translate ASCII code to browser keycode
-+static uint8_t translateAscii(uint8_t ascii) {
-+ if ('A' <= ascii && ascii <= 'Z') {
-+ return ascii;
-+ } else if ('a' <= ascii && ascii <= 'z') {
-+ return toupper(ascii);
-+ } else if ('0' <= ascii && ascii <= '9') {
-+ return ascii;
-+ } else if (' ' == ascii || '\r' == ascii || '\t' == ascii ||
-+ '\x1b' == ascii || '\b' == ascii) {
-+ return ascii;
-+ } else {
-+ switch (ascii) {
-+ case '!': return '1';
-+ case '@': return '2';
-+ case '#': return '3';
-+ case '$': return '4';
-+ case '%': return '5';
-+ case '^': return '6';
-+ case '&': return '7';
-+ case '*': return '8';
-+ case '(': return '9';
-+ case ')': return '0';
-+ case ';': case ':': return 186;
-+ case '=': case '+': return 187;
-+ case ',': case '<': return 188;
-+ case '-': case '_': return 189;
-+ case '.': case '>': return 190;
-+ case '/': case '?': return 191;
-+ case '`': case '~': return 192;
-+ case '[': case '{': return 219;
-+ case '\\': case '|': return 220;
-+ case ']': case '}': return 221;
-+ case '\'': case '"': return 222;
-+ default:
-+ break;
-+ }
-+ }
-+ return 0;
-+}
-+
-+// Translate browser keycode to SDLKey
-+static SDLKey translateKey(uint32_t code) {
-+ if (code >= 'A' && code <= 'Z')
-+ return (SDLKey)(code - 'A' + SDLK_a);
-+ if (code >= SDLK_0 && code <= SDLK_9)
-+ return (SDLKey)code;
-+ const uint32_t f1_code = 112;
-+ if (code >= f1_code && code < f1_code + 12)
-+ return (SDLKey)(code - f1_code + SDLK_F1);
-+ const uint32_t kp0_code = 96;
-+ if (code >= kp0_code && code < kp0_code + 10)
-+ return (SDLKey)(code - kp0_code + SDLK_KP0);
-+ switch (code) {
-+ case SDLK_BACKSPACE:
-+ return SDLK_BACKSPACE;
-+ case SDLK_TAB:
-+ return SDLK_TAB;
-+ case SDLK_RETURN:
-+ return SDLK_RETURN;
-+ case SDLK_PAUSE:
-+ return SDLK_PAUSE;
-+ case SDLK_ESCAPE:
-+ return SDLK_ESCAPE;
-+ case 16:
-+ return SDLK_LSHIFT;
-+ case 17:
-+ return SDLK_LCTRL;
-+ case 18:
-+ return SDLK_LALT;
-+ case 32:
-+ return SDLK_SPACE;
-+ case 37:
-+ return SDLK_LEFT;
-+ case 38:
-+ return SDLK_UP;
-+ case 39:
-+ return SDLK_RIGHT;
-+ case 40:
-+ return SDLK_DOWN;
-+ case 106:
-+ return SDLK_KP_MULTIPLY;
-+ case 107:
-+ return SDLK_KP_PLUS;
-+ case 109:
-+ return SDLK_KP_MINUS;
-+ case 110:
-+ return SDLK_KP_PERIOD;
-+ case 111:
-+ return SDLK_KP_DIVIDE;
-+ case 45:
-+ return SDLK_INSERT;
-+ case 46:
-+ return SDLK_DELETE;
-+ case 36:
-+ return SDLK_HOME;
-+ case 35:
-+ return SDLK_END;
-+ case 33:
-+ return SDLK_PAGEUP;
-+ case 34:
-+ return SDLK_PAGEDOWN;
-+ case 189:
-+ return SDLK_MINUS;
-+ case 187:
-+ return SDLK_EQUALS;
-+ case 219:
-+ return SDLK_LEFTBRACKET;
-+ case 221:
-+ return SDLK_RIGHTBRACKET;
-+ case 186:
-+ return SDLK_SEMICOLON;
-+ case 222:
-+ return SDLK_QUOTE;
-+ case 220:
-+ return SDLK_BACKSLASH;
-+ case 188:
-+ return SDLK_COMMA;
-+ case 190:
-+ return SDLK_PERIOD;
-+ case 191:
-+ return SDLK_SLASH;
-+ case 192:
-+ return SDLK_BACKQUOTE;
-+ default:
-+ return SDLK_UNKNOWN;
-+ }
-+}
-+
-+static SDL_Event *copyEvent(SDL_Event *event) {
-+ SDL_Event *event_copy = (SDL_Event*)malloc(sizeof(SDL_Event));
-+ *event_copy = *event;
-+ return event_copy;
-+}
-+
-+void SDL_NACL_PushEvent(PP_Resource input_event) {
-+ static Uint8 last_scancode = 0;
-+ SDL_keysym keysym;
-+ static double wheel_clicks_x;
-+ static double wheel_clicks_y;
-+ SDL_Event event;
-+ PP_InputEvent_Type type = g_nacl_input_event_interface->GetType(input_event);
-+
-+ if (type == PP_INPUTEVENT_TYPE_MOUSEDOWN ||
-+ type == PP_INPUTEVENT_TYPE_MOUSEUP) {
-+ event.type = (type == PP_INPUTEVENT_TYPE_MOUSEUP) ? SDL_MOUSEBUTTONUP
-+ : SDL_MOUSEBUTTONDOWN;
-+ event.button.button = translateButton(
-+ g_nacl_mouse_input_event_interface->GetButton(input_event));
-+ PP_Point point =
-+ g_nacl_mouse_input_event_interface->GetPosition(input_event);
-+ event.button.x = point.x;
-+ event.button.y = point.y;
-+ event_queue.PushEvent(copyEvent(&event));
-+ } else if (type == PP_INPUTEVENT_TYPE_WHEEL) {
-+ PP_FloatPoint ticks =
-+ g_nacl_wheel_input_event_interface->GetTicks(input_event);
-+ wheel_clicks_x += ticks.x;
-+ wheel_clicks_y += ticks.y;
-+ int sdl_wheel_clicks_x = trunc(wheel_clicks_x);
-+ int sdl_wheel_clicks_y = trunc(wheel_clicks_y);
-+ event.button.x = event.button.y = 0;
-+ event.button.button =
-+ (sdl_wheel_clicks_x > 0) ? SDL_BUTTON_X1 : SDL_BUTTON_X2;
-+ for (int i = 0; i < abs(sdl_wheel_clicks_x); i++) {
-+ event.type = SDL_MOUSEBUTTONDOWN;
-+ event_queue.PushEvent(copyEvent(&event));
-+ event.type = SDL_MOUSEBUTTONUP;
-+ event_queue.PushEvent(copyEvent(&event));
-+ }
-+ event.button.button =
-+ (sdl_wheel_clicks_y > 0) ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN;
-+ for (int i = 0; i < abs(sdl_wheel_clicks_y); i++) {
-+ event.type = SDL_MOUSEBUTTONDOWN;
-+ event_queue.PushEvent(copyEvent(&event));
-+ event.type = SDL_MOUSEBUTTONUP;
-+ event_queue.PushEvent(copyEvent(&event));
-+ }
-+ wheel_clicks_x -= sdl_wheel_clicks_x;
-+ wheel_clicks_y -= sdl_wheel_clicks_y;
-+ } else if (type == PP_INPUTEVENT_TYPE_MOUSEMOVE) {
-+ event.type = SDL_MOUSEMOTION;
-+ PP_Point point =
-+ g_nacl_mouse_input_event_interface->GetPosition(input_event);
-+ event.motion.x = point.x;
-+ event.motion.y = point.y;
-+ event_queue.PushEvent(copyEvent(&event));
-+ } else if (type == PP_INPUTEVENT_TYPE_KEYDOWN ||
-+ type == PP_INPUTEVENT_TYPE_KEYUP ||
-+ type == PP_INPUTEVENT_TYPE_CHAR) {
-+ // PPAPI sends us separate events for KEYDOWN and CHAR; the first one
-+ // contains only the keycode, the second one - only the unicode text.
-+ // SDL wants both in SDL_PRESSED event :(
-+ // For now, ignore the keydown event for printable ascii (32-126) as we
-+ // know we'll get a char event and can set sym directly. For everything
-+ // else, risk sending an extra SDL_PRESSED with unicode text and zero
-+ // keycode for scancode / sym.
-+ // It seems that SDL 1.3 is better in this regard.
-+ keysym.scancode =
-+ g_nacl_keyboard_input_event_interface->GetKeyCode(input_event);
-+ PP_Var unicode_var =
-+ g_nacl_keyboard_input_event_interface->GetCharacterText(input_event);
-+ uint32_t unicode_var_len;
-+ keysym.unicode =
-+ g_nacl_var_interface->VarToUtf8(unicode_var, &unicode_var_len)[0];
-+ g_nacl_var_interface->Release(unicode_var);
-+ keysym.sym = translateKey(keysym.scancode);
-+ if (type == PP_INPUTEVENT_TYPE_KEYDOWN) {
-+ event.type = SDL_KEYDOWN;
-+ last_scancode = keysym.scancode;
-+ if (keysym.sym >= ' ' && keysym.sym <= 126) {
-+ return;
-+ }
-+ } else if (type == PP_INPUTEVENT_TYPE_CHAR) {
-+ event.type = SDL_KEYDOWN;
-+ if (keysym.sym >= ' ' && keysym.sym <= 126) {
-+ keysym.scancode = translateAscii(keysym.unicode);
-+ keysym.sym = translateKey(keysym.scancode);
-+ } else if (last_scancode) {
-+ keysym.scancode = last_scancode;
-+ keysym.sym = translateKey(keysym.scancode);
-+ }
-+ } else { // event->type == PP_INPUTEVENT_TYPE_KEYUP
-+ event.type = SDL_KEYUP;
-+ last_scancode = 0;
-+ }
-+ keysym.mod = KMOD_NONE;
-+ event.key.keysym = keysym;
-+ event_queue.PushEvent(copyEvent(&event));
-+ } else if (type == PP_INPUTEVENT_TYPE_MOUSEENTER ||
-+ type == PP_INPUTEVENT_TYPE_MOUSELEAVE) {
-+ event.type = SDL_ACTIVEEVENT;
-+ event.active.gain = (type == PP_INPUTEVENT_TYPE_MOUSEENTER) ? 1 : 0;
-+ event.active.state = SDL_APPMOUSEFOCUS;
-+ event_queue.PushEvent(copyEvent(&event));
-+ }
-+}
-+
-+void SDL_NACL_SetHasFocus(int has_focus) {
-+ SDL_Event event;
-+ event.type = SDL_ACTIVEEVENT;
-+ event.active.gain = has_focus ? 1 : 0;
-+ event.active.state = SDL_APPINPUTFOCUS;
-+ event_queue.PushEvent(copyEvent(&event));
-+}
-+
-+void SDL_NACL_SetPageVisible(int is_visible) {
-+ SDL_Event event;
-+ event.type = SDL_ACTIVEEVENT;
-+ event.active.gain = is_visible ? 1 : 0;
-+ event.active.state = SDL_APPACTIVE;
-+ event_queue.PushEvent(copyEvent(&event));
-+}
-+
-+void NACL_PumpEvents(_THIS) {
-+ SDL_Event* event;
-+ while (event = event_queue.PopEvent()) {
-+ if (event->type == SDL_MOUSEBUTTONDOWN) {
-+ SDL_PrivateMouseButton(SDL_PRESSED, event->button.button,
-+ event->button.x, event->button.y);
-+ } else if (event->type == SDL_MOUSEBUTTONUP) {
-+ SDL_PrivateMouseButton(SDL_RELEASED, event->button.button,
-+ event->button.x, event->button.y);
-+ } else if (event->type == SDL_MOUSEMOTION) {
-+ SDL_PrivateMouseMotion(0, 0, event->motion.x, event->motion.y);
-+ } else if (event->type == SDL_KEYDOWN) {
-+ SDL_PrivateKeyboard(SDL_PRESSED, &event->key.keysym);
-+ } else if (event->type == SDL_KEYUP) {
-+ SDL_PrivateKeyboard(SDL_RELEASED, &event->key.keysym);
-+ } else if (event->type == SDL_ACTIVEEVENT) {
-+ SDL_PrivateAppActive(event->active.gain, event->active.state);
-+ }
-+ free(event);
-+ }
-+}
-+
-+void NACL_InitOSKeymap(_THIS) {
-+ /* do nothing. */
-+}
-diff --git a/src/video/nacl/SDL_naclevents_c.h b/src/video/nacl/SDL_naclevents_c.h
-new file mode 100644
-index 0000000..71ae309
---- /dev/null
-+++ b/src/video/nacl/SDL_naclevents_c.h
-@@ -0,0 +1,7 @@
-+#include "SDL_config.h"
-+
-+#include "SDL_naclvideo.h"
-+#include "SDL_nacl.h"
-+
-+extern void NACL_InitOSKeymap(_THIS);
-+extern void NACL_PumpEvents(_THIS);
-diff --git a/src/video/nacl/SDL_naclvideo.cc b/src/video/nacl/SDL_naclvideo.cc
-new file mode 100644
-index 0000000..f1ababa
---- /dev/null
-+++ b/src/video/nacl/SDL_naclvideo.cc
-@@ -0,0 +1,465 @@
-+#include "SDL_config.h"
-+
-+#include <assert.h>
-+
-+#include "SDL_naclvideo.h"
-+#include "SDL_naclevents_c.h"
-+
-+#include <ppapi/c/pp_completion_callback.h>
-+#include <ppapi/c/pp_errors.h>
-+#include <ppapi/c/pp_instance.h>
-+#include <ppapi/c/pp_point.h>
-+#include <ppapi/c/pp_rect.h>
-+#include <ppapi/c/pp_size.h>
-+#include <ppapi/c/pp_var.h>
-+#include <ppapi/c/ppb_core.h>
-+#include <ppapi/c/ppb_graphics_2d.h>
-+#include <ppapi/c/ppb_graphics_3d.h>
-+#include <ppapi/c/ppb_image_data.h>
-+#include <ppapi/c/ppb_input_event.h>
-+#include <ppapi/c/ppb_instance.h>
-+#include <ppapi/c/ppb_opengles2.h>
-+#include <ppapi/c/ppb_var.h>
-+#include <ppapi/gles2/gl2ext_ppapi.h>
-+
-+PP_Instance g_nacl_pp_instance;
-+PPB_GetInterface g_nacl_get_interface;
-+const PPB_Core_1_0 *g_nacl_core_interface;
-+const PPB_Instance_1_0 *g_nacl_instance_interface;
-+const PPB_ImageData_1_0 *g_nacl_image_data_interface;
-+const PPB_Graphics2D_1_1 *g_nacl_graphics2d_interface;
-+const PPB_Graphics3D_1_0 *g_nacl_graphics3d_interface;
-+const PPB_OpenGLES2 *g_nacl_opengles2_interface;
-+
-+const PPB_InputEvent_1_0 *g_nacl_input_event_interface;
-+const PPB_MouseInputEvent_1_1 *g_nacl_mouse_input_event_interface;
-+const PPB_WheelInputEvent_1_0 *g_nacl_wheel_input_event_interface;
-+const PPB_KeyboardInputEvent_1_0 *g_nacl_keyboard_input_event_interface;
-+const PPB_Var_1_1 *g_nacl_var_interface;
-+
-+static int g_nacl_video_width;
-+static int g_nacl_video_height;
-+
-+static int kNaClFlushDelayMs = 20;
-+
-+#include "SDL_nacl.h"
-+
-+extern "C" {
-+
-+#ifdef SDL_VIDEO_OPENGL_REGAL
-+#include "SDL_opengl.h"
-+#endif
-+#include "SDL_video.h"
-+#include "SDL_mouse.h"
-+#include "../SDL_sysvideo.h"
-+#include "../SDL_pixels_c.h"
-+#include "../../events/SDL_events_c.h"
-+
-+#define NACLVID_DRIVER_NAME "nacl"
-+
-+void SDL_NACL_SetInstance(PP_Instance instance, PPB_GetInterface get_interface,
-+ int width, int height) {
-+ bool is_resize = g_nacl_pp_instance && (width != g_nacl_video_width ||
-+ height != g_nacl_video_height);
-+
-+ g_nacl_pp_instance = instance;
-+ g_nacl_get_interface = get_interface;
-+ g_nacl_core_interface =
-+ (const PPB_Core_1_0 *)get_interface(PPB_CORE_INTERFACE_1_0);
-+ g_nacl_instance_interface =
-+ (const PPB_Instance_1_0 *)get_interface(PPB_INSTANCE_INTERFACE_1_0);
-+ g_nacl_image_data_interface =
-+ (const PPB_ImageData_1_0 *)get_interface(PPB_IMAGEDATA_INTERFACE_1_0);
-+ g_nacl_graphics2d_interface =
-+ (const PPB_Graphics2D_1_1 *)get_interface(PPB_GRAPHICS_2D_INTERFACE_1_1);
-+ g_nacl_graphics3d_interface =
-+ (const PPB_Graphics3D_1_0 *)get_interface(PPB_GRAPHICS_3D_INTERFACE_1_0);
-+ g_nacl_opengles2_interface =
-+ (const PPB_OpenGLES2 *)get_interface(PPB_OPENGLES2_INTERFACE_1_0);
-+ g_nacl_input_event_interface =
-+ (const PPB_InputEvent_1_0 *)get_interface(PPB_INPUT_EVENT_INTERFACE_1_0);
-+ g_nacl_mouse_input_event_interface =
-+ (const PPB_MouseInputEvent_1_1 *)get_interface(
-+ PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1);
-+ g_nacl_wheel_input_event_interface =
-+ (const PPB_WheelInputEvent_1_0 *)get_interface(
-+ PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0);
-+ g_nacl_keyboard_input_event_interface =
-+ (const PPB_KeyboardInputEvent_1_0 *)get_interface(
-+ PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0);
-+ g_nacl_var_interface =
-+ (const PPB_Var_1_1 *)get_interface(PPB_VAR_INTERFACE_1_1);
-+ g_nacl_video_width = width;
-+ g_nacl_video_height = height;
-+ if (is_resize && current_video) {
-+ current_video->hidden->ow = width;
-+ current_video->hidden->oh = height;
-+ SDL_PrivateResize(width, height);
-+ }
-+}
-+
-+static void flush(void *data, int32_t unused);
-+
-+/* Initialization/Query functions */
-+static int NACL_VideoInit(_THIS, SDL_PixelFormat *vformat);
-+static SDL_Rect **NACL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
-+static SDL_Surface *NACL_SetVideoMode(_THIS, SDL_Surface *current, int width,
-+ int height, int bpp, Uint32 flags);
-+static void NACL_VideoQuit(_THIS);
-+static void NACL_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
-+
-+#ifdef SDL_VIDEO_OPENGL_REGAL
-+static int NACL_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
-+static int NACL_GL_MakeCurrent(_THIS);
-+static void NACL_GL_SwapBuffers(_THIS);
-+#endif
-+
-+/* The implementation dependent data for the window manager cursor */
-+struct WMcursor {
-+ // Fake cursor data to fool SDL into not using its broken (as it seems)
-+ // software cursor emulation.
-+};
-+
-+static void NACL_FreeWMCursor(_THIS, WMcursor *cursor);
-+static WMcursor *NACL_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w,
-+ int h, int hot_x, int hot_y);
-+static int NACL_ShowWMCursor(_THIS, WMcursor *cursor);
-+static void NACL_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
-+
-+static int NACL_Available(void) {
-+ return g_nacl_pp_instance != 0;
-+}
-+
-+static void NACL_DeleteDevice(SDL_VideoDevice *device) {
-+ SDL_free(device->hidden);
-+ SDL_free(device);
-+}
-+
-+static SDL_VideoDevice *NACL_CreateDevice(int devindex) {
-+ SDL_VideoDevice *device;
-+
-+ assert(g_nacl_pp_instance);
-+
-+ /* Initialize all variables that we clean on shutdown */
-+ device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
-+ if (device) {
-+ SDL_memset(device, 0, (sizeof *device));
-+ device->hidden =
-+ (struct SDL_PrivateVideoData *)SDL_malloc((sizeof *device->hidden));
-+ }
-+ if (device == NULL || device->hidden == NULL) {
-+ SDL_OutOfMemory();
-+ if (device) {
-+ SDL_free(device);
-+ }
+ return 0;
-+ }
-+ SDL_memset(device->hidden, 0, (sizeof *device->hidden));
-+
-+ device->hidden->ow = g_nacl_video_width;
-+ device->hidden->oh = g_nacl_video_height;
-+
-+ // TODO: query the fullscreen size
-+
-+ /* Set the function pointers */
-+ device->VideoInit = NACL_VideoInit;
-+ device->ListModes = NACL_ListModes;
-+ device->SetVideoMode = NACL_SetVideoMode;
-+ device->UpdateRects = NACL_UpdateRects;
-+ device->VideoQuit = NACL_VideoQuit;
-+ device->InitOSKeymap = NACL_InitOSKeymap;
-+ device->PumpEvents = NACL_PumpEvents;
-+
-+ device->FreeWMCursor = NACL_FreeWMCursor;
-+ device->CreateWMCursor = NACL_CreateWMCursor;
-+ device->ShowWMCursor = NACL_ShowWMCursor;
-+ device->WarpWMCursor = NACL_WarpWMCursor;
-+
-+#ifdef SDL_VIDEO_OPENGL_REGAL
-+ device->GL_GetAttribute = NACL_GL_GetAttribute;
-+ device->GL_MakeCurrent = NACL_GL_MakeCurrent;
-+ device->GL_SwapBuffers = NACL_GL_SwapBuffers;
-+#endif
-+
-+ device->free = NACL_DeleteDevice;
-+
-+ return device;
-+}
-+
-+VideoBootStrap NACL_bootstrap = {
-+ NACLVID_DRIVER_NAME, "SDL Native Client video driver",
-+ NACL_Available, NACL_CreateDevice
-+};
-+
-+int NACL_VideoInit(_THIS, SDL_PixelFormat *vformat) {
-+ fprintf(stderr,
-+ "SDL: Congratulations you are using the SDL nacl video driver!\n");
-+
-+ /* Determine the screen depth (use default 8-bit depth) */
-+ /* we change this during the SDL_SetVideoMode implementation... */
-+ vformat->BitsPerPixel = 32;
-+ vformat->BytesPerPixel = 4;
-+
-+ _this->info.current_w = g_nacl_video_width;
-+ _this->info.current_h = g_nacl_video_height;
-+
-+ /* We're done! */
-+ return 0;
-+}
-+
-+SDL_Rect **NACL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) {
-+ // TODO: list modes
-+ return (SDL_Rect **)-1;
+}
+
-+SDL_Surface *NACL_SetVideoMode(_THIS, SDL_Surface *current, int width,
-+ int height, int bpp, Uint32 flags) {
-+
-+ fprintf(stderr, "SDL: setvideomode %dx%d bpp=%d opengl=%d flags=%u\n", width,
-+ height, bpp, flags & SDL_OPENGL ? 1 : 0, flags);
-+ fflush(stderr);
-+
-+ if (width > _this->hidden->ow || height > _this->hidden->oh) return NULL;
-+ _this->hidden->bpp = bpp = 32; // Let SDL handle pixel format conversion.
-+ _this->hidden->w = width;
-+ _this->hidden->h = height;
++#undef main
+
-+ if (_this->hidden->context2d) {
-+ g_nacl_core_interface->ReleaseResource(_this->hidden->context2d);
-+ _this->hidden->context2d = 0;
-+ }
-+
-+ if (_this->hidden->context3d) {
-+ g_nacl_core_interface->ReleaseResource(_this->hidden->context3d);
-+ _this->hidden->context3d = 0;
-+ }
-+
-+ if (flags & SDL_OPENGL) {
-+ int32_t attribs[] = {
-+ PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
-+ PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
-+ PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8,
-+ PP_GRAPHICS3DATTRIB_SAMPLES, 0,
-+ PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
-+ PP_GRAPHICS3DATTRIB_WIDTH, width,
-+ PP_GRAPHICS3DATTRIB_HEIGHT, height,
-+ PP_GRAPHICS3DATTRIB_NONE
-+ };
-+ _this->hidden->context3d =
-+ g_nacl_graphics3d_interface->Create(g_nacl_pp_instance, 0, attribs);
-+
-+ if (!g_nacl_instance_interface->BindGraphics(g_nacl_pp_instance,
-+ _this->hidden->context3d)) {
-+ fprintf(stderr, "***** Couldn't bind the graphic3d context *****\n");
-+ return NULL;
-+ }
-+ } else {
-+ PP_Size size = PP_MakeSize(width, height);
-+ _this->hidden->context2d = g_nacl_graphics2d_interface->Create(
-+ g_nacl_pp_instance, &size, PP_FALSE /* is_always_opaque */);
-+ assert(_this->hidden->context2d != 0);
-+
-+ if (!g_nacl_instance_interface->BindGraphics(g_nacl_pp_instance,
-+ _this->hidden->context2d)) {
-+ fprintf(stderr, "***** Couldn't bind the graphic2d context *****\n");
-+ return NULL;
-+ }
-+
-+ if (_this->hidden->image_data) {
-+ g_nacl_core_interface->ReleaseResource(_this->hidden->image_data);
++/* This is started in a worker thread by ppapi_simple! */
++int
++main(int argc, char *argv[])
++{
++ SDL_TRACE("main\n");
++ PSEvent* ps_event;
++ PP_Resource event;
++ struct PP_Rect rect;
++ int ready = 0;
++ const PPB_View *ppb_view = PSInterfaceView();
++
++ if (ProcessArgs(argc, argv) != 0) {
++ return 1;
+ }
+
-+ _this->hidden->image_data = g_nacl_image_data_interface->Create(
-+ g_nacl_pp_instance, PP_IMAGEDATAFORMAT_BGRA_PREMUL, &size,
-+ PP_FALSE /* init_to_zero */);
-+ assert(_this->hidden->image_data != 0);
-+
-+ current->pixels =
-+ g_nacl_image_data_interface->Map(_this->hidden->image_data);
-+ }
-+
-+ /* Allocate the new pixel format for the screen */
-+ if (!SDL_ReallocFormat(current, bpp, 0xFF0000, 0xFF00, 0xFF, 0)) {
-+ SDL_SetError("Couldn't allocate new pixel format for requested mode");
-+ return NULL;
-+ }
-+
-+ /* Set up the new mode framebuffer */
-+ current->flags = flags & (SDL_FULLSCREEN | SDL_OPENGL);
-+ _this->hidden->bpp = bpp;
-+ _this->hidden->w = current->w = width;
-+ _this->hidden->h = current->h = height;
-+ current->pitch = current->w * (bpp / 8);
-+
-+ /* We're done */
-+ return current;
-+}
-+
-+static void NACL_UpdateRects(_THIS, int numrects, SDL_Rect *rects) {
-+ if (_this->hidden->context2d == 0) // not initialized
-+ return;
-+
-+ assert(_this->hidden->image_data);
-+ assert(_this->hidden->w > 0);
-+ assert(_this->hidden->h > 0);
-+
-+ // Clear alpha channel in the ImageData.
-+ unsigned char *start = (unsigned char*)_this->screen->pixels;
-+ unsigned char *end =
-+ start + (_this->hidden->w * _this->hidden->h * _this->hidden->bpp / 8);
-+ for (unsigned char *p = start + 3; p < end; p += 4) *p = 0xFF;
-+
-+ // Flush on the main thread.
-+ for (int i = 0; i < numrects; ++i) {
-+ SDL_Rect &r = rects[i];
-+ PP_Point top_left = PP_MakePoint(0, 0);
-+ PP_Rect src_rect = PP_MakeRectFromXYWH(r.x, r.y, r.w, r.h);
-+ g_nacl_graphics2d_interface->PaintImageData(_this->hidden->context2d,
-+ _this->hidden->image_data,
-+ &top_left, &src_rect);
-+ }
-+
-+ g_nacl_graphics2d_interface->Flush(_this->hidden->context2d,
-+ PP_BlockUntilComplete());
-+}
-+
-+static void NACL_FreeWMCursor(_THIS, WMcursor *cursor) {
-+ delete cursor;
-+}
-+
-+static WMcursor *NACL_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w,
-+ int h, int hot_x, int hot_y) {
-+ return new WMcursor();
-+}
-+
-+static int NACL_ShowWMCursor(_THIS, WMcursor *cursor) {
-+ return 1; // Success!
-+}
-+
-+static void NACL_WarpWMCursor(_THIS, Uint16 x, Uint16 y) {}
-+
-+/* Note: If we are terminated, this could be called in the middle of
-+ another SDL video routine -- notably UpdateRects.
-+*/
-+void NACL_VideoQuit(_THIS) {
-+ if (_this->hidden->context2d) {
-+ g_nacl_core_interface->ReleaseResource(_this->hidden->context2d);
-+ _this->hidden->context2d = 0;
-+ }
-+
-+ if (_this->hidden->context3d) {
-+ g_nacl_core_interface->ReleaseResource(_this->hidden->context3d);
-+ _this->hidden->context3d = 0;
-+ }
-+
-+ if (_this->hidden->image_data) {
-+ g_nacl_image_data_interface->Unmap(_this->hidden->image_data);
-+ g_nacl_core_interface->ReleaseResource(_this->hidden->image_data);
-+ _this->hidden->image_data = 0;
-+ }
-+
-+ // No need to free pixels as this is a pointer directly to
-+ // the pixel data within the image_data.
-+ _this->screen->pixels = NULL;
-+}
-+
-+#ifdef SDL_VIDEO_OPENGL_REGAL
-+static void regalLogCallback(GLenum stream, GLsizei length,
-+ const GLchar *message, GLvoid *context) {
-+ fprintf(stderr, "regal: %s\n", message);
-+}
-+
-+static int NACL_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) {
-+ int unsupported = 0;
-+ int nacl_attrib = 0;
-+
-+ switch (attrib) {
-+ case SDL_GL_RED_SIZE:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_RED_SIZE;
-+ break;
-+ case SDL_GL_GREEN_SIZE:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_GREEN_SIZE;
-+ break;
-+ case SDL_GL_BLUE_SIZE:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_BLUE_SIZE;
-+ break;
-+ case SDL_GL_ALPHA_SIZE:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_ALPHA_SIZE;
-+ break;
-+ case SDL_GL_DEPTH_SIZE:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_DEPTH_SIZE;
-+ break;
-+ case SDL_GL_STENCIL_SIZE:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_STENCIL_SIZE;
-+ break;
-+ case SDL_GL_MULTISAMPLEBUFFERS:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS;
-+ break;
-+ case SDL_GL_MULTISAMPLESAMPLES:
-+ nacl_attrib = PP_GRAPHICS3DATTRIB_SAMPLES;
-+ break;
-+ // The rest of the these attributes are not part of PPAPI
-+ case SDL_GL_DOUBLEBUFFER:
-+ case SDL_GL_BUFFER_SIZE:
-+ case SDL_GL_ACCUM_RED_SIZE:
-+ case SDL_GL_ACCUM_GREEN_SIZE:
-+ case SDL_GL_ACCUM_BLUE_SIZE:
-+ case SDL_GL_ACCUM_ALPHA_SIZE:
-+ case SDL_GL_STEREO:
-+ case SDL_GL_ACCELERATED_VISUAL:
-+ case SDL_GL_SWAP_CONTROL:
-+ default:
-+ unsupported = 1;
-+ break;
-+ }
-+
-+ if (unsupported) {
-+ SDL_SetError("OpenGL attribute is unsupported by NaCl: %d", attrib);
-+ return -1;
-+ }
-+
-+ int32_t attribs[] = {nacl_attrib, 0, PP_GRAPHICS3DATTRIB_NONE, };
-+
-+ int retval = g_nacl_graphics3d_interface->GetAttribs(_this->hidden->context3d,
-+ attribs);
-+ if (retval != PP_OK) {
-+ // TODO(sbc): GetAttribs seems to always return PP_ERROR_FAILED(-2).
-+ // fprintf(stderr, "SDL: GetAttribs failed %#x -> %d\n", nacl_attrib,
-+ // retval);
-+ SDL_SetError("Error getting OpenGL attribute (%d) from NaCl: %d", attrib,
-+ retval);
-+ return -1;
-+ }
-+
-+ *value = attribs[1];
-+ return 0;
-+}
-+
-+static int NACL_GL_MakeCurrent(_THIS) {
-+ if (!_this->hidden->context3d) {
-+ assert(_this->hidden->context3d);
-+ SDL_SetError("GL_MakeCurrent called without an OpenGL video mode set");
-+ return -1;
-+ }
-+ fprintf(stderr, "SDL: making GL context current\n");
-+ glSetCurrentContextPPAPI(_this->hidden->context3d);
-+
-+ RegalMakeCurrent(_this->hidden->context3d,
-+ (PPB_OpenGLES2 *)g_nacl_opengles2_interface);
-+ glLogMessageCallbackREGAL(regalLogCallback);
-+ return 0;
-+}
-+
-+static void NACL_GL_SwapBuffers(_THIS) {
-+ if (!_this->hidden->context3d) {
-+ assert(_this->hidden->context3d);
-+ fprintf(stderr,
-+ "SDL: GL_SwapBuffers called without an OpenGL video mode set\n");
-+ return;
-+ }
-+ g_nacl_graphics3d_interface->SwapBuffers(_this->hidden->context3d,
-+ PP_BlockUntilComplete());
-+}
-+#endif
-+
-+} // extern "C"
-diff --git a/src/video/nacl/SDL_naclvideo.h b/src/video/nacl/SDL_naclvideo.h
-new file mode 100644
-index 0000000..7dde7dd
---- /dev/null
-+++ b/src/video/nacl/SDL_naclvideo.h
-@@ -0,0 +1,36 @@
-+#include "SDL_config.h"
-+
-+#ifndef _SDL_naclvideo_h
-+#define _SDL_naclvideo_h
-+
-+extern "C" {
-+#include "../SDL_sysvideo.h"
-+#include "SDL_mutex.h"
-+}
-+
-+#include <ppapi/cpp/instance.h>
-+#include <ppapi/cpp/graphics_2d.h>
-+#include <ppapi/cpp/graphics_3d.h>
-+#include <vector>
-+
-+
-+/* Hidden "this" pointer for the video functions */
-+#define _THIS SDL_VideoDevice *_this
-+
-+
-+/* Private display data */
-+
-+struct SDL_PrivateVideoData {
-+ int bpp;
-+ int w, h;
-+ void *buffer;
-+
-+ int ow, oh; // plugin output dimensions
-+ int fsw, fsh; // fullscreen dimensions
-+
-+ PP_Resource image_data;
-+ PP_Resource context2d; // The PPAPI 2D drawing context.
-+ PP_Resource context3d; // The PPAPI 3D drawing context.
-+};
-+
-+#endif /* _SDL_naclvideo_h */
-diff --git a/src/video/nacl/eventqueue.h b/src/video/nacl/eventqueue.h
-new file mode 100644
-index 0000000..0a6a0cd
---- /dev/null
-+++ b/src/video/nacl/eventqueue.h
-@@ -0,0 +1,40 @@
-+#ifndef _SDL_nacl_eventqueue_h
-+#define _SDL_nacl_eventqueue_h
-+
-+#include "SDL_mutex.h"
-+
-+#include <queue>
-+
-+class EventQueue {
-+public:
-+ EventQueue() {
-+ mu_ = SDL_CreateMutex();
-+ }
-+
-+ ~EventQueue() {
-+ SDL_DestroyMutex(mu_);
-+ }
-+
-+ SDL_Event* PopEvent() {
-+ SDL_LockMutex(mu_);
-+ SDL_Event* event = NULL;
-+ if (!queue_.empty()) {
-+ event = queue_.front();
-+ queue_.pop();
++ /* Wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before starting the app */
++ PSEventSetFilter(PSE_INSTANCE_DIDCHANGEVIEW);
++ /* Process all waiting events without blocking */
++ while (!ready) {
++ ps_event = PSEventWaitAcquire();
++ event = ps_event->as_resource;
++ switch(ps_event->type) {
++ /* From DidChangeView, contains a view resource */
++ case PSE_INSTANCE_DIDCHANGEVIEW:
++ ppb_view->GetRect(event, &rect);
++ NACL_SetScreenResolution(rect.size.width, rect.size.height);
++ ready = 1;
++ break;
++ default:
++ break;
++ }
++ PSEventRelease(ps_event);
+ }
-+ SDL_UnlockMutex(mu_);
-+ return event;
-+ }
-+
-+ void PushEvent(SDL_Event* event) {
-+ SDL_LockMutex(mu_);
-+ queue_.push(event);
-+ SDL_UnlockMutex(mu_);
-+ }
-+
-+private:
-+ std::queue<SDL_Event*> queue_;
-+ SDL_mutex* mu_;
-+};
-+
-+#endif // _SDL_nacl_eventqueue_h
-diff --git a/test/configure b/test/configure
-index 30b56b6..10046ec 100755
---- a/test/configure
-+++ b/test/configure
-@@ -1,18 +1,20 @@
- #! /bin/sh
- # Guess values for system-dependent variables and create Makefiles.
--# Generated by GNU Autoconf 2.63.
-+# Generated by GNU Autoconf 2.69.
-+#
-+#
-+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
-+#
- #
--# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
--# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
- # This configure script is free software; the Free Software Foundation
- # gives unlimited permission to copy, distribute and modify it.
--## --------------------- ##
--## M4sh Initialization. ##
--## --------------------- ##
-+## -------------------- ##
-+## M4sh Initialization. ##
-+## -------------------- ##
-
- # Be more Bourne compatible
- DUALCASE=1; export DUALCASE # for MKS sh
--if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-@@ -20,23 +22,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
- else
-- case `(set -o) 2>/dev/null` in
-- *posix*) set -o posix ;;
-+ case `(set -o) 2>/dev/null` in #(
-+ *posix*) :
-+ set -o posix ;; #(
-+ *) :
-+ ;;
- esac
--
- fi
-
-
--
--
--# PATH needs CR
--# Avoid depending upon Character Ranges.
--as_cr_letters='abcdefghijklmnopqrstuvwxyz'
--as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
--as_cr_Letters=$as_cr_letters$as_cr_LETTERS
--as_cr_digits='0123456789'
--as_cr_alnum=$as_cr_Letters$as_cr_digits
--
- as_nl='
- '
- export as_nl
-@@ -44,7 +38,13 @@ export as_nl
- as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
- as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
- as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
--if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-+# Prefer a ksh shell builtin over an external printf program on Solaris,
-+# but without wasting forks for bash or zsh.
-+if test -z "$BASH_VERSION$ZSH_VERSION" \
-+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-+ as_echo='print -r --'
-+ as_echo_n='print -rn --'
-+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='printf %s\n'
- as_echo_n='printf %s'
- else
-@@ -55,7 +55,7 @@ else
- as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
- as_echo_n_body='eval
- arg=$1;
-- case $arg in
-+ case $arg in #(
- *"$as_nl"*)
- expr "X$arg" : "X\\(.*\\)$as_nl";
- arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-@@ -78,13 +78,6 @@ if test "${PATH_SEPARATOR+set}" != set; then
- }
- fi
-
--# Support unset when possible.
--if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-- as_unset=unset
--else
-- as_unset=false
--fi
--
-
- # IFS
- # We need space, tab and new line, in precisely that order. Quoting is
-@@ -94,15 +87,16 @@ fi
- IFS=" "" $as_nl"
-
- # Find who we are. Look in the path if we contain no directory separator.
--case $0 in
-+as_myself=
-+case $0 in #((
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
- for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
--done
-+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-+ done
- IFS=$as_save_IFS
-
- ;;
-@@ -114,12 +108,16 @@ if test "x$as_myself" = x; then
- fi
- if test ! -f "$as_myself"; then
- $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-- { (exit 1); exit 1; }
-+ exit 1
- fi
-
--# Work around bugs in pre-3.0 UWIN ksh.
--for as_var in ENV MAIL MAILPATH
--do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
-+# Unset variables that we do not need and which cause bugs (e.g. in
-+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
-+# suppresses any "Segmentation fault" message there. '((' could
-+# trigger a bug in pdksh 5.2.14.
-+for as_var in BASH_ENV ENV MAIL MAILPATH
-+do eval test x\${$as_var+set} = xset \
-+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
- done
- PS1='$ '
- PS2='> '
-@@ -131,330 +129,343 @@ export LC_ALL
- LANGUAGE=C
- export LANGUAGE
-
--# Required to use basename.
--if expr a : '\(a\)' >/dev/null 2>&1 &&
-- test "X`expr 00001 : '.*\(...\)'`" = X001; then
-- as_expr=expr
--else
-- as_expr=false
--fi
--
--if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-- as_basename=basename
--else
-- as_basename=false
--fi
--
--
--# Name of the executable.
--as_me=`$as_basename -- "$0" ||
--$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-- X"$0" : 'X\(//\)$' \| \
-- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
--$as_echo X/"$0" |
-- sed '/^.*\/\([^/][^/]*\)\/*$/{
-- s//\1/
-- q
-- }
-- /^X\/\(\/\/\)$/{
-- s//\1/
-- q
-- }
-- /^X\/\(\/\).*/{
-- s//\1/
-- q
-- }
-- s/.*/./; q'`
--
- # CDPATH.
--$as_unset CDPATH
--
--
-+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-+
-+# Use a proper internal environment variable to ensure we don't fall
-+ # into an infinite loop, continuously re-executing ourselves.
-+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
-+ _as_can_reexec=no; export _as_can_reexec;
-+ # We cannot yet assume a decent shell, so we have to provide a
-+# neutralization value for shells without unset; and this also
-+# works around shells that cannot unset nonexistent variables.
-+# Preserve -v and -x to the replacement shell.
-+BASH_ENV=/dev/null
-+ENV=/dev/null
-+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-+case $- in # ((((
-+ *v*x* | *x*v* ) as_opts=-vx ;;
-+ *v* ) as_opts=-v ;;
-+ *x* ) as_opts=-x ;;
-+ * ) as_opts= ;;
-+esac
-+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-+# Admittedly, this is quite paranoid, since all the known shells bail
-+# out after a failed `exec'.
-+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-+as_fn_exit 255
-+ fi
-+ # We don't want this to propagate to other subprocesses.
-+ { _as_can_reexec=; unset _as_can_reexec;}
- if test "x$CONFIG_SHELL" = x; then
-- if (eval ":") 2>/dev/null; then
-- as_have_required=yes
-+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
-+ emulate sh
-+ NULLCMD=:
-+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
-+ # is contrary to our usage. Disable this feature.
-+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
-+ setopt NO_GLOB_SUBST
- else
-- as_have_required=no
-+ case \`(set -o) 2>/dev/null\` in #(
-+ *posix*) :
-+ set -o posix ;; #(
-+ *) :
-+ ;;
-+esac
- fi
--
-- if test $as_have_required = yes && (eval ":
--(as_func_return () {
-- (exit \$1)
--}
--as_func_success () {
-- as_func_return 0
--}
--as_func_failure () {
-- as_func_return 1
--}
--as_func_ret_success () {
-- return 0
--}
--as_func_ret_failure () {
-- return 1
--}
-+"
-+ as_required="as_fn_return () { (exit \$1); }
-+as_fn_success () { as_fn_return 0; }
-+as_fn_failure () { as_fn_return 1; }
-+as_fn_ret_success () { return 0; }
-+as_fn_ret_failure () { return 1; }
-
- exitcode=0
--if as_func_success; then
-- :
--else
-- exitcode=1
-- echo as_func_success failed.
--fi
-+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-
--if as_func_failure; then
-- exitcode=1
-- echo as_func_failure succeeded.
--fi
--
--if as_func_ret_success; then
-- :
- else
-- exitcode=1
-- echo as_func_ret_success failed.
--fi
--
--if as_func_ret_failure; then
-- exitcode=1
-- echo as_func_ret_failure succeeded.
--fi
--
--if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
-- :
-+ exitcode=1; echo positional parameters were not saved.
-+fi
-+test x\$exitcode = x0 || exit 1
-+test -x / || exit 1"
-+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
-+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
-+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
-+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"
-+ if (eval "$as_required") 2>/dev/null; then :
-+ as_have_required=yes
- else
-- exitcode=1
-- echo positional parameters were not saved.
-+ as_have_required=no
- fi
-+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
-
--test \$exitcode = 0) || { (exit 1); exit 1; }
--
--(
-- as_lineno_1=\$LINENO
-- as_lineno_2=\$LINENO
-- test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
-- test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
--") 2> /dev/null; then
-- :
- else
-- as_candidate_shells=
-- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+as_found=false
- for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- case $as_dir in
-+ as_found=:
-+ case $as_dir in #(
- /*)
- for as_base in sh bash ksh sh5; do
-- as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
-+ # Try only shells that exist, to save several forks.
-+ as_shell=$as_dir/$as_base
-+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
-+ CONFIG_SHELL=$as_shell as_have_required=yes
-+ if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
-+ break 2
-+fi
-+fi
- done;;
- esac
-+ as_found=false
- done
-+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
-+ CONFIG_SHELL=$SHELL as_have_required=yes
-+fi; }
- IFS=$as_save_IFS
-
-
-- for as_shell in $as_candidate_shells $SHELL; do
-- # Try only shells that exist, to save several forks.
-- if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-- { ("$as_shell") 2> /dev/null <<\_ASEOF
--if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-- emulate sh
-- NULLCMD=:
-- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-- # is contrary to our usage. Disable this feature.
-- alias -g '${1+"$@"}'='"$@"'
-- setopt NO_GLOB_SUBST
--else
-- case `(set -o) 2>/dev/null` in
-- *posix*) set -o posix ;;
--esac
--
--fi
--
--
--:
--_ASEOF
--}; then
-- CONFIG_SHELL=$as_shell
-- as_have_required=yes
-- if { "$as_shell" 2> /dev/null <<\_ASEOF
--if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-- emulate sh
-- NULLCMD=:
-- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-- # is contrary to our usage. Disable this feature.
-- alias -g '${1+"$@"}'='"$@"'
-- setopt NO_GLOB_SUBST
--else
-- case `(set -o) 2>/dev/null` in
-- *posix*) set -o posix ;;
-+ if test "x$CONFIG_SHELL" != x; then :
-+ export CONFIG_SHELL
-+ # We cannot yet assume a decent shell, so we have to provide a
-+# neutralization value for shells without unset; and this also
-+# works around shells that cannot unset nonexistent variables.
-+# Preserve -v and -x to the replacement shell.
-+BASH_ENV=/dev/null
-+ENV=/dev/null
-+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-+case $- in # ((((
-+ *v*x* | *x*v* ) as_opts=-vx ;;
-+ *v* ) as_opts=-v ;;
-+ *x* ) as_opts=-x ;;
-+ * ) as_opts= ;;
- esac
--
--fi
--
--
--:
--(as_func_return () {
-- (exit $1)
--}
--as_func_success () {
-- as_func_return 0
--}
--as_func_failure () {
-- as_func_return 1
--}
--as_func_ret_success () {
-- return 0
--}
--as_func_ret_failure () {
-- return 1
--}
--
--exitcode=0
--if as_func_success; then
-- :
--else
-- exitcode=1
-- echo as_func_success failed.
--fi
--
--if as_func_failure; then
-- exitcode=1
-- echo as_func_failure succeeded.
--fi
--
--if as_func_ret_success; then
-- :
--else
-- exitcode=1
-- echo as_func_ret_success failed.
--fi
--
--if as_func_ret_failure; then
-- exitcode=1
-- echo as_func_ret_failure succeeded.
--fi
--
--if ( set x; as_func_ret_success y && test x = "$1" ); then
-- :
--else
-- exitcode=1
-- echo positional parameters were not saved.
-+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-+# Admittedly, this is quite paranoid, since all the known shells bail
-+# out after a failed `exec'.
-+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-+exit 255
-+fi
-+
-+ if test x$as_have_required = xno; then :
-+ $as_echo "$0: This script requires a shell more modern than all"
-+ $as_echo "$0: the shells that I found on your system."
-+ if test x${ZSH_VERSION+set} = xset ; then
-+ $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-+ $as_echo "$0: be upgraded to zsh 4.3.4 or later."
-+ else
-+ $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
-+$0: including any error possibly output before this
-+$0: message. Then install a modern shell, or manually run
-+$0: the script under such a shell if you do have one."
-+ fi
-+ exit 1
- fi
--
--test $exitcode = 0) || { (exit 1); exit 1; }
--
--(
-- as_lineno_1=$LINENO
-- as_lineno_2=$LINENO
-- test "x$as_lineno_1" != "x$as_lineno_2" &&
-- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
--
--_ASEOF
--}; then
-- break
- fi
--
- fi
-+SHELL=${CONFIG_SHELL-/bin/sh}
-+export SHELL
-+# Unset more variables known to interfere with behavior of common tools.
-+CLICOLOR_FORCE= GREP_OPTIONS=
-+unset CLICOLOR_FORCE GREP_OPTIONS
-
-- done
--
-- if test "x$CONFIG_SHELL" != x; then
-- for as_var in BASH_ENV ENV
-- do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
-- done
-- export CONFIG_SHELL
-- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
--fi
-+## --------------------- ##
-+## M4sh Shell Functions. ##
-+## --------------------- ##
-+# as_fn_unset VAR
-+# ---------------
-+# Portably unset VAR.
-+as_fn_unset ()
-+{
-+ { eval $1=; unset $1;}
-+}
-+as_unset=as_fn_unset
-
-+# as_fn_set_status STATUS
-+# -----------------------
-+# Set $? to STATUS, without forking.
-+as_fn_set_status ()
-+{
-+ return $1
-+} # as_fn_set_status
-
-- if test $as_have_required = no; then
-- echo This script requires a shell more modern than all the
-- echo shells that I found on your system. Please install a
-- echo modern shell, or manually run the script under such a
-- echo shell if you do have one.
-- { (exit 1); exit 1; }
--fi
-+# as_fn_exit STATUS
-+# -----------------
-+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-+as_fn_exit ()
-+{
-+ set +e
-+ as_fn_set_status $1
-+ exit $1
-+} # as_fn_exit
-+
-+# as_fn_mkdir_p
-+# -------------
-+# Create "$as_dir" as a directory, including parents if necessary.
-+as_fn_mkdir_p ()
-+{
-
-+ case $as_dir in #(
-+ -*) as_dir=./$as_dir;;
-+ esac
-+ test -d "$as_dir" || eval $as_mkdir_p || {
-+ as_dirs=
-+ while :; do
-+ case $as_dir in #(
-+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-+ *) as_qdir=$as_dir;;
-+ esac
-+ as_dirs="'$as_qdir' $as_dirs"
-+ as_dir=`$as_dirname -- "$as_dir" ||
-+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-+ X"$as_dir" : 'X\(//\)[^/]' \| \
-+ X"$as_dir" : 'X\(//\)$' \| \
-+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-+$as_echo X"$as_dir" |
-+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-+ s//\1/
-+ q
-+ }
-+ /^X\(\/\/\)[^/].*/{
-+ s//\1/
-+ q
-+ }
-+ /^X\(\/\/\)$/{
-+ s//\1/
-+ q
-+ }
-+ /^X\(\/\).*/{
-+ s//\1/
-+ q
-+ }
-+ s/.*/./; q'`
-+ test -d "$as_dir" && break
-+ done
-+ test -z "$as_dirs" || eval "mkdir $as_dirs"
-+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
--fi
-
--fi
-+} # as_fn_mkdir_p
-
-+# as_fn_executable_p FILE
-+# -----------------------
-+# Test if FILE is an executable regular file.
-+as_fn_executable_p ()
-+{
-+ test -f "$1" && test -x "$1"
-+} # as_fn_executable_p
-+# as_fn_append VAR VALUE
-+# ----------------------
-+# Append the text in VALUE to the end of the definition contained in VAR. Take
-+# advantage of any shell optimizations that allow amortized linear growth over
-+# repeated appends, instead of the typical quadratic growth present in naive
-+# implementations.
-+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-+ eval 'as_fn_append ()
-+ {
-+ eval $1+=\$2
-+ }'
-+else
-+ as_fn_append ()
-+ {
-+ eval $1=\$$1\$2
-+ }
-+fi # as_fn_append
+
-+# as_fn_arith ARG...
-+# ------------------
-+# Perform arithmetic evaluation on the ARGs, and store the result in the
-+# global $as_val. Take advantage of shells that can avoid forks. The arguments
-+# must be portable across $(()) and expr.
-+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-+ eval 'as_fn_arith ()
-+ {
-+ as_val=$(( $* ))
-+ }'
-+else
-+ as_fn_arith ()
-+ {
-+ as_val=`expr "$@" || test $? -eq 1`
-+ }
-+fi # as_fn_arith
-
-
--(eval "as_func_return () {
-- (exit \$1)
--}
--as_func_success () {
-- as_func_return 0
--}
--as_func_failure () {
-- as_func_return 1
--}
--as_func_ret_success () {
-- return 0
--}
--as_func_ret_failure () {
-- return 1
--}
-+# as_fn_error STATUS ERROR [LINENO LOG_FD]
-+# ----------------------------------------
-+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-+# script with STATUS, using 1 if that was 0.
-+as_fn_error ()
-+{
-+ as_status=$1; test $as_status -eq 0 && as_status=1
-+ if test "$4"; then
-+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-+ fi
-+ $as_echo "$as_me: error: $2" >&2
-+ as_fn_exit $as_status
-+} # as_fn_error
-
--exitcode=0
--if as_func_success; then
-- :
-+if expr a : '\(a\)' >/dev/null 2>&1 &&
-+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
-+ as_expr=expr
- else
-- exitcode=1
-- echo as_func_success failed.
--fi
--
--if as_func_failure; then
-- exitcode=1
-- echo as_func_failure succeeded.
-+ as_expr=false
- fi
-
--if as_func_ret_success; then
-- :
-+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-+ as_basename=basename
- else
-- exitcode=1
-- echo as_func_ret_success failed.
--fi
--
--if as_func_ret_failure; then
-- exitcode=1
-- echo as_func_ret_failure succeeded.
-+ as_basename=false
- fi
-
--if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
-- :
-+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-+ as_dirname=dirname
- else
-- exitcode=1
-- echo positional parameters were not saved.
-+ as_dirname=false
- fi
-
--test \$exitcode = 0") || {
-- echo No shell found that supports shell functions.
-- echo Please tell bug-autoconf@gnu.org about your system,
-- echo including any error possibly output before this message.
-- echo This can help us improve future autoconf versions.
-- echo Configuration will now proceed without shell functions.
--}
--
-+as_me=`$as_basename -- "$0" ||
-+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-+ X"$0" : 'X\(//\)$' \| \
-+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-+$as_echo X/"$0" |
-+ sed '/^.*\/\([^/][^/]*\)\/*$/{
-+ s//\1/
-+ q
-+ }
-+ /^X\/\(\/\/\)$/{
-+ s//\1/
-+ q
-+ }
-+ /^X\/\(\/\).*/{
-+ s//\1/
-+ q
-+ }
-+ s/.*/./; q'`
-
-+# Avoid depending upon Character Ranges.
-+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-+as_cr_digits='0123456789'
-+as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-- as_lineno_1=$LINENO
-- as_lineno_2=$LINENO
-- test "x$as_lineno_1" != "x$as_lineno_2" &&
-- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
-
-- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
-- # uniformly replaced by the line number. The first 'sed' inserts a
-- # line-number line after each line using $LINENO; the second 'sed'
-- # does the real work. The second script uses 'N' to pair each
-- # line-number line with the line containing $LINENO, and appends
-- # trailing '-' during substitution so that $LINENO is not a special
-- # case at line end.
-- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-- # scripts with optimization help from Paolo Bonzini. Blame Lee
-- # E. McMahon (1931-1989) for sed's syntax. :-)
-+ as_lineno_1=$LINENO as_lineno_1a=$LINENO
-+ as_lineno_2=$LINENO as_lineno_2a=$LINENO
-+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
-+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
-+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
- sed -n '
- p
- /[$]LINENO/=
-@@ -471,9 +482,12 @@ test \$exitcode = 0") || {
- s/-\n.*//
- ' >$as_me.lineno &&
- chmod +x "$as_me.lineno" ||
-- { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
-- { (exit 1); exit 1; }; }
-+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-
-+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
-+ # already done that, so ensure we don't try to do so again and fall
-+ # in an infinite loop. This has already happened in practice.
-+ _as_can_reexec=no; export _as_can_reexec
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensitive to this).
-@@ -482,29 +496,18 @@ test \$exitcode = 0") || {
- exit
++ mount("", /* source */
++ "/persistent", /* target */
++ "html5fs", /* filesystemtype */
++ 0, /* mountflags */
++ "type=PERSISTENT,expected_size=1048576"); /* data */
++
++ mount("", /* source. Use relative URL */
++ "/http", /* target */
++ "httpfs", /* filesystemtype */
++ 0, /* mountflags */
++ ""); /* data */
++
++ return SDL_main(argc, argv);
++}
++
++#endif /* SDL_VIDEO_DRIVER_NACL */
+diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
+index 5753927..da37fe6 100644
+--- a/src/events/SDL_keyboard.c
++++ b/src/events/SDL_keyboard.c
+@@ -371,6 +371,13 @@ Uint8 * SDL_GetKeyState (int *numkeys)
+ *numkeys = SDLK_LAST;
+ return(SDL_KeyState);
}
-
--
--if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-- as_dirname=dirname
--else
-- as_dirname=false
--fi
--
- ECHO_C= ECHO_N= ECHO_T=
--case `echo -n x` in
-+case `echo -n x` in #(((((
- -n*)
-- case `echo 'x\c'` in
-+ case `echo 'xy\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
-- *) ECHO_C='\c';;
-+ xy) ECHO_C='\c';;
-+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
-+ ECHO_T=' ';;
- esac;;
- *)
- ECHO_N='-n';;
- esac
--if expr a : '\(a\)' >/dev/null 2>&1 &&
-- test "X`expr 00001 : '.*\(...\)'`" = X001; then
-- as_expr=expr
--else
-- as_expr=false
--fi
-
- rm -f conf$$ conf$$.exe conf$$.file
- if test -d conf$$.dir; then
-@@ -519,49 +522,29 @@ if (echo >conf$$.file) 2>/dev/null; then
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-- # In both cases, we have to default to `cp -p'.
-+ # In both cases, we have to default to `cp -pR'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-- as_ln_s='cp -p'
-+ as_ln_s='cp -pR'
- elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
- else
-- as_ln_s='cp -p'
-+ as_ln_s='cp -pR'
- fi
- else
-- as_ln_s='cp -p'
-+ as_ln_s='cp -pR'
- fi
- rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
- rmdir conf$$.dir 2>/dev/null
-
- if mkdir -p . 2>/dev/null; then
-- as_mkdir_p=:
-+ as_mkdir_p='mkdir -p "$as_dir"'
- else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
- fi
-
--if test -x / >/dev/null 2>&1; then
-- as_test_x='test -x'
--else
-- if ls -dL / >/dev/null 2>&1; then
-- as_ls_L_option=L
-- else
-- as_ls_L_option=
-- fi
-- as_test_x='
-- eval sh -c '\''
-- if test -d "$1"; then
-- test -d "$1/.";
-- else
-- case $1 in
-- -*)set "./$1";;
-- esac;
-- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
-- ???[sx]*):;;*)false;;esac;fi
-- '\'' sh
-- '
--fi
--as_executable_p=$as_test_x
-+as_test_x='test -x'
-+as_executable_p=as_fn_executable_p
-
- # Sed expression to map a string onto a valid CPP name.
- as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-@@ -570,11 +553,11 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
- as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
--
--exec 7<&0 </dev/null 6>&1
-+test -n "$DJDIR" || exec 7<&0 </dev/null
-+exec 6>&1
-
- # Name of the host.
--# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
- # so uname gets run too.
- ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-@@ -589,7 +572,6 @@ cross_compiling=no
- subdirs=
- MFLAGS=
- MAKEFLAGS=
--SHELL=${CONFIG_SHELL-/bin/sh}
-
- # Identity of this package.
- PACKAGE_NAME=
-@@ -597,6 +579,7 @@ PACKAGE_TARNAME=
- PACKAGE_VERSION=
- PACKAGE_STRING=
- PACKAGE_BUGREPORT=
-+PACKAGE_URL=
-
- ac_unique_file="README"
- ac_subst_vars='LTLIBOBJS
-@@ -655,6 +638,7 @@ bindir
- program_transform_name
- prefix
- exec_prefix
-+PACKAGE_URL
- PACKAGE_BUGREPORT
- PACKAGE_STRING
- PACKAGE_VERSION
-@@ -742,8 +726,9 @@ do
- fi
-
- case $ac_option in
-- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-- *) ac_optarg=yes ;;
-+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-+ *=) ac_optarg= ;;
-+ *) ac_optarg=yes ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-@@ -788,8 +773,7 @@ do
- ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-- { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "invalid feature name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
-@@ -815,8 +799,7 @@ do
- ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-- { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "invalid feature name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
-@@ -1020,8 +1003,7 @@ do
- ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-- { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "invalid package name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
-@@ -1037,8 +1019,7 @@ do
- ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-- { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "invalid package name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
-@@ -1068,17 +1049,17 @@ do
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries=$ac_optarg ;;
-
-- -*) { $as_echo "$as_me: error: unrecognized option: $ac_option
--Try \`$0 --help' for more information." >&2
-- { (exit 1); exit 1; }; }
-+ -*) as_fn_error $? "unrecognized option: \`$ac_option'
-+Try \`$0 --help' for more information"
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
-- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
-- { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
-- { (exit 1); exit 1; }; }
-+ case $ac_envvar in #(
-+ '' | [0-9]* | *[!_$as_cr_alnum]* )
-+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
-+ esac
- eval $ac_envvar=\$ac_optarg
- export $ac_envvar ;;
-
-@@ -1087,7 +1068,7 @@ Try \`$0 --help' for more information." >&2
- $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
-+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
- ;;
-
- esac
-@@ -1095,15 +1076,13 @@ done
-
- if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-- { $as_echo "$as_me: error: missing argument to $ac_option" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "missing argument to $ac_option"
- fi
-
- if test -n "$ac_unrecognized_opts"; then
- case $enable_option_checking in
- no) ;;
-- fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
-- { (exit 1); exit 1; }; } ;;
-+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
- *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
- esac
- fi
-@@ -1126,8 +1105,7 @@ do
- [\\/$]* | ?:[\\/]* ) continue;;
- NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
- esac
-- { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
- done
-
- # There might be people who depend on the old broken behavior: `$host'
-@@ -1141,8 +1119,6 @@ target=$target_alias
- if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
-- $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
-- If a cross compiler is detected then cross compile mode will be used." >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-@@ -1157,11 +1133,9 @@ test "$silent" = yes && exec 6>/dev/null
- ac_pwd=`pwd` && test -n "$ac_pwd" &&
- ac_ls_di=`ls -di .` &&
- ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-- { $as_echo "$as_me: error: working directory cannot be determined" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "working directory cannot be determined"
- test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-- { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "pwd does not report name of working directory"
-
-
- # Find the source files, if location was not specified.
-@@ -1200,13 +1174,11 @@ else
- fi
- if test ! -r "$srcdir/$ac_unique_file"; then
- test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-- { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
- fi
- ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
- ac_abs_confdir=`(
-- cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
-- { (exit 1); exit 1; }; }
-+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
- pwd)`
- # When building in place, set srcdir=.
- if test "$ac_abs_confdir" = "$ac_pwd"; then
-@@ -1246,7 +1218,7 @@ Configuration:
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
-- -q, --quiet, --silent do not print \`checking...' messages
-+ -q, --quiet, --silent do not print \`checking ...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
-@@ -1322,7 +1294,7 @@ Some influential environment variables:
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- LIBS libraries to pass to the linker, e.g. -l<library>
-- CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
-+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
- you have headers in a nonstandard directory <include dir>
- XMKMF Path to xmkmf, Makefile generator for X Window System
- CPP C preprocessor
-@@ -1330,6 +1302,7 @@ Some influential environment variables:
- Use these variables to override the choices made by `configure' or to help
- it to find libraries and programs with nonstandard names/locations.
-
-+Report bugs to the package provider.
- _ACEOF
- ac_status=$?
- fi
-@@ -1393,21 +1366,187 @@ test -n "$ac_init_help" && exit $ac_status
- if $ac_init_version; then
- cat <<\_ACEOF
- configure
--generated by GNU Autoconf 2.63
-+generated by GNU Autoconf 2.69
-
--Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
--2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-+Copyright (C) 2012 Free Software Foundation, Inc.
- This configure script is free software; the Free Software Foundation
- gives unlimited permission to copy, distribute and modify it.
- _ACEOF
- exit
- fi
-+
-+## ------------------------ ##
-+## Autoconf initialization. ##
-+## ------------------------ ##
-+
-+# ac_fn_c_try_compile LINENO
-+# --------------------------
-+# Try to compile conftest.$ac_ext, and return whether this succeeded.
-+ac_fn_c_try_compile ()
-+{
-+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ rm -f conftest.$ac_objext
-+ if { { ac_try="$ac_compile"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_compile") 2>conftest.err
-+ ac_status=$?
-+ if test -s conftest.err; then
-+ grep -v '^ *+' conftest.err >conftest.er1
-+ cat conftest.er1 >&5
-+ mv -f conftest.er1 conftest.err
-+ fi
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; } && {
-+ test -z "$ac_c_werror_flag" ||
-+ test ! -s conftest.err
-+ } && test -s conftest.$ac_objext; then :
-+ ac_retval=0
-+else
-+ $as_echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ ac_retval=1
-+fi
-+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-+ as_fn_set_status $ac_retval
+
-+} # ac_fn_c_try_compile
-+
-+# ac_fn_c_try_run LINENO
-+# ----------------------
-+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-+# that executables *can* be run.
-+ac_fn_c_try_run ()
-+{
-+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ if { { ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-+ { { case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }; }; then :
-+ ac_retval=0
-+else
-+ $as_echo "$as_me: program exited with status $ac_status" >&5
-+ $as_echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ ac_retval=$ac_status
-+fi
-+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-+ as_fn_set_status $ac_retval
-+
-+} # ac_fn_c_try_run
-+
-+# ac_fn_c_try_link LINENO
-+# -----------------------
-+# Try to link conftest.$ac_ext, and return whether this succeeded.
-+ac_fn_c_try_link ()
++// private (used in naclevents.c)
++void SDL_SetKeyState (SDLKey key, Uint8 state)
+{
-+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ rm -f conftest.$ac_objext conftest$ac_exeext
-+ if { { ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_link") 2>conftest.err
-+ ac_status=$?
-+ if test -s conftest.err; then
-+ grep -v '^ *+' conftest.err >conftest.er1
-+ cat conftest.er1 >&5
-+ mv -f conftest.er1 conftest.err
-+ fi
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; } && {
-+ test -z "$ac_c_werror_flag" ||
-+ test ! -s conftest.err
-+ } && test -s conftest$ac_exeext && {
-+ test "$cross_compiling" = yes ||
-+ test -x conftest$ac_exeext
-+ }; then :
-+ ac_retval=0
-+else
-+ $as_echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ ac_retval=1
-+fi
-+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-+ # interfere with the next link command; also delete a directory that is
-+ # left behind by Apple's compiler. We do this before executing the actions.
-+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-+ as_fn_set_status $ac_retval
-+
-+} # ac_fn_c_try_link
-+
-+# ac_fn_c_try_cpp LINENO
-+# ----------------------
-+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-+ac_fn_c_try_cpp ()
-+{
-+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ if { { ac_try="$ac_cpp conftest.$ac_ext"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-+ ac_status=$?
-+ if test -s conftest.err; then
-+ grep -v '^ *+' conftest.err >conftest.er1
-+ cat conftest.er1 >&5
-+ mv -f conftest.er1 conftest.err
-+ fi
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; } > conftest.i && {
-+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-+ test ! -s conftest.err
-+ }; then :
-+ ac_retval=0
-+else
-+ $as_echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ ac_retval=1
-+fi
-+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-+ as_fn_set_status $ac_retval
-+
-+} # ac_fn_c_try_cpp
- cat >config.log <<_ACEOF
- This file contains any messages produced by compilers while
- running configure, to aid debugging if configure makes a mistake.
-
- It was created by $as_me, which was
--generated by GNU Autoconf 2.63. Invocation command line was
-+generated by GNU Autoconf 2.69. Invocation command line was
-
- $ $0 $@
-
-@@ -1443,8 +1582,8 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- $as_echo "PATH: $as_dir"
--done
-+ $as_echo "PATH: $as_dir"
-+ done
- IFS=$as_save_IFS
-
- } >&5
-@@ -1481,9 +1620,9 @@ do
- ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
-- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
-+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
- 2)
-- ac_configure_args1="$ac_configure_args1 '$ac_arg'"
-+ as_fn_append ac_configure_args1 " '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
-@@ -1499,13 +1638,13 @@ do
- -* ) ac_must_keep_next=true ;;
- esac
- fi
-- ac_configure_args="$ac_configure_args '$ac_arg'"
-+ as_fn_append ac_configure_args " '$ac_arg'"
- ;;
- esac
- done
- done
--$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
--$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-+{ ac_configure_args0=; unset ac_configure_args0;}
-+{ ac_configure_args1=; unset ac_configure_args1;}
-
- # When interrupted or exit'd, cleanup temporary files, and complete
- # config.log. We remove comments because anyway the quotes in there
-@@ -1517,11 +1656,9 @@ trap 'exit_status=$?
- {
- echo
-
-- cat <<\_ASBOX
--## ---------------- ##
-+ $as_echo "## ---------------- ##
- ## Cache variables. ##
--## ---------------- ##
--_ASBOX
-+## ---------------- ##"
- echo
- # The following way of writing the cache mishandles newlines in values,
- (
-@@ -1530,13 +1667,13 @@ _ASBOX
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
-- *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
-+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
- $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-- *) $as_unset $ac_var ;;
-+ *) { eval $ac_var=; unset $ac_var;} ;;
- esac ;;
- esac
- done
-@@ -1555,11 +1692,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- )
- echo
-
-- cat <<\_ASBOX
--## ----------------- ##
-+ $as_echo "## ----------------- ##
- ## Output variables. ##
--## ----------------- ##
--_ASBOX
-+## ----------------- ##"
- echo
- for ac_var in $ac_subst_vars
- do
-@@ -1572,11 +1707,9 @@ _ASBOX
- echo
-
- if test -n "$ac_subst_files"; then
-- cat <<\_ASBOX
--## ------------------- ##
-+ $as_echo "## ------------------- ##
- ## File substitutions. ##
--## ------------------- ##
--_ASBOX
-+## ------------------- ##"
- echo
- for ac_var in $ac_subst_files
- do
-@@ -1590,11 +1723,9 @@ _ASBOX
- fi
-
- if test -s confdefs.h; then
-- cat <<\_ASBOX
--## ----------- ##
-+ $as_echo "## ----------- ##
- ## confdefs.h. ##
--## ----------- ##
--_ASBOX
-+## ----------- ##"
- echo
- cat confdefs.h
- echo
-@@ -1608,46 +1739,53 @@ _ASBOX
- exit $exit_status
- ' 0
- for ac_signal in 1 2 13 15; do
-- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
- done
- ac_signal=0
-
- # confdefs.h avoids OS command line length limits that DEFS can exceed.
- rm -f -r conftest* confdefs.h
-
-+$as_echo "/* confdefs.h */" > confdefs.h
-+
- # Predefined preprocessor variables.
-
- cat >>confdefs.h <<_ACEOF
- #define PACKAGE_NAME "$PACKAGE_NAME"
- _ACEOF
-
--
- cat >>confdefs.h <<_ACEOF
- #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
- _ACEOF
-
--
- cat >>confdefs.h <<_ACEOF
- #define PACKAGE_VERSION "$PACKAGE_VERSION"
- _ACEOF
-
--
- cat >>confdefs.h <<_ACEOF
- #define PACKAGE_STRING "$PACKAGE_STRING"
- _ACEOF
-
--
- cat >>confdefs.h <<_ACEOF
- #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
- _ACEOF
-
-+cat >>confdefs.h <<_ACEOF
-+#define PACKAGE_URL "$PACKAGE_URL"
-+_ACEOF
-+
-
- # Let the site file select an alternate cache file if it wants to.
- # Prefer an explicitly selected file to automatically selected ones.
- ac_site_file1=NONE
- ac_site_file2=NONE
- if test -n "$CONFIG_SITE"; then
-- ac_site_file1=$CONFIG_SITE
-+ # We do not want a PATH search for config.site.
-+ case $CONFIG_SITE in #((
-+ -*) ac_site_file1=./$CONFIG_SITE;;
-+ */*) ac_site_file1=$CONFIG_SITE;;
-+ *) ac_site_file1=./$CONFIG_SITE;;
-+ esac
- elif test "x$prefix" != xNONE; then
- ac_site_file1=$prefix/share/config.site
- ac_site_file2=$prefix/etc/config.site
-@@ -1658,19 +1796,23 @@ fi
- for ac_site_file in "$ac_site_file1" "$ac_site_file2"
- do
- test "x$ac_site_file" = xNONE && continue
-- if test -r "$ac_site_file"; then
-- { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-+ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
- $as_echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
-- . "$ac_site_file"
-+ . "$ac_site_file" \
-+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+as_fn_error $? "failed to load site script $ac_site_file
-+See \`config.log' for more details" "$LINENO" 5; }
- fi
- done
-
- if test -r "$cache_file"; then
-- # Some versions of bash will fail to source /dev/null (special
-- # files actually), so we avoid doing that.
-- if test -f "$cache_file"; then
-- { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
-+ # Some versions of bash will fail to source /dev/null (special files
-+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
-+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
- $as_echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . "$cache_file";;
-@@ -1678,7 +1820,7 @@ $as_echo "$as_me: loading cache $cache_file" >&6;}
- esac
- fi
- else
-- { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
- $as_echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
- fi
-@@ -1693,11 +1835,11 @@ for ac_var in $ac_precious_vars; do
- eval ac_new_val=\$ac_env_${ac_var}_value
- case $ac_old_set,$ac_new_set in
- set,)
-- { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
- $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
-- { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
- $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
-@@ -1707,17 +1849,17 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_old_val_w=`echo x $ac_old_val`
- ac_new_val_w=`echo x $ac_new_val`
- if test "$ac_old_val_w" != "$ac_new_val_w"; then
-- { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
- $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- ac_cache_corrupted=:
- else
-- { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
- $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
- eval $ac_var=\$ac_old_val
- fi
-- { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
- $as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
-- { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
- $as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
- fi;;
- esac
-@@ -1729,35 +1871,20 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
-- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
-+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;
- esac
- fi
- done
- if $ac_cache_corrupted; then
-- { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
- $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-- { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
- $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-- { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
--$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
- fi
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-+## -------------------- ##
-+## Main body of script. ##
-+## -------------------- ##
-
- ac_ext=c
- ac_cpp='$CPP $CPPFLAGS'
-@@ -1784,9 +1911,7 @@ for ac_dir in $srcdir/../build-scripts; do
- fi
- done
- if test -z "$ac_aux_dir"; then
-- { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir/../build-scripts" >&5
--$as_echo "$as_me: error: cannot find install-sh or install.sh in $srcdir/../build-scripts" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "cannot find install-sh, install.sh, or shtool in $srcdir/../build-scripts" "$LINENO" 5
- fi
-
- # These three variables are undocumented and unsupported,
-@@ -1800,35 +1925,27 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
-
- # Make sure we can run config.sub.
- $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-- { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
--$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-
--{ $as_echo "$as_me:$LINENO: checking build system type" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
- $as_echo_n "checking build system type... " >&6; }
--if test "${ac_cv_build+set}" = set; then
-+if ${ac_cv_build+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- ac_build_alias=$build_alias
- test "x$ac_build_alias" = x &&
- ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
- test "x$ac_build_alias" = x &&
-- { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
--$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
- ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-- { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
--$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-
- fi
--{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
- $as_echo "$ac_cv_build" >&6; }
- case $ac_cv_build in
- *-*-*) ;;
--*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
--$as_echo "$as_me: error: invalid value of canonical build" >&2;}
-- { (exit 1); exit 1; }; };;
-+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
- esac
- build=$ac_cv_build
- ac_save_IFS=$IFS; IFS='-'
-@@ -1844,28 +1961,24 @@ IFS=$ac_save_IFS
- case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
--{ $as_echo "$as_me:$LINENO: checking host system type" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
- $as_echo_n "checking host system type... " >&6; }
--if test "${ac_cv_host+set}" = set; then
-+if ${ac_cv_host+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- if test "x$host_alias" = x; then
- ac_cv_host=$ac_cv_build
- else
- ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-- { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
--$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
- fi
-
- fi
--{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
- $as_echo "$ac_cv_host" >&6; }
- case $ac_cv_host in
- *-*-*) ;;
--*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
--$as_echo "$as_me: error: invalid value of canonical host" >&2;}
-- { (exit 1); exit 1; }; };;
-+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
- esac
- host=$ac_cv_host
- ac_save_IFS=$IFS; IFS='-'
-@@ -1891,9 +2004,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
- set dummy ${ac_tool_prefix}gcc; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_CC+set}" = set; then
-+if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- if test -n "$CC"; then
-@@ -1904,24 +2017,24 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- fi
- fi
- CC=$ac_cv_prog_CC
- if test -n "$CC"; then
-- { $as_echo "$as_me:$LINENO: result: $CC" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
- $as_echo "$CC" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-@@ -1931,9 +2044,9 @@ if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
- set dummy gcc; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-+if ${ac_cv_prog_ac_ct_CC+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- if test -n "$ac_ct_CC"; then
-@@ -1944,24 +2057,24 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- fi
- fi
- ac_ct_CC=$ac_cv_prog_ac_ct_CC
- if test -n "$ac_ct_CC"; then
-- { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
- $as_echo "$ac_ct_CC" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-@@ -1970,7 +2083,7 @@ fi
- else
- case $cross_compiling:$ac_tool_warned in
- yes:)
--{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
- $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
- ac_tool_warned=yes ;;
- esac
-@@ -1984,9 +2097,9 @@ if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
- set dummy ${ac_tool_prefix}cc; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_CC+set}" = set; then
-+if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- if test -n "$CC"; then
-@@ -1997,24 +2110,24 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- fi
- fi
- CC=$ac_cv_prog_CC
- if test -n "$CC"; then
-- { $as_echo "$as_me:$LINENO: result: $CC" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
- $as_echo "$CC" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-@@ -2024,9 +2137,9 @@ fi
- if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
- set dummy cc; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_CC+set}" = set; then
-+if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- if test -n "$CC"; then
-@@ -2038,18 +2151,18 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- if test $ac_prog_rejected = yes; then
-@@ -2068,10 +2181,10 @@ fi
- fi
- CC=$ac_cv_prog_CC
- if test -n "$CC"; then
-- { $as_echo "$as_me:$LINENO: result: $CC" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
- $as_echo "$CC" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-@@ -2083,9 +2196,9 @@ if test -z "$CC"; then
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
- set dummy $ac_tool_prefix$ac_prog; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_CC+set}" = set; then
-+if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- if test -n "$CC"; then
-@@ -2096,24 +2209,24 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- fi
- fi
- CC=$ac_cv_prog_CC
- if test -n "$CC"; then
-- { $as_echo "$as_me:$LINENO: result: $CC" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
- $as_echo "$CC" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-@@ -2127,9 +2240,9 @@ if test -z "$CC"; then
- do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
- set dummy $ac_prog; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-+if ${ac_cv_prog_ac_ct_CC+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- if test -n "$ac_ct_CC"; then
-@@ -2140,24 +2253,24 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- fi
- fi
- ac_ct_CC=$ac_cv_prog_ac_ct_CC
- if test -n "$ac_ct_CC"; then
-- { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
- $as_echo "$ac_ct_CC" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-@@ -2170,7 +2283,7 @@ done
- else
- case $cross_compiling:$ac_tool_warned in
- yes:)
--{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
- $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
- ac_tool_warned=yes ;;
- esac
-@@ -2181,57 +2294,37 @@ fi
- fi
-
-
--test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
- $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
--{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
--See \`config.log' for more details." >&5
--$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
--See \`config.log' for more details." >&2;}
-- { (exit 1); exit 1; }; }; }
-+as_fn_error $? "no acceptable C compiler found in \$PATH
-+See \`config.log' for more details" "$LINENO" 5; }
-
- # Provide some information about the compiler.
--$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
-+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
- set X $ac_compile
- ac_compiler=$2
--{ (ac_try="$ac_compiler --version >&5"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compiler --version >&5") 2>&5
-- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }
--{ (ac_try="$ac_compiler -v >&5"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compiler -v >&5") 2>&5
-- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }
--{ (ac_try="$ac_compiler -V >&5"
-+for ac_option in --version -v -V -qversion; do
-+ { { ac_try="$ac_compiler $ac_option >&5"
- case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
- esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compiler -V >&5") 2>&5
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }
-+ if test -s conftest.err; then
-+ sed '10a\
-+... rest of stderr output deleted ...
-+ 10q' conftest.err >conftest.er1
-+ cat conftest.er1 >&5
-+ fi
-+ rm -f conftest.er1 conftest.err
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }
-+done
-
--cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- int
-@@ -2247,8 +2340,8 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
- # Try to create an executable without -o first, disregard a.out.
- # It will help us diagnose broken compilers, and finding out an intuition
- # of exeext.
--{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
--$as_echo_n "checking for C compiler default output file name... " >&6; }
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-+$as_echo_n "checking whether the C compiler works... " >&6; }
- ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
- # The possible output files:
-@@ -2264,17 +2357,17 @@ do
- done
- rm -f $ac_rmfiles
-
--if { (ac_try="$ac_link_default"
-+if { { ac_try="$ac_link_default"
- case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
- esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link_default") 2>&5
- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }; then
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }; then :
- # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
- # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
- # in a Makefile. We should not override ac_cv_exeext if it was cached,
-@@ -2291,7 +2384,7 @@ do
- # certainly right.
- break;;
- *.* )
-- if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
-+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
- then :; else
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- fi
-@@ -2310,84 +2403,41 @@ test "$ac_cv_exeext" = no && ac_cv_exeext=
- else
- ac_file=''
- fi
--
--{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
--$as_echo "$ac_file" >&6; }
--if test -z "$ac_file"; then
-- $as_echo "$as_me: failed program was:" >&5
-+if test -z "$ac_file"; then :
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+$as_echo "$as_me: failed program was:" >&5
- sed 's/^/| /' conftest.$ac_ext >&5
-
--{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
- $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
--{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
--See \`config.log' for more details." >&5
--$as_echo "$as_me: error: C compiler cannot create executables
--See \`config.log' for more details." >&2;}
-- { (exit 77); exit 77; }; }; }
-+as_fn_error 77 "C compiler cannot create executables
-+See \`config.log' for more details" "$LINENO" 5; }
-+else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
- fi
--
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-+$as_echo_n "checking for C compiler default output file name... " >&6; }
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-+$as_echo "$ac_file" >&6; }
- ac_exeext=$ac_cv_exeext
-
--# Check that the compiler produces executables we can run. If not, either
--# the compiler is broken, or we cross compile.
--{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
--$as_echo_n "checking whether the C compiler works... " >&6; }
--# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
--# If not cross compiling, check that we can run a simple program.
--if test "$cross_compiling" != yes; then
-- if { ac_try='./$ac_file'
-- { (case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_try") 2>&5
-- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }; }; then
-- cross_compiling=no
-- else
-- if test "$cross_compiling" = maybe; then
-- cross_compiling=yes
-- else
-- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
--$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
--{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
--If you meant to cross compile, use \`--host'.
--See \`config.log' for more details." >&5
--$as_echo "$as_me: error: cannot run C compiled programs.
--If you meant to cross compile, use \`--host'.
--See \`config.log' for more details." >&2;}
-- { (exit 1); exit 1; }; }; }
-- fi
-- fi
--fi
--{ $as_echo "$as_me:$LINENO: result: yes" >&5
--$as_echo "yes" >&6; }
--
- rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
- ac_clean_files=$ac_clean_files_save
--# Check that the compiler produces executables we can run. If not, either
--# the compiler is broken, or we cross compile.
--{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
--$as_echo_n "checking whether we are cross compiling... " >&6; }
--{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
--$as_echo "$cross_compiling" >&6; }
--
--{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
- $as_echo_n "checking for suffix of executables... " >&6; }
--if { (ac_try="$ac_link"
-+if { { ac_try="$ac_link"
- case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
- esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }; then
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }; then :
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
- # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
- # work properly (i.e., refer to `conftest.exe'), while it won't with
-@@ -2402,32 +2452,83 @@ for ac_file in conftest.exe conftest conftest.*; do
- esac
- done
- else
-- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
- $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
--{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
--See \`config.log' for more details." >&5
--$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
--See \`config.log' for more details." >&2;}
-- { (exit 1); exit 1; }; }; }
-+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-+See \`config.log' for more details" "$LINENO" 5; }
- fi
--
--rm -f conftest$ac_cv_exeext
--{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-+rm -f conftest conftest$ac_cv_exeext
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
- $as_echo "$ac_cv_exeext" >&6; }
-
- rm -f conftest.$ac_ext
- EXEEXT=$ac_cv_exeext
- ac_exeext=$EXEEXT
--{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
-+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+#include <stdio.h>
-+int
-+main ()
-+{
-+FILE *f = fopen ("conftest.out", "w");
-+ return ferror (f) || fclose (f) != 0;
-+
-+ ;
-+ return 0;
++ SDL_KeyState[key] = state;
+}
-+_ACEOF
-+ac_clean_files="$ac_clean_files conftest.out"
-+# Check that the compiler produces executables we can run. If not, either
-+# the compiler is broken, or we cross compile.
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-+$as_echo_n "checking whether we are cross compiling... " >&6; }
-+if test "$cross_compiling" != yes; then
-+ { { ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }
-+ if { ac_try='./conftest$ac_cv_exeext'
-+ { { case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }; }; then
-+ cross_compiling=no
-+ else
-+ if test "$cross_compiling" = maybe; then
-+ cross_compiling=yes
-+ else
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+as_fn_error $? "cannot run C compiled programs.
-+If you meant to cross compile, use \`--host'.
-+See \`config.log' for more details" "$LINENO" 5; }
-+ fi
-+ fi
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-+$as_echo "$cross_compiling" >&6; }
+
-+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-+ac_clean_files=$ac_clean_files_save
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
- $as_echo_n "checking for suffix of object files... " >&6; }
--if test "${ac_cv_objext+set}" = set; then
-+if ${ac_cv_objext+:} false; then :
- $as_echo_n "(cached) " >&6
- else
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- int
-@@ -2439,17 +2540,17 @@ main ()
- }
- _ACEOF
- rm -f conftest.o conftest.obj
--if { (ac_try="$ac_compile"
-+if { { ac_try="$ac_compile"
- case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
- esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compile") 2>&5
- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }; then
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }; then :
- for ac_file in conftest.o conftest.obj conftest.*; do
- test -f "$ac_file" || continue;
- case $ac_file in
-@@ -2462,31 +2563,23 @@ else
- $as_echo "$as_me: failed program was:" >&5
- sed 's/^/| /' conftest.$ac_ext >&5
-
--{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
- $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
--{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
--See \`config.log' for more details." >&5
--$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
--See \`config.log' for more details." >&2;}
-- { (exit 1); exit 1; }; }; }
-+as_fn_error $? "cannot compute suffix of object files: cannot compile
-+See \`config.log' for more details" "$LINENO" 5; }
- fi
--
- rm -f conftest.$ac_cv_objext conftest.$ac_ext
- fi
--{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
- $as_echo "$ac_cv_objext" >&6; }
- OBJEXT=$ac_cv_objext
- ac_objext=$OBJEXT
--{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
- $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
--if test "${ac_cv_c_compiler_gnu+set}" = set; then
-+if ${ac_cv_c_compiler_gnu+:} false; then :
- $as_echo_n "(cached) " >&6
- else
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- int
-@@ -2500,37 +2593,16 @@ main ()
- return 0;
- }
- _ACEOF
--rm -f conftest.$ac_objext
--if { (ac_try="$ac_compile"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compile") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest.$ac_objext; then
-+if ac_fn_c_try_compile "$LINENO"; then :
- ac_compiler_gnu=yes
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
-- ac_compiler_gnu=no
-+ ac_compiler_gnu=no
- fi
--
- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
- fi
--{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
- $as_echo "$ac_cv_c_compiler_gnu" >&6; }
- if test $ac_compiler_gnu = yes; then
- GCC=yes
-@@ -2539,20 +2611,16 @@ else
- fi
- ac_test_CFLAGS=${CFLAGS+set}
- ac_save_CFLAGS=$CFLAGS
--{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
- $as_echo_n "checking whether $CC accepts -g... " >&6; }
--if test "${ac_cv_prog_cc_g+set}" = set; then
-+if ${ac_cv_prog_cc_g+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- ac_save_c_werror_flag=$ac_c_werror_flag
- ac_c_werror_flag=yes
- ac_cv_prog_cc_g=no
- CFLAGS="-g"
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- int
-@@ -2563,35 +2631,11 @@ main ()
- return 0;
- }
- _ACEOF
--rm -f conftest.$ac_objext
--if { (ac_try="$ac_compile"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compile") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest.$ac_objext; then
-+if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_g=yes
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
-- CFLAGS=""
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ CFLAGS=""
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- int
-@@ -2602,36 +2646,12 @@ main ()
- return 0;
- }
- _ACEOF
--rm -f conftest.$ac_objext
--if { (ac_try="$ac_compile"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compile") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest.$ac_objext; then
-- :
--else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
-+if ac_fn_c_try_compile "$LINENO"; then :
-
-- ac_c_werror_flag=$ac_save_c_werror_flag
-+else
-+ ac_c_werror_flag=$ac_save_c_werror_flag
- CFLAGS="-g"
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- int
-@@ -2642,42 +2662,17 @@ main ()
- return 0;
- }
- _ACEOF
--rm -f conftest.$ac_objext
--if { (ac_try="$ac_compile"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compile") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest.$ac_objext; then
-+if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_g=yes
--else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
--
- fi
--
- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
--
- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
--
- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_c_werror_flag=$ac_save_c_werror_flag
- fi
--{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
- $as_echo "$ac_cv_prog_cc_g" >&6; }
- if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-@@ -2694,23 +2689,18 @@ else
- CFLAGS=
- fi
- fi
--{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
- $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
--if test "${ac_cv_prog_cc_c89+set}" = set; then
-+if ${ac_cv_prog_cc_c89+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- ac_cv_prog_cc_c89=no
- ac_save_CC=$CC
--cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
- #include <stdarg.h>
- #include <stdio.h>
--#include <sys/types.h>
--#include <sys/stat.h>
-+struct stat;
- /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
- struct buf { int x; };
- FILE * (*rcsopen) (struct buf *, struct stat *, int);
-@@ -2762,32 +2752,9 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
- -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
- do
- CC="$ac_save_CC $ac_arg"
-- rm -f conftest.$ac_objext
--if { (ac_try="$ac_compile"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compile") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest.$ac_objext; then
-+ if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_c89=$ac_arg
--else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
--
- fi
--
- rm -f core conftest.err conftest.$ac_objext
- test "x$ac_cv_prog_cc_c89" != "xno" && break
- done
-@@ -2798,17 +2765,19 @@ fi
- # AC_CACHE_VAL
- case "x$ac_cv_prog_cc_c89" in
- x)
-- { $as_echo "$as_me:$LINENO: result: none needed" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
- $as_echo "none needed" >&6; } ;;
- xno)
-- { $as_echo "$as_me:$LINENO: result: unsupported" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
- $as_echo "unsupported" >&6; } ;;
- *)
- CC="$CC $ac_cv_prog_cc_c89"
-- { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
- $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
- esac
-+if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-+fi
-
- ac_ext=c
- ac_cpp='$CPP $CPPFLAGS'
-@@ -2819,26 +2788,22 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
--{ $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
- $as_echo_n "checking for an ANSI C-conforming const... " >&6; }
--if test "${ac_cv_c_const+set}" = set; then
-+if ${ac_cv_c_const+:} false; then :
- $as_echo_n "(cached) " >&6
- else
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- int
- main ()
+ SDLMod SDL_GetModState (void)
{
--/* FIXME: Include the comments suggested by Paul. */
-+
- #ifndef __cplusplus
-- /* Ultrix mips cc rejects this. */
-+ /* Ultrix mips cc rejects this sort of thing. */
- typedef int charset[2];
-- const charset cs;
-+ const charset cs = { 0, 0 };
- /* SunOS 4.1.1 cc rejects this. */
- char const *const *pcpcc;
- char **ppc;
-@@ -2855,8 +2820,9 @@ main ()
- ++pcpcc;
- ppc = (char**) pcpcc;
- pcpcc = (char const *const *) ppc;
-- { /* SCO 3.2v4 cc rejects this. */
-- char *t;
-+ { /* SCO 3.2v4 cc rejects this sort of thing. */
-+ char tx;
-+ char *t = &tx;
- char const *s = 0 ? (char *) 0 : (char const *) 0;
-
- *t++ = 0;
-@@ -2872,10 +2838,10 @@ main ()
- iptr p = 0;
- ++p;
- }
-- { /* AIX XL C 1.02.0.0 rejects this saying
-+ { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
-- struct s { int j; const int *ap[3]; };
-- struct s *b; b->j = 5;
-+ struct s { int j; const int *ap[3]; } bx;
-+ struct s *b = &bx; b->j = 5;
- }
- { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
- const int foo = 10;
-@@ -2888,41 +2854,18 @@ main ()
- return 0;
- }
- _ACEOF
--rm -f conftest.$ac_objext
--if { (ac_try="$ac_compile"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compile") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest.$ac_objext; then
-+if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_c_const=yes
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
-- ac_cv_c_const=no
-+ ac_cv_c_const=no
- fi
--
- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
--{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
- $as_echo "$ac_cv_c_const" >&6; }
- if test $ac_cv_c_const = no; then
-
--cat >>confdefs.h <<\_ACEOF
--#define const /**/
--_ACEOF
-+$as_echo "#define const /**/" >>confdefs.h
-
- fi
-
-@@ -2955,9 +2898,9 @@ case "$host" in
- MATHLIB=""
- # Extract the first word of "osmesa-config", so it can be a program name with args.
- set dummy osmesa-config; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_path_OSMESA_CONFIG+set}" = set; then
-+if ${ac_cv_path_OSMESA_CONFIG+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- case $OSMESA_CONFIG in
-@@ -2970,14 +2913,14 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_OSMESA_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- test -z "$ac_cv_path_OSMESA_CONFIG" && ac_cv_path_OSMESA_CONFIG="no"
-@@ -2986,10 +2929,10 @@ esac
- fi
- OSMESA_CONFIG=$ac_cv_path_OSMESA_CONFIG
- if test -n "$OSMESA_CONFIG"; then
-- { $as_echo "$as_me:$LINENO: result: $OSMESA_CONFIG" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OSMESA_CONFIG" >&5
- $as_echo "$OSMESA_CONFIG" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-@@ -3015,7 +2958,7 @@ esac
- SDL_VERSION=1.2.10
-
- # Check whether --with-sdl-prefix was given.
--if test "${with_sdl_prefix+set}" = set; then
-+if test "${with_sdl_prefix+set}" = set; then :
- withval=$with_sdl_prefix; sdl_prefix="$withval"
- else
- sdl_prefix=""
-@@ -3023,14 +2966,14 @@ fi
-
-
- # Check whether --with-sdl-exec-prefix was given.
--if test "${with_sdl_exec_prefix+set}" = set; then
-+if test "${with_sdl_exec_prefix+set}" = set; then :
- withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval"
- else
- sdl_exec_prefix=""
- fi
-
- # Check whether --enable-sdltest was given.
--if test "${enable_sdltest+set}" = set; then
-+if test "${enable_sdltest+set}" = set; then :
- enableval=$enable_sdltest;
- else
- enable_sdltest=yes
-@@ -3055,9 +2998,9 @@ fi
- fi
- # Extract the first word of "sdl-config", so it can be a program name with args.
- set dummy sdl-config; ac_word=$2
--{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_path_SDL_CONFIG+set}" = set; then
-+if ${ac_cv_path_SDL_CONFIG+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- case $SDL_CONFIG in
-@@ -3070,14 +3013,14 @@ for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- for ac_exec_ext in '' $ac_executable_extensions; do
-- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
- done
--done
-+ done
- IFS=$as_save_IFS
-
- test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no"
-@@ -3086,16 +3029,16 @@ esac
- fi
- SDL_CONFIG=$ac_cv_path_SDL_CONFIG
- if test -n "$SDL_CONFIG"; then
-- { $as_echo "$as_me:$LINENO: result: $SDL_CONFIG" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDL_CONFIG" >&5
- $as_echo "$SDL_CONFIG" >&6; }
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
-
-
- min_sdl_version=$SDL_VERSION
-- { $as_echo "$as_me:$LINENO: checking for SDL - version >= $min_sdl_version" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL - version >= $min_sdl_version" >&5
- $as_echo_n "checking for SDL - version >= $min_sdl_version... " >&6; }
- no_sdl=""
- if test "$SDL_CONFIG" = "no" ; then
-@@ -3118,14 +3061,10 @@ $as_echo_n "checking for SDL - version >= $min_sdl_version... " >&6; }
- CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
- LIBS="$LIBS $SDL_LIBS"
- rm -f conf.sdltest
-- if test "$cross_compiling" = yes; then
-+ if test "$cross_compiling" = yes; then :
- echo $ac_n "cross compiling; assumed OK... $ac_c"
- else
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- #include <stdio.h>
-@@ -3186,53 +3125,26 @@ int main (int argc, char *argv[])
-
-
- _ACEOF
--rm -f conftest$ac_exeext
--if { (ac_try="$ac_link"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_link") 2>&5
-- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-- { (case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_try") 2>&5
-- ac_status=$?
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }; }; then
-- :
--else
-- $as_echo "$as_me: program exited with status $ac_status" >&5
--$as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
-+if ac_fn_c_try_run "$LINENO"; then :
-
--( exit $ac_status )
--no_sdl=yes
-+else
-+ no_sdl=yes
- fi
--rm -rf conftest.dSYM
--rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-+ conftest.$ac_objext conftest.beam conftest.$ac_ext
- fi
-
--
- CFLAGS="$ac_save_CFLAGS"
- CXXFLAGS="$ac_save_CXXFLAGS"
- LIBS="$ac_save_LIBS"
- fi
- fi
- if test "x$no_sdl" = x ; then
-- { $as_echo "$as_me:$LINENO: result: yes" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
- $as_echo "yes" >&6; }
- :
- else
-- { $as_echo "$as_me:$LINENO: result: no" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- if test "$SDL_CONFIG" = "no" ; then
- echo "*** The sdl-config script installed by SDL could not be found"
-@@ -3247,11 +3159,7 @@ $as_echo "no" >&6; }
- CFLAGS="$CFLAGS $SDL_CFLAGS"
- CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
- LIBS="$LIBS $SDL_LIBS"
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
- #include <stdio.h>
-@@ -3270,27 +3178,7 @@ main ()
- return 0;
- }
- _ACEOF
--rm -f conftest.$ac_objext conftest$ac_exeext
--if { (ac_try="$ac_link"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_link") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest$ac_exeext && {
-- test "$cross_compiling" = yes ||
-- $as_test_x conftest$ac_exeext
-- }; then
-+if ac_fn_c_try_link "$LINENO"; then :
- echo "*** The test program compiled, but did not run. This usually means"
- echo "*** that the run-time linker is not finding SDL or finding the wrong"
- echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
-@@ -3301,18 +3189,13 @@ $as_echo "$ac_try_echo") >&5
- echo "*** If you have an old version installed, it is best to remove it, although"
- echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
-- echo "*** The test program failed to compile or link. See the file config.log for the"
-+ echo "*** The test program failed to compile or link. See the file config.log for the"
- echo "*** exact error that occured. This usually means SDL was incorrectly installed"
- echo "*** or that you have moved SDL since it was installed. In the latter case, you"
- echo "*** may want to edit the sdl-config script: $SDL_CONFIG"
- fi
--
--rm -rf conftest.dSYM
--rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-- conftest$ac_exeext conftest.$ac_ext
-+rm -f core conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$ac_save_CFLAGS"
- CXXFLAGS="$ac_save_CXXFLAGS"
- LIBS="$ac_save_LIBS"
-@@ -3320,9 +3203,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- fi
- SDL_CFLAGS=""
- SDL_LIBS=""
-- { { $as_echo "$as_me:$LINENO: error: *** SDL version $SDL_VERSION not found!" >&5
--$as_echo "$as_me: error: *** SDL version $SDL_VERSION not found!" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "*** SDL version $SDL_VERSION not found!" "$LINENO" 5
-
- fi
-
-@@ -3337,14 +3218,14 @@ ac_cpp='$CPP $CPPFLAGS'
- ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
- ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
- ac_compiler_gnu=$ac_cv_c_compiler_gnu
--{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
- $as_echo_n "checking how to run the C preprocessor... " >&6; }
- # On Suns, sometimes $CPP names a directory.
- if test -n "$CPP" && test -d "$CPP"; then
- CPP=
- fi
- if test -z "$CPP"; then
-- if test "${ac_cv_prog_CPP+set}" = set; then
-+ if ${ac_cv_prog_CPP+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- # Double quotes because CPP needs to be expanded
-@@ -3359,11 +3240,7 @@ do
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
- #ifdef __STDC__
- # include <limits.h>
-@@ -3372,78 +3249,34 @@ cat >>conftest.$ac_ext <<_ACEOF
- #endif
- Syntax error
- _ACEOF
--if { (ac_try="$ac_cpp conftest.$ac_ext"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } >/dev/null && {
-- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- }; then
-- :
--else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
-+if ac_fn_c_try_cpp "$LINENO"; then :
-
-+else
- # Broken: fails on valid input.
- continue
- fi
--
--rm -f conftest.err conftest.$ac_ext
-+rm -f conftest.err conftest.i conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
- #include <ac_nonexistent.h>
- _ACEOF
--if { (ac_try="$ac_cpp conftest.$ac_ext"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } >/dev/null && {
-- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- }; then
-+if ac_fn_c_try_cpp "$LINENO"; then :
- # Broken: success on invalid input.
- continue
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
- # Passes both tests.
- ac_preproc_ok=:
- break
- fi
--
--rm -f conftest.err conftest.$ac_ext
-+rm -f conftest.err conftest.i conftest.$ac_ext
-
- done
- # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
--rm -f conftest.err conftest.$ac_ext
--if $ac_preproc_ok; then
-+rm -f conftest.i conftest.err conftest.$ac_ext
-+if $ac_preproc_ok; then :
- break
- fi
-
-@@ -3455,7 +3288,7 @@ fi
- else
- ac_cv_prog_CPP=$CPP
- fi
--{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
- $as_echo "$CPP" >&6; }
- ac_preproc_ok=false
- for ac_c_preproc_warn_flag in '' yes
-@@ -3466,100 +3299,49 @@ do
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
- #ifdef __STDC__
- # include <limits.h>
- #else
- # include <assert.h>
--#endif
-- Syntax error
--_ACEOF
--if { (ac_try="$ac_cpp conftest.$ac_ext"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } >/dev/null && {
-- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- }; then
-- :
--else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
-+#endif
-+ Syntax error
-+_ACEOF
-+if ac_fn_c_try_cpp "$LINENO"; then :
-
-+else
- # Broken: fails on valid input.
- continue
- fi
--
--rm -f conftest.err conftest.$ac_ext
-+rm -f conftest.err conftest.i conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
- #include <ac_nonexistent.h>
- _ACEOF
--if { (ac_try="$ac_cpp conftest.$ac_ext"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } >/dev/null && {
-- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- }; then
-+if ac_fn_c_try_cpp "$LINENO"; then :
- # Broken: success on invalid input.
- continue
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
- # Passes both tests.
- ac_preproc_ok=:
- break
- fi
--
--rm -f conftest.err conftest.$ac_ext
-+rm -f conftest.err conftest.i conftest.$ac_ext
-
- done
- # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
--rm -f conftest.err conftest.$ac_ext
--if $ac_preproc_ok; then
-- :
-+rm -f conftest.i conftest.err conftest.$ac_ext
-+if $ac_preproc_ok; then :
-+
- else
-- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
- $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
--{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
--See \`config.log' for more details." >&5
--$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
--See \`config.log' for more details." >&2;}
-- { (exit 1); exit 1; }; }; }
-+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-+See \`config.log' for more details" "$LINENO" 5; }
- fi
-
- ac_ext=c
-@@ -3569,12 +3351,12 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
- ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
--{ $as_echo "$as_me:$LINENO: checking for X" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5
- $as_echo_n "checking for X... " >&6; }
-
-
- # Check whether --with-x was given.
--if test "${with_x+set}" = set; then
-+if test "${with_x+set}" = set; then :
- withval=$with_x;
- fi
-
-@@ -3584,10 +3366,8 @@ if test "x$with_x" = xno; then
- have_x=disabled
- else
- case $x_includes,$x_libraries in #(
-- *\'*) { { $as_echo "$as_me:$LINENO: error: cannot use X directory names containing '" >&5
--$as_echo "$as_me: error: cannot use X directory names containing '" >&2;}
-- { (exit 1); exit 1; }; };; #(
-- *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then
-+ *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
-+ *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then :
- $as_echo_n "(cached) " >&6
- else
- # One or both of the vars are not set, and there is no cached value.
-@@ -3604,7 +3384,7 @@ libdir:
- @echo libdir='${LIBDIR}'
- _ACEOF
- if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
-- # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-+ # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
- for ac_var in incroot usrlibdir libdir; do
- eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
- done
-@@ -3635,21 +3415,25 @@ fi
- # Check X11 before X11Rn because it is often a symlink to the current release.
- ac_x_header_dirs='
- /usr/X11/include
-+/usr/X11R7/include
- /usr/X11R6/include
- /usr/X11R5/include
- /usr/X11R4/include
-
- /usr/include/X11
-+/usr/include/X11R7
- /usr/include/X11R6
- /usr/include/X11R5
- /usr/include/X11R4
-
- /usr/local/X11/include
-+/usr/local/X11R7/include
- /usr/local/X11R6/include
- /usr/local/X11R5/include
- /usr/local/X11R4/include
-
- /usr/local/include/X11
-+/usr/local/include/X11R7
- /usr/local/include/X11R6
- /usr/local/include/X11R5
- /usr/local/include/X11R4
-@@ -3671,37 +3455,14 @@ ac_x_header_dirs='
- if test "$ac_x_includes" = no; then
- # Guess where to find include files, by looking for Xlib.h.
- # First, try using that file with no special directory specified.
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
- #include <X11/Xlib.h>
- _ACEOF
--if { (ac_try="$ac_cpp conftest.$ac_ext"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } >/dev/null && {
-- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- }; then
-+if ac_fn_c_try_cpp "$LINENO"; then :
- # We can compile using X headers with no special include directory.
- ac_x_includes=
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
- for ac_dir in $ac_x_header_dirs; do
- if test -r "$ac_dir/X11/Xlib.h"; then
- ac_x_includes=$ac_dir
-@@ -3709,8 +3470,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
- fi
- done
- fi
--
--rm -f conftest.err conftest.$ac_ext
-+rm -f conftest.err conftest.i conftest.$ac_ext
- fi # $ac_x_includes = no
-
- if test "$ac_x_libraries" = no; then
-@@ -3719,11 +3479,7 @@ if test "$ac_x_libraries" = no; then
- # Don't add to $LIBS permanently.
- ac_save_LIBS=$LIBS
- LIBS="-lX11 $LIBS"
-- cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
- #include <X11/Xlib.h>
- int
-@@ -3734,35 +3490,12 @@ XrmInitialize ()
- return 0;
- }
- _ACEOF
--rm -f conftest.$ac_objext conftest$ac_exeext
--if { (ac_try="$ac_link"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_link") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest$ac_exeext && {
-- test "$cross_compiling" = yes ||
-- $as_test_x conftest$ac_exeext
-- }; then
-+if ac_fn_c_try_link "$LINENO"; then :
- LIBS=$ac_save_LIBS
- # We can link X programs with no special library path.
- ac_x_libraries=
- else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
-- LIBS=$ac_save_LIBS
-+ LIBS=$ac_save_LIBS
- for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
- do
- # Don't even attempt the hair of trying to link an X program!
-@@ -3774,10 +3507,8 @@ do
- done
- done
- fi
--
--rm -rf conftest.dSYM
--rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-- conftest$ac_exeext conftest.$ac_ext
-+rm -f core conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
- fi # $ac_x_libraries = no
-
- case $ac_x_includes,$ac_x_libraries in #(
-@@ -3798,7 +3529,7 @@ fi
- fi # $with_x != no
-
- if test "$have_x" != yes; then
-- { $as_echo "$as_me:$LINENO: result: $have_x" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5
- $as_echo "$have_x" >&6; }
- no_x=yes
- else
-@@ -3809,7 +3540,7 @@ else
- ac_cv_have_x="have_x=yes\
- ac_x_includes='$x_includes'\
- ac_x_libraries='$x_libraries'"
-- { $as_echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5
- $as_echo "libraries $x_libraries, headers $x_includes" >&6; }
- fi
-
-@@ -3826,14 +3557,10 @@ if test x$have_x = xyes; then
- fi
- fi
-
--{ $as_echo "$as_me:$LINENO: checking for OpenGL support" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL support" >&5
- $as_echo_n "checking for OpenGL support... " >&6; }
- have_opengl=no
--cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
-+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
+ return(SDL_ModState);
+diff --git a/src/video/nacl/SDL_naclevents.c b/src/video/nacl/SDL_naclevents.c
+index a2f7e19..461e1ca 100644
+--- a/src/video/nacl/SDL_naclevents.c
++++ b/src/video/nacl/SDL_naclevents.c
+@@ -29,6 +29,7 @@
+
+ #include <math.h>
+ #include <ppapi_simple/ps_event.h>
++#include <ppapi/c/ppb_input_event.h>
- #include "SDL_opengl.h"
-@@ -3847,36 +3574,13 @@ main ()
- return 0;
+ #define PPAPI_KEY_CTRL 17
+ #define PPAPI_KEY_ALT 18
+@@ -176,12 +177,15 @@ static SDLKey translateKey(uint32_t code) {
+ }
}
- _ACEOF
--rm -f conftest.$ac_objext
--if { (ac_try="$ac_compile"
--case "(($ac_try" in
-- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-- *) ac_try_echo=$ac_try;;
--esac
--eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
--$as_echo "$ac_try_echo") >&5
-- (eval "$ac_compile") 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } && {
-- test -z "$ac_c_werror_flag" ||
-- test ! -s conftest.err
-- } && test -s conftest.$ac_objext; then
-+if ac_fn_c_try_compile "$LINENO"; then :
-
- have_opengl=yes
-
--else
-- $as_echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
--
- fi
--
- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
--{ $as_echo "$as_me:$LINENO: result: $have_opengl" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengl" >&5
- $as_echo "$have_opengl" >&6; }
- if test x$have_opengl = xyes; then
- CFLAGS="$CFLAGS -DHAVE_OPENGL"
-@@ -3915,13 +3619,13 @@ _ACEOF
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
-- *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
-+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
- $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-- *) $as_unset $ac_var ;;
-+ *) { eval $ac_var=; unset $ac_var;} ;;
- esac ;;
- esac
- done
-@@ -3929,8 +3633,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- (set) 2>&1 |
- case $as_nl`(ac_space=' '; set) 2>&1` in #(
- *${as_nl}ac_space=\ *)
-- # `set' does not quote correctly, so add quotes (double-quote
-- # substitution turns \\\\ into \\, and sed turns \\ into \).
-+ # `set' does not quote correctly, so add quotes: double-quote
-+ # substitution turns \\\\ into \\, and sed turns \\ into \.
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-@@ -3952,12 +3656,23 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- :end' >>confcache
- if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
- if test -w "$cache_file"; then
-- test "x$cache_file" != "x/dev/null" &&
-- { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
-+ if test "x$cache_file" != "x/dev/null"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
- $as_echo "$as_me: updating cache $cache_file" >&6;}
-- cat confcache >$cache_file
-+ if test ! -f "$cache_file" || test -h "$cache_file"; then
-+ cat confcache >"$cache_file"
-+ else
-+ case $cache_file in #(
-+ */* | ?:*)
-+ mv -f confcache "$cache_file"$$ &&
-+ mv -f "$cache_file"$$ "$cache_file" ;; #(
-+ *)
-+ mv -f confcache "$cache_file" ;;
-+ esac
-+ fi
-+ fi
- else
-- { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
- $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
- fi
- fi
-@@ -4007,14 +3722,15 @@ DEFS=`sed -n "$ac_script" confdefs.h`
-
- ac_libobjs=
- ac_ltlibobjs=
-+U=
- for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
- ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
- # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
- # will be set to the directory where LIBOBJS objects are built.
-- ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-- ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
-+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
- done
- LIBOBJS=$ac_libobjs
-
-@@ -4022,13 +3738,14 @@ LTLIBOBJS=$ac_ltlibobjs
-
-
-
--: ${CONFIG_STATUS=./config.status}
-+: "${CONFIG_STATUS=./config.status}"
- ac_write_fail=0
- ac_clean_files_save=$ac_clean_files
- ac_clean_files="$ac_clean_files $CONFIG_STATUS"
--{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
- $as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
--cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-+as_write_fail=0
-+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
- #! $SHELL
- # Generated by $as_me.
- # Run this file to recreate the current configuration.
-@@ -4038,17 +3755,18 @@ cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- debug=false
- ac_cs_recheck=false
- ac_cs_silent=false
--SHELL=\${CONFIG_SHELL-$SHELL}
--_ACEOF
-
--cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
--## --------------------- ##
--## M4sh Initialization. ##
--## --------------------- ##
-+SHELL=\${CONFIG_SHELL-$SHELL}
-+export SHELL
-+_ASEOF
-+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-+## -------------------- ##
-+## M4sh Initialization. ##
-+## -------------------- ##
-
- # Be more Bourne compatible
- DUALCASE=1; export DUALCASE # for MKS sh
--if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-@@ -4056,23 +3774,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
- else
-- case `(set -o) 2>/dev/null` in
-- *posix*) set -o posix ;;
-+ case `(set -o) 2>/dev/null` in #(
-+ *posix*) :
-+ set -o posix ;; #(
-+ *) :
-+ ;;
- esac
--
- fi
-
-
--
--
--# PATH needs CR
--# Avoid depending upon Character Ranges.
--as_cr_letters='abcdefghijklmnopqrstuvwxyz'
--as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
--as_cr_Letters=$as_cr_letters$as_cr_LETTERS
--as_cr_digits='0123456789'
--as_cr_alnum=$as_cr_Letters$as_cr_digits
--
- as_nl='
- '
- export as_nl
-@@ -4080,7 +3790,13 @@ export as_nl
- as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
- as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
- as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
--if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-+# Prefer a ksh shell builtin over an external printf program on Solaris,
-+# but without wasting forks for bash or zsh.
-+if test -z "$BASH_VERSION$ZSH_VERSION" \
-+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-+ as_echo='print -r --'
-+ as_echo_n='print -rn --'
-+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='printf %s\n'
- as_echo_n='printf %s'
- else
-@@ -4091,7 +3807,7 @@ else
- as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
- as_echo_n_body='eval
- arg=$1;
-- case $arg in
-+ case $arg in #(
- *"$as_nl"*)
- expr "X$arg" : "X\\(.*\\)$as_nl";
- arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-@@ -4114,13 +3830,6 @@ if test "${PATH_SEPARATOR+set}" != set; then
- }
- fi
-
--# Support unset when possible.
--if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-- as_unset=unset
--else
-- as_unset=false
--fi
--
-
- # IFS
- # We need space, tab and new line, in precisely that order. Quoting is
-@@ -4130,15 +3839,16 @@ fi
- IFS=" "" $as_nl"
-
- # Find who we are. Look in the path if we contain no directory separator.
--case $0 in
-+as_myself=
-+case $0 in #((
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
- for as_dir in $PATH
- do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
-- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
--done
-+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-+ done
- IFS=$as_save_IFS
-
- ;;
-@@ -4150,12 +3860,16 @@ if test "x$as_myself" = x; then
- fi
- if test ! -f "$as_myself"; then
- $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-- { (exit 1); exit 1; }
-+ exit 1
- fi
-
--# Work around bugs in pre-3.0 UWIN ksh.
--for as_var in ENV MAIL MAILPATH
--do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
-+# Unset variables that we do not need and which cause bugs (e.g. in
-+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
-+# suppresses any "Segmentation fault" message there. '((' could
-+# trigger a bug in pdksh 5.2.14.
-+for as_var in BASH_ENV ENV MAIL MAILPATH
-+do eval test x\${$as_var+set} = xset \
-+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
- done
- PS1='$ '
- PS2='> '
-@@ -4167,7 +3881,89 @@ export LC_ALL
- LANGUAGE=C
- export LANGUAGE
-
--# Required to use basename.
-+# CDPATH.
-+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-+
-+
-+# as_fn_error STATUS ERROR [LINENO LOG_FD]
-+# ----------------------------------------
-+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-+# script with STATUS, using 1 if that was 0.
-+as_fn_error ()
-+{
-+ as_status=$1; test $as_status -eq 0 && as_status=1
-+ if test "$4"; then
-+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-+ fi
-+ $as_echo "$as_me: error: $2" >&2
-+ as_fn_exit $as_status
-+} # as_fn_error
-+
-+
-+# as_fn_set_status STATUS
-+# -----------------------
-+# Set $? to STATUS, without forking.
-+as_fn_set_status ()
-+{
-+ return $1
-+} # as_fn_set_status
-+
-+# as_fn_exit STATUS
-+# -----------------
-+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-+as_fn_exit ()
-+{
-+ set +e
-+ as_fn_set_status $1
-+ exit $1
-+} # as_fn_exit
-+
-+# as_fn_unset VAR
-+# ---------------
-+# Portably unset VAR.
-+as_fn_unset ()
-+{
-+ { eval $1=; unset $1;}
-+}
-+as_unset=as_fn_unset
-+# as_fn_append VAR VALUE
-+# ----------------------
-+# Append the text in VALUE to the end of the definition contained in VAR. Take
-+# advantage of any shell optimizations that allow amortized linear growth over
-+# repeated appends, instead of the typical quadratic growth present in naive
-+# implementations.
-+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-+ eval 'as_fn_append ()
-+ {
-+ eval $1+=\$2
-+ }'
-+else
-+ as_fn_append ()
-+ {
-+ eval $1=\$$1\$2
-+ }
-+fi # as_fn_append
-+
-+# as_fn_arith ARG...
-+# ------------------
-+# Perform arithmetic evaluation on the ARGs, and store the result in the
-+# global $as_val. Take advantage of shells that can avoid forks. The arguments
-+# must be portable across $(()) and expr.
-+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-+ eval 'as_fn_arith ()
-+ {
-+ as_val=$(( $* ))
-+ }'
-+else
-+ as_fn_arith ()
-+ {
-+ as_val=`expr "$@" || test $? -eq 1`
-+ }
-+fi # as_fn_arith
-+
-+
- if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-@@ -4181,8 +3977,12 @@ else
- as_basename=false
- fi
-
-+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-+ as_dirname=dirname
-+else
-+ as_dirname=false
-+fi
--# Name of the executable.
- as_me=`$as_basename -- "$0" ||
- $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
-@@ -4202,76 +4002,25 @@ $as_echo X/"$0" |
- }
- s/.*/./; q'`
-
--# CDPATH.
--$as_unset CDPATH
--
--
--
-- as_lineno_1=$LINENO
-- as_lineno_2=$LINENO
-- test "x$as_lineno_1" != "x$as_lineno_2" &&
-- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
--
-- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
-- # uniformly replaced by the line number. The first 'sed' inserts a
-- # line-number line after each line using $LINENO; the second 'sed'
-- # does the real work. The second script uses 'N' to pair each
-- # line-number line with the line containing $LINENO, and appends
-- # trailing '-' during substitution so that $LINENO is not a special
-- # case at line end.
-- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-- # scripts with optimization help from Paolo Bonzini. Blame Lee
-- # E. McMahon (1931-1989) for sed's syntax. :-)
-- sed -n '
-- p
-- /[$]LINENO/=
-- ' <$as_myself |
-- sed '
-- s/[$]LINENO.*/&-/
-- t lineno
-- b
-- :lineno
-- N
-- :loop
-- s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
-- t loop
-- s/-\n.*//
-- ' >$as_me.lineno &&
-- chmod +x "$as_me.lineno" ||
-- { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
-- { (exit 1); exit 1; }; }
--
-- # Don't try to exec as it changes $[0], causing all sort of problems
-- # (the dirname of $[0] is not the place where we might find the
-- # original and so on. Autoconf is especially sensitive to this).
-- . "./$as_me.lineno"
-- # Exit status is that of the last command.
-- exit
--}
--
--
--if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-- as_dirname=dirname
--else
-- as_dirname=false
--fi
-+# Avoid depending upon Character Ranges.
-+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-+as_cr_digits='0123456789'
-+as_cr_alnum=$as_cr_Letters$as_cr_digits
-
- ECHO_C= ECHO_N= ECHO_T=
--case `echo -n x` in
-+case `echo -n x` in #(((((
- -n*)
-- case `echo 'x\c'` in
-+ case `echo 'xy\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
-- *) ECHO_C='\c';;
-+ xy) ECHO_C='\c';;
-+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
-+ ECHO_T=' ';;
- esac;;
- *)
- ECHO_N='-n';;
- esac
--if expr a : '\(a\)' >/dev/null 2>&1 &&
-- test "X`expr 00001 : '.*\(...\)'`" = X001; then
-- as_expr=expr
--else
-- as_expr=false
--fi
-
- rm -f conf$$ conf$$.exe conf$$.file
- if test -d conf$$.dir; then
-@@ -4286,49 +4035,85 @@ if (echo >conf$$.file) 2>/dev/null; then
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-- # In both cases, we have to default to `cp -p'.
-+ # In both cases, we have to default to `cp -pR'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-- as_ln_s='cp -p'
-+ as_ln_s='cp -pR'
- elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
- else
-- as_ln_s='cp -p'
-+ as_ln_s='cp -pR'
- fi
- else
-- as_ln_s='cp -p'
-+ as_ln_s='cp -pR'
- fi
- rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
- rmdir conf$$.dir 2>/dev/null
-
-+
-+# as_fn_mkdir_p
-+# -------------
-+# Create "$as_dir" as a directory, including parents if necessary.
-+as_fn_mkdir_p ()
-+{
-+
-+ case $as_dir in #(
-+ -*) as_dir=./$as_dir;;
-+ esac
-+ test -d "$as_dir" || eval $as_mkdir_p || {
-+ as_dirs=
-+ while :; do
-+ case $as_dir in #(
-+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-+ *) as_qdir=$as_dir;;
-+ esac
-+ as_dirs="'$as_qdir' $as_dirs"
-+ as_dir=`$as_dirname -- "$as_dir" ||
-+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-+ X"$as_dir" : 'X\(//\)[^/]' \| \
-+ X"$as_dir" : 'X\(//\)$' \| \
-+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-+$as_echo X"$as_dir" |
-+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-+ s//\1/
-+ q
-+ }
-+ /^X\(\/\/\)[^/].*/{
-+ s//\1/
-+ q
-+ }
-+ /^X\(\/\/\)$/{
-+ s//\1/
-+ q
-+ }
-+ /^X\(\/\).*/{
-+ s//\1/
-+ q
-+ }
-+ s/.*/./; q'`
-+ test -d "$as_dir" && break
-+ done
-+ test -z "$as_dirs" || eval "mkdir $as_dirs"
-+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-+
-+
-+} # as_fn_mkdir_p
- if mkdir -p . 2>/dev/null; then
-- as_mkdir_p=:
-+ as_mkdir_p='mkdir -p "$as_dir"'
- else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
- fi
-
--if test -x / >/dev/null 2>&1; then
-- as_test_x='test -x'
--else
-- if ls -dL / >/dev/null 2>&1; then
-- as_ls_L_option=L
-- else
-- as_ls_L_option=
-- fi
-- as_test_x='
-- eval sh -c '\''
-- if test -d "$1"; then
-- test -d "$1/.";
-- else
-- case $1 in
-- -*)set "./$1";;
-- esac;
-- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
-- ???[sx]*):;;*)false;;esac;fi
-- '\'' sh
-- '
--fi
--as_executable_p=$as_test_x
++static SDL_bool SDL_NeedModUpdate = SDL_TRUE;
++
+ void HandleInputEvent(_THIS, PP_Resource event) {
+ static Uint8 last_scancode = 0;
+ static int alt_down = 0;
+ static int ctrl_down = 0;
+ PP_InputEvent_Type type;
+ PP_InputEvent_Modifier modifiers;
++ SDLMod sdl_mod;
+ Uint8 button;
+ Uint8 state;
+ Uint8 gained;
+@@ -197,9 +201,49 @@ void HandleInputEvent(_THIS, PP_Resource event) {
+ int sdl_wheel_clicks_y;
+ int i;
+
++ // defining modifiers array for conversion
++ static const size_t modcnt = 6;
++ static const int ppapi_mods[modcnt] = {
++ PP_INPUTEVENT_MODIFIER_SHIFTKEY,
++ PP_INPUTEVENT_MODIFIER_CONTROLKEY,
++ PP_INPUTEVENT_MODIFIER_ALTKEY,
++ PP_INPUTEVENT_MODIFIER_METAKEY,
++ PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY,
++ PP_INPUTEVENT_MODIFIER_NUMLOCKKEY
++ };
++ static const SDLMod sdl_mods[modcnt] = {
++ KMOD_LSHIFT,
++ KMOD_LCTRL,
++ KMOD_LALT,
++ KMOD_LMETA,
++ KMOD_CAPS,
++ KMOD_NUM
++ };
++ static const SDLKey sdl_keys[modcnt] = {
++ SDLK_LSHIFT,
++ SDLK_LCTRL,
++ SDLK_LALT,
++ SDLK_LMETA,
++ SDLK_CAPSLOCK,
++ SDLK_NUMLOCK
++ };
++ static const SDLKey sdl_rkeys[modcnt] = {
++ SDLK_RSHIFT,
++ SDLK_RCTRL,
++ SDLK_RALT,
++ SDLK_RMETA,
++ SDLK_CAPSLOCK,
++ SDLK_NUMLOCK
++ };
+
-+# as_fn_executable_p FILE
-+# -----------------------
-+# Test if FILE is an executable regular file.
-+as_fn_executable_p ()
-+{
-+ test -f "$1" && test -x "$1"
-+} # as_fn_executable_p
-+as_test_x='test -x'
-+as_executable_p=as_fn_executable_p
-
- # Sed expression to map a string onto a valid CPP name.
- as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-@@ -4338,13 +4123,19 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
- exec 6>&1
-+## ----------------------------------- ##
-+## Main body of $CONFIG_STATUS script. ##
-+## ----------------------------------- ##
-+_ASEOF
-+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
--# Save the log message, to keep $[0] and so on meaningful, and to
-+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-+# Save the log message, to keep $0 and so on meaningful, and to
- # report actual input values of CONFIG_FILES etc. instead of their
- # values after options handling.
- ac_log="
- This file was extended by $as_me, which was
--generated by GNU Autoconf 2.63. Invocation command line was
-+generated by GNU Autoconf 2.69. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
-@@ -4371,13 +4162,15 @@ _ACEOF
-
- cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
- ac_cs_usage="\
--\`$as_me' instantiates files from templates according to the
--current configuration.
-+\`$as_me' instantiates files and other configuration actions
-+from templates according to the current configuration. Unless the files
-+and actions are specified as TAGs, all are instantiated by default.
-
--Usage: $0 [OPTION]... [FILE]...
-+Usage: $0 [OPTION]... [TAG]...
-
- -h, --help print this help, then exit
- -V, --version print version number and configuration settings, then exit
-+ --config print configuration, then exit
- -q, --quiet, --silent
- do not print progress messages
- -d, --debug don't remove temporary files
-@@ -4388,16 +4181,17 @@ Usage: $0 [OPTION]... [FILE]...
- Configuration files:
- $config_files
-
--Report bugs to <bug-autoconf@gnu.org>."
-+Report bugs to the package provider."
-
- _ACEOF
- cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
- ac_cs_version="\\
- config.status
--configured by $0, generated by GNU Autoconf 2.63,
-- with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
-+configured by $0, generated by GNU Autoconf 2.69,
-+ with options \\"\$ac_cs_config\\"
-
--Copyright (C) 2008 Free Software Foundation, Inc.
-+Copyright (C) 2012 Free Software Foundation, Inc.
- This config.status script is free software; the Free Software Foundation
- gives unlimited permission to copy, distribute and modify it."
-
-@@ -4412,11 +4206,16 @@ ac_need_defaults=:
- while test $# != 0
- do
- case $1 in
-- --*=*)
-+ --*=?*)
- ac_option=`expr "X$1" : 'X\([^=]*\)='`
- ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
- ac_shift=:
- ;;
-+ --*=)
-+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
-+ ac_optarg=
-+ ac_shift=:
-+ ;;
- *)
- ac_option=$1
- ac_optarg=$2
-@@ -4430,14 +4229,17 @@ do
- ac_cs_recheck=: ;;
- --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
- $as_echo "$ac_cs_version"; exit ;;
-+ --config | --confi | --conf | --con | --co | --c )
-+ $as_echo "$ac_cs_config"; exit ;;
- --debug | --debu | --deb | --de | --d | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- case $ac_optarg in
- *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-+ '') as_fn_error $? "missing file argument" ;;
- esac
-- CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
-+ as_fn_append CONFIG_FILES " '$ac_optarg'"
- ac_need_defaults=false;;
- --he | --h | --help | --hel | -h )
- $as_echo "$ac_cs_usage"; exit ;;
-@@ -4446,11 +4248,10 @@ do
- ac_cs_silent=: ;;
-
- # This is an error.
-- -*) { $as_echo "$as_me: error: unrecognized option: $1
--Try \`$0 --help' for more information." >&2
-- { (exit 1); exit 1; }; } ;;
-+ -*) as_fn_error $? "unrecognized option: \`$1'
-+Try \`$0 --help' for more information." ;;
-
-- *) ac_config_targets="$ac_config_targets $1"
-+ *) as_fn_append ac_config_targets " $1"
- ac_need_defaults=false ;;
-
- esac
-@@ -4467,7 +4268,7 @@ fi
- _ACEOF
- cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- if \$ac_cs_recheck; then
-- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
- shift
- \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
- CONFIG_SHELL='$SHELL'
-@@ -4498,9 +4299,7 @@ do
- case $ac_config_target in
- "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-
-- *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
--$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
-- { (exit 1); exit 1; }; };;
-+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
- esac
- done
-
-@@ -4521,26 +4320,24 @@ fi
- # after its creation but before its name has been assigned to `$tmp'.
- $debug ||
- {
-- tmp=
-+ tmp= ac_tmp=
- trap 'exit_status=$?
-- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
-+ : "${ac_tmp:=$tmp}"
-+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
- ' 0
-- trap '{ (exit 1); exit 1; }' 1 2 13 15
-+ trap 'as_fn_exit 1' 1 2 13 15
- }
- # Create a (secure) tmp directory for tmp files.
-
- {
- tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-- test -n "$tmp" && test -d "$tmp"
-+ test -d "$tmp"
- } ||
- {
- tmp=./conf$$-$RANDOM
- (umask 077 && mkdir "$tmp")
--} ||
--{
-- $as_echo "$as_me: cannot create a temporary directory in ." >&2
-- { (exit 1); exit 1; }
--}
-+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-+ac_tmp=$tmp
-
- # Set up the scripts for CONFIG_FILES section.
- # No need to generate them if there are no CONFIG_FILES.
-@@ -4548,7 +4345,13 @@ $debug ||
- if test -n "$CONFIG_FILES"; then
-
-
--ac_cr=' '
-+ac_cr=`echo X | tr X '\015'`
-+# On cygwin, bash can eat \r inside `` if the user requested igncr.
-+# But we know of no other shell where ac_cr would be empty at this
-+# point, so we can use a bashism as a fallback.
-+if test "x$ac_cr" = x; then
-+ eval ac_cr=\$\'\\r\'
-+fi
- ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
- if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
- ac_cs_awk_cr='\\r'
-@@ -4556,7 +4359,7 @@ else
- ac_cs_awk_cr=$ac_cr
- fi
-
--echo 'BEGIN {' >"$tmp/subs1.awk" &&
-+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
- _ACEOF
-
-
-@@ -4565,24 +4368,18 @@ _ACEOF
- echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
- echo "_ACEOF"
- } >conf$$subs.sh ||
-- { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
--$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
-- { (exit 1); exit 1; }; }
--ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
-+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
- ac_delim='%!_!# '
- for ac_last_try in false false false false false :; do
- . ./conf$$subs.sh ||
-- { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
--$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-
- ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
- if test $ac_delim_n = $ac_delim_num; then
- break
- elif $ac_last_try; then
-- { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
--$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
- else
- ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
- fi
-@@ -4590,7 +4387,7 @@ done
- rm -f conf$$subs.sh
-
- cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
--cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
-+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
- _ACEOF
- sed -n '
- h
-@@ -4604,7 +4401,7 @@ s/'"$ac_delim"'$//
- t delim
- :nl
- h
--s/\(.\{148\}\).*/\1/
-+s/\(.\{148\}\)..*/\1/
- t more1
- s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
- p
-@@ -4618,7 +4415,7 @@ s/.\{148\}//
- t nl
- :delim
- h
--s/\(.\{148\}\).*/\1/
-+s/\(.\{148\}\)..*/\1/
- t more2
- s/["\\]/\\&/g; s/^/"/; s/$/"/
- p
-@@ -4638,7 +4435,7 @@ t delim
- rm -f conf$$subs.awk
- cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- _ACAWK
--cat >>"\$tmp/subs1.awk" <<_ACAWK &&
-+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
- for (key in S) S_is_set[key] = 1
- FS = ""
-
-@@ -4670,23 +4467,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
- sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
- else
- cat
--fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-- || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
--$as_echo "$as_me: error: could not setup config files machinery" >&2;}
-- { (exit 1); exit 1; }; }
-+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
-+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
- _ACEOF
-
--# VPATH may cause trouble with some makes, so we remove $(srcdir),
--# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
- # trailing colons and then remove the whole line if VPATH becomes empty
- # (actually we leave an empty line to preserve line numbers).
- if test "x$srcdir" = x.; then
-- ac_vpsub='/^[ ]*VPATH[ ]*=/{
--s/:*\$(srcdir):*/:/
--s/:*\${srcdir}:*/:/
--s/:*@srcdir@:*/:/
--s/^\([^=]*=[ ]*\):*/\1/
-+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
-+h
-+s///
-+s/^/:/
-+s/[ ]*$/:/
-+s/:\$(srcdir):/:/g
-+s/:\${srcdir}:/:/g
-+s/:@srcdir@:/:/g
-+s/^:*//
- s/:*$//
-+x
-+s/\(=[ ]*\).*/\1/
-+G
-+s/\n//
- s/^[^=]*=[ ]*$//
- }'
- fi
-@@ -4704,9 +4507,7 @@ do
- esac
- case $ac_mode$ac_tag in
- :[FHL]*:*);;
-- :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
--$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
-- { (exit 1); exit 1; }; };;
-+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
- :[FH]-) ac_tag=-:-;;
- :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
- esac
-@@ -4725,7 +4526,7 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
- for ac_f
- do
- case $ac_f in
-- -) ac_f="$tmp/stdin";;
-+ -) ac_f="$ac_tmp/stdin";;
- *) # Look for the file first in the build tree, then in the source tree
- # (if the path is not absolute). The absolute path cannot be DOS-style,
- # because $ac_f cannot contain `:'.
-@@ -4734,12 +4535,10 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
- [\\/$]*) false;;
- *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
- esac ||
-- { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
--$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
-- { (exit 1); exit 1; }; };;
-+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
- esac
- case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-- ac_file_inputs="$ac_file_inputs '$ac_f'"
-+ as_fn_append ac_file_inputs " '$ac_f'"
- done
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
-@@ -4750,7 +4549,7 @@ $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
- `' by configure.'
- if test x"$ac_file" != x-; then
- configure_input="$ac_file. $configure_input"
-- { $as_echo "$as_me:$LINENO: creating $ac_file" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
- $as_echo "$as_me: creating $ac_file" >&6;}
- fi
- # Neutralize special characters interpreted by sed in replacement strings.
-@@ -4762,10 +4561,8 @@ $as_echo "$as_me: creating $ac_file" >&6;}
- esac
-
- case $ac_tag in
-- *:-:* | *:-) cat >"$tmp/stdin" \
-- || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
--$as_echo "$as_me: error: could not create $ac_file" >&2;}
-- { (exit 1); exit 1; }; } ;;
-+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
-+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
- esac
- ;;
- esac
-@@ -4793,47 +4590,7 @@ $as_echo X"$ac_file" |
- q
- }
- s/.*/./; q'`
-- { as_dir="$ac_dir"
-- case $as_dir in #(
-- -*) as_dir=./$as_dir;;
-- esac
-- test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
-- as_dirs=
-- while :; do
-- case $as_dir in #(
-- *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-- *) as_qdir=$as_dir;;
-- esac
-- as_dirs="'$as_qdir' $as_dirs"
-- as_dir=`$as_dirname -- "$as_dir" ||
--$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-- X"$as_dir" : 'X\(//\)[^/]' \| \
-- X"$as_dir" : 'X\(//\)$' \| \
-- X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
--$as_echo X"$as_dir" |
-- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-- s//\1/
-- q
-- }
-- /^X\(\/\/\)[^/].*/{
-- s//\1/
-- q
-- }
-- /^X\(\/\/\)$/{
-- s//\1/
-- q
-- }
-- /^X\(\/\).*/{
-- s//\1/
-- q
-- }
-- s/.*/./; q'`
-- test -d "$as_dir" && break
-- done
-- test -z "$as_dirs" || eval "mkdir $as_dirs"
-- } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
--$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
-- { (exit 1); exit 1; }; }; }
-+ as_dir="$ac_dir"; as_fn_mkdir_p
- ac_builddir=.
-
- case "$ac_dir" in
-@@ -4881,7 +4638,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
- # If the template does not know about datarootdir, expand it.
- # FIXME: This hack should be removed a few years after 2.60.
- ac_datarootdir_hack=; ac_datarootdir_seen=
--
- ac_sed_dataroot='
- /datarootdir/ {
- p
-@@ -4891,12 +4647,11 @@ ac_sed_dataroot='
- /@docdir@/p
- /@infodir@/p
- /@localedir@/p
--/@mandir@/p
--'
-+/@mandir@/p'
- case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
- *datarootdir*) ac_datarootdir_seen=yes;;
- *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-- { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
- $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
- _ACEOF
- cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-@@ -4906,7 +4661,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- s&@infodir@&$infodir&g
- s&@localedir@&$localedir&g
- s&@mandir@&$mandir&g
-- s&\\\${datarootdir}&$datarootdir&g' ;;
-+ s&\\\${datarootdir}&$datarootdir&g' ;;
- esac
- _ACEOF
-
-@@ -4932,27 +4687,24 @@ s&@abs_builddir@&$ac_abs_builddir&;t t
- s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
- $ac_datarootdir_hack
- "
--eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
-- || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
--$as_echo "$as_me: error: could not create $ac_file" >&2;}
-- { (exit 1); exit 1; }; }
-+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
-+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-
- test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
-- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
-- { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
--which seems to be undefined. Please make sure it is defined." >&5
-+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
-+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
-+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-+which seems to be undefined. Please make sure it is defined" >&5
- $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
--which seems to be undefined. Please make sure it is defined." >&2;}
-+which seems to be undefined. Please make sure it is defined" >&2;}
-
-- rm -f "$tmp/stdin"
-+ rm -f "$ac_tmp/stdin"
- case $ac_file in
-- -) cat "$tmp/out" && rm -f "$tmp/out";;
-- *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
-+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
-+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
- esac \
-- || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
--$as_echo "$as_me: error: could not create $ac_file" >&2;}
-- { (exit 1); exit 1; }; }
-+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- ;;
-
-
-@@ -4962,15 +4714,12 @@ $as_echo "$as_me: error: could not create $ac_file" >&2;}
- done # for ac_tag
-
-
--{ (exit 0); exit 0; }
-+as_fn_exit 0
- _ACEOF
--chmod +x $CONFIG_STATUS
- ac_clean_files=$ac_clean_files_save
-
- test $ac_write_fail = 0 ||
-- { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
--$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
-- { (exit 1); exit 1; }; }
-+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
- # configure is writing to config.log, and then calls config.status.
-@@ -4991,10 +4740,10 @@ if test "$no_create" != yes; then
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
-- $ac_cs_success || { (exit 1); exit 1; }
-+ $ac_cs_success || as_fn_exit 1
- fi
- if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-- { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
- $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
- fi
-
+ type = dd->ppb_input_event->GetType(event);
+ modifiers = dd->ppb_input_event->GetModifiers(event);
+
++ // alt_down and ctrl_down correction
++ // needed when one of these keys were pressed outside of the module
++ alt_down = modifiers & PP_INPUTEVENT_MODIFIER_ALTKEY ? 1 : 0;
++ ctrl_down = modifiers & PP_INPUTEVENT_MODIFIER_CONTROLKEY ? 1 : 0;
++
+ switch (type) {
+ case PP_INPUTEVENT_TYPE_MOUSEDOWN:
+ case PP_INPUTEVENT_TYPE_MOUSEUP:
+@@ -216,13 +260,13 @@ void HandleInputEvent(_THIS, PP_Resource event) {
+ sdl_wheel_clicks_y = trunc(wheel_clicks_y);
+ button = (sdl_wheel_clicks_x > 0) ? SDL_BUTTON_X1 : SDL_BUTTON_X2;
+ for (i = 0; i < abs(sdl_wheel_clicks_x); i++) {
+- SDL_PrivateMouseButton(SDL_MOUSEBUTTONDOWN, button, 0, 0);
+- SDL_PrivateMouseButton(SDL_MOUSEBUTTONUP, button, 0, 0);
++ SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0);
++ SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0);
+ }
+ button = (sdl_wheel_clicks_y > 0) ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN;
+ for (i = 0; i < abs(sdl_wheel_clicks_y); i++) {
+- SDL_PrivateMouseButton(SDL_MOUSEBUTTONDOWN, button, 0, 0);
+- SDL_PrivateMouseButton(SDL_MOUSEBUTTONUP, button, 0, 0);
++ SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0);
++ SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0);
+ }
+ wheel_clicks_x -= sdl_wheel_clicks_x;
+ wheel_clicks_y -= sdl_wheel_clicks_y;
+@@ -318,6 +362,34 @@ void HandleInputEvent(_THIS, PP_Resource event) {
+ state = SDL_RELEASED;
+ last_scancode = 0;
+ }
++
++ if (SDL_NeedModUpdate) {
++ // copying keyboard modifiers from PPAPI
++ sdl_mod = KMOD_NONE;
++ for (i = 0; i < modcnt; ++i) {
++ if (sdl_keys[i] == keysym.sym) // if key is a modifier
++ continue; // then do not copy it
++ if (modifiers & ppapi_mods[i]) {
++ sdl_mod |= sdl_mods[i];
++ SDL_SetKeyState(sdl_keys[i], SDL_PRESSED);
++ } else {
++ SDL_SetKeyState(sdl_keys[i], SDL_RELEASED);
++ }
++ }
++ SDL_SetModState(sdl_mod);
++ SDL_NeedModUpdate = SDL_FALSE;
++ }
++
++ if (modifiers & PP_INPUTEVENT_MODIFIER_ISRIGHT) {
++ // convert left modifier keycode to the right one
++ for (i = 0; i < modcnt; ++i) {
++ if (keysym.sym == sdl_keys[i]) {
++ keysym.sym = sdl_rkeys[i];
++ break;
++ }
++ }
++ }
++
+ keysym.mod = KMOD_NONE;
+ SDL_TRACE("Key event: %d: %s\n", state, SDL_GetKeyName(keysym.sym));
+ SDL_PrivateKeyboard(state, &keysym);
+@@ -352,6 +424,7 @@ static void HandleEvent(_THIS, PSEvent* ps_event) {
+
+ /* From DidChangeFocus, contains a PP_Bool with the current focus state. */
+ case PSE_INSTANCE_DIDCHANGEFOCUS:
++ SDL_NeedModUpdate = SDL_TRUE;
+ break;
+
+ /* When the 3D context is lost, no resource. */
diff --git a/packaging/nacl/ports/sdl/pkg_info b/packaging/nacl/ports/sdl/pkg_info
index 2be6d94ee..21813f18c 100644
--- a/packaging/nacl/ports/sdl/pkg_info
+++ b/packaging/nacl/ports/sdl/pkg_info
@@ -1,9 +1,7 @@
NAME=sdl
-VERSION=1.2.14
-ARCHIVE_ROOT=SDL-1.2.14
-URL=http://www.libsdl.org/release/SDL-1.2.14.tar.gz
+VERSION=1.2.15
+URL=https://github.com/sbc100/SDL-mirror.git@1c6f2d0
LICENSE=LGPL2
-DEPENDS=(libtar regal)
-# Disabled on bionic due to regal.
-DISABLED_LIBC=(bionic)
-SHA1=ba625b4b404589b97e92d7acd165992debe576dd
+DEPENDS=(nacl-spawn regal)
+SHA1=0c5f193ced810b0d7ce3ab06d808cbb5eef03a2c
+DISABLED_TOOLCHAIN=(emscripten)
diff --git a/packaging/nacl/ports/zlib/build.sh b/packaging/nacl/ports/zlib/build.sh
deleted file mode 100644
index 96c860fd0..000000000
--- a/packaging/nacl/ports/zlib/build.sh
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2011 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# zlib doesn't support custom build directories so we have
-# to build directly in the source dir.
-BUILD_DIR=${SRC_DIR}
-EXECUTABLES="minigzip${NACL_EXEEXT} example${NACL_EXEEXT}"
-if [ "${NACL_SHARED}" = "1" ]; then
- EXECUTABLES+=" libz.so.1"
-fi
-
-ConfigureStep() {
- LogExecute rm -f libz.*
- SetupCrossEnvironment
- CHOST=${NACL_CROSS_PREFIX} LogExecute ./configure --prefix=${PREFIX}
-}
-
-
-RunMinigzip() {
-# export LD_LIBRARY_PATH=.
-# if echo "hello world" | ./minigzip | ./minigzip -d; then
-# echo ' *** minigzip test OK ***'
-# else
-# echo ' *** minigzip test FAILED ***'
-# exit 1
-# fi
-# unset LD_LIBRARY_PATH
- return 0
-}
-
-
-RunExample() {
- export LD_LIBRARY_PATH=.
- # This second test does not yet work on nacl (gzopen fails)
- #if ./example; then \
- #echo ' *** zlib test OK ***'; \
- #else \
- #echo ' *** zlib test FAILED ***'; \
- #exit 1
- #fi
- unset LD_LIBRARY_PATH
-}
-
-
-TestStep() {
- if [ "${NACL_LIBC}" = "glibc" ]; then
- # Tests do not currently run on GLIBC due to fdopen() not working
- # TODO(sbc): Remove this once glibc is fixed:
- # https://code.google.com/p/nativeclient/issues/detail?id=3362
- return
- fi
-
- if [ "${NACL_ARCH}" = "pnacl" ]; then
- local minigzip_pexe="minigzip${NACL_EXEEXT}"
- local example_pexe="example${NACL_EXEEXT}"
- local minigzip_script="minigzip"
- local example_script="example"
- TranslateAndWriteSelLdrScript ${minigzip_pexe} x86-32 \
- minigzip.x86-32.nexe ${minigzip_script}
- RunMinigzip
- TranslateAndWriteSelLdrScript ${minigzip_pexe} x86-64 \
- minigzip.x86-64.nexe ${minigzip_script}
- RunMinigzip
- TranslateAndWriteSelLdrScript ${example_pexe} x86-32 \
- example.x86-32.nexe ${example_script}
- RunExample
- TranslateAndWriteSelLdrScript ${example_pexe} x86-64 \
- example.x86-64.nexe ${example_script}
- RunExample
- else
- RunMinigzip
- RunExample
- fi
-}
diff --git a/packaging/nacl/ports/zlib/nacl.patch b/packaging/nacl/ports/zlib/nacl.patch
deleted file mode 100644
index 176552330..000000000
--- a/packaging/nacl/ports/zlib/nacl.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-diff --git a/configure b/configure
-index b77a8a8..e52609f 100755
---- a/configure
-+++ b/configure
-@@ -188,6 +188,12 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
- *BSD | *bsd* | DragonFly)
- LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"}
- LDCONFIG="ldconfig -m" ;;
-+ pnacl)
-+ LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"}
-+ EXE='.pexe' ;;
-+ nacl)
-+ LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"}
-+ EXE='.nexe' ;;
- CYGWIN* | Cygwin* | cygwin* | OS/2*)
- EXE='.exe' ;;
- MINGW* | mingw*)
diff --git a/packaging/nacl/ports/zlib/pkg_info b/packaging/nacl/ports/zlib/pkg_info
deleted file mode 100644
index 22f1701e5..000000000
--- a/packaging/nacl/ports/zlib/pkg_info
+++ /dev/null
@@ -1,5 +0,0 @@
-NAME=zlib
-VERSION=1.2.8
-URL=http://www.zlib.net/zlib-1.2.8.tar.gz
-LICENSE=CUSTOM:README
-SHA1=a4d316c404ff54ca545ea71a27af7dbc29817088