configure.in
branchSDL-1.2
changeset 4192 2f5e884f0a9d
parent 4185 cb2d5514efb3
child 4204 976bc19f8f6b
--- a/configure.in	Sat Sep 12 19:41:54 2009 +0000
+++ b/configure.in	Sun Sep 13 22:19:56 2009 +0000
@@ -591,30 +591,62 @@
 AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
                   , enable_nas=yes)
     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
-        save_LDFLAGS="$LDFLAGS"
-        LDFLAGS="$LDFLAGS -lXt -lm"
-        AC_CHECK_HEADER(audio/audiolib.h, have_audio_hdr=yes)
-        AC_CHECK_LIB(audio, AuOpenServer, have_audio_lib=yes)
-        AC_CHECK_HEADER(nas/audiolib.h, have_nas_hdr=yes)
-        AC_CHECK_LIB(nas, AuOpenServer, have_nas_lib=yes)
-        LDFLAGS="$save_LDFLAGS"
+        AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
+        AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
 
         AC_MSG_CHECKING(for NAS audio support)
         have_nas=no
-        if test x$have_audio_hdr = xyes -a x$have_audio_lib = xyes; then
+
+        if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
+            have_nas=yes
+            NAS_LIBS="-laudio"
+
+        elif test -r /usr/X11R6/include/audio/audiolib.h; then
             have_nas=yes
-            NAS_LIBS="-laudio -lXt"
-        elif test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
+            NAS_CFLAGS="-I/usr/X11R6/include/"
+            NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
+
+        dnl On IRIX, the NAS includes are in a different directory,
+        dnl and libnas must be explicitly linked in
+
+        elif test -r /usr/freeware/include/nas/audiolib.h; then
             have_nas=yes
             NAS_LIBS="-lnas -lXt"
-	fi
+        fi
+
         AC_MSG_RESULT($have_nas)
 
         if test x$have_nas = xyes; then
+            AC_ARG_ENABLE(nas-shared,
+AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
+                          , enable_nas_shared=yes)
+            if test "x`echo $NAS_LIBS | grep -- -L`" = "x"; then
+                if test "x`ls /lib/libaudio.so.* 2> /dev/null`" != "x"; then
+                    NAS_LIBS="-L/lib $NAS_LIBS"
+                elif test "x`ls /usr/lib/libaudio.so.* 2> /dev/null`" != "x"; then
+                    NAS_LIBS="-L/usr/lib $NAS_LIBS"
+                elif test "x`ls /usr/local/lib/libaudio.so.* 2> /dev/null`" != "x"; then
+                    NAS_LIBS="-L/usr/local/lib $NAS_LIBS"
+                fi
+            fi
+            nas_lib_spec=`echo $NAS_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libaudio.so.*/'`
+            nas_lib=`ls -- $nas_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
+            echo "-- $nas_lib_spec -> $nas_lib"
+
+            if test x$have_loadso != xyes && \
+               test x$enable_nas_shared = xyes; then
+                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
+            fi
+            if test x$have_loadso = xyes && \
+               test x$enable_nas_shared = xyes && test x$nas_lib != x; then
+                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib")
+            else
+                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
+            fi
+
             AC_DEFINE(SDL_AUDIO_DRIVER_NAS)
             SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
             EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
             have_audio=yes
         fi
     fi