/tags/rel-0-1-2/FreeSpeech/vflow/macros/gnome-print-check.m4

# · m4 · 171 lines · 145 code · 12 blank · 14 comment · 0 complexity · 54b4408b5877c23896ebcb3c6ebb0fbb MD5 · raw file

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