From 81d8eda2419e7a23088a98cdfc52a305c9ceac0d Mon Sep 17 00:00:00 2001 From: Martin Ebourne Date: Wed, 7 Dec 2005 16:34:47 +0000 Subject: Merged martin/autoconf at r35 to trunk --- infrastructure/m4/ac_cxx_exceptions.m4 | 24 ++++++ infrastructure/m4/ac_cxx_namespaces.m4 | 25 ++++++ infrastructure/m4/ax_check_bdb_v1.m4 | 43 ++++++++++ infrastructure/m4/ax_check_define_pragma.m4 | 25 ++++++ infrastructure/m4/ax_check_dirent_d_type.m4 | 41 +++++++++ infrastructure/m4/ax_check_llong_minmax.m4 | 76 +++++++++++++++++ infrastructure/m4/ax_check_malloc_workaround.m4 | 38 +++++++++ infrastructure/m4/ax_check_mount_point.m4 | 41 +++++++++ infrastructure/m4/ax_check_nonaligned_access.m4 | 57 +++++++++++++ infrastructure/m4/ax_check_ssl.m4 | 37 +++++++++ infrastructure/m4/ax_check_syscall_lseek.m4 | 54 ++++++++++++ infrastructure/m4/ax_func_syscall.m4 | 39 +++++++++ infrastructure/m4/ax_random_device.m4 | 31 +++++++ infrastructure/m4/vl_lib_readline.m4 | 106 ++++++++++++++++++++++++ 14 files changed, 637 insertions(+) create mode 100644 infrastructure/m4/ac_cxx_exceptions.m4 create mode 100644 infrastructure/m4/ac_cxx_namespaces.m4 create mode 100644 infrastructure/m4/ax_check_bdb_v1.m4 create mode 100644 infrastructure/m4/ax_check_define_pragma.m4 create mode 100644 infrastructure/m4/ax_check_dirent_d_type.m4 create mode 100644 infrastructure/m4/ax_check_llong_minmax.m4 create mode 100644 infrastructure/m4/ax_check_malloc_workaround.m4 create mode 100644 infrastructure/m4/ax_check_mount_point.m4 create mode 100644 infrastructure/m4/ax_check_nonaligned_access.m4 create mode 100644 infrastructure/m4/ax_check_ssl.m4 create mode 100644 infrastructure/m4/ax_check_syscall_lseek.m4 create mode 100644 infrastructure/m4/ax_func_syscall.m4 create mode 100644 infrastructure/m4/ax_random_device.m4 create mode 100644 infrastructure/m4/vl_lib_readline.m4 (limited to 'infrastructure/m4') diff --git a/infrastructure/m4/ac_cxx_exceptions.m4 b/infrastructure/m4/ac_cxx_exceptions.m4 new file mode 100644 index 00000000..4c3013dc --- /dev/null +++ b/infrastructure/m4/ac_cxx_exceptions.m4 @@ -0,0 +1,24 @@ +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 +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 +]) diff --git a/infrastructure/m4/ac_cxx_namespaces.m4 b/infrastructure/m4/ac_cxx_namespaces.m4 new file mode 100644 index 00000000..2f18477b --- /dev/null +++ b/infrastructure/m4/ac_cxx_namespaces.m4 @@ -0,0 +1,25 @@ +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 +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 +]) diff --git a/infrastructure/m4/ax_check_bdb_v1.m4 b/infrastructure/m4/ax_check_bdb_v1.m4 new file mode 100644 index 00000000..de36ca07 --- /dev/null +++ b/infrastructure/m4/ax_check_bdb_v1.m4 @@ -0,0 +1,43 @@ +dnl @synopsis AX_CHECK_BDB_V1 +dnl +dnl This macro find an installation of Berkeley DB version 1, or compatible. +dnl It will define the following macros on success: +dnl +dnl HAVE_DB - If Berkeley DB version 1 or compatible is available +dnl DB_HEADER - The relative path and filename of the header file +dnl LIBS - Updated for correct library +dnl +dnl @category C +dnl @author Martin Ebourne +dnl @version 2005/07/12 +dnl @license AllPermissive + +AC_DEFUN([AX_CHECK_BDB_V1], [ + ac_have_bdb=no + AC_CHECK_HEADERS([db_185.h db4/db_185.h db3/db_185.h db1/db.h db.h], + [ac_bdb_header=$ac_header; break], [ac_bdb_header=""]) + if test "x$ac_bdb_header" != x; then + AC_SEARCH_LIBS([__db185_open], + [db db-4.3 db-4.2 db-4.1 db-4.0 db-3], + [ac_have_bdb=yes], + [AC_SEARCH_LIBS([dbopen], [db-1 db], [ac_have_bdb=yes])]) + fi + if test "x$ac_have_bdb" = "xyes"; then + AC_MSG_CHECKING([whether found db libraries work]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + $ac_includes_default + #include "$ac_bdb_header"]], [[ + DB *dbp = dbopen(0, 0, 0, DB_HASH, 0); + if(dbp) dbp->close(dbp); + return 0; + ]])], [ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_DB], 1, [Define to 1 if Berkeley DB is available]) + AC_DEFINE_UNQUOTED([DB_HEADER], ["$ac_bdb_header"], + [Define to the location of the Berkeley DB 1.85 header]) + ], [ + AC_MSG_RESULT([no]) + ac_have_bdb=no + ]) + fi + ])dnl diff --git a/infrastructure/m4/ax_check_define_pragma.m4 b/infrastructure/m4/ax_check_define_pragma.m4 new file mode 100644 index 00000000..176faf3d --- /dev/null +++ b/infrastructure/m4/ax_check_define_pragma.m4 @@ -0,0 +1,25 @@ +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 diff --git a/infrastructure/m4/ax_check_dirent_d_type.m4 b/infrastructure/m4/ax_check_dirent_d_type.m4 new file mode 100644 index 00000000..87b93185 --- /dev/null +++ b/infrastructure/m4/ax_check_dirent_d_type.m4 @@ -0,0 +1,41 @@ +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 ]]) + 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 + ]], [[ + 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 diff --git a/infrastructure/m4/ax_check_llong_minmax.m4 b/infrastructure/m4/ax_check_llong_minmax.m4 new file mode 100644 index 00000000..f3f99c53 --- /dev/null +++ b/infrastructure/m4/ax_check_llong_minmax.m4 @@ -0,0 +1,76 @@ +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 ]]) + if test -z "$have_llong_max"; then + AC_MSG_CHECKING([[for max value of long long]]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + /* Why is this so damn hard? */ + #undef __GNUC__ + #undef __USE_ISOC99 + #define __USE_ISOC99 + #include + #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 diff --git a/infrastructure/m4/ax_check_malloc_workaround.m4 b/infrastructure/m4/ax_check_malloc_workaround.m4 new file mode 100644 index 00000000..9b1c9848 --- /dev/null +++ b/infrastructure/m4/ax_check_malloc_workaround.m4 @@ -0,0 +1,38 @@ +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 + ]], [[ + 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 diff --git a/infrastructure/m4/ax_check_mount_point.m4 b/infrastructure/m4/ax_check_mount_point.m4 new file mode 100644 index 00000000..747888cc --- /dev/null +++ b/infrastructure/m4/ax_check_mount_point.m4 @@ -0,0 +1,41 @@ +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_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 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([mntent.h sys/mnttab.h sys/mount.h],,, [[#include ]]) + # BSD + AC_CHECK_MEMBERS([struct statfs.f_mntonname],,, [[ + #include + #include + ]]) + # Linux + AC_CHECK_MEMBERS([struct mntent.mnt_dir],,, [[#include ]]) + # Solaris + AC_CHECK_MEMBERS([struct mnttab.mnt_mountp],,, [[ + #include + #include + ]]) + if test "x$ac_cv_member_struct_statfs_f_mntonname" = "xyes" || \ + test "x$ac_cv_member_struct_mntent_mnt_dir" = "xyes" || \ + test "x$ac_cv_member_struct_mnttab_mnt_mountp" = "xyes" + then + m4_ifvaln([$1],[$1],[:])dnl + m4_ifvaln([$2],[else $2])dnl + fi + ])dnl diff --git a/infrastructure/m4/ax_check_nonaligned_access.m4 b/infrastructure/m4/ax_check_nonaligned_access.m4 new file mode 100644 index 00000000..8a6cd0c6 --- /dev/null +++ b/infrastructure/m4/ax_check_nonaligned_access.m4 @@ -0,0 +1,57 @@ +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 diff --git a/infrastructure/m4/ax_check_ssl.m4 b/infrastructure/m4/ax_check_ssl.m4 new file mode 100644 index 00000000..039c8398 --- /dev/null +++ b/infrastructure/m4/ax_check_ssl.m4 @@ -0,0 +1,37 @@ +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]) + + 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 diff --git a/infrastructure/m4/ax_check_syscall_lseek.m4 b/infrastructure/m4/ax_check_syscall_lseek.m4 new file mode 100644 index 00000000..6bf93c23 --- /dev/null +++ b/infrastructure/m4/ax_check_syscall_lseek.m4 @@ -0,0 +1,54 @@ +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 + #include + #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 diff --git a/infrastructure/m4/ax_func_syscall.m4 b/infrastructure/m4/ax_func_syscall.m4 new file mode 100644 index 00000000..40496bf0 --- /dev/null +++ b/infrastructure/m4/ax_func_syscall.m4 @@ -0,0 +1,39 @@ +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 + #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 diff --git a/infrastructure/m4/ax_random_device.m4 b/infrastructure/m4/ax_random_device.m4 new file mode 100644 index 00000000..ab9b56fd --- /dev/null +++ b/infrastructure/m4/ax_random_device.m4 @@ -0,0 +1,31 @@ +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 diff --git a/infrastructure/m4/vl_lib_readline.m4 b/infrastructure/m4/vl_lib_readline.m4 new file mode 100644 index 00000000..7c9217d6 --- /dev/null +++ b/infrastructure/m4/vl_lib_readline.m4 @@ -0,0 +1,106 @@ +dnl @synopsis VL_LIB_READLINE +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 +dnl # elif defined(HAVE_READLINE_H) +dnl # include +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 +dnl # elif defined(HAVE_HISTORY_H) +dnl # include +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 +dnl @category InstalledPackages +dnl @author Ville Laurikari +dnl @version 2002-04-04 +dnl @license AllPermissive + +AC_DEFUN([VL_LIB_READLINE], [ + AC_ARG_ENABLE( + [gnu-readline], + AC_HELP_STRING([--enable-gnu-readline], + [Allow use of GNU readline (may violate GNU licence)]) + ) + vl_gnu_readline_lib="" + if test "x$enable_gnu_readline" = "xyes"; then + vl_gnu_readline_lib=readline + fi + AC_CACHE_CHECK([for a readline compatible library], + vl_cv_lib_readline, [ + ORIG_LIBS="$LIBS" + for readline_lib in edit editline $vl_gnu_readline_lib; 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_readline="$TRY_LIB") + if test -n "$vl_cv_lib_readline"; then + break + fi + done + if test -n "$vl_cv_lib_readline"; then + break + fi + done + if test -z "$vl_cv_lib_readline"; then + vl_cv_lib_readline="no" + LIBS="$ORIG_LIBS" + fi + ]) + + if test "x$vl_cv_lib_readline" != "xno"; then + AC_DEFINE(HAVE_LIBREADLINE, 1, + [Define if you have a readline compatible library]) + AC_CHECK_HEADERS(readline.h readline/readline.h) + AC_CACHE_CHECK([whether readline supports history], + vl_cv_lib_readline_history, [ + vl_cv_lib_readline_history="no" + AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes") + ]) + if test "x$vl_cv_lib_readline_history" = "xyes"; then + AC_DEFINE(HAVE_READLINE_HISTORY, 1, + [Define if your readline library has \`add_history']) + AC_CHECK_HEADERS(history.h readline/history.h) + fi + fi +])dnl -- cgit v1.2.3