dnl =======================================================
dnl FILE: ./admin/configure.in.min
dnl =======================================================

dnl    This file is part of the KDE libraries/packages
dnl    Copyright (C) 2001 Stephan Kulow (coolo@kde.org)
 
dnl    This file is free software; you can redistribute it and/or
dnl    modify it under the terms of the GNU Library General Public
dnl    License as published by the Free Software Foundation; either
dnl    version 2 of the License, or (at your option) any later version.
 
dnl    This library is distributed in the hope that it will be useful,
dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl    Library General Public License for more details.
 
dnl    You should have received a copy of the GNU Library General Public License
dnl    along with this library; see the file COPYING.LIB.  If not, write to
dnl    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
dnl    Boston, MA 02110-1301, USA.

# Original Author was Kalle@kde.org
# I lifted it in some mater. (Stephan Kulow)
# I used much code from Janos Farkas

dnl Process this file with autoconf to produce a configure script.

AC_INIT(acinclude.m4) dnl a source file from your sub dir

dnl This is so we can use kde-common
AC_CONFIG_AUX_DIR(admin)

dnl This ksh/zsh feature conflicts with `cd blah ; pwd`
unset CDPATH

dnl Checking host/target/build systems, for make, install etc.
AC_CANONICAL_SYSTEM 
dnl Perform program name transformation
AC_ARG_PROGRAM

dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(k3b-1.0.5, "3.5.9") dnl searches for some needed programs

KDE_SET_PREFIX

dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done

dnl Checks for programs.
AC_CHECK_COMPILERS
AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
KDE_PROG_LIBTOOL

dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files
AM_KDE_WITH_NLS

KDE_USE_QT(3.2)
AC_PATH_KDE
dnl =======================================================
dnl FILE: configure.in.in
dnl =======================================================

#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
	KDE_CHECK_HEADERS(artsc/artsc.h,
		[arts_available=yes
	 	 ARTS_LIBS="-lartsc"],
		[arts_available=no]
	)
fi
AC_SUBST(ARTS_LIBS)
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
dnl =======================================================
dnl FILE: ./libk3b/configure.in.in
dnl =======================================================

AC_CHECK_FUNCS(stat64)
AC_CHECK_HEADERS(sys/vfs.h)
AC_CHECK_HEADERS(sys/statvfs.h)
dnl =======================================================
dnl FILE: ./libk3b/plugin/libsamplerate/configure.in.in
dnl =======================================================

LIBS="-lm $all_libraries"

AC_CHECK_DECL(lrint,
          AC_DEFINE(HAVE_LRINT,1,[Define if lrint is supported]),
          AC_DEFINE(HAVE_LRINT,0,[Define if lrint is not supported]),
          [#include <math.h>]
)

AC_CHECK_DECL(lrintf,
          AC_DEFINE(HAVE_LRINTF,1,[Define if lrintf is supported]),
          AC_DEFINE(HAVE_LRINTF,0,[Define if lrintf is not supported]),
          [#include <math.h>]
)
dnl =======================================================
dnl FILE: ./libk3b/videodvd/configure.in.in
dnl =======================================================

AC_ARG_WITH(
	libdvdread, 
	AS_HELP_STRING(
		[--without-libdvdread], 
		[build K3b without libdvdread (Video DVD ripping) support (default=no)]),
	[ac_cv_use_libdvdread=$withval], 
	[ac_cv_use_libdvdread=yes]
)

have_libdvdread=no
if test "$ac_cv_use_libdvdread" = "yes"; then
	KDE_CHECK_HEADERS(dvdread/dvd_reader.h, 
	[
		AC_CHECK_LIB(dvdread,
			DVDOpen,
			[
        	           AC_DEFINE(HAVE_LIBDVDREAD,1,[Defined if you have libdvdread headers and libs installed.])
	        	   have_libdvdread=yes
			]
		)
	])
fi
AM_CONDITIONAL(include_videodvdrip, [test x$have_libdvdread = xyes])

#if test "$have_libdvdread" = "no"; then
#   AC_MSG_ERROR([Could not find libdvdread. Please install.])
#   DO_NOT_COMPILE="$DO_NOT_COMPILE k3b"
#fi
dnl =======================================================
dnl FILE: ./libk3bdevice/configure.in.in
dnl =======================================================

dnl FIXME: only make the linux header check on linux systems.

linux_scsi=no
AC_MSG_CHECKING(for linux scsi headers)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([
	#include <linux/version.h>
	#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,50)
	typedef unsigned char u8;
	#endif
	#include <sys/types.h>
	#include <linux/../scsi/scsi.h> /* cope with silly includes */
	],
	[],
	[linux_scsi=yes])
AC_MSG_RESULT($linux_scsi)

case "$host_os" in
freebsd*|dragonfly*)
	# I'll be damned if lousy coding prevents us from running
	# this application.
	linux_scsi=yes
	;;
esac

if test "x$linux_scsi" = "xno" ; then
	DO_NOT_COMPILE="$DO_NOT_COMPILE k3b"
fi
AC_LANG_RESTORE

dnl - find the cam_* functions
AC_CHECK_FUNC(cam_close_device,
	[CAM_LIB=""],
	[AC_CHECK_LIB(cam, cam_close_device, [CAM_LIB=-lcam], [CAM_LIB=""])]
	)
AC_SUBST(CAM_LIB)



dnl === check for resmgr - begin ============
AC_ARG_WITH(
	resmgr, 
	AS_HELP_STRING([--without-resmgr], [build K3b without ResMgr support (default=no)]), 
	[ac_cv_use_resmgr=$withval], 
	[ac_cv_use_resmgr=yes]
)

if test "$ac_cv_use_resmgr" = "yes"; then
  RESMGR_LIB=""
  KDE_CHECK_HEADERS(resmgr.h, [
         KDE_CHECK_LIB(resmgr,rsm_open_device,[
                 RESMGR_LIB="-lresmgr"
                 AC_DEFINE(HAVE_RESMGR,1,[defined if you have resmgr libraries and headers])
         ])
  ])
  AC_SUBST(RESMGR_LIB)
fi
dnl === check for resmgr - end ============





# HAL check from tdebase/kioslave/media

AC_ARG_WITH(
	hal, 
	AS_HELP_STRING(
		[--without-hal], 
		[build K3b without HAL support (default=no)]),
	[ac_cv_use_hal=$withval], 
	[ac_cv_use_hal=yes]
)

if test "x$ac_cv_use_hal" = "xyes" ; then

########### Check for the HAL

  AC_MSG_CHECKING(for the HAL)

  hal_inc=NOTFOUND
  hal_lib=NOTFOUND
  hal=NOTFOUND

  search_incs="$kde_includes /usr/include /usr/include/hal /usr/local/include /usr/local/include/hal"
  AC_FIND_FILE(libhal.h libhal-storage.h, $search_incs, hal_incdir)

  if [test -r $hal_incdir/libhal.h] ; then
    HAL_INCS="-I$hal_incdir"
    hal_inc=FOUND
  fi

  if test -r $hal_incdir/libhal-storage.h ; then
    hal_storage_version=4
    grep LibHalVolume $hal_incdir/libhal-storage.h \
    > /dev/null 2>&1 && hal_storage_version=5
    if test $hal_storage_version = 4 ; then
      AC_DEFINE(HAL_0_4, , [HAL API version 0.4])
    fi
  fi

  search_libs="$kde_libraries /usr/lib64 /usr/lib /usr/local/lib /lib /lib64"
  AC_FIND_FILE(libhal.so, $search_libs, hal_libdir)

  if [test -r $hal_libdir/libhal.so] ; then
    HAL_LIBS="-L$hal_libdir -lhal"
    hal_lib=FOUND
  fi


  if [test $hal_inc = FOUND] && [test $hal_lib = FOUND] ; then
      AC_MSG_RESULT(headers $hal_incdir  libraries $hal_libdir)
  	hal=FOUND
  else
      AC_MSG_RESULT(searched but not found)
  fi

  AC_SUBST(HAL_INCS)
  AC_SUBST(HAL_LIBS)


########### Check for DBus

  AC_MSG_CHECKING(for DBus)

  dbus_inc=NOTFOUND
  dbus_lib=NOTFOUND
  dbus=NOTFOUND

  search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
  AC_FIND_FILE(dbus/dbus.h, $search_incs, dbus_incdir)

  search_incs_arch_deps="$kde_includes /usr/lib64/dbus-1.0/include /usr/lib/dbus-1.0/include /usr/local/lib/dbus-1.0/include"
  AC_FIND_FILE(dbus/dbus-arch-deps.h, $search_incs_arch_deps, dbus_incdir_arch_deps)

  if [test -r $dbus_incdir/dbus/dbus.h] && [test -r $dbus_incdir_arch_deps/dbus/dbus-arch-deps.h] ; then
    DBUS_INCS="-I$dbus_incdir -I$dbus_incdir_arch_deps"
    dbus_inc=FOUND
  fi

  search_libs="$kde_libraries /usr/lib64 /usr/lib /usr/local/lib /lib /lib64"
  AC_FIND_FILE(libdbus-1.so, $search_libs, dbus_libdir)

  if test -r $dbus_libdir/libdbus-1.so ; then
    DBUS_LIBS="-L$dbus_libdir -ldbus-1"
    dbus_lib=FOUND
  fi

  if [test $dbus_inc = FOUND] && [test $dbus_lib = FOUND] ; then
    AC_MSG_RESULT(headers $dbus_incdir $dbus_incdir_arch_deps  libraries $dbus_libdir)
    dbus=FOUND
  else
    AC_MSG_RESULT(searched but not found)
  fi

  AC_SUBST(DBUS_INCS)
  AC_SUBST(DBUS_LIBS)

########### Check for DBus-Qt bindings

  AC_MSG_CHECKING(for DBus-Qt bindings)

  dbusqt_inc=NOTFOUND
  dbusqt_lib=NOTFOUND
  dbusqt=NOTFOUND

  search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
  AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir)

  if test -r $dbusqt_incdir/dbus/connection.h ; then
    have_qt_patch=0
    grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \
    > /dev/null 2>&1 && have_qt_patch=1
    if test $have_qt_patch = 1 ; then
      DBUSQT_INCS="-I$dbusqt_incdir"
      dbusqt_inc=FOUND
    fi
  fi

  search_libs="$kde_libraries /usr/lib /usr/lib64 /usr/local/lib"
  AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir)

  if test -r $dbusqt_libdir/libdbus-qt-1.so ; then
    DBUSQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1"
    dbusqt_lib=FOUND
  fi

  if [test $dbusqt_inc = FOUND] && [test $dbusqt_lib = FOUND] ; then
    AC_MSG_RESULT(headers $dbusqt_incdir libraries $dbusqt_libdir)
    dbusqt=FOUND
  else
    AC_MSG_RESULT(searched but not found)
  fi

  AC_SUBST(DBUSQT_INCS)
  AC_SUBST(DBUSQT_LIBS)
fi

########### Check if media HAL backend sould be compiled

have_hal=no
HAL_DBUS_LIBS=""
if [test "x$hal" = "xFOUND"] && [test "x$dbus" = "xFOUND"] && [test "x$dbusqt" = "xFOUND"] && [ test $hal_storage_version = 5 ] ; then
  AC_DEFINE(HAVE_HAL, , [compile in HAL support])
  have_hal=yes
  HAL_DBUS_LIBS="$HAL_LIBS $DBUS_LIBS $DBUSQT_LIBS"
fi

AM_CONDITIONAL(include_HAL, [test x$have_hal = xyes])
AC_SUBST(HAL_DBUS_LIBS)

dnl =======================================================
dnl FILE: ./plugins/audiooutput/alsa/configure.in.in
dnl =======================================================

dnl --------- ALSA CHECK BEGIN -------------

AC_DEFUN([KDE_CHECK_ALSA],
[
  PKG_CHECK_MODULES([ALSA], [alsa >= 0.9], [have_alsa=yes], [have_alsa=no])
  AC_SUBST([ALSA_CFLAGS])
  AC_SUBST([ALSA_LIBS])
])

AC_ARG_WITH(alsa,
  [AS_HELP_STRING(--with-alsa,
    [enable support for ALSA output @<:@default=check@:>@])],
  [], with_alsa=check)

have_alsa=no
if test "x$with_alsa" != xno; then
  KDE_CHECK_ALSA

  if test "x$with_alsa" != xcheck && test "x$have_alsa" != xyes; then
    AC_MSG_FAILURE([--with-alsa was given, but test for ALSA failed])
  fi
fi

AM_CONDITIONAL(include_ALSA, [test "x$have_alsa" = "xyes"])

dnl --------- ALSA CHECK END ---------------
dnl =======================================================
dnl FILE: ./plugins/decoder/ffmpeg/configure.in.in
dnl =======================================================

dnl --------------- FFMPEG CHECK ---------------------------------

AC_ARG_WITH(
	ffmpeg, 
	AS_HELP_STRING(
		[--without-ffmpeg], 
		[build K3b without ffmpeg audio decoder support (default=no)]),
	[ac_cv_use_ffmpeg=$withval], 
	[ac_cv_use_ffmpeg=yes]
)

#
# The ffmpeg decoder plugin needs ffmpeg 0.4.9 or higher
#
have_ffmpeg=no
if test "$ac_cv_use_ffmpeg" = "yes"; then
	k3b_cxxflags_save="$CXXFLAGS"
	CXXFLAGS="$CXXFLAGS -D__STDC_CONSTANT_MACROS"
	AC_MSG_CHECKING(for ffmpeg >= 0.4.9)
	AC_LANG_SAVE
	AC_LANG_CPLUSPLUS
	AC_COMPILE_IFELSE( 
		extern "C" {
		#include <libavformat/avformat.h>
		#include <libavcodec/avcodec.h>
		}

		int main() {
		  AVFormatContext* fc = 0;
		  AVPacket* p = 0;
		  av_register_all();
		  return av_read_frame( fc, p );
		},
	[ffmpeg_compiles=yes], [ffmpeg_compiles=no] )
	OLD_LIBS=$LIBS
	LIBS="-lavformat -lavcodec $LIBS"
	AC_LINK_IFELSE( 
		extern "C" {
		#include <libavformat/avformat.h>
		#include <libavcodec/avcodec.h>
		}

		int main() {
		  AVFormatContext* fc = 0;
		  AVPacket* p = 0;
		  av_register_all();
		  return av_read_frame( fc, p );
		},
	[ffmpeg_links=yes], [ffmpeg_links=no] )
	AC_LANG_RESTORE
	LIBS=$OLD_LIBS
	have_ffmpeg=$ffmpeg_links
	AC_MSG_RESULT($have_ffmpeg)
	CXXFLAGS=$k3b_cxxflags_save
fi
AM_CONDITIONAL(include_FFMPEG, [test x$have_ffmpeg = xyes])

dnl --------------- FFMPEG CHECK END ------------------------------

AC_ARG_ENABLE(
	ffmpeg-all-codecs, 
	AS_HELP_STRING(
		[--enable-ffmpeg-all-codecs], 
		[Build K3b's ffmeg decoder plugin with all audio codecs enabled (default=disabled)]),
	[AC_DEFINE(K3B_FFMPEG_ALL_CODECS, 1, [Defined if all ffmpeg codecs should be allowed])
	 enable_ffmpeg_all_codecs=yes], 
	[enable_ffmpeg_all_codecs=no]
)
dnl =======================================================
dnl FILE: ./plugins/decoder/flac/configure.in.in
dnl =======================================================

dnl === test for FLAC++ and FLAC - begin ====
AC_ARG_WITH(
	flac, 
	AS_HELP_STRING([--without-flac], [build K3b without FLAC support (default=no)]), 
	[ac_cv_use_flac=$withval], 
	[ac_cv_use_flac=yes]
)

have_flac=no
if test "$ac_cv_use_flac" = "yes"; then
  KDE_CHECK_HEADERS(FLAC++/decoder.h, [
     AC_CHECK_LIB(FLAC,FLAC__stream_decoder_process_single,
	        have_flac=yes,[],$all_libraries)])

    AC_MSG_CHECKING(for libFLAC newer than 1.1.1)
    AC_CACHE_VAL(k3b_flac_new,
    [
	AC_LANG_SAVE
	AC_LANG_CPLUSPLUS
	AC_TRY_COMPILE(
	[
		#include <FLAC++/metadata.h>
	], [
		FLAC::Metadata::VorbisComment* vc;
		vc->get_vendor_string().get_field();
	], k3b_flac_new=no, k3b_flac_new=yes )
	AC_LANG_RESTORE
    ])
    AC_MSG_RESULT($k3b_flac_new)
    if test $k3b_flac_new = yes; then
	AC_DEFINE(FLAC_NEWER_THAN_1_1_1, 
		1,
		[Define to 1 if your flac library's version is newer than or equal to 1.1.2]
	)
    fi
else
    have_flac=no
fi

AM_CONDITIONAL(include_FLAC, [test x$have_flac = xyes])
dnl === test for FLAC++ and FLAC - end ====
dnl =======================================================
dnl FILE: ./plugins/decoder/libsndfile/configure.in.in
dnl =======================================================

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 ===
dnl =======================================================
dnl FILE: ./plugins/decoder/mp3/configure.in.in
dnl =======================================================

dnl === libmad MPEG decoder check - begin ===
AC_ARG_WITH(
	libmad, 
	AS_HELP_STRING([--without-libmad], [build K3b without libmad support (default=no)]), 
	[ac_cv_use_libmad=$withval], 
	[ac_cv_use_libmad=yes]
)

if test "$ac_cv_use_libmad" = "yes"; then
  MAD_LIB=""
  KDE_CHECK_HEADER(mad.h, [
	AC_CHECK_LIB(mad, mad_synth_frame, [
		MAD_LIB="-lmad"
		AC_DEFINE(HAVE_LIBMAD,1,[defined if you have libmad headers and libraries])],
		[],
		$all_libraries
	)
  ])
  AC_SUBST(MAD_LIB)

fi

AM_CONDITIONAL(include_MP3, [test -n "$MAD_LIB"])
dnl === libmad MPeg decoder check - end ===
dnl =======================================================
dnl FILE: ./plugins/decoder/musepack/configure.in.in
dnl =======================================================

dnl --------- MUSEPACK CHECK ---------------

AC_ARG_WITH(
	musepack, 
	AS_HELP_STRING(
		[--without-musepack], 
		[build K3b without Musepack audio support (default=no)]),
	[ac_cv_use_mpc=$withval], 
	[ac_cv_use_mpc=yes]
)

have_mpc=no
if test "$ac_cv_use_mpc" = "yes"; then

  dnl - search for both the new and the old naming -

  KDE_CHECK_HEADERS(mpcdec/mpcdec.h, [
  	AC_CHECK_LIB(mpcdec, mpc_decoder_setup, [
  		have_mpc=yes
		MPC_LIBS="-lmpcdec"
		AC_DEFINE(
			MPC_HEADER_FILE, 
			<mpcdec/mpcdec.h>, 
			[The header to include for MPC decoding.])
		],
		[], [], [])
  ])

  if test "$have_mpc" = "no"; then
    KDE_CHECK_HEADERS(mpc/mpcdec.h, [
        AC_CHECK_LIB(mpcdec, mpc_decoder_setup, [
                have_mpc=yes
                MPC_LIBS="-lmpcdec"
                AC_DEFINE(
                        MPC_HEADER_FILE,
                        <mpc/mpcdec.h>,
                        [The header to include for MPC decoding.])
                ],
                [], [], [])
    ])
  fi
	
  if test "$have_mpc" = "no"; then
    KDE_CHECK_HEADERS(musepack/musepack.h, [
    	  AC_CHECK_LIB(musepack, mpc_decoder_setup, [
  		  have_mpc=yes
		  MPC_LIBS="-lmusepack"
		  AC_DEFINE(
			  MPC_HEADER_FILE, 
			  <musepack/musepack.h>, 
			  [The header to include for MPC decoding.]
		  )
		  AC_DEFINE(
			  mpc_bool_t,
			  BOOL,
			  [backwards compatibility stuff]
		  )
  		  ], [], [])
    ])
  fi
fi
AC_SUBST(MPC_LIBS)

AM_CONDITIONAL(include_MPC, [test x$have_mpc = xyes])

dnl --------- MUSEPACK CHECK END -----------
dnl =======================================================
dnl FILE: ./plugins/decoder/ogg/configure.in.in
dnl =======================================================

dnl === Ogg Vorbis Test - Begin ===
AC_ARG_WITH(
	oggvorbis, 
	AS_HELP_STRING([--without-oggvorbis], [build K3b without OggVorbis support (default=no)]), 
	[ac_cv_use_oggvorbis=$withval], 
	[ac_cv_use_oggvorbis=yes]
)

if test "$ac_cv_use_oggvorbis" = "yes"; then

  AC_MSG_CHECKING(for ogg/vorbis headers)
  ogg_vorbis=no
  AC_TRY_COMPILE([
  		#include <vorbis/codec.h>
  		#include <vorbis/vorbisfile.h>
                ],[
                ],[
                ogg_vorbis=yes
                ])
  AC_MSG_RESULT($ogg_vorbis)
  if test x$ogg_vorbis = xyes; then
     dnl we need the ogg_vorbis_lib because otherwise we override LIBS !
     AC_CHECK_LIB(vorbisfile,ov_open,ogg_vorbis_lib=yes,
                  ogg_vorbis=no,[$all_libraries -lvorbisfile -lvorbis -logg])
  fi
  if test x$ogg_vorbis = xyes; then
	AC_DEFINE(OGG_VORBIS,1,[Define if you have ogg/vorbis installed])
  fi
fi

AM_CONDITIONAL(include_OGG, [test x$ogg_vorbis = xyes])
dnl === Ogg Vorbis Test - End ===
dnl =======================================================
dnl FILE: ./plugins/encoder/lame/configure.in.in
dnl =======================================================

dnl === test for LAME - begin ====
AC_ARG_WITH(
	lame, 
	AS_HELP_STRING([--without-lame], [build K3b without LAME support (default=no)]), 
	[ac_cv_use_lame=$withval], 
	[ac_cv_use_lame=yes]
)

have_lame=no
if test "$ac_cv_use_lame" = "yes"; then
  KDE_CHECK_HEADERS(lame/lame.h, [
  	AC_CHECK_LIB(mp3lame, lame_init, [
  		have_lame=yes
  		AC_DEFINE(HAVE_LAME,1,[defined if you have the lame header and lib])
  		], [], $all_libraries -lm)
  ])
fi

AM_CONDITIONAL(include_LAME, [test x$have_lame = xyes])
dnl === test for LAME - end ====
dnl =======================================================
dnl FILE: ./src/fastscale/configure.in.in
dnl =======================================================

#
# Imlib/Mosfet scaling
#
AM_PROG_AS

# MMX test duped from tdelibs/tdefx - it should be probably moved to admin/
dnl -----------------------------------------------------
dnl IA32 checks
dnl -----------------------------------------------------

gv_asm_defs=
case $host_cpu in
  i*86 )
  AC_MSG_CHECKING(for assembler support for IA32 extensions)
 
  dnl MMX check
  AC_TRY_COMPILE(, [ __asm__("pxor %mm0, %mm0") ],
  [
    echo $ECHO_N "MMX yes$ECHO_C"
    AC_DEFINE_UNQUOTED(HAVE_X86_MMX, 1, [Define to 1 if the assembler supports MMX instructions.])
    gv_asm_defs="$gv_asm_defs -DHAVE_X86_MMX"
  ], [ echo $ECHO_N "MMX no$ECHO_C" ])

  dnl SSE check
  AC_TRY_COMPILE(,[ __asm__("xorps %xmm0, %xmm0") ],
  [
    echo $ECHO_N ", SSE yes$ECHO_C"
    AC_DEFINE_UNQUOTED(HAVE_X86_SSE, 1, [Define to 1 if the assembler supports SSE instructions.])
    gv_asm_defs="$gv_asm_defs -DHAVE_X86_SSE"
  ], [ echo $ECHO_N ", SSE no$ECHO_C" ])

  dnl SSE2 check
  AC_TRY_COMPILE(, [ __asm__("xorpd %xmm0, %xmm0") ],
  [
    echo $ECHO_N ", SSE2 yes$ECHO_C"
    AC_DEFINE_UNQUOTED(HAVE_X86_SSE2, 1, [Define to 1 if the assembler supports SSE2 instructions.])
    gv_asm_defs="$gv_asm_defs -DHAVE_X86_SSE2"
  ], [ echo $ECHO_N ", SSE2 no$ECHO_C" ])
 
  dnl 3DNOW check
  AC_TRY_COMPILE(, [ __asm__("femms") ],
  [
    echo $ECHO_N ", 3DNOW yes$ECHO_C"
    AC_DEFINE_UNQUOTED(HAVE_X86_3DNOW, 1, [Define to 1 if the assembler supports 3DNOW instructions.])
    gv_asm_defs="$gv_asm_defs -DHAVE_X86_3DNOW"
  ], [ echo $ECHO_N ", 3DNOW no$ECHO_C" ])
  echo
  ;;
  powerpc )
  AC_MSG_CHECKING(for assembler support for AltiVec instructions)
  dnl AltiVec check
  AC_TRY_COMPILE(, [ __asm__("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0" : : "r"(-1) ) ],
  [
    echo $ECHO_N " yes$ECHO_C"
    AC_DEFINE_UNQUOTED(HAVE_PPC_ALTIVEC, 1, [Define to 1 if the assembler supports AltiVec instructions.])
    gv_asm_defs="$gv_asm_defs -DHAVE_PPC_ALTIVEC"
  ], [ echo $ECHO_N ", AltiVec no$ECHO_C" ])
  echo
  ;;
esac

GV_ASM_DEFS="$gv_asm_defs"
AC_SUBST(GV_ASM_DEFS)
KDE_CREATE_SUBDIRSLIST
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ doc/Makefile ])
AC_CONFIG_FILES([ k3bsetup/Makefile ])
AC_CONFIG_FILES([ kfile-plugins/Makefile ])
AC_CONFIG_FILES([ kfile-plugins/k3bproject/Makefile ])
AC_CONFIG_FILES([ kioslaves/Makefile ])
AC_CONFIG_FILES([ kioslaves/videodvd/Makefile ])
AC_CONFIG_FILES([ libk3b/Makefile ])
AC_CONFIG_FILES([ libk3b/cddb/Makefile ])
AC_CONFIG_FILES([ libk3b/core/Makefile ])
AC_CONFIG_FILES([ libk3b/jobs/Makefile ])
AC_CONFIG_FILES([ libk3b/plugin/Makefile ])
AC_CONFIG_FILES([ libk3b/plugin/libsamplerate/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/audiocd/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/datacd/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/datadvd/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/mixedcd/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/movixcd/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/movixdvd/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/videocd/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/videocd/cdi/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/videocd/extra/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/videocd/mpeginfo/Makefile ])
AC_CONFIG_FILES([ libk3b/projects/videodvd/Makefile ])
AC_CONFIG_FILES([ libk3b/scripts/Makefile ])
AC_CONFIG_FILES([ libk3b/tools/Makefile ])
AC_CONFIG_FILES([ libk3b/tools/libisofs/Makefile ])
AC_CONFIG_FILES([ libk3b/videodvd/Makefile ])
AC_CONFIG_FILES([ libk3bdevice/Makefile ])
AC_CONFIG_FILES([ plugins/Makefile ])
AC_CONFIG_FILES([ plugins/audiooutput/Makefile ])
AC_CONFIG_FILES([ plugins/audiooutput/alsa/Makefile ])
AC_CONFIG_FILES([ plugins/audiooutput/arts/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/ffmpeg/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/flac/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/libsndfile/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/mp3/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/musepack/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/ogg/Makefile ])
AC_CONFIG_FILES([ plugins/decoder/wave/Makefile ])
AC_CONFIG_FILES([ plugins/encoder/Makefile ])
AC_CONFIG_FILES([ plugins/encoder/external/Makefile ])
AC_CONFIG_FILES([ plugins/encoder/lame/Makefile ])
AC_CONFIG_FILES([ plugins/encoder/ogg/Makefile ])
AC_CONFIG_FILES([ plugins/encoder/sox/Makefile ])
AC_CONFIG_FILES([ plugins/project/Makefile ])
AC_CONFIG_FILES([ plugins/project/audiometainforenamer/Makefile ])
AC_CONFIG_FILES([ plugins/project/audioprojectcddb/Makefile ])
AC_CONFIG_FILES([ src/Makefile ])
AC_CONFIG_FILES([ src/fastscale/Makefile ])
AC_CONFIG_FILES([ src/icons/Makefile ])
AC_CONFIG_FILES([ src/icons/actions/Makefile ])
AC_CONFIG_FILES([ src/konqi/Makefile ])
AC_CONFIG_FILES([ src/mimetypes/Makefile ])
AC_CONFIG_FILES([ src/misc/Makefile ])
AC_CONFIG_FILES([ src/option/Makefile ])
AC_CONFIG_FILES([ src/pics/Makefile ])
AC_CONFIG_FILES([ src/pics/73lab/Makefile ])
AC_CONFIG_FILES([ src/pics/RobsTheme/Makefile ])
AC_CONFIG_FILES([ src/pics/crystal/Makefile ])
AC_CONFIG_FILES([ src/pics/quant/Makefile ])
AC_CONFIG_FILES([ src/projects/Makefile ])
AC_CONFIG_FILES([ src/projects/kostore/Makefile ])
AC_CONFIG_FILES([ src/rip/Makefile ])
AC_CONFIG_FILES([ src/rip/videodvd/Makefile ])
AC_CONFIG_FILES([ src/sounds/Makefile ])
AC_OUTPUT
echo ""

echo "K3b - Include libdvdread (Video DVD ripping) support:"
if test "$have_libdvdread" = "yes"; then
	echo "K3b -                                        yes"
else
	echo "K3b -                                        no"
	if test "$ac_cv_use_libdvdread" = "yes"; then
		echo "K3b -     You are missing the libdvdread library."
	fi
fi
echo ""

if test -n "$RESMGR_LIB"; then
	echo "K3b - Resmgr support:                        yes"
else
	echo "K3b - Resmgr support:                         no"
fi

echo ""


if test x$have_hal = xyes; then
	echo "K3b - Compile HAL support                    yes"
else
	echo "K3b - Compile HAL support                     no"
if test "x$ac_cv_use_hal" = "xyes" ; then
	echo "K3b -     You are missing the HAL >= 0.5 headers and libraries"
	echo "K3b -     or the DBus Qt bindings."
fi
fi
echo ""

if test "x$have_alsa" = xyes; then
	echo "K3b - Audioplayer available (alsa)           yes"
else
	echo "K3b - Audioplayer available (alsa)            no"
fi
echo ""

echo "K3b - FFMpeg decoder plugin (decodes wma and others):"
if test  x$have_ffmpeg = xyes; then
        echo "K3b -                                        yes"
	if test x$enable_ffmpeg_all_codecs = xyes; then
		echo "K3b -     WARNING: You enabled all codecs in the ffmpeg decoder plugin."
		echo "K3b -              Be aware that most are not tested and track lengths"
		echo "K3b -              will be wrong in many cases."
	fi
else
        echo "K3b -                                         no"
if test "$ac_cv_use_ffmpeg" = "yes"; then
	if test "$ffmpeg_compiles" = "yes"; then
		echo "K3b -     You are missing the ffmpeg libraries."
		echo "K3b -     Make sure ffmpeg has been configured as a"
		echo "K3b -     shared library (which is not the default)."
	else
		echo "K3b -     You are missing the ffmpeg headers and libraries"
		echo "K3b -     version 0.4.9 or higher."
	fi
	echo "K3b -     The ffmpeg audio decoding plugin (decodes wma and"
	echo "K3b -     others) won't be compiled."
fi
fi
echo ""

if test x$have_flac = xyes; then
	echo "K3b - FLAC support:                          yes"
else
	echo "K3b - FLAC support:                           no"
if test "$ac_cv_use_flac" = "yes"; then
	if test "$have_flac" = "no"; then
		echo "K3b -     You are missing the FLAC++ headers and libraries."
		echo "K3b -     The FLAC decoding plugin won't be compiled."
	fi
fi
fi
echo ""

if $av_cv_sndfile; then
	echo "K3b - libsndfile audio decoding support:     yes"
else
	echo "K3b - libsndfile audio decoding support:      no"
if test "$ac_cv_use_sndfile" = "yes"; then
	echo "K3b -     You are missing the libsndfile headers and libraries."
	echo "K3b -     The libsndfile audio decoding plugin won't be compiled."
fi
fi
echo ""

if test -n "$MAD_LIB"; then
	echo "K3b - Mp3 decoding support (libmad):         yes"
else
	echo "K3b - Mp3 decoding support (libmad):          no"
if test "$ac_cv_use_libmad" = "yes"; then
	echo "K3b -     You are missing the libmad headers and libraries."
	echo "K3b -     The Mp3 decoding plugin won't be compiled."
fi
fi
echo ""

if test x$have_mpc = xyes; then
	echo "K3b - Musepack support:                      yes"
else
	echo "K3b - Musepack support:                       no"
if test "$ac_cv_use_mpc" = "yes"; then
	echo "K3b -     You are missing the Musepack headers and libraries >= 1.1."
	echo "K3b -     The Musepack audio decoding plugin won't be compiled."
fi
fi

echo ""

if test x$ogg_vorbis = xyes; then
	echo "K3b - Ogg Vorbis support:                    yes"
else
	echo "K3b - Ogg Vorbis support:                     no"
if test "$ac_cv_use_oggvorbis" = "yes"; then
	echo "K3b -     You are missing the Ogg-Vorbis headers and libraries."
	echo "K3b -     The Ogg Vorbis decoding and encoding plugins won't be compiled."
fi
fi
echo ""

if test x$have_lame = xyes; then
	echo "K3b - Lame Mp3 encoder plugin:               yes"
else
	echo "K3b - Lame Mp3 encoder plugin                 no"
if test "$ac_cv_use_lame" = "yes"; then
	echo "K3b -     You are missing the Lame headers and libraries."
	echo "K3b -     The Lame Mp3 encoding plugin won't be compiled."
fi
fi
echo ""

if test "$use_k3b_debug" = "yes"; then
	echo 	""
	echo	"K3b - K3B DEBUGGING ENABLED! THIS ENABLES ADDITIONAL DEBUGGING OUTPUT"
	echo	"K3b - AND FUNCTIONALITY WHICH IS ONLY INTENDED FOR K3B DEVELOPERS!"
	echo	"K3b - THIS MAY EVEN SLOW DOWN K3B IN SOME PLACES!"
	echo 	""
fi

if test "$cdrecord_suid_root" != "yes"; then
	echo    ""
	echo    "K3b - Suid root test for cdrecord, cdrdao, and wodim deactivated"
	echo    "K3b - This is NOT recommended although it might work out fine ;)"
	echo    ""
fi

if $have_taglib; then
	echo "K3b - Audio meta data reading with Taglib:   yes"
else
	echo "K3b - Audio meta data reading with Taglib:    no"
	echo "K3b -     You are missing the Taglib headers and libraries."
	echo "K3b -     The mp3 and flac decoder plugins will fall back to"
	echo "K3b -     using KMetaFileInfo."
fi

echo ""

echo "K3b - Audio resampling:"
if test -n "$LIBSAMPLERATE"; then
	echo "K3b -                    using installed version"
else
        echo "K3b -             using version bundled with K3b"
fi

echo ""

if test x$arts_available = xyes; then
	echo "K3b - Audioplayer available (aRts)           yes"
else
	echo "K3b - Audioplayer available (aRts)            no"
fi

echo ""

if test x$compile_k3bsetup = xyes; then
	echo "K3b - Compile K3bSetup 2:                    yes"
else
	echo "K3b - Compile K3bSetup 2:                     no"
fi

echo ""

if $have_mb; then
	echo "K3b - Tag guessing using MusicBrainz         yes"
else
	echo "K3b - Tag guessing using MusicBrainz          no"
if test "$ac_cv_use_musicbrainz" = "yes"; then
	echo "K3b -     You are missing the musicbrainz headers and libraries."
	echo "K3b -     K3b will be compiled without support for tag guessing."
fi
fi
# Check if KDE_SET_PREFIX was called, and --prefix was passed to configure
if test -n "$kde_libs_prefix" -a -n "$given_prefix"; then
  # And if so, warn when they don't match
  if test "$kde_libs_prefix" != "$given_prefix"; then
    # And if kde doesn't know about the prefix yet
    echo ":"`tde-config --path exe`":" | grep ":$given_prefix/bin/:" 2>&1 >/dev/null
    if test $? -ne 0; then
      echo ""
      echo "Warning: you chose to install this package in $given_prefix,"
      echo "but KDE was found in $kde_libs_prefix."
      echo "For this to work, you will need to tell KDE about the new prefix, by ensuring"
      echo "that TDEDIRS contains it, e.g. export TDEDIRS=$given_prefix:$kde_libs_prefix"
      echo "Then restart KDE."
      echo ""
    fi
  fi
fi

if test x$GXX = "xyes" -a x$kde_have_gcc_visibility = "xyes" -a x$kde_cv_val_qt_gcc_visibility_patched = "xno"; then
  echo ""
  echo "Your GCC supports symbol visibility, but the patch for Qt supporting visibility"
  echo "was not included. Therefore, GCC symbol visibility support remains disabled."
  echo ""
  echo "For better performance, consider including the Qt visibility supporting patch"
  echo "located at:"
  echo ""
  echo "http://bugs.kde.org/show_bug.cgi?id=109386"
  echo ""
  echo "and recompile all of Qt and KDE. Note, this is entirely optional and"
  echo "everything will continue to work just fine without it."
  echo ""
fi

if test "$all_tests" = "bad"; then
  if test ! "$cache_file" = "/dev/null"; then
    echo ""
    echo "Please remove the file $cache_file after changing your setup"
    echo "so that configure will find the changes next time."
    echo ""
  fi
else
  echo ""
  echo "Good - your configure finished. Start make now"
  echo ""
fi