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., 59 Temple Place - Suite 330,
dnl    Boston, MA 02111-1307, 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-0.11.9, "3.2.90") 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.1)
AC_PATH_KDE
dnl =======================================================
dnl FILE: configure.in.in
dnl =======================================================

#MIN_CONFIG(3.1)
CXXFLAGS="$CXXFLAGS $KDE_DEFAULT_CXXFLAGS"
AC_CHECK_SETENV
AC_CHECK_UNSETENV
dnl ============
dnl Machine type
dnl ============
 
ARCH_CFLAGS="$CFLAGS -O2 -funroll-all-loops -finline-functions -ffast-math"

case "$ARCH_TYPE" in
	i486)
		AC_DEFINE(ARCH_486, 1, [WE ARE BUILDING FOR A 486])
		OPTIMIZED_ARCH="YES"
	;;
	i586)
		AC_DEFINE(ARCH_586, 1, [WE ARE BUILDING FOR A PENTIUM])
		OPTIMIZED_ARCH="YES"
	;;
	i686)
		AC_DEFINE(ARCH_686, 1, [WE ARE BUILDING FOR A PPRO])
		OPTIMIZED_ARCH="YES"
		#EXTRA_CPU_CFLAGS=$(if $CC -march=i686 -S -o /dev/null -xc /dev/null > /dev/null; then echo "-march=i686"; fi)
	;;
	ppc)
		AC_DEFINE(ARCH_PPC, 1, [WE ARE BUILDING FOR A POWERPC])
		OPTIMIZED_ARCH="YES"
	;;
	sun4u)
		AC_DEFINE(ARCH_ULTRA, 1, [WE ARE BUILDING FOR A SUN ULTRASPARC])
		# Is there mpg123 optimization for UltraSparc?
	;;
esac

# ARCH_X86
if test "$ARCH_TYPE" = "i486" || test "$ARCH_TYPE" = "i586" || test "$ARCH_TYPE" = "i686"; then
	MPG123_PLAT_LIB="$MPG123_PLAT_LIB libmpx86.la"
fi
# ARCH_486
if test "$ARCH_TYPE" = "i486"; then
	MPG123_PLAT_LIB="$MPG123_PLAT_LIB libmp486.la"
	ARCH_CFLAGS="$ARCH_CFLAGS -DROT_I386 -DI386_ASSEM -DI486_OPT -DLINUX -DREAL_IS_FLOAT"
fi
# ARCH_586
if test "$ARCH_TYPE" = "i586" -a "$MMX_SUPPORT" = "no"; then
        MPG123_PLAT_LIB="$MPG123_PLAT_LIB libmp586.la"
	ARCH_CFLAGS="$ARCH_CFLAGS -DROT_I386 -DI386_ASSEM -DPENTIUM_OPT -DLINUX -DREAL_IS_FLOAT"
fi
# ARCH_586_MMX
if test "$ARCH_TYPE" = "i586" -a "$MMX_SUPPORT" = "yes"; then
	ARCH_CFLAGS="$ARCH_CFLAGS -DROT_I386 -DI386_ASSEM -DPENTIUM_OPT -DLINUX -DREAL_IS_FLOAT"
	MPG123_PLAT_LIB=libmp586mmx.la
fi
# ARCH_686
if test "$ARCH_TYPE" = "i686" -a "$MMX_SUPPORT" = "no"; then
	ARCH_CFLAGS="$ARCH_CFLAGS -DROT_I386 -DI386_ASSEM -DPENTIUM_OPT -DLINUX -DREAL_IS_FLOAT -march=pentiumpro"
	MPG123_PLAT_LIB=libmp686.la
fi
# ARCH_686_MMX
if test "$ARCH_TYPE" = "i686" -a "$MMX_SUPPORT" = "yes"; then
	ARCH_CFLAGS="$ARCH_CFLAGS -DROT_I386 -DI386_ASSEM -DPENTIUM_OPT -DUSE_MMX -DLINUX -DREAL_IS_FLOAT -march=pentiumpro"
	MPG123_PLAT_LIB=libmp686mmx.la
fi
# ARCH_PPC
if test "$ARCH_TYPE" = "ppc"; then
	ARCH_CFLAGS="$ARCH_CFLAGS -mcpu=ppc"
	MPG123_PLAT_LIB=libmpppc.la
fi
# ARCH_ULTRA
if test "$ARCH_TYPE" = "sun4u"; then
	:
	# nothing for now
fi
# ARCH_PLAIN
if test -z "$OPTIMIZED_ARCH"; then
	MPG123_PLAT_LIB=libmpplain.la
fi

AC_SUBST(ARCH_CFLAGS)

# this is run after libtool configure parts, which set AS to as
# which is the wrong one for us.  E.g. libtool doesn't recognize that as
# tag.  So we unset it here, so the below macro can set it.
save_AS=$AS
unset AS
ifdef([AM_PROG_AS],[AM_PROG_AS],[])
#if the macro did set something useful fallback.
test -z "$AS" && AS=$save_AS
#and if AS was set to as by the macro, and we have a saved value,
#it's likely it contains a better guess (or it's also as)
test "x$AS" = xas && test -n "$save_AS" && AS=$save_AS


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)

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


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


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,[-lvorbisfile -lvorbis -logg])
fi
if test x$ogg_vorbis = xyes; then
	AC_DEFINE(OGG_VORBIS,1,[Define if you have ogg/vorbis installed])
fi

AM_CONDITIONAL(include_OGG, [test x$ogg_vorbis = xyes])


dnl === libmad MPEG decoder check ===
MAD_LIB=""
AC_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])
	])
])
AC_SUBST(MAD_LIB)

AM_CONDITIONAL(include_MP3, [test -n "$MAD_LIB"])



dnl === test for FLAC++ and FLAC ====
have_flac=no
KDE_CHECK_HEADERS(FLAC++/decoder.h, [
   AC_CHECK_LIB(FLAC,FLAC__seekable_stream_decoder_process_single,
	        have_flac=yes)])
AM_CONDITIONAL(include_FLAC, [test x$have_flac = xyes])


dnl === check for id3lib ============
ID3_LIB=""
KDE_CHECK_HEADERS(id3/tag.h, [
	ID3_LIB="-lid3"
	AC_DEFINE(HAVE_LIBID3,1,[defined if you have libid3 headers and libraries])
])
AC_SUBST(ID3_LIB)


dnl === check for resmgr ============
RESMGR_LIB=""
AC_CHECK_HEADERS(resmgr.h, [
       AC_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)


dnl === check for libsamplerate ==========
LIBSAMPLERATE=""
AC_CHECK_HEADERS(samplerate.h, [
	AC_CHECK_LIB(samplerate, src_new, [
		LIBSAMPLERATE="-lsamplerate"	
		AC_DEFINE(HAVE_LIBSAMPLERATE,1,[defined if you have libsamplerate library and header])
	])
])
AC_SUBST(LIBSAMPLERATE)
AM_CONDITIONAL(compile_libsamplerate, [test -z "$LIBSAMPLERATE"])


dnl Find aRts
ARTS_LIBS=""
KDE_CHECK_HEADERS(arts/artsflow.h,
	[KDE_CHECK_HEADERS(arts/kmedia2.h,
		[arts_available=yes
	 	 ARTS_LIBS="-lartskde"],
		[arts_available=no]
	)]
)
AC_SUBST(ARTS_LIBS)

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])
dnl =======================================================
dnl FILE: ./src/plugin/libsamplerate/configure.in.in
dnl =======================================================

AC_MSG_CHECKING(for lrint)
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_MSG_CHECKING(for lrintf)
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>]
)

KDE_CREATE_SUBDIRSLIST
AM_CONDITIONAL(doc_SUBDIR_included, test "x$doc_SUBDIR_included" = xyes)
AM_CONDITIONAL(src_SUBDIR_included, test "x$src_SUBDIR_included" = xyes)
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ doc/Makefile ])
AC_CONFIG_FILES([ doc/k3b/Makefile ])
AC_CONFIG_FILES([ src/Makefile ])
AC_CONFIG_FILES([ src/audiodecoding/Makefile ])
AC_CONFIG_FILES([ src/audiodecoding/flac/Makefile ])
AC_CONFIG_FILES([ src/audiodecoding/mp3/Makefile ])
AC_CONFIG_FILES([ src/audiodecoding/ogg/Makefile ])
AC_CONFIG_FILES([ src/audiodecoding/wave/Makefile ])
AC_CONFIG_FILES([ src/audioencoding/Makefile ])
AC_CONFIG_FILES([ src/audioencoding/external/Makefile ])
AC_CONFIG_FILES([ src/audioencoding/ogg/Makefile ])
AC_CONFIG_FILES([ src/audioencoding/sox/Makefile ])
AC_CONFIG_FILES([ src/cdcopy/Makefile ])
AC_CONFIG_FILES([ src/cddb/Makefile ])
AC_CONFIG_FILES([ src/cdinfo/Makefile ])
AC_CONFIG_FILES([ src/core/Makefile ])
AC_CONFIG_FILES([ src/device/Makefile ])
AC_CONFIG_FILES([ src/dvdcopy/Makefile ])
AC_CONFIG_FILES([ src/icons/Makefile ])
AC_CONFIG_FILES([ src/images/Makefile ])
AC_CONFIG_FILES([ src/k3bsetup/Makefile ])
AC_CONFIG_FILES([ src/konqi/Makefile ])
AC_CONFIG_FILES([ src/mimetypes/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/crystal/Makefile ])
AC_CONFIG_FILES([ src/plugin/Makefile ])
AC_CONFIG_FILES([ src/plugin/libsamplerate/Makefile ])
AC_CONFIG_FILES([ src/projects/Makefile ])
AC_CONFIG_FILES([ src/projects/audiocd/Makefile ])
AC_CONFIG_FILES([ src/projects/datacd/Makefile ])
AC_CONFIG_FILES([ src/projects/datadvd/Makefile ])
AC_CONFIG_FILES([ src/projects/kostore/Makefile ])
AC_CONFIG_FILES([ src/projects/mixedcd/Makefile ])
AC_CONFIG_FILES([ src/projects/movixcd/Makefile ])
AC_CONFIG_FILES([ src/projects/movixdvd/Makefile ])
AC_CONFIG_FILES([ src/projects/songdb/Makefile ])
AC_CONFIG_FILES([ src/projects/videocd/Makefile ])
AC_CONFIG_FILES([ src/projects/videocd/cdi/Makefile ])
AC_CONFIG_FILES([ src/projects/videocd/mpeginfo/Makefile ])
AC_CONFIG_FILES([ src/projects/videodvd/Makefile ])
AC_CONFIG_FILES([ src/rip/Makefile ])
AC_CONFIG_FILES([ src/sounds/Makefile ])
AC_CONFIG_FILES([ src/tests/Makefile ])
AC_CONFIG_FILES([ src/tests/kpartplugins/Makefile ])
AC_CONFIG_FILES([ src/tests/kpartplugins/audiometainforenamer/Makefile ])
AC_CONFIG_FILES([ src/tests/kpartplugins/debugger/Makefile ])
AC_CONFIG_FILES([ src/tools/Makefile ])
AC_CONFIG_FILES([ src/tools/libisofs/Makefile ])
AC_CONFIG_FILES([ src/videoEncoding/Makefile ])
AC_OUTPUT
echo ""
echo ""
echo "Configure results:"
echo "------------------------------------------"
if test x$ogg_vorbis = xyes; then
	echo "Ogg Vorbis support:                    yes"
else
	echo "Ogg Vorbis support:                     no"
	echo "    You are missing the Ogg-Vorbis headers and libraries"
	echo "    The Ogg Vorbis decoding and encoding plugins won't be compiled."
fi

echo ""

if test -n "$MAD_LIB"; then
	echo "Mp3 decoding support (libmad):         yes"
	if test -n "$ID3_LIB"; then
		echo "    ID3 Tag handling with libid3:      yes"
	else
		echo "    ID3 Tag handling with libid3:       no"
		echo "    Using KFileMetaInfo instead."
	fi
else
	echo "Mp3 decoding support (libmad):          no"
	echo "    You are missing the libmad headers and libraries"
	echo "    The Mp3 decoding plugin won't be compiled."
fi

echo ""

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

echo ""

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

echo ""

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

echo ""

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

echo ""

if test x$compile_k3bsetup = xyes; then
	echo "Compile K3bSetup 2:                    yes"
else
	echo "Compile K3bSetup 2:                     no"
fi
echo "------------------------------------------"
echo ""
# 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 "$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
