Use ax_cxx_compile_stdcxx_0x.m4 to detect C++0x support.

This commit is contained in:
Gunnar Beutner 2012-05-26 14:40:15 +02:00
parent 7f33b2caae
commit 2e3e1af32b
3 changed files with 140 additions and 16 deletions

View File

@ -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 <memory>
# include <functional>
using namespace std::placeholders;
#else /* HAVE_CXX11 */
#else /* HAVE_STDCXX_0X */
# ifdef HAVE_BOOST
# include <boost/smart_ptr.hpp>
# include <boost/make_shared.hpp>
@ -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"

View File

@ -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 <bkoz@redhat.com>
#
# 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 <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(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 <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(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 <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(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
])

View File

@ -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 <openssl/ssl.h>]], [])], [], [AC_MSG_ERROR([You need the OpenSSL headers and libraries in order to build this application]) ])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [])],
[],
[AC_MSG_ERROR([You need the OpenSSL headers and libraries in order to build this application]) ])
AC_OUTPUT([