glib-2.0.m4 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # Configure paths for GLIB
  2. # Owen Taylor 1997-2001
  3. # Increment this whenever this file is changed.
  4. #serial 3
  5. dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
  6. dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject,
  7. dnl gthread, or gio is specified in MODULES, pass to pkg-config
  8. dnl
  9. AC_DEFUN([AM_PATH_GLIB_2_0],
  10. [dnl
  11. dnl Get the cflags and libraries from pkg-config
  12. dnl
  13. dnl We can't use PKG_PREREQ because that needs 0.29.
  14. m4_ifndef([PKG_PROG_PKG_CONFIG],
  15. [pkg.m4 version 0.28 or later is required])
  16. AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program],
  17. , enable_glibtest=yes)
  18. min_glib_version=ifelse([$1], [], [2.0.0], [$1])
  19. pkg_config_args="glib-2.0 >= $min_glib_version"
  20. for module in . $4
  21. do
  22. case "$module" in
  23. gmodule)
  24. pkg_config_args="$pkg_config_args gmodule-2.0"
  25. ;;
  26. gmodule-no-export)
  27. pkg_config_args="$pkg_config_args gmodule-no-export-2.0"
  28. ;;
  29. gobject)
  30. pkg_config_args="$pkg_config_args gobject-2.0"
  31. ;;
  32. gthread)
  33. pkg_config_args="$pkg_config_args gthread-2.0"
  34. ;;
  35. gio*)
  36. pkg_config_args="$pkg_config_args $module-2.0"
  37. ;;
  38. esac
  39. done
  40. PKG_PROG_PKG_CONFIG([0.16])
  41. no_glib=""
  42. if test "x$PKG_CONFIG" = x ; then
  43. no_glib=yes
  44. PKG_CONFIG=no
  45. fi
  46. dnl For GLIB_CFLAGS and GLIB_LIBS
  47. PKG_CHECK_MODULES([GLIB], [$pkg_config_args], [:], [:])
  48. dnl For the tools
  49. PKG_CHECK_VAR([GLIB_GENMARSHAL], [glib-2.0], [glib_genmarshal])
  50. PKG_CHECK_VAR([GOBJECT_QUERY], [glib-2.0], [gobject_query])
  51. PKG_CHECK_VAR([GLIB_MKENUMS], [glib-2.0], [glib_mkenums])
  52. PKG_CHECK_VAR([GLIB_COMPILE_RESOURCES], [gio-2.0], [glib_compile_resources])
  53. AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
  54. if test x$PKG_CONFIG != xno ; then
  55. ## don't try to run the test against uninstalled libtool libs
  56. if $PKG_CONFIG --uninstalled $pkg_config_args; then
  57. echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
  58. enable_glibtest=no
  59. fi
  60. if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
  61. :
  62. else
  63. no_glib=yes
  64. fi
  65. fi
  66. if test x"$no_glib" = x ; then
  67. glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
  68. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  69. glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
  70. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  71. glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
  72. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  73. if test "x$enable_glibtest" = "xyes" ; then
  74. ac_save_CFLAGS="$CFLAGS"
  75. ac_save_LIBS="$LIBS"
  76. CFLAGS="$CFLAGS $GLIB_CFLAGS"
  77. LIBS="$GLIB_LIBS $LIBS"
  78. dnl
  79. dnl Now check if the installed GLIB is sufficiently new. (Also sanity
  80. dnl checks the results of pkg-config to some extent)
  81. dnl
  82. rm -f conf.glibtest
  83. AC_TRY_RUN([
  84. #include <glib.h>
  85. #include <stdio.h>
  86. #include <stdlib.h>
  87. int
  88. main (void)
  89. {
  90. unsigned int major, minor, micro;
  91. fclose (fopen ("conf.glibtest", "w"));
  92. if (sscanf("$min_glib_version", "%u.%u.%u", &major, &minor, &micro) != 3) {
  93. printf("%s, bad version string\n", "$min_glib_version");
  94. exit(1);
  95. }
  96. if ((glib_major_version != $glib_config_major_version) ||
  97. (glib_minor_version != $glib_config_minor_version) ||
  98. (glib_micro_version != $glib_config_micro_version))
  99. {
  100. printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
  101. $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
  102. glib_major_version, glib_minor_version, glib_micro_version);
  103. printf ("*** was found! If pkg-config was correct, then it is best\n");
  104. printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
  105. printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
  106. printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
  107. printf("*** required on your system.\n");
  108. printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
  109. printf("*** to point to the correct configuration files\n");
  110. }
  111. else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
  112. (glib_minor_version != GLIB_MINOR_VERSION) ||
  113. (glib_micro_version != GLIB_MICRO_VERSION))
  114. {
  115. printf("*** GLIB header files (version %d.%d.%d) do not match\n",
  116. GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
  117. printf("*** library (version %d.%d.%d)\n",
  118. glib_major_version, glib_minor_version, glib_micro_version);
  119. }
  120. else
  121. {
  122. if ((glib_major_version > major) ||
  123. ((glib_major_version == major) && (glib_minor_version > minor)) ||
  124. ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
  125. {
  126. return 0;
  127. }
  128. else
  129. {
  130. printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n",
  131. glib_major_version, glib_minor_version, glib_micro_version);
  132. printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n",
  133. major, minor, micro);
  134. printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
  135. printf("***\n");
  136. printf("*** If you have already installed a sufficiently new version, this error\n");
  137. printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
  138. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  139. printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
  140. printf("*** correct copy of pkg-config. (In this case, you will have to\n");
  141. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  142. printf("*** so that the correct libraries are found at run-time))\n");
  143. }
  144. }
  145. return 1;
  146. }
  147. ],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  148. CFLAGS="$ac_save_CFLAGS"
  149. LIBS="$ac_save_LIBS"
  150. fi
  151. fi
  152. if test "x$no_glib" = x ; then
  153. AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
  154. ifelse([$2], , :, [$2])
  155. else
  156. AC_MSG_RESULT(no)
  157. if test "$PKG_CONFIG" = "no" ; then
  158. echo "*** A new enough version of pkg-config was not found."
  159. echo "*** See http://www.freedesktop.org/software/pkgconfig/"
  160. else
  161. if test -f conf.glibtest ; then
  162. :
  163. else
  164. echo "*** Could not run GLIB test program, checking why..."
  165. ac_save_CFLAGS="$CFLAGS"
  166. ac_save_LIBS="$LIBS"
  167. CFLAGS="$CFLAGS $GLIB_CFLAGS"
  168. LIBS="$LIBS $GLIB_LIBS"
  169. AC_TRY_LINK([
  170. #include <glib.h>
  171. #include <stdio.h>
  172. ], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
  173. [ echo "*** The test program compiled, but did not run. This usually means"
  174. echo "*** that the run-time linker is not finding GLIB or finding the wrong"
  175. echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
  176. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  177. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  178. echo "*** is required on your system"
  179. echo "***"
  180. echo "*** If you have an old version installed, it is best to remove it, although"
  181. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
  182. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  183. echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
  184. CFLAGS="$ac_save_CFLAGS"
  185. LIBS="$ac_save_LIBS"
  186. fi
  187. fi
  188. GLIB_CFLAGS=""
  189. GLIB_LIBS=""
  190. GLIB_GENMARSHAL=""
  191. GOBJECT_QUERY=""
  192. GLIB_MKENUMS=""
  193. GLIB_COMPILE_RESOURCES=""
  194. ifelse([$3], , :, [$3])
  195. fi
  196. rm -f conf.glibtest
  197. ])