dnl $Id: configure.in.in 23014 2006-09-02 14:19:44Z benny $
dnl
dnl Copyright (c) 2003-2006
dnl         os-cillation e.K. All rights reserved.
dnl
dnl Written by Benedikt Meurer <benny@xfce.org>.
dnl

dnl ***************************
dnl *** Version information ***
dnl ***************************
m4_define([terminal_version_major], [0])
m4_define([terminal_version_minor], [2])
m4_define([terminal_version_micro], [5])
m4_define([terminal_version_nano], [6])
m4_define([terminal_version_build], [23062])
m4_define([terminal_version_tag], [rc1])
m4_define([terminal_version_dbus], [3])
m4_define([terminal_version], [terminal_version_major().terminal_version_minor().terminal_version_micro()ifelse(terminal_version_nano(), [], [], [.terminal_version_nano()])ifelse(terminal_version_tag(), [svn], [terminal_version_tag()-terminal_version_build()], [terminal_version_tag()])])

dnl *******************************************
dnl *** Debugging support for SVN snapshots ***
dnl *******************************************
m4_define([terminal_debug_default], [ifelse(terminal_version_tag(), [svn], [yes], [minimum])])

dnl ***************************
dnl *** Initialize autoconf ***
dnl ***************************
AC_COPYRIGHT([Copyright (c) 2003-2006
        os-cillation e.K. All rights reserved.

Written by Benedikt Meurer <benny@xfce.org>.])
AC_INIT([Terminal], [terminal_version()], [http://bugzilla.xfce.org/], [Terminal])
AC_REVISION([$Id: configure.in.in 23014 2006-09-02 14:19:44Z benny $])
AC_PREREQ([2.50])

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

dnl ***********************************
dnl *** Subst D-BUS service version ***
dnl ***********************************
TERMINAL_VERSION_DBUS=terminal_version_dbus()
AC_SUBST([TERMINAL_VERSION_DBUS])

dnl *******************************
dnl *** Check for UNIX variants ***
dnl *******************************
AC_AIX()
AC_MINIX()
AC_ISC_POSIX()

dnl ********************************
dnl *** Check for basic programs ***
dnl ********************************
AC_PROG_CC()
AC_PROG_INSTALL()
AC_PROG_INTLTOOL([0.31], [no-xml])
AC_PROG_LIBTOOL()

dnl **********************************
dnl *** Check for standard headers ***
dnl **********************************
AC_CHECK_HEADERS([ctype.h errno.h limits.h pwd.h time.h])

dnl ******************************
dnl *** Check for i18n support ***
dnl ******************************
XDT_I18N([ca cs de el en_GB eo es eu fi fr gl he hu it ja ko lt nl pl pt_BR ru sk sv uk vi zh_CN zh_TW])

dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.1.10])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
XDT_CHECK_PACKAGE([VTE], [vte], [0.11.11])

dnl *************************************************
dnl *** Optional support for startup notification ***
dnl *************************************************
XDT_CHECK_OPTIONAL_PACKAGE([LIBSTARTUP_NOTIFICATION],
                           [libstartup-notification-1.0],
                           [0.4], [startup-notification],
                           [startup notification library])

dnl **********************************
dnl *** Optional support for D-BUS ***
dnl **********************************
XDT_CHECK_OPTIONAL_PACKAGE([DBUS], [dbus-glib-1], [0.22],
                           [dbus], [D-BUS GLib bindings])
if test x"$DBUS_FOUND" = x"yes"; then
  AC_MSG_CHECKING([whether to use new D-BUS API])
  if $PKG_CONFIG --atleast-version 0.31 dbus-1 >/dev/null 2>&1; then
    AC_DEFINE([DBUS_USE_NEW_API], [1], [Define to use new D-BUS API])
    AC_MSG_RESULT([yes])
  else
    AC_MSG_RESULT([no])
  fi
fi

dnl **************************
dnl *** Check for xsltproc ***
dnl **************************
AC_ARG_ENABLE([xsltproc], [AC_HELP_STRING([--enable-xsltproc], [Use xsltproc to build documentation [default=no]])],, [enable_xsltproc=no])
if test x"$enable_xsltproc" = x"yes"; then
  AC_PATH_PROG([XSLTPROC], [xsltproc], [no])
  if test x"$XSLTPROC" = x"no"; then
    enable_xsltproc=no
  fi
fi
AM_CONDITIONAL([ENABLE_XSLTPROC], [test x"$enable_xsltproc" = x"yes"])

dnl ************************
dnl *** Check for xml2po ***
dnl ************************
AC_ARG_ENABLE([xml2po], [AC_HELP_STRING([--enable-xml2po], [Use xml2po to build documentation [default=no]])],, [enable_xml2po=no])
if test x"$enable_xml2po" = x"yes"; then
  AC_PATH_PROG([XML2PO], [xml2po], [no])
  if test x"$XML2PO" = x"no"; then
    enable_xml2po=no
  fi
fi
AM_CONDITIONAL([ENABLE_XML2PO], [test x"$enable_xml2po" = x"yes"])

dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=terminal_debug_default@:>@]),
  [], [enable_debug=terminal_debug_default])
AC_MSG_CHECKING([whether to enable debugging support])
if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then
  dnl Check whether the compiler accepts the -fno-strict-aliasing
  dnl switch, as certain packages - like Glib - still don't work
  dnl properly with newer compilers.
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -fno-strict-aliasing"
  AC_MSG_CHECKING([whether $CC accepts -fno-strict-aliasing])
  AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
    AC_MSG_RESULT([yes])
    PLATFORM_CFLAGS="$PLATFORM_CFLAGS -fno-strict-aliasing"
  ], [
    AC_MSG_RESULT([no])
  ])
  CFLAGS="$save_CFLAGS"

  dnl Make sure we detect possible errors
  PLATFORM_CFLAGS="$PLATFORM_CFLAGS -Werror -Wall"

  dnl Paranoia for --enable-debug=full
  if test x"$enable_debug" = x"full"; then
    PLATFORM_CFLAGS="$PLATFORM_CFLAGS -O0 -g3"
    PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_ENABLE_DEBUG"
  fi
else
  dnl Disable object cast checks
  PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_CAST_CHECKS"

  dnl Disable all checks for --enable-debug=no
  if test x"$enable_debug" = x"no"; then
    PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
  fi
fi
AC_MSG_RESULT([$enable_debug])

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

dnl *********************************
dnl *** Substitute platform flags ***
dnl *********************************
AC_MSG_CHECKING([PLATFORM_CPPFLAGS])
AC_MSG_RESULT([$PLATFORM_CPPFLAGS])
AC_SUBST([PLATFORM_CPPFLAGS])
AC_MSG_CHECKING([PLATFORM_CFLAGS])
AC_MSG_RESULT([$PLATFORM_CFLAGS])
AC_SUBST([PLATFORM_CFLAGS])
AC_MSG_CHECKING([PLATFORM_LDFLAGS])
AC_MSG_RESULT([$PLATFORM_LDFLAGS])
AC_SUBST([PLATFORM_LDFLAGS])

AC_OUTPUT([
Makefile
Terminal.spec
doc/Makefile
doc/C/Makefile
doc/C/Terminal.xml
doc/C/images/Makefile
doc/ja/Makefile
doc/ja/Terminal.xml
doc/ja/images/Makefile
helpers/Makefile
icons/Makefile
icons/16x16/Makefile
icons/24x24/Makefile
icons/48x48/Makefile
icons/scalable/Makefile
po/Makefile.in
po-doc/Makefile
terminal/Makefile
terminal/terminal-config.h
])
