dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/vmaid.c)
PACKAGE=vmaid

dnl version number
MAJOR_VERSION=1
MINOR_VERSION=8
MICRO_VERSION=8
EXTRA_VERSION=
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION

AM_INIT_AUTOMAKE($PACKAGE,$VERSION)
AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION,"$VERSION")

dnl Specify a header configuration file
AM_CONFIG_HEADER(config.h)

dnl **************************************************************
dnl Checks for programs.
dnl **************************************************************
AC_ARG_PROGRAM
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_ISC_POSIX
AC_PROG_MAKE_SET
AM_MAINTAINER_MODE

dnl **************************************************************
dnl libtool
dnl **************************************************************
AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
AM_PROG_LIBTOOL

dnl **************************************************************
dnl Check for GTK+.
dnl **************************************************************
AC_ARG_ENABLE(gtk2,
  [  --enable-gtk2[=ARG]     Use Gtk+-2.0 [ARG=yes/no/auto] default=auto])
if test "$enable_gtk2" = "no"; then
  AM_PATH_GTK(1.2.0,,AC_MSG_ERROR(Test for GTK+ failed.),gthread)
elif test "$enable_gtk2" != "yes"; then
  AM_PATH_GTK(1.2.0,enable_gtk2="no",enable_gtk2="yes",gthread)
fi
if test "$enable_gtk2" = "yes"; then
  AM_PATH_GTK_2_0(2.0.0,AC_DEFINE(USE_GTK2),AC_MSG_ERROR(Test for GTK+-2.0 failed.),gthread)
fi

dnl **************************************************************
dnl Check for Library.
dnl **************************************************************
AC_CHECK_LIB(c_r,pthread_create,LIBS="$LIBS -pthread")

dnl **************************************************************
dnl enable/disable Win32 codec support.
dnl **************************************************************
AC_ARG_WITH(w32,
  [  --with-w32[=DIR]        support Win32])
if test -z "$with_w32" || test "$with_w32" = "yes"; then
  if test -d "${libdir}/win32"; then
    with_w32="${libdir}/win32"
  elif test -d "/usr/local/lib/win32"; then
    with_w32="/usr/local/lib/win32"
  elif test -d "/usr/lib/win32"; then
    with_w32="/usr/lib/win32"
  fi
  if test "$with_w32" = "yes"; then
    with_w32="${libdir}/win32"
  fi
fi
if test -z "$with_w32"; then
  with_w32="no"
fi
AM_CONDITIONAL(WITH_W32,test "$with_w32" != "no")
if test "$with_w32" != "no"; then
  AC_DEFINE_UNQUOTED(W32CODECDIR,"$with_w32")
fi

dnl **************************************************************
dnl Check for gettext.
dnl **************************************************************
ALL_LINGUAS="ja"
AM_GNU_GETTEXT
AC_CHECK_FUNC(gettext,,AC_CHECK_LIB(intl,gettext))
if test "${prefix}" = "NONE"; then
  AC_DEFINE_UNQUOTED(LOCALEDIR,"${ac_default_prefix}/share/locale")
else
  AC_DEFINE_UNQUOTED(LOCALEDIR,"${prefix}/share/locale")
fi

dnl **************************************************************
dnl Checks for header files.
dnl **************************************************************
AC_HEADER_STDC
AC_CHECK_HEADERS(bits/sigset.h fcntl.h pthread.h strings.h sys/file.h sys/stat.h sys/types.h unistd.h)

dnl **************************************************************
dnl Checks for typedefs, structures, and compiler characteristics.
dnl **************************************************************
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
if test "$CC" = "gcc"; then
  CFLAGS="$CFLAGS -Wall"
fi

dnl **************************************************************
dnl Checks for library functions.
dnl **************************************************************
AC_FUNC_MEMCMP
AC_FUNC_MMAP

AC_OUTPUT([
Makefile
avicore/Makefile
dllloader/Makefile
intl/Makefile
m4/Makefile
misc/Makefile
po/Makefile.in
src/Makefile
])

dnl **************************************************************
dnl Show some info.
dnl **************************************************************
AC_MSG_RESULT([
Configure Result :

   Package      : ${PACKAGE}
   Version      : ${VERSION}
   C Compiler   : ${CC} ${CFLAGS}
   Install path : ${prefix}
   Gtk+-2.0     : ${enable_gtk2}
   Win32 codec  : ${with_w32}
])
