diff configure.in @ 865:92615154bb68

Date: Sun, 29 Feb 2004 15:14:22 +0200 From: Martin_Storsj Subject: Dynamic loading of ALSA I recently discovered that SDL can dynamically load ESD and aRts, and made a patch which adds this same functionality to ALSA. The update for configure.in isn't too good (it should e.g. look for libasound.so in other directories than /usr/lib), because I'm not too good at shellscripting and autoconf. The reason for using dlfcn.h and dlopen instead of SDL_LoadLibrary and SDL_LoadFunction is that libasound uses versioned symbols, and it is necessary to load the correct version using dlvsym. This isn't probably any real portability issue, because ALSA is linux-only.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 02 Mar 2004 12:49:16 +0000
parents d3165b90ee42
children e805075f6d94
line wrap: on
line diff
--- a/configure.in	Tue Mar 02 12:45:22 2004 +0000
+++ b/configure.in	Tue Mar 02 12:49:16 2004 +0000
@@ -295,8 +295,22 @@
         AC_CHECK_LIB(asound, snd_pcm_open, have_alsa=yes)
         ])
         if test x$have_alsa = xyes; then
-            CFLAGS="$CFLAGS -DALSA_SUPPORT"
-            SYSTEM_LIBS="$SYSTEM_LIBS -lasound"
+            AC_ARG_ENABLE(alsa-shared,
+[  --enable-alsa-shared     dynamically load ALSA audio support [default=yes]],
+                          , enable_alsa_shared=yes)
+            alsa_lib=`ls /usr/lib/libasound.so.* | head -1 | sed 's/.*\/\(.*\)/\1/'`
+            if test x$use_dlopen != xyes && \
+               test x$enable_alsa_shared = xyes; then
+                AC_MSG_ERROR([You must have dlopen() support and use the --enable-dlopen option])
+            fi
+            if test x$use_dlopen = xyes && \
+               test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
+                CFLAGS="$CFLAGS -DALSA_SUPPORT -DALSA_DYNAMIC=\$(alsa_lib)"
+                AC_SUBST(alsa_lib)
+            else
+                CFLAGS="$CFLAGS -DALSA_SUPPORT"
+                SYSTEM_LIBS="$SYSTEM_LIBS -lasound"
+            fi
             AUDIO_SUBDIRS="$AUDIO_SUBDIRS alsa"
             AUDIO_DRIVERS="$AUDIO_DRIVERS alsa/libaudio_alsa.la"
         else