/build/autoconf/glib.m4

http://github.com/zpao/v8monkey · m4 · 200 lines · 184 code · 9 blank · 7 comment · 0 complexity · 722ef7349731343e2887c941b3443500 MD5 · raw file

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