Commit efa1aa9a8fe9da03ec4e556e38d95f9fa5c42f2c

Ozkan Sezer 2021-12-01T01:55:56

initial attempt at adding os2 support to autotools

diff --git a/configure.ac b/configure.ac
index 146beb2..b7f0f66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3183,6 +3183,21 @@ CheckWINDOWS()
     CheckStackBoundary
 }
 
+dnl Determine whether the compiler can produce OS/2 executables
+CheckOS2()
+{
+    AC_MSG_CHECKING(OS/2 compiler)
+    have_os2_gcc=no
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <os2.h>]],
+     [])],[have_os2_gcc=yes],[])
+    AC_MSG_RESULT($have_os2_gcc)
+    if test x$have_os2_gcc != xyes; then
+       AC_MSG_ERROR([
+*** Your compiler ($CC) does not produce OS/2 executables!
+       ])
+    fi
+}
+
 dnl Find the DirectX includes and libraries
 CheckDIRECTX()
 {
@@ -4381,6 +4396,78 @@ case "$host" in
             have_timers=yes
         fi
         ;;
+    *-*-os2*)
+        ARCH=os2
+        if test "$build" != "$host"; then # cross-compiling
+            # Default cross-compile location
+            ac_default_prefix=/@unixroot/usr/local/cross-tools/$host
+        else
+            # Look for the location of the tools and install there
+            if test "$BUILD_PREFIX" != ""; then
+                ac_default_prefix=$BUILD_PREFIX
+            fi
+        fi
+        EXTRA_CFLAGS="$EXTRA_CFLAGS -DOS2EMX_PLAIN_CHAR"
+        CheckOS2
+        CheckDeclarationAfterStatement
+        CheckDummyVideo
+        CheckDiskAudio
+        CheckDummyAudio
+
+        # Set up the core platform files
+        SOURCES="$SOURCES $srcdir/src/core/os2/*.c"
+        # FIXME: use system iconv() if available?
+        SOURCES="$SOURCES $srcdir/src/core/os2/geniconv/*.c"
+        # Use the Unix locale APIs.
+        SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
+        have_locale=yes
+        # Set up files for the video library
+        if test x$enable_video = xyes; then
+            AC_DEFINE(SDL_VIDEO_DRIVER_OS2, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/video/os2/*.c"
+            have_video=yes
+            SUMMARY_video="${SUMMARY_video} os/2"
+        fi
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AC_DEFINE(SDL_AUDIO_DRIVER_OS2, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/audio/os2/*.c"
+            have_audio=yes
+            SUMMARY_audio="${SUMMARY_audio} os/2"
+            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmmpm2"
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            AC_DEFINE(SDL_THREAD_OS2, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/thread/os2/*.c"
+            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
+            have_threads=yes
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            AC_DEFINE(SDL_TIMER_OS2, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/timer/os2/*.c"
+            have_timers=yes
+        fi
+        # Set up files for the shared object loading library
+        if test x$enable_loadso = xyes; then
+            AC_DEFINE(SDL_LOADSO_OS2, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/loadso/os2/*.c"
+            have_loadso=yes
+        fi
+        # Set up files for the filesystem library
+        if test x$enable_filesystem = xyes; then
+            AC_DEFINE(SDL_FILESYSTEM_OS2, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/filesystem/os2/*.c"
+            have_filesystem=yes
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            AC_DEFINE(SDL_JOYSTICK_OS2, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/joystick/os2/*.c"
+            have_joystick=yes
+        fi
+        ;;
     *)
         AC_MSG_ERROR([
 *** Unsupported host:  Please add to configure.ac
diff --git a/test/Makefile.in b/test/Makefile.in
index 1e05758..d29dc6e 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -235,14 +235,22 @@ testnative$(EXE): $(srcdir)/testnative.c \
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @XLIB@
 endif
 
+ifeq (@ISOS2@,true)
+testnative$(EXE): $(srcdir)/testnative.c \
+			$(srcdir)/testnativeos2.c
+	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+endif
+
 #there's probably a better way of doing this
 ifeq (@ISMACOSX@,false)
 ifeq (@ISWINDOWS@,false)
 ifeq (@ISUNIX@,false)
+ifeq (@ISOS2@,false)
 testnative$(EXE): ;
 endif
 endif
 endif
+endif
 
 testoverlay2$(EXE): $(srcdir)/testoverlay2.c $(srcdir)/testyuv_cvt.c
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
diff --git a/test/configure.ac b/test/configure.ac
index 2f085d6..694551c 100644
--- a/test/configure.ac
+++ b/test/configure.ac
@@ -18,6 +18,7 @@ dnl  (Haiku, for example, sets none of these.)
 ISUNIX="false"
 ISWINDOWS="false"
 ISMACOSX="false"
+ISOS2="false"
 
 dnl Figure out which math library to use
 case "$host" in
@@ -32,7 +33,7 @@ case "$host" in
         MATHLIB=""
         SYS_GL_LIBS="-lGL"
         ;;
-    *-*-darwin* )
+    *-*-darwin*)
         ISMACOSX="true"
         EXE=""
         MATHLIB=""
@@ -64,17 +65,23 @@ case "$host" in
         MATHLIB=""
         SYS_GL_LIBS="-lGLES_CM"
         ;;
-    *-*-emscripten* )
+    *-*-emscripten*)
         dnl This should really be .js, but we need to specify extra flags when compiling to js
         EXE=".bc"
         MATHLIB=""
         SYS_GL_LIBS=""
         ;;
-    *-*-riscos* )
+    *-*-riscos*)
         EXE=",e1f"
         MATHLIB=""
         SYS_GL_LIBS=""
         ;;
+    *-*-os2*)
+        ISOS2="true"
+        EXE=".exe"
+        MATHLIB=""
+        SYS_GL_LIBS=""
+        ;;
     *)
         dnl Oh well, call it Unix...
         ISUNIX="true"
@@ -90,6 +97,7 @@ AC_SUBST(MATHLIB)
 AC_SUBST(ISMACOSX)
 AC_SUBST(ISWINDOWS)
 AC_SUBST(ISUNIX)
+AC_SUBST(ISOS2)
 
 dnl Check for SDL
 SDL_VERSION=2.0.18