-# Check several libraries without adding -lxxx to LIBS, without
-# defining HAVE_LIBXXX nor HAVE_XXX_H because they are used only for
-# libm17-X.so. Instead, define XXX_LD_FLAGS and HAVE_XXX if library
-# XXX is available. CPPFLAGS will be augmented.
+dnl Checks where the m17n database is installed.
+
+AC_CHECK_PROG(HAVE_M17N_DB, m17n-db, yes)
+if test "x$HAVE_M17N_DB" = "xyes"; then
+ M17NDIR=`m17n-db`
+else
+ M17NDIR="${datadir}/m17n"
+fi
+AC_SUBST(M17NDIR)
+
+dnl Checks which levels of APIs should be compiled.
+
+AC_ARG_ENABLE(gui,
+ AC_HELP_STRING([--with-gui],
+ [with GUI level APIs (default is YES)]))
+
+AM_CONDITIONAL(WITH_GUI, test x$with_gui != xno)
+
+if test x$with_gui != xno; then
+
+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 funciton 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=
+
+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)