+AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
+AM_GLIB_GNU_GETTEXT
+
+m4_pattern_allow([AM_V_GEN])dnl Make autoconf not complain about the rule below
+EV_INTLTOOL_EVINCE_BACKEND_RULE='%.evince-backend: %.evince-backend.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(AM_V_GEN) LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
+AC_SUBST([EV_INTLTOOL_EVINCE_BACKEND_RULE])
+
+# Check which platform to use
+
+AC_MSG_CHECKING([for which platform to build])
+AC_ARG_WITH([platform],
+ [AS_HELP_STRING([--with-platform=gnome|win32|hildon (default: gnome)])],
+ [case "$withval" in
+ gnome|win32|hildon) ;;
+ *) AC_MSG_ERROR([invalid argument "$withval" for --with-platform]) ;;
+ esac],
+ [case "$host" in
+ *-*-mingw*|*-*-cygwin*) with_platform="win32" ;;
+ *) with_platform=gnome ;;
+ esac])
+
+AC_MSG_RESULT([$with_platform])
+
+if test "$with_platform" = "win32"; then
+ AC_CHECK_TOOL([WINDRES],[windres])
+ AC_MSG_CHECKING([for native Win32])
+ case "$host" in
+ *-*-mingw*)
+ os_win32=yes
+ ;;
+ *)
+ os_win32=no
+ ;;
+ esac
+ AC_MSG_RESULT([$os_win32])
+fi
+
+AM_CONDITIONAL([PLATFORM_HILDON],[test "$with_platform" = "hildon"])
+AM_CONDITIONAL([PLATFORM_WIN32],[test "$with_platform" = "win32"])
+
+dnl Specify required versions of dependencies
+DBUS_GLIB_REQUIRED=0.70
+GTK_REQUIRED=2.14.0
+GLIB_REQUIRED=2.18.0
+KEYRING_REQUIRED=2.22.0
+AC_SUBST([GLIB_REQUIRED])
+AC_SUBST([GTK_REQUIRED])
+
+GNOME_ICON_THEME_REQUIRED=2.17.1
+LIBXML_REQUIRED=2.5.0
+
+dnl Check dependencies
+
+# LIB_CFLAGS for helpers and generic widgets. (libdocument, cut-and-paste)
+# BACKEND_CFLAGS for backend implementations.
+# FRONTEND_CFLAGS for frontend implementations. (properties, thumbnailer)
+# FRONTEND_LIBS
+# SHELL_CFLAGS for shell implementation.
+# SHELL_LIBS
+
+PKG_CHECK_MODULES(LIBDOCUMENT, gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED)
+PKG_CHECK_MODULES(LIBVIEW, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
+PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED)
+PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
+PKG_CHECK_MODULES(PREVIEWER, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
+
+SHELL_PLATFORM_PKGS=
+case "$with_platform" in
+ hildon) AC_DEFINE([PLATFORM_HILDON],[1],[Define if building for the hildon platform])
+ SHELL_PLATFORM_PKGS="hildon-1 hildon-fm-2 libosso"
+ ;;
+ *) SHELL_PLATFORM_PKGS="gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED"
+ ;;
+esac
+
+PKG_CHECK_MODULES([SHELL_CORE],[libxml-2.0 >= $LIBXML_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gthread-2.0 $SHELL_PLATFORM_PKGS])
+
+# *********
+# SM client
+# *********
+
+GDK_TARGET="$($PKG_CONFIG --variable target gdk-2.0)"
+
+SMCLIENT_PKGS=
+AC_MSG_CHECKING([which smclient backend to use])
+AC_ARG_WITH([smclient],
+ [AS_HELP_STRING([--with-smclient-backend],[which smclient backend to use (no|xsmp|win32|quartz)])],
+ [],
+ [case "$GDK_TARGET" in
+ x11) case "$with_platform" in
+ gnome) with_smclient=xsmp SMCLIENT_PKGS="sm >= 1.0.0" ;;
+ *) with_smclient=no ;;
+ esac ;;
+ win32|quartz) with_smclient=$GDK_TARGET ;;
+ *) with_smclient=no ;;
+ esac])
+AC_MSG_RESULT([$with_smclient])
+
+if test "$with_smclient" != "no"; then
+ AC_DEFINE([WITH_SMCLIENT],[1],[Define if smclient is enabled])
+
+ PKG_CHECK_MODULES([SMCLIENT],[gtk+-2.0 gthread-2.0 $SMCLIENT_PKGS])
+ AC_SUBST([SMCLIENT_CFLAGS])
+ AC_SUBST([SMCLIENT_LIBS])
+fi
+
+AM_CONDITIONAL([WITH_SMCLIENT],[test "$with_smclient" != "no"])
+AM_CONDITIONAL([WITH_SMCLIENT_XSMP],[test "$with_smclient" = "xsmp"])
+AM_CONDITIONAL([WITH_SMCLIENT_WIN32],[test "$with_smclient" = "win32"])
+AM_CONDITIONAL([WITH_SMCLIENT_QUARTZ],[test "$with_smclient" = "quartz"])
+
+# ***
+
+BACKEND_LIBTOOL_FLAGS="-module -avoid-version -no-undefined -export-symbols \$(top_srcdir)/backend/backend.symbols"
+AC_SUBST(BACKEND_LIBTOOL_FLAGS)
+
+dnl ===== Check special functions
+evince_save_LIBS=$LIBS
+LIBS="$LIBS $BACKEND_LIBS"
+AC_CHECK_FUNCS(cairo_format_stride_for_width)
+AC_CHECK_FUNCS(gtk_print_operation_get_n_pages_to_print)
+LIBS=$evince_save_LIBS
+
+# ******************
+# GKT+ Unix Printing
+# ******************
+
+AC_MSG_CHECKING([whether gtk+-unix-print support is requested])
+AC_ARG_WITH([gtk-unix-print],
+ [AS_HELP_STRING([--without-gtk-unix-print],[disable the use of gtk-unix-print])],
+ [],[case "$os_win32" in
+ yes) with_gtk_unix_print=no ;;
+ *) with_gtk_unix_print=yes ;;
+ esac])
+AC_MSG_RESULT([$with_gtk_unix_print])
+
+if test "$with_gtk_unix_print" = "yes"; then
+ PKG_CHECK_MODULES(GTKUNIXPRINT, [gtk+-unix-print-2.0 >= $GTK_REQUIRED])
+ AC_DEFINE([GTKUNIXPRINT_ENABLED], [1], [Define if gtk+-unix-print is enabled.])
+fi
+
+# *********************
+# GNOME Keyring support
+# *********************