[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/05: build: Make sure $CXX supports C++11.
From: |
Ludovic Courtès |
Subject: |
03/05: build: Make sure $CXX supports C++11. |
Date: |
Tue, 19 May 2015 14:10:19 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit 368d08f74744ed5d5ef5ef747e86bddbfaa47312
Author: Ludovic Courtès <address@hidden>
Date: Tue May 19 09:09:47 2015 +0200
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.
---
config-daemon.ac | 3 +++
doc/guix.texi | 7 ++++---
m4/guix.m4 | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/config-daemon.ac b/config-daemon.ac
index fb80c75..a6cf29c 100644
--- a/config-daemon.ac
+++ b/config-daemon.ac
@@ -5,9 +5,12 @@ AC_MSG_RESULT([$guix_build_daemon])
dnl C++ environment. This macro must be used unconditionnaly.
AC_PROG_CXX
+AC_LANG([C++])
if test "x$guix_build_daemon" = "xyes"; then
+ GUIX_ASSERT_CXX11
+
AC_PROG_RANLIB
AC_CONFIG_HEADER([nix/config.h])
diff --git a/doc/guix.texi b/doc/guix.texi
index 6964a4e..91c86dc 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -368,9 +368,10 @@ Unless @code{--disable-daemon} was passed to
@command{configure}, the
following packages are also needed:
@itemize
address@hidden @url{http://sqlite.org, SQLite 3}
address@hidden @url{http://www.bzip.org, libbz2}
address@hidden @url{http://gcc.gnu.org, GCC's g++}
address@hidden @url{http://sqlite.org, SQLite 3};
address@hidden @url{http://www.bzip.org, libbz2};
address@hidden @url{http://gcc.gnu.org, GCC's g++}, with support for the
+C++11 standard.
@end itemize
When a working installation of @url{http://nixos.org/nix/, the Nix package
diff --git a/m4/guix.m4 b/m4/guix.m4
index 445ce85..fa5a402 100644
--- a/m4/guix.m4
+++ b/m4/guix.m4
@@ -218,3 +218,42 @@ AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [
AC_MSG_ERROR([store directory '$storedir' would lead to overly long
hash-bang lines])
fi
])
+
+dnl GUIX_CHECK_CXX11
+dnl
+dnl Check whether the C++ compiler can compile a typical C++11 program.
+AC_DEFUN([GUIX_CHECK_CXX11], [
+ AC_REQUIRE([AC_PROG_CXX])
+ AC_CACHE_CHECK([whether $CXX supports C++11],
+ [ac_cv_guix_cxx11_support],
+ [save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="-std=c++11 $CXXFLAGS"
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ #include <functional>
+
+ std::function<int(int)>
+ return_plus_lambda (int x)
+ {
+ auto result = [[&]](int y) {
+ return x + y;
+ };
+
+ return result;
+ }
+ ])],
+ [ac_cv_guix_cxx11_support=yes],
+ [ac_cv_guix_cxx11_support=no])
+ CXXFLAGS="$save_CXXFLAGS"
+ ])
+])
+
+dnl GUIX_ASSERT_CXX11
+dnl
+dnl Error out if the C++ compiler cannot compile C++11 code.
+AC_DEFUN([GUIX_ASSERT_CXX11], [
+ GUIX_CHECK_CXX11
+ if test "x$ac_cv_guix_cxx11_support" != "xyes"; then
+ AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard])
+ fi
+])