--- configure.in.orig	2008-05-29 00:33:03.535492000 +0200
+++ configure.in	2008-05-29 00:34:21.277673000 +0200
@@ -90,6 +90,7 @@
 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
 
 dnl Check for tools
+AC_LIBTOOL_DLOPEN
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 AC_PROG_CC
@@ -287,6 +288,9 @@
     AC_DEFINE(SDL_ASSEMBLY_ROUTINES)
 fi
 
+dnl set this to use on systems that use lib64 instead of lib
+base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
+
 dnl See if the OSS audio interface is supported
 CheckOSS()
 {
@@ -348,12 +352,12 @@
 AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
                           , enable_alsa_shared=yes)
             if test "x`echo $ALSA_LIBS | grep -- -L`" = "x"; then
-                if test "x`ls /lib/libasound.so.* 2> /dev/null`" != "x"; then
-                    ALSA_LIBS="-L/lib $ALSA_LIBS"
-                elif test "x`ls /usr/lib/libasound.so.* 2> /dev/null`" != "x"; then
-                    ALSA_LIBS="-L/usr/lib $ALSA_LIBS"
-                elif test "x`ls /usr/local/lib/libasound.so.* 2> /dev/null`" != "x"; then
-                    ALSA_LIBS="-L/usr/local/lib $ALSA_LIBS"
+                if test "x`ls /$base_libdir/libasound.so.* 2> /dev/null`" != "x"; then
+                    ALSA_LIBS="-L/$base_libdir $ALSA_LIBS"
+                elif test "x`ls /usr/$base_libdir/libasound.so.* 2> /dev/null`" != "x"; then
+                    ALSA_LIBS="-L/usr/$base_libdir $ALSA_LIBS"
+                elif test "x`ls /usr/local/$base_libdir/libasound.so.* 2> /dev/null`" != "x"; then
+                    ALSA_LIBS="-L/usr/local/$base_libdir $ALSA_LIBS"
                 fi
             fi
             alsa_lib_spec=`echo $ALSA_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libasound.so.*/'`
@@ -452,8 +456,13 @@
             AC_ARG_ENABLE(esd-shared,
 AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
                           , enable_esd_shared=yes)
-            esd_lib_spec=`echo $ESD_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libesd.so.*/'`
-            esd_lib=`ls -- $esd_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
+            ESD_LIBS_test="$ESD_LIBS"
+            esd_lib_spec=x
+            while test "x$esd_lib" = x && test "x$esd_lib_spec" != x; do
+                esd_lib_spec=`echo $ESD_LIBS_test | sed 's/.*-L\([[^ ]]*\).*/\1\/libesd.so.*/' |grep /libesd.so. `
+        	esd_lib=`ls -- $esd_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
+                ESD_LIBS_test=`echo $ESD_LIBS_test | sed 's/\(.*\)-L.*/\1/'`
+            done
             echo "-- $esd_lib_spec -> $esd_lib"
 
             AC_DEFINE(SDL_AUDIO_DRIVER_ESD)
@@ -501,12 +510,12 @@
 AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
                           , enable_pulse_shared=yes)
             if test "x`echo $PULSE_LIBS | grep -- -L`" = "x"; then
-                if test "x`ls /lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
-                    PULSE_LIBS="-L/lib $PULSE_LIBS"
-                elif test "x`ls /usr/lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
-                    PULSE_LIBS="-L/usr/lib $PULSE_LIBS"
-                elif test "x`ls /usr/local/lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
-                    PULSE_LIBS="-L/usr/local/lib $PULSE_LIBS"
+                if test "x`ls /$base_libdir/libpulse-simple.so.* 2> /dev/null`" != "x"; then
+                    PULSE_LIBS="-L/$base_libdir $PULSE_LIBS"
+                elif test "x`ls /usr/$base_libdir/libpulse-simple.so.* 2> /dev/null`" != "x"; then
+                    PULSE_LIBS="-L/usr/$base_libdir $PULSE_LIBS"
+                elif test "x`ls /usr/local/$base_libdir/libpulse-simple.so.* 2> /dev/null`" != "x"; then
+                    PULSE_LIBS="-L/usr/local/$base_libdir $PULSE_LIBS"
                 fi
             fi
             pulse_lib_spec=`echo $PULSE_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libpulse-simple.so.*/'`
@@ -561,7 +570,7 @@
                 AC_ARG_ENABLE(arts-shared,
 AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
                               , enable_arts_shared=yes)
-                arts_lib_spec="$ARTS_PREFIX/lib/libartsc.so.*"
+                arts_lib_spec="$ARTS_PREFIX/$base_libdir/libartsc.so.*"
                 arts_lib=`ls -- $arts_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
                 echo "-- $arts_lib_spec -> $arts_lib"
 
