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(kaffeine-0.8.8, "3.5.7") 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.3)
AC_PATH_KDE
dnl =======================================================
dnl FILE: configure.in.in
dnl =======================================================

#MIN_CONFIG(3.3)
CXXFLAGS="$CXXFLAGS $KDE_DEFAULT_CXXFLAGS"

if test "$build_arts" = "yes"; then
    AC_DEFINE(USE_ARTS, 1, [If we use arts volume])
    LIB_ARTS="-lartskde"
    AC_SUBST(LIB_ARTS)
fi

KDE_INIT_DOXYGEN([The API Reference], [Version $VERSION])

dnl =======================================================
dnl FILE: ./kaffeine/configure.in.in
dnl =======================================================

dnl -----------
dnl basic stuff
dnl -----------

KDE_ENABLE_HIDDEN_VISIBILITY

AC_ARG_VAR([PKG_CONFIG], [Path to pkg-config])

if test -z "$PKG_CONFIG" ; then
	PKG_CONFIG="pkg-config"
fi

AC_MSG_CHECKING([for pkg-config])

if ! "$PKG_CONFIG" --version ; then
	echo ""
	echo "---------------------------------------------------------------------"
	echo "ERROR: Could not find pkg-config. Make sure it is in your path or set"
	echo "the PKG_CONFIG environment variable to the full path to pkg-config."
	echo "---------------------------------------------------------------------"
	echo ""
	AC_MSG_ERROR([could not find pkg-config])
fi

AC_ARG_WITH([xinit-workaround],
  [AS_HELP_STRING([--with-xinit-workaround],
    [use this flag if Kaffeine hangs at startup and you are using XFree86 4.4 or X.Org 6.7.0])],,
  [with_xinit_workaround=no])

if test "$with_xinit_workaround" = "yes" ; then
	AC_DEFINE([XINIT_WKRND],,[workaround buggy X server])
fi

dnl ------------------------
dnl check for DPMS extension
dnl ------------------------

AC_ARG_WITH([dpms], [AS_HELP_STRING([--without-dpms], [build without DPMS support])],,
  [with_dpms=yes])

CFLAGS_DPMS=""
LIB_DPMS=""

if test "$with_dpms" != "no" ; then
	AC_MSG_CHECKING([for DPMS extension])

	if "$PKG_CONFIG" --exists xext ; then
		with_dpms=yes
		CFLAGS_DPMS=`"$PKG_CONFIG" --cflags xext`
		LIB_DPMS=`"$PKG_CONFIG" --libs xext`
		AC_DEFINE([HAVE_DPMS],,[DPMS extension available])
		AC_MSG_RESULT([yes])
	else
		with_dpms=no
		AC_MSG_RESULT([no])
	fi
fi

AC_SUBST([CFLAGS_DPMS])
AC_SUBST([LIB_DPMS])

dnl -------------------------
dnl check for XTest extension
dnl -------------------------

AC_ARG_WITH([xtest], [AS_HELP_STRING([--without-xtest], [build without XTest support])],,
  [with_xtest=yes])

CFLAGS_XTEST=""
LIB_XTEST=""

if test "$with_xtest" != "no" ; then
	AC_MSG_CHECKING([for XTest extension])

	if "$PKG_CONFIG" --exists xtst ; then
		with_xtest=yes
		CFLAGS_XTEST=`"$PKG_CONFIG" --cflags xtst`
		LIB_XTEST=`"$PKG_CONFIG" --libs xtst`
		AC_DEFINE([HAVE_XTEST],,[XTest extension available])
		AC_MSG_RESULT([yes])
	else
		with_xtest=no
		AC_MSG_RESULT([no])
	fi
fi

AC_SUBST([CFLAGS_XTEST])
AC_SUBST([LIB_XTEST])

dnl ----------------------------
dnl check for Xinerama extension
dnl ----------------------------

AC_ARG_WITH([xinerama], [AS_HELP_STRING([--without-xinerama], [build without Xinerama support])],,
  [with_xinerama=yes])

CFLAGS_XINERAMA=""
LIB_XINERAMA=""

if test "$with_xinerama" != "no" ; then
	AC_MSG_CHECKING([for Xinerama extension])

	if "$PKG_CONFIG" --exists xinerama ; then
		with_xinerama=yes
		CFLAGS_XINERAMA=`"$PKG_CONFIG" --cflags xinerama`
		LIB_XINERAMA=`"$PKG_CONFIG" --libs xinerama`
		AC_DEFINE([HAVE_XINERAMA],,[Xinerama extension available])
		AC_MSG_RESULT([yes])
	else
		with_xinerama=no
		AC_MSG_RESULT([no])
	fi
fi

AC_SUBST([CFLAGS_XINERAMA])
AC_SUBST([LIB_XINERAMA])

dnl ------------------
dnl check for xine-lib
dnl ------------------

AC_MSG_CHECKING([for xine-lib])

CFLAGS_XINE=""
LIB_XINE=""

if "$PKG_CONFIG" --exists "libxine >= 1.1.9" ; then
	CFLAGS_XINE=`"$PKG_CONFIG" --cflags libxine`
	LIB_XINE=`"$PKG_CONFIG" --libs libxine`
	AC_MSG_RESULT([yes])
else
	AC_MSG_RESULT([no])

	echo ""
	echo "---------------------------------------"
	echo "ERROR: Could not find xine-lib >= 1.1.9"
	echo "---------------------------------------"
	echo ""

	AC_MSG_ERROR([could not find xine-lib])
fi

AC_SUBST([CFLAGS_XINE])
AC_SUBST([LIB_XINE])

dnl -------------
dnl check for xcb
dnl -------------

AC_ARG_WITH([xcb], [AS_HELP_STRING([--without-xcb], [disable xcb support (not recommended)])],,
  [with_xcb=yes])

AC_MSG_CHECKING([for xcb and xine-lib >= 1.1.9])

CFLAGS_XCB=""
LIB_XCB=""

if test "$with_xcb" != "no" ; then
	if "$PKG_CONFIG" --exists "xcb >= 1.0" ; then
		with_xcb=yes
		CFLAGS_XCB=`"$PKG_CONFIG" --cflags xcb`
		LIB_XCB=`"$PKG_CONFIG" --libs xcb`
		AC_DEFINE([HAVE_XCB],,[xcb available])
		AC_MSG_RESULT([yes])
	else
		with_xcb=no
		AC_MSG_RESULT([no])
	fi
fi

AC_SUBST([CFLAGS_XCB])
AC_SUBST([LIB_XCB])

AM_CONDITIONAL([with_xcb], [test "$with_xcb" = "yes"])

dnl ---------------------
dnl check for DVB headers
dnl ---------------------

AC_ARG_WITH([dvb], [AS_HELP_STRING([--without-dvb], [build without DVB support])],,
  [with_dvb=yes])

if test "$with_dvb" != "no" ; then
	KDE_CHECK_HEADER([linux/dvb/frontend.h], [with_dvb=yes]
	  [AC_DEFINE([HAVE_DVB],,[DVB headers installed])], [with_dvb=no])
fi

AM_CONDITIONAL([with_dvb], [test "$with_dvb" = "yes"])

dnl -------------------
dnl check for gstreamer
dnl -------------------

AC_ARG_WITH([gstreamer], [AS_HELP_STRING([--without-gstreamer], [disable GStreamer player part])],,
  [with_gstreamer=yes])

CFLAGS_GSTREAMER=""
LIB_GSTREAMER=""

if test "$with_gstreamer" != "no" ; then
	AC_MSG_CHECKING([for GStreamer])

	if "$PKG_CONFIG" --exists "gstreamer-0.10 gstreamer-plugins-base-0.10"; then
		with_gstreamer=yes
		CFLAGS_GSTREAMER=`"$PKG_CONFIG" --cflags gstreamer-0.10 gstreamer-plugins-base-0.10`
		LIB_GSTREAMER=`"$PKG_CONFIG" --libs gstreamer-0.10 gstreamer-plugins-base-0.10`
		AC_MSG_RESULT([yes])
	else
		with_gstreamer=no
		AC_MSG_RESULT([no])
	fi
fi

AC_SUBST([CFLAGS_GSTREAMER])
AC_SUBST([LIB_GSTREAMER])

AM_CONDITIONAL([with_gstreamer], [test "$with_gstreamer" = "yes"])

dnl --------------------
dnl check for cdparanoia
dnl --------------------

KDE_CHECK_HEADER([cdio/cdda.h], [with_cdparanoia=yes], [with_cdparanoia=no])

if test "$with_cdparanoia" != "yes" ; then
	echo ""
	echo "-----------------------------------------"
	echo "ERROR: Could not find cdparanoia headers."
	echo "-----------------------------------------"
	echo ""

	AC_MSG_ERROR([could not find cdparanoia headers])
fi

dnl ----------------------------
dnl check for Ogg Vorbis encoder
dnl ----------------------------

AC_ARG_WITH([oggvorbis], [AS_HELP_STRING([--without-oggvorbis], [build without Ogg Vorbis support])],,
  [with_oggvorbis=yes])

CFLAGS_OGGVORBIS=""
LIB_OGGVORBIS=""

if test "$with_oggvorbis" != "no" ; then
	AC_MSG_CHECKING([for Ogg/Vorbis encoder])

	if "$PKG_CONFIG" --exists vorbisenc ; then
		with_oggvorbis=yes
		CFLAGS_OGGVORBIS=`"$PKG_CONFIG" --cflags vorbisenc`
		LIB_OGGVORBIS=`"$PKG_CONFIG" --libs vorbisenc`
		AC_MSG_RESULT([yes])
	else
		with_oggvorbis=no
		AC_MSG_RESULT([no])
	fi
fi

AC_SUBST([CFLAGS_OGGVORBIS])
AC_SUBST([LIB_OGGVORBIS])

AM_CONDITIONAL([with_oggvorbis], [test "$with_oggvorbis" = "yes"])

dnl --------------
dnl check for LAME
dnl --------------

AC_ARG_WITH([lame], [AS_HELP_STRING([--without-lame], [build without LAME support])],,
  [with_lame=yes])

LIB_LAME=""

if test "$with_lame" != "no" ; then
	KDE_CHECK_HEADER([lame/lame.h], [with_lame=yes], [with_lame=no])
fi

if test "$with_lame" = "yes" ; then
	KDE_CHECK_LIB([mp3lame], [lame_init], [LIB_LAME="-lmp3lame"], [with_lame=no], [-lm])
fi

AC_SUBST([LIB_LAME])

AM_CONDITIONAL([with_lame], [test "$with_lame" = "yes"])
KDE_CREATE_SUBDIRSLIST
AM_CONDITIONAL(doc_SUBDIR_included, test "x$doc_SUBDIR_included" = xyes)
AM_CONDITIONAL(kaffeine_SUBDIR_included, test "x$kaffeine_SUBDIR_included" = xyes)
AM_CONDITIONAL(po_SUBDIR_included, test "x$po_SUBDIR_included" = xyes)
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ doc/Makefile ])
AC_CONFIG_FILES([ doc/kaffeine/Makefile ])
AC_CONFIG_FILES([ kaffeine/Makefile ])
AC_CONFIG_FILES([ kaffeine/images/Makefile ])
AC_CONFIG_FILES([ kaffeine/mimetypes/Makefile ])
AC_CONFIG_FILES([ kaffeine/mimetypes/application/Makefile ])
AC_CONFIG_FILES([ kaffeine/protocols/Makefile ])
AC_CONFIG_FILES([ kaffeine/servicemenus/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/audiobrowser/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/disc/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/disc/plugins/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/disc/plugins/mp3lame/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/disc/plugins/oggvorbis/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/lib/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/lib/libdvbapi/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/lib/libdvben50221/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/lib/libucsi/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/lib/libucsi/atsc/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/lib/libucsi/dvb/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/lib/libucsi/mpeg/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/plugins/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/plugins/epg/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvb/plugins/stream/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/input/dvbclient/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/player-parts/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/player-parts/dummy-part/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/player-parts/gstreamer-part/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/player-parts/kaffeine-part/Makefile ])
AC_CONFIG_FILES([ kaffeine/src/player-parts/xine-part/Makefile ])
AC_CONFIG_FILES([ po/Makefile ])
AC_OUTPUT
echo ""
echo "-------------------------------------------------------"
echo "Kaffeine configure results:"
echo ""

if test "$with_xcb" = "yes" ; then
	echo "Build with xcb support:                             yes"
else
	echo "Build with xcb support:                              no"
	echo "IMPORTANT: this is strongly discouraged"
fi

if test "$with_dpms" = "yes" ; then
	echo "Build with DPMS support:                            yes"
else
	echo "Build with DPMS support:                             no"
fi

if test "$with_xtest" = "yes" ; then
	echo "Build with XTest support:                           yes"
else
	echo "Build with XTest support:                            no"
fi

if test "$with_xinerama" = "yes" ; then
	echo "Build with Xinerama support:                        yes"
else
	echo "Build with Xinerama support:                         no"
fi

if test "$with_dvb" = "yes" ; then
	echo "Build with DVB support:                             yes"
else
	echo "Build with DVB support:                              no"
fi

if test "$with_gstreamer" = "yes" ; then
	echo "Build GStreamer player part:                        yes"
	echo "IMPORTANT: the GStreamer player part is experimental"
else
	echo "Build GStreamer player-part:                         no"
fi

if test "$with_oggvorbis" = "yes" ; then
	echo "Build Ogg Vorbis encoder plugin:                    yes"
else
	echo "Build Ogg Vorbis encoder plugin:                     no"
fi

if test "$with_lame" = "yes" ; then
	echo "Build LAME encoder plugin:                          yes"
else
	echo "Build LAME encoder plugin:                           no"
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 ":"`kde-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 KDEDIRS contains it, e.g. export KDEDIRS=$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
