Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 1 | # Configure paths for libFLAC |
| 2 | # "Inspired" by ogg.m4 |
| 3 | |
| 4 | dnl AM_PATH_LIBFLAC([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 5 | dnl Test for libFLAC, and define LIBFLAC_CFLAGS, LIBFLAC_LIBS, LIBFLAC_LIBDIR |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 6 | dnl |
Josh Coalson | a941454 | 2004-07-20 01:24:48 +0000 | [diff] [blame] | 7 | AC_DEFUN([AM_PATH_LIBFLAC], |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 8 | [dnl |
| 9 | dnl Get the cflags and libraries |
| 10 | dnl |
| 11 | AC_ARG_WITH(libFLAC,[ --with-libFLAC=PFX Prefix where libFLAC is installed (optional)], libFLAC_prefix="$withval", libFLAC_prefix="") |
| 12 | AC_ARG_WITH(libFLAC-libraries,[ --with-libFLAC-libraries=DIR Directory where libFLAC library is installed (optional)], libFLAC_libraries="$withval", libFLAC_libraries="") |
| 13 | AC_ARG_WITH(libFLAC-includes,[ --with-libFLAC-includes=DIR Directory where libFLAC header files are installed (optional)], libFLAC_includes="$withval", libFLAC_includes="") |
| 14 | AC_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 |
Erik de Castro Lopo | c08b679 | 2012-02-13 19:39:55 +1100 | [diff] [blame] | 17 | LIBFLAC_LIBS="-L$libFLAC_libraries" |
| 18 | elif test "x$libFLAC_prefix" = "xno" || test "x$libFLAC_prefix" = "xyes" ; then |
| 19 | LIBFLAC_LIBS="" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 20 | elif test "x$libFLAC_prefix" != "x" ; then |
Erik de Castro Lopo | c08b679 | 2012-02-13 19:39:55 +1100 | [diff] [blame] | 21 | LIBFLAC_LIBS="-L$libFLAC_prefix/lib" |
| 22 | elif test "x$prefix" != "xNONE"; then |
| 23 | LIBFLAC_LIBS="-L$prefix/lib" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 24 | fi |
| 25 | |
Erik de Castro Lopo | c08b679 | 2012-02-13 19:39:55 +1100 | [diff] [blame] | 26 | if test "x$libFLAC_prefix" != "xno" ; then |
| 27 | LIBFLAC_LIBS="$LIBFLAC_LIBS -lFLAC $OGG_LIBS -lm" |
| 28 | fi |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 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 |
Josh Coalson | 32e85a7 | 2006-11-13 06:42:51 +0000 | [diff] [blame] | 35 | LIBFLAC_CFLAGS="" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 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" |
Josh Coalson | 39eb471 | 2002-07-01 20:37:39 +0000 | [diff] [blame] | 44 | ac_save_CXXFLAGS="$CXXFLAGS" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 45 | ac_save_LIBS="$LIBS" |
Josh Coalson | 60a43f0 | 2007-06-14 05:25:35 +0000 | [diff] [blame] | 46 | ac_save_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 47 | CFLAGS="$CFLAGS $LIBFLAC_CFLAGS" |
Josh Coalson | 39eb471 | 2002-07-01 20:37:39 +0000 | [diff] [blame] | 48 | CXXFLAGS="$CXXFLAGS $LIBFLAC_CFLAGS" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 49 | LIBS="$LIBS $LIBFLAC_LIBS" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 50 | LD_LIBRARY_PATH="$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 51 | dnl |
| 52 | dnl Now check if the installed libFLAC is sufficiently new. |
| 53 | dnl |
| 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 | |
| 61 | int 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" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 69 | CXXFLAGS="$ac_save_CXXFLAGS" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 70 | LIBS="$ac_save_LIBS" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 71 | LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 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" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 84 | CXXFLAGS="$CXXFLAGS $LIBFLAC_CFLAGS" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 85 | LIBS="$LIBS $LIBFLAC_LIBS" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 86 | LD_LIBRARY_PATH="$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 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" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 105 | CXXFLAGS="$ac_save_CXXFLAGS" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 106 | LIBS="$ac_save_LIBS" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 107 | LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 108 | fi |
| 109 | LIBFLAC_CFLAGS="" |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 110 | LIBFLAC_LIBDIR="" |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 111 | LIBFLAC_LIBS="" |
| 112 | ifelse([$2], , :, [$2]) |
| 113 | fi |
| 114 | AC_SUBST(LIBFLAC_CFLAGS) |
Josh Coalson | 03a6887 | 2006-10-25 00:44:26 +0000 | [diff] [blame] | 115 | AC_SUBST(LIBFLAC_LIBDIR) |
Josh Coalson | bfeec74 | 2002-06-28 23:45:53 +0000 | [diff] [blame] | 116 | AC_SUBST(LIBFLAC_LIBS) |
| 117 | rm -f conf.libFLACtest |
| 118 | ]) |