gdk-pixbuf.m4 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # Configure paths for gdk-pixbuf
  2. # Elliot Lee 2000-01-10
  3. # stolen from Raph Levien 98-11-18
  4. # stolen from Manish Singh 98-9-30
  5. # stolen back from Frank Belew
  6. # stolen from Manish Singh
  7. # Shamelessly stolen from Owen Taylor
  8. dnl AM_PATH_GDK_PIXBUF([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  9. dnl Test for GDK_PIXBUF, and define GDK_PIXBUF_CFLAGS and GDK_PIXBUF_LIBS
  10. dnl
  11. AC_DEFUN([AM_PATH_GDK_PIXBUF],
  12. [dnl
  13. dnl Get the cflags and libraries from the gdk-pixbuf-config script
  14. dnl
  15. AC_ARG_WITH(gdk-pixbuf-prefix,[ --with-gdk-pixbuf-prefix=PFX Prefix where GDK_PIXBUF is installed (optional)],
  16. gdk_pixbuf_prefix="$withval", gdk_pixbuf_prefix="")
  17. AC_ARG_WITH(gdk-pixbuf-exec-prefix,[ --with-gdk-pixbuf-exec-prefix=PFX Exec prefix where GDK_PIXBUF is installed (optional)],
  18. gdk_pixbuf_exec_prefix="$withval", gdk_pixbuf_exec_prefix="")
  19. AC_ARG_ENABLE(gdk_pixbuftest, [ --disable-gdk_pixbuftest Do not try to compile and run a test GDK_PIXBUF program],
  20. , enable_gdk_pixbuftest=yes)
  21. if test x$gdk_pixbuf_exec_prefix != x ; then
  22. gdk_pixbuf_args="$gdk_pixbuf_args --exec-prefix=$gdk_pixbuf_exec_prefix"
  23. if test x${GDK_PIXBUF_CONFIG+set} = xset ; then
  24. GDK_PIXBUF_CONFIG=$gdk_pixbuf_exec_prefix/gdk-pixbuf-config
  25. fi
  26. fi
  27. if test x$gdk_pixbuf_prefix != x ; then
  28. gdk_pixbuf_args="$gdk_pixbuf_args --prefix=$gdk_pixbuf_prefix"
  29. if test x${GDK_PIXBUF_CONFIG+set} = xset ; then
  30. GDK_PIXBUF_CONFIG=$gdk_pixbuf_prefix/bin/gdk-pixbuf-config
  31. fi
  32. fi
  33. AC_PATH_PROG(GDK_PIXBUF_CONFIG, gdk-pixbuf-config, no)
  34. min_gdk_pixbuf_version=ifelse([$1], ,0.2.5,$1)
  35. AC_MSG_CHECKING(for GDK_PIXBUF - version >= $min_gdk_pixbuf_version)
  36. no_gdk_pixbuf=""
  37. if test "$GDK_PIXBUF_CONFIG" = "no" ; then
  38. no_gdk_pixbuf=yes
  39. else
  40. GDK_PIXBUF_CFLAGS=`$GDK_PIXBUF_CONFIG $gdk_pixbufconf_args --cflags`
  41. GDK_PIXBUF_LIBS=`$GDK_PIXBUF_CONFIG $gdk_pixbufconf_args --libs`
  42. gdk_pixbuf_major_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_args --version | \
  43. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  44. gdk_pixbuf_minor_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_args --version | \
  45. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  46. gdk_pixbuf_micro_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_config_args --version | \
  47. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  48. if test "x$enable_gdk_pixbuftest" = "xyes" ; then
  49. ac_save_CFLAGS="$CFLAGS"
  50. ac_save_LIBS="$LIBS"
  51. CFLAGS="$CFLAGS $GDK_PIXBUF_CFLAGS"
  52. LIBS="$LIBS $GDK_PIXBUF_LIBS"
  53. dnl
  54. dnl Now check if the installed GDK_PIXBUF is sufficiently new. (Also sanity
  55. dnl checks the results of gdk-pixbuf-config to some extent
  56. dnl
  57. rm -f conf.gdk_pixbuftest
  58. AC_TRY_RUN([
  59. #include <stdio.h>
  60. #include <stdlib.h>
  61. #include <string.h>
  62. #include <gdk-pixbuf/gdk-pixbuf.h>
  63. char*
  64. my_strdup (char *str)
  65. {
  66. char *new_str;
  67. if (str)
  68. {
  69. new_str = malloc ((strlen (str) + 1) * sizeof(char));
  70. strcpy (new_str, str);
  71. }
  72. else
  73. new_str = NULL;
  74. return new_str;
  75. }
  76. int main ()
  77. {
  78. int major, minor, micro;
  79. char *tmp_version;
  80. system ("touch conf.gdk_pixbuftest");
  81. /* HP/UX 9 (%@#!) writes to sscanf strings */
  82. tmp_version = my_strdup("$min_gdk_pixbuf_version");
  83. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  84. printf("%s, bad version string\n", "$min_gdk_pixbuf_version");
  85. exit(1);
  86. }
  87. if (($gdk_pixbuf_major_version > major) ||
  88. (($gdk_pixbuf_major_version == major) && ($gdk_pixbuf_minor_version > minor)) ||
  89. (($gdk_pixbuf_major_version == major) && ($gdk_pixbuf_minor_version == minor) && ($gdk_pixbuf_micro_version >= micro)))
  90. {
  91. return 0;
  92. }
  93. else
  94. {
  95. printf("\n*** 'gdk-pixbuf-config --version' returned %d.%d.%d, but the minimum version\n", $gdk_pixbuf_major_version, $gdk_pixbuf_minor_version, $gdk_pixbuf_micro_version);
  96. printf("*** of GDK_PIXBUF required is %d.%d.%d. If gdk-pixbuf-config is correct, then it is\n", major, minor, micro);
  97. printf("*** best to upgrade to the required version.\n");
  98. printf("*** If gdk-pixbuf-config was wrong, set the environment variable GDK_PIXBUF_CONFIG\n");
  99. printf("*** to point to the correct copy of gdk-pixbuf-config, and remove the file\n");
  100. printf("*** config.cache before re-running configure\n");
  101. return 1;
  102. }
  103. }
  104. ],, no_gdk_pixbuf=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  105. CFLAGS="$ac_save_CFLAGS"
  106. LIBS="$ac_save_LIBS"
  107. fi
  108. fi
  109. if test "x$no_gdk_pixbuf" = x ; then
  110. AC_MSG_RESULT(yes)
  111. ifelse([$2], , :, [$2])
  112. else
  113. AC_MSG_RESULT(no)
  114. if test "$GDK_PIXBUF_CONFIG" = "no" ; then
  115. echo "*** The gdk-pixbuf-config script installed by GDK_PIXBUF could not be found"
  116. echo "*** If GDK_PIXBUF was installed in PREFIX, make sure PREFIX/bin is in"
  117. echo "*** your path, or set the GDK_PIXBUF_CONFIG environment variable to the"
  118. echo "*** full path to gdk-pixbuf-config."
  119. else
  120. if test -f conf.gdk_pixbuftest ; then
  121. :
  122. else
  123. echo "*** Could not run GDK_PIXBUF test program, checking why..."
  124. CFLAGS="$CFLAGS $GDK_PIXBUF_CFLAGS"
  125. LIBS="$LIBS $GDK_PIXBUF_LIBS"
  126. AC_TRY_LINK([
  127. #include <stdio.h>
  128. #include <gdk-pixbuf/gdk-pixbuf.h>
  129. ], [ return 0; ],
  130. [ echo "*** The test program compiled, but did not run. This usually means"
  131. echo "*** that the run-time linker is not finding GDK_PIXBUF or finding the wrong"
  132. echo "*** version of GDK_PIXBUF. If it is not finding GDK_PIXBUF, you'll need to set your"
  133. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  134. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  135. echo "*** is required on your system"
  136. echo "***"
  137. echo "*** If you have an old version installed, it is best to remove it, although"
  138. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  139. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  140. echo "*** exact error that occured. This usually means GDK_PIXBUF was incorrectly installed"
  141. echo "*** or that you have moved GDK_PIXBUF since it was installed. In the latter case, you"
  142. echo "*** may want to edit the gdk-pixbuf-config script: $GDK_PIXBUF_CONFIG" ])
  143. CFLAGS="$ac_save_CFLAGS"
  144. LIBS="$ac_save_LIBS"
  145. fi
  146. fi
  147. GDK_PIXBUF_CFLAGS=""
  148. GDK_PIXBUF_LIBS=""
  149. ifelse([$3], , :, [$3])
  150. fi
  151. AC_SUBST(GDK_PIXBUF_CFLAGS)
  152. AC_SUBST(GDK_PIXBUF_LIBS)
  153. rm -f conf.gdk_pixbuftest
  154. ])