diff options
author | Savio Sena <savio.sena@acm.org> | 2014-08-23 00:19:23 -0300 |
---|---|---|
committer | Savio Sena <savio.sena@acm.org> | 2014-08-23 00:19:23 -0300 |
commit | 8682064e4ce4c152a12875ac73e863aa88a12212 (patch) | |
tree | ab458dffb8b14959129d02bf6d330243e2f5876f | |
parent | 12a82574519bb98523e071ea37249ee8e41675dd (diff) |
autotools: Introduce C++11 requirement.
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | m4/efl_stdcxx_11.m4 | 136 |
2 files changed, 144 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 041dfc9..009be02 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -35,7 +35,9 @@ AC_PROG_CC | |||
35 | 35 | ||
36 | LT_PROG_RC | 36 | LT_PROG_RC |
37 | 37 | ||
38 | ### Check for C++11 | ||
38 | 39 | ||
40 | EFL_CXX_COMPILE_STDCXX_11([ext], [mandatory]) | ||
39 | 41 | ||
40 | ### Checks for libraries | 42 | ### Checks for libraries |
41 | 43 | ||
@@ -55,6 +57,9 @@ PKG_CHECK_MODULES([EFL], eina >= 1.7.99 efl >= 1.11.99 eo >= 1.7.99 evas >= 1.7. | |||
55 | EFL_ENABLE_EO_API_SUPPORT | 57 | EFL_ENABLE_EO_API_SUPPORT |
56 | EFL_ENABLE_BETA_API_SUPPORT | 58 | EFL_ENABLE_BETA_API_SUPPORT |
57 | 59 | ||
60 | # EFL++ dependencies | ||
61 | |||
62 | PKG_CHECK_MODULES([EFL_CXX], eina-cxx >= 1.11.0 eo-cxx >= 1.11.0 evas-cxx >= 1.11.0 eet-cxx >= 1.11.0) | ||
58 | 63 | ||
59 | ### Checks for header files | 64 | ### Checks for header files |
60 | 65 | ||
@@ -92,8 +97,10 @@ AC_MSG_CHECKING([whether the compiler supports -fno-rtti -fno-exceptions]) | |||
92 | AC_MSG_RESULT([${have_cxx_flags}]) | 97 | AC_MSG_RESULT([${have_cxx_flags}]) |
93 | CXXFLAGS="${CXXFLAGS_save}" | 98 | CXXFLAGS="${CXXFLAGS_save}" |
94 | if test "x${have_cxx_flags}" = "xyes" ; then | 99 | if test "x${have_cxx_flags}" = "xyes" ; then |
95 | EXPEDITE_CXXFLAGS="-fno-rtti -fno-exceptions" | 100 | EXPEDITE_CXXFLAGS="-fno-rtti -fno-exceptions -std=c++11" |
96 | fi | 101 | fi |
102 | CXXFLAGS="{CXXFLAGS} -std=c++11" | ||
103 | |||
97 | AC_LANG_POP([C++]) | 104 | AC_LANG_POP([C++]) |
98 | AC_SUBST(EXPEDITE_CXXFLAGS) | 105 | AC_SUBST(EXPEDITE_CXXFLAGS) |
99 | 106 | ||
diff --git a/m4/efl_stdcxx_11.m4 b/m4/efl_stdcxx_11.m4 new file mode 100644 index 0000000..f606bc0 --- /dev/null +++ b/m4/efl_stdcxx_11.m4 | |||
@@ -0,0 +1,136 @@ | |||
1 | # ============================================================================ | ||
2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html | ||
3 | # ============================================================================ | ||
4 | # | ||
5 | # SYNOPSIS | ||
6 | # | ||
7 | # AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) | ||
8 | # | ||
9 | # DESCRIPTION | ||
10 | # | ||
11 | # Check for baseline language coverage in the compiler for the C++11 | ||
12 | # standard; if necessary, add switches to CXXFLAGS to enable support. | ||
13 | # | ||
14 | # The first argument, if specified, indicates whether you insist on an | ||
15 | # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. | ||
16 | # -std=c++11). If neither is specified, you get whatever works, with | ||
17 | # preference for an extended mode. | ||
18 | # | ||
19 | # The second argument, if specified 'mandatory' or if left unspecified, | ||
20 | # indicates that baseline C++11 support is required and that the macro | ||
21 | # should error out if no mode with that support is found. If specified | ||
22 | # 'optional', then configuration proceeds regardless, after defining | ||
23 | # HAVE_CXX11 if and only if a supporting mode is found. | ||
24 | # | ||
25 | # LICENSE | ||
26 | # | ||
27 | # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> | ||
28 | # Copyright (c) 2012 Zack Weinberg <zackw@panix.com> | ||
29 | # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> | ||
30 | # | ||
31 | # Copying and distribution of this file, with or without modification, are | ||
32 | # permitted in any medium without royalty provided the copyright notice | ||
33 | # and this notice are preserved. This file is offered as-is, without any | ||
34 | # warranty. | ||
35 | |||
36 | #serial 3 | ||
37 | |||
38 | m4_define([_EFL_CXX_COMPILE_STDCXX_11_testbody], [ | ||
39 | template <typename T> | ||
40 | struct check | ||
41 | { | ||
42 | static_assert(sizeof(int) <= sizeof(T), "not big enough"); | ||
43 | }; | ||
44 | |||
45 | typedef check<check<bool>> right_angle_brackets; | ||
46 | |||
47 | int a; | ||
48 | decltype(a) b; | ||
49 | |||
50 | typedef check<int> check_type; | ||
51 | check_type c; | ||
52 | check_type&& cr = static_cast<check_type&&>(c); | ||
53 | |||
54 | struct A { A(int); }; | ||
55 | struct B : A { using A::A; }; // inheriting constructors | ||
56 | |||
57 | auto d = a; | ||
58 | ]) | ||
59 | |||
60 | AC_DEFUN([EFL_CXX_COMPILE_STDCXX_11], [dnl | ||
61 | m4_if([$1], [], [], | ||
62 | [$1], [ext], [], | ||
63 | [$1], [noext], [], | ||
64 | [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl | ||
65 | m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], | ||
66 | [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], | ||
67 | [$2], [optional], [ax_cxx_compile_cxx11_required=false], | ||
68 | [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl | ||
69 | AC_LANG_PUSH([C++])dnl | ||
70 | ac_success=no | ||
71 | AC_CACHE_CHECK(whether $CXX supports C++11 features by default, | ||
72 | ax_cv_cxx_compile_cxx11, | ||
73 | [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_EFL_CXX_COMPILE_STDCXX_11_testbody])], | ||
74 | [ax_cv_cxx_compile_cxx11=yes], | ||
75 | [ax_cv_cxx_compile_cxx11=no])]) | ||
76 | if test x$ax_cv_cxx_compile_cxx11 = xyes; then | ||
77 | ac_success=yes | ||
78 | fi | ||
79 | |||
80 | m4_if([$1], [noext], [], [dnl | ||
81 | if test x$ac_success = xno; then | ||
82 | for switch in -std=gnu++11; do | ||
83 | cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) | ||
84 | AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, | ||
85 | $cachevar, | ||
86 | [ac_save_CXXFLAGS="$CXXFLAGS" | ||
87 | CXXFLAGS="$CXXFLAGS $switch" | ||
88 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([_EFL_CXX_COMPILE_STDCXX_11_testbody])], | ||
89 | [eval $cachevar=yes], | ||
90 | [eval $cachevar=no]) | ||
91 | CXXFLAGS="$ac_save_CXXFLAGS"]) | ||
92 | if eval test x\$$cachevar = xyes; then | ||
93 | CXXFLAGS="$CXXFLAGS $switch" | ||
94 | ac_success=yes | ||
95 | break | ||
96 | fi | ||
97 | done | ||
98 | fi]) | ||
99 | |||
100 | m4_if([$1], [ext], [], [dnl | ||
101 | if test x$ac_success = xno; then | ||
102 | for switch in -std=c++11; do | ||
103 | cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) | ||
104 | AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, | ||
105 | $cachevar, | ||
106 | [ac_save_CXXFLAGS="$CXXFLAGS" | ||
107 | CXXFLAGS="$CXXFLAGS $switch" | ||
108 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([_EFL_CXX_COMPILE_STDCXX_11_testbody])], | ||
109 | [eval $cachevar=yes], | ||
110 | [eval $cachevar=no]) | ||
111 | CXXFLAGS="$ac_save_CXXFLAGS"]) | ||
112 | if eval test x\$$cachevar = xyes; then | ||
113 | CXXFLAGS="$CXXFLAGS $switch" | ||
114 | ac_success=yes | ||
115 | break | ||
116 | fi | ||
117 | done | ||
118 | fi]) | ||
119 | AC_LANG_POP([C++]) | ||
120 | if test x$ax_cxx_compile_cxx11_required = xtrue; then | ||
121 | if test x$ac_success = xno; then | ||
122 | AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) | ||
123 | fi | ||
124 | else | ||
125 | if test x$ac_success = xno; then | ||
126 | HAVE_CXX11=0 | ||
127 | AC_MSG_NOTICE([No compiler with C++11 support was found]) | ||
128 | else | ||
129 | HAVE_CXX11=1 | ||
130 | AC_DEFINE(HAVE_CXX11,1, | ||
131 | [define if the compiler supports basic C++11 syntax]) | ||
132 | fi | ||
133 | |||
134 | AC_SUBST(HAVE_CXX11) | ||
135 | fi | ||
136 | ]) | ||