glib-2.0.m4 8.1 KB

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