summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-05-19 09:09:47 +0200
committerLudovic Courtès <ludo@gnu.org>2015-05-19 16:09:58 +0200
commit368d08f74744ed5d5ef5ef747e86bddbfaa47312 (patch)
tree66e45685184aa5e086d132541d9841e63d2abf2d /m4
parent2bb04905f86f9c3f1d27557fbff8cbdc776560a3 (diff)
build: Make sure $CXX supports C++11.
* m4/guix.m4 (GUIX_CHECK_CXX11, GUIX_ASSERT_CXX11): New macros. * config-daemon.ac: Use 'AC_LANG([C++])' and 'GUIX_ASSERT_CXX11'.C * doc/guix.texi (Requirements): Mention C++11 support.
Diffstat (limited to 'm4')
-rw-r--r--m4/guix.m439
1 files changed, 39 insertions, 0 deletions
diff --git a/m4/guix.m4 b/m4/guix.m4
index 445ce857dd6..fa5a4023ba0 100644
--- a/m4/guix.m4
+++ b/m4/guix.m4
@@ -218,3 +218,42 @@ AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [
218 AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines]) 218 AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines])
219 fi 219 fi
220]) 220])
221
222dnl GUIX_CHECK_CXX11
223dnl
224dnl Check whether the C++ compiler can compile a typical C++11 program.
225AC_DEFUN([GUIX_CHECK_CXX11], [
226 AC_REQUIRE([AC_PROG_CXX])
227 AC_CACHE_CHECK([whether $CXX supports C++11],
228 [ac_cv_guix_cxx11_support],
229 [save_CXXFLAGS="$CXXFLAGS"
230 CXXFLAGS="-std=c++11 $CXXFLAGS"
231 AC_COMPILE_IFELSE([
232 AC_LANG_SOURCE([
233 #include <functional>
234
235 std::function<int(int)>
236 return_plus_lambda (int x)
237 {
238 auto result = [[&]](int y) {
239 return x + y;
240 };
241
242 return result;
243 }
244 ])],
245 [ac_cv_guix_cxx11_support=yes],
246 [ac_cv_guix_cxx11_support=no])
247 CXXFLAGS="$save_CXXFLAGS"
248 ])
249])
250
251dnl GUIX_ASSERT_CXX11
252dnl
253dnl Error out if the C++ compiler cannot compile C++11 code.
254AC_DEFUN([GUIX_ASSERT_CXX11], [
255 GUIX_CHECK_CXX11
256 if test "x$ac_cv_guix_cxx11_support" != "xyes"; then
257 AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard])
258 fi
259])