+dnl Checks if dlopen exists, and if it's in libc or libdl.
+
+AC_SEARCH_LIBS(dlopen, dl,
+ AC_DEFINE(HAVE_DLOPEN, 1,
+ [Define to 1 if you have the function dlopen.]))
+
+dnl Check several libraries without adding -lxxx to LIBS, without
+dnl defining HAVE_LIBXXX nor HAVE_XXX_H because they are used only by
+dnl some libraries (e.g. libm17n-X.so). Instead, define XXX_LD_FLAGS
+dnl and HAVE_XXX if library XXX is available. CPPFLAGS will be
+dnl augmented.
+
+M17N_EXT_LIBS=
+
+AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
+
+if test "x$no_x" != "xyes"; then
+ AC_DEFINE(HAVE_X11, 1, [Define to 1 if you have X11.])
+ X11_LD_FLAGS="-lXt -lX11"
+ M17N_EXT_LIBS="$M17N_EXT_LIBS X11"
+
+ if test "x$HAVE_XAW" = "xyes"; then
+ AC_DEFINE(HAVE_X11_XAW_COMMAND_H, 1,
+ [Define to 1 if you have the Xaw header files.])
+ XAW_LD_FLAGS="-lXaw -lXmu"
+ CONFIG_FLAGS="$CONFIG_FLAGS -DHAVE_X11_XAW_COMMAND_H"
+ M17N_EXT_LIBS="$M17N_EXT_LIBS Xaw"
+ fi
+fi
+AC_SUBST(X11_LD_FLAGS)
+AC_SUBST(XAW_LD_FLAGS)
+
+dnl Check for fribidi library.
+save_CPPFLAGS="$CPPFLAGS"
+save_LIBS="$LIBS"
+AC_CHECK_PROG(HAVE_FRIBIDI_CONFIG, fribidi-config, yes)
+if test "x$HAVE_FRIBIDI_CONFIG" = "xyes"; then
+ CPPFLAGS="$CPPFLAGS `fribidi-config --cflags`"
+ FRIBIDI_LD_FLAGS="`fribidi-config --libs`"
+ LIBS="$LIBS $FRIBIDI_LD_FLAGS"
+else
+ FRIBIDI_LD_FLAGS=-lfribidi
+fi