diff configure.in @ 1168:045f186426e1

Dynamically load X11 libraries like we currently do for alsa, esd, etc. This allows you to run an SDL program on a system without Xlib, since it'll just report the x11 target unavailable at runtime.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 05 Nov 2005 19:53:37 +0000
parents 2651158f59b8
children bb1a52a8d3d6
line wrap: on
line diff
--- a/configure.in	Sat Nov 05 17:41:11 2005 +0000
+++ b/configure.in	Sat Nov 05 19:53:37 2005 +0000
@@ -609,11 +609,45 @@
         AC_PATH_X
         AC_PATH_XTRA
         if test x$have_x = xyes; then
-            CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -I$srcdir/include -I$srcdir/src/video"
+            AC_ARG_ENABLE(x11-shared,
+[  --enable-x11-shared     dynamically load X11 support [default=yes]],
+                          , enable_x11_shared=yes)
+
+            dnl !!! FIXME: make this work?
+            dnl x11_lib_spec=`echo $X11_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libX11.so.*/'`
+            dnl x11_lib=`ls $x11_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
+            dnl echo "-- $x11_lib_spec -> $x11_lib"
+            dnl x11ext_lib_spec=`echo $X11EXT_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libXext.so.*/'`
+            dnl x11ext_lib=`ls $x11ext_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
+            dnl echo "-- $x11ext_lib_spec -> $x11ext_lib"
+
+            x11_lib_spec='/usr/X11R6/lib/libX11.so.*'
+            x11_lib='libX11.so.6'
+            echo "-- $x11_lib_spec -> $x11_lib"
+            x11ext_lib_spec='/usr/X11R6/lib/libXext.so.*'
+            x11_lib='libXext.so.6'
+            echo "-- $x11ext_lib_spec -> $x11_lib"
+
+            if test x$use_dlopen != xyes && \
+               test x$enable_x11_shared = xyes; then
+                AC_MSG_ERROR([You must have dlopen() support and use the --enable-dlopen option])
+            fi
+
+            if test x$use_dlopen = xyes && \
+               test x$enable_x11_shared = xyes && test x$x11_lib != x; then
+                CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -DX11_DYNAMIC=\$(x11_lib) -DX11EXT_DYNAMIC=\$(x11ext_lib) -I$srcdir/include -I$srcdir/src/video"
+                SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS"
+                AC_SUBST(x11_lib)
+                AC_SUBST(x11ext_lib)
+            else
+                CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -I$srcdir/include -I$srcdir/src/video"
+                SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
+            fi
+
             if test x$ac_cv_func_shmat != xyes; then
                 CFLAGS="$CFLAGS -DNO_SHARED_MEMORY"
             fi
-            SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
+
             VIDEO_SUBDIRS="$VIDEO_SUBDIRS x11"
             VIDEO_DRIVERS="$VIDEO_DRIVERS x11/libvideo_x11.la"