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
5 AC_DEFUN([AM_PATH_CHECK],
8 [ --with-check=PATH prefix where check is installed [default=auto]])
10 min_check_version=ifelse([$1], ,0.9.2,$1)
12 AC_MSG_CHECKING(for check - version >= $min_check_version)
14 if test x$with_check = xno; then
15 AC_MSG_RESULT(disabled)
16 ifelse([$3], , AC_MSG_ERROR([disabling check is not supported]), [$3])
18 if test "x$with_check" != x; then
19 CHECK_CFLAGS="-I$with_check/include"
20 CHECK_LIBS="-L$with_check/lib -lcheck"
26 ac_save_CFLAGS="$CFLAGS"
29 CFLAGS="$CFLAGS $CHECK_CFLAGS"
30 LIBS="$CHECK_LIBS $LIBS"
41 int major, minor, micro;
44 system ("touch conf.check-test");
46 /* HP/UX 9 (%@#!) writes to sscanf strings */
47 tmp_version = strdup("$min_check_version");
48 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
49 printf("%s, bad version string\n", "$min_check_version");
53 if ((CHECK_MAJOR_VERSION != check_major_version) ||
54 (CHECK_MINOR_VERSION != check_minor_version) ||
55 (CHECK_MICRO_VERSION != check_micro_version))
57 printf("\n*** The check header file (version %d.%d.%d) does not match\n",
58 CHECK_MAJOR_VERSION, CHECK_MINOR_VERSION, CHECK_MICRO_VERSION);
59 printf("*** the check library (version %d.%d.%d).\n",
60 check_major_version, check_minor_version, check_micro_version);
64 if ((check_major_version > major) ||
65 ((check_major_version == major) && (check_minor_version > minor)) ||
66 ((check_major_version == major) && (check_minor_version == minor) && (check_micro_version >= micro)))
72 printf("\n*** An old version of check (%d.%d.%d) was found.\n",
73 check_major_version, check_minor_version, check_micro_version);
74 printf("*** You need a version of check being at least %d.%d.%d.\n", major, minor, micro);
76 printf("*** If you have already installed a sufficiently new version, this error\n");
77 printf("*** probably means that the wrong copy of the check library and header\n");
78 printf("*** file is being found. Rerun configure with the --with-check=PATH option\n");
79 printf("*** to specify the prefix where the correct version was installed.\n");
84 ],, no_check=yes, [echo $ac_n "cross compiling; assumed OK... $ac_c"])
86 CFLAGS="$ac_save_CFLAGS"
89 if test "x$no_check" = x ; then
91 ifelse([$2], , :, [$2])
94 if test -f conf.check-test ; then
97 echo "*** Could not run check test program, checking why..."
98 CFLAGS="$CFLAGS $CHECK_CFLAGS"
99 LIBS="$CHECK_LIBS $LIBS"
105 ], , [ echo "*** The test program compiled, but did not run. This usually means"
106 echo "*** that the run-time linker is not finding check. You'll need to set your"
107 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
108 echo "*** to the installed location Also, make sure you have run ldconfig if that"
109 echo "*** is required on your system"
111 echo "*** If you have an old version installed, it is best to remove it, although"
112 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
113 [ echo "*** The test program failed to compile or link. See the file config.log for"
114 echo "*** the exact error that occured." ])
116 CFLAGS="$ac_save_CFLAGS"
123 rm -f conf.check-test
124 ifelse([$3], , AC_MSG_ERROR([check not found]), [$3])
127 AC_SUBST(CHECK_CFLAGS)
130 rm -f conf.check-test