loader: ifdef libdrm specific code and include
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 19 Jan 2014 03:09:03 +0000 (03:09 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sun, 19 Jan 2014 15:17:00 +0000 (15:17 +0000)
Mesa provides the flexibility of building without the
need to have libdrm present on the system. The situation
has regressed with the recent commit

commit 8c2e7fd8460750543367053b1be9368cc38e1d6a
Author: Emil Velikov <emil.l.velikov@gmail.com>
Date:   Fri Jan 10 23:36:16 2014 +0000

    loader: introduce the loader util lib

By isolating libdrm code by #ifndef __NOT_HAVE_DRM_H we
can have libdrm-less builds on across all build systems.

This patch converts Android's _EGL_NO_DRM to __NOT_HAVE_DRM_H
to provide consistency with the other cases within mesa, allows
compilation of libloader on libdrm-less scons and conditionally
links against libdrm if present under automake.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73776
BUgzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73777
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
configure.ac
src/loader/Android.mk
src/loader/Makefile.am
src/loader/SConscript
src/loader/loader.c

index 9ca6704a3e13dfb2fb9d5ffe4b363850b4186e48..d9e18968c99237bd6f0f1041753df338cc9e5497 100644 (file)
@@ -1935,6 +1935,7 @@ AM_CONDITIONAL(HAVE_MESA_LLVM, test x$MESA_LLVM = x1)
 AC_SUBST([ELF_LIB])
 
 AM_CONDITIONAL(DRICOMMON_NEED_LIBDRM, test "x$DRICOMMON_NEED_LIBDRM" = xyes)
+AM_CONDITIONAL(HAVE_LIBDRM, test "x$have_libdrm" = xyes)
 AM_CONDITIONAL(HAVE_X11_DRIVER, test "x$enable_xlib_glx" = xyes)
 AM_CONDITIONAL(HAVE_OSMESA, test "x$enable_osmesa" = xyes)
 AM_CONDITIONAL(HAVE_GALLIUM_OSMESA, test "x$enable_gallium_osmesa" = xyes)
index 01699dcc5330716696e73c369f91d9b341ac37fe..6890af47342a61b3ffbec88d1a2659348e457326 100644 (file)
@@ -35,7 +35,7 @@ LOCAL_SRC_FILES := \
 
 # swrast only
 ifeq ($(MESA_GPU_DRIVERS),swrast)
-       LOCAL_CFLAGS += -D_EGL_NO_DRM
+       LOCAL_CFLAGS += -D__NOT_HAVE_DRM_H
 else
 LOCAL_C_INCLUDES += \
        $(DRM_TOP)/include/drm \
index a118fef1d9cbeb28ef97ce4c714240e2a6fa729d..371dd575c095c7ee59730b89ac3d14d119a0a213 100644 (file)
@@ -27,11 +27,20 @@ libloader_la_CPPFLAGS = \
        $(DEFINES) \
        -I$(top_srcdir)/include \
        $(VISIBILITY_CFLAGS) \
-       $(LIBDRM_CFLAGS) \
        $(LIBUDEV_CFLAGS)
 
 libloader_la_LIBADD = \
-       $(LIBDRM_LIBS) \
        $(LIBUDEV_LIBS)
 
+if !HAVE_LIBDRM
+libloader_la_CPPFLAGS += \
+       -D__NOT_HAVE_DRM_H
+else
+libloader_la_CPPFLAGS += \
+       $(LIBDRM_CFLAGS)
+
+libloader_la_LIBADD += \
+       $(LIBDRM_LIBS)
+endif
+
 libloader_la_SOURCES = $(LOADER_C_FILES)
index 76b0871005be210049be05276041ba69e7bb20da..359fc1850fe476bb3df9b148262d35793b8c280c 100644 (file)
@@ -1,15 +1,12 @@
 Import('*')
 
-if not env['drm']:
-    Return()
-
 env = env.Clone()
 
 env.Prepend(CPPPATH = [
     '#include'
 ])
 
-env.PkgUseModules('DRM')
+env.Append(CPPDEFINES = ['__NOT_HAVE_DRM_H'])
 
 if env['udev']:
     env.PkgUseModules('UDEV')
index 108e4440291789069228411b721cbd45baf54cc9..6fe8c8fc453b4ee29ea026a2f8701be06cef2c66 100644 (file)
@@ -69,7 +69,9 @@
 #include <string.h>
 #include "loader.h"
 
+#ifndef __NOT_HAVE_DRM_H
 #include <xf86drm.h>
+#endif
 
 #define __IS_LOADER
 #include "pci_ids/pci_id_driver_map.h"
@@ -149,7 +151,7 @@ out:
    return (*chip_id >= 0);
 }
 
-#elif defined(ANDROID) && !defined(_EGL_NO_DRM)
+#elif defined(ANDROID) && !defined(__NOT_HAVE_DRM_H)
 
 /* for i915 */
 #include <i915_drm.h>
@@ -267,6 +269,8 @@ loader_get_driver_for_fd(int fd, unsigned driver_types)
       driver_types = _LOADER_GALLIUM | _LOADER_DRI;
 
    if (!loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) {
+
+#ifndef __NOT_HAVE_DRM_H
       /* fallback to drmGetVersion(): */
       drmVersionPtr version = drmGetVersion(fd);
 
@@ -279,6 +283,7 @@ loader_get_driver_for_fd(int fd, unsigned driver_types)
       log(_LOADER_INFO, "using driver %s for %d", driver, fd);
 
       drmFreeVersion(version);
+#endif
 
       return driver;
    }