-# Check for libxml2 usability.
-AC_CHECK_LIB(xml2, xmlParseMemory, HAVE_XML2=yes, HAVE_XML2=no)
-if test "x$HAVE_XML2" = "xyes"; then
- save_CPPFLAGS=$CPPFLAGS
- CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2"
- AC_CHECK_HEADER(libxml/tree.h,, HAVE_XML2=no, /**/)
- if test "x$HAVE_XML2" = "xyes"; then
- AC_DEFINE(HAVE_XML2, 1,
- [Define to 1 if you have libxml2 library and header file])
- XML2_LD_FLAGS="-lxml2"
+dnl Check for Xft2 usability.
+save_CPPFLAGS="$CPPFLAGS"
+save_LIBS="$LIBS"
+XFT2_LD_FLAGS="-lXft -lfreetype -lfontconfig -lXrender -lX11"
+AC_CHECK_PROG(HAVE_XFT_CONFIG, xft-config, yes)
+if test "x$HAVE_XFT_CONFIG" = "xyes"; then
+ CPPFLAGS="$CPPFLAGS `xft-config --cflags`"
+ XFT2_LD_FLAGS="`xft-config --libs`"
+elif test "x$HAVE_PKG_CONFIG" = "xyes" ; then
+ if pkg-config xft ; then
+ CPPFLAGS="$CPPFLAGS `pkg-config --cflags xft`"
+ XFT2_LD_FLAGS="`pkg-config --libs xft`"
+ fi
+fi
+LIBS="$LIBS $XFT2_LD_FLAGS"
+AC_CHECK_LIB(Xft, XftDrawCreate, HAVE_XFT2=yes, HAVE_XFT2=no)
+AC_CHECK_HEADER(X11/Xft/Xft.h,, HAVE_XFT2=no,
+ [#include <X11/Xft/Xft.h>
+#if XftVersion >= 20000
+#else
+Version too old. Compiling this line should fail.
+#endif])
+if test "x$HAVE_XFT2" = "xyes"; then
+ AC_DEFINE(HAVE_XFT2, 1,
+ [Define to 1 if you have Xft2 library and header file.])
+ M17N_EXT_LIBS="$M17N_EXT_LIBS xft2"
+else
+ XFT2_LD_FLAGS=
+ CPPFLAGS="$save_CPPFLAGS"
+fi
+LIBS="$save_LIBS"
+AC_SUBST(XFT2_LD_FLAGS)
+
+dnl Check for fontconfig usability.
+AC_ARG_WITH(fontconfig,
+ AC_HELP_STRING([--with-fontconfig],
+ [with FontConfig library (default is YES)]))
+if test "x$with_fontconfig" != "xno"; then
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LIBS="$LIBS"
+ FONTCONFIG_LD_FLAGS=-lfontconfig
+ if test "x$HAVE_PKG_CONFIG" = "xyes"; then
+ if pkg-config --exists fontconfig; then
+ CPPFLAGS="$CPPFLAGS `pkg-config --cflags fontconfig`"
+ FONTCONFIG_LD_FLAGS="`pkg-config --libs fontconfig`"
+ LIBS="$LIBS $FONTCONFIG_LD_FLAGS"
+ fi
+ fi
+ AC_CHECK_LIB(fontconfig, FcInit, HAVE_FONTCONFIG=yes, HAVE_FONTCONFIG=no)
+ AC_CHECK_HEADER(fontconfig/fontconfig.h, , HAVE_FONTCONFIG=no)
+ if test "x$HAVE_FONTCONFIG" = "xyes"; then
+ AC_DEFINE(HAVE_FONTCONFIG, 1,
+ [Define to 1 if you have fontconfig library and header file.])
+ M17N_EXT_LIBS="$M17N_EXT_LIBS fontconfig"