[SDL] Try to configure - compile the test.

T. Joseph Carter tjcarter at spiritsubstance.com
Wed Oct 9 09:54:48 PDT 2013


Gabriel,

I just made a patch that does the same kind of thing.  Well, it does 
that and a few other things.  I'd suggest that it might be a better 
fix.  I've resolved the conflict and attached the result.  Lemme know 
what you think.

Works on Ubuntu and doesn't break anything new on my Mac.  I say 
doesn't break anything _new_ because a few things are quite broken on 
the mac in the past 24-36 hours.

Joseph


On Wed, Oct 09, 2013 at 11:35:47AM -0300, Gabriel Jacobo wrote:
>This should fix the GL and GLES problems in tests:
>http://hg.libsdl.org/SDL/rev/7995e0920bf9
>
>One caveat though...if you are using Linux with Nvidia binaries testgles
>won't work out of the box...
>
>The compile command for it will be something like:
>
>gcc -o testgles ../testgles.c -g -O2 -D_REENTRANT -I/usr/local/include/SDL2
>  -DHAVE_OPENGLES -DHAVE_OPENGL -Wl,-rpath,/usr/local/lib -L/usr/local/lib
>-lSDL2 -lpthread   -lSDL2_test  -lGLESv1_CM -lm
>
>However, Nvidia is not providing libGLESv1_CM.so, Mesa is, and they are
>incompatible...so while it will appear that everything is fine, what you
>actually want for this to work is something like:
>
>gcc -o testgles ../testgles.c -g -O2 -D_REENTRANT -I/usr/local/include/SDL2
>  -DHAVE_OPENGLES -DHAVE_OPENGL -Wl,-rpath,/usr/local/lib -L/usr/local/lib
>-lSDL2 -lpthread   -lSDL2_test -L/usr/lib/nvidia-313-updates  -lGL -lm
>
>And before you come complaining about this, I think Linus Torvalds said it
>best...(NSFW)
>http://www.geekosystem.com/wp-content/uploads/2012/06/v40g6.gif
>
>
>
>2013/10/8 T. Joseph Carter <tjcarter at spiritsubstance.com>
>
>> On Tue, Oct 08, 2013 at 07:29:18PM +0200, Loïc Maury wrote:
>>
>>> adding a couple of debug echo statements at this point to the standard
>>>> configure.in to see what configure thinks those values are?  If they're
>>>> not what they should be, that'd be useful to know.
>>>>
>>>
>>> I have added at the end of if test x$have_x, and just before
>>> dnl Check for OpenGL,
>>>
>>> echo "$ac_x_includes and $ac_x_libraries", values are empty, so the
>>> AC_PATH_X doesn't work for me ?
>>>
>>
>> More variables to test in about the same spot:
>>
>> $have_x
>> $x_includes
>> $x_libraries
>>
>> I notice that the main configure.in uses those, not $ac_x_includes …
>>
>>
>>  Otherwise, let's continue:
>>>>
>>>> Default to we don't have OpenGL
>>>> If we can compile #include "SDL_opengl.h", we DO have OpenGL
>>>>
>>>
>>> for me, it seem that the :
>>> AC_TRY_COMPILE([
>>> #include "SDL_opengl.h"
>>> ],[
>>> ],[
>>> have_opengl=yes
>>> ])
>>>
>>> doesn't work
>>> in fact at last I have opengl/opengles = no
>>> maybe because the AC_PATH_X path before.
>>>
>>
>> Possibly.  The no input files error is bugging me.  Usually you get that
>> when gcc is misconfigured or not installed in the right spot on mingw or
>> something.  Well, one bug at a time.
>>
>> Let's leave this here in case someone is looking at this message without
>> context and wants to try and interpret it:
>>
>>  Here what I have in config.log :
>>>
>>> configure:3594: checking for X
>>> configure:3702: gcc -E  conftest.c
>>> configure:3702: $? = 0
>>> configure:3733: gcc -o conftest -g -O2 -I/usr/local/include/SDL2
>>> -D_REENTRANT   conftest.c -lX11   -L/usr/local/lib
>>> -Wl,-rpath,/usr/local/lib -lSDL2 -lpthread -lSDL2_test >&5
>>> configure:3733: $? = 0
>>> configure:3783: result: libraries , headers
>>> configure:3805: checking for OpenGL support
>>> configure:3822: gcc -c -g -O2 -I/usr/local/include/SDL2 -D_REENTRANT -I
>>> conftest.c >&5
>>> gcc: fatal error: no input files
>>> compilation terminated.
>>> configure:3822: $? = 4
>>> configure: failed program was:
>>> | /* confdefs.h */
>>> | #define PACKAGE_NAME ""
>>> | #define PACKAGE_TARNAME ""
>>> | #define PACKAGE_VERSION ""
>>> | #define PACKAGE_STRING ""
>>> | #define PACKAGE_BUGREPORT ""
>>> | #define PACKAGE_URL ""
>>> | /* end confdefs.h.  */
>>> |
>>> |  #include "SDL_opengl.h"
>>> |
>>> | int
>>> | main ()
>>> | {
>>> |
>>> |
>>> |   ;
>>> |   return 0;
>>> | }
>>> configure:3828: result: no
>>> configure:3831: checking for OpenGL ES support
>>> configure:3852: gcc -c -g -O2 -I/usr/local/include/SDL2 -D_REENTRANT -I
>>> conftest.c >&5
>>> gcc: fatal error: no input files
>>> compilation terminated.
>>> configure:3852: $? = 4
>>> configure: failed program was:
>>> | /* confdefs.h */
>>> | #define PACKAGE_NAME ""
>>> | #define PACKAGE_TARNAME ""
>>> | #define PACKAGE_VERSION ""
>>> | #define PACKAGE_STRING ""
>>> | #define PACKAGE_BUGREPORT ""
>>> | #define PACKAGE_URL ""
>>> | /* end confdefs.h.  */
>>> |
>>> |  #if defined (__IPHONEOS__)
>>> |     #include <OpenGLES/ES1/gl.h>
>>> |  #else
>>> |     #include <GLES/gl.h>
>>> |  #endif /* __QNXNTO__ */
>>> |
>>> | int
>>> | main ()
>>> | {
>>> |
>>> |
>>> |   ;
>>> |   return 0;
>>> | }
>>> configure:3858: result: no
>>>
>>> For the path, I don't modified something, it was installed here at the
>>> package install step.
>>>
>>> Sorry if I forgive to give more informations, I'am not a specialist
>>> with autotools:)
>>>
>>> Thank you for your help and time
>>>
>>
>> I'm happy to help.  I'd be a lot happier if I actually WAS some help…
>>  It's been a freakin' decade since I dealt with autocrap.  I really did not
>> miss it.  :D
>>
>> But it needs fixing, and fixing it is relevant to my interests, which
>> involve nice, crunchy pi…
>>
>> Joseph
>>
>> ______________________________**_________________
>> SDL mailing list
>> SDL at lists.libsdl.org
>> http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
>>
>
>
>
>-- 
>Gabriel.

>_______________________________________________
>SDL mailing list
>SDL at lists.libsdl.org
>http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
diff -r b8d4be87970a test/Makefile.in
--- a/test/Makefile.in	Mon Oct 07 14:16:38 2013 -0700
+++ b/test/Makefile.in	Wed Oct 09 09:32:00 2013 -0700
@@ -121,10 +121,10 @@
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
  
 testgl2$(EXE): $(srcdir)/testgl2.c
-	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
+	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIBS@ @MATHLIB@
 
 testgles$(EXE): $(srcdir)/testgles.c
-	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
+	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLES1LIBS@ @MATHLIB@
 
 testhaptic$(EXE): $(srcdir)/testhaptic.c
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
@@ -194,7 +194,7 @@
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
 
 testshader$(EXE): $(srcdir)/testshader.c
-	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
+	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIBS@ @MATHLIB@
 
 testshape$(EXE): $(srcdir)/testshape.c
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
diff -r b8d4be87970a test/configure
--- a/test/configure	Mon Oct 07 14:16:38 2013 -0700
+++ b/test/configure	Wed Oct 09 09:32:00 2013 -0700
@@ -586,7 +586,8 @@
 LIBOBJS
 SDL_TTF_LIB
 XLIB
-GLLIB
+GLESLIBS
+GLLIBS
 CPP
 XMKMF
 SDL_CONFIG
@@ -3451,7 +3452,7 @@
   rm -f conf.sdltest
 
 CFLAGS="$CFLAGS $SDL_CFLAGS"
-LIBS="$LIBS $SDL_LIBS -lSDL2_test"
+LIBS="$LIBS  $SDL_LIBS -lSDL2_test"
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -3785,25 +3786,29 @@
 fi
 
 if test x$have_x = xyes; then
-    if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone; then
-        :
-    else
-        CFLAGS="$CFLAGS -I$ac_x_includes"
-    fi
-    if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
-        :
-    else
-        XPATH="-L$ac_x_libraries"
-        if test "x$ac_x_libraries" = x; then
+    case "x$ac_x_includes" in
+        "x"|"xno"|"xNone")
+            ;;
+        *)
+            CFLAGS="$CFLAGS -I$ac_x_includes"
+            ;;
+    esac
+
+    case "x$ac_x_libraries" in
+        "x"|"xno"|"xNone")
+            XPATH=""
             XLIB="-lX11"
-        else
-            XLIB="-L$ac_x_libraries -lX11"
-        fi
-    fi
+            ;;
+        *)
+            XPATH="-L$ac_x_libraries"
+            XLIB="-L$ac_x_libraries $XLIB"
+            ;;
+    esac
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL support" >&5
 $as_echo_n "checking for OpenGL support... " >&6; }
+GLLIBS=""
 have_opengl=no
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -3822,14 +3827,16 @@
 if ac_fn_c_try_compile "$LINENO"; then :
 
 have_opengl=yes
+CFLAGS="$CFLAGS -DHAVE_OPENGL"
+GLLIBS="$XPATH $SYS_GL_LIBS"
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengl" >&5
 $as_echo "$have_opengl" >&6; }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES support" >&5
-$as_echo_n "checking for OpenGL ES support... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 support" >&5
+$as_echo_n "checking for OpenGL ES v1 support... " >&6; }
 have_opengles=no
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -3852,22 +3859,14 @@
 if ac_fn_c_try_compile "$LINENO"; then :
 
 have_opengles=yes
+CFLAGS="$CFLAGS -DHAVE_OPENGLES"
+GLES1LIBS="$XPATH -lGLESv1_CM"
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengles" >&5
 $as_echo "$have_opengles" >&6; }
 
-GLLIB=""
-if test x$have_opengles = xyes; then
-    CFLAGS="$CFLAGS -DHAVE_OPENGLES"
-    GLLIB="$XPATH -lGLESv1_CM"
-elif test x$have_opengl = xyes; then
-    CFLAGS="$CFLAGS -DHAVE_OPENGL"
-    GLLIB="$XPATH $SYS_GL_LIBS"
-else
-    GLLIB=""
-fi
 
 
 
diff -r b8d4be87970a test/configure.in
--- a/test/configure.in	Mon Oct 07 14:16:38 2013 -0700
+++ b/test/configure.in	Wed Oct 09 09:32:00 2013 -0700
@@ -91,36 +91,42 @@
 dnl Check for X11 path, needed for OpenGL on some systems
 AC_PATH_X
 if test x$have_x = xyes; then
-    if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone; then
-        :
-    else
-        CFLAGS="$CFLAGS -I$ac_x_includes"
-    fi
-    if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
-        :
-    else
-        XPATH="-L$ac_x_libraries"
-        if test "x$ac_x_libraries" = x; then
+    case "x$ac_x_includes" in
+        "x"|"xno"|"xNone")
+            ;;
+        *)
+            CFLAGS="$CFLAGS -I$ac_x_includes"
+            ;;
+    esac
+
+    case "x$ac_x_libraries" in
+        "x"|"xno"|"xNone")
+            XPATH=""
             XLIB="-lX11"
-        else
-            XLIB="-L$ac_x_libraries -lX11"
-        fi
-    fi
+            ;;
+        *)
+            XPATH="-L$ac_x_libraries"
+            XLIB="-L$ac_x_libraries $XLIB"
+            ;;
+    esac
 fi
 
 dnl Check for OpenGL
 AC_MSG_CHECKING(for OpenGL support)
+GLLIBS=""
 have_opengl=no
 AC_TRY_COMPILE([
  #include "SDL_opengl.h"
 ],[
 ],[
 have_opengl=yes
+CFLAGS="$CFLAGS -DHAVE_OPENGL"
+GLLIBS="$XPATH $SYS_GL_LIBS"
 ])
 AC_MSG_RESULT($have_opengl)
 
-dnl Check for OpenGL ES
-AC_MSG_CHECKING(for OpenGL ES support)
+dnl Check for OpenGL ES v1
+AC_MSG_CHECKING(for OpenGL ES v1 support)
 have_opengles=no
 AC_TRY_COMPILE([
  #if defined (__IPHONEOS__)
@@ -131,21 +137,13 @@
 ],[
 ],[
 have_opengles=yes
+CFLAGS="$CFLAGS -DHAVE_OPENGLES"
+GLES1LIBS="$XPATH -lGLESv1_CM"
 ])
 AC_MSG_RESULT($have_opengles)
 
-GLLIB=""
-if test x$have_opengles = xyes; then
-    CFLAGS="$CFLAGS -DHAVE_OPENGLES"
-    GLLIB="$XPATH -lGLESv1_CM"
-elif test x$have_opengl = xyes; then
-    CFLAGS="$CFLAGS -DHAVE_OPENGL"
-    GLLIB="$XPATH $SYS_GL_LIBS"
-else
-    GLLIB=""
-fi
-
-AC_SUBST(GLLIB)
+AC_SUBST(GLLIBS)
+AC_SUBST(GLESLIBS)
 AC_SUBST(XLIB)
 
 dnl Check for SDL_ttf


More information about the SDL mailing list