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