dnl $Id: configure.ac 63 2005-03-13 18:38:09Z bmeurer $
dnl
dnl Copyright (c) 2004-2005 os-cillation.
dnl All rights reserved.
dnl
dnl Written by Benedikt Meurer <benny@xfce.org>.
dnl

dnl Version information
m4_define([libexo_verinfo], [0:0:0])
m4_define([libexo_version_major], [0])
m4_define([libexo_version_minor], [3])
m4_define([libexo_version_micro], [0])
m4_define([libexo_version_tag], [])
m4_define([libexo_version], [libexo_version_major().libexo_version_minor().libexo_version_micro()libexo_version_tag()])

dnl Initialize autoconf
AC_COPYRIGHT([Copyright (c) 2004-2005 os-cillation.
All rights reserved.
        
Written by Benedikt Meurer <benny@xfce.org>.])
AC_INIT([exo], [libexo_version()], [benny@xfce.org])
AC_PREREQ([2.50])
AC_REVISION([$Id: configure.ac 63 2005-03-13 18:38:09Z bmeurer $])

dnl Initialize automake
AM_INIT_AUTOMAKE([AC_PACKAGE_TARNAME()], [AC_PACKAGE_VERSION()])
AM_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE()

dnl libtool versioning
LIBEXO_VERINFO=libexo_verinfo()
AC_SUBST([LIBEXO_VERINFO])

dnl Subst libexo version
LIBEXO_VERSION_MAJOR=libexo_version_major()
LIBEXO_VERSION_MINOR=libexo_version_minor()
LIBEXO_VERSION_MICRO=libexo_version_micro()
LIBEXO_VERSION_API=$LIBEXO_VERSION_MAJOR.$LIBEXO_VERSION_MINOR
AC_SUBST([LIBEXO_VERSION_MAJOR])
AC_SUBST([LIBEXO_VERSION_MINOR])
AC_SUBST([LIBEXO_VERSION_MICRO])
AC_SUBST([LIBEXO_VERSION_API])

dnl check for UNIX variants
AC_AIX()
AC_ISC_POSIX()
AC_MINIX()

dnl check for basic programs
AC_PROG_CC()
AC_PROG_INSTALL()
AC_PROG_LIBTOOL()

dnl check for standard header files
AC_HEADER_STDC()
AC_CHECK_HEADERS([errno.h fcntl.h locale.h math.h md5.h string.h \
                  sys/resource.h sys/stat.h sys/time.h sys/types.h \
                  time.h])

dnl check for Message Digest functions
AC_SEARCH_LIBS([MD5Init], [md c], \
               [AC_DEFINE([HAVE_MD5INIT], [1], [Define if MD5Init present])])

dnl Check for i18n support
XDT_I18N([de en_GB], [libexo-libexo_version_major().libexo_version_minor()])

dnl Check for required packages
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.4.0])
XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.2.0])

dnl Check for X11 libraries
XDT_CHECK_LIBX11_REQUIRE()

dnl Check for gtk-doc
GTK_DOC_CHECK([1.0])

dnl Check for debugging support
BM_DEBUG_SUPPORT()

dnl Check for python (optional)
AC_ARG_ENABLE([python], 
  [AC_HELP_STRING([--enable-python], [build python bindings])],
  [enable_python=$enableval],
  [enable_python=auto])
have_python=no
if test x"$enable_python" != x"no"; then
  AC_MSG_NOTICE([Checking to see if we can build Python bindings])
  AM_PATH_PYTHON([2.2])

  if test -z "$PYTHON"; then
    AC_MSG_WARN([Python not found])
  else
    XDT_CHECK_PYTHON_HEADERS([have_python_headers=yes],[have_python_headers=no])
    XDT_CHECK_PACKAGE([PYGTK], [pygtk-2.0], [2.4.0], \
                      [have_pygtk=yes], [have_pygtk=no])

    AC_PATH_PROG([PYGTK_CODEGEN], [pygtk-codegen-2.0], [no])

    if test x"$have_python_headers" = x"yes" -a x"$have_pygtk" = x"yes" -a x"$PYGTK_CODEGEN" != x"no"; then
      have_python=yes

      AC_MSG_CHECKING([for PyGTK defs])
      PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
      AC_MSG_RESULT([$PYGTK_DEFSDIR])
      AC_SUBST([PYGTK_DEFSDIR])

      dnl Check whether the compiler accepts -fno-strict-aliasing,
      dnl which is required to compile the source generated by
      dnl pygtk-codegen-2.0 with gcc 3.x.
      save_CPPFLAGS="$CPPFLAGS"
      CPPFLAGS="$CPPFLAGS -fno-strict-aliasing"
      AC_MSG_CHECKING([whether $CC accepts -fno-strict-aliasing])
      AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
        AC_MSG_RESULT([yes])
        PYGTK_CFLAGS="$PYGTK_CFLAGS -fno-strict-aliasing"
      ], [
        AC_MSG_RESULT([no])
      ])
      CPPFLAGS="$save_CPPFLAGS"
    fi
  fi

  if test x"$have_python" = x"no"; then
    if test x"$enable_python" = x"yes"; then
      AC_MSG_ERROR([Building python explicitly requested, but cannot build python bindings])
    else
      AC_MSG_WARN([Couldn't find either PyGTK or the Python headers, not building Python bindings])
    fi
  fi
fi
AM_CONDITIONAL([HAVE_PYTHON], [test x"$have_python" = x"yes"])

AC_OUTPUT([
Makefile
exo.spec
docs/Makefile
docs/reference/Makefile
docs/reference/version.xml
exo/Makefile
exo/exo-0.3.pc
exo/exo-config.h
po/Makefile.in
python/Makefile
python/examples/Makefile
])
