dnl === test for libsndfile - begin ===
dnl
dnl Don't use PKG_CHECK, since if there is no pkg-config installed,
dnl then there is no auto* magic for it either.
dnl
dnl Tests copied from tdebase/kioslave/thumbnail/
dnl
if test -z "$PKG_CONFIG"; then
    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi

AC_ARG_WITH(
	sndfile, 
	AS_HELP_STRING([--without-sndfile], 
	[build K3b without libsndfile support (default=no)]), 
	[ac_cv_use_sndfile=$withval], 
	[ac_cv_use_sndfile=yes]
)

if test "$ac_cv_use_sndfile" = "yes"; then
  SNDFILE_CFLAGS=""
  SNDFILE_LIBS=""
  if test "$PKG_CONFIG" = "no" ; then
      ac_cv_sndfile=0
      echo "*** The pkg-config script could not be found. Make sure it is"
      echo "*** in your path, or set the PKG_CONFIG environment variable"
      echo "*** to the full path to pkg-config."
      echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
  else
      if !(`$PKG_CONFIG --exists sndfile`) ; then
          echo "*** sndfile is not installed."
          ac_cv_sndfile=0
      else
          if !(`$PKG_CONFIG --atleast-version="1.0.2" sndfile`) ; then
              echo "*** You need at least version 1.0.2 of sndfile."
              ac_cv_sndfile=0
          else
              ac_cv_sndfile=1
              SNDFILE_CFLAGS=`$PKG_CONFIG --cflags sndfile`
              SNDFILE_LIBS=`$PKG_CONFIG --libs sndfile`
          fi
      fi
  fi

  AC_DEFINE_UNQUOTED([HAVE_SNDFILE],${ac_cv_sndfile},
  			[Set to 1 if you have libsndfile.])
  AC_SUBST(SNDFILE_CFLAGS)
  AC_SUBST(SNDFILE_LIBS)
fi

AM_CONDITIONAL(include_AIFF, [test x$ac_cv_sndfile = x1])
dnl === test for libsndfile - end ===
