dnl configure.in
dnl
dnl Copyright (C) 2004, 2005 Sylvain Cresto <scresto@gmail.com>
dnl This file is part of graveman!
dnl
dnl graveman! is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or
dnl (at your option) any later version.
dnl
dnl graveman! 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 General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with program; see the file COPYING. If not, write to the
dnl Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
dnl MA 02111-1307, USA.
dnl
dnl
dnl URL: http://www.nongnu.org/graveman/

AC_INIT(configure.in)
AC_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE

PACKAGE=graveman
VERSION=0.3.12-5

AM_INIT_AUTOMAKE([$PACKAGE], [$VERSION])

AC_ISC_POSIX
AC_PROG_CC
AC_HEADER_STDC
AC_FUNC_MMAP
AC_CANONICAL_HOST

dnl traitement ligne de commande
AC_ARG_ENABLE(mp3, AC_HELP_STRING([--disable-mp3], [Disable support for mp3 files (default=enabled)]),,
		enable_mp3=yes)
AC_ARG_ENABLE(ogg, AC_HELP_STRING([--disable-ogg], [Disable support for ogg vorbis files (default=enabled)]),,
		enable_ogg=yes)
AC_ARG_ENABLE(flac, AC_HELP_STRING([--disable-flac], [Disable support for FLAC files (default=enabled)]),,
		enable_flac=yes)
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debug mode (default=disabled)]),,
		debug=no)
AC_ARG_ENABLE(linux-ide, AC_HELP_STRING([--enable-linux-ide], [Enable linux-ide support mode (default=auto)]),
		linux_ide=yes,
		linux_ide=no)
AC_ARG_ENABLE(linux-scsi, AC_HELP_STRING([--enable-linux-scsi], [Enable linux-scsi support mode (default=auto)]),
		linux_scsi=yes,
		linux_scsi=no)

dnl prerequis pour gtk
pkg_modules="gtk+-2.0 >= 2.4.0 glib-2.0 >= 2.4.0 atk >= 1.0 pango >= 1.0 libglade-2.0 >= 2.4.0"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)

dnl: libz
AC_CHECK_LIB([z], [deflate],,
[ 
  echo "*** Error! You need to have zlib around."
  echo "*** Get it on http://www.gzip.org/zlib/ !"
  exit -1
])

dnl: libmng
AC_CHECK_LIB([mng], [mng_read],,
[
  echo "*** Error! You need to have libmng around."
  echo "*** Get it on http://libmng.sourceforge.net/ !"
  exit -1
])
AC_CHECK_HEADER([libmng.h],,
[
  echo "*** Error! You need to have libmng headers around."
  echo "*** Get them on http://libmng.sourceforce.net/ !"
  exit -1
])

dnl: libjpeg, required by libmng
AC_CHECK_HEADER([jpeglib.h],,
[
  echo "*** Error! You need to have jpeglib headers around."
  echo "*** Get them on http://www.ijg.org/ !"
  exit -1
])

dnl: native wav support
enable_wav=yes

dnl verification presence libid3tag (and id3tag.h)
if test "A$enable_mp3" = "Ayes"; then
  AC_CHECK_LIB([id3tag], [id3_frame_field], , mp3_available=no)
  AC_CHECK_HEADER([id3tag.h], , mp3_available=no)
  AC_CHECK_LIB([mad], [mad_decoder_init], , mp3_available=no)
  AC_CHECK_HEADER([mad.h], , mp3_available=no)
fi

AC_MSG_CHECKING(for mp3/id3 tag file support)

if test "A$enable_mp3" = "Ayes"; then
  if test "A$mp3_available" = "Ano"; then
 	AC_MSG_RESULT(no)
	echo "*** Warning: MP3 file support disabled"
	echo "*** Install libid3tag and libmad libraries to enable it"
	echo "*** Get them on http://www.underbit.com/products/mad/ !"
	enable_mp3="no"
  else
	AC_MSG_RESULT(yes)
	AC_DEFINE(ENABLE_MP3,1,[Define for mp3 file support])
  fi
else
 	AC_MSG_RESULT(no)
	echo "*** MP3 file support disabled on command line"
	echo "*** Use --enable-mp3 to enable it"
	enable_mp3="no"
fi

if test "A$enable_ogg" = "Ayes"; then
  dnl verification presence libogg (and ogg/ogg.h)
  AC_CHECK_LIB([ogg], [ogg_sync_init], , ogg_available=no)
  AC_CHECK_HEADER([ogg/ogg.h], , ogg_available=no)

  dnl verification presence libvorbis (and vorbis/codec.h)
  AC_CHECK_LIB([vorbis], [vorbis_info_init], , ogg_available=no)
  AC_CHECK_HEADER([vorbis/codec.h], , ogg_available=no)
fi

AC_MSG_CHECKING(for ogg vorbis file support)

if test "A$enable_ogg" = "Ayes"; then
  if test "A$ogg_available" = "Ano"; then
	AC_MSG_RESULT(no)
	echo "*** Warning: OGG VORBIS file support disabled"
	echo "*** Install libogg and libvorbis libraries to enable it"
	echo "*** Get it on http://www.vorbis.com !"
	enable_ogg="no"
  else
 	AC_MSG_RESULT(yes)
	AC_DEFINE(ENABLE_OGG,1,[Define for ogg vorbis file support])
  fi
else
 	AC_MSG_RESULT(no)
	echo "*** OGG VORBIS file support disabled on command line"
	echo "*** Use --enable-ogg to enable it"
	enable_ogg="no"
fi

if test "A$enable_flac" = "Ayes"; then
  dnl verification presence libFLAC (and FLAC/metadata.h)
  AC_CHECK_LIB([FLAC], [FLAC__metadata_iterator_get_block], , flac_available=no)
  AC_CHECK_HEADER([FLAC/metadata.h], , flac_available=no)
fi

AC_MSG_CHECKING(for FLAC file support)

if test "A$enable_flac" = "Ayes"; then
  if test "A$flac_available" = "Ano"; then
	AC_MSG_RESULT(no)
	echo "*** Warning: FLAC file support disabled"
	echo "*** Install libFLAC librarie to enable it"
	echo "*** Get it on http://flac.sourceforge.net !"
	enable_flac="no"
  else
 	AC_MSG_RESULT(yes)
	AC_DEFINE(ENABLE_FLAC,1,[Define for FLAC file support])
  fi
else
 	AC_MSG_RESULT(no)
	echo "*** FLAC file support disabled on command line"
	echo "*** Use --enable-flac to enable it"
	enable_flac="no"
fi

AC_MSG_CHECKING(for linux-ide device support)
if test "A$enable_linux_ide" = "Ayes"; then
 	AC_MSG_RESULT(yes)
	echo "*** LINUX-IDE devices support enabled on command line"
else
	if test "A$enable_linux_ide" = "Ano"; then
 		AC_MSG_RESULT(no)
		echo "*** LINUX-IDE devices support disabled on command line"
	else
		dnl host type test
		case "$host" in
			*-*-linux-gnu)
		 		AC_MSG_RESULT(yes (auto))
				enable_linux_ide=yes
				;;
			*)
				AC_MSG_RESULT(no (auto))
				enable_linux_ide=no
				;;
		esac
	 fi
fi

if test "A$enable_linux_ide" = "Ayes"; then
	AC_DEFINE(LINUX_IDE,1,[Define for linux ide devices support])
fi

AC_MSG_CHECKING(for linux-scsi device support)
if test "A$enable_linux_scsi" = "Ayes"; then
 	AC_MSG_RESULT(yes)
	echo "*** LINUX-SCSI devices support enabled on command line"
else
	if test "A$enable_linux_scsi" = "Ano"; then
 		AC_MSG_RESULT(no)
		echo "*** LINUX-SCSI devices support disabled on command line"
	else
		dnl host type test
		case "$host" in
			*-*-linux-gnu)
 				AC_MSG_RESULT(yes (auto))
				enable_linux_scsi=yes
				;;
			*)
				AC_MSG_RESULT(no (auto))
				enable_linux_scsi=no
				;;
		esac
	fi
fi

if test "A$enable_linux_scsi" = "Ayes"; then
	AC_DEFINE(LINUX_SCSI,1,[Define for linux scsi devices support])
fi

AC_MSG_CHECKING(for debug mode request)
if test "A$enable_debug" = "Ayes"; then
 	AC_MSG_RESULT(yes)
	echo "***"
	echo "*** DEBUG MODE enabled on command line"
	echo "***"
	AC_DEFINE(DEBUG,1,[Define for debug support])
else
 	AC_MSG_RESULT(no)
fi

dnl nls support
GRAVEMAN_LANG="cs de es fr hu it ja lt nl no pl pt_BR ru sv"
AC_ARG_ENABLE(nls, , [
ALL_LINGUAS=""
USE_NLS="no"
], [
 	ALL_LINGUAS="$GRAVEMAN_LANG"
	AM_GLIB_GNU_GETTEXT
])

GETTEXT_PACKAGE=[$PACKAGE]
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[gettext domain])

if test "A$enable_debug" = "A"; then
	enable_debug=no
	CFLAGS="-Wall"
else
	CFLAGS="-Wall -g"
fi

dnl Ecriture des fichiers
AC_OUTPUT([ m4/Makefile 
Makefile
desktop/Makefile
glade/Makefile
man/Makefile
pixmaps/Makefile
src/Makefile
themes/Makefile
])

echo "
Configuration for $PACKAGE $VERSION :
-----------------------------------

  Host System Type ................ : $host
  Compiler ........................ : $CC $CPPFLAGS
  Linker .......................... : $CC $LDFLAGS $LIBS
  GTK+ version .................... : `pkg-config --modversion gtk+-2.0`
  GLIB version .................... : `pkg-config --modversion glib-2.0`
  Ogg vorbis file support ......... : $enable_ogg
  Mp3 file support ................ : $enable_mp3
  FLAC file support ............... : $enable_flac
  Wav file support ................ : $enable_wav
  NLS/gettext ..................... : $USE_NLS
  Linux IDE/SCSI devices support .. : $enable_linux_ide/$enable_linux_scsi
  Debug mode ...................... : $enable_debug

  Now type 'make' to build $PACKAGE $VERSION,
  and then type 'make install' for installation.
"
