Initial emscripten SDL2 integration. It compiles. Hope it works

This commit is contained in:
Jonathan Campbell
2018-09-14 16:10:08 -07:00
parent 63a35160a4
commit 73977da7e8
5 changed files with 79 additions and 31 deletions

20
build-emscripten-sdl2 Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
# make sure you use ". ./emsdk_set_env.sh"
# I'm sick and tired of all the churn the three versions of autoconf
# are causing in this repo. Stop committing the configure scripts
# and just autoregen.
./autogen.sh || exit 1
echo Compiling DOSBox-X
chmod +x configure
# for sdl2-config and sdl-config
export PATH=/opt/emsdk/emscripten/incoming/system/bin:$PATH
# build command borrowed from Yksoft1 vanilla DOSBox-X port with modifications
CC="emcc" CXX="em++" LD="emcc" LD_CXX="em++" CFLAGS="-DEMTERPRETER_SYNC" CXXFLAGS="-DEMSCRIPTEN=1 -DEMTERPRETER_SYNC" ./configure --host=x86_64-linux --disable-dynamic-x86 --enable-sdl2 --with-sdl-prefix=/opt/emsdk/emscripten/incoming/system --disable-opengl --disable-mt32 --enable-emscripten
make -j3 || exit 1
#emcc -O1 -s USE_SDL=2 -s TOTAL_MEMORY=104857600 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s EMTERPRETIFY_WHITELIST=@d3.txt dosbox-x.bc --memory-init-file 0 -o th5e.html --preload-file d:/tmpp/th5x@/

View File

@@ -156,6 +156,10 @@ dnl This is how the build script can specify a HX DOS extender target
AH_TEMPLATE(C_HX_DOS,[Define to 1 to target HX DOS])
AC_ARG_ENABLE(hx-dos,AC_HELP_STRING([--enable-hx-dos],[Enable HX target]),enable_hx=yes)
dnl Let me know if you're targeting Emscripten
AH_TEMPLATE(C_EMSCRIPTEN,[Define to 1 to target Emscripten])
AC_ARG_ENABLE(emscripten,AC_HELP_STRING([--enable-emscripten],[Enable Emscripten target]),enable_emscripten=$enableval,enable_emscripten=no)
dnl Optimize for speed by default
AC_ARG_ENABLE(optimize,AC_HELP_STRING([--disable-optimize],[Don't enable compiler optimizations]))
@@ -168,6 +172,10 @@ if test x$enable_optimize != xno; then
CXXFLAGS="$CXXFLAGS -O2"
fi
if test x$enable_emscripten == xyes; then
AC_DEFINE(C_EMSCRIPTEN,1,[Targeting Emscripten])
fi
dnl Some stuff for the icon.
case "$host" in
*-*-cygwin* | *-*-mingw32*)
@@ -274,13 +282,17 @@ case "$host" in
;;
esac
dnl Some default CPU flags
case "$host_cpu" in
x86_64 | amd64)
# SSE is part of the x86_64 ABI
CXXFLAGS="$CXXFLAGS -msse"
;;
esac
if test x$enable_emscripten == xyes; then
CXXFLAGS="$CXXFLAGS"
else
dnl Some default CPU flags
case "$host_cpu" in
x86_64 | amd64)
# SSE is part of the x86_64 ABI
CXXFLAGS="$CXXFLAGS -msse"
;;
esac
fi
dnl Some needed libaries for OS2
dnl perharps join this with the other target depended checks. move them upwards
@@ -331,6 +343,7 @@ esac
AM_CONDITIONAL(HAVE_WINDRES, test "x$WINDRES" != "x:")
AC_SUBST(WINDRES)
if test x$enable_emscripten != xyes; then
dnl Some target detection and actions for them
case "$host" in
*-*-cygwin* | *-*-mingw32*)
@@ -370,6 +383,7 @@ case "$host" in
AC_DEFINE(OS2, 1, [Compiling on OS/2 EMX])
;;
esac
fi
AM_CONDITIONAL(MACOSX, test x"$macosx" == x"1")
@@ -475,9 +489,11 @@ dnl LIBRARY TEST: SDLnet 1.x
AC_CHECK_HEADER(SDL_net.h,have_sdl_net_h=yes,)
AC_CHECK_LIB(SDL_net, SDLNet_Init, have_sdl_net_lib=yes, , )
dnl LIBRARY TEST: X11 Xlib support
AC_CHECK_LIB(X11, main, have_x11_lib=yes, have_x11_lib=no, )
AC_CHECK_HEADER(X11/XKBlib.h, have_x11_h=yes, have_x11_h=no, )
if test x$enable_emscripten != xyes; then
dnl LIBRARY TEST: X11 Xlib support
AC_CHECK_LIB(X11, main, have_x11_lib=yes, have_x11_lib=no, )
AC_CHECK_HEADER(X11/XKBlib.h, have_x11_h=yes, have_x11_h=no, )
fi
dnl LIBRARY TEST: Fluidsynth support
AC_CHECK_HEADER(fluidsynth.h,have_fluidsynth_h=yes,)
@@ -686,26 +702,30 @@ else
AC_MSG_WARN([Can't find libpcap, NE2000 ethernet passthrough disabled])
fi
dnl FEATURE: Whether to use X11 XKBlib
AH_TEMPLATE(C_X11_XKB,[define to 1 if you have XKBlib.h and X11 lib])
AC_MSG_CHECKING(for XKBlib support)
if test x$have_x11_lib = xyes -a x$have_x11_h = xyes ; then
LIBS="$LIBS -lX11 -lxkbfile"
AC_DEFINE(C_X11_XKB,1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
if test x$enable_emscripten != xyes; then
dnl FEATURE: Whether to use X11 XKBlib
AH_TEMPLATE(C_X11_XKB,[define to 1 if you have XKBlib.h and X11 lib])
AC_MSG_CHECKING(for XKBlib support)
if test x$have_x11_lib = xyes -a x$have_x11_h = xyes ; then
LIBS="$LIBS -lX11 -lxkbfile"
AC_DEFINE(C_X11_XKB,1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
dnl FEATURE: Whether to use X11 XRandR
AH_TEMPLATE(C_X11_XRANDR,[define to 1 if you have XRandr.h and X11 lib])
AC_MSG_CHECKING(for XRandR support)
if test x$have_x11_lib = xyes -a x$have_x11_h = xyes ; then
LIBS="$LIBS -lXrandr"
AC_DEFINE(C_X11_XRANDR,1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
if test x$enable_emscripten != xyes; then
dnl FEATURE: Whether to use X11 XRandR
AH_TEMPLATE(C_X11_XRANDR,[define to 1 if you have XRandr.h and X11 lib])
AC_MSG_CHECKING(for XRandR support)
if test x$have_x11_lib = xyes -a x$have_x11_h = xyes ; then
LIBS="$LIBS -lXrandr"
AC_DEFINE(C_X11_XRANDR,1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
dnl FEATURE: Whether to use Fluidsynth

View File

@@ -1,6 +1,11 @@
/* Emscripten does not have endian.h */
# if defined(EMSCRIPTEN)
# include <endian.h>
/* MinGW implements some MSVC idioms, so always test for MinGW first. */
#if defined(__MINGW32__)
# elif defined(__MINGW32__)
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__

View File

@@ -31,6 +31,9 @@
#ifdef WIN32
# define BYTESEX_LITTLE
# define _G_DIR_SEPARATOR '\\'
#elif defined(EMSCRIPTEN)
# define BYTESEX_LITTLE
# define _G_DIR_SEPARATOR '/'
#else
# include "byteorder.h"
# define _G_DIR_SEPARATOR '/'

View File

@@ -104,7 +104,7 @@ bool sse2_available = false;
void CheckSSESupport()
{
#if defined (__GNUC__) || (_MSC_VER)
#if (defined (__GNUC__) || (_MSC_VER)) && !defined(EMSCRIPTEN)
Bitu a, b, c, d;
cpuid(1, a, b, c, d);
sse2_available = ((d >> 26) & 1)?true:false;
@@ -905,7 +905,7 @@ void DOSBOX_SetupConfigSections(void) {
0
};
#if defined(__SSE__) && !defined(_M_AMD64)
#if defined(__SSE__) && !defined(_M_AMD64) && !defined(EMSCRIPTEN)
CheckSSESupport();
#endif
SDLNetInited = false;