#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

#AC_PREREQ(2.56)
AC_INIT(mpeg, 1.0)

AC_CONFIG_SRCDIR([mpeg.c])

AC_CANONICAL_SYSTEM

AM_INIT_AUTOMAKE

# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET

AC_DISABLE_STATIC
AC_LIBTOOL_DLOPEN
AC_LIBTOOL_WIN32_DLL

AC_PROG_LIBTOOL

AM_MAINTAINER_MODE

echo "You Machine: ${target_cpu} ${target_os}"

AC_ARG_WITH(fenix-prefix,[  --with-fenix-prefix=PFX Prefix where Fenix is installed (optional)],
            fenix_prefix="$withval", fenix_prefix="/opt/Fenix")

CFLAGS="$CFLAGS -I${fenix_prefix}/include -I${fenix_prefix}/fxi/inc -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"

# Check for SDL library
SDL_VERSION=1.2.0
AM_PATH_SDL($SDL_VERSION,:,AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))

# Check for SMPEG library
SMPEG_VERSION=0.4.5
AM_PATH_SMPEG($SMPEG_VERSION,:,AC_MSG_ERROR([*** SMPEG version $SMPEG_VERSION not found!]))

# Checks for libraries.
AC_CHECK_LIB([SDL], SDL_Init)
AC_CHECK_LIB([SMPEG], SMPEG_new)
AC_CHECK_LIB(z, gzsetparams,, [AC_MSG_ERROR(zlib library not found)])
AC_CHECK_LIB(SDL_mixer, main,, AC_MSG_ERROR([*** SDL_mixer library not found!]))

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

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
