glib.m4 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # Configure paths for GLIB
  2. # Owen Taylor 97-11-3
  3. dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
  4. dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" is specified
  5. dnl in MODULES, feature the glib-config gmodule option.
  6. dnl
  7. AC_DEFUN(AM_PATH_GLIB,
  8. [dnl
  9. dnl Get the cflags and libraries from the glib-config script
  10. dnl
  11. AC_ARG_WITH(glib-prefix,[ --with-glib-prefix=PFX Prefix where GLIB is installed (optional)],
  12. glib_config_prefix="$withval", glib_config_prefix="")
  13. AC_ARG_WITH(glib-exec-prefix,[ --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)],
  14. glib_config_exec_prefix="$withval", glib_config_exec_prefix="")
  15. AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program],
  16. , enable_glibtest=yes)
  17. if test x$glib_config_exec_prefix != x ; then
  18. glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix"
  19. if test x${GLIB_CONFIG+set} != xset ; then
  20. GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config
  21. fi
  22. fi
  23. if test x$glib_config_prefix != x ; then
  24. glib_config_args="$glib_config_args --prefix=$glib_config_prefix"
  25. if test x${GLIB_CONFIG+set} != xset ; then
  26. GLIB_CONFIG=$glib_config_prefix/bin/glib-config
  27. fi
  28. fi
  29. case "$4" in
  30. *gmodule*) glib_config_args="$glib_config_args gmodule";;
  31. esac
  32. AC_PATH_PROG(GLIB_CONFIG, glib-config, no)
  33. min_glib_version=ifelse([$1], ,0.99.7,$1)
  34. AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
  35. no_glib=""
  36. if test "$GLIB_CONFIG" = "no" ; then
  37. no_glib=yes
  38. else
  39. GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags`
  40. GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs`
  41. glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \
  42. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  43. glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \
  44. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  45. glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \
  46. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  47. if test "x$enable_glibtest" = "xyes" ; then
  48. ac_save_CFLAGS="$CFLAGS"
  49. ac_save_LIBS="$LIBS"
  50. CFLAGS="$CFLAGS $GLIB_CFLAGS"
  51. LIBS="$LIBS $GLIB_LIBS"
  52. dnl
  53. dnl Now check if the installed GLIB is sufficiently new. (Also sanity
  54. dnl checks the results of glib-config to some extent
  55. dnl
  56. rm -f conf.glibtest
  57. AC_TRY_RUN([
  58. #include <glib.h>
  59. #include <stdio.h>
  60. #include <stdlib.h>
  61. int
  62. main ()
  63. {
  64. int major, minor, micro;
  65. char *tmp_version;
  66. system ("touch conf.glibtest");
  67. /* HP/UX 9 (%@#!) writes to sscanf strings */
  68. tmp_version = g_strdup("$min_glib_version");
  69. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  70. printf("%s, bad version string\n", "$min_glib_version");
  71. exit(1);
  72. }
  73. if ((glib_major_version != $glib_config_major_version) ||
  74. (glib_minor_version != $glib_config_minor_version) ||
  75. (glib_micro_version != $glib_config_micro_version))
  76. {
  77. printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
  78. $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
  79. glib_major_version, glib_minor_version, glib_micro_version);
  80. printf ("*** was found! If glib-config was correct, then it is best\n");
  81. printf ("*** to remove the old version of GLIB. You may also be able to fix the error\n");
  82. printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
  83. printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
  84. printf("*** required on your system.\n");
  85. printf("*** If glib-config was wrong, set the environment variable GLIB_CONFIG\n");
  86. printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n");
  87. printf("*** before re-running configure\n");
  88. }
  89. else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
  90. (glib_minor_version != GLIB_MINOR_VERSION) ||
  91. (glib_micro_version != GLIB_MICRO_VERSION))
  92. {
  93. printf("*** GLIB header files (version %d.%d.%d) do not match\n",
  94. GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
  95. printf("*** library (version %d.%d.%d)\n",
  96. glib_major_version, glib_minor_version, glib_micro_version);
  97. }
  98. else
  99. {
  100. if ((glib_major_version > major) ||
  101. ((glib_major_version == major) && (glib_minor_version > minor)) ||
  102. ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
  103. {
  104. return 0;
  105. }
  106. else
  107. {
  108. printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
  109. glib_major_version, glib_minor_version, glib_micro_version);
  110. printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
  111. major, minor, micro);
  112. printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
  113. printf("***\n");
  114. printf("*** If you have already installed a sufficiently new version, this error\n");
  115. printf("*** probably means that the wrong copy of the glib-config shell script is\n");
  116. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  117. printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n");
  118. printf("*** correct copy of glib-config. (In this case, you will have to\n");
  119. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  120. printf("*** so that the correct libraries are found at run-time))\n");
  121. }
  122. }
  123. return 1;
  124. }
  125. ],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  126. CFLAGS="$ac_save_CFLAGS"
  127. LIBS="$ac_save_LIBS"
  128. fi
  129. fi
  130. if test "x$no_glib" = x ; then
  131. AC_MSG_RESULT(yes)
  132. ifelse([$2], , :, [$2])
  133. else
  134. AC_MSG_RESULT(no)
  135. if test "$GLIB_CONFIG" = "no" ; then
  136. echo "*** The glib-config script installed by GLIB could not be found"
  137. echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in"
  138. echo "*** your path, or set the GLIB_CONFIG environment variable to the"
  139. echo "*** full path to glib-config."
  140. else
  141. if test -f conf.glibtest ; then
  142. :
  143. else
  144. echo "*** Could not run GLIB test program, checking why..."
  145. CFLAGS="$CFLAGS $GLIB_CFLAGS"
  146. LIBS="$LIBS $GLIB_LIBS"
  147. AC_TRY_LINK([
  148. #include <glib.h>
  149. #include <stdio.h>
  150. ], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
  151. [ echo "*** The test program compiled, but did not run. This usually means"
  152. echo "*** that the run-time linker is not finding GLIB or finding the wrong"
  153. echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
  154. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  155. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  156. echo "*** is required on your system"
  157. echo "***"
  158. echo "*** If you have an old version installed, it is best to remove it, although"
  159. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
  160. echo "***"
  161. echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
  162. echo "*** came with the system with the command"
  163. echo "***"
  164. echo "*** rpm --erase --nodeps gtk gtk-devel" ],
  165. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  166. echo "*** exact error that occured. This usually means GLIB was incorrectly installed"
  167. echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
  168. echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ])
  169. CFLAGS="$ac_save_CFLAGS"
  170. LIBS="$ac_save_LIBS"
  171. fi
  172. fi
  173. GLIB_CFLAGS=""
  174. GLIB_LIBS=""
  175. ifelse([$3], , :, [$3])
  176. fi
  177. AC_SUBST(GLIB_CFLAGS)
  178. AC_SUBST(GLIB_LIBS)
  179. rm -f conf.glibtest
  180. ])