#MIN_CONFIG(3.2)
#AM_KDE_MIN_VERSION(3.4)

AC_CHECK_HEADERS(byteswap.h)

dnl - check the byte order -
dnl this will define WORDS_BIGENDIAN or do nothing
AC_C_BIGENDIAN()

AC_ARG_WITH(
	external-libsamplerate,
	[  --with-external-libsamplerate   use the libsamplerate provided by the system (default=yes)],
	[external_sampletrate=$withval], 
	[external_sampletrate=yes]
)

LIBSAMPLERATE=""

if test x$external_sampletrate != xno; then

dnl === check for libsamplerate ==========
KDE_CHECK_HEADERS(samplerate.h, [
	KDE_CHECK_LIB(samplerate, src_new, [
		LIBSAMPLERATE="-lsamplerate"	
		AC_DEFINE(HAVE_LIBSAMPLERATE,1,[defined if you have libsamplerate library and header])
	])
])

fi

AC_SUBST(LIBSAMPLERATE)
AM_CONDITIONAL(compile_libsamplerate, [test -z "$LIBSAMPLERATE"])


ARTS_LIBS=""
if test "x$build_arts" = "xyes"; then
	dnl Find aRts
	if $PKG_CONFIG artsc --exists; then
		arts_available=yes
		ARTS_LIBS="-lartsc"
		ARTS_INCLUDES="`$PKG_CONFIG artsc --cflags`"
	else
		KDE_CHECK_HEADERS(artsc/artsc.h,
			[arts_available=yes
			 ARTS_LIBS="-lartsc"
			 ARTS_INCLUDES="`$ARTSCCONFIG --cflags`"],
			[arts_available=no]
		)
	fi
fi
AC_SUBST(ARTS_LIBS)
AC_SUBST(ARTS_INCLUDES)
AM_CONDITIONAL(include_arts, [test -n "$ARTS_LIBS"])
if test "x$build_arts" = "xyes" -a "x$arts_available" = "xyes"; then
	AC_DEFINE(WITH_ARTS,1,[defined if arts support is compiled in])
fi

KDE_CHECK_THREADING

compile_k3bsetup=yes
AC_ARG_WITH(
	k3bsetup, 
	[  --with-k3bsetup[=ARG]     do compile K3bSetup2 KControl Module (default=yes)],
	[compile_k3bsetup=$withval]
)

if test x$compile_k3bsetup = xyes; then
        AC_DEFINE(HAVE_K3BSETUP,1,[defined if K3bSetup is compiled])
fi

AM_CONDITIONAL(with_k3bsetup1, [test x$compile_k3bsetup = xyes])


cdrecord_suid_root=yes
AC_ARG_WITH(
	cdrecord-suid-root, 
	AS_HELP_STRING(
		[--without-cdrecord-suid-root], 
		[enable or disable K3b's suid root check for cdrecord/cdrdao/wodim (default=enabled)]),
	[cdrecord_suid_root=$withval], 
	[cdrecord_suid_root=yes]
)
if test x$cdrecord_suid_root = xyes; then
	AC_DEFINE(CDRECORD_SUID_ROOT_CHECK,1,[defined if K3b should check cdrecord for suid root])
fi


# Extra SCSI support libs can go in CAM_LIB, and are linked into
# libk3bdevice. For Linux, nothing is needed. FreeBSD requires -lcam
# (which is in base, so no test is needed).
case "$host_os" in
freebsd* | dragonfly*)
	CAM_LIB="-lcam"
	;;
*)
	CAM_LIB=""
	;;
esac
AC_SUBST(CAM_LIB)



dnl ---------- TAGLIB CHECK ----------

AC_DEFUN([AC_HAVE_TAGLIB],
[
    AC_DEFINE(HAVE_TAGLIB, 1, [have TagLib])
    taglib_includes=[`$TAGLIB_CONFIG --cflags`]
    taglib_libs=[`$TAGLIB_CONFIG --libs`]
    have_taglib=true
])

AC_DEFUN([AC_NO_TAGLIB],
[
    taglib_includes=""
    taglib_libs=""
    have_taglib=false
])

AC_PATH_PROG(TAGLIB_CONFIG, taglib-config, [no], [$PATH:$prefix/bin])
if test "x$TAGLIB_CONFIG" = "xno" ; then
    AC_NO_TAGLIB
else
    AC_HAVE_TAGLIB
fi

AC_SUBST(taglib_includes)
AC_SUBST(taglib_libs)

dnl ---------- END TAGLIB CHECK ----------



dnl ----------- TUNEPIMP/MUSICBRAINZ CHECK -----------

AC_ARG_WITH(
	musicbrainz, 
	AS_HELP_STRING(
		[--without-musicbrainz], 
		[build K3b without Musicbrainz support (default=no)]),
	[ac_cv_use_musicbrainz=$withval], 
	[ac_cv_use_musicbrainz=yes]
)

have_mb=false
MUSICBRAINZ_LIBS=""
if test "$ac_cv_use_musicbrainz" = "yes"; then
  KDE_CHECK_HEADER(musicbrainz/mb_c.h,
  [
	KDE_CHECK_LIB(musicbrainz,mb_New,[
        	AC_DEFINE(HAVE_MUSICBRAINZ, 1, [have MusicBrainz])
        	MUSICBRAINZ_LIBS="-lmusicbrainz"
		have_mb=true
        ])
  ], [])
fi
AC_SUBST(MUSICBRAINZ_LIBS)

dnl --------- TUNEPIMP/MUSICBRAINZ CHECK END -----------


dnl --------- K3b debugging stuff (only for developers) ----

AC_ARG_WITH(
	k3b-debug, 
	AS_HELP_STRING(
		[--with-k3b-debug], 
		[Enable additional K3b debugging output and functionality (default=no)]),
	[use_k3b_debug=$withval], 
	[use_k3b_debug=no]
)
if test "$use_k3b_debug" = "yes"; then
	AC_DEFINE(K3B_DEBUG, "1", [K3b additional debugging support])
fi

dnl --------------------------------------------------------




dnl --------------- libiconv check -------------------------

AC_CHECK_HEADERS(iconv.h)

dnl --------------------------------------------------------


#AC_DEFINE(LIBK3B_VERSION, "0.11.98", [k3b library version])
#AC_SUBST(LIBK3B_VERSION, 0.11.98)
#AC_CONFIG_FILES([k3b/libk3b/libk3b.pc])

KDE_ENABLE_HIDDEN_VISIBILITY
