ac-glib.m4 2.6 KB

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