1 # Configure paths for libFLAC++
3 # Caller must first run AM_PATH_LIBFLAC
5 dnl AM_PATH_LIBFLACPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6 dnl Test for libFLAC++, and define LIBFLACPP_CFLAGS, LIBFLACPP_LIBS, LIBFLACPP_LIBDIR
8 AC_DEFUN([AM_PATH_LIBFLACPP],
10 dnl Get the cflags and libraries
12 AC_ARG_WITH(libFLACPP,[ --with-libFLACPP=PFX Prefix where libFLAC++ is installed (optional)], libFLACPP_prefix="$withval", libFLACPP_prefix="")
13 AC_ARG_WITH(libFLACPP-libraries,[ --with-libFLACPP-libraries=DIR Directory where libFLAC++ library is installed (optional)], libFLACPP_libraries="$withval", libFLACPP_libraries="")
14 AC_ARG_WITH(libFLACPP-includes,[ --with-libFLACPP-includes=DIR Directory where libFLAC++ header files are installed (optional)], libFLACPP_includes="$withval", libFLACPP_includes="")
15 AC_ARG_ENABLE(libFLACPPtest, [ --disable-libFLACPPtest Do not try to compile and run a test libFLAC++ program],, enable_libFLACPPtest=yes)
17 if test "x$libFLACPP_libraries" != "x" ; then
18 LIBFLACPP_LIBDIR="$libFLACPP_libraries"
19 elif test "x$libFLACPP_prefix" != "x" ; then
20 LIBFLACPP_LIBDIR="$libFLACPP_prefix/lib"
21 elif test "x$prefix" != "xNONE" ; then
22 LIBFLACPP_LIBDIR="$libdir"
25 LIBFLACPP_LIBS="-L$LIBFLACPP_LIBDIR -lFLAC++ $LIBFLAC_LIBS"
27 if test "x$libFLACPP_includes" != "x" ; then
28 LIBFLACPP_CFLAGS="-I$libFLACPP_includes"
29 elif test "x$libFLACPP_prefix" != "x" ; then
30 LIBFLACPP_CFLAGS="-I$libFLACPP_prefix/include"
31 elif test "$prefix" != "xNONE"; then
35 LIBFLACPP_CFLAGS="$LIBFLACPP_CFLAGS $LIBFLAC_CFLAGS"
37 AC_MSG_CHECKING(for libFLAC++)
41 if test "x$enable_libFLACPPtest" = "xyes" ; then
42 ac_save_CFLAGS="$CFLAGS"
43 ac_save_CXXFLAGS="$CXXFLAGS"
45 ac_save_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
46 CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS"
47 CXXFLAGS="$CXXFLAGS $LIBFLACPP_CFLAGS"
48 LIBS="$LIBS $LIBFLACPP_LIBS"
49 LD_LIBRARY_PATH="$LIBFLACPP_LIBDIR:$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH"
51 dnl Now check if the installed libFLAC++ is sufficiently new.
53 rm -f conf.libFLAC++test
58 #include <FLAC++/decoder.h>
62 system("touch conf.libFLAC++test");
66 ],, no_libFLACPP=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
67 CFLAGS="$ac_save_CFLAGS"
68 CXXFLAGS="$ac_save_CXXFLAGS"
70 LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH"
73 if test "x$no_libFLACPP" = "x" ; then
75 ifelse([$1], , :, [$1])
78 if test -f conf.libFLAC++test ; then
81 echo "*** Could not run libFLAC++ test program, checking why..."
82 CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS"
83 CXXFLAGS="$CXXFLAGS $LIBFLACPP_CFLAGS"
84 LIBS="$LIBS $LIBFLACPP_LIBS"
85 LD_LIBRARY_PATH="$LIBFLACPP_LIBDIR:$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH"
88 #include <FLAC++/decoder.h>
90 [ echo "*** The test program compiled, but did not run. This usually means"
91 echo "*** that the run-time linker is not finding libFLAC++ or finding the wrong"
92 echo "*** version of libFLAC++. If it is not finding libFLAC++, you'll need to set your"
93 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
94 echo "*** to the installed location Also, make sure you have run ldconfig if that"
95 echo "*** is required on your system"
97 echo "*** If you have an old version installed, it is best to remove it, although"
98 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
99 [ echo "*** The test program failed to compile or link. See the file config.log for the"
100 echo "*** exact error that occured. This usually means libFLAC++ was incorrectly installed"
101 echo "*** or that you have moved libFLAC++ since it was installed. In the latter case, you"
102 echo "*** may want to edit the libFLAC++-config script: $LIBFLACPP_CONFIG" ])
103 CFLAGS="$ac_save_CFLAGS"
104 CXXFLAGS="$ac_save_CXXFLAGS"
106 LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH"
111 ifelse([$2], , :, [$2])
113 AC_SUBST(LIBFLACPP_CFLAGS)
114 AC_SUBST(LIBFLACPP_LIBDIR)
115 AC_SUBST(LIBFLACPP_LIBS)
116 rm -f conf.libFLAC++test