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.]) AH_TEMPLATE(HAVE_O_DIRECT, [Define to 1 if you have the O_DIRECT flag.])
fi 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 ## 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. ## inside of an AM_CONDITIONAL to get conditional compilation to work.
AM_CONDITIONAL(HAVE_LIBCHECK, echo $LIBS | [ #AM_CONDITIONAL(HAVE_LIBCHECK, echo $LIBS | [
perl -ne 'if($_=~/-lcheck/) #perl -ne 'if($_=~/-lcheck/)
{ print qq(Check found, make check will run test suites. --enable-confuse will enable extra tests of old code. # { print qq(Check found, make check will run test suites
); exit 0; } else { print qq( #); exit 0; } else { print qq(
-------------------------------- #--------------------------------
#
#
Check not found! Most tests will be skipped by make check! #Check not found! Most tests will be skipped by make check!
#
#
-------------------------------- #--------------------------------
); exit 1; }']) #); exit 1; }'])
#have_libcheck", "xyes") #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) #AM_CONDITIONAL(HAVE_CHECK, test xyes, xyes)
AC_CHECK_LIB([m], [sqrt]) AC_CHECK_LIB([m], [sqrt])
AC_CHECK_LIB([pthread], [pthread_create]) 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], AC_ARG_ENABLE([network],
[Enables old networking code. Requires libconfuse]), AC_HELP_STRING([--disable-network],
[Disable old networking code]),
if test x$enableval = xno ; then if test x$enableval = xno ; then
echo "Networking disabled; not checking for confuse" echo "Networking disabled; not checking for confuse";
have_libconfuse=no
else else
AC_CHECK_LIB([confuse], [cfg_set_validate_func]) AC_CHECK_LIB([confuse], [cfg_set_validate_func],
have_libconfuse=yes, have_libconfuse=no)
fi, 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, test x$have_libconfuse = xyes)
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; }'])
AC_ARG_ENABLE([pobj], 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, test x$enableval = xyes),
AM_CONDITIONAL(BUILD_POBJ, false) AM_CONDITIONAL(BUILD_POBJ, true)
) )
AC_ARG_ENABLE([benchmarks], AC_ARG_ENABLE([benchmarks],
AC_HELP_STRING([--enable-benchmarks], AC_HELP_STRING([--disable-benchmarks],
[Build benchmarks. Requires Berkeley DB >= 4.2]), [Don't build benchmarks]),
AM_CONDITIONAL(BUILD_BENCHMARKS, test x$enableval = xyes), if test x$enableval = xyes ; then
# AC_CONFIG_DB, build_benchmarks=yes
AM_CONDITIONAL(BUILD_BENCHMARKS, false) else
build_benchmarks=no
fi,
build_benchmarks=yes
) )
AC_CONFIG_DB 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([intl], [bindtextdomain])
AC_CHECK_LIB([c], [bindtextdomain]) AC_CHECK_LIB([c], [bindtextdomain])

View file

@ -3,27 +3,16 @@ dnl Autoconf support for finding Berkeley DB
dnl dnl
AC_DEFUN([AC_DB_HELP], [ 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 the ones searched for, you may
If your installed version is not one of [$dbversions], you may
have to specify it with --with-dbver. have to specify it with --with-dbver.
If your installation is in a non-standard path, you can specify If your installation is in a non-standard path, you can specify
it with --with-db=DIR. 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
dnl Main macro for finding a usable db installation 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 if test x$dtn_cv_path_db_h = x ; then
AC_DB_HELP 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 fi
]) ])