dnl $Id: configure.in.in 29622 2009-02-26 12:27:57Z jannis $
dnl
dnl Copyright (c) 2003-2009
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], [12])
m4_define([terminal_version_nano], [])
m4_define([terminal_version_build], [29850])
m4_define([terminal_version_tag], [])
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-2009
        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 29622 2009-02-26 12:27:57Z jannis $])
AC_PREREQ([2.50])

dnl ***************************
dnl *** Initialize automake ***
dnl ***************************
AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
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()
AM_PROG_CC_C_O()
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 signal.h time.h])

dnl ******************************
dnl *** Check for i18n support ***
dnl ******************************
XDT_I18N([ar be ca cs da de dz el en_GB eo es et eu fi fr gl he hu id it ja ko ku lt lv nb nl pa pl pt_BR pt ro ru sk sq sv tr uk ur vi zh_CN zh_TW])

dnl ********************************
dnl *** Check for X11 (optional) ***
dnl ********************************
XDT_CHECK_LIBX11()

dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.4])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.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 VTE transparency ***
dnl **********************************
AC_MSG_CHECKING([whether VTE supports real transparency])
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$LIBS $VTE_LIBS"
CFLAGS="$CFLAGS $VTE_CFLAGS"
AC_TRY_LINK([
  #include <vte/vte.h>
], [ vte_terminal_set_opacity (0, 0); ], [
  AC_DEFINE_UNQUOTED([HAVE_VTE_TERMINAL_SET_OPACITY], [1], [Define to 1 if vte_terminal_set_opacity() is available])
  AC_MSG_RESULT([yes])
], [
  AC_MSG_RESULT([no])
])
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"

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 Print the result
  AC_MSG_RESULT([$enable_debug])

  dnl Check whether the compiler accepts the -Werror
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -Werror"
  AC_MSG_CHECKING([whether $CC accepts -Werror])
  AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
    AC_MSG_RESULT([yes])
    PLATFORM_CFLAGS="$PLATFORM_CFLAGS -Werror"
  ], [
    AC_MSG_RESULT([no])

		dnl Check whether the compiler accepts the -errwarn=%all
		CFLAGS="$save_CFLAGS -errwarn=%all"
		AC_MSG_CHECKING([whether $CC accepts -errwarn=%all])
		AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
			AC_MSG_RESULT([yes])
			PLATFORM_CFLAGS="$PLATFORM_CFLAGS -errwarn=%all"
		], [
			AC_MSG_RESULT([no])
		])
  ])
  CFLAGS="$save_CFLAGS"

  dnl Check whether the compiler accepts the -Wall
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -Wall"
  AC_MSG_CHECKING([whether $CC accepts -Wall])
  AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
    AC_MSG_RESULT([yes])
    PLATFORM_CFLAGS="$PLATFORM_CFLAGS -Wall"
  ], [
    AC_MSG_RESULT([no])
  ])
  CFLAGS="$save_CFLAGS"

  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 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 Print the result
  AC_MSG_RESULT([$enable_debug])

  dnl Disable debugging (release build)
  PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DNDEBUG"

  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

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/fr/Makefile
doc/fr/Terminal.xml
doc/fr/images/Makefile
doc/ja/Makefile
doc/ja/Terminal.xml
doc/ja/images/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
])
