From: Gunnar Beutner Date: Sat, 26 May 2012 12:40:15 +0000 (+0200) Subject: Use ax_cxx_compile_stdcxx_0x.m4 to detect C++0x support. X-Git-Tag: v0.0.1~486 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e3e1af32b01a873d45a8923e4bcd46c9a67d835;p=icinga2 Use ax_cxx_compile_stdcxx_0x.m4 to detect C++0x support. --- diff --git a/base/i2-base.h b/base/i2-base.h index 683ce3bda..c9795adb6 100644 --- a/base/i2-base.h +++ b/base/i2-base.h @@ -53,7 +53,7 @@ */ #ifdef _MSC_VER -# define HAVE_CXX11 +# define HAVE_STDCXX_0X # pragma warning(disable:4251) # define _CRT_SECURE_NO_DEPRECATE # define _CRT_SECURE_NO_WARNINGS @@ -94,13 +94,13 @@ using namespace std; using std::exception; -#ifdef HAVE_CXX11 +#ifdef HAVE_STDCXX_0X # include # include using namespace std::placeholders; -#else /* HAVE_CXX11 */ +#else /* HAVE_STDCXX_0X */ # ifdef HAVE_BOOST # include # include @@ -118,7 +118,7 @@ using namespace std::tr1; using namespace std::tr1::placeholders; #endif /* HAVE_BOOST */ -#endif /* HAVE_CXX11 */ +#endif /* HAVE_STDCXX_0X */ #if defined(__APPLE__) && defined(__MACH__) # pragma GCC diagnostic ignored "-Wdeprecated-declarations" diff --git a/config/ax_cxx_compile_stdcxx_0x.m4 b/config/ax_cxx_compile_stdcxx_0x.m4 new file mode 100644 index 000000000..1390ee581 --- /dev/null +++ b/config/ax_cxx_compile_stdcxx_0x.m4 @@ -0,0 +1,113 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_0x.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_0X +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++0x +# standard. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([AC_CXX_COMPILE_STDCXX_0X], [AX_CXX_COMPILE_STDCXX_0X]) +AC_DEFUN([AX_CXX_COMPILE_STDCXX_0X], [ + AC_CACHE_CHECK(if g++ supports C++0x features without additional flags, + ax_cv_cxx_compile_cxx0x_native, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c);],, + ax_cv_cxx_compile_cxx0x_native=yes, ax_cv_cxx_compile_cxx0x_native=no) + AC_LANG_RESTORE + ]) + + AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x, + ax_cv_cxx_compile_cxx0x_cxx, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=c++0x" + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c);],, + ax_cv_cxx_compile_cxx0x_cxx=yes, ax_cv_cxx_compile_cxx0x_cxx=no) + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE + ]) + + AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x, + ax_cv_cxx_compile_cxx0x_gxx, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=gnu++0x" + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c);],, + ax_cv_cxx_compile_cxx0x_gxx=yes, ax_cv_cxx_compile_cxx0x_gxx=no) + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE + ]) + + if test "$ax_cv_cxx_compile_cxx0x_native" = yes || + test "$ax_cv_cxx_compile_cxx0x_cxx" = yes || + test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then + AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ]) + fi + + if test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then + CXXFLAGS="$CXXFLAGS -std=gnu++0x" + elif test "$ax_cv_cxx_compile_cxx0x_cxx" = yes; then + CXXFLAGS="$CXXFLAGS -std=c++0x" + fi +]) diff --git a/configure.ac b/configure.ac index 03a737b57..3e0595dd8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,21 @@ -dnl Process this file with autoconf to produce a configure script. -dnl Created by Anjuta application wizard. +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ AC_INIT([icinga], [2.0]) AC_LANG(C++) @@ -31,6 +47,7 @@ AC_PROG_INSTALL AC_PROG_CC AC_PROG_CXX AC_PROG_LIBTOOL +AX_CXX_COMPILE_STDCXX_0X AX_CXX_GCC_ABI_DEMANGLE AX_PTHREAD @@ -41,16 +58,10 @@ AC_CHECK_LIB(m, floor) AC_CHECK_LIB(pthread, pthread_create) AC_CHECK_LIB(socket, getsockname) -AX_CHECK_COMPILE_FLAG([-std=c++0x], [have_cxx11_support=yes]) - -if test "$have_cxx11_support" = "yes"; then - CXXFLAGS="$CXXFLAGS -std=c++0x" - AC_DEFINE(HAVE_CXX11, 1, - [define if the compiler supports C++11]) -fi - - -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [])], [], [AC_MSG_ERROR([You need the OpenSSL headers and libraries in order to build this application]) ]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], [])], + [], + [AC_MSG_ERROR([You need the OpenSSL headers and libraries in order to build this application]) ]) AC_OUTPUT([