dnl $Id: configure.in.in 18995 2005-12-05 16:46:54Z benny $
dnl
dnl Copyright (c) 2004-2005 os-cillation.
dnl All rights reserved.
dnl
dnl Written by Benedikt Meurer <benny@xfce.org>.
dnl

dnl ***************************
dnl *** Version information ***
dnl ***************************
m4_define([libexo_verinfo], [0:1:0])
m4_define([libexo_version_major], [0])
m4_define([libexo_version_minor], [3])
m4_define([libexo_version_micro], [1])
m4_define([libexo_version_nano], [1])
m4_define([libexo_version_build], [r@REVISION@])
m4_define([libexo_version_tag], [svn])
m4_define([libexo_version], [libexo_version_major().libexo_version_minor().libexo_version_micro()ifelse(libexo_version_nano(), [], [], [.libexo_version_nano()])ifelse(libexo_version_tag(), [], [], [libexo_version_tag()-libexo_version_build()])])

dnl ***************************
dnl *** Initialize autoconf ***
dnl ***************************
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.in.in 18995 2005-12-05 16:46:54Z benny $])
AC_CANONICAL_TARGET()

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

dnl **************************
dnl *** Libtool versioning ***
dnl **************************
LIBEXO_VERINFO=libexo_verinfo()
AC_SUBST([LIBEXO_VERINFO])

dnl ****************************
dnl *** Subst libexo version ***
dnl ****************************
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 *******************************
dnl *** Check for UNIX variants ***
dnl *******************************
AC_AIX()
AC_ISC_POSIX()
AC_MINIX()

dnl ********************************
dnl *** Check for basic programs ***
dnl ********************************
AM_PROG_AS()
AC_PROG_CC()
AC_PROG_INSTALL()
AC_PROG_INTLTOOL([0.31], [no-xml])
AC_PROG_LIBTOOL()
AC_CHECK_PROGS([PERL], [perl5 perl])

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

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

dnl ******************************
dnl *** Check for i18n support ***
dnl ******************************
XDT_I18N([ca de el en_GB es fi fr ja pt_BR],
         [libexo-libexo_version_major().libexo_version_minor()])

dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.6.4])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.2.0])

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

dnl *********************************************
dnl *** Check for xfce-mcs-manager (optional) ***
dnl *********************************************
XDT_CHECK_OPTIONAL_PACKAGE([XFCE_MCS_MANAGER], [xfce-mcs-manager], [4.2.0],
                           [mcs-plugin], [xfce-mcs-manager], [yes])

dnl ***********************************
dnl *** Check for python (optional) ***
dnl ***********************************
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"])

dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug], [Enable debugging support])
AC_HELP_STRING([--disable-debug], [Disable debugging support]),
  [], [ifelse(libexo_version_tag(), [], [enable_debug=no], [enable_debug=yes])])
AC_MSG_CHECKING([whether to enable debugging support])
if test x"$enable_debug" != x"no"; then
  CFLAGS="$CFLAGS -O0 -g3 -DG_DISABLE_DEPRECATED -Werror -Wall"
  AC_MSG_RESULT([yes])
else
  CPPFLAGS="$CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CAST_CHECKS -DG_DISABLE_CHECKS"
  AC_MSG_RESULT([no])

  AC_MSG_CHECKING([whether $LD accepts -O1])
  case `$LD -O1 -v 2>&1 </dev/null` in
  *GNU* | *'with BFD'*)
    LDFLAGS="$LDFLAGS -Wl,-O1"
    AC_MSG_RESULT([yes])
    ;;
  *)
    AC_MSG_RESULT([no])
    ;;
  esac
fi

dnl ****************************************
dnl *** Check for ELF visibility support ***
dnl ****************************************
AC_ARG_ENABLE([visibility], AC_HELP_STRING([--disable-visibility], [Don't use ELF visibility attributes]), [], [enable_visibility=yes])
have_gnuc_visibility=no
if test x"$enable_visibility" != x"no"; then
  dnl Check whether the compiler supports the visibility attribute
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -Wall -Werror"
  AC_MSG_CHECKING([whether $CC supports the GNUC visibility attribute])
  AC_COMPILE_IFELSE(AC_LANG_SOURCE(
  [
    void __attribute__ ((visibility("default"))) test_default (void) {}
    void __attribute__ ((visibility("hidden"))) test_hidden (void) {}
    int main (int argc, char **argv) { test_default (); test_hidden (); return 0; }
  ]),
  [
    have_gnuc_visibility=yes
    AC_MSG_RESULT([yes])
  ],
  [
    AC_MSG_RESULT([no])
  ])
  CFLAGS="$save_CFLAGS"
fi
if test x"$have_gnuc_visibility" = x"yes"; then
  CPPFLAGS="$CPPFLAGS -DHAVE_GNUC_VISIBILITY"
fi
AM_CONDITIONAL([HAVE_GNUC_VISIBILITY], [test x"$have_gnuc_visibility" = 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
exo-csource/Makefile
exo-helper/Makefile
exo-helper/helpers/Makefile
icons/Makefile
icons/48x48/Makefile
po/Makefile.in
python/Makefile
python/examples/Makefile
tests/Makefile
tests/data/Makefile
])
