gtk-2.0.m4 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. # Configure paths for GTK+
  2. # Owen Taylor 1997-2001
  3. dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
  4. dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
  5. dnl pass to pkg-config
  6. dnl
  7. AC_DEFUN([AM_PATH_GTK_2_0],
  8. [dnl
  9. dnl Get the cflags and libraries from pkg-config
  10. dnl
  11. AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
  12. , enable_gtktest=yes)
  13. pkg_config_args=gtk+-2.0
  14. for module in . $4
  15. do
  16. case "$module" in
  17. gthread)
  18. pkg_config_args="$pkg_config_args gthread-2.0"
  19. ;;
  20. esac
  21. done
  22. no_gtk=""
  23. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  24. if test x$PKG_CONFIG != xno ; then
  25. if pkg-config --atleast-pkgconfig-version 0.7 ; then
  26. :
  27. else
  28. echo "*** pkg-config too old; version 0.7 or better required."
  29. no_gtk=yes
  30. PKG_CONFIG=no
  31. fi
  32. else
  33. no_gtk=yes
  34. fi
  35. min_gtk_version=ifelse([$1], ,2.0.0,$1)
  36. AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
  37. if test x$PKG_CONFIG != xno ; then
  38. ## don't try to run the test against uninstalled libtool libs
  39. if $PKG_CONFIG --uninstalled $pkg_config_args; then
  40. echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
  41. enable_gtktest=no
  42. fi
  43. if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
  44. :
  45. else
  46. no_gtk=yes
  47. fi
  48. fi
  49. if test x"$no_gtk" = x ; then
  50. GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
  51. GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
  52. gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  53. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  54. gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  55. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  56. gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  57. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  58. if test "x$enable_gtktest" = "xyes" ; then
  59. ac_save_CFLAGS="$CFLAGS"
  60. ac_save_LIBS="$LIBS"
  61. CFLAGS="$CFLAGS $GTK_CFLAGS"
  62. LIBS="$GTK_LIBS $LIBS"
  63. dnl
  64. dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
  65. dnl checks the results of pkg-config to some extent)
  66. dnl
  67. rm -f conf.gtktest
  68. AC_TRY_RUN([
  69. #include <gtk/gtk.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.gtktest");
  78. /* HP/UX 9 (%@#!) writes to sscanf strings */
  79. tmp_version = g_strdup("$min_gtk_version");
  80. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  81. printf("%s, bad version string\n", "$min_gtk_version");
  82. exit(1);
  83. }
  84. if ((gtk_major_version != $gtk_config_major_version) ||
  85. (gtk_minor_version != $gtk_config_minor_version) ||
  86. (gtk_micro_version != $gtk_config_micro_version))
  87. {
  88. printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
  89. $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
  90. gtk_major_version, gtk_minor_version, gtk_micro_version);
  91. printf ("*** was found! If pkg-config was correct, then it is best\n");
  92. printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
  93. printf("*** by modifying your LD_LIBRARY_PATH enviroment 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 pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
  97. printf("*** to point to the correct configuration files\n");
  98. }
  99. else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
  100. (gtk_minor_version != GTK_MINOR_VERSION) ||
  101. (gtk_micro_version != GTK_MICRO_VERSION))
  102. {
  103. printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
  104. GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
  105. printf("*** library (version %d.%d.%d)\n",
  106. gtk_major_version, gtk_minor_version, gtk_micro_version);
  107. }
  108. else
  109. {
  110. if ((gtk_major_version > major) ||
  111. ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
  112. ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
  113. {
  114. return 0;
  115. }
  116. else
  117. {
  118. printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
  119. gtk_major_version, gtk_minor_version, gtk_micro_version);
  120. printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
  121. major, minor, micro);
  122. printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
  123. printf("***\n");
  124. printf("*** If you have already installed a sufficiently new version, this error\n");
  125. printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
  126. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  127. printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
  128. printf("*** correct copy of pkg-config. (In this case, you will have to\n");
  129. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  130. printf("*** so that the correct libraries are found at run-time))\n");
  131. }
  132. }
  133. return 1;
  134. }
  135. ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  136. CFLAGS="$ac_save_CFLAGS"
  137. LIBS="$ac_save_LIBS"
  138. fi
  139. fi
  140. if test "x$no_gtk" = x ; then
  141. AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
  142. ifelse([$2], , :, [$2])
  143. else
  144. AC_MSG_RESULT(no)
  145. if test "$PKG_CONFIG" = "no" ; then
  146. echo "*** A new enough version of pkg-config was not found."
  147. echo "*** See http://pkgconfig.sourceforge.net"
  148. else
  149. if test -f conf.gtktest ; then
  150. :
  151. else
  152. echo "*** Could not run GTK+ test program, checking why..."
  153. ac_save_CFLAGS="$CFLAGS"
  154. ac_save_LIBS="$LIBS"
  155. CFLAGS="$CFLAGS $GTK_CFLAGS"
  156. LIBS="$LIBS $GTK_LIBS"
  157. AC_TRY_LINK([
  158. #include <gtk/gtk.h>
  159. #include <stdio.h>
  160. ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
  161. [ echo "*** The test program compiled, but did not run. This usually means"
  162. echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
  163. echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
  164. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  165. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  166. echo "*** is required on your system"
  167. echo "***"
  168. echo "*** If you have an old version installed, it is best to remove it, although"
  169. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
  170. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  171. echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
  172. CFLAGS="$ac_save_CFLAGS"
  173. LIBS="$ac_save_LIBS"
  174. fi
  175. fi
  176. GTK_CFLAGS=""
  177. GTK_LIBS=""
  178. ifelse([$3], , :, [$3])
  179. fi
  180. AC_SUBST(GTK_CFLAGS)
  181. AC_SUBST(GTK_LIBS)
  182. rm -f conf.gtktest
  183. ])