changeset 2125:5c33e8e1a479

- add a m4 macro file to setup MAD_CFLAGS and MAD_LIBS. - fix for a typo in libFLAC.m4 founded in editing libmad.m4.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Wed, 24 Oct 2007 15:05:27 +0900
parents b8da6a0b0da2
children fe479ddb4f4e
files configure.ac m4/libFLAC.m4 m4/libmad.m4
diffstat 3 files changed, 116 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Wed Oct 24 07:34:02 2007 +0300
+++ b/configure.ac	Wed Oct 24 15:05:27 2007 +0900
@@ -367,24 +367,18 @@
 )
 
 if test "$enable_mp3" = "yes"; then
-        AC_CHECK_LIB(mad, mad_timer_add,
-		[INPUT_PLUGINS="$INPUT_PLUGINS madplug"
-		 MAD_CFLAGS=""
-		 MAD_LIBS="-lmad -lm"],
-		[PKG_CHECK_MODULES(MAD, [libmad],
-		 [INPUT_PLUGINS="$INPUT_PLUGINS madplug"],
-		 [enable_mp3="no"])
-		])
+    AM_PATH_LIBMAD([enable_mp3=yes], 
+        [AC_MSG_WARN([*** Cannot find libmad, mp3 plugin will not be built ***])
+         enable_mp3=no]
+    )
+else
+    AC_MSG_RESULT([*** mp3 plugin disabled per user request ***])
+    enable_mp3=no
 fi
-# XXX rtsp support
-#        PKG_CHECK_MODULES(LIBNMS,[libnms >= 0.6.0],
-#            [LIBNMS_SRC=rtsp.c
-#             AC_DEFINE(HAVE_NEMESI,,[Define if rtp/rtsp support is available])
-#            ],[LIBNMS_SRC=""])
-#        AC_SUBST(LIBNMS_CFLAGS)
-#        AC_SUBST(LIBNMS_LIBS)
-#        AC_SUBST(LIBNMS_SRC)
-# fi
+
+if test "$enable_mp3" = "yes"; then
+	INPUT_PLUGINS="$INPUT_PLUGINS madplug"
+fi
 
 AC_SUBST(MAD_CFLAGS)
 AC_SUBST(MAD_LIBS)
--- a/m4/libFLAC.m4	Wed Oct 24 07:34:02 2007 +0300
+++ b/m4/libFLAC.m4	Wed Oct 24 15:05:27 2007 +0900
@@ -28,7 +28,7 @@
     LIBFLAC_CFLAGS="-I$libFLAC_includes"
   elif test "x$libFLAC_prefix" != "x" ; then
     LIBFLAC_CFLAGS="-I$libFLAC_prefix/include"
-  elif test "$prefix" != "xNONE"; then
+  elif test "x$prefix" != "xNONE"; then
     LIBFLAC_CFLAGS="-I$prefix/include"
   fi
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/libmad.m4	Wed Oct 24 15:05:27 2007 +0900
@@ -0,0 +1,104 @@
+dnl Configure paths for libmad
+dnl derived from libFLAC.m4
+
+dnl AM_PATH_LIBMAD([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Test for libmad, and define MAD_CFLAGS and MAD_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBMAD],
+[dnl 
+dnl Get the cflags and libraries
+dnl
+AC_ARG_WITH(libmad,[  --with-libmad=PFX   Prefix where libmad is installed (optional)], libmad_prefix="$withval", libmad_prefix="")
+AC_ARG_WITH(libmad-libraries,[  --with-libmad-libraries=DIR   Directory where libmad library is installed (optional)], libmad_libraries="$withval", libmad_libraries="")
+AC_ARG_WITH(libmad-includes,[  --with-libmad-includes=DIR   Directory where libmad header files are installed (optional)], libmad_includes="$withval", libmad_includes="")
+AC_ARG_ENABLE(libmadtest, [  --disable-libmadtest   do not try to compile and run a test libmad program],, enable_libmadtest=yes)
+
+  if test "x$libmad_libraries" != "x" ; then
+    MAD_LIBS="-L$libmad_libraries"
+  elif test "x$libmad_prefix" != "x" ; then
+    MAD_LIBS="-L$libmad_prefix/lib"
+  elif test "x$prefix" != "xNONE" ; then
+    MAD_LIBS="-L$libdir"
+  fi
+
+  MAD_LIBS="$MAD_LIBS -lmad -lm"
+
+  if test "x$libmad_includes" != "x" ; then
+    MAD_CFLAGS="-I$libmad_includes"
+  elif test "x$libmad_prefix" != "x" ; then
+    MAD_CFLAGS="-I$libmad_prefix/include"
+  elif test "x$prefix" != "xNONE"; then
+    MAD_CFLAGS="-I$prefix/include"
+  fi
+
+  no_libmad=""
+
+
+  if test "x$enable_libmadtest" = "xyes" ; then
+    ac_save_CFLAGS="$CFLAGS"
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    ac_save_LIBS="$LIBS"
+    CFLAGS="$CFLAGS $MAD_CFLAGS"
+    CXXFLAGS="$CXXFLAGS $MAD_CFLAGS"
+    LIBS="$LIBS $MAD_LIBS"
+dnl
+dnl Now check if the installed libmad is sufficiently new.
+dnl
+      rm -f conf.libmadtest
+      AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mad.h>
+
+int main ()
+{
+  mad_timer_t t;
+  mad_timer_add(&t, t);
+  system("touch conf.libmadtest");
+  return 0;
+}
+
+],, no_libmad=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+  fi
+
+  if test "x$no_libmad" = "x" ; then
+     AC_MSG_RESULT(yes)
+     ifelse([$1], , :, [$1])     
+  else
+     AC_MSG_RESULT(no)
+     if test -f conf.libmadtest ; then
+       :
+     else
+       echo "*** Could not run libmad test program, checking why..."
+       CFLAGS="$CFLAGS $MAD_CFLAGS"
+       LIBS="$LIBS $MAD_LIBS"
+       AC_TRY_LINK([
+#include <stdio.h>
+],     [ return 0; ],
+       [ echo "*** The test program compiled, but did not run. This usually means"
+       echo "*** that the run-time linker is not finding libmad or finding the wrong"
+       echo "*** version of libmad. If it is not finding libmad, you'll need to set your"
+       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+       echo "*** is required on your system"
+       echo "***"
+       echo "*** If you have an old version installed, it is best to remove it, although"
+       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+       [ echo "*** The test program failed to compile or link. See the file config.log for the"
+       echo "*** exact error that occured. This usually means libmad was incorrectly installed"
+       echo "*** or that you have moved libmad since it was installed. In the latter case, you"
+       echo "*** may want to edit the libmad-config script: $LIBMAD_CONFIG" ])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+     MAD_CFLAGS=""
+     MAD_LIBS=""
+     ifelse([$2], , :, [$2])
+  fi
+  AC_SUBST(MAD_CFLAGS)
+  AC_SUBST(MAD_LIBS)
+  rm -f conf.libmadtest
+])