+# Glib detection
+PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
+
+if test x$have_glib = xno ; then
+ AC_MSG_WARN([GLib development libraries not found])
+fi
+
+if test x$enable_glib = xyes; then
+ if test x$have_glib = xno; then
+ AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
+ fi
+fi
+
+if test x$enable_glib = xno; then
+ have_glib=no;
+fi
+
+AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
+
+dnl GLib flags
+AC_SUBST(DBUS_GLIB_CFLAGS)
+AC_SUBST(DBUS_GLIB_LIBS)
+
+# Qt detection
+have_qt=no
+if test -n "$QTDIR" -a -f $QTDIR/include/qglobal.h; then
+ have_qt=yes
+ DBUS_QT_CXXFLAGS=-I$QTDIR/include
+fi
+
+dnl linking to kdecore will give us a bit of help from libtool
+kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
+if test -z $kdelibs -a -f $kdelibs/libkdecore.la; then
+ have_qt=no
+else
+ DBUS_QT_LIBS=$kdelibs/libkdecore.la
+fi
+
+if test x$have_qt = xno ; then
+ AC_MSG_WARN([Qt development libraries not found])
+fi
+
+if test x$enable_qt = xyes; then
+ if test x$have_qt = xno; then
+ AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
+ fi
+fi
+
+if test x$enable_qt = xno; then
+ have_qt=no;
+fi
+
+AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
+
+dnl Qt flags
+AC_SUBST(DBUS_QT_CXXFLAGS)
+AC_SUBST(DBUS_QT_LIBS)
+