From c2d788f6de2ee98faef1a49b700fcf577c2f0d32 Mon Sep 17 00:00:00 2001
From: Avuton Olrich <avuton@gmail.com>
Date: Thu, 15 Apr 2010 19:41:18 -0700
Subject: [PATCH] configure.ac: Check for LAME libraries the same way others
 are checked for.

Check for LAME libraries the same way other libraries are checked for, in line
with the configure and outside the buggy macro. This will fix problems with
cross compilation.
---
 configure.ac | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 504bd6474..18c2f1f8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1133,12 +1133,20 @@ MPD_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc],
 	[Ogg Vorbis encoder], [libvorbisenc not found])
 
 if test x$enable_lame_encoder != xno; then
-	AM_PATH_LAME([found_lame_encoder=yes], [found_lame_encoder=no])
-	MPD_AUTO_RESULT(lame_encoder, [LAME encoder plugin],
-		[LAME not found])
+	AC_CHECK_HEADERS(lame/lame.h,,
+		[AC_CHECK_HEADERS(lame.h,, using_lame=no)])
+	AC_CHECK_LIB(mp3lame, lame_init,, using_lame=no)
+	if test x$using_lame != xno; then
+		AC_DEFINE(HAVE_LAME, 1, [Define to 1 if you have lame 3.98 or greater.])
+		LAME_LIBS="-lmp3lame -lm"
+		enable_lame_encoder=yes
+	fi
+
+	if test "$enable_lame_encoder" = "yes" -a "$using_lame" = "no"; then
+		AC_MSG_ERROR([LAME libraries and development support files not found.])
+	fi
 fi
 
-AC_SUBST(LAME_CFLAGS)
 AC_SUBST(LAME_LIBS)
 
 MPD_AUTO_PKG(twolame_encoder, TWOLAME, [twolame],