opus.m4 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Configure paths for libopus
  2. # Gregory Maxwell <greg@xiph.org> 08-30-2012
  3. # Shamelessly stolen from Jack Moffitt (libogg) who
  4. # Shamelessly stole from Owen Taylor and Manish Singh
  5. dnl XIPH_PATH_OPUS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
  6. dnl Test for libopus, and define OPUS_CFLAGS and OPUS_LIBS
  7. dnl
  8. AC_DEFUN([XIPH_PATH_OPUS],
  9. [dnl
  10. dnl Get the cflags and libraries
  11. dnl
  12. AC_ARG_WITH(opus,AC_HELP_STRING([--with-opus=PFX],[Prefix where opus is installed (optional)]), opus_prefix="$withval", opus_prefix="")
  13. AC_ARG_WITH(opus-libraries,AC_HELP_STRING([--with-opus-libraries=DIR],[Directory where the opus library is installed (optional)]), opus_libraries="$withval", opus_libraries="")
  14. AC_ARG_WITH(opus-includes,AC_HELP_STRING([--with-opus-includes=DIR],[Directory where the opus header files are installed (optional)]), opus_includes="$withval", opus_includes="")
  15. AC_ARG_ENABLE(opustest,AC_HELP_STRING([--disable-opustest],[Do not try to compile and run a test opus program]),, enable_opustest=yes)
  16. if test "x$opus_libraries" != "x" ; then
  17. OPUS_LIBS="-L$opus_libraries"
  18. elif test "x$opus_prefix" = "xno" || test "x$opus_prefix" = "xyes" ; then
  19. OPUS_LIBS=""
  20. elif test "x$opus_prefix" != "x" ; then
  21. OPUS_LIBS="-L$opus_prefix/lib"
  22. elif test "x$prefix" != "xNONE" ; then
  23. OPUS_LIBS="-L$prefix/lib"
  24. fi
  25. if test "x$opus_prefix" != "xno" ; then
  26. OPUS_LIBS="$OPUS_LIBS -lopus"
  27. fi
  28. if test "x$opus_includes" != "x" ; then
  29. OPUS_CFLAGS="-I$opus_includes"
  30. elif test "x$opus_prefix" = "xno" || test "x$opus_prefix" = "xyes" ; then
  31. OPUS_CFLAGS=""
  32. elif test "x$opus_prefix" != "x" ; then
  33. OPUS_CFLAGS="-I$opus_prefix/include/opus"
  34. elif test "x$prefix" != "xNONE"; then
  35. OPUS_CFLAGS="-I$prefix/include/opus"
  36. fi
  37. AC_MSG_CHECKING(for Opus)
  38. if test "x$opus_prefix" = "xno" ; then
  39. no_opus="disabled"
  40. enable_opustest="no"
  41. else
  42. no_opus=""
  43. fi
  44. if test "x$enable_opustest" = "xyes" ; then
  45. ac_save_CFLAGS="$CFLAGS"
  46. ac_save_LIBS="$LIBS"
  47. CFLAGS="$CFLAGS $OPUS_CFLAGS"
  48. LIBS="$LIBS $OPUS_LIBS"
  49. dnl
  50. dnl Now check if the installed Opus is sufficiently new.
  51. dnl
  52. rm -f conf.opustest
  53. AC_TRY_RUN([
  54. #include <stdio.h>
  55. #include <stdlib.h>
  56. #include <string.h>
  57. #include <opus.h>
  58. int main ()
  59. {
  60. system("touch conf.opustest");
  61. return 0;
  62. }
  63. ],, no_opus=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  64. CFLAGS="$ac_save_CFLAGS"
  65. LIBS="$ac_save_LIBS"
  66. fi
  67. if test "x$no_opus" = "xdisabled" ; then
  68. AC_MSG_RESULT(no)
  69. ifelse([$2], , :, [$2])
  70. elif test "x$no_opus" = "x" ; then
  71. AC_MSG_RESULT(yes)
  72. ifelse([$1], , :, [$1])
  73. else
  74. AC_MSG_RESULT(no)
  75. if test -f conf.opustest ; then
  76. :
  77. else
  78. echo "*** Could not run Opus test program, checking why..."
  79. CFLAGS="$CFLAGS $OPUS_CFLAGS"
  80. LIBS="$LIBS $OPUS_LIBS"
  81. AC_TRY_LINK([
  82. #include <stdio.h>
  83. #include <opus.h>
  84. ], [ return 0; ],
  85. [ echo "*** The test program compiled, but did not run. This usually means"
  86. echo "*** that the run-time linker is not finding Opus or finding the wrong"
  87. echo "*** version of Opus. If it is not finding Opus, you'll need to set your"
  88. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  89. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  90. echo "*** is required on your system"
  91. echo "***"
  92. echo "*** If you have an old version installed, it is best to remove it, although"
  93. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  94. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  95. echo "*** exact error that occured. This usually means Opus was incorrectly installed"
  96. echo "*** or that you have moved Opus since it was installed." ])
  97. CFLAGS="$ac_save_CFLAGS"
  98. LIBS="$ac_save_LIBS"
  99. fi
  100. OPUS_CFLAGS=""
  101. OPUS_LIBS=""
  102. ifelse([$2], , :, [$2])
  103. fi
  104. AC_SUBST(OPUS_CFLAGS)
  105. AC_SUBST(OPUS_LIBS)
  106. rm -f conf.opustest
  107. ])