AC_INIT([libmms], [0.6.4])
AC_CONFIG_SRCDIR(configure.in)
AM_INIT_AUTOMAKE

AC_CONFIG_HEADERS([config.h src/mms_config.h])

AC_ISC_POSIX
AC_CANONICAL_HOST
AC_PROG_CC
AC_HEADER_STDC
AM_PROG_LIBTOOL
AC_PROG_LIBTOOL
AC_PROG_INSTALL

dnl Checks for header files.
AC_CHECK_HEADERS([sys/socket.h netinet/in.h netdb.h windows.h winsock2.h])

case $host in
    *beos*)
        AC_DEFINE([BEOS],1,[Define if compiling on BeOS system.])
        ;;
    *mingw*)
        MMS_LIBS="$MMS_LIBS -lws2_32"
dnl Needed for getaddrinfo under mingw
        MMS_CFLAGS="-DWINVER=0x0600 -D_WIN32_WINNT=0x0600"
        ;;
esac

dnl
dnl check for large file support
dnl hacky, copied from gstreamer's configure.ac

AC_MSG_CHECKING(for large file support)
AC_TRY_RUN([
#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
int main () { return !(sizeof(off_t) == 8); }
],
[
  AC_MSG_RESULT(yes)
  MMS_PKG_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
  echo "#define LIBMMS_HAVE_64BIT_OFF_T 1" >> confdefs.h
],
[
  AC_MSG_RESULT(no)
],
[
  AC_MSG_RESULT(no)
])

AC_SUBST(MMS_CFLAGS)
AC_SUBST(MMS_PKG_CFLAGS)
AC_SUBST(MMS_LIBS)


AC_CONFIG_FILES([
Makefile
pkgconfig/Makefile
pkgconfig/libmms.pc
src/Makefile
libmms.spec])
AC_OUTPUT

echo "configure done"
