cannam@154: # Configure paths for libopus cannam@154: # Gregory Maxwell 08-30-2012 cannam@154: # Shamelessly stolen from Jack Moffitt (libogg) who cannam@154: # Shamelessly stole from Owen Taylor and Manish Singh cannam@154: cannam@154: dnl XIPH_PATH_OPUS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) cannam@154: dnl Test for libopus, and define OPUS_CFLAGS and OPUS_LIBS cannam@154: dnl cannam@154: AC_DEFUN([XIPH_PATH_OPUS], cannam@154: [dnl cannam@154: dnl Get the cflags and libraries cannam@154: dnl cannam@154: AC_ARG_WITH(opus,AC_HELP_STRING([--with-opus=PFX],[Prefix where opus is installed (optional)]), opus_prefix="$withval", opus_prefix="") cannam@154: 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="") cannam@154: 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="") cannam@154: AC_ARG_ENABLE(opustest,AC_HELP_STRING([--disable-opustest],[Do not try to compile and run a test opus program]),, enable_opustest=yes) cannam@154: cannam@154: if test "x$opus_libraries" != "x" ; then cannam@154: OPUS_LIBS="-L$opus_libraries" cannam@154: elif test "x$opus_prefix" = "xno" || test "x$opus_prefix" = "xyes" ; then cannam@154: OPUS_LIBS="" cannam@154: elif test "x$opus_prefix" != "x" ; then cannam@154: OPUS_LIBS="-L$opus_prefix/lib" cannam@154: elif test "x$prefix" != "xNONE" ; then cannam@154: OPUS_LIBS="-L$prefix/lib" cannam@154: fi cannam@154: cannam@154: if test "x$opus_prefix" != "xno" ; then cannam@154: OPUS_LIBS="$OPUS_LIBS -lopus" cannam@154: fi cannam@154: cannam@154: if test "x$opus_includes" != "x" ; then cannam@154: OPUS_CFLAGS="-I$opus_includes" cannam@154: elif test "x$opus_prefix" = "xno" || test "x$opus_prefix" = "xyes" ; then cannam@154: OPUS_CFLAGS="" cannam@154: elif test "x$opus_prefix" != "x" ; then cannam@154: OPUS_CFLAGS="-I$opus_prefix/include" cannam@154: elif test "x$prefix" != "xNONE"; then cannam@154: OPUS_CFLAGS="-I$prefix/include" cannam@154: fi cannam@154: cannam@154: AC_MSG_CHECKING(for Opus) cannam@154: if test "x$opus_prefix" = "xno" ; then cannam@154: no_opus="disabled" cannam@154: enable_opustest="no" cannam@154: else cannam@154: no_opus="" cannam@154: fi cannam@154: cannam@154: cannam@154: if test "x$enable_opustest" = "xyes" ; then cannam@154: ac_save_CFLAGS="$CFLAGS" cannam@154: ac_save_LIBS="$LIBS" cannam@154: CFLAGS="$CFLAGS $OPUS_CFLAGS" cannam@154: LIBS="$LIBS $OPUS_LIBS" cannam@154: dnl cannam@154: dnl Now check if the installed Opus is sufficiently new. cannam@154: dnl cannam@154: rm -f conf.opustest cannam@154: AC_TRY_RUN([ cannam@154: #include cannam@154: #include cannam@154: #include cannam@154: #include cannam@154: cannam@154: int main () cannam@154: { cannam@154: system("touch conf.opustest"); cannam@154: return 0; cannam@154: } cannam@154: cannam@154: ],, no_opus=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) cannam@154: CFLAGS="$ac_save_CFLAGS" cannam@154: LIBS="$ac_save_LIBS" cannam@154: fi cannam@154: cannam@154: if test "x$no_opus" = "xdisabled" ; then cannam@154: AC_MSG_RESULT(no) cannam@154: ifelse([$2], , :, [$2]) cannam@154: elif test "x$no_opus" = "x" ; then cannam@154: AC_MSG_RESULT(yes) cannam@154: ifelse([$1], , :, [$1]) cannam@154: else cannam@154: AC_MSG_RESULT(no) cannam@154: if test -f conf.opustest ; then cannam@154: : cannam@154: else cannam@154: echo "*** Could not run Opus test program, checking why..." cannam@154: CFLAGS="$CFLAGS $OPUS_CFLAGS" cannam@154: LIBS="$LIBS $OPUS_LIBS" cannam@154: AC_TRY_LINK([ cannam@154: #include cannam@154: #include cannam@154: ], [ return 0; ], cannam@154: [ echo "*** The test program compiled, but did not run. This usually means" cannam@154: echo "*** that the run-time linker is not finding Opus or finding the wrong" cannam@154: echo "*** version of Opus. If it is not finding Opus, you'll need to set your" cannam@154: echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" cannam@154: echo "*** to the installed location Also, make sure you have run ldconfig if that" cannam@154: echo "*** is required on your system" cannam@154: echo "***" cannam@154: echo "*** If you have an old version installed, it is best to remove it, although" cannam@154: echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], cannam@154: [ echo "*** The test program failed to compile or link. See the file config.log for the" cannam@154: echo "*** exact error that occurred. This usually means Opus was incorrectly installed" cannam@154: echo "*** or that you have moved Opus since it was installed." ]) cannam@154: CFLAGS="$ac_save_CFLAGS" cannam@154: LIBS="$ac_save_LIBS" cannam@154: fi cannam@154: OPUS_CFLAGS="" cannam@154: OPUS_LIBS="" cannam@154: ifelse([$2], , :, [$2]) cannam@154: fi cannam@154: AC_SUBST(OPUS_CFLAGS) cannam@154: AC_SUBST(OPUS_LIBS) cannam@154: rm -f conf.opustest cannam@154: ])