/lib/timidity/autoconf/gtk.m4

http://github.com/xbmc/xbmc · m4 · 194 lines · 177 code · 8 blank · 9 comment · 0 complexity · 4bbe0df16259421ab575d1c987dfe16a MD5 · raw file

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