Better conditional compilation; handles missing libraries gracefully.

This commit is contained in:
Sears Russell 2006-11-10 11:18:50 +00:00
parent 329b5b26b9
commit c7591e8311
2 changed files with 62 additions and 53 deletions

View file

@ -67,23 +67,34 @@ if test "$db_cv_open_o_direct" = "yes"; then
AH_TEMPLATE(HAVE_O_DIRECT, [Define to 1 if you have the O_DIRECT flag.])
fi
AC_CHECK_LIB([check], [suite_create], , AC_MSG_WARN([Check not found; cannot run unit tests!]))
AC_CHECK_LIB([check], [suite_create])
AC_CHECK_LIB([check], [suite_create],
have_libcheck=yes,
have_libcheck=no)
if test x$have_libcheck = xyes ; then
AM_CONDITIONAL(HAVE_LIBCHECK, true)
else
AM_CONDITIONAL(HAVE_LIBCHECK, false)
AC_MSG_WARN([Check not found; cannot run unit tests!])
fi
#AM_CONDITIONAL(HAVE_LIBCHECK, test x$have_libcheck=xyes)
## This perl script thing is a total hack, but we need to define HAVE_LIBCHECK
## inside of an AM_CONDITIONAL to get conditional compilation to work.
AM_CONDITIONAL(HAVE_LIBCHECK, echo $LIBS | [
perl -ne 'if($_=~/-lcheck/)
{ print qq(Check found, make check will run test suites. --enable-confuse will enable extra tests of old code.
); exit 0; } else { print qq(
--------------------------------
Check not found! Most tests will be skipped by make check!
--------------------------------
); exit 1; }'])
#AM_CONDITIONAL(HAVE_LIBCHECK, echo $LIBS | [
#perl -ne 'if($_=~/-lcheck/)
# { print qq(Check found, make check will run test suites
#); exit 0; } else { print qq(
#--------------------------------
#
#
#Check not found! Most tests will be skipped by make check!
#
#
#--------------------------------
#); exit 1; }'])
#have_libcheck", "xyes")
@ -96,44 +107,52 @@ Check not found! Most tests will be skipped by make check!
#AM_CONDITIONAL(HAVE_CHECK, test xyes, xyes)
AC_CHECK_LIB([m], [sqrt])
AC_CHECK_LIB([pthread], [pthread_create])
#AC_CHECK_LIB([confuse], [cfg_set_validate_func])
## Repeat hack for LIBCONFUSE
AC_ARG_ENABLE([deprecated-networking],
AC_HELP_STRING([--enable-network],
[Enables old networking code. Requires libconfuse]),
AC_ARG_ENABLE([network],
AC_HELP_STRING([--disable-network],
[Disable old networking code]),
if test x$enableval = xno ; then
echo "Networking disabled; not checking for confuse"
echo "Networking disabled; not checking for confuse";
have_libconfuse=no
else
AC_CHECK_LIB([confuse], [cfg_set_validate_func])
AC_CHECK_LIB([confuse], [cfg_set_validate_func],
have_libconfuse=yes, have_libconfuse=no)
fi,
echo "Networking disabled; not checking for confuse"
AC_CHECK_LIB([confuse], [cfg_set_validate_func],
have_libconfuse=yes, have_libconfuse=no)
)
# Repeat hack for LIBCONFUSE
AM_CONDITIONAL(HAVE_LIBCONFUSE, echo $LIBS | [
perl -ne 'if($_=~/-lconfuse/)
{ print qq(Confuse found, make check will run full test suite.
); exit 0; } else { print qq(Confuse not found; will skip networked stuff.
); exit 1; }'])
AM_CONDITIONAL(HAVE_LIBCONFUSE, test x$have_libconfuse = xyes)
AC_ARG_ENABLE([pobj],
AC_HELP_STRING([--enable-pobj], [Build pobj]),
AC_HELP_STRING([--disable-pobj], [Don't build pobj]),
AM_CONDITIONAL(BUILD_POBJ, test x$enableval = xyes),
AM_CONDITIONAL(BUILD_POBJ, false)
AM_CONDITIONAL(BUILD_POBJ, true)
)
AC_ARG_ENABLE([benchmarks],
AC_HELP_STRING([--enable-benchmarks],
[Build benchmarks. Requires Berkeley DB >= 4.2]),
AM_CONDITIONAL(BUILD_BENCHMARKS, test x$enableval = xyes),
# AC_CONFIG_DB,
AM_CONDITIONAL(BUILD_BENCHMARKS, false)
AC_HELP_STRING([--disable-benchmarks],
[Don't build benchmarks]),
if test x$enableval = xyes ; then
build_benchmarks=yes
else
build_benchmarks=no
fi,
build_benchmarks=yes
)
AC_CONFIG_DB
if test x$build_benchmarks = xyes ; then
if test $DB_ENABLED = 0; then
AC_MSG_WARN([Could not find Berkeley DB; some benchmarks will not be built])
fi
AM_CONDITIONAL(BUILD_BENCHMARKS, true)
else
AM_CONDITIONAL(BUILD_BENCHMARKS, false)
fi
AC_CHECK_LIB([intl], [bindtextdomain])
AC_CHECK_LIB([c], [bindtextdomain])

View file

@ -3,27 +3,16 @@ dnl Autoconf support for finding Berkeley DB
dnl
AC_DEFUN([AC_DB_HELP], [
cat <<EOF
AC_MSG_NOTICE([
Could not find Berkeley DB. Stasis includes benchmarks that use it.
They will not be built.
Configure error with Berkeley DB...
If your installed version is not one of [$dbversions], you may
If your installed version is not one of the ones searched for, you may
have to specify it with --with-dbver.
If your installation is in a non-standard path, you can specify
it with --with-db=DIR.
To download the latest version, go to http://www.sleepycat.com
To build and install to /usr/local/BerkeleyDB-<version>:
# cd <db_download_dir>/build_unix
# ../dist/configure --enable-cxx
# make
# make install
EOF
])
])])
dnl
dnl Main macro for finding a usable db installation
@ -187,6 +176,7 @@ AC_DEFUN([AC_FIND_DB], [
if test x$dtn_cv_path_db_h = x ; then
AC_DB_HELP
AC_MSG_ERROR([can't find usable Berkeley DB installation])
#AC_MSG_WARN([can't find usable Berkeley DB installation])
DB_ENABLED=0
fi
])