swrast: Build the driver into the shared mesa_dri_drivers.so.
authorEric Anholt <eric@anholt.net>
Fri, 27 Sep 2013 23:57:11 +0000 (16:57 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 24 Oct 2013 21:13:09 +0000 (14:13 -0700)
v2: drop dridir now that it's unused.
v3: Fix linking after rebase when building just swrast from classic but a
    drm-using gallium driver.
v4: Consistently put spaces around += in the updated Makefile.am block.
v5: Set a global driverAPI variable so loaders don't have to update to
    createNewScreen2() (though they may want to for thread safety).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v3)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
configure.ac
src/mesa/drivers/dri/Makefile.am
src/mesa/drivers/dri/common/Makefile.am
src/mesa/drivers/dri/swrast/Makefile.am
src/mesa/drivers/dri/swrast/Makefile.sources
src/mesa/drivers/dri/swrast/swrast.c

index 0ac3bf8e172edfe31e9c7eaa9b18e8131687ac61..30b57bd33979634cf3895ff66ce76a4f40f492d9 100644 (file)
@@ -1022,10 +1022,15 @@ if test "x$enable_dri" = xyes; then
     LIBS="$save_LIBS"
 
     # If we are building any DRI driver other than swrast.
-    if test -n "$DRI_DIRS" -a x"$DRI_DIRS" != xswrast; then
-        # ... libdrm is required
-        if test "x$have_libdrm" != xyes; then
-            AC_MSG_ERROR([DRI drivers requires libdrm >= $LIBDRM_REQUIRED])
+    if test -n "$DRI_DIRS"; then
+        if test x"$DRI_DIRS" != xswrast; then
+            # ... libdrm is required
+            if test "x$have_libdrm" != xyes; then
+                AC_MSG_ERROR([DRI drivers requires libdrm >= $LIBDRM_REQUIRED])
+            fi
+            DRICOMMON_NEED_LIBDRM=yes
+        else
+            DRICOMMON_NEED_LIBDRM=no
         fi
     fi
 
@@ -1037,14 +1042,6 @@ if test "x$enable_dri" = xyes; then
 fi
 
 enable_dricore=no
-enable_megadriver=no
-for driver in $DRI_DIRS; do
-    if test $driver = "swrast"; then
-        enable_dricore=yes
-    else
-        enable_megadriver=yes
-    fi
-done
 
 # megadriver wants to use libmesa.la, while non-megadrivers want to
 # automatically get libdricore.  Some day hopefully we'll transition
@@ -1053,10 +1050,10 @@ MEGADRIVER_DRI_LIB_DEPS=$DRI_LIB_DEPS
 DRI_LIB_DEPS="\$(top_builddir)/src/mesa/libdricore/libdricore${VERSION}.la $DRI_LIB_DEPS"
 
 AM_CONDITIONAL(NEED_LIBDRICORE, test "x$enable_dricore" = xyes)
-AM_CONDITIONAL(NEED_MEGADRIVER, test "x$enable_megadriver" = xyes)
+AM_CONDITIONAL(NEED_MEGADRIVER, test -n "$DRI_DIRS")
 AM_CONDITIONAL(NEED_LIBMESA, test "x$enable_xlib_glx" = xyes -o \
                                   "x$enable_osmesa" = xyes -o \
-                                  "x$enable_megadriver" = xyes)
+                                  -n "$DRI_DIRS")
 AC_SUBST([EXPAT_INCLUDES])
 AC_SUBST([DRI_LIB_DEPS])
 AC_SUBST([DRI_DRIVER_LDFLAGS])
@@ -1777,6 +1774,7 @@ if test "x$with_gallium_drivers" != x; then
             fi
             GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
             gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
+            DRICOMMON_NEED_LIBDRM=yes
             ;;
         xilo)
             HAVE_GALLIUM_ILO=yes
@@ -1784,6 +1782,7 @@ if test "x$with_gallium_drivers" != x; then
             gallium_require_drm_loader
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS ilo"
             gallium_check_st "intel/drm" "dri-ilo"
+            DRICOMMON_NEED_LIBDRM=yes
             ;;
         xr300)
             HAVE_GALLIUM_R300=yes
@@ -1791,6 +1790,7 @@ if test "x$with_gallium_drivers" != x; then
             gallium_require_llvm "Gallium R300"
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
             gallium_check_st "radeon/drm" "r300/dri" "" "" "r300/xvmc" "r300/vdpau"
+            DRICOMMON_NEED_LIBDRM=yes
             ;;
         xr600)
             HAVE_GALLIUM_R600=yes
@@ -1808,6 +1808,7 @@ if test "x$with_gallium_drivers" != x; then
                 LLVM_COMPONENTS="${LLVM_COMPONENTS} bitreader asmparser"
             fi
             gallium_check_st "radeon/drm" "r600/dri" "r600/xorg" "" "r600/xvmc" "r600/vdpau"
+            DRICOMMON_NEED_LIBDRM=yes
             ;;
         xradeonsi)
             HAVE_GALLIUM_RADEONSI=yes
@@ -1816,6 +1817,7 @@ if test "x$with_gallium_drivers" != x; then
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS radeonsi"
             radeon_llvm_check
             gallium_check_st "radeon/drm" "radeonsi/dri" "radeonsi/xorg" "" "" "radeonsi/vdpau" ""
+            DRICOMMON_NEED_LIBDRM=yes
             ;;
         xnouveau)
             HAVE_GALLIUM_NOUVEAU=yes
@@ -1823,6 +1825,7 @@ if test "x$with_gallium_drivers" != x; then
             gallium_require_drm_loader
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau"
             gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" "" "xvmc-nouveau" "vdpau-nouveau"
+            DRICOMMON_NEED_LIBDRM=yes
             ;;
         xfreedreno)
             HAVE_GALLIUM_FREEDRENO=yes
@@ -1830,6 +1833,7 @@ if test "x$with_gallium_drivers" != x; then
             gallium_require_drm_loader
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS freedreno"
             gallium_check_st "freedreno/drm" "dri-freedreno" "" "" "" ""
+            DRICOMMON_NEED_LIBDRM=yes
             ;;
         xswrast)
             HAVE_GALLIUM_SOFTPIPE=yes
@@ -1961,10 +1965,11 @@ 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(NEED_LIBPROGRAM, test "x$with_gallium_drivers" != x -o \
                                      "x$enable_xlib_glx" = xyes -o \
                                      "x$enable_osmesa" = xyes -o \
-                                     "x$enable_megadriver" = xyes -o \
+                                     -n "$DRI_DIRS" -o \
                                      "x$enable_gallium_osmesa" = xyes)
 AM_CONDITIONAL(HAVE_X11_DRIVER, test "x$enable_xlib_glx" = xyes)
 AM_CONDITIONAL(HAVE_OSMESA, test "x$enable_osmesa" = xyes)
index 57b2341fa07b36a5eaf06ae8cec31ef721703f01..aee6990c4394f62a85a7354d8a684939a95e25ba 100644 (file)
@@ -37,7 +37,9 @@ MEGADRIVERS += radeon_dri.so
 endif
 
 if HAVE_SWRAST_DRI
-SUBDIRS+=swrast
+SUBDIRS += swrast
+MEGADRIVERS_DEPS += swrast/libswrast_dri.la
+MEGADRIVERS += swrast_dri.so
 endif
 
 pkgconfigdir = $(libdir)/pkgconfig
index e9c4acaece5eb58e79fe1b370f132aadb0d0d687..9f49ff3aee415d6082aaee64d3c0efe6ba3fb77f 100644 (file)
@@ -27,7 +27,6 @@ AM_CFLAGS = \
        -I$(top_srcdir)/src/mapi \
        -I$(top_srcdir)/src/mesa/ \
        $(DEFINES) \
-       $(LIBDRM_CFLAGS) \
        $(VISIBILITY_CFLAGS)
 
 noinst_LTLIBRARIES = \
@@ -47,3 +46,10 @@ libdri_test_stubs_la_CFLAGS = $(AM_CFLAGS) -DNO_MAIN
 libmegadriver_stub_la_SOURCES = megadriver_stub.c
 
 sysconf_DATA = drirc
+
+if DRICOMMON_NEED_LIBDRM
+AM_CFLAGS += $(LIBDRM_CFLAGS)
+libdricommon_la_LDFLAGS = $(LIBDRM_LIBS)
+else
+AM_CFLAGS += -D__NOT_HAVE_DRM_H
+endif
index c51ad2d874b218ffa8e9e90fc43589819f60a275..0837b4518ff02d4fd154df7a8a527c88f0d28004 100644 (file)
@@ -34,19 +34,5 @@ AM_CFLAGS = \
        $(DEFINES) \
        $(VISIBILITY_CFLAGS)
 
-dridir = $(DRI_DRIVER_INSTALL_DIR)
-dri_LTLIBRARIES = swrast_dri.la
-
-swrast_dri_la_SOURCES = \
-       $(SWRAST_C_FILES)
-
-swrast_dri_la_LDFLAGS = $(DRI_DRIVER_LDFLAGS)
-
-swrast_dri_la_LIBADD = \
-       $(DRI_LIB_DEPS)
-
-# Provide compatibility with scripts for the old Mesa build system for
-# a while by putting a link to the driver into /lib of the build tree.
-all-local: swrast_dri.la
-       $(MKDIR_P) $(top_builddir)/$(LIB_DIR);
-       ln -f .libs/swrast_dri.so $(top_builddir)/$(LIB_DIR)/swrast_dri.so;
+noinst_LTLIBRARIES = libswrast_dri.la
+libswrast_dri_la_SOURCES = $(SWRAST_C_FILES)
index fc7ef32dbd55f56f1d2a4815b0047ef361cd090e..70e432febb5d38cf5fae824d05a29b8313ab7608 100644 (file)
@@ -1,11 +1,5 @@
 SWRAST_DRIVER_FILES = \
        swrast.c 
 
-SWRAST_COMMON_FILES = \
-       ../common/utils.c \
-       ../common/dri_util.c \
-       ../common/xmlconfig.c
-
 SWRAST_C_FILES = \
-       $(SWRAST_COMMON_FILES) \
        $(SWRAST_DRIVER_FILES)
index 4725a7f42dd12d6e4a28be117673b58e0f9bf4eb..bfa2efd21c81ebbd20d62c5190a9b4ac123a99c1 100644 (file)
@@ -59,6 +59,7 @@
 #include "swrast_priv.h"
 #include "swrast/s_context.h"
 
+const __DRIextension **__driDriverGetExtensions_swrast(void);
 
 /**
  * Screen and config-related functions
@@ -819,7 +820,7 @@ dri_unbind_context(__DRIcontext * cPriv)
 }
 
 
-const struct __DriverAPIRec driDriverAPI = {
+static const struct __DriverAPIRec swrast_driver_api = {
     .InitScreen = dri_init_screen,
     .DestroyScreen = dri_destroy_screen,
     .CreateContext = dri_create_context,
@@ -831,9 +832,21 @@ const struct __DriverAPIRec driDriverAPI = {
     .UnbindContext = dri_unbind_context,
 };
 
-/* This is the table of extensions that the loader will dlsym() for. */
-PUBLIC const __DRIextension *__driDriverExtensions[] = {
+static const struct __DRIDriverVtableExtensionRec swrast_vtable = {
+   .base = { __DRI_DRIVER_VTABLE, 1 },
+   .vtable = &swrast_driver_api,
+};
+
+static const __DRIextension *swrast_driver_extensions[] = {
     &driCoreExtension.base,
     &driSWRastExtension.base,
+    &swrast_vtable.base,
     NULL
 };
+
+PUBLIC const __DRIextension **__driDriverGetExtensions_swrast(void)
+{
+   globalDriverAPI = &swrast_driver_api;
+
+   return swrast_driver_extensions;
+}