# generated automatically by aclocal 1.9.2 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
dnl @synopsis AC_CXX_EXCEPTIONS
dnl
dnl If the C++ compiler supports exceptions handling (try, throw and
dnl catch), define HAVE_EXCEPTIONS.
dnl
dnl @category Cxx
dnl @author Todd Veldhuizen
dnl @author Luc Maisonobe <luc@spaceroots.org>
dnl @version 2004-02-04
dnl @license AllPermissive
AC_DEFUN([AC_CXX_EXCEPTIONS],
[AC_CACHE_CHECK(whether the compiler supports exceptions,
ac_cv_cxx_exceptions,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(,[try { throw 1; } catch (int i) { return i; }],
ac_cv_cxx_exceptions=yes, ac_cv_cxx_exceptions=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_exceptions" = yes; then
AC_DEFINE(HAVE_EXCEPTIONS,,[define if the compiler supports exceptions])
fi
])
dnl @synopsis AC_CXX_NAMESPACES
dnl
dnl If the compiler can prevent names clashes using namespaces, define
dnl HAVE_NAMESPACES.
dnl
dnl @category Cxx
dnl @author Todd Veldhuizen
dnl @author Luc Maisonobe <luc@spaceroots.org>
dnl @version 2004-02-04
dnl @license AllPermissive
AC_DEFUN([AC_CXX_NAMESPACES],
[AC_CACHE_CHECK(whether the compiler implements namespaces,
ac_cv_cxx_namespaces,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
[using namespace Outer::Inner; return i;],
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_namespaces" = yes; then
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
fi
])
dnl @synopsis AX_BSWAP64
dnl
dnl This macro will check for a built in way of endian reversing an int64_t.
dnl If one is found then HAVE_BSWAP64 is set to 1 and BSWAP64 will be defined
dnl to the name of the endian swap function.
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2006/02/02
dnl @license AllPermissive
AC_DEFUN([AX_BSWAP64], [
bswap64_function=""
AC_CHECK_HEADERS([sys/endian.h asm/byteorder.h])
if test "x$ac_cv_header_sys_endian_h" = "xyes"; then
AC_CACHE_CHECK([for htobe64], [have_htobe64],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
$ac_includes_default
#include <sys/endian.h>
]], [[
htobe64(0);
return 1;
]])],
[have_htobe64=yes], [have_htobe64=no]
)])
if test "x$have_htobe64" = "xyes"; then
bswap64_function=htobe64
fi
fi
if test "x$bswap64_function" = "x" && \
test "x$ac_cv_header_asm_byteorder_h" = "xyes"; then
AC_CACHE_CHECK([for __cpu_to_be64], [have___cpu_to_be64],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
$ac_includes_default
#include <asm/byteorder.h>
]], [[
__cpu_to_be64(0);
return 1;
]])],
[have___cpu_to_be64=yes], [have___cpu_to_be64=no]
)])
if test "x$have___cpu_to_be64" = "xyes"; then
bswap64_function=__cpu_to_be64
fi
fi
if test "x$bswap64_function" != "x"; then
AC_DEFINE([HAVE_BSWAP64], 1,
[Define to 1 if BSWAP64 is defined to the name of a valid 64 bit endian swapping function])
AC_DEFINE_UNQUOTED([BSWAP64], [$bswap64_function], [Name of the 64 bit endian swapping function])
fi
])dnl
dnl @synopsis AX_CHECK_DEFINE_PRAGMA([ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl
dnl This macro will find out if the compiler will accept #pragma inside a
dnl #define. HAVE_DEFINE_PRAGMA will be defined if this is the case, and
dnl ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2005/07/03
dnl @license AllPermissive
AC_DEFUN([AX_CHECK_DEFINE_PRAGMA], [
AC_CACHE_CHECK([for pre-processor pragma defines], [have_define_pragma],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#define TEST_DEFINE #pragma pack(1)
TEST_DEFINE
]])],
[have_define_pragma=yes], [have_define_pragma=no]
)])
if test "x$have_define_pragma" = "xyes"; then
AC_DEFINE([HAVE_DEFINE_PRAGMA], 1, [Define to 1 if #define of pragmas works])
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
])dnl
dnl @synopsis AX_CHECK_DIRENT_D_TYPE([ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl
dnl This macro will find out if struct dirent.d_type is present and supported.
dnl
dnl The following defines will be set as appropriate:
dnl HAVE_STRUCT_DIRENT_D_TYPE
dnl HAVE_VALID_DIRENT_D_TYPE
dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2005/07/03
dnl @license AllPermissive
AC_DEFUN([AX_CHECK_DIRENT_D_TYPE], [
AC_CHECK_MEMBERS([struct dirent.d_type],,, [[#include <dirent.h>]])
if test "x$ac_cv_member_struct_dirent_d_type" = "xyes"; then
AC_CACHE_CHECK([[whether struct dirent.d_type is valid]], [have_valid_dirent_d_type],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
$ac_includes_default
#include <dirent.h>
]], [[
DIR* dir = opendir(".");
struct dirent* res = NULL;
if(dir) res = readdir(dir);
return res ? (res->d_type==DT_UNKNOWN) : 1;
]])],
[have_valid_dirent_d_type=yes], [have_valid_dirent_d_type=no]
)])
if test "x$have_valid_dirent_d_type" = "xyes"; then
AC_DEFINE([HAVE_VALID_DIRENT_D_TYPE], 1, [Define to 1 if struct dirent.d_type is valid])
fi
fi
if test "x$ac_cv_member_struct_dirent_d_type" = "xyes" || \
test "x$have_valid_dirent_d_type" = "xyes"
then
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
])dnl
dnl @synopsis AX_CHECK_LLONG_MINMAX
dnl
dnl This macro will fix up LLONG_MIN and LLONG_MAX as appropriate. I'm finding
dnl it quite difficult to believe that so many hoops are necessary. The world
dnl seems to have gone quite mad.
dnl
dnl This gem is adapted from the OpenSSH configure script so here's
dnl the original copyright notice:
dnl
dnl Copyright (c) 1999-2004 Damien Miller
dnl
dnl Permission to use, copy, modify, and distribute this software for any
dnl purpose with or without fee is hereby granted, provided that the above
dnl copyright notice and this permission notice appear in all copies.
dnl
dnl @category C
dnl @author Martin Ebourne and Damien Miller
dnl @version 2005/07/07
AC_DEFUN([AX_CHECK_LLONG_MINMAX], [
AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [[#include <limits.h>]])
if test -z "$have_llong_max"; then
AC_MSG_CHECKING([[for max value of long long]])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
/* Why is this so damn hard? */
#undef __GNUC__
#undef __USE_ISOC99
#define __USE_ISOC99
#include <limits.h>
#define DATA "conftest.llminmax"
int main(void) {
FILE *f;
long long i, llmin, llmax = 0;
if((f = fopen(DATA,"w")) == NULL)
exit(1);
#if defined(LLONG_MIN) && defined(LLONG_MAX)
fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
llmin = LLONG_MIN;
llmax = LLONG_MAX;
#else
fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
/* This will work on one's complement and two's complement */
for (i = 1; i > llmax; i <<= 1, i++)
llmax = i;
llmin = llmax + 1LL; /* wrap */
#endif
/* Sanity check */
if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax || llmax - 1 > llmax) {
fprintf(f, "unknown unknown\n");
exit(2);
}
if (fprintf(f ,"%lld %lld", llmin, llmax) < 0)
exit(3);
exit(0);
}
]])], [
read llong_min llong_max < conftest.llminmax
AC_MSG_RESULT([$llong_max])
AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
[max value of long long calculated by configure])
AC_MSG_CHECKING([[for min value of long long]])
AC_MSG_RESULT([$llong_min])
AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
[min value of long long calculated by configure])
],
[AC_MSG_RESULT(not found)],
[AC_MSG_WARN([[cross compiling: not checking]])]
)
fi
])dnl
dnl @synopsis AX_CHECK_MALLOC_WORKAROUND
dnl
dnl This macro will see if there is a potential STL memory leak, and if we can
dnl work around it will define __USE_MALLOC as the fix.
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2005/07/12
dnl @license AllPermissive
AC_DEFUN([AX_CHECK_MALLOC_WORKAROUND], [
if test "x$GXX" = "xyes"; then
AC_CACHE_CHECK([for gcc version 3 or later], [gcc_3_plus],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if __GNUC__ < 3
#error "Old GNU C"
#endif
]])],
[gcc_3_plus=yes], [gcc_3_plus=no]
)])
if test "x$gcc_3_plus" = "xno"; then
AC_CACHE_CHECK([for malloc workaround], [malloc_workaround],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#define __USE_MALLOC
#include <string>
]], [[
std::string s;
s = "test";
]])],
[malloc_workaround=yes], [malloc_workaround=no]
)])
if test "x$malloc_workaround" = "xyes"; then
AC_DEFINE([__USE_MALLOC], 1,
[Define to 1 if __USE_MALLOC is required work around STL memory leaks])
fi
fi
fi
])dnl
dnl @synopsis AX_CHECK_MOUNT_POINT([ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl
dnl This macro will find out how to get mount point information if possible.
dnl
dnl The following defines will be set as appropriate:
dnl HAVE_MOUNTS
dnl HAVE_MNTENT_H
dnl HAVE_SYS_MNTTAB_H
dnl HAVE_SYS_MOUNT_H
dnl HAVE_STRUCT_MNTENT_MNT_DIR
dnl HAVE_STRUCT_MNTTAB_MNT_MOUNTP
dnl HAVE_STRUCT_STATFS_F_MNTONNAME
dnl HAVE_STRUCT_STATVFS_F_MNTONNAME
dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2005/07/01
dnl @license AllPermissive
AC_DEFUN([AX_CHECK_MOUNT_POINT], [
AC_CHECK_FUNCS([getmntent statfs])
AC_CHECK_HEADERS([sys/param.h])
AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/mount.h],,, [[
#include <stdio.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
]])
# BSD
AC_CHECK_MEMBERS([struct statfs.f_mntonname],,, [[
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <sys/mount.h>
]])
# NetBSD
AC_CHECK_MEMBERS([struct statvfs.f_mntonname],,, [[
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <sys/mount.h>
]])
# Linux
AC_CHECK_MEMBERS([struct mntent.mnt_dir],,, [[#include <mntent.h>]])
# Solaris
AC_CHECK_MEMBERS([struct mnttab.mnt_mountp],,, [[
#include <stdio.h>
#include <sys/mnttab.h>
]])
if test "x$ac_cv_member_struct_statfs_f_mntonname" = "xyes" || \
test "x$ac_cv_member_struct_statvfs_f_mntonname" = "xyes" || \
test "x$ac_cv_member_struct_mntent_mnt_dir" = "xyes" || \
test "x$ac_cv_member_struct_mnttab_mnt_mountp" = "xyes"
then
AC_DEFINE([HAVE_MOUNTS], [1], [Define to 1 if this platform supports mounts])
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
])dnl
dnl @synopsis AX_CHECK_NONALIGNED_ACCESS
dnl
dnl This macro will see if non-aligned memory accesses will fail. The following
dnl defines will be made as appropriate:
dnl HAVE_ALIGNED_ONLY_INT16
dnl HAVE_ALIGNED_ONLY_INT32
dnl HAVE_ALIGNED_ONLY_INT64
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2005/07/12
dnl @license AllPermissive
AC_DEFUN([AX_CHECK_NONALIGNED_ACCESS], [
AC_CACHE_CHECK([if non-aligned 16 bit word accesses fail], [have_aligned_only_int16],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]], [[
#ifndef HAVE_UINT16_T
#define uint16_t u_int16_t;
#endif
uint16_t scratch[2];
memset(scratch, 0, sizeof(scratch));
return *(uint16_t*)((char*)scratch+1);
]])],
[have_aligned_only_int16=no], [have_aligned_only_int16=yes]
)])
if test "x$have_aligned_only_int16" = "xyes"; then
AC_DEFINE([HAVE_ALIGNED_ONLY_INT16], 1, [Define to 1 if non-aligned int16 access will fail])
fi
AC_CACHE_CHECK([if non-aligned 32 bit word accesses fail], [have_aligned_only_int32],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]], [[
#ifndef HAVE_UINT32_T
#define uint32_t u_int32_t;
#endif
uint32_t scratch[2];
memset(scratch, 0, sizeof(scratch));
return *(uint32_t*)((char*)scratch+1);
]])],
[have_aligned_only_int32=no], [have_aligned_only_int32=yes]
)])
if test "x$have_aligned_only_int32" = "xyes"; then
AC_DEFINE([HAVE_ALIGNED_ONLY_INT32], 1, [Define to 1 if non-aligned int32 access will fail])
fi
AC_CACHE_CHECK([if non-aligned 64 bit word accesses fail], [have_aligned_only_int64],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]], [[
#ifndef HAVE_UINT64_T
#define uint64_t u_int64_t;
#endif
uint64_t scratch[2];
memset(scratch, 0, sizeof(scratch));
return *(uint64_t*)((char*)scratch+1);
]])],
[have_aligned_only_int64=no], [have_aligned_only_int64=yes]
)])
if test "x$have_aligned_only_int64" = "xyes"; then
AC_DEFINE([HAVE_ALIGNED_ONLY_INT64], 1, [Define to 1 if non-aligned int64 access will fail])
fi
])dnl
dnl @synopsis AX_CHECK_SSL([ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl
dnl This macro will check for OpenSSL in the standard path, allowing the user
dnl to specify a directory if it is not found. The user uses
dnl '--with-ssl-headers=/path/to/headers' or
dnl '--with-ssl-lib=/path/to/lib' as arguments to configure.
dnl
dnl If OpenSSL is found the include directory gets added to CPPFLAGS,
dnl '-lcrypto', '-lssl', and the libraries directory are added to LDFLAGS.
dnl Also HAVE_SSL is defined to 1, and ACTION-IF-TRUE and ACTION-IF-FALSE are
dnl run as appropriate
dnl
dnl @category InstalledPackages
dnl @author Martin Ebourne
dnl @version 2005/07/01
dnl @license AllPermissive
AC_DEFUN([AX_CHECK_SSL], [
AC_ARG_WITH(
[ssl-headers],
[AC_HELP_STRING([--with-ssl-headers=DIR], [SSL include files location])],
[CPPFLAGS="$CPPFLAGS -I$withval"])
AC_ARG_WITH(
[ssl-lib],
[AC_HELP_STRING([--with-ssl-lib=DIR], [SSL library location])],
[LDFLAGS="$LDFLAGS -L$withval"])
ax_check_ssl_found=yes
AC_CHECK_HEADERS([openssl/ssl.h],, [ax_check_ssl_found=no])
AC_CHECK_LIB([ssl], [SSL_read],, [ax_check_ssl_found=no], [-lcrypto])
if test "x$ax_check_ssl_found" = "xyes"; then
AC_DEFINE([HAVE_SSL], 1, [Define to 1 if SSL is available])
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
])dnl
dnl @synopsis AX_CHECK_SYSCALL_LSEEK([ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl
dnl This macro will find out if the lseek syscall requires a dummy middle
dnl parameter
dnl
dnl The following defines will be set as appropriate:
dnl HAVE_LSEEK_DUMMY_PARAM
dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2005/07/03
dnl @license AllPermissive
AC_DEFUN([AX_CHECK_SYSCALL_LSEEK], [
AC_REQUIRE([AX_FUNC_SYSCALL])dnl
if test "x$ac_cv_header_sys_syscall_h" = "xyes"; then
AC_CACHE_CHECK([[whether syscall lseek requires dummy parameter]], [have_lseek_dummy_param],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
$ac_includes_default
#include <fcntl.h>
#include <sys/syscall.h>
#ifdef HAVE___SYSCALL_NEED_DEFN
extern "C" off_t __syscall(quad_t number, ...);
#endif
#ifndef HAVE_SYSCALL
#undef syscall
#define syscall __syscall
#endif
]], [[
int fh = creat("lseektest", 0600);
int res = 0;
if(fh>=0)
{
res = syscall(SYS_lseek, fh, 0, SEEK_SET, 99);
close(fh);
}
unlink("lseektest");
return res!=-1;
]])],
[have_lseek_dummy_param=yes], [have_lseek_dummy_param=no]
)])
if test "x$have_lseek_dummy_param" = "xyes"; then
AC_DEFINE([HAVE_LSEEK_DUMMY_PARAM], 1,
[Define to 1 if syscall lseek requires a dummy middle parameter])
fi
fi
if test "x$have_lseek_dummy_param" = "xno"
then
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
])dnl
dnl @synopsis AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl
dnl This macro compares two version strings. It is used heavily in the
dnl macro _AX_PATH_BDB for library checking. Due to the various number
dnl of minor-version numbers that can exist, and the fact that string
dnl comparisons are not compatible with numeric comparisons, this is
dnl not necessarily trivial to do in a autoconf script. This macro
dnl makes doing these comparisons easy.
dnl
dnl The six basic comparisons are available, as well as checking
dnl equality limited to a certain number of minor-version levels.
dnl
dnl The operator OP determines what type of comparison to do, and can
dnl be one of:
dnl
dnl eq - equal (test A == B)
dnl ne - not equal (test A != B)
dnl le - less than or equal (test A <= B)
dnl ge - greater than or equal (test A >= B)
dnl lt - less than (test A < B)
dnl gt - greater than (test A > B)
dnl
dnl Additionally, the eq and ne operator can have a number after it to
dnl limit the test to that number of minor versions.
dnl
dnl eq0 - equal up to the length of the shorter version
dnl ne0 - not equal up to the length of the shorter version
dnl eqN - equal up to N sub-version levels
dnl neN - not equal up to N sub-version levels
dnl
dnl When the condition is true, shell commands ACTION-IF-TRUE are run,
dnl otherwise shell commands ACTION-IF-FALSE are run. The environment
dnl variable 'ax_compare_version' is always set to either 'true' or
dnl 'false' as well.
dnl
dnl Examples:
dnl
dnl AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
dnl AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
dnl
dnl would both be true.
dnl
dnl AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
dnl AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
dnl
dnl would both be false.
dnl
dnl AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
dnl
dnl would be true because it is only comparing two minor versions.
dnl
dnl AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
dnl
dnl would be true because it is only comparing the lesser number of
dnl minor versions of the two values.
dnl
dnl Note: The characters that separate the version numbers do not
dnl matter. An empty string is the same as version 0. OP is evaluated
dnl by autoconf, not configure, so must be a string, not a variable.
dnl
dnl The author would like to acknowledge Guido Draheim whose advice
dnl about the m4_case and m4_ifvaln functions make this macro only
dnl include the portions necessary to perform the specific comparison
dnl specified by the OP argument in the final configure script.
dnl
dnl @category Misc
dnl @author Tim Toolan <toolan@ele.uri.edu>
dnl @version 2004-03-01
dnl @license GPLWithACException
dnl #########################################################################
AC_DEFUN([AX_COMPARE_VERSION], [
# Used to indicate true or false condition
ax_compare_version=false
# Convert the two version strings to be compared into a format that
# allows a simple string comparison. The end result is that a version
# string of the form 1.12.5-r617 will be converted to the form
# 0001001200050617. In other words, each number is zero padded to four
# digits, and non digits are removed.
AS_VAR_PUSHDEF([A],[ax_compare_version_A])
A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/[[^0-9]]//g'`
AS_VAR_PUSHDEF([B],[ax_compare_version_B])
B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/[[^0-9]]//g'`
dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
dnl # then the first line is used to determine if the condition is true.
dnl # The sed right after the echo is to remove any indented white space.
m4_case(m4_tolower($2),
[lt],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
],
[gt],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
],
[le],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
],
[ge],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
],[
dnl Split the operator from the subversion count if present.
m4_bmatch(m4_substr($2,2),
[0],[
# A count of zero means use the length of the shorter version.
# Determine the number of characters in A and B.
ax_compare_version_len_A=`echo "$A" | awk '{print(length)}'`
ax_compare_version_len_B=`echo "$B" | awk '{print(length)}'`
# Set A to no more than B's length and B to no more than A's length.
A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
],
[[0-9]+],[
# A count greater than zero means use only that many subversions
A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
],
[.+],[
AC_WARNING(
[illegal OP numeric parameter: $2])
],[])
# Pad zeros at end of numbers to make same length.
ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
B="$B`echo $A | sed 's/./0/g'`"
A="$ax_compare_version_tmp_A"
# Check for equality or inequality as necessary.
m4_case(m4_tolower(m4_substr($2,0,2)),
[eq],[
test "x$A" = "x$B" && ax_compare_version=true
],
[ne],[
test "x$A" != "x$B" && ax_compare_version=true
],[
AC_WARNING([illegal OP parameter: $2])
])
])
AS_VAR_POPDEF([A])dnl
AS_VAR_POPDEF([B])dnl
dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
if test "$ax_compare_version" = "true" ; then
m4_ifvaln([$4],[$4],[:])dnl
m4_ifvaln([$5],[else $5])dnl
fi
]) dnl AX_COMPARE_VERSION
dnl @synopsis AX_FUNC_SYSCALL
dnl
dnl This macro will find out how to call syscall. One or more of the following
dnl defines will be made as appropriate:
dnl HAVE_UNISTD_H - If unistd.h is available
dnl HAVE_SYS_SYSCALL_H - If sys/syscall.h is available
dnl HAVE_SYSCALL - If syscall() is available and is defined in unistd.h
dnl HAVE___SYSCALL - If __syscall() is available and is defined in unistd.h
dnl HAVE___SYSCALL_NEED_DEFN - If __syscall() is available but is not defined in unistd.h
dnl
dnl @category C
dnl @author Martin Ebourne
dnl @version 2005/07/01
dnl @license AllPermissive
AC_DEFUN([AX_FUNC_SYSCALL], [
AC_CHECK_HEADERS([sys/syscall.h unistd.h])
AC_CHECK_FUNCS([syscall __syscall])
if test "x$ac_cv_func_syscall" != "xyes" &&
test "x$ac_cv_func___syscall" != "xyes"; then
AC_CACHE_CHECK([for __syscall needing definition], [have___syscall_need_defn],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
$ac_includes_default
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
#endif
extern "C" off_t __syscall(quad_t number, ...);
]], [[
__syscall(SYS_exit, 0);
return 1;
]])],
[have___syscall_need_defn=yes], [have___syscall_need_defn=no]
)])
if test "x$have___syscall_need_defn" = "xyes"; then
AC_DEFINE([HAVE___SYSCALL_NEED_DEFN], 1,
[Define to 1 if __syscall is available but needs a definition])
fi
fi
])dnl
dnl @synopsis AX_PATH_BDB([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl
dnl This macro finds the latest version of Berkeley DB on the system,
dnl and ensures that the header file and library versions match. If
dnl MINIMUM-VERSION is specified, it will ensure that the library found
dnl is at least that version.
dnl
dnl It determines the name of the library as well as the path to the
dnl header file and library. It will check both the default environment
dnl as well as the default Berkeley DB install location. When found, it
dnl sets BDB_LIBS, BDB_CPPFLAGS, and BDB_LDFLAGS to the necessary
dnl values to add to LIBS, CPPFLAGS, and LDFLAGS, as well as setting
dnl BDB_VERSION to the version found. HAVE_DB_H is defined also.
dnl
dnl The option --with-bdb-dir=DIR can be used to specify a specific
dnl Berkeley DB installation to use.
dnl
dnl An example of it's use is:
dnl
dnl AX_PATH_BDB([3],[
dnl LIBS="$BDB_LIBS $LIBS"
dnl LDFLAGS="$BDB_LDFLAGS $LDFLAGS"
dnl CPPFLAGS="$CPPFLAGS $BDB_CPPFLAGS"
dnl ])
dnl
dnl which will locate the latest version of Berkeley DB on the system,
dnl and ensure that it is version 3.0 or higher.
dnl
dnl Details: This macro does not use either AC_CHECK_HEADERS or
dnl AC_CHECK_LIB because, first, the functions inside the library are
dnl sometimes renamed to contain a version code that is only available
dnl from the db.h on the system, and second, because it is common to
dnl have multiple db.h and libdb files on a system it is important to
dnl make sure the ones being used correspond to the same version.
dnl Additionally, there are many different possible names for libdb
dnl when installed by an OS distribution, and these need to be checked
dnl if db.h does not correspond to libdb.
dnl
dnl When cross compiling, only header versions are verified since it
dnl would be difficult to check the library version. Additionally the
dnl default Berkeley DB installation locations /usr/local/BerkeleyDB*
dnl are not searched for higher versions of the library.
dnl
dnl The format for the list of library names to search came from the
dnl Cyrus IMAP distribution, although they are generated dynamically
dnl here, and only for the version found in db.h.
dnl
dnl The macro AX_COMPARE_VERSION is required to use this macro, and
dnl should be available from the Autoconf Macro Archive.
dnl
dnl The author would like to acknowledge the generous and valuable
dnl feedback from Guido Draheim, without which this macro would be far
dnl less robust, and have poor and inconsistent cross compilation
dnl support.
dnl
dnl Changes:
dnl
dnl 1/5/05 applied patch from Rafa Rzepecki to eliminate compiler
dnl warning about unused variable, argv
dnl
dnl @category InstalledPackages
dnl @author Tim Toolan <toolan@ele.uri.edu>
dnl @version 2005-01-17
dnl @license GPLWithACException
dnl #########################################################################
AC_DEFUN([AX_PATH_BDB], [
dnl # Used to indicate success or failure of this function.
ax_path_bdb_ok=no
# Add --with-bdb-dir option to configure.
AC_ARG_WITH([bdb-dir],
[AC_HELP_STRING([--with-bdb-dir=DIR],
[Berkeley DB installation directory])])
# Check if --with-bdb-dir was specified.
if test "x$with_bdb_dir" = "x" ; then
# No option specified, so just search the system.
AX_PATH_BDB_NO_OPTIONS([$1], [HIGHEST], [
ax_path_bdb_ok=yes
])
else
# Set --with-bdb-dir option.
ax_path_bdb_INC="$with_bdb_dir/include"
ax_path_bdb_LIB="$with_bdb_dir/lib"
dnl # Save previous environment, and modify with new stuff.
ax_path_bdb_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I$ax_path_bdb_INC $CPPFLAGS"
ax_path_bdb_save_LDFLAGS=$LDFLAGS
LDFLAGS="-L$ax_path_bdb_LIB $LDFLAGS"
# Check for specific header file db.h
AC_MSG_CHECKING([db.h presence in $ax_path_bdb_INC])
if test -f "$ax_path_bdb_INC/db.h" ; then
AC_MSG_RESULT([yes])
# Check for library
AX_PATH_BDB_NO_OPTIONS([$1], [ENVONLY], [
ax_path_bdb_ok=yes
BDB_CPPFLAGS="-I$ax_path_bdb_INC"
BDB_LDFLAGS="-L$ax_path_bdb_LIB"
])
else
AC_MSG_RESULT([no])
AC_MSG_NOTICE([no usable Berkeley DB not found])
fi
dnl # Restore the environment.
CPPFLAGS="$ax_path_bdb_save_CPPFLAGS"
LDFLAGS="$ax_path_bdb_save_LDFLAGS"
fi
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
if test "$ax_path_bdb_ok" = "yes" ; then
m4_ifvaln([$2],[$2],[:])dnl
m4_ifvaln([$3],[else $3])dnl
fi
]) dnl AX_PATH_BDB
dnl #########################################################################
dnl Check for berkeley DB of at least MINIMUM-VERSION on system.
dnl
dnl The OPTION argument determines how the checks occur, and can be one of:
dnl
dnl HIGHEST - Check both the environment and the default installation
dnl directories for Berkeley DB and choose the version that
dnl is highest. (default)
dnl ENVFIRST - Check the environment first, and if no satisfactory
dnl library is found there check the default installation
dnl directories for Berkeley DB which is /usr/local/BerkeleyDB*
dnl ENVONLY - Check the current environment only.
dnl
dnl Requires AX_PATH_BDB_PATH_GET_VERSION, AX_PATH_BDB_PATH_FIND_HIGHEST,
dnl AX_PATH_BDB_ENV_CONFIRM_LIB, AX_PATH_BDB_ENV_GET_VERSION, and
dnl AX_COMPARE_VERSION macros.
dnl
dnl Result: sets ax_path_bdb_no_options_ok to yes or no
dnl sets BDB_LIBS, BDB_CPPFLAGS, BDB_LDFLAGS, BDB_VERSION
dnl
dnl AX_PATH_BDB_NO_OPTIONS([MINIMUM-VERSION], [OPTION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
AC_DEFUN([AX_PATH_BDB_NO_OPTIONS], [
dnl # Used to indicate success or failure of this function.
ax_path_bdb_no_options_ok=no
# Values to add to environment to use Berkeley DB.
BDB_VERSION=''
BDB_LIBS=''
BDB_CPPFLAGS=''
BDB_LDFLAGS=''
# Check cross compilation here.
if test "x$cross_compiling" = "xyes" ; then
# If cross compiling, can't use AC_RUN_IFELSE so do these tests.
# The AC_PREPROC_IFELSE confirms that db.h is preprocessable,
# and extracts the version number from it.
AC_MSG_CHECKING([for db.h])
AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_no_options_HEADER_VERSION])dnl
HEADER_VERSION=''
AC_PREPROC_IFELSE([
AC_LANG_SOURCE([[
#include <db.h>
#ifdef DB_VERSION_MAJOR
AX_PATH_BDB_STUFF DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH
#else
AX_PATH_BDB_STUFF 1,0,0
#endif
]])
],[
# Extract version from preprocessor output.
HEADER_VERSION=`eval "$ac_cpp conftest.$ac_ext" 2> /dev/null \
| grep AX_PATH_BDB_STUFF | sed 's/[[^0-9,]]//g;s/,/./g;1q'`
],[])
if test "x$HEADER_VERSION" = "x" ; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([$HEADER_VERSION])
# Check that version is high enough.
AX_COMPARE_VERSION([$HEADER_VERSION],[ge],[$1],[
# get major and minor version numbers
AS_VAR_PUSHDEF([MAJ],[ax_path_bdb_no_options_MAJOR])dnl
MAJ=`echo $HEADER_VERSION | sed 's,\..*,,'`
AS_VAR_PUSHDEF([MIN],[ax_path_bdb_no_options_MINOR])dnl
MIN=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'`
dnl # Save LIBS.
ax_path_bdb_no_options_save_LIBS="$LIBS"
# Check that we can link with the library.
AC_SEARCH_LIBS([db_version],
[db db-$MAJ.$MIN db$MAJ.$MIN db$MAJ$MIN db-$MAJ db$MAJ],[
# Sucessfully found library.
ax_path_bdb_no_options_ok=yes
BDB_VERSION=$HEADER_VERSION
# Extract library from LIBS
ax_path_bdb_no_options_LEN=` \
echo "x$ax_path_bdb_no_options_save_LIBS" \
| awk '{print(length)}'`
BDB_LIBS=`echo "x$LIBS " \
| sed "s/.\{$ax_path_bdb_no_options_LEN\}\$//;s/^x//;s/ //g"`
],[])
dnl # Restore LIBS
LIBS="$ax_path_bdb_no_options_save_LIBS"
AS_VAR_POPDEF([MAJ])dnl
AS_VAR_POPDEF([MIN])dnl
])
fi
AS_VAR_POPDEF([HEADER_VERSION])dnl
else
# Not cross compiling.
# Check version of Berkeley DB in the current environment.
AX_PATH_BDB_ENV_GET_VERSION([
AX_COMPARE_VERSION([$ax_path_bdb_env_get_version_VERSION],[ge],[$1],[
# Found acceptable version in current environment.
ax_path_bdb_no_options_ok=yes
BDB_VERSION="$ax_path_bdb_env_get_version_VERSION"
BDB_LIBS="$ax_path_bdb_env_get_version_LIBS"
])
])
# Determine if we need to search /usr/local/BerkeleyDB*
ax_path_bdb_no_options_DONE=no
if test "x$2" = "xENVONLY" ; then
ax_path_bdb_no_options_DONE=yes
elif test "x$2" = "xENVFIRST" ; then
ax_path_bdb_no_options_DONE=$ax_path_bdb_no_options_ok
fi
if test "$ax_path_bdb_no_options_DONE" = "no" ; then
ax_compare_version=false
# Check for highest in /usr/local/BerkeleyDB*
AX_PATH_BDB_PATH_FIND_HIGHEST([
if test "$ax_path_bdb_no_options_ok" = "yes" ; then
# If we already have an acceptable version use this if higher.
AX_COMPARE_VERSION(
[$ax_path_bdb_path_find_highest_VERSION],[gt],[$BDB_VERSION])
else
# Since we didn't have an acceptable version check if this one is.
AX_COMPARE_VERSION(
[$ax_path_bdb_path_find_highest_VERSION],[ge],[$1])
fi
])
dnl # If result from _AX_COMPARE_VERSION is true we want this version.
if test "$ax_compare_version" = "true" ; then
ax_path_bdb_no_options_ok=yes
BDB_LIBS="-ldb"
if test "x$ax_path_bdb_path_find_highest_DIR" != x ; then
BDB_CPPFLAGS="-I$ax_path_bdb_path_find_highest_DIR/include"
BDB_LDFLAGS="-L$ax_path_bdb_path_find_highest_DIR/lib"
fi
BDB_VERSION="$ax_path_bdb_path_find_highest_VERSION"
fi
fi
fi
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
if test "$ax_path_bdb_no_options_ok" = "yes" ; then
AC_MSG_NOTICE([using Berkeley DB version $BDB_VERSION])
AC_DEFINE([HAVE_DB_H],[1],
[Define to 1 if you have the <db.h> header file.])
m4_ifvaln([$3],[$3])dnl
else
AC_MSG_NOTICE([no Berkeley DB version $1 or higher found])
m4_ifvaln([$4],[$4])dnl
fi
]) dnl AX_PATH_BDB_NO_OPTIONS
dnl #########################################################################
dnl Check the default installation directory for Berkeley DB which is
dnl of the form /usr/local/BerkeleyDB* for the highest version.
dnl
dnl Result: sets ax_path_bdb_path_find_highest_ok to yes or no,
dnl sets ax_path_bdb_path_find_highest_VERSION to version,
dnl sets ax_path_bdb_path_find_highest_DIR to directory.
dnl
dnl AX_PATH_BDB_PATH_FIND_HIGHEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
AC_DEFUN([AX_PATH_BDB_PATH_FIND_HIGHEST], [
dnl # Used to indicate success or failure of this function.
ax_path_bdb_path_find_highest_ok=no
AS_VAR_PUSHDEF([VERSION],[ax_path_bdb_path_find_highest_VERSION])dnl
VERSION=''
ax_path_bdb_path_find_highest_DIR=''
# find highest verison in default install directory for Berkeley DB
AS_VAR_PUSHDEF([CURDIR],[ax_path_bdb_path_find_highest_CURDIR])dnl
AS_VAR_PUSHDEF([CUR_VERSION],[ax_path_bdb_path_get_version_VERSION])dnl
for CURDIR in `ls -d /usr/local/BerkeleyDB* 2> /dev/null`
do
AX_PATH_BDB_PATH_GET_VERSION([$CURDIR],[
AX_COMPARE_VERSION([$CUR_VERSION],[gt],[$VERSION],[
ax_path_bdb_path_find_highest_ok=yes
ax_path_bdb_path_find_highest_DIR="$CURDIR"
VERSION="$CUR_VERSION"
])
])
done
AS_VAR_POPDEF([VERSION])dnl
AS_VAR_POPDEF([CUR_VERSION])dnl
AS_VAR_POPDEF([CURDIR])dnl
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
if test "$ax_path_bdb_path_find_highest_ok" = "yes" ; then
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
]) dnl AX_PATH_BDB_PATH_FIND_HIGHEST
dnl #########################################################################
dnl Checks for Berkeley DB in specified directory's lib and include
dnl subdirectories.
dnl
dnl Result: sets ax_path_bdb_path_get_version_ok to yes or no,
dnl sets ax_path_bdb_path_get_version_VERSION to version.
dnl
dnl AX_PATH_BDB_PATH_GET_VERSION(BDB-DIR, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
AC_DEFUN([AX_PATH_BDB_PATH_GET_VERSION], [
dnl # Used to indicate success or failure of this function.
ax_path_bdb_path_get_version_ok=no
# Indicate status of checking for Berkeley DB header.
AC_MSG_CHECKING([in $1/include for db.h])
ax_path_bdb_path_get_version_got_header=no
test -f "$1/include/db.h" && ax_path_bdb_path_get_version_got_header=yes
AC_MSG_RESULT([$ax_path_bdb_path_get_version_got_header])
# Indicate status of checking for Berkeley DB library.
AC_MSG_CHECKING([in $1/lib for library -ldb])
ax_path_bdb_path_get_version_VERSION=''
if test -d "$1/include" && test -d "$1/lib" &&
test "$ax_path_bdb_path_get_version_got_header" = "yes" ; then
dnl # save and modify environment
ax_path_bdb_path_get_version_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I$1/include $CPPFLAGS"
ax_path_bdb_path_get_version_save_LIBS="$LIBS"
LIBS="$LIBS -ldb"
ax_path_bdb_path_get_version_save_LDFLAGS="$LDFLAGS"
LDFLAGS="-L$1/lib $LDFLAGS"
# Compile and run a program that compares the version defined in
# the header file with a version defined in the library function
# db_version.
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <stdio.h>
#include <db.h>
int main(int argc,char **argv)
{
(void) argv;
#ifdef DB_VERSION_MAJOR
int major,minor,patch;
db_version(&major,&minor,&patch);
if (argc > 1)
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH);
if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor &&
DB_VERSION_PATCH == patch)
return 0;
else
return 1;
#else
DB *dbp = dbopen(0, 0, 0, DB_HASH, 0);
if(dbp) dbp->close(dbp);
if (argc > 1)
printf("1.0.0\n");
if (dbp)
return 0;
else
return 1;
#endif
}
]])
],[
# Program compiled and ran, so get version by adding argument.
ax_path_bdb_path_get_version_VERSION=`./conftest$ac_exeext x`
ax_path_bdb_path_get_version_ok=yes
],[],[])
dnl # restore environment
CPPFLAGS="$ax_path_bdb_path_get_version_save_CPPFLAGS"
LIBS="$ax_path_bdb_path_get_version_save_LIBS"
LDFLAGS="$ax_path_bdb_path_get_version_save_LDFLAGS"
fi
dnl # Finally, execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
if test "$ax_path_bdb_path_get_version_ok" = "yes" ; then
AC_MSG_RESULT([$ax_path_bdb_path_get_version_VERSION])
m4_ifvaln([$2],[$2])dnl
else
AC_MSG_RESULT([no])
m4_ifvaln([$3],[$3])dnl
fi
]) dnl AX_PATH_BDB_PATH_GET_VERSION
dnl Checks if version of library and header match specified version.
dnl Only meant to be used by AX_PATH_BDB_ENV_GET_VERSION macro.
dnl
dnl Requires AX_COMPARE_VERSION macro.
dnl
dnl Result: sets ax_path_bdb_env_confirm_lib_ok to yes or no.
dnl
dnl AX_PATH_BDB_ENV_CONFIRM_LIB(VERSION, [LIBNAME])
AC_DEFUN([AX_PATH_BDB_ENV_CONFIRM_LIB], [
dnl # Used to indicate success or failure of this function.
ax_path_bdb_env_confirm_lib_ok=no
dnl # save and modify environment to link with library LIBNAME
ax_path_bdb_env_confirm_lib_save_LIBS="$LIBS"
LIBS="$LIBS $2"
# Compile and run a program that compares the version defined in
# the header file with a version defined in the library function
# db_version.
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <stdio.h>
#include <db.h>
int main(int argc,char **argv)
{
(void) argv;
#ifdef DB_VERSION_MAJOR
int major,minor,patch;
db_version(&major,&minor,&patch);
if (argc > 1)
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH);
if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor &&
DB_VERSION_PATCH == patch)
return 0;
else
return 1;
#else
DB *dbp = dbopen(0, 0, 0, DB_HASH, 0);
if(dbp) dbp->close(dbp);
if (argc > 1)
printf("1.0.0\n");
if (dbp)
return 0;
else
return 1;
#endif
}
]])
],[
# Program compiled and ran, so get version by giving an argument,
# which will tell the program to print the output.
ax_path_bdb_env_confirm_lib_VERSION=`./conftest$ac_exeext x`
# If the versions all match up, indicate success.
AX_COMPARE_VERSION([$ax_path_bdb_env_confirm_lib_VERSION],[eq],[$1],[
ax_path_bdb_env_confirm_lib_ok=yes
])
],[],[])
dnl # restore environment
LIBS="$ax_path_bdb_env_confirm_lib_save_LIBS"
]) dnl AX_PATH_BDB_ENV_CONFIRM_LIB
dnl Finds the version and library name for Berkeley DB in the
dnl current environment. Tries many different names for library.
dnl
dnl Requires AX_PATH_BDB_ENV_CONFIRM_LIB macro.
dnl
dnl Result: set ax_path_bdb_env_get_version_ok to yes or no,
dnl set ax_path_bdb_env_get_version_VERSION to the version found,
dnl and ax_path_bdb_env_get_version_LIBNAME to the library name.
dnl
dnl AX_PATH_BDB_ENV_GET_VERSION([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
AC_DEFUN([AX_PATH_BDB_ENV_GET_VERSION], [
dnl # Used to indicate success or failure of this function.
ax_path_bdb_env_get_version_ok=no
ax_path_bdb_env_get_version_VERSION=''
ax_path_bdb_env_get_version_LIBS=''
AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_env_get_version_HEADER_VERSION])dnl
AS_VAR_PUSHDEF([TEST_LIBNAME],[ax_path_bdb_env_get_version_TEST_LIBNAME])dnl
# Indicate status of checking for Berkeley DB library.
AC_MSG_CHECKING([for db.h])
# Compile and run a program that determines the Berkeley DB version
# in the header file db.h.
HEADER_VERSION=''
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <stdio.h>
#include <db.h>
int main(int argc,char **argv)
{
(void) argv;
if (argc > 1)
#ifdef DB_VERSION_MAJOR
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH);
#else
printf("1.0.0\n");
#endif
return 0;
}
]])
],[
# Program compiled and ran, so get version by adding an argument.
HEADER_VERSION=`./conftest$ac_exeext x`
AC_MSG_RESULT([$HEADER_VERSION])
],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no])])
# Have header version, so try to find corresponding library.
# Looks for library names in the order:
# nothing, db, db-X.Y, dbX.Y, dbXY, db-X, dbX
# and stops when it finds the first one that matches the version
# of the header file.
if test "x$HEADER_VERSION" != "x" ; then
AC_MSG_CHECKING([for library containing Berkeley DB $HEADER_VERSION])
AS_VAR_PUSHDEF([MAJOR],[ax_path_bdb_env_get_version_MAJOR])dnl
AS_VAR_PUSHDEF([MINOR],[ax_path_bdb_env_get_version_MINOR])dnl
# get major and minor version numbers
MAJOR=`echo $HEADER_VERSION | sed 's,\..*,,'`
MINOR=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'`
# see if it is already specified in LIBS
TEST_LIBNAME=''
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
# try format "db"
TEST_LIBNAME='-ldb'
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
fi
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
# try format "db-X.Y"
TEST_LIBNAME="-ldb-${MAJOR}.$MINOR"
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
fi
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
# try format "dbX.Y"
TEST_LIBNAME="-ldb${MAJOR}.$MINOR"
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
fi
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
# try format "dbXY"
TEST_LIBNAME="-ldb$MAJOR$MINOR"
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
fi
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
# try format "db-X"
TEST_LIBNAME="-ldb-$MAJOR"
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
fi
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
# try format "dbX"
TEST_LIBNAME="-ldb$MAJOR"
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
fi
dnl # Found a valid library.
if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then
if test "x$TEST_LIBNAME" = "x" ; then
AC_MSG_RESULT([none required])
else
AC_MSG_RESULT([$TEST_LIBNAME])
fi
ax_path_bdb_env_get_version_VERSION="$HEADER_VERSION"
ax_path_bdb_env_get_version_LIBS="$TEST_LIBNAME"
ax_path_bdb_env_get_version_ok=yes
else
AC_MSG_RESULT([no])
fi
AS_VAR_POPDEF([MAJOR])dnl
AS_VAR_POPDEF([MINOR])dnl
fi
AS_VAR_POPDEF([HEADER_VERSION])dnl
AS_VAR_POPDEF([TEST_LIBNAME])dnl
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
]) dnl BDB_ENV_GET_VERSION
dnl @synopsis AX_RANDOM_DEVICE
dnl
dnl This macro will check for a random device, allowing the user to explicitly
dnl set the path. The user uses '--with-random=FILE' as an argument to
dnl configure.
dnl
dnl If A random device is found then HAVE_RANDOM_DEVICE is set to 1 and
dnl RANDOM_DEVICE contains the path.
dnl
dnl @category Miscellaneous
dnl @author Martin Ebourne
dnl @version 2005/07/01
dnl @license AllPermissive
AC_DEFUN([AX_RANDOM_DEVICE], [
AC_ARG_WITH([random],
[AC_HELP_STRING([--with-random=FILE], [Use FILE as random number seed [auto-detected]])],
[RANDOM_DEVICE="$withval"],
[AC_CHECK_FILE("/dev/urandom", [RANDOM_DEVICE="/dev/urandom";],
[AC_CHECK_FILE("/dev/arandom", [RANDOM_DEVICE="/dev/arandom";],
[AC_CHECK_FILE("/dev/random", [RANDOM_DEVICE="/dev/random";])]
)])
])
if test "x$RANDOM_DEVICE" != "x" ; then
AC_DEFINE([HAVE_RANDOM_DEVICE], 1,
[Define to 1 (and set RANDOM_DEVICE) if a random device is available])
AC_SUBST([RANDOM_DEVICE])
AC_DEFINE_UNQUOTED([RANDOM_DEVICE], ["$RANDOM_DEVICE"],
[Define to the filename of the random device (and set HAVE_RANDOM_DEVICE)])
fi
])dnl
dnl @synopsis AX_SPLIT_VERSION(DEFINE, VERSION)
dnl
dnl Splits a version number in the format MAJOR.MINOR.POINT into it's
dnl separate components and AC_DEFINES <DEFINE>_MAJOR etc with the values.
dnl
dnl @category Automake
dnl @author Martin Ebourne <martin@zepler.org>
dnl @version
dnl @license AllPermissive
AC_DEFUN([AX_SPLIT_VERSION],[
ax_major_version=`echo "$2" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
ax_minor_version=`echo "$2" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
ax_point_version=`echo "$2" | sed 's/[[^.]][[^.]]*.[[^.]][[^.]]*.\(.*\)/\1/'`
AC_DEFINE_UNQUOTED([$1_MAJOR], [$ax_major_version], [Define to major version for $1])
AC_DEFINE_UNQUOTED([$1_MINOR], [$ax_minor_version], [Define to minor version for $1])
AC_DEFINE_UNQUOTED([$1_POINT], [$ax_point_version], [Define to point version for $1])
])
dnl @synopsis VL_LIB_READLINE([ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl
dnl Searches for a readline compatible library. If found, defines
dnl `HAVE_LIBREADLINE'. If the found library has the `add_history'
dnl function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
dnl locations of the necessary include files and sets `HAVE_READLINE_H'
dnl or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
dnl 'HAVE_HISTORY_H' if the corresponding include files exists.
dnl
dnl The libraries that may be readline compatible are `libedit',
dnl `libeditline' and `libreadline'. Sometimes we need to link a
dnl termcap library for readline to work, this macro tests these cases
dnl too by trying to link with `libtermcap', `libcurses' or
dnl `libncurses' before giving up.
dnl
dnl Here is an example of how to use the information provided by this
dnl macro to perform the necessary includes or declarations in a C
dnl file:
dnl
dnl #ifdef HAVE_LIBREADLINE
dnl # if defined(HAVE_READLINE_READLINE_H)
dnl # include <readline/readline.h>
dnl # elif defined(HAVE_READLINE_H)
dnl # include <readline.h>
dnl # else /* !defined(HAVE_READLINE_H) */
dnl extern char *readline ();
dnl # endif /* !defined(HAVE_READLINE_H) */
dnl char *cmdline = NULL;
dnl #else /* !defined(HAVE_READLINE_READLINE_H) */
dnl /* no readline */
dnl #endif /* HAVE_LIBREADLINE */
dnl
dnl #ifdef HAVE_READLINE_HISTORY
dnl # if defined(HAVE_READLINE_HISTORY_H)
dnl # include <readline/history.h>
dnl # elif defined(HAVE_HISTORY_H)
dnl # include <history.h>
dnl # else /* !defined(HAVE_HISTORY_H) */
dnl extern void add_history ();
dnl extern int write_history ();
dnl extern int read_history ();
dnl # endif /* defined(HAVE_READLINE_HISTORY_H) */
dnl /* no history */
dnl #endif /* HAVE_READLINE_HISTORY */
dnl
dnl Modifications to add --enable-gnu-readline to work around licensing
dnl problems between the traditional BSD licence and the GPL.
dnl Martin Ebourne, 2005/7/11
dnl Rewrite to match headers with libraries and be more selective.
dnl Martin Ebourne, 2006/1/4
dnl
dnl @category InstalledPackages
dnl @author Ville Laurikari <vl@iki.fi>
dnl @version 2002-04-04
dnl @license AllPermissive
AC_DEFUN([VL_LIB_READLINE], [
AC_ARG_ENABLE(
[gnu-readline],
AC_HELP_STRING([--enable-gnu-readline],
[Use GNU readline if present (may violate GNU licence)])
)
vl_cv_lib_readline_compat_found=no
if test "x$enable_gnu_readline" = "xyes"; then
VL_LIB_READLINE_CHECK([readline],
[readline],
[readline/readline.h readline.h],
[readline/history.h history.h])
fi
if test "x$vl_cv_lib_readline_compat_found" = "xno"; then
VL_LIB_READLINE_CHECK([editline],
[edit editline],
[editline/readline.h],
[editline/readline.h])
fi
if test "x$vl_cv_lib_readline_compat_found" = "xyes"; then
m4_ifvaln([$1],[$1],[:])dnl
m4_ifvaln([$2],[else $2])dnl
fi
])
dnl VL_LIB_READLINE_CHECK(name, libraries, headers, history headers)
AC_DEFUN([VL_LIB_READLINE_CHECK], [
AC_CACHE_CHECK([for $1 library],
[vl_cv_lib_$1], [
ORIG_LIBS="$LIBS"
vl_cv_lib_$1=""
for readline_lib in $2; do
for termcap_lib in "" termcap curses ncurses; do
if test -z "$termcap_lib"; then
TRY_LIB="-l$readline_lib"
else
TRY_LIB="-l$readline_lib -l$termcap_lib"
fi
LIBS="$ORIG_LIBS $TRY_LIB"
AC_TRY_LINK_FUNC([readline], [vl_cv_lib_$1="$TRY_LIB"])
if test -n "$vl_cv_lib_$1"; then
break
fi
done
if test -n "$vl_cv_lib_$1"; then
break
fi
done
if test -z "$vl_cv_lib_$1"; then
vl_cv_lib_$1=no
LIBS="$ORIG_LIBS"
fi
])
vl_cv_lib_readline_compat_found=no
if test "x$vl_cv_lib_$1" != "xno"; then
AC_CHECK_HEADERS([$3], [vl_cv_lib_readline_compat_found=yes])
fi
if test "x$vl_cv_lib_readline_compat_found" = "xyes"; then
AC_DEFINE([HAVE_LIBREADLINE], 1,
[Define if you have a readline compatible library])
AC_CACHE_CHECK([whether $1 supports history],
[vl_cv_lib_$1_history], [
vl_cv_lib_$1_history=no
AC_TRY_LINK_FUNC([add_history], [vl_cv_lib_$1_history=yes])
])
if test "x$vl_cv_lib_$1_history" = "xyes"; then
vl_cv_lib_$1_history=no
AC_CHECK_HEADERS(
[$4],
[AC_DEFINE([HAVE_READLINE_HISTORY], [1],
[Define if your readline library has add_history])])
fi
else
LIBS="$ORIG_LIBS"
fi
])dnl
syntax highlighted by Code2HTML, v. 0.9.1