summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavio Sena <savio.sena@acm.org>2014-08-23 00:19:23 -0300
committerSavio Sena <savio@expertisesolutions.com.br>2014-09-16 19:35:17 -0300
commit1a3b5e8d7d43c5736f2ac7fb45d1d2daf69e4bd5 (patch)
tree4b65ef70ad6bf54433bf3a353b9be461392361a4
parent578c0b4318a3a557a94098bf4bde0375012ae761 (diff)
autotools: Introduce C++11 requirement.
-rw-r--r--configure.ac9
-rw-r--r--m4/efl_stdcxx_11.m4136
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
36LT_PROG_RC 36LT_PROG_RC
37 37
38### Check for C++11
38 39
40EFL_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.
55EFL_ENABLE_EO_API_SUPPORT 57EFL_ENABLE_EO_API_SUPPORT
56EFL_ENABLE_BETA_API_SUPPORT 58EFL_ENABLE_BETA_API_SUPPORT
57 59
60# EFL++ dependencies
61
62PKG_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])
92AC_MSG_RESULT([${have_cxx_flags}]) 97AC_MSG_RESULT([${have_cxx_flags}])
93CXXFLAGS="${CXXFLAGS_save}" 98CXXFLAGS="${CXXFLAGS_save}"
94if test "x${have_cxx_flags}" = "xyes" ; then 99if test "x${have_cxx_flags}" = "xyes" ; then
95 EXPEDITE_CXXFLAGS="-fno-rtti -fno-exceptions" 100 EXPEDITE_CXXFLAGS="-fno-rtti -fno-exceptions -std=c++11"
96fi 101fi
102CXXFLAGS="{CXXFLAGS} -std=c++11"
103
97AC_LANG_POP([C++]) 104AC_LANG_POP([C++])
98AC_SUBST(EXPEDITE_CXXFLAGS) 105AC_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
38m4_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
60AC_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])