1 dnl _AM_TRY_CHECK(MINIMUM-VERSION, EXTRA-CFLAGS, EXTRA-LIBS, CHECK-LIB-NAME
2 dnl [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
3 dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS
4 dnl Done this way because of the brokenness that is
5 dnl https://launchpad.net/distros/ubuntu/+source/check/+bug/5840
8 AC_DEFUN([_AM_TRY_CHECK],
15 CHECK_CFLAGS="$extra_cflags"
16 CHECK_LIBS="$extra_libs -l$check_lib_name"
18 ac_save_CFLAGS="$CFLAGS"
21 CFLAGS="$CFLAGS $CHECK_CFLAGS"
22 LIBS="$CHECK_LIBS $LIBS"
24 AC_MSG_CHECKING(for check named $check_lib_name - version >= $min_check_version)
27 dnl unset no_check, since in our second run it would have been set to yes
38 int major, minor, micro;
41 system ("touch conf.check-test");
43 /* HP/UX 9 (%@#!) writes to sscanf strings */
44 tmp_version = strdup("$min_check_version");
45 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
46 printf("%s, bad version string\n", "$min_check_version");
50 if ((CHECK_MAJOR_VERSION != check_major_version) ||
51 (CHECK_MINOR_VERSION != check_minor_version) ||
52 (CHECK_MICRO_VERSION != check_micro_version))
54 printf("\n*** The check header file (version %d.%d.%d) does not match\n",
55 CHECK_MAJOR_VERSION, CHECK_MINOR_VERSION, CHECK_MICRO_VERSION);
56 printf("*** the check library (version %d.%d.%d).\n",
57 check_major_version, check_minor_version, check_micro_version);
61 if ((check_major_version > major) ||
62 ((check_major_version == major) && (check_minor_version > minor)) ||
63 ((check_major_version == major) && (check_minor_version == minor) && (check_micro_version >= micro)))
69 printf("\n*** An old version of check (%d.%d.%d) was found.\n",
70 check_major_version, check_minor_version, check_micro_version);
71 printf("*** You need a version of check being at least %d.%d.%d.\n", major, minor, micro);
73 printf("*** If you have already installed a sufficiently new version, this error\n");
74 printf("*** probably means that the wrong copy of the check library and header\n");
75 printf("*** file is being found. Rerun configure with the --with-check=PATH option\n");
76 printf("*** to specify the prefix where the correct version was installed.\n");
81 ],, no_check=yes, [echo $ac_n "cross compiling; assumed OK... $ac_c"])
83 CFLAGS="$ac_save_CFLAGS"
86 if test "x$no_check" = x ; then
88 ifelse([$5], , :, [$5])
91 if test -f conf.check-test ; then
94 echo "*** Could not run check test program, checking why..."
95 CFLAGS="$CFLAGS $CHECK_CFLAGS"
96 LIBS="$CHECK_LIBS $LIBS"
102 ], , [ echo "*** The test program compiled, but did not run. This usually means"
103 echo "*** that the run-time linker is not finding check. You'll need to set your"
104 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
105 echo "*** to the installed location Also, make sure you have run ldconfig if that"
106 echo "*** is required on your system"
108 echo "*** If you have an old version installed, it is best to remove it, although"
109 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
110 [ echo "*** The test program failed to compile or link. See the file config.log for"
111 echo "*** the exact error that occured." ])
113 CFLAGS="$ac_save_CFLAGS"
120 rm -f conf.check-test
121 ifelse([$6], , AC_MSG_ERROR([check not found]), [$6])
126 dnl AM_PATH_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
127 dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS
130 AC_DEFUN([AM_PATH_CHECK],
133 [ --with-check=PATH prefix where check is installed [default=auto]])
135 AC_ARG_WITH(checklibname,
136 AC_HELP_STRING([--with-check-lib-name=NAME],
137 [name of the PIC check library (default=check)]))
139 min_check_version=ifelse([$1], ,0.8.2,$1)
141 if test x$with_check = xno; then
142 AC_MSG_RESULT(disabled)
143 ifelse([$3], , AC_MSG_ERROR([disabling check is not supported]), [$3])
145 if test "x$with_check" != x; then
146 CHECK_EXTRA_CFLAGS="-I$with_check/include"
147 CHECK_EXTRA_LIBS="-L$with_check/lib"
149 CHECK_EXTRA_CFLAGS=""
153 if test x$with_checklibname = x; then
154 _AM_TRY_CHECK($min_check_version, $CHECK_EXTRA_CFLAGS, $CHECK_EXTRA_LIBS,
155 check_pic, [have_check=true], [have_check=false])
156 if test x$have_check = xtrue; then
157 ifelse([$2], , :, [$2])
159 _AM_TRY_CHECK($min_check_version, $CHECK_EXTRA_CFLAGS, $CHECK_EXTRA_LIBS,
160 check, [have_check=true], [have_check=false])
161 if test x$have_check = xtrue; then
162 ifelse([$2], , :, [$2])
164 ifelse([$3], , AC_MSG_ERROR([check not found]), [$3])
168 _AM_TRY_CHECK($min_check_version, $CHECK_EXTRA_CFLAGS, $CHECK_EXTRA_LIBS,
169 $with_checklibname, [have_check=true], [have_check=false])
170 if test x$have_check = xtrue; then
171 ifelse([$2], , :, [$2])
173 ifelse([$3], , AC_MSG_ERROR([check not found]), [$3])
177 AC_SUBST(CHECK_CFLAGS)
179 rm -f conf.check-test