]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5208] C++11 detection code moved to ax_cpp11.m4
authorTomek Mrugalski <tomasz@isc.org>
Fri, 14 Apr 2017 17:24:52 +0000 (19:24 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Thu, 20 Apr 2017 17:44:15 +0000 (19:44 +0200)
configure.ac
m4macros/ax_cpp11.m4 [new file with mode: 0644]

index 04a700a7b6d86020827b3a007dd44ab1678a54e6..2a230f4777dd0b18ce0667d328c0633a2a7d8b10 100644 (file)
@@ -118,124 +118,7 @@ AC_CHECK_DECL([__clang__], [CLANGPP="yes"], [CLANGPP="no"])
 AM_CONDITIONAL(USE_CLANGPP, test "X${CLANGPP}" = "Xyes")
 
 # Check for C++11 features support
-CXX_SAVED=$CXX
-feature=
-for retry in "none" "--std=c++11" "--std=c++0x" "--std=c++1x" "fail"; do
-       if test "$retry" = "fail"; then
-               AC_MSG_ERROR([$feature (a C++11 feature) is not supported])
-       fi
-       if test "$retry" != "none"; then
-               AC_MSG_WARN([unsupported C++11 feature])
-               AC_MSG_NOTICE([retrying by adding $retry to $CXX])
-               CXX="$CXX_SAVED $retry"
-               AC_MSG_CHECKING($retry support)
-               AC_COMPILE_IFELSE(
-                       [AC_LANG_PROGRAM(
-                               [],
-                               [int myincr = 1;])],
-                       [AC_MSG_RESULT([yes])],
-                       [AC_MSG_RESULT([no])
-                        continue])
-       fi
-
-       AC_MSG_CHECKING(std::unique_ptr support)
-       feature="std::unique_ptr"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <memory>],
-                       [std::unique_ptr<int> a;])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(cbegin/cend support)
-       feature="cbegin/cend"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <string>],
-                       [const std::string& s = "abcd";
-                        unsigned count = 0;
-                        for (std::string::const_iterator i = s.cbegin();
-                             i != s.cend(); ++i)
-                               if (*i == 'b')
-                                       ++count;])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(final method support)
-       feature="final method"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [class Foo {
-                        public:
-                               virtual ~Foo() {};
-                               virtual void bar() final;
-                        };],[])],
-                [AC_MSG_RESULT([yes])],
-                [AC_MSG_RESULT([no])
-                 continue])
-
-       AC_MSG_CHECKING(aggregate initialization support)
-       feature="aggregate initialization"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [#include <vector>],
-                       [std::vector<int> foo = { 1, 2, 3};])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(variadic template support)
-       feature="variadic template"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [template<typename ... Args>
-                        struct A {
-                        void foo(Args... myargs) { return; };
-                        };],
-                        [A<> a;
-                         a.foo();])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(static_assert support)
-       feature="static_assert"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [static_assert(1 + 1 == 2, "");],
-                       [])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(template alias)
-       feature="template alias"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [template<int i>
-                        class I {
-                        public: int get() { return i; };
-                        };
-                        using Zero = I<0>;],
-                       [Zero Z;
-                        return Z.get();])],
-               [AC_MSG_RESULT([yes])],
-               [AC_MSG_RESULT([no])
-                continue])
-
-       AC_MSG_CHECKING(lambda support)
-       feature="lambda"
-       AC_COMPILE_IFELSE(
-               [AC_LANG_PROGRAM(
-                       [],
-                       [auto myincr = [[]](int x) { return x + 1; };])],
-               [AC_MSG_RESULT([yes])
-                break],
-               [AC_MSG_RESULT([no])
-                continue])
-done
+AX_ISC_CPP11
 
 # Check for std::is_base_of support
 AC_MSG_CHECKING([for std::is_base_of])
diff --git a/m4macros/ax_cpp11.m4 b/m4macros/ax_cpp11.m4
new file mode 100644 (file)
index 0000000..cf6b2ba
--- /dev/null
@@ -0,0 +1,122 @@
+AC_DEFUN([AX_ISC_CPP11], [
+
+CXX_SAVED=$CXX
+feature=
+for retry in "none" "--std=c++11" "--std=c++0x" "--std=c++1x" "fail"; do
+       if test "$retry" = "fail"; then
+               AC_MSG_ERROR([$feature (a C++11 feature) is not supported])
+       fi
+       if test "$retry" != "none"; then
+               AC_MSG_WARN([unsupported C++11 feature])
+               AC_MSG_NOTICE([retrying by adding $retry to $CXX])
+               CXX="$CXX_SAVED $retry"
+               AC_MSG_CHECKING($retry support)
+               AC_COMPILE_IFELSE(
+                       [AC_LANG_PROGRAM(
+                               [],
+                               [int myincr = 1;])],
+                       [AC_MSG_RESULT([yes])],
+                       [AC_MSG_RESULT([no])
+                        continue])
+       fi
+
+       AC_MSG_CHECKING(std::unique_ptr support)
+       feature="std::unique_ptr"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [#include <memory>],
+                       [std::unique_ptr<int> a;])],
+               [AC_MSG_RESULT([yes])],
+               [AC_MSG_RESULT([no])
+                continue])
+
+       AC_MSG_CHECKING(cbegin/cend support)
+       feature="cbegin/cend"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [#include <string>],
+                       [const std::string& s = "abcd";
+                        unsigned count = 0;
+                        for (std::string::const_iterator i = s.cbegin();
+                             i != s.cend(); ++i)
+                               if (*i == 'b')
+                                       ++count;])],
+               [AC_MSG_RESULT([yes])],
+               [AC_MSG_RESULT([no])
+                continue])
+
+       AC_MSG_CHECKING(final method support)
+       feature="final method"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [class Foo {
+                        public:
+                               virtual ~Foo() {};
+                               virtual void bar() final;
+                        };],[])],
+                [AC_MSG_RESULT([yes])],
+                [AC_MSG_RESULT([no])
+                 continue])
+
+       AC_MSG_CHECKING(aggregate initialization support)
+       feature="aggregate initialization"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [#include <vector>],
+                       [std::vector<int> foo = { 1, 2, 3};])],
+               [AC_MSG_RESULT([yes])],
+               [AC_MSG_RESULT([no])
+                continue])
+
+       AC_MSG_CHECKING(variadic template support)
+       feature="variadic template"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [template<typename ... Args>
+                        struct A {
+                        void foo(Args... myargs) { return; };
+                        };],
+                        [A<> a;
+                         a.foo();])],
+               [AC_MSG_RESULT([yes])],
+               [AC_MSG_RESULT([no])
+                continue])
+
+       AC_MSG_CHECKING(static_assert support)
+       feature="static_assert"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [static_assert(1 + 1 == 2, "");],
+                       [])],
+               [AC_MSG_RESULT([yes])],
+               [AC_MSG_RESULT([no])
+                continue])
+
+       AC_MSG_CHECKING(template alias)
+       feature="template alias"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [template<int i>
+                        class I {
+                        public: int get() { return i; };
+                        };
+                        using Zero = I<0>;],
+                       [Zero Z;
+                        return Z.get();])],
+               [AC_MSG_RESULT([yes])],
+               [AC_MSG_RESULT([no])
+                continue])
+
+       AC_MSG_CHECKING(lambda support)
+       feature="lambda"
+       AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM(
+                       [],
+                       [auto myincr = [[]](int x) { return x + 1; };])],
+               [AC_MSG_RESULT([yes])
+                break],
+               [AC_MSG_RESULT([no])
+                continue])
+done
+
+])dnl AX_ISC_RPATH