(copy_dir_dir): get rid of extra string duplication.
[midnight-commander.git] / m4.include / ac-glib.m4
blob2277dfa06c0e1d5c55b5bd18179f5a0b8fde26a7
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=""
10     found_gmodule=no
11     PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.8], [found_gmodule=yes], [:])
12     if test x"$found_gmodule" = xyes; then
13         g_module_supported="gmodule-no-export-2.0"
14     else
15         dnl try fallback to the generic gmodule
16         PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.8], [found_gmodule=yes], [:])
17         if test x"$found_gmodule" = xyes; then
18             g_module_supported="gmodule-2.0"
19         fi
20     fi
22     case x"$g_module_supported" in
23         xgmodule-no-export-2.0|xgmodule-2.0)
24             if test x`$PKG_CONFIG --variable=gmodule_supported "$g_module_supported"` = xtrue; then
25                 AC_DEFINE([HAVE_GMODULE], [1], [Defined if gmodule functionality is supported])
26             else
27                 g_module_supported=""
28             fi
29             ;;
30         *)
31             g_module_supported=""
32             ;;
33     esac
35     AM_CONDITIONAL([HAVE_GMODULE], [test x"$g_module_supported" != x])
37     dnl
38     dnl Try to find static libraries for glib and gmodule.
39     dnl
40     if test x$with_glib_static = xyes; then
41         new_GLIB_LIBS=
42         for i in $GLIB_LIBS; do
43             case x$i in
44             x-lglib*)
45                 lib=glib ;;
46             x-lgmodule*)
47                 lib=gmodule ;;
48             *)
49                 lib=
50                 add="$i" ;;
51             esac
53             if test -n "$lib"; then
54                 lib1=`echo $i | sed 's/^-l//'`
55                 if test -f "$GLIB_LIBDIR/lib${lib1}.a"; then
56                     add="$GLIB_LIBDIR/lib${lib1}.a"
57                 else
58                     if test -f "$GLIB_LIBDIR/lib${lib}.a"; then
59                         add="$GLIB_LIBDIR/lib${lib}.a"
60                     else
61                         AC_MSG_ERROR([Cannot find static $lib])
62                     fi
63                 fi
64             fi
65             new_GLIB_LIBS="$new_GLIB_LIBS $add"
66         done
67         GLIB_LIBS="$new_GLIB_LIBS"
68     fi
72 AC_DEFUN([AC_CHECK_GLIB], [
73     dnl
74     dnl First try glib 2.x.
75     dnl Keep this check close to the beginning, so that the users
76     dnl without any glib won't have their time wasted by other checks.
77     dnl
79     AC_ARG_WITH([glib_static],
80         AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@]))
82     glib_found=no
83     PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.8], [glib_found=yes], [:])
84     if test x"$glib_found" = xno; then
85         AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)])
86     fi