You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
4.3 KiB

  1. dnl AM_PATH_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  2. dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS
  3. dnl
  4. AC_DEFUN([AM_PATH_CHECK],
  5. [
  6. AC_MSG_WARN([A@&t@M_PATH_CHECK() is deprecated])
  7. AC_MSG_WARN([[use P@&t@KG_CHECK_MODULES([CHECK], [check >= 0.9.4]) instead]])
  8. AC_ARG_WITH([check],
  9. [ --with-check=PATH prefix where check is installed [default=auto]])
  10. min_check_version=ifelse([$1], ,0.8.2,$1)
  11. AC_MSG_CHECKING(for check - version >= $min_check_version)
  12. if test x$with_check = xno; then
  13. AC_MSG_RESULT(disabled)
  14. ifelse([$3], , AC_MSG_ERROR([disabling check is not supported]), [$3])
  15. else
  16. if test "x$with_check" != x; then
  17. CHECK_CFLAGS="-I$with_check/include"
  18. CHECK_LIBS="-L$with_check/lib -lcheck"
  19. else
  20. CHECK_CFLAGS=""
  21. CHECK_LIBS="-lcheck"
  22. fi
  23. ac_save_CFLAGS="$CFLAGS"
  24. ac_save_LIBS="$LIBS"
  25. CFLAGS="$CFLAGS $CHECK_CFLAGS"
  26. LIBS="$CHECK_LIBS $LIBS"
  27. rm -f conf.check-test
  28. AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([])
  29. #include <check.h>
  30. int main ()
  31. {
  32. int major, minor, micro;
  33. char *tmp_version;
  34. system ("touch conf.check-test");
  35. /* HP/UX 9 (%@#!) writes to sscanf strings */
  36. tmp_version = strdup("$min_check_version");
  37. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  38. printf("%s, bad version string\n", "$min_check_version");
  39. return 1;
  40. }
  41. if ((CHECK_MAJOR_VERSION != check_major_version) ||
  42. (CHECK_MINOR_VERSION != check_minor_version) ||
  43. (CHECK_MICRO_VERSION != check_micro_version))
  44. {
  45. printf("\n*** The check header file (version %d.%d.%d) does not match\n",
  46. CHECK_MAJOR_VERSION, CHECK_MINOR_VERSION, CHECK_MICRO_VERSION);
  47. printf("*** the check library (version %d.%d.%d).\n",
  48. check_major_version, check_minor_version, check_micro_version);
  49. return 1;
  50. }
  51. if ((check_major_version > major) ||
  52. ((check_major_version == major) && (check_minor_version > minor)) ||
  53. ((check_major_version == major) && (check_minor_version == minor) && (check_micro_version >= micro)))
  54. {
  55. return 0;
  56. }
  57. else
  58. {
  59. printf("\n*** An old version of check (%d.%d.%d) was found.\n",
  60. check_major_version, check_minor_version, check_micro_version);
  61. printf("*** You need a version of check being at least %d.%d.%d.\n", major, minor, micro);
  62. printf("***\n");
  63. printf("*** If you have already installed a sufficiently new version, this error\n");
  64. printf("*** probably means that the wrong copy of the check library and header\n");
  65. printf("*** file is being found. Rerun configure with the --with-check=PATH option\n");
  66. printf("*** to specify the prefix where the correct version was installed.\n");
  67. }
  68. return 1;
  69. }
  70. ])],, no_check=yes, [echo $ac_n "cross compiling; assumed OK... $ac_c"])
  71. CFLAGS="$ac_save_CFLAGS"
  72. LIBS="$ac_save_LIBS"
  73. if test "x$no_check" = x ; then
  74. AC_MSG_RESULT(yes)
  75. ifelse([$2], , :, [$2])
  76. else
  77. AC_MSG_RESULT(no)
  78. if test -f conf.check-test ; then
  79. :
  80. else
  81. echo "*** Could not run check test program, checking why..."
  82. CFLAGS="$CFLAGS $CHECK_CFLAGS"
  83. LIBS="$CHECK_LIBS $LIBS"
  84. AC_TRY_LINK([
  85. #include <stdio.h>
  86. #include <stdlib.h>
  87. #include <check.h>
  88. ], , [ echo "*** The test program compiled, but did not run. This usually means"
  89. echo "*** that the run-time linker is not finding check. You'll need to set your"
  90. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  91. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  92. echo "*** is required on your system"
  93. echo "***"
  94. echo "*** If you have an old version installed, it is best to remove it, although"
  95. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  96. [ echo "*** The test program failed to compile or link. See the file config.log for"
  97. echo "*** the exact error that occured." ])
  98. CFLAGS="$ac_save_CFLAGS"
  99. LIBS="$ac_save_LIBS"
  100. fi
  101. CHECK_CFLAGS=""
  102. CHECK_LIBS=""
  103. rm -f conf.check-test
  104. ifelse([$3], , AC_MSG_ERROR([check not found]), [$3])
  105. fi
  106. AC_SUBST(CHECK_CFLAGS)
  107. AC_SUBST(CHECK_LIBS)
  108. rm -f conf.check-test
  109. fi
  110. ])