+###############################################################################
+#
+# Check for -lXft
+#
+###############################################################################
+
+have_xutf8drawstring=no
+AC_CHECK_X_LIB(X11, Xutf8DrawString,
+ [have_xutf8drawstring=yes],
+ [true], -lX11 -lXext -lm)
+if test "$have_xutf8drawstring" = yes ; then
+ AC_DEFINE(HAVE_XUTF8DRAWSTRING)
+fi
+
+
+have_xft=no
+with_xft_req=unspecified
+xft_halfassed=no
+AC_ARG_WITH(xft,
+[ --with-xft Include support for the X Freetype library.],
+ [with_xft="$withval"; with_xft_req="$withval"],
+ [with_xft=yes])
+
+HANDLE_X_PATH_ARG(with_xft, --with-xft, Xft)
+
+if test "$with_xft" != yes -a "$with_xft" != no ; then
+ echo "error: must be yes or no: --with-xft=$with_xft"
+ exit 1
+fi
+
+if test "$with_xft" = yes; then
+
+ pkgs=''
+ ok="yes"
+ pkg_check_version xft 2.1.0
+ have_xft="$ok"
+
+ if test "$have_xft" = yes; then
+ AC_CACHE_CHECK([for Xft includes], ac_cv_xft_config_cflags,
+ [ac_cv_xft_config_cflags=`$pkg_config --cflags $pkgs`])
+ AC_CACHE_CHECK([for Xft libs], ac_cv_xft_config_libs,
+ [ac_cv_xft_config_libs=`$pkg_config --libs $pkgs`])
+ fi
+
+ ac_xft_config_cflags=$ac_cv_xft_config_cflags
+ ac_xft_config_libs=$ac_cv_xft_config_libs
+
+ if test "$have_xft" = yes; then
+ #
+ # we appear to have Xft; check for headers/libs to be sure.
+ #
+ ac_save_xft_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $ac_xft_config_cflags"
+
+ have_xft=no
+ AC_CHECK_X_HEADER(X11/Xft/Xft.h, [have_xft=yes])
+
+ CPPFLAGS="$ac_save_xft_CPPFLAGS"
+ fi
+
+ if test "$have_xft" = yes; then
+ # we have the headers, now check for the libraries
+ have_xft=no
+ xft_halfassed=yes
+
+ AC_MSG_RESULT(checking for Xft usability...)
+ AC_CHECK_X_LIB(c, XftDrawStringUtf8, [have_xft=yes],,
+ $ac_xft_config_libs -lX11 -lXext -lm)
+ fi
+
+ if test "$have_xft" = no; then
+ AC_MSG_RESULT(checking for Xft usability... no)
+ fi
+fi
+
+if test "$have_xft" = yes; then
+ INCLUDES="$INCLUDES $ac_xft_config_cflags"
+ XFT_LIBS="$ac_xft_config_libs"
+ XFT_SRCS=''
+ XFT_OBJS=''
+ AC_DEFINE(HAVE_XFT)
+else
+ XFT_LIBS=''
+ XFT_SRCS='$(UTILS_SRC)/xft.c'
+ XFT_OBJS='$(UTILS_BIN)/xft.o'
+fi
+
+