Fix check with autotool
This commit is contained in:
parent
063eb7d0ab
commit
04e0d6724b
7 changed files with 160 additions and 3 deletions
133
aclocal.m4
vendored
133
aclocal.m4
vendored
|
@ -20,6 +20,139 @@ You have another version of autoconf. It may work, but is not guaranteed to.
|
|||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
|
||||
|
||||
dnl AM_PATH_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AM_PATH_CHECK],
|
||||
[
|
||||
AC_MSG_WARN([A@&t@M_PATH_CHECK() is deprecated])
|
||||
AC_MSG_WARN([[use P@&t@KG_CHECK_MODULES([CHECK], [check >= 0.9.4]) instead]])
|
||||
AC_ARG_WITH([check],
|
||||
[ --with-check=PATH prefix where check is installed [default=auto]])
|
||||
|
||||
min_check_version=ifelse([$1], ,0.8.2,$1)
|
||||
|
||||
AC_MSG_CHECKING(for check - version >= $min_check_version)
|
||||
|
||||
if test x$with_check = xno; then
|
||||
AC_MSG_RESULT(disabled)
|
||||
ifelse([$3], , AC_MSG_ERROR([disabling check is not supported]), [$3])
|
||||
else
|
||||
if test "x$with_check" != x; then
|
||||
CHECK_CFLAGS="-I$with_check/include"
|
||||
CHECK_LIBS="-L$with_check/lib -lcheck"
|
||||
else
|
||||
CHECK_CFLAGS=""
|
||||
CHECK_LIBS="-lcheck"
|
||||
fi
|
||||
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
|
||||
CFLAGS="$CFLAGS $CHECK_CFLAGS"
|
||||
LIBS="$CHECK_LIBS $LIBS"
|
||||
|
||||
rm -f conf.check-test
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([])
|
||||
#include <check.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
int major, minor, micro;
|
||||
char *tmp_version;
|
||||
|
||||
system ("touch conf.check-test");
|
||||
|
||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
||||
tmp_version = strdup("$min_check_version");
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string\n", "$min_check_version");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((CHECK_MAJOR_VERSION != check_major_version) ||
|
||||
(CHECK_MINOR_VERSION != check_minor_version) ||
|
||||
(CHECK_MICRO_VERSION != check_micro_version))
|
||||
{
|
||||
printf("\n*** The check header file (version %d.%d.%d) does not match\n",
|
||||
CHECK_MAJOR_VERSION, CHECK_MINOR_VERSION, CHECK_MICRO_VERSION);
|
||||
printf("*** the check library (version %d.%d.%d).\n",
|
||||
check_major_version, check_minor_version, check_micro_version);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((check_major_version > major) ||
|
||||
((check_major_version == major) && (check_minor_version > minor)) ||
|
||||
((check_major_version == major) && (check_minor_version == minor) && (check_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n*** An old version of check (%d.%d.%d) was found.\n",
|
||||
check_major_version, check_minor_version, check_micro_version);
|
||||
printf("*** You need a version of check being at least %d.%d.%d.\n", major, minor, micro);
|
||||
printf("***\n");
|
||||
printf("*** If you have already installed a sufficiently new version, this error\n");
|
||||
printf("*** probably means that the wrong copy of the check library and header\n");
|
||||
printf("*** file is being found. Rerun configure with the --with-check=PATH option\n");
|
||||
printf("*** to specify the prefix where the correct version was installed.\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
])],, no_check=yes, [echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
|
||||
if test "x$no_check" = x ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
if test -f conf.check-test ; then
|
||||
:
|
||||
else
|
||||
echo "*** Could not run check test program, checking why..."
|
||||
CFLAGS="$CFLAGS $CHECK_CFLAGS"
|
||||
LIBS="$CHECK_LIBS $LIBS"
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <check.h>
|
||||
], , [ echo "*** The test program compiled, but did not run. This usually means"
|
||||
echo "*** that the run-time linker is not finding check. You'll need to set your"
|
||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
||||
echo "*** is required on your system"
|
||||
echo "***"
|
||||
echo "*** If you have an old version installed, it is best to remove it, although"
|
||||
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
|
||||
[ echo "*** The test program failed to compile or link. See the file config.log for"
|
||||
echo "*** the exact error that occured." ])
|
||||
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
|
||||
CHECK_CFLAGS=""
|
||||
CHECK_LIBS=""
|
||||
|
||||
rm -f conf.check-test
|
||||
ifelse([$3], , AC_MSG_ERROR([check not found]), [$3])
|
||||
fi
|
||||
|
||||
AC_SUBST(CHECK_CFLAGS)
|
||||
AC_SUBST(CHECK_LIBS)
|
||||
|
||||
rm -f conf.check-test
|
||||
|
||||
fi
|
||||
])
|
||||
|
||||
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||
|
|
|
@ -821,6 +821,10 @@ S["DEPS_CFLAGS"]="-D_THREAD_SAFE -I/opt/local/include "
|
|||
S["PKG_CONFIG_LIBDIR"]=""
|
||||
S["PKG_CONFIG_PATH"]=""
|
||||
S["PKG_CONFIG"]="/opt/local/bin/pkg-config"
|
||||
S["HAVE_CHECK_FALSE"]=""
|
||||
S["HAVE_CHECK_TRUE"]="#"
|
||||
S["CHECK_LIBS"]=""
|
||||
S["CHECK_CFLAGS"]=""
|
||||
S["CPP"]="gcc -E"
|
||||
S["OTOOL64"]=":"
|
||||
S["OTOOL"]="otool"
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
AC_INIT([r3], 1.0)
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AM_INIT_AUTOMAKE
|
||||
LT_INIT
|
||||
AC_PROG_CC
|
||||
|
||||
# AM_PATH_CHECK()
|
||||
AM_PATH_CHECK(,[have_check="yes"],
|
||||
AC_MSG_WARN([Check not found; cannot run unit tests!])
|
||||
[have_check="no"])
|
||||
AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes")
|
||||
|
||||
PKG_PROG_PKG_CONFIG
|
||||
PKG_CHECK_MODULES(DEPS, [libpcre check])
|
||||
AC_SUBST(DEPS_CFLAGS)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
// Judy array
|
||||
// #include <Judy.h>
|
||||
#include <config.h>
|
||||
|
||||
#include "r3_define.h"
|
||||
#include "r3_str.h"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
bin_PROGRAMS=test_tree
|
||||
test_tree_SOURCES=test_tree.c
|
||||
test_tree_LDADD=$(DEPS_LIBS) -L$(top_builddir)/src -lcheck -lr3
|
||||
# INCLUDES = @CHECK_CFLAGS@
|
||||
if HAVE_CHECK
|
||||
TESTS = check_tree
|
||||
else
|
||||
TESTS =
|
||||
endif
|
||||
# noinst_PROGRAMS = $(TESTS)
|
||||
check_PROGRAMS = $(TESTS)
|
||||
check_tree_SOURCES = check_tree.c
|
||||
check_tree_LDADD=$(DEPS_LIBS) -L$(top_builddir)/src -lcheck -lr3
|
||||
check_tree_CFLAGS=$(DEPS_CFLAGS) @CHECK_CFLAGS@
|
||||
# AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir)/include
|
||||
AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include
|
||||
CLEANFILES = check_tree.log
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <check.h>
|
||||
#include <stdlib.h>
|
Loading…
Reference in a new issue