dnl Copyright (C) 1996-2002 Thomas Niederreiter <tn@xcdroast.org>
dnl 
dnl This program 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 of the License, or
dnl (at your option) any later version.
dnl 
dnl This program 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
dnl GNU General Public License for more details.
dnl 
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

dnl Template file for GNU Autoconf
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.53)

AC_INIT(xcdroast,0.98alpha16)
AC_CONFIG_SRCDIR([src/xcdroast.h])

AM_INIT_AUTOMAKE(xcdroast,0.98alpha16)
AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CC


dnl Compiler flags
AC_CANONICAL_HOST
if test "$GCC" = "yes"; then
	GNUCFLAGS="-Wall"

	case "$host" in
	*-*-darwin*)
		EXTRA_CFLAGS="$EXTRA_CFLAGS -g -traditional-cpp -fno-common"
		EXTRA_LDFLAGS="$EXTRA_LDFLAGS -framework CoreAudio"
		;;
	esac
fi

case "$host" in
*-*-hpux*)
	EXTRA_CFLAGS="-Dhpux"
	
	dnl check for hpux-alib and enable if found
	if test -d /opt/audio/include; then
		EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/audio/include"
	fi
	if test -d /opt/audio/lib; then
		EXTRA_CFLAGS="$EXTRA_CFLAGS -Dhpux_alib"
		EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/audio/lib -lAlib"
	fi
	;;

*-*-solaris*)
	# anyone knows how to make a autoconf test for socket() and
	# socketpair() that works on solaris?
	LIBS="$LIBS -lsocket -lnsl"
	;;

*-*-irix*)
        AUDIO_LIBS="-laudio"
        ;;
esac

AC_SUBST(GNUCFLAGS)
AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(EXTRA_LDFLAGS)
AC_SUBST(AUDIO_LIBS)


dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h strings.h sys/ioctl.h sys/time.h unistd.h ctype.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_HEADER_TIME

dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(getcwd gethostname mkdir select socketpair socket strerror strstr strtol setenv unsetenv setreuid seteuid)


AM_PATH_CDRTOOLS
AM_PATH_XCDRLIBDIR
AM_DEP_NONROOTMODE
AM_DEP_ENABLEGTK2

if test "$ENABLE_GTK2" = "TRUE"; then

	PKG_CHECK_MODULES(PKGCONFIG, gtk+-2.0 >= 2.0.6)
	LIBS="$LIBS $PKGCONFIG_LIBS"
	CFLAGS="$CFLAGS $PKGCONFIG_CFLAGS"

else 
	dnl pure plain GTK+-1.2.x support

	dnl Check for GLIB
	AM_PATH_GLIB(1.2.3,, AC_MSG_ERROR(Test for GLIB failed. See the file 'INSTALL' for help.))

	dnl Check for GTK+
	AM_PATH_GTK(1.2.3,, AC_MSG_ERROR(Test for GTK failed. See the file 'INSTALL' for help.))

	dnl Check for GDK-Pixbuf
	AM_PATH_GDK_PIXBUF(0.8.0,, AC_MSG_ERROR(Test for gdk_pixbuf failed. See the file 'INSTALL' for help.))
fi

dnl internationalization macros
AM_GNU_GETTEXT

dnl on my machine this macro is not yet defined. Uncomment if needed.
dnl AM_GNU_GETTEXT_VERSION(0.11.5)

dnl large file support
AC_SYS_LARGEFILE
if test "$enable_largefile" != no; then
	EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_LARGEFILES"
fi
AC_SUBST(EXTRA_CFLAGS)

AC_CONFIG_FILES([Makefile po/Makefile.in src/Makefile man/Makefile m4/Makefile  intl/Makefile ])
AC_CONFIG_COMMANDS([default],[[ echo timestamp > stamp-h ]],[[]])
AC_OUTPUT

