Skip to content
Snippets Groups Projects
Commit 154851f6 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

second patches of FS#984 that allow further caching of configure checks.

Kudos to Christoph Grueninger.


[[Imported from SVN: r6543]]
parent 7d1a4ad5
No related branches found
No related tags found
No related merge requests found
# whether g++ accepts -std=c++0x
AC_DEFUN([GXX0X],[
AC_REQUIRE([AC_PROG_CXX])
AC_ARG_ENABLE(gxx0xcheck,
AC_HELP_STRING([--disable-gxx0xcheck],
[try to enable c++0x feature for g++ [[default=yes]]]),
[gxx0xcheck=$enableval],
[gxx0xcheck=yes])
if test "x$GXX" = xyes && test "x$gxx0xcheck" = xyes; then
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether g++ accepts -std=c++0x])
ac_save_CXX="$CXX"
CXX="$CXX -std=c++0x"
HAVE_CXX0X=no
AC_TRY_COMPILE([#include <iostream>
#include <array>],[],[HAVE_CXX0X=yes],[])
if test "x$HAVE_CXX0X" == "xyes" ; then
CXXCPP="$CXXCPP -std=c++0x"
else
CXX="$ac_save_CXX"
ac_save_CXX="$CXX"
AC_CACHE_CHECK([whether g++ accepts -std=c++0x], dune_cv_gplusplus_accepts_cplusplus0x, [
AC_REQUIRE([AC_PROG_CXX])
AC_ARG_ENABLE(gxx0xcheck,
AC_HELP_STRING([--disable-gxx0xcheck],
[try to enable c++0x feature for g++ [[default=yes]]]),
[gxx0xcheck=$enableval],
[gxx0xcheck=yes])
if test "x$GXX" = xyes && test "x$gxx0xcheck" = xyes; then
AC_LANG_PUSH([C++])
CXX="$CXX -std=c++0x"
AC_TRY_COMPILE([
#include <iostream>
#include <array>
], [],
dune_cv_gplusplus_accepts_cplusplus0x=yes,
dune_cv_gplusplus_accepts_cplusplus0x=no)
AC_LANG_POP
fi
AC_MSG_RESULT([$HAVE_CXX0X])
AC_LANG_POP
])
if test "x$dune_cv_gplusplus_accepts_cplusplus0x" == "xyes" ; then
CXX="$ac_save_CXX -std=c++0x"
CXXCPP="$CXXCPP -std=c++0x"
else
CXX="$ac_save_CXX"
fi
])
......@@ -2,32 +2,31 @@
# the associated macro is called HAVE_RVALUE_REFERENCES
AC_DEFUN([RVALUE_REFERENCES_CHECK],[
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether rvalue references are supported])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([#include<cassert>
#include <utility>
int foo(int&& x) { return 1; }
int foo(const int& x) { return -1; }
AC_CACHE_CHECK([whether rvalue references are supported], dune_cv_rvalue_references_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([#include<cassert>
#include <utility>
int foo(int&& x) { return 1; }
int foo(const int& x) { return -1; }
template<typename T>
int forward(T&& x)
{
return foo(std::forward<T>(x));
}],
[
int i = 0;
assert( forward(i) + forward(int(2)) == 0);
return 0;
])],[
HAVE_RVALUE_REFERENCES=yes
AC_MSG_RESULT(yes)], [
HAVE_RVALUE_REFERENCES=no
AC_MSG_RESULT(no)])
if test "x$HAVE_RVALUE_REFERENCES" = xyes; then
template<typename T>
int forward(T&& x)
{
return foo(std::forward<T>(x));
}],
[
int i = 0;
assert( forward(i) + forward(int(2)) == 0);
return 0;
])],
dune_cv_rvalue_references_support=yes,
dune_cv_rvalue_references_support=no)
AC_LANG_POP
])
if test "x$dune_cv_rvalue_references_support" = xyes; then
AC_DEFINE(HAVE_RVALUE_REFERENCES, 1, [Define to 1 if rvalue references are supported])
fi
AC_LANG_POP
])
......@@ -2,36 +2,35 @@
# the associated macro is called HAVE_VARIADIC_TEMPLATES
AC_DEFUN([VARIADIC_TEMPLATES_CHECK],[
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether variadic templates are supported])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([#include<cassert>
AC_CACHE_CHECK([whether variadic templates are supported], dune_cv_variadic_templates_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([#include<cassert>
template<typename... T>
int addints(T... x);
template<typename... T>
int addints(T... x);
int add_ints()
{
return 0;
}
int add_ints()
{
return 0;
}
template<typename T1, typename... T>
int add_ints(T1 t1, T... t)
{
return t1 + add_ints(t...);
}],
[
assert( 5 == add_ints(9,3,-5,-2) );
return 0;
])],[
HAVE_VARIADIC_TEMPLATES=yes
AC_MSG_RESULT(yes)], [
HAVE_VARIADIC_TEMPLATES=no
AC_MSG_RESULT(no)])
if test "x$HAVE_VARIADIC_TEMPLATES" = xyes; then
template<typename T1, typename... T>
int add_ints(T1 t1, T... t)
{
return t1 + add_ints(t...);
}],
[
assert( 5 == add_ints(9,3,-5,-2) );
return 0;
])],
dune_cv_variadic_templates_support=yes,
dune_cv_variadic_templates_support=no)
AC_LANG_POP
])
if test "x$dune_cv_variadic_templates_support" = xyes; then
AC_DEFINE(HAVE_VARIADIC_TEMPLATES, 1, [Define to 1 if variadic templates are supported])
fi
AC_LANG_POP
])
......@@ -3,52 +3,52 @@
# the associated macro is called HAVE_VARIADIC_CONSTRUCTOR_SFINAE
AC_DEFUN([VARIADIC_CONSTRUCTOR_SFINAE_CHECK],[
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether SFINAE on variadic template constructors is fully supported])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([#include <cassert>
#include <functional>
AC_CACHE_CHECK([whether SFINAE on variadic template constructors is fully supported],
dune_cv_variadic_constructor_sfinae_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([#include <cassert>
#include <functional>
template<typename... U>
struct A
{
template<typename... U>
struct A
{
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) < 2)>::type
>
A(T... t)
: i(1)
{}
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) < 2)>::type
>
A(T... t)
: i(1)
{}
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
typename = void
>
A(T... t)
: i(-1)
{}
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
typename = void
>
A(T... t)
: i(-1)
{}
A()
: i(1)
{}
A()
: i(1)
{}
int i;
};],
[
assert( A<int>().i +
A<int>(2).i +
A<int>("foo",3.4).i +
A<int>(8,'a',A<int>()).i == 0);
return 0;
])],[
HAVE_VARIADIC_CONSTRUCTOR_SFINAE=yes
AC_MSG_RESULT(yes)], [
HAVE_VARIADIC_CONSTRUCTOR_SFINAE=no
AC_MSG_RESULT(no)])
if test "x$HAVE_VARIADIC_CONSTRUCTOR_SFINAE" = xyes; then
int i;
};],
[
assert( A<int>().i +
A<int>(2).i +
A<int>("foo",3.4).i +
A<int>(8,'a',A<int>()).i == 0);
return 0;
])],
dune_cv_variadic_constructor_sfinae_support=yes,
dune_cv_variadic_constructor_sfinae_support=no)
AC_LANG_POP
])
if test "x$dune_cv_variadic_constructor_sfinae_support" = xyes; then
AC_DEFINE(HAVE_VARIADIC_CONSTRUCTOR_SFINAE, 1, [Define to 1 if SFINAE on variadic template constructors is fully supported])
fi
AC_LANG_POP
])
......@@ -3,7 +3,7 @@
# Check for the right way to create the deprecation warning
AC_DEFUN([DUNE_CHECKDEPRECATED],[
AC_MSG_CHECKING([for __attribute__((deprecated))])
AC_CACHE_CHECK([for __attribute__((deprecated))], dune_cv_attribute_deprecated, [
AC_LANG_PUSH([C++])
AC_TRY_COMPILE([#define DEP __attribute__((deprecated))
class bar { bar() DEP; };
......@@ -14,14 +14,13 @@ AC_DEFUN([DUNE_CHECKDEPRECATED],[
class t_peng { t_peng() {}; } DEP;
void foo() DEP;
void foo() {};],[],
[HAS_ATTRIBUTE_DEPRECATED="yes"
AC_MSG_RESULT(yes)],
[HAS_ATTRIBUTE_DEPRECATED="no"
AC_MSG_RESULT(no)])
dune_cv_attribute_deprecated="yes",
dune_cv_attribute_deprecated="no")
AC_LANG_POP([C++])
])
AC_MSG_CHECKING([for __attribute__((deprecated("message")))])
AC_CACHE_CHECK([for __attribute__((deprecated("message")))],
dune_cv_attribute_deprecated_message, [
AC_LANG_PUSH([C++])
AC_TRY_COMPILE([#define DEP __attribute__((deprecated("fireworks!")))
class bar { bar() DEP; };
......@@ -32,20 +31,19 @@ AC_DEFUN([DUNE_CHECKDEPRECATED],[
class t_peng { t_peng() {}; } DEP;
void foo() DEP;
void foo() {};],[],
[HAS_ATTRIBUTE_DEPRECATED_MSG="yes"
AC_MSG_RESULT(yes)],
[HAS_ATTRIBUTE_DEPRECATED_MSG="no"
AC_MSG_RESULT(no)])
AC_LANG_POP([C++])
dune_cv_attribute_deprecated_message="yes",
dune_cv_attribute_deprecated_message="no")
AC_LANG_POP([C++])
])
if test "$HAS_ATTRIBUTE_DEPRECATED" = "yes"; then
if test "$dune_cv_attribute_deprecated" = "yes"; then
AC_DEFINE_UNQUOTED(HAS_ATTRIBUTE_DEPRECATED, 1,
[does the compiler support __attribute__((deprecated))?])
fi
if test "$HAS_ATTRIBUTE_DEPRECATED_MSG" = "yes"; then
if test "$dune_cv_attribute_deprecated_message" = "yes"; then
AC_DEFINE_UNQUOTED(HAS_ATTRIBUTE_DEPRECATED_MSG, 1,
[does the compiler support __attribute__((deprecated("text"))?])
[does the compiler support __attribute__((deprecated("message"))?])
fi
AH_BOTTOM([#include <dune/common/deprecated.hh>])
......
......@@ -10,13 +10,16 @@ AC_DEFUN([DUNE_TR1_HEADERS], [
[enable_tr_headers=yes])
AS_IF([test "x$enable_tr1_headers" != "xno"],
[AC_CHECK_HEADERS([type_traits tr1/type_traits tuple tr1/tuple])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[array]],
AC_CACHE_CHECK([whether <array> C++0x is supported], dune_cv_array_cplusplus0x, [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <array>]],
[[std::array<int,2> a; a.fill(9);]])],
[HAVE_ARRAY=yes], [HAVE_ARRAY=no])
AS_IF([test "x$HAVE_ARRAY" != "xno"],
[AC_DEFINE([HAVE_ARRAY], 1, [Define to 1 if the <array> C++0x is available and support array::fill])])]
)
dune_cv_array_cplusplus0x=yes,
dune_cv_array_cplusplus0x=no)
])
AS_IF([test "x$dune_cv_array_cplusplus0x" != "xno"],
[AC_DEFINE([HAVE_ARRAY], 1, [Define to 1 if the <array> C++0x is available and support array::fill])
])
])
AC_LANG_POP([C++])
])
......@@ -2,10 +2,13 @@ AC_DEFUN([MAKE_SHARED],[
AC_REQUIRE([SHARED_PTR])
AS_IF([test "$SHARED_PTR_NAMESPACE" = "boost"],[
AC_CHECK_HEADER([boost/make_shared.hpp],
[AC_DEFINE([HAVE_BOOST_MAKE_SHARED_HPP], [1],
[Define to 1 if you have <boost/make_shared.hpp>.])])])
AC_MSG_CHECKING([whether SHARED_PTR_NAMESPACE ($SHARED_PTR_NAMESPACE) provides make_shared])
AC_LANG_PUSH([C++])
[AC_DEFINE([HAVE_BOOST_MAKE_SHARED_HPP], [1],
[Define to 1 if you have <boost/make_shared.hpp>.])
])
])
AC_CACHE_CHECK([whether SHARED_PTR_NAMESPACE ($SHARED_PTR_NAMESPACE) provides make_shared],
dune_cv_make_shared, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#if defined(HAVE_MEMORY)
......@@ -22,13 +25,11 @@ AC_DEFUN([MAKE_SHARED],[
]],[[
$SHARED_PTR_NAMESPACE::make_shared<int>(3);
]])],
[ AC_MSG_RESULT(yes)
have_make_shared=yes
],[AC_MSG_RESULT(no)
have_make_shared=no
])
AS_IF([test "$have_make_shared" = "yes"],[
dune_cv_make_shared=yes,
dune_cv_make_shared=no)
AC_LANG_POP
])
AS_IF([test "$dune_cv_make_shared" = "yes"],[
AC_DEFINE([HAVE_MAKE_SHARED], [1],
[Define to 1 if SHARED_PTR_NAMESPACE::make_shared is usable.])])
AC_LANG_POP
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment