dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_bool.html dnl AC_DEFUN([AC_CXX_BOOL], [AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type, ac_cv_cxx_bool, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ int f(int x){return 1;} int f(char x){return 1;} int f(bool x){return 1;} ],[bool b = true; return f(b);], ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_bool" = yes; then AC_DEFINE(HAVE_BOOL,,[define if bool is a built-in type]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_complex_math_in_namespace_std.html dnl AC_DEFUN([AC_CXX_COMPLEX_MATH_IN_NAMESPACE_STD], [AC_CACHE_CHECK(whether complex math functions are in std::, ac_cv_cxx_complex_math_in_namespace_std, [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include namespace S { using namespace std; complex pow(complex x, complex y) { return std::pow(x,y); } }; ],[using namespace S; complex x = 1.0, y = 1.0; S::pow(x,y); return 0;], ac_cv_cxx_complex_math_in_namespace_std=yes, ac_cv_cxx_complex_math_in_namespace_std=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_complex_math_in_namespace_std" = yes; then AC_DEFINE(HAVE_COMPLEX_MATH_IN_NAMESPACE_STD,, [define if complex math functions are in std::]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html dnl AC_DEFUN([AC_CXX_CONST_CAST], [AC_CACHE_CHECK(whether the compiler supports const_cast<>, ac_cv_cxx_const_cast, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast(y);return z;], ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_const_cast" = yes; then AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_default_template_parameters.html dnl AC_DEFUN([AC_CXX_DEFAULT_TEMPLATE_PARAMETERS], [AC_CACHE_CHECK(whether the compiler supports default template parameters, ac_cv_cxx_default_template_parameters, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class A {public: int f() {return 0;}}; ],[A a; return a.f();], ac_cv_cxx_default_template_parameters=yes, ac_cv_cxx_default_template_parameters=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_default_template_parameters" = yes; then AC_DEFINE(HAVE_DEFAULT_TEMPLATE_PARAMETERS,, [define if the compiler supports default template parameters]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_dynamic_cast.html dnl AC_DEFUN([AC_CXX_DYNAMIC_CAST], [AC_CACHE_CHECK(whether the compiler supports dynamic_cast<>, ac_cv_cxx_dynamic_cast, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include class Base { public : Base () {} virtual void f () = 0;}; class Derived : public Base { public : Derived () {} virtual void f () {} };],[ Derived d; Base& b=d; return dynamic_cast(&b) ? 0 : 1;], ac_cv_cxx_dynamic_cast=yes, ac_cv_cxx_dynamic_cast=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_dynamic_cast" = yes; then AC_DEFINE(HAVE_DYNAMIC_CAST,,[define if the compiler supports dynamic_cast<>]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_exceptions.html dnl 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 Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_explicit.html dnl AC_DEFUN([AC_CXX_EXPLICIT], [AC_CACHE_CHECK(whether the compiler supports the explicit keyword, ac_cv_cxx_explicit, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([class A{public:explicit A(double){}};], [double c = 5.0;A x(c);return 0;], ac_cv_cxx_explicit=yes, ac_cv_cxx_explicit=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_explicit" = yes; then AC_DEFINE(HAVE_EXPLICIT,,[define if the compiler supports the explicit keyword]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_map.html dnl AC_DEFUN([AC_CXX_HAVE_EXT_HASH_MAP], [AC_CACHE_CHECK(whether the compiler has ext/hash_map, ac_cv_cxx_have_ext_hash_map, [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include #ifdef HAVE_NAMESPACES using namespace std; #endif],[hash_map t; return 0;], ac_cv_cxx_have_ext_hash_map=yes, ac_cv_cxx_have_ext_hash_map=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_have_ext_hash_map" = yes; then AC_DEFINE(HAVE_EXT_HASH_MAP,,[define if the compiler has ext/hash_map]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_set.html dnl AC_DEFUN([AC_CXX_HAVE_EXT_HASH_SET], [AC_CACHE_CHECK(whether the compiler has ext/hash_set, ac_cv_cxx_have_ext_hash_set, [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include #ifdef HAVE_NAMESPACES using namespace std; #endif],[hash_set t; return 0;], ac_cv_cxx_have_ext_hash_set=yes, ac_cv_cxx_have_ext_hash_set=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_have_ext_hash_set" = yes; then AC_DEFINE(HAVE_EXT_HASH_SET,,[define if the compiler has ext/hash_set]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_numeric_limits.html 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 Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_sstream.html dnl AC_DEFUN([AC_CXX_HAVE_SSTREAM], [AC_CACHE_CHECK(whether the compiler has stringstream, ac_cv_cxx_have_sstream, [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include #ifdef HAVE_NAMESPACES using namespace std; #endif],[stringstream message; message << "Hello"; return 0;], ac_cv_cxx_have_sstream=yes, ac_cv_cxx_have_sstream=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_have_sstream" = yes; then AC_DEFINE(HAVE_SSTREAM,,[define if the compiler has stringstream]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_std.html dnl AC_DEFUN([AC_CXX_HAVE_STD], [AC_CACHE_CHECK(whether the compiler supports ISO C++ standard library, ac_cv_cxx_have_std, [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include #include #include #include #ifdef HAVE_NAMESPACES using namespace std; #endif],[return 0;], ac_cv_cxx_have_std=yes, ac_cv_cxx_have_std=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_have_std" = yes; then AC_DEFINE(HAVE_STD,,[define if the compiler supports ISO C++ standard library]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_stl.html dnl AC_DEFUN([AC_CXX_HAVE_STL], [AC_CACHE_CHECK(whether the compiler supports 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" = yes; then AC_DEFINE(HAVE_STL,,[define if the compiler supports Standard Template Library]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_namespaces.html dnl 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 Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_new_for_scoping.html dnl AC_DEFUN([AC_CXX_NEW_FOR_SCOPING], [AC_CACHE_CHECK(whether the compiler accepts the new for scoping rules, ac_cv_cxx_new_for_scoping, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE(,[ int z = 0; for (int i = 0; i < 10; ++i) z = z + i; for (int i = 0; i < 10; ++i) z = z - i; return z;], ac_cv_cxx_new_for_scoping=yes, ac_cv_cxx_new_for_scoping=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_new_for_scoping" = yes; then AC_DEFINE(HAVE_NEW_FOR_SCOPING,,[define if the compiler accepts the new for scoping rules]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html dnl AC_DEFUN([AC_CXX_REINTERPRET_CAST], [AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>, ac_cv_cxx_reinterpret_cast, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include class Base { public : Base () {} virtual void f () = 0;}; class Derived : public Base { public : Derived () {} virtual void f () {} }; class Unrelated { public : Unrelated () {} }; int g (Unrelated&) { return 0; }],[ Derived d;Base& b=d;Unrelated& e=reinterpret_cast(b);return g(e);], ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_reinterpret_cast" = yes; then AC_DEFINE(HAVE_REINTERPRET_CAST,, [define if the compiler supports reinterpret_cast<>]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_rtti.html dnl AC_DEFUN([AC_CXX_RTTI], [AC_CACHE_CHECK(whether the compiler supports Run-Time Type Identification, ac_cv_cxx_rtti, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include class Base { public : Base () {} virtual int f () { return 0; } }; class Derived : public Base { public : Derived () {} virtual int f () { return 1; } }; ],[Derived d; Base *ptr = &d; return typeid (*ptr) == typeid (Derived); ], ac_cv_cxx_rtti=yes, ac_cv_cxx_rtti=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_rtti" = yes; then AC_DEFINE(HAVE_RTTI,, [define if the compiler supports Run-Time Type Identification]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html dnl AC_DEFUN([AC_CXX_STATIC_CAST], [AC_CACHE_CHECK(whether the compiler supports static_cast<>, ac_cv_cxx_static_cast, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include class Base { public : Base () {} virtual void f () = 0; }; class Derived : public Base { public : Derived () {} virtual void f () {} }; int g (Derived&) { return 0; }],[ Derived d; Base& b = d; Derived& s = static_cast (b); return g (s);], ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_static_cast" = yes; then AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_template_qualified_base_class.html dnl AC_DEFUN([AC_CXX_TEMPLATE_QUALIFIED_BASE_CLASS], [AC_CACHE_CHECK(whether the compiler supports template-qualified base class specifiers, ac_cv_cxx_template_qualified_base_class, [AC_REQUIRE([AC_CXX_TYPENAME]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #ifndef HAVE_TYPENAME #define typename #endif class Base1 { public : int f () const { return 1; } }; class Base2 { public : int f () const { return 0; } }; template struct base_trait { typedef Base1 base; }; struct base_trait { typedef Base2 base; }; template class Weird : public base_trait::base { public : typedef typename base_trait::base base; int g () const { return f (); } };],[ Weird z; return z.g ();], ac_cv_cxx_template_qualified_base_class=yes, ac_cv_cxx_template_qualified_base_class=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_template_qualified_base_class" = yes; then AC_DEFINE(HAVE_TEMPLATE_QUALIFIED_BASE_CLASS,, [define if the compiler supports template-qualified base class specifiers]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_template_qualified_return_type.html 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" = yes; then AC_DEFINE(HAVE_TEMPLATE_QUALIFIED_RETURN_TYPE,, [define if the compiler supports template-qualified return types]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_template_scoped_argument_matching.html dnl AC_DEFUN([AC_CXX_TEMPLATE_SCOPED_ARGUMENT_MATCHING], [AC_CACHE_CHECK(whether the compiler supports function matching with argument types which are template scope-qualified, ac_cv_cxx_template_scoped_argument_matching, [AC_REQUIRE([AC_CXX_TYPENAME]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #ifndef HAVE_TYPENAME #define typename #endif template class A { public : typedef X W; }; template class B {}; template void operator+(B d1, typename Y::W d2) {} ],[B > z; z + 0.5f; return 0;], ac_cv_cxx_template_scoped_argument_matching=yes, ac_cv_cxx_template_scoped_argument_matching=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_template_scoped_argument_matching" = yes; then AC_DEFINE(HAVE_TEMPLATE_SCOPED_ARGUMENT_MATCHING,, [define if the compiler supports function matching with argument types which are template scope-qualified]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_templates.html dnl AC_DEFUN([AC_CXX_TEMPLATES], [AC_CACHE_CHECK(whether the compiler supports basic templates, ac_cv_cxx_templates, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([template class A {public:A(){}}; template void f(const A& ){}],[ A d; A i; f(d); f(i); return 0;], ac_cv_cxx_templates=yes, ac_cv_cxx_templates=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_templates" = yes; then AC_DEFINE(HAVE_TEMPLATES,,[define if the compiler supports basic templates]) fi ]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_typename.html 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 Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html dnl AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_SAVE AC_LANG_C acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) AC_MSG_RESULT($acx_pthread_ok) if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthread or # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [acx_pthread_ok=yes]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($acx_pthread_ok) if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: threads are created detached by default # and the JOINABLE attribute has a nonstandard name (UNDETACHED). AC_MSG_CHECKING([for joinable pthread attribute]) AC_TRY_LINK([#include ], [int attr=PTHREAD_CREATE_JOINABLE;], ok=PTHREAD_CREATE_JOINABLE, ok=unknown) if test x"$ok" = xunknown; then AC_TRY_LINK([#include ], [int attr=PTHREAD_CREATE_UNDETACHED;], ok=PTHREAD_CREATE_UNDETACHED, ok=unknown) fi if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok, [Define to the necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_RESULT(${ok}) if test x"$ok" = xunknown; then AC_MSG_WARN([we do not know how to create joinable pthreads]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with cc_r AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else acx_pthread_ok=no $2 fi AC_LANG_RESTORE ])dnl ACX_PTHREAD dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ax_prefix_config_h.html dnl AC_DEFUN([AX_PREFIX_CONFIG_H],[AC_REQUIRE([AC_CONFIG_HEADERS]) AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl m4_pushdef([_script],[conftest.prefix])dnl m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl _OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)` _DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` _PKG=`echo ifelse($2, , $PACKAGE, $2)` _LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` _UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` _INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'` if test ".$_INP" = "."; then for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue case "$ac_file" in *.h) _INP=$ac_file ;; *) esac test ".$_INP" != "." && break done fi if test ".$_INP" = "."; then case "$_OUT" in */*) _INP=`basename "$_OUT"` ;; *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` ;; *) _INP=config.h ;; esac fi if test -z "$_PKG" ; then AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) else if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then _INP="$srcdir/$_INP" fi fi AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) if test -f $_INP ; then echo "s/@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/" > _script echo "s/@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/" >> _script echo "s/@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1 \\" >> _script echo "@%:@def[]ine $_UPP""_\\1 \\2 \\" >> _script echo "@%:@endif/" >>_script echo "s/@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1 \\" >> _script echo "@%:@define $_LOW""_\\1 \\2 \\" >> _script echo "@%:@endif/" >> _script # now executing _script on _DEF input to create _OUT output file echo "@%:@ifndef $_DEF" >$tmp/pconfig.h echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h sed -f _script $_INP >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h echo "@%:@endif" >>$tmp/pconfig.h if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then AC_MSG_NOTICE([$_OUT is unchanged]) else ac_dir=`AS_DIRNAME(["$_OUT"])` AS_MKDIR_P(["$ac_dir"]) rm -f "$_OUT" mv $tmp/pconfig.h "$_OUT" fi cp _script _configs.sed else AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT]) fi rm -f conftest.* fi m4_popdef([_symbol])dnl m4_popdef([_script])dnl AS_VAR_POPDEF([_INP])dnl AS_VAR_POPDEF([_UPP])dnl AS_VAR_POPDEF([_LOW])dnl AS_VAR_POPDEF([_PKG])dnl AS_VAR_POPDEF([_DEF])dnl AS_VAR_POPDEF([_OUT])dnl ],[PACKAGE="$PACKAGE"])]) dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/check_zlib.html dnl AC_DEFUN([CHECK_ZLIB], # # Handle user hints # [AC_MSG_CHECKING(if zlib is wanted) AC_ARG_WITH(zlib, [ --with-zlib=DIR root directory path of zlib installation [defaults to /usr/local or /usr if not found in /usr/local] --without-zlib to disable zlib usage completely], [if test "$withval" != no ; then AC_MSG_RESULT(yes) ZLIB_HOME="$withval" else AC_MSG_RESULT(no) fi], [ AC_MSG_RESULT(yes) ZLIB_HOME=/usr/local if test ! -f "${ZLIB_HOME}/include/zlib.h" then ZLIB_HOME=/usr fi ]) # # Locate zlib, if wanted # if test -n "${ZLIB_HOME}" then ZLIB_OLD_LDFLAGS=$LDFLAGS ZLIB_OLD_CPPFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" AC_LANG_SAVE AC_LANG_C AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no]) AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no]) AC_LANG_RESTORE if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes" then # # If both library and header were found, use them # AC_CHECK_LIB(z, inflateEnd) AC_MSG_CHECKING(zlib in ${ZLIB_HOME}) AC_MSG_RESULT(ok) else # # If either header or library was not found, revert and bomb # AC_MSG_CHECKING(zlib in ${ZLIB_HOME}) LDFLAGS="$ZLIB_OLD_LDFLAGS" CPPFLAGS="$ZLIB_OLD_CPPFLAGS" AC_MSG_RESULT(failed) AC_MSG_ERROR(either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib) fi fi ]) AC_DEFUN([OB_CXX_HAVE_ISFINITE], [AC_CACHE_CHECK(whether the compiler supports isfinite macro, ac_cv_cxx_have_isfinite, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#define _GNU_SOURCE #include ], [double d=0; int n = isfinite(d);], ac_cv_cxx_have_isfinite=yes, ac_cv_cxx_have_isfinite=no) AC_LANG_RESTORE ]) if test $ac_cv_cxx_have_isfinite = yes; then AC_DEFINE(HAVE_ISFINITE,,[define if the macro isfinite exist]) fi ]) AC_DEFUN([OB_CXX_LONG_LONG], [AC_CACHE_CHECK(for long long int, ob_cv_cxx_long_long, [ AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE(,[long long int i;], ob_cv_cxx_long_long=yes, ob_cv_cxx_long_long=no) ]) if test $ob_cv_cxx_long_long = yes; then AC_DEFINE(HAVE_LONG_LONG,,[define if long long int type is supported]) fi ])