# Process this file with autoconf to produce a configure script.
AC_INIT(SDL_sound.c)

dnl ---------------------------------------------------------------------
dnl System/version info
dnl ---------------------------------------------------------------------

# Making releases:
#   MICRO_VERSION += 1;
#   INTERFACE_AGE += 1;
#   BINARY_AGE += 1;
# if any functions have been added, set INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set BINARY_AGE and INTERFACE_AGE to 0.

MAJOR_VERSION=0
MINOR_VERSION=1
MICRO_VERSION=2
INTERFACE_AGE=0
BINARY_AGE=0
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION

AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(MICRO_VERSION)
AC_SUBST(INTERFACE_AGE)
AC_SUBST(BINARY_AGE)
AC_SUBST(VERSION)

# libtool versioning
LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
LT_REVISION=$INTERFACE_AGE
LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`

AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

dnl Detect the canonical host and target build environment
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

dnl Setup for automake
AM_INIT_AUTOMAKE(SDL_sound, $VERSION)


dnl ---------------------------------------------------------------------
dnl Compilers and other tools
dnl ---------------------------------------------------------------------

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL


dnl ---------------------------------------------------------------------
dnl Checks for libraries.
dnl ---------------------------------------------------------------------

dnl Check for SDL
SDL_VERSION=1.2.0
AM_PATH_SDL($SDL_VERSION,
            :,
	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
)
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"

dnl Check for voc decoder inclusion...
AC_ARG_ENABLE(voc,
[  --enable-voc               enable VOC decoding [default=yes]],
              , enable_voc=yes)
if test x$enable_voc = xyes; then
    AC_DEFINE(SOUND_SUPPORTS_VOC)
fi


dnl Check for wav decoder inclusion...
AC_ARG_ENABLE(wav,
[  --enable-wav               enable WAV decoding [default=yes]],
              , enable_wav=yes)
if test x$enable_wav = xyes; then
    AC_DEFINE(SOUND_SUPPORTS_WAV)
fi


dnl Check for raw decoder inclusion...
AC_ARG_ENABLE(raw,
[  --enable-raw               enable raw audio "decoding" [default=yes]],
              , enable_raw=yes)
if test x$enable_raw = xyes; then
    AC_DEFINE(SOUND_SUPPORTS_RAW)
fi


dnl Check for aiff decoder inclusion...
AC_ARG_ENABLE(aiff,
[  --enable-aiff              enable AIFF decoding [default=yes]],
              , enable_aiff=yes)
if test x$enable_aiff = xyes; then
    AC_DEFINE(SOUND_SUPPORTS_AIFF)
fi


dnl Check for libmikmod
AC_ARG_ENABLE(mikmod,
[  --enable-mikmod            enable MOD decoding via mikmod [default=yes]],
              , enable_mikmod=yes)
if test x$enable_mikmod = xyes; then
  AM_PATH_LIBMIKMOD
  if test "x$no_libmikmod" = "x" ; then
    CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS"
    LIBS="$LIBS $LIBMIKMOD_LIBS"
    LDADD="$LDADD $LIBMIKMOD_LDADD"
    AC_DEFINE(SOUND_SUPPORTS_MOD)
  fi
fi

dnl Check for vorbis
AC_ARG_ENABLE(vorbis,
[  --enable-vorbis            enable OGG music via vorbis [default=yes]],
              , enable_vorbis=yes)
if test x$enable_vorbis = xyes; then
  AM_PATH_VORBIS
  if test "x$no_vorbis" = "x" ; then
    CFLAGS="$CFLAGS $VORBIS_CFLAGS"
    LIBS="$LIBS $VORBIS_LIBS $VORBISFILE_LIBS $VORBISENC_LIBS"
    AC_DEFINE(SOUND_SUPPORTS_OGG)
  fi
fi

dnl Check for SMPEG
AC_ARG_ENABLE(smpeg,
[  --enable-smpeg             enable MP3 music via smpeg [default=yes]],
              , enable_smpeg=yes)
if test x$enable_smpeg = xyes; then
  SMPEG_VERSION=0.4.3
  AM_PATH_SMPEG($SMPEG_VERSION, , no_smpeg=yes)
  if test "x$no_smpeg" = "x" ; then
    CFLAGS="$CFLAGS $SMPEG_CFLAGS"
    LIBS="$LIBS $SMPEG_LIBS"
    AC_DEFINE(SOUND_SUPPORTS_MP3)
  fi
fi



# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T

# Checks for library functions.

# This is only in the bleeding edge autoconf distro...
#AC_FUNC_MALLOC

AC_FUNC_MEMCMP
AC_CHECK_FUNCS([memset strrchr])


AC_OUTPUT([
Makefile
decoders/Makefile
test/Makefile
])
