autoconf: Configurable DRI drivers

The user can request specific DRI drivers to build rather than the
default of "all that build on this platform". This allows the list of
drivers to be easily slimmed down.

This is controlled through the option --with-dri-drivers. For example:

    ./configure --with-driver=dri --with-dri-drivers="i965,nouveau"

Unfortunately, using this setting means the DRI drivers aren't filtered
by platform anymore and you might try to build something that doesn't
work.
diff --git a/configure.ac b/configure.ac
index 814fb2e..c639378 100644
--- a/configure.ac
+++ b/configure.ac
@@ -325,8 +325,8 @@
         GLX_USE_TLS="$enableval",
         GLX_USE_TLS=no)
 dnl Directory for DRI drivers
-AC_ARG_WITH(dridriverdir,
-    [AS_HELP_STRING([--with-dridriverdir=DIR],
+AC_ARG_WITH(dri-driverdir,
+    [AS_HELP_STRING([--with-dri-driverdir=DIR],
         [directory for the DRI drivers @<:@/usr/X11R6/lib/modules/dri@:>@])],
     DRI_DRIVER_INSTALL_DIR="$withval",
     DRI_DRIVER_INSTALL_DIR='/usr/X11R6/lib/modules/dri')
@@ -338,6 +338,32 @@
         driglx_direct="$enableval",
         driglx_direct="yes")
 
+dnl Which drivers to build - default is chosen by platform
+AC_ARG_WITH(dri-drivers,
+    [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
+        [comma delimited DRI drivers to build @<:@default=auto by platform@:>@])],
+    with_dri_drivers="$withval",
+    with_dri_drivers=yes)
+if test "x$with_dri_drivers" = x; then
+    with_dri_drivers=no
+fi
+
+dnl If $with_dri_drivers is yes, directories will be added through
+dnl platform checks
+DRI_DIRS=""
+case "$with_dri_drivers" in
+no|yes) ;;
+*)
+    # verify the requested driver directories exist
+    dri_drivers=`IFS=,; echo $with_dri_drivers`
+    for driver in $dri_drivers; do
+        test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
+            AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
+    done
+    DRI_DIRS="$dri_drivers"
+    ;;
+esac
+
 dnl Just default to no EGL for now
 USING_EGL=0
 AC_SUBST(USING_EGL)
@@ -364,15 +390,21 @@
 
         case "$host_cpu" in
         i*86)
-            DRI_DIRS="i810 i915tex i915 i965 mach64 mga r128 r200 r300 \
-                radeon s3v savage sis tdfx trident unichrome ffb"
+            if test "x$DRI_DIRS" = x; then
+                DRI_DIRS="i810 i915tex i915 i965 mach64 mga r128 r200 r300 \
+                    radeon s3v savage sis tdfx trident unichrome ffb"
+            fi
             ;;
         x86_64)
-            DRI_DIRS="i915tex i915 i965 mach64 mga r128 r200 radeon tdfx \
-                unichrome savage r300"
+            if test "x$DRI_DIRS" = x; then
+                DRI_DIRS="i915tex i915 i965 mach64 mga r128 r200 radeon tdfx \
+                    unichrome savage r300"
+            fi
             ;;
         powerpc*)
-            DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
+            if test "x$DRI_DIRS" = x; then
+                DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
+            fi
             ;;
         esac
         ;;
@@ -387,8 +419,10 @@
             CXXFLAGS="$CXXFLAGS -ansi -pedantic"
         fi
 
-        DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
-            unichrome savage sis"
+        if test "x$DRI_DIRS" = x; then
+            DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
+                unichrome savage sis"
+        fi
         ;;
     esac
     DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/  */ /g'`