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