libFLAC++.m4 4.4 KB

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