gtk-3.0.m4 8.1 KB

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