Dirk Meyer wrote:
[...]
> You can use check_cc, kaa.metadata does this to find libdvdread.

I already did it with dl.open, if it's ugly I'll look into this check_cc
and change it.

>> Please help me with this one, then I think I'll be able to provide a
>> patch for the rest, and I also think it would be benefic for Freevo2
>> if someone can always check if it builds and is usable even without
>> X. 
> 
> That would be great. Maybe move the display code from __init__.py into
> an extra file like we do for fb. Than you can use import with
> try/except to avoid problems with the missing display
> variables...wait, you don't need to, it should work without it.

So here it is, my somehow hackish patch, now ALL kaa modules build on my
X11-less gentoo, provided that evas-0.9.9.023 (I installed CVS and
evas-config reports this version, and gentoo has a live CVS ebuild for
it) was successfully built & installed.

I tried kaa/xine/test/kaaplayer.py and kaa/xine/test/test.py,
unfortunately they both use kaa/xine/test/kaaplayer.py and
kaa/xine/test/kaaplayer.py, so I couldn't actually see kaa.xine at work.
But importing the modules in a python prompt now works. So where to go
from here, in order to see kaa.xine play something xine-lib can handle,
on DirectFB?

Lucian
diff -Naur --exclude=entries kaa/display/setup.py kaa_noX11/display/setup.py
--- kaa/display/setup.py	2006-02-24 00:35:51.000000000 +0100
+++ kaa_noX11/display/setup.py	2006-02-24 00:21:42.000000000 +0100
@@ -34,6 +34,7 @@
 import os
 import sys
 import popen2
+import dl
 
 try:
     # kaa base imports
@@ -42,6 +43,13 @@
     print 'kaa.base not installed'
     sys.exit(1)
 
+have_x11 = 1
+try:
+    dl.open('/usr/lib/libX11.so')
+except dl.error, err:
+    print "System without X11 detected"
+    have_x11 = 0
+
 # the framebuffer so module
 fb = Extension('kaa.display._FBmodule', [ 'src/fb.c'] )
 
@@ -61,12 +69,18 @@
     dfb = None
 
 # the display so module
-display = Extension('kaa.display._Displaymodule',
+if have_x11:
+    display = Extension('kaa.display._Displaymodule',
                     [ 'src/display.c', 'src/sdl.c', 'src/x11display.c',
                       'src/x11window.c', 'src/imlib2.c', 'src/evas.c' ],
                     libraries = ['png', 'rt'],
                     config='src/config.h')
-
+    display.config('#define HAVE_X11')
+else:
+    display = Extension('kaa.display._Displaymodule',
+                    [ 'src/display.c', 'src/sdl.c', 'src/imlib2.c', 'src/evas.c' ],
+                    libraries = ['png', 'rt'],
+                    config='src/config.h')
 
 if display.check_library('imlib2', '1.1.1'):
     display.config('#define USE_IMLIB2')
diff -Naur --exclude=entries kaa/display/src/display.c kaa_noX11/display/src/display.c
--- kaa/display/src/display.c	2006-02-24 00:35:50.000000000 +0100
+++ kaa_noX11/display/src/display.c	2006-02-24 00:31:24.000000000 +0100
@@ -33,8 +33,10 @@
 #include <Python.h>
 #include "config.h"
 #include "display.h"
+#ifdef HAVE_X11
 #include "x11display.h"
 #include "x11window.h"
+#endif
 #include "imlib2.h"
 #include "evas.h"
 #include "sdl.h"
@@ -43,11 +45,13 @@
     { "image_to_surface", (PyCFunction) image_to_surface, METH_VARARGS },
     { "render_imlib2_image", (PyCFunction) render_imlib2_image, METH_VARARGS },
 #ifdef USE_EVAS
+#ifdef HAVE_X11
     { "new_evas_software_x11", (PyCFunction) new_evas_software_x11, METH_VARARGS | METH_KEYWORDS },
 #ifdef ENABLE_ENGINE_GL_X11
     { "new_evas_gl_x11", (PyCFunction) new_evas_gl_x11, METH_VARARGS | METH_KEYWORDS },
 #endif
 #endif
+#endif
     { NULL }
 };
 
@@ -74,7 +78,7 @@
     static void *display_api_ptrs[3];
 
     m = Py_InitModule("_Display", display_methods);
-
+    #ifdef HAVE_X11
     if (PyType_Ready(&X11Display_PyObject_Type) < 0)
         return;
     Py_INCREF(&X11Display_PyObject_Type);
@@ -85,11 +89,12 @@
     Py_INCREF(&X11Window_PyObject_Type);
     PyModule_AddObject(m, "X11Window", (PyObject *)&X11Window_PyObject_Type);
 
+
     // Export display C API
     display_api_ptrs[0] = (void *)X11Window_PyObject__wrap;
     display_api_ptrs[1] = (void *)&X11Window_PyObject_Type;
     display_api_ptrs[2] = (void *)x11window_object_decompose;
-
+    #endif
     display_c_api = PyCObject_FromVoidPtr((void *)display_api_ptrs, NULL);
     PyModule_AddObject(m, "_C_API", display_c_api);
 
@@ -114,7 +119,8 @@
 #else
     Evas_PyObject_Type = NULL;
 #endif
-
+    #ifdef HAVE_X11
     if (!XInitThreads())
         PyErr_Format(PyExc_SystemError, "Unable to initialize X11 threads.");
+    #endif
 }
diff -Naur --exclude=entries kaa/display/src/evas.c kaa_noX11/display/src/evas.c
--- kaa/display/src/evas.c	2006-02-24 00:35:49.000000000 +0100
+++ kaa_noX11/display/src/evas.c	2006-02-24 00:24:18.000000000 +0100
@@ -39,8 +39,10 @@
 #ifdef USE_EVAS
 
 #include "evas.h"
+#ifdef HAVE_X11
 #include "x11display.h"
 #include "x11window.h"
+#endif
 
 Evas *(*evas_object_from_pyobject)(PyObject *pyevas);
 
diff -Naur --exclude=entries kaa/display/src/evas.h kaa_noX11/display/src/evas.h
--- kaa/display/src/evas.h	2006-02-24 00:35:49.000000000 +0100
+++ kaa_noX11/display/src/evas.h	2006-02-24 00:30:23.000000000 +0100
@@ -37,15 +37,17 @@
 #define _EVAS_H_
 
 #ifdef USE_EVAS
+#ifdef HAVE_X11
 #include "x11window.h"
+#endif
 #include <Evas.h>
 extern Evas *(*evas_object_from_pyobject)(PyObject *pyevas);
-
+#ifdef HAVE_X11
 X11Window_PyObject *new_evas_software_x11(PyObject *, PyObject *, PyObject *);
 
 #ifdef ENABLE_ENGINE_GL_X11
 X11Window_PyObject *new_evas_gl_x11(PyObject *, PyObject *, PyObject *);
 #endif
-
+#endif // HAVE_X11
 #endif // USE_EVAS
 #endif // _EVAS_H_
diff -Naur --exclude=entries kaa/xine/setup.py kaa_noX11/xine/setup.py
--- kaa/xine/setup.py	2006-02-24 00:35:39.000000000 +0100
+++ kaa_noX11/xine/setup.py	2006-02-24 00:21:42.000000000 +0100
@@ -26,7 +26,7 @@
 # -----------------------------------------------------------------------------
 
 # python imports
-import sys, os
+import sys, os, dl
 
 try:
     # kaa base imports
@@ -34,18 +34,36 @@
 except ImportError:
     print 'kaa.base not installed'
     sys.exit(1)
+
+have_x11 = 1
+try:
+    dl.open('/usr/lib/libX11.so')
+except dl.error, err:
+    print "System without X11 detected"
+    have_x11 = 0
     
-files = ['src/xine.c', 'src/video_port.c', 'src/audio_port.c', 'src/stream.c',
+if have_x11:
+    files = ['src/xine.c', 'src/video_port.c', 'src/audio_port.c', 'src/stream.c',
          'src/post.c', 'src/drivers/x11.c', 'src/drivers/video_out_kaa.c',
          'src/post_out.c', 'src/post_in.c', 'src/event.c', 'src/event_queue.c',
          'src/utils.c', 'src/vo_driver.c', 'src/drivers/kaa.c',
          'src/drivers/yuv2rgb.c', 'src/drivers/yuv2rgb_mmx.c', 'src/drivers/dummy.c',
          'src/drivers/video_out_dummy.c', 'src/drivers/common.c', 'src/drivers/fb.c'
-]
-xineso = Extension('kaa.xine._xinemodule', files, config='src/config.h', 
+    ]
+    xineso = Extension('kaa.xine._xinemodule', files, config='src/config.h', 
                    libraries = ["X11"], 
                    # FIXME: don't hardcode this path
                    library_dirs = ["/usr/X11R6/lib"])
+    xineso.config('#define HAVE_X11')
+else:
+    files = ['src/xine.c', 'src/video_port.c', 'src/audio_port.c', 'src/stream.c',
+         'src/post.c', 'src/drivers/video_out_kaa.c',
+         'src/post_out.c', 'src/post_in.c', 'src/event.c', 'src/event_queue.c',
+         'src/utils.c', 'src/vo_driver.c', 'src/drivers/kaa.c',
+         'src/drivers/yuv2rgb.c', 'src/drivers/yuv2rgb_mmx.c', 'src/drivers/dummy.c',
+         'src/drivers/video_out_dummy.c', 'src/drivers/common.c', 'src/drivers/fb.c'
+    ]
+    xineso = Extension('kaa.xine._xinemodule', files, config='src/config.h')
 
 if not xineso.check_library('xine', '1.1.1'):
     print 'xine >= 1.1.1 not found'
diff -Naur --exclude=entries kaa/xine/src/drivers/common.c kaa_noX11/xine/src/drivers/common.c
--- kaa/xine/src/drivers/common.c	2006-02-24 00:35:37.000000000 +0100
+++ kaa_noX11/xine/src/drivers/common.c	2006-02-24 00:21:42.000000000 +0100
@@ -1,5 +1,7 @@
 #include "common.h"
+#ifdef HAVE_X11
 #include "x11.h"
+#endif
 #include "kaa.h"
 #include "dummy.h"
 
@@ -10,8 +12,12 @@
     *visual_type_return = XINE_VISUAL_TYPE_NONE;
     if (!strcmp(driver, "xv") || !strcmp(driver, "xshm") || !strcmp(driver, "auto") ||
         !strcmp(driver, "opengl") || !strcmp(driver, "sdl")) {
+	#ifdef HAVE_X11
         *visual_type_return = XINE_VISUAL_TYPE_X11;
         return x11_get_visual_info(xine, kwargs, visual_return, driver_info_return);
+	#endif
+	PyErr_Format(PyExc_ValueError, "Unsupported driver: %s", driver);
+	return 0;	
     } else if (!strcmp(driver, "none")) {
         *driver_info_return = 0;
         *visual_return = 0;
diff -Naur --exclude=entries kaa/xine/src/xine.c kaa_noX11/xine/src/xine.c
--- kaa/xine/src/xine.c	2006-02-24 00:35:37.000000000 +0100
+++ kaa_noX11/xine/src/xine.c	2006-02-24 00:21:42.000000000 +0100
@@ -13,7 +13,9 @@
 #include "drivers/video_out_kaa.h"
 #include "drivers/video_out_dummy.h"
 #include "drivers/kaa.h"
+#ifdef HAVE_X11
 #include "drivers/x11.h"
+#endif
 #include "drivers/dummy.h"
 #include "drivers/common.h"
 
@@ -740,10 +742,14 @@
         PyErr_Format(xine_error, "Failed to import kaa.display");
         return;
     }
+    #ifdef HAVE_X11
     X11Window_PyObject_Type = display_api_ptrs[1];
     x11window_object_decompose = display_api_ptrs[2];
+    #endif
 #else
+    #ifdef HAVE_X11
     X11Window_PyObject_Type = NULL;
+    #endif
 #endif
 
     PyEval_InitThreads();

Reply via email to