$OpenBSD: patch-configure_ac,v 1.11 2012/09/27 06:17:08 ajacoutot Exp $
--- configure.ac.orig	Tue Sep 25 02:21:07 2012
+++ configure.ac	Thu Sep 27 07:58:59 2012
@@ -296,6 +296,36 @@ else
     HAVE_OSS=0
 fi
 
+### SNDIO support (optional) ###
+
+AC_ARG_ENABLE([sndio],
+    AC_HELP_STRING([--disable-sndio], [Disable optional sndio support]),
+        [
+            case "${enableval}" in
+                yes) sndio=yes ;;
+                no) sndio=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --disable-sndio) ;;
+            esac
+        ],
+        [sndio=auto])
+
+if test "x${sndio}" != xno ; then
+    AC_CHECK_HEADERS(sndio.h)
+    if test "${ac_cv_header_sndio_h}" = "yes"; then
+	HAVE_SNDIO=1
+        AC_DEFINE([HAVE_SNDIO], 1, [Have sndio?])
+        SNDIO_LIBS='-lsndio'
+    else
+	HAVE_SNDIO=0
+        if test "x$sndio" = xyes ; then
+            AC_MSG_ERROR([*** sndio not found ***])
+        fi
+    fi
+else
+    HAVE_SNDIO=0
+fi
+AC_SUBST(SNDIO_LIBS)
+
 ### PulseAudio (optional) ####
 
 AC_ARG_ENABLE([pulse],
@@ -597,6 +627,7 @@ BUILTIN_DSO=0
 BUILTIN_PULSE=0
 BUILTIN_ALSA=0
 BUILTIN_OSS=0
+BUILTIN_SNDIO=0
 BUILTIN_GSTREAMER=0
 BUILTIN_NULL=0
 
@@ -609,6 +640,7 @@ case "x$with_builtin" in
         BUILTIN_PULSE=1
         HAVE_ALSA=0
 	HAVE_OSS=0
+	HAVE_SNDIO=0
 	HAVE_GSTREAMER=0
         HAVE_NULL=0
      ;;
@@ -620,6 +652,7 @@ case "x$with_builtin" in
 
         BUILTIN_ALSA=1
 	HAVE_OSS=0
+	HAVE_SNDIO=0
         HAVE_PULSE=0
 	HAVE_GSTREAMER=0
         HAVE_NULL=0
@@ -633,6 +666,7 @@ case "x$with_builtin" in
         BUILTIN_GSTREAMER=1
         HAVE_ALSA=0
 	HAVE_OSS=0
+	HAVE_SNDIO=0
         HAVE_PULSE=0
         HAVE_NULL=0
      ;;
@@ -644,11 +678,25 @@ case "x$with_builtin" in
 
 	BUILTIN_OSS=1
 	HAVE_ALSA=0
+	HAVE_SNDIO=0
 	HAVE_PULSE=0
 	HAVE_GSTREAMER=0
 	HAVE_NULL=0
      ;;
 
+     xsndio)
+        if test "x$HAV_SNDIO" != x1 ; then
+	        AC_MSG_ERROR([*** sndio selected for builtin driver, but not enabled. ***])
+	fi
+
+	BUILTIN_SNDIO=1
+	HAVE_ALSA=0
+	HAVE_OSS=0
+	HAVE_PULSE=0
+	HAVE_GSTREAMER=0
+	HAVE_NULL=0
+     ;;
+
      xnull)
         if test "x$HAVE_NULL" != x1 ; then
                 AC_MSG_ERROR([*** Null output selected for builtin driver, but not enabled. ***])
@@ -656,6 +704,7 @@ case "x$with_builtin" in
 
         BUILTIN_NULL=1
         HAVE_PULSE=0
+	HAVE_SNDIO=0
         HAVE_ALSA=0
 	HAVE_OSS=0
 	HAVE_GSTREAMER=0
@@ -671,7 +720,7 @@ case "x$with_builtin" in
         AC_MSG_ERROR([*** Unknown driver $with_builtin selected for builtin ***])
 esac
 
-if test "x$HAVE_PULSE" != x1 -a "x$HAVE_ALSA" != x1 -a "x$HAVE_OSS" != x1 -a "x$HAVE_GSTREAMER" != x1 -a "x$HAVE_NULL" != x1 ; then
+if test "x$HAVE_PULSE" != x1 -a "x$HAVE_ALSA" != x1 -a "x$HAVE_OSS" != x1 -a "x$HAVE_SNDIO" != x1 -a "x$HAVE_GSTREAMER" != x1 -a "x$HAVE_NULL" != x1 ; then
    AC_MSG_ERROR([*** No backend enabled. ***])
 fi
 
@@ -679,23 +728,27 @@ AC_SUBST(HAVE_DSO)
 AC_SUBST(HAVE_PULSE)
 AC_SUBST(HAVE_ALSA)
 AC_SUBST(HAVE_OSS)
+AC_SUBST(HAVE_SNDIO)
 AC_SUBST(HAVE_GSTREAMER)
 AC_SUBST(HAVE_NULL)
 AC_SUBST(BUILTIN_DSO)
 AC_SUBST(BUILTIN_PULSE)
 AC_SUBST(BUILTIN_ALSA)
 AC_SUBST(BUILTIN_OSS)
+AC_SUBST(BUILTIN_SNDIO)
 AC_SUBST(BUILTIN_GSTREAMER)
 AC_SUBST(BUILTIN_NULL)
 AM_CONDITIONAL([HAVE_PULSE], [test "x$HAVE_PULSE" = x1])
 AM_CONDITIONAL([HAVE_ALSA], [test "x$HAVE_ALSA" = x1])
 AM_CONDITIONAL([HAVE_OSS], [test "x$HAVE_OSS" = x1])
+AM_CONDITIONAL([HAVE_SNDIO], [test "x$HAVE_SNDIO" = x1])
 AM_CONDITIONAL([HAVE_GSTREAMER], [test "x$HAVE_GSTREAMER" = x1])
 AM_CONDITIONAL([HAVE_NULL], [test "x$HAVE_NULL" = x1])
 AM_CONDITIONAL([BUILTIN_DSO], [test "x$BUILTIN_DSO" = x1])
 AM_CONDITIONAL([BUILTIN_PULSE], [test "x$BUILTIN_PULSE" = x1])
 AM_CONDITIONAL([BUILTIN_ALSA], [test "x$BUILTIN_ALSA" = x1])
 AM_CONDITIONAL([BUILTIN_OSS], [test "x$BUILTIN_OSS" = x1])
+AM_CONDITIONAL([BUILTIN_SNDIO], [test "x$BUILTIN_SNDIO" = x1])
 AM_CONDITIONAL([BUILTIN_GSTREAMER], [test "x$BUILTIN_GSTREAMER" = x1])
 AM_CONDITIONAL([BUILTIN_NULL], [test "x$BUILTIN_NULL" = x1])
 
@@ -754,6 +807,15 @@ if test "x$BUILTIN_OSS" = "x1" ; then
     ENABLE_BUILTIN_OSS=yes
 fi
 
+ENABLE_SNDIO=no
+if test "x$HAVE_SNDIO" = "x1" ; then
+    ENABLE_SNDIO=yes
+fi
+ENABLE_BUILTIN_SNDIO=no
+if test "x$BUILTIN_SNDIO" = "x1" ; then
+    ENABLE_BUILTIN_SNDIO=yes
+fi
+
 ENABLE_GSTREAMER=no
 if test "x$HAVE_GSTREAMER" = "x1" ; then
    ENABLE_GSTREAMER=yes
@@ -814,6 +876,8 @@ echo "
     Builtin ALSA:           ${ENABLE_BUILTIN_ALSA}
     Enable OSS:             ${ENABLE_OSS}
     Builtin OSS:            ${ENABLE_BUILTIN_OSS}
+    Enable SNDIO:           ${ENABLE_SNDIO}
+    Builtin SNDIO:          ${ENABLE_BUILTIN_SNDIO}
     Enable GStreamer:       ${ENABLE_GSTREAMER}
     Builtin GStreamer:      ${ENABLE_BUILTIN_GSTREAMER}
     Enable Null Output:     ${ENABLE_NULL}
