ac-glib.m4 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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([mc_GMODULE_SUPPORTED], [
  7. g_module_supported=""
  8. if test x$with_glib_static = xyes; then
  9. AC_MSG_WARN([Static build is enabled... Cannot use GModule])
  10. else
  11. found_gmodule=no
  12. PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.12], [found_gmodule=yes], [:])
  13. if test x"$found_gmodule" = xyes; then
  14. g_module_supported="gmodule-no-export-2.0"
  15. else
  16. dnl try fallback to the generic gmodule
  17. PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.12], [found_gmodule=yes], [:])
  18. if test x"$found_gmodule" = xyes; then
  19. g_module_supported="gmodule-2.0"
  20. fi
  21. 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
  34. if test x"$g_module_supported" != x; then
  35. GLIB_LIBS="$GMODULE_LIBS"
  36. GLIB_CFLAGS="$GMODULE_CFLAGS"
  37. fi
  38. fi
  39. AM_CONDITIONAL([HAVE_GMODULE], [test x"$g_module_supported" != x])
  40. ])
  41. AC_DEFUN([mc_CHECK_STATIC_GLIB], [
  42. dnl
  43. dnl Try to find static libraries for glib and gmodule.
  44. dnl
  45. AC_ARG_WITH([glib_static],
  46. AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@]),
  47. [
  48. if test x$withval = xno; then
  49. with_glib_static=no
  50. else
  51. with_glib_static=yes
  52. fi
  53. ],
  54. [with_glib_static=no])
  55. if test x$with_glib_static = xyes; then
  56. dnl Redefine GLIB_LIBS using --static option to define linker flags for static linking
  57. GLIB_LIBS=`pkg-config --libs --static glib-2.0`
  58. GLIB_LIBDIR=`pkg-config --variable=libdir glib-2.0`
  59. new_GLIB_LIBS=
  60. for i in $GLIB_LIBS; do
  61. case x$i in
  62. x-lglib*)
  63. lib=glib ;;
  64. *)
  65. lib=
  66. add="$i" ;;
  67. esac
  68. if test -n "$lib"; then
  69. lib1=`echo $i | sed 's/^-l//'`
  70. if test -f "$GLIB_LIBDIR/lib${lib1}.a"; then
  71. add="$GLIB_LIBDIR/lib${lib1}.a"
  72. else
  73. if test -f "$GLIB_LIBDIR/lib${lib}.a"; then
  74. add="$GLIB_LIBDIR/lib${lib}.a"
  75. else
  76. AC_MSG_ERROR([Cannot find static $lib])
  77. fi
  78. fi
  79. fi
  80. new_GLIB_LIBS="$new_GLIB_LIBS $add"
  81. done
  82. GLIB_LIBS="$new_GLIB_LIBS"
  83. fi
  84. ])
  85. AC_DEFUN([AC_CHECK_GLIB], [
  86. dnl
  87. dnl First try glib 2.x.
  88. dnl Keep this check close to the beginning, so that the users
  89. dnl without any glib won't have their time wasted by other checks.
  90. dnl
  91. glib_found=no
  92. PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12], [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.12)])
  95. fi
  96. mc_CHECK_STATIC_GLIB
  97. mc_GMODULE_SUPPORTED
  98. ])