Hi,

I've been playing with cross-compiling the SDL backend using the MinGW
compiler and the binaries from Tor Lillqvist. It almost works out of
the box apart from a few issues which I thought I would share:

- The DATADIR macro conflicts with some obscure define in the Windows
  headers so it won't compile. As far as I can tell it's not actually
  used anywhere in Clutter yet so I've renamed it to CLUTTER_DATADIR.

- The configure script chokes when trying to find libGL because it's
  called opengl32 on Windows and it should probably use libGLee
  anyway. I've changed the tests for Windows builds.

- In pangoclutter-render.c there is a bare call to malloc. This gets
  redefined to rpl_malloc because configure.ac contains the
  AC_FUNC_MALLOC test and the MSVC malloc isn't GNU
  compatible. However, the rpl_malloc function isn't defined anywhere
  so it fails to link when compiling test-text. I've just replaced the
  call with g_malloc because the return value isn't checked anyway so
  it doesn't look right. But I guess ideally unless I've misunderstood
  something, either the AC_FUNC_MALLOC macro should be taken out or
  the rpl_malloc function should be defined somewhere.

- The GLee header is included as <GL/Glee.h> but in the GLee zip file
  it is actually <GL/GLee.h> so it won't compile on case-sensitive
  OSs.

I've attached a patch to work around these issues.

Regards,
- Neil
Index: clutter/pango/pangoclutter-render.c
===================================================================
--- clutter/pango/pangoclutter-render.c (revision 1771)
+++ clutter/pango/pangoclutter-render.c (working copy)
@@ -221,7 +221,7 @@
       size = (size + 4095) & ~4095;
       free (buffer);
       alloc = size;
-      buffer = malloc (size);
+      buffer = g_malloc (size);
     }
 
   return buffer;
Index: clutter/cogl/gl/cogl-defines.h.in
===================================================================
--- clutter/cogl/gl/cogl-defines.h.in   (revision 1771)
+++ clutter/cogl/gl/cogl-defines.h.in   (working copy)
@@ -29,7 +29,7 @@
 #ifdef WIN32
 
 #include <windows.h>
-#include <GL/Glee.h>
+#include <GL/GLee.h>
 
 #else
 
Index: clutter/Makefile.am
===================================================================
--- clutter/Makefile.am (revision 1771)
+++ clutter/Makefile.am (working copy)
@@ -18,9 +18,9 @@
        -I$(top_srcdir)/clutter/cogl            \
        -I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
        -I$(top_srcdir)/clutter/json            \
-       -DPREFIX=\""$(prefix)"\"                \
-       -DLIBDIR=\""$(libdir)"\"                \
-       -DDATADIR=\""$(datadir)"\"              \
+       -DCLUTTER_PREFIX=\""$(prefix)"\"        \
+       -DCLUTTER_LIBDIR=\""$(libdir)"\"        \
+       -DCLUTTER_DATADIR=\""$(datadir)"\"      \
        -DG_DISABLE_DEPRECATED                  \
        -DG_LOG_DOMAIN=\"Clutter\"              \
        -DCLUTTER_JSON_API=1                    \
Index: configure.ac
===================================================================
--- configure.ac        (revision 1771)
+++ configure.ac        (working copy)
@@ -148,14 +148,32 @@
 
        AC_CHECK_HEADERS([$clutter_gl_header],,
                         [AC_MSG_ERROR([Unable to locate required GL headers])])
-       
-       AC_CHECK_LIB(GL, glEnable, HAVE_LIBGL=yes, HAVE_LIBGL=no)
-       if test "x$HAVE_LIBGL" = "xno"; then
-         AC_MSG_ERROR([libGL not found]);
-       fi
-       
-       SDL_LIBS="$SDL_LIBS -lGL"
-     fi
+
+
+       dnl Use GLee under Windows instead of GL
+       case "$host" in
+         *mingw32*)
+           AC_CHECK_LIB(GLee, GLeeInit, HAVE_LIBGLEE=yes, HAVE_LIBGLEE=no, 
-lopengl32)
+          if test "x$HAVE_LIBGLEE" = "xno"; then
+            AC_MSG_ERROR([libGLee not found]);
+          fi
+
+          dnl We should probably check for -lopengl32 as well, but
+          dnl it's difficult to do with autoconf because it needs to
+          dnl be defined as __stdcall otherwise it won't know the
+          dnl symbol has @4 tacked on the end
+
+           SDL_LIBS="$SDL_LIBS -lGLee -lopengl32"
+           ;;
+         *)
+          AC_CHECK_LIB(GL, glEnable, HAVE_LIBGL=yes, HAVE_LIBGL=no)
+          if test "x$HAVE_LIBGL" = "xno"; then
+            AC_MSG_ERROR([libGL not found]);
+          fi
+           SDL_LIBS="$SDL_LIBS -lGL"
+           ;;
+       esac
+    fi
     ;;
 
   glx)

Reply via email to