home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / share / aclocal / libFLAC++.m4 < prev    next >
Encoding:
M4 Source File  |  2005-06-14  |  4.0 KB  |  108 lines

  1. # Configure paths for libFLAC++
  2. # "Inspired" by ogg.m4
  3. # Caller must first run AM_PATH_LIBFLAC
  4.  
  5. dnl AM_PATH_LIBFLACPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
  6. dnl Test for libFLAC++, and define LIBFLACPP_CFLAGS and LIBFLACPP_LIBS
  7. dnl
  8. AC_DEFUN([AM_PATH_LIBFLACPP],
  9. [dnl 
  10. dnl Get the cflags and libraries
  11. dnl
  12. AC_ARG_WITH(libFLACPP,[  --with-libFLACPP=PFX   Prefix where libFLAC++ is installed (optional)], libFLACPP_prefix="$withval", libFLACPP_prefix="")
  13. AC_ARG_WITH(libFLACPP-libraries,[  --with-libFLACPP-libraries=DIR   Directory where libFLAC++ library is installed (optional)], libFLACPP_libraries="$withval", libFLACPP_libraries="")
  14. AC_ARG_WITH(libFLACPP-includes,[  --with-libFLACPP-includes=DIR   Directory where libFLAC++ header files are installed (optional)], libFLACPP_includes="$withval", libFLACPP_includes="")
  15. AC_ARG_ENABLE(libFLACPPtest, [  --disable-libFLACPPtest       Do not try to compile and run a test libFLAC++ program],, enable_libFLACPPtest=yes)
  16.  
  17.   if test "x$libFLACPP_libraries" != "x" ; then
  18.     LIBFLACPP_LIBS="-L$libFLACPP_libraries"
  19.   elif test "x$libFLACPP_prefix" != "x" ; then
  20.     LIBFLACPP_LIBS="-L$libFLACPP_prefix/lib"
  21.   elif test "x$prefix" != "xNONE" ; then
  22.     LIBFLACPP_LIBS="-L$libdir"
  23.   fi
  24.  
  25.   LIBFLACPP_LIBS="$LIBFLACPP_LIBS -lFLAC++ $LIBFLAC_LIBS"
  26.  
  27.   if test "x$libFLACPP_includes" != "x" ; then
  28.     LIBFLACPP_CFLAGS="-I$libFLACPP_includes"
  29.   elif test "x$libFLACPP_prefix" != "x" ; then
  30.     LIBFLACPP_CFLAGS="-I$libFLACPP_prefix/include"
  31.   elif test "$prefix" != "xNONE"; then
  32.     LIBFLACPP_CFLAGS="-I$prefix/include"
  33.   fi
  34.  
  35.   LIBFLACPP_CFLAGS="$LIBFLACPP_CFLAGS $LIBFLAC_CFLAGS"
  36.  
  37.   AC_MSG_CHECKING(for libFLAC++)
  38.   no_libFLACPP=""
  39.  
  40.  
  41.   if test "x$enable_libFLACPPtest" = "xyes" ; then
  42.     ac_save_CFLAGS="$CFLAGS"
  43.     ac_save_CXXFLAGS="$CXXFLAGS"
  44.     ac_save_LIBS="$LIBS"
  45.     CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS"
  46.     CXXFLAGS="$CXXFLAGS $LIBFLACPP_CFLAGS"
  47.     LIBS="$LIBS $LIBFLACPP_LIBS"
  48. dnl
  49. dnl Now check if the installed libFLAC++ is sufficiently new.
  50. dnl
  51.       rm -f conf.libFLAC++test
  52.       AC_TRY_RUN([
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <string.h>
  56. #include <FLAC++/decoder.h>
  57.  
  58. int main ()
  59. {
  60.   system("touch conf.libFLAC++test");
  61.   return 0;
  62. }
  63.  
  64. ],, no_libFLACPP=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  65.        CFLAGS="$ac_save_CFLAGS"
  66.        LIBS="$ac_save_LIBS"
  67.   fi
  68.  
  69.   if test "x$no_libFLACPP" = "x" ; then
  70.      AC_MSG_RESULT(yes)
  71.      ifelse([$1], , :, [$1])     
  72.   else
  73.      AC_MSG_RESULT(no)
  74.      if test -f conf.libFLAC++test ; then
  75.        :
  76.      else
  77.        echo "*** Could not run libFLAC++ test program, checking why..."
  78.        CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS"
  79.        LIBS="$LIBS $LIBFLACPP_LIBS"
  80.        AC_TRY_LINK([
  81. #include <stdio.h>
  82. #include <FLAC++/decoder.h>
  83. ],     [ return 0; ],
  84.        [ echo "*** The test program compiled, but did not run. This usually means"
  85.        echo "*** that the run-time linker is not finding libFLAC++ or finding the wrong"
  86.        echo "*** version of libFLAC++. If it is not finding libFLAC++, you'll need to set your"
  87.        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  88.        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
  89.        echo "*** is required on your system"
  90.        echo "***"
  91.        echo "*** If you have an old version installed, it is best to remove it, although"
  92.        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  93.        [ echo "*** The test program failed to compile or link. See the file config.log for the"
  94.        echo "*** exact error that occured. This usually means libFLAC++ was incorrectly installed"
  95.        echo "*** or that you have moved libFLAC++ since it was installed. In the latter case, you"
  96.        echo "*** may want to edit the libFLAC++-config script: $LIBFLACPP_CONFIG" ])
  97.        CFLAGS="$ac_save_CFLAGS"
  98.        LIBS="$ac_save_LIBS"
  99.      fi
  100.      LIBFLACPP_CFLAGS=""
  101.      LIBFLACPP_LIBS=""
  102.      ifelse([$2], , :, [$2])
  103.   fi
  104.   AC_SUBST(LIBFLACPP_CFLAGS)
  105.   AC_SUBST(LIBFLACPP_LIBS)
  106.   rm -f conf.libFLAC++test
  107. ])
  108.