dnl CHECK FOR WORKING MMAP CALL dnl --------------------------------------------------------------------- AC_DEFUN([AC_WORKING_MMAP], [AC_CACHE_CHECK(whether mmap() works as expected, ac_cv_working_mmap, [AC_LANG_SAVE AC_LANG_C AC_TRY_RUN([ #include #include #include #include #include int main( void ) { int fd;char* ptr; fd = open ("/etc/passwd", O_RDONLY, 0); if( ! ((void*)ptr = mmap (NULL, 512, PROT_READ,MAP_PRIVATE|MAP_FILE, fd, 0)) ) exit(-1); return 0;} ], ac_cv_working_mmap=yes, ac_cv_working_mmap=no) AC_LANG_RESTORE ]) if test "$ac_cv_working_mmap" = yes; then AC_DEFINE(HAVE_MMAP,,[define if mmap works]) fi ]) dnl CHECK FOR NAMESPACE SUPPORT dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_NAMESPACES], [AC_CACHE_CHECK(whether the compiler supports 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 supports namespaces]) fi ]) dnl CHECK FOR IEEE MATH dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_HAVE_IEEE_MATH], [AC_CACHE_CHECK(whether the compiler supports the IEEE math library, ac_cv_cxx_have_ieee_math, [AC_LANG_SAVE AC_LANG_CPLUSPLUS ac_save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ #ifndef _ALL_SOURCE #define _ALL_SOURCE #endif #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE #endif #ifndef _XOPEN_SOURCE_EXTENDED #define _XOPEN_SOURCE_EXTENDED 1 #endif #include ],[double x = 1.0; double y = 1.0; acosh(x); asinh(x); atanh(x); expm1(x); erf(x); erfc(x); isnan(x); j0(x); j1(x); lgamma(x); logb(x); log1p(x); rint(x); y0(x); y1(x); return 0;], ac_cv_cxx_have_ieee_math=yes, ac_cv_cxx_have_ieee_math=no) LIBS="$ac_save_LIBS" AC_LANG_RESTORE ]) if test "$ac_cv_cxx_have_ieee_math" = yes; then AC_DEFINE(HAVE_IEEE_MATH,,[define if the compiler supports IEEE math library]) fi ]) dnl CHECK FOR STL dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_HAVE_STL], [AC_CACHE_CHECK(whether the compiler has the Standard Template Library, ac_cv_cxx_have_stl, [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include #include #ifdef HAVE_NAMESPACES using namespace std; #endif],[list x; x.push_back(5); list::iterator iter = x.begin(); if (iter != x.end()) ++iter; return 0;], ac_cv_cxx_have_stl=yes, ac_cv_cxx_have_stl=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_have_stl" = no; then AC_MSG_ERROR(No Standard Template Library Found) fi ]) dnl CHECK FOR numeric_Limits<> dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_HAVE_NUMERIC_LIMITS], [AC_CACHE_CHECK(whether the compiler has numeric_limits, ac_cv_cxx_have_numeric_limits, [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include #ifdef HAVE_NAMESPACES using namespace std; #endif],[double e = numeric_limits::epsilon(); return 0;], ac_cv_cxx_have_numeric_limits=yes, ac_cv_cxx_have_numeric_limits=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_have_numeric_limits" = yes; then AC_DEFINE(HAVE_NUMERIC_LIMITS,,[define if the compiler has numeric_limits]) fi ]) dnl CHECK FOR PROPOSED 'RESTRICT' KEYWORD dnl --------------------------------------------------------------------- dnl Try the official restrict keyword, then gcc's __restrict__, then dnl SGI's __restrict. __restrict has slightly different semantics than dnl restrict (it's a bit stronger, in that __restrict pointers can't dnl overlap even with non __restrict pointers), but I think it should be dnl okay under the circumstances where restrict is normally used. dnl define restrict_ to be whatever is supported AC_DEFUN([AC_CXX_NCEG_RESTRICT], [AC_CACHE_CHECK([for NCEG/C99 restrict keyword], acx_cv_c_restrict, [acx_cv_c_restrict=unsupported AC_LANG_SAVE AC_LANG_CPLUSPLUS for acx_kw in restrict __restrict__ __restrict; do AC_TRY_COMPILE([], [float * $acx_kw x;], [acx_cv_c_restrict=$acx_kw; break]) done AC_LANG_RESTORE ]) acx_kw="$acx_cv_c_restrict" if test "$acx_kw" = unsupported; then acx_kw=""; fi AC_DEFINE_UNQUOTED(restrict_, $acx_kw, [Define to equivalent of C99 restrict keyword, or to nothing if this is not supported. Do not define if restrict is supported directly.]) if test "$acx_cv_c_restrict" != unsupported; then AC_DEFINE(HAVE_NCEG_RESTRICT,, [define if the compiler supports the NCEG/C99 restrict keyword]) fi ]) dnl CHECK FOR ENUM COMPUTATIONS dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_ENUM_COMPUTATIONS], [AC_CACHE_CHECK(whether the compiler supports enum computations, ac_cv_cxx_enum_computations, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ struct A { enum { a = 5, b = 7, c = 2 }; }; struct B { enum { a = 1, b = 6, c = 9 }; }; template struct Z { enum { a = (T1::a > T2::a) ? T1::a : T2::b, b = T1::b + T2::b, c = (T1::c * T2::c + T2::a + T1::a) }; };],[ return (((int)Z::a == 5) && ((int)Z::b == 13) && ((int)Z::c == 24)) ? 0 : 1;], ac_cv_cxx_enum_computations=yes, ac_cv_cxx_enum_computations=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_enum_computations" = no; then AC_MSG_ERROR(Compiler does not support enum computations) fi ]) dnl CHECK FOR TEMPLATES PARTIAL SPECIALIZATION dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_PARTIAL_SPECIALIZATION], [AC_CACHE_CHECK(whether the compiler supports partial specialization, ac_cv_cxx_partial_specialization, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class A { public : enum e { z = 0 }; }; template class A { public : enum e { z = 1 }; }; template class A { public : enum e { z = 2 }; }; ],[return (A::z == 0) && (A::z == 1) && (A::z == 2);], ac_cv_cxx_partial_specialization=yes, ac_cv_cxx_partial_specialization=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_partial_specialization" = no; then AC_MSG_ERROR(Compiler does not support partial specialization of templates) fi ]) dnl CHECK FOR TEMPLATES FULL SPECIALIZATION dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_FULL_SPECIALIZATION_SYNTAX], [AC_CACHE_CHECK(whether the compiler supports full specializations, ac_cv_cxx_full_specialization_syntax, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class A { public : int f () const { return 1; } }; template<> class A { public: int f () const { return 0; } };],[ A a; return a.f();], ac_cv_cxx_full_specialization_syntax=yes, ac_cv_cxx_full_specialization_syntax=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_full_specialization_syntax" = no; then AC_MSG_ERROR(Compiler does not support full specialization of templates) fi ]) dnl CHECK FOR MEMBER TEMPLATES dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_MEMBER_TEMPLATES], [AC_CACHE_CHECK(whether the compiler supports member templates, ac_cv_cxx_member_templates, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class A { public: template A operator=(const A& z) { return A(); } };],[A x; A y; x = y; return 0;], ac_cv_cxx_member_templates=yes, ac_cv_cxx_member_templates=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_member_templates" = no; then AC_MSG_ERROR(Compiler does not support member templates) fi ]) dnl CHECK FOR MEMBER TEMPLATE DECLARATIONS OUTSIDE CLASSES dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_MEMBER_TEMPLATES_OUTSIDE_CLASS], [AC_CACHE_CHECK(whether the compiler supports member templates outside the class declaration, ac_cv_cxx_member_templates_outside_class, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class A { public : template A operator=(const A& z); }; template template A A::operator=(const A& z){ return A(); }],[ A x; A y; x = y; return 0;], ac_cv_cxx_member_templates_outside_class=yes, ac_cv_cxx_member_templates_outside_class=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_member_templates_outside_class" = no; then AC_MSG_ERROR(Compiler does not support template declarations outside classes) fi ]) dnl CHECK FOR TYPENAME KEYWORD dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_TYPENAME], [AC_CACHE_CHECK(whether the compiler recognizes typename, ac_cv_cxx_typename, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([templateclass X {public:X(){}};], [X z; return 0;], ac_cv_cxx_typename=yes, ac_cv_cxx_typename=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_typename" = yes; then AC_DEFINE(HAVE_TYPENAME,,[define if the compiler recognizes typename]) fi ]) dnl CHECK FOR TEMPLATE QUALIFIED RETURN TYPES dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_TEMPLATE_QUALIFIED_RETURN_TYPE], [AC_CACHE_CHECK(whether the compiler supports template-qualified return types, ac_cv_cxx_template_qualified_return_type, [AC_REQUIRE([AC_CXX_TYPENAME]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #ifndef HAVE_TYPENAME #define typename #endif template struct promote_trait { typedef X T; }; template<> struct promote_trait { typedef float T; }; template class A { public : A () {} }; template A::T> operator+ (const A&, const A&) { return A::T>(); } ],[A x; A y; A z = x + y; return 0;], ac_cv_cxx_template_qualified_return_type=yes, ac_cv_cxx_template_qualified_return_type=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_template_qualified_return_type" = no; then AC_MSG_ERROR(Compiler does not support template qualified return types) fi ]) dnl CHECK FOR TEMPLATE PARTIAL ORDERING dnl --------------------------------------------------------------------- AC_DEFUN([AC_CXX_PARTIAL_ORDERING], [AC_CACHE_CHECK(whether the compiler supports partial ordering, ac_cv_cxx_partial_ordering, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template struct I {}; template struct A { int r; template int operator() (T1, T2) { r = 0; return r; } template int operator() (I, I) { r = 1; return r; } };],[A x, y; I<0> a; I<1> b; return x (a,b) + y (float(), double());], ac_cv_cxx_partial_ordering=yes, ac_cv_cxx_partial_ordering=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_partial_ordering" = no; then AC_MSG_ERROR(Compiler does not support template partial ordering) fi ]) dnl @synopsis AC_NEED_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])] dnl dnl the "ISO C9X: 7.18 Integer types " section requires the dnl existence of an include file that defines a set of dnl typedefs, especially uint8_t,int32_t,uintptr_t. dnl Many older installations will not provide this file, but some will dnl have the very same definitions in . In other enviroments dnl we can use the inet-types in which would define the dnl typedefs int8_t and u_int8_t respectivly. dnl dnl This macros will create a local "stdint.h" if it cannot find the dnl global (or it will create the headerfile given as an argument). dnl In many cases that file will just have a singular "#include " dnl statement, while in other environments it will provide the set of basic dnl stdint's defined: dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t dnl int_least32_t.. int_fast32_t.. intmax_t dnl which may or may not rely on the definitions of other files, dnl or using the AC_COMPILE_CHECK_SIZEOF macro to determine the actual dnl sizeof each type. dnl dnl if your header files require the stdint-types you will want to create an dnl installable file package-stdint.h that all your other installable header dnl may include. So if you have a library package named "mylib", just use dnl AC_NEED_STDINT(zziplib-stdint.h) dnl in configure.in and go to install that very header file in Makefile.am dnl along with the other headers (mylib.h) - and the mylib-specific headers dnl can simply use "#include " to obtain the stdint-types. dnl dnl Remember, if the system already had a valid , the generated dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things... dnl dnl @version $Id: acinclude.m4,v 1.1.1.1.4.1 2003/10/20 12:12:20 cag Exp $ dnl @author Guido Draheim STATUS: used on new platforms dnl Modified by Robby Dermody REASON: Fixed warning about dnl __AC_STDINT_H with newer versions of autoconf dnl AC_DEFUN([AC_NEED_STDINT_H], [AC_MSG_CHECKING([for stdint-types]) ac_cv_header_stdint="no-file" ac_cv_header_stdint_u="no-file" for i in $1 inttypes.h sys/inttypes.h sys/int_types.h stdint.h ; do AC_CHECK_TYPEDEF_(uint32_t, $i, [ac_cv_header_stdint=$i]) done for i in $1 sys/types.h inttypes.h sys/inttypes.h sys/int_types.h ; do AC_CHECK_TYPEDEF_(u_int32_t, $i, [ac_cv_header_stdint_u=$i]) done dnl debugging: __AC_MSG( !$ac_cv_header_stdint!$ac_cv_header_stdint_u! ...) ac_stdint_h=`echo ifelse($1, , stdint.h, $1)` if test "$ac_cv_header_stdint" != "no-file" ; then if test "$ac_cv_header_stdint" != "$ac_stdint_h" ; then AC_MSG_RESULT(found in $ac_cv_header_stdint) echo "#include <$ac_cv_header_stdint>" >$ac_stdint_h AC_MSG_RESULT(creating $ac_stdint_h - (just to include $ac_cv_header_stdint) ) else AC_MSG_RESULT(found in $ac_stdint_h) fi ac_cv_header_stdint_generated=false elif test "$ac_cv_header_stdint_u" != "no-file" ; then AC_MSG_RESULT(found u_types in $ac_cv_header_stdint_u) if test $ac_cv_header_stdint = "$ac_stdint_h" ; then AC_MSG_RESULT(creating $ac_stdint_h - includes $ac_cv_header_stdint, expect problems!) else AC_MSG_RESULT(creating $ac_stdint_h - (include inet-types in $ac_cv_header_stdint_u and re-typedef)) fi cat >$ac_stdint_h < #include <$ac_cv_header_stdint_u> /* int8_t int16_t int32_t defined by inet code */ typedef u_int8_t uint8_t; typedef u_int16_t uint16_t; typedef u_int32_t uint32_t; /* it's a networkable system, but without any stdint.h */ /* hence it's an older 32-bit system... (a wild guess that seems to work) */ typedef u_int32_t uintptr_t; typedef int32_t intptr_t; EOF ac_cv_header_stdint_generated=true else AC_MSG_RESULT(not found, need to guess the types now... ) AC_COMPILE_CHECK_SIZEOF(long, 32) AC_COMPILE_CHECK_SIZEOF(void*, 32) AC_MSG_RESULT( creating $ac_stdint_h - using detected values for sizeof long and sizeof void* ) cat >$ac_stdint_h < */ #define __int8_t_defined typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; EOF if test "$ac_cv_sizeof_long" = "64" ; then cat >>$ac_stdint_h <>$ac_stdint_h <>$ac_stdint_h <>$ac_stdint_h <>$ac_stdint_h <>)dnl dnl The name to #define. define(<>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl dnl The cache variable name. define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl changequote([, ])dnl AC_MSG_CHECKING(size of $1) AC_CACHE_VAL(AC_CV_NAME, [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence. AC_TRY_COMPILE([#include "confdefs.h" #include $2 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) if test x$AC_CV_NAME != x ; then break; fi done ]) if test x$AC_CV_NAME = x ; then AC_MSG_ERROR([cannot determine a size for $1]) fi AC_MSG_RESULT($AC_CV_NAME) AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) undefine([AC_TYPE_NAME])dnl undefine([AC_CV_NAME])dnl ]) AC_DEFUN(AC_CHECK_TYPEDEF_, [dnl ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` AC_CACHE_VAL(ac_cv_lib_$ac_lib_var, [ eval "ac_cv_type_$ac_lib_var='not-found'" ac_cv_check_typedef_header=`echo ifelse([$2], , stddef.h, $2)` AC_TRY_COMPILE( [#include <$ac_cv_check_typedef_header>], [int x = sizeof($1); x = x;], eval "ac_cv_type_$ac_lib_var=yes" , eval "ac_cv_type_$ac_lib_var=no" ) if test `eval echo '$ac_cv_type_'$ac_lib_var` = "no" ; then ifelse([$4], , :, $4) else ifelse([$3], , :, $3) fi ])]) dnl AC_CHECK_TYPEDEF(TYPEDEF, HEADER [, ACTION-IF-FOUND, dnl [, ACTION-IF-NOT-FOUND ]]) AC_DEFUN(AC_CHECK_TYPEDEF, [dnl AC_MSG_CHECKING([for $1 in $2]) AC_CHECK_TYPEDEF_($1,$2,AC_MSG_RESULT(yes),AC_MSG_RESULT(no))dnl ]) dnl @synopsis AC_SYS_LARGEFILE_SENSITIVE dnl dnl checker whether the current system is sensitive to -Ddefines dnl making off_t having different types/sizes. Automatically define dnl a config.h symbol LARGEFILE_SENSITIVE if that is the case, dnl otherwise leave everything as is. dnl dnl This macro builds on top of AC_SYS_LARGEFILE to detect whether dnl special options are neede to make the code use 64bit off_t - in dnl many setups this will also make the code use 64bit off_t immediatly. dnl dnl The common use of a LARGEFILE_SENSITIVE config.h-define is to rename dnl exported functions, usually adding a 64 to the original function name. dnl Such renamings are only needed on systems being both (a) 32bit off_t dnl by default and (b) implementing large.file extensions (as for unix98). dnl dnl a renaming section could look like this: dnl #if defined LARGEFILE_SENSITIVE && _FILE_OFFSET_BITS+0 == 64 dnl #define zzip_open zzip_open64 dnl #define zzip_seek zzip_seek64 dnl #endif dnl dnl for libraries, it is best to take advantage of the prefix-config.h dnl macro, otherwise you want to export a renamed LARGEFILE_SENSITIVE dnl in an installed header file. -> see AX_PREFIX_CONFIG_H dnl dnl @, System Headers dnl @Author Guido Draheim dnl @Version $Id: acinclude.m4,v 1.1.1.1.4.1 2003/10/20 12:12:20 cag Exp $ AC_DEFUN([AC_SYS_LARGEFILE_SENSITIVE],[dnl AC_REQUIRE([AC_SYS_LARGEFILE])dnl # we know about some internals of ac_sys_largefile here... AC_MSG_CHECKING(whether system differentiates 64bit off_t by defines) ac_cv_sys_largefile_sensitive="no" if test ".$ac_cv_sys_file_offset_bits$ac_cv_sys_large_files" != ".nono" then ac_cv_sys_largefile_sensitive="yes" AC_DEFINE(LARGEFILE_SENSITIVE, 1, [whether the system defaults to 32bit off_t but can do 64bit when requested]) fi AC_MSG_RESULT([$ac_cv_sys_largefile_sensitive]) ])