Ticket #2783: directories is opened in the wrong panel.
[midnight-commander.git] / m4.include / ac-glib.m4
blob535314ad307073dcde0bf6372f5d30f80b4d5577
1 dnl
2 dnl Check whether the g_module_* family of functions works
3 dnl on this system.  We need to know that at the compile time to
4 dnl decide whether to link with X11.
5 dnl
6 AC_DEFUN([AC_G_MODULE_SUPPORTED], [
8     g_module_supported=""
9     if test x"$no_x" = xyes; then
10         textmode_x11_support="no"
11     else
12         found_gmodule=no
13         PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.8], [found_gmodule=yes], [:])
14         if test x"$found_gmodule" = xyes; then
15             g_module_supported="gmodule-no-export-2.0"
16         else
17             dnl try fallback to the generic gmodule
18             PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.8], [found_gmodule=yes], [:])
19             if test x"$found_gmodule" = xyes; then
20                 g_module_supported="gmodule-2.0"
21             fi
22         fi
24         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
25         case x"$g_module_supported" in
26             xgmodule-no-export-2.0|xgmodule-2.0)
27                 if test x`$PKG_CONFIG --variable=gmodule_supported "$g_module_supported"` = xtrue; then
28                     AC_DEFINE([HAVE_GMODULE], [1], [Defined if gmodule functionality is supported])
29                 else
30                     g_module_supported=""
31                 fi
32                 ;;
33             *)
34                 MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
35                 g_module_supported=""
36                 ;;
37         esac
39         AC_DEFINE([HAVE_TEXTMODE_X11_SUPPORT], [1],
40                         [Define to enable getting events from X Window System])
41         textmode_x11_support="yes"
42     fi
44     AM_CONDITIONAL([HAVE_GMODULE], [test x"$g_module_supported" != x])
46     dnl
47     dnl Try to find static libraries for glib and gmodule.
48     dnl
49     if test x$with_glib_static = xyes; then
50         new_GLIB_LIBS=
51         for i in $GLIB_LIBS; do
52             case x$i in
53             x-lglib*)
54                 lib=glib ;;
55             x-lgmodule*)
56                 lib=gmodule ;;
57             *)
58                 lib=
59                 add="$i" ;;
60             esac
62             if test -n "$lib"; then
63                 lib1=`echo $i | sed 's/^-l//'`
64                 if test -f "$GLIB_LIBDIR/lib${lib1}.a"; then
65                     add="$GLIB_LIBDIR/lib${lib1}.a"
66                 else
67                     if test -f "$GLIB_LIBDIR/lib${lib}.a"; then
68                         add="$GLIB_LIBDIR/lib${lib}.a"
69                     else
70                         AC_MSG_ERROR([Cannot find static $lib])
71                     fi
72                 fi
73             fi
74             new_GLIB_LIBS="$new_GLIB_LIBS $add"
75         done
76         GLIB_LIBS="$new_GLIB_LIBS"
77     fi
81 AC_DEFUN([AC_CHECK_GLIB], [
82     dnl
83     dnl First try glib 2.x.
84     dnl Keep this check close to the beginning, so that the users
85     dnl without any glib won't have their time wasted by other checks.
86     dnl
88     AC_ARG_WITH([glib_static],
89         AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@]))
91     glib_found=no
92     PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.8], [glib_found=yes], [:])
93     if test x"$glib_found" = xno; then
94         AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)])
95     fi