Commit ecaee771f63c5610868d9a426d969aaa49bbca5f

Thomas de Grivel 2022-08-10T15:16:12

fix configure for sndio

diff --git a/config.subr b/config.subr
index b53954c..920492b 100644
--- a/config.subr
+++ b/config.subr
@@ -186,7 +186,14 @@ check_sndio() {
 	LIBS="$LIBS $(pkg-config --libs sndio)"
         HAVE_SNDIO=Yes
     else
-        HAVE_SNDIO=No
+	OLD_LIBS="$LIBS"
+	LIBS="$LIBS -lsndio"
+	if "${CC}" ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} "${SRCDIR}/lib/sndio/check_sndio.c" ${LIBS} -o /dev/null; then
+	    HAVE_SNDIO=Yes
+	else
+	    LIBS="${OLD_LIBS}"
+            HAVE_SNDIO=No
+	fi
     fi
     echo "Checking library sndio: $HAVE_SNDIO" >&2
     echo "HAVE_SNDIO = $HAVE_SNDIO" >> ${CONFIG_MK}
diff --git a/configure b/configure
index 9d090bd..26f96bb 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,8 @@
 #!/bin/sh
 set -e
 
+export SRCDIR="$PWD"
+
 . ./config.subr
 
 (cd librtbuf && ./configure)
diff --git a/lib/sndio/check_sndio.c b/lib/sndio/check_sndio.c
new file mode 100644
index 0000000..afeba81
--- /dev/null
+++ b/lib/sndio/check_sndio.c
@@ -0,0 +1,8 @@
+#include <sndio.h>
+
+int main ()
+{
+  struct sio_hdl *sio_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
+  sio_close(sio_hdl);
+  return 0;
+}
diff --git a/lib/sndio/configure b/lib/sndio/configure
index 568b147..b7ce2d9 100755
--- a/lib/sndio/configure
+++ b/lib/sndio/configure
@@ -18,13 +18,12 @@ echo "CFLAGS = $CFLAGS" >> ${CONFIG_MK}
 
 echo "LDFLAGS = $LDFLAGS" >> ${CONFIG_MK}
 
-LIBS="-lsndio ../librtbuf_signal.la"
-echo "LIBS = $LIBS" >> ${CONFIG_MK}
-
 check_sndio
 
 if test "x$HAVE_SNDIO" = "xYes"; then
     rtbuf_library sndio
+    LIBS="-lsndio ../librtbuf_signal.la"
+    echo "LIBS = $LIBS" >> ${CONFIG_MK}
 else
     echo "libraries:" >> ${CONFIG_MK}
 fi