SDL-1.2: initial attempt at adding os2 support to autotools

From f132e7163e5370f05fc71bf488c1bfcf6df0c12c Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 15 Dec 2021 17:55:10 +0300
Subject: [PATCH] initial attempt at adding os2 support to autotools

invented 'LT_EXTRA' for -os2dllname libtool option
---
 Makefile.in       |   3 +-
 configure         | 168 ++++++++++++++++++++++++++++++++++++++++------
 configure.ac      | 101 +++++++++++++++++++++++++++-
 test/configure    |   9 ++-
 test/configure.ac |   9 ++-
 5 files changed, 263 insertions(+), 27 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 824ae12cb..c55180f66 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -50,7 +50,8 @@ LT_AGE      = @LT_AGE@
 LT_CURRENT  = @LT_CURRENT@
 LT_RELEASE  = @LT_RELEASE@
 LT_REVISION = @LT_REVISION@
-LT_LDFLAGS  = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+LT_EXTRA    = @LT_EXTRA@
+LT_LDFLAGS  = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) $(LT_EXTRA)
 
 all: $(srcdir)/configure Makefile $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET)
 
diff --git a/configure b/configure
index e0731550c..deb44437d 100755
--- a/configure
+++ b/configure
@@ -823,6 +823,7 @@ CXXCPP
 ac_ct_CXX
 CXXFLAGS
 CXX
+LT_EXTRA
 LT_AGE
 LT_REVISION
 LT_CURRENT
@@ -998,6 +999,7 @@ enable_pth
 enable_pthreads
 enable_pthread_sem
 enable_stdio_redirect
+enable_video_fslib
 enable_directx
 enable_gapi
 enable_sdl_dlopen
@@ -1732,6 +1734,7 @@ Optional Features:
   --enable-pthreads       use POSIX threads for multi-threading [default=yes]
   --enable-pthread-sem    use pthread semaphores [default=yes]
   --enable-stdio-redirect Redirect STDIO to files on Win32 [default=yes]
+  --enable-video-fslib    use the old OS/2 FSLib video driver [default=no]
   --enable-directx        use DirectX for Win32 audio/video [default=yes]
   --enable-gapi           use GAPI for WinCE video [default=no]
   --enable-sdl-dlopen     use dlopen for shared object loading [default=yes]
@@ -4279,7 +4282,6 @@ SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
 
 
 
-# libtool versioning
 case `pwd` in
   *\ * | *\	*)
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
@@ -4830,13 +4832,13 @@ if ${lt_cv_nm_interface+:} false; then :
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:4833: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:4835: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4836: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:4838: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4839: output\"" >&5)
+  (eval echo "\"\$as_me:4841: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6049,7 +6051,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6052 "configure"' > conftest.$ac_ext
+  echo '#line 6054 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7607,11 +7609,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7610: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7612: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7614: \$? = $ac_status" >&5
+   echo "$as_me:7616: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7956,11 +7958,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7959: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7961: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7963: \$? = $ac_status" >&5
+   echo "$as_me:7965: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8061,11 +8063,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8064: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8066: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8068: \$? = $ac_status" >&5
+   echo "$as_me:8070: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8116,11 +8118,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8119: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8121: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8123: \$? = $ac_status" >&5
+   echo "$as_me:8125: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -10559,7 +10561,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10562 "configure"
+#line 10564 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10655,7 +10657,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10658 "configure"
+#line 10660 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10887,6 +10889,7 @@ LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
 LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
 LT_REVISION=$SDL_INTERFACE_AGE
 LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
+LT_EXTRA=""
 
 
 
@@ -14103,11 +14106,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14106: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14109: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:14110: \$? = $ac_status" >&5
+   echo "$as_me:14113: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -14202,11 +14205,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14205: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14208: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14209: \$? = $ac_status" >&5
+   echo "$as_me:14212: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -14254,11 +14257,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14257: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14260: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14261: \$? = $ac_status" >&5
+   echo "$as_me:14264: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -15566,6 +15569,15 @@ case "$host" in
         BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
         BASE_LDFLAGS="-mno-cygwin"
         ;;
+    *-*-os2*)
+        # disable static builds on os/2
+        enable_static=no
+        # -DBUILD_SDL is needed for DECLSPEC
+        BASE_CFLAGS="-DBUILD_SDL"
+        BASE_LDFLAGS=""
+        # SDL-1.2 has been built as SDL12.dll
+        LT_EXTRA="-os2dllname SDL12"
+        ;;
     *)
         BASE_CFLAGS="-D_GNU_SOURCE=1"
         BASE_LDFLAGS=""
@@ -18080,6 +18092,9 @@ $as_echo "$CompileNASM_ret" >&6; }
               macosx)
                   NASMFLAGS="-f macho"
                   ;;
+              os2)
+                  NASMFLAGS="-f aout"
+                  ;;
               *)
                   NASMFLAGS="-f elf32"
                   ;;
@@ -21397,6 +21412,43 @@ fi
     fi
 }
 
+CheckOS2()
+{
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking OS/2 compiler" >&5
+$as_echo_n "checking OS/2 compiler... " >&6; }
+    have_os2_gcc=no
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <os2.h>
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  have_os2_gcc=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_os2_gcc" >&5
+$as_echo "$have_os2_gcc" >&6; }
+    if test x$have_os2_gcc != xyes; then
+       as_fn_error $? "
+*** Your compiler ($CC) does not produce OS/2 executables!
+       " "$LINENO" 5
+    fi
+
+    # Check whether --enable-video-fslib was given.
+if test "${enable_video_fslib+set}" = set; then :
+  enableval=$enable_video_fslib;
+else
+  enable_video_fslib=no
+fi
+
+}
+
 CheckDIRECTX()
 {
     # Check whether --enable-directx was given.
@@ -22640,6 +22692,80 @@ 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 -I$srcdir/os2/h"
+        CheckOS2
+        CheckNASM
+        CheckDummyVideo
+        CheckDiskAudio
+        CheckDummyAudio
+
+        # Set up files for the video library
+        if test x$enable_video = xyes; then
+            $as_echo "#define SDL_VIDEO_DRIVER_OS2GROP 1" >>confdefs.h
+
+            SOURCES="$SOURCES $srcdir/src/video/os2grop/*.c"
+            have_video=yes
+            if test x$enable_video_fslib = xyes; then
+                $as_echo "#define SDL_VIDEO_DRIVER_OS2FS 1" >>confdefs.h
+
+                SOURCES="$SOURCES $srcdir/src/video/os2fslib/*.c"
+            fi
+        fi
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            $as_echo "#define SDL_AUDIO_DRIVER_DART 1" >>confdefs.h
+
+            SOURCES="$SOURCES $srcdir/src/audio/dart/*.c"
+            have_audio=yes
+            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmmpm2"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            $as_echo "#define SDL_CDROM_OS2 1" >>confdefs.h
+
+            SOURCES="$SOURCES $srcdir/src/cdrom/os2/*.c"
+            have_cdrom=yes
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            $as_echo "#define SDL_THREAD_OS2 1" >>confdefs.h
+
+            SOURCES="$SOURCES $srcdir/src/thread/os2/*.c"
+            have_threads=yes
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            $as_echo "#define SDL_TIMER_OS2 1" >>confdefs.h
+
+            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
+            $as_echo "#define SDL_LOADSO_OS2 1" >>confdefs.h
+
+            SOURCES="$SOURCES $srcdir/src/loadso/os2/*.c"
+            have_loadso=yes
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            $as_echo "#define SDL_JOYSTICK_OS2 1" >>confdefs.h
+
+            SOURCES="$SOURCES $srcdir/src/joystick/os2/*.c"
+            have_joystick=yes
+        fi
+        ;;
     *)
         as_fn_error $? "
 *** Unsupported host:  Please add to configure.ac
diff --git a/configure.ac b/configure.ac
index 13367b268..5197de7b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,19 +30,21 @@ AC_SUBST(SDL_INTERFACE_AGE)
 AC_SUBST(SDL_BINARY_AGE)
 AC_SUBST(SDL_VERSION)
 
-# libtool versioning
+dnl libtool versioning
 LT_INIT([win32-dll])
 
 LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
 LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
 LT_REVISION=$SDL_INTERFACE_AGE
 LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
+LT_EXTRA="" dnl for OS2 dll name
 m4_pattern_allow([^LT_])
 
 AC_SUBST(LT_RELEASE)
 AC_SUBST(LT_CURRENT)
 AC_SUBST(LT_REVISION)
 AC_SUBST(LT_AGE)
+AC_SUBST(LT_EXTRA)
 
 dnl Detect the canonical build and host environments
 dnl AC_CANONICAL_HOST
@@ -77,6 +79,15 @@ case "$host" in
         BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
         BASE_LDFLAGS="-mno-cygwin"
         ;;
+    *-*-os2*)
+        # disable static builds on os/2
+        enable_static=no
+        # -DBUILD_SDL is needed for DECLSPEC
+        BASE_CFLAGS="-DBUILD_SDL"
+        BASE_LDFLAGS=""
+        # SDL-1.2 has been built as SDL12.dll
+        LT_EXTRA="-os2dllname SDL12"
+        ;;
     *)
         BASE_CFLAGS="-D_GNU_SOURCE=1"
         BASE_LDFLAGS=""
@@ -757,6 +768,9 @@ CheckNASM()
               macosx)
                   NASMFLAGS="-f macho"
                   ;;
+              os2)
+                  NASMFLAGS="-f aout"
+                  ;;
               *)
                   NASMFLAGS="-f elf32"
                   ;;
@@ -2191,6 +2205,25 @@ CheckWIN32()
     fi
 }
 
+dnl Determine whether the compiler can produce OS/2 executables
+CheckOS2()
+{
+    AC_MSG_CHECKING(OS/2 compiler)
+    have_os2_gcc=no
+    AC_TRY_COMPILE([#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
+
+    AC_ARG_ENABLE(video-fslib,
+[AS_HELP_STRING([--enable-video-fslib], [use the old OS/2 FSLib video driver [default=no]])],
+                 , enable_video_fslib=no)
+}
+
 dnl Find the DirectX includes and libraries
 CheckDIRECTX()
 {
@@ -2963,6 +2996,72 @@ 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 -I$srcdir/os2/h"
+        CheckOS2
+        CheckNASM
+        CheckDummyVideo
+        CheckDiskAudio
+        CheckDummyAudio
+
+        # Set up files for the video library
+        if test x$enable_video = xyes; then
+            AC_DEFINE(SDL_VIDEO_DRIVER_OS2GROP)
+            SOURCES="$SOURCES $srcdir/src/video/os2grop/*.c"
+            have_video=yes
+            if test x$enable_video_fslib = xyes; then
+                AC_DEFINE(SDL_VIDEO_DRIVER_OS2FS)
+                SOURCES="$SOURCES $srcdir/src/video/os2fslib/*.c"
+            fi
+        fi
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AC_DEFINE(SDL_AUDIO_DRIVER_DART)
+            SOURCES="$SOURCES $srcdir/src/audio/dart/*.c"
+            have_audio=yes
+            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmmpm2"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            AC_DEFINE(SDL_CDROM_OS2)
+            SOURCES="$SOURCES $srcdir/src/cdrom/os2/*.c"
+            have_cdrom=yes
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            AC_DEFINE(SDL_THREAD_OS2)
+            SOURCES="$SOURCES $srcdir/src/thread/os2/*.c"
+            have_threads=yes
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            AC_DEFINE(SDL_TIMER_OS2)
+            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)
+            SOURCES="$SOURCES $srcdir/src/loadso/os2/*.c"
+            have_loadso=yes
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            AC_DEFINE(SDL_JOYSTICK_OS2)
+            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/configure b/test/configure
index 46393b21c..f25e6947e 100755
--- a/test/configure
+++ b/test/configure
@@ -2895,7 +2895,7 @@ case "$host" in
         MATHLIB=""
         SYS_GL_LIBS="-lGL"
         ;;
-    *-*-darwin* )
+    *-*-darwin*)
         EXE=""
         MATHLIB=""
         SYS_GL_LIBS="-Wl,-framework,OpenGL"
@@ -2960,11 +2960,16 @@ fi
             SYS_GL_LIBS="-lOSMesa"
         fi
         ;;
-    *-*-riscos* )
+    *-*-riscos*)
         EXE=",e1f"
         MATHLIB=""
         SYS_GL_LIBS=""
         ;;
+    *-*-os2*)
+        EXE=".exe"
+        MATHLIB=""
+        SYS_GL_LIBS=""
+        ;;
     *)
         EXE=""
         MATHLIB="-lm"
diff --git a/test/configure.ac b/test/configure.ac
index a46e55464..19b14bb72 100644
--- a/test/configure.ac
+++ b/test/configure.ac
@@ -24,7 +24,7 @@ case "$host" in
         MATHLIB=""
         SYS_GL_LIBS="-lGL"
         ;;
-    *-*-darwin* )
+    *-*-darwin*)
         EXE=""
         MATHLIB=""
         SYS_GL_LIBS="-Wl,-framework,OpenGL"
@@ -49,11 +49,16 @@ case "$host" in
             SYS_GL_LIBS="-lOSMesa"
         fi
         ;;
-    *-*-riscos* )
+    *-*-riscos*)
         EXE=",e1f"
         MATHLIB=""
         SYS_GL_LIBS=""
         ;;
+    *-*-os2*)
+        EXE=".exe"
+        MATHLIB=""
+        SYS_GL_LIBS=""
+        ;;
     *)
         EXE=""
         MATHLIB="-lm"