mirror of https://github.com/aria2/aria2
Make AX_CXX_COMPILE_STDCXX_11 test for -stdlib=libc++ via std::shared_ptr
The clang shipped with OSX XCode and clangs not build enabling libcpp, will default to the libstdc++ headers and lib installed on the system. In the OSX case, that libstdc++ is the one bundles with gcc-4.2, which is far too old to provide all required C++11 types, such as std::shared_ptr. Hence, the C++11 check should try to compile a program with a C++11 type and try -stdlib=libc++ if the default lib fails to compile said program.pull/119/head
parent
b888088dc3
commit
22e414dbb0
|
@ -22,11 +22,16 @@
|
||||||
# 'optional', then configuration proceeds regardless, after defining
|
# 'optional', then configuration proceeds regardless, after defining
|
||||||
# HAVE_CXX11 if and only if a supporting mode is found.
|
# HAVE_CXX11 if and only if a supporting mode is found.
|
||||||
#
|
#
|
||||||
|
# This version of AX_CXX_COMPILE_STDCXX_11 will also check if specifying
|
||||||
|
# `-stdlib=libc++`` is required, as it is on current OSX systems using
|
||||||
|
# a clang which defaults to an old libstdc++.
|
||||||
|
#
|
||||||
# LICENSE
|
# LICENSE
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||||
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||||
|
# Copyright (c) 2013 Nils Maier <maierman@web.de>
|
||||||
#
|
#
|
||||||
# Copying and distribution of this file, with or without modification, are
|
# Copying and distribution of this file, with or without modification, are
|
||||||
# permitted in any medium without royalty provided the copyright notice
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
@ -34,8 +39,11 @@
|
||||||
# warranty.
|
# warranty.
|
||||||
|
|
||||||
#serial 3
|
#serial 3
|
||||||
|
#modified to check fo -stdlib=libc++ (required on OSX)
|
||||||
|
|
||||||
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct check
|
struct check
|
||||||
{
|
{
|
||||||
|
@ -52,6 +60,9 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
||||||
check_type&& cr = static_cast<check_type&&>(c);
|
check_type&& cr = static_cast<check_type&&>(c);
|
||||||
|
|
||||||
auto d = a;
|
auto d = a;
|
||||||
|
|
||||||
|
// Check std::shared_ptr is available, which might require -stdlib=libc++.
|
||||||
|
std::shared_ptr<check_type> ptr;
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
|
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
|
||||||
|
@ -77,41 +88,45 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
|
||||||
m4_if([$1], [noext], [], [dnl
|
m4_if([$1], [noext], [], [dnl
|
||||||
if test x$ac_success = xno; then
|
if test x$ac_success = xno; then
|
||||||
for switch in -std=gnu++11 -std=gnu++0x; do
|
for switch in -std=gnu++11 -std=gnu++0x; do
|
||||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
for lib in "" -stdlib=libc++; do
|
||||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch$lib])
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch $lib,
|
||||||
$cachevar,
|
$cachevar,
|
||||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||||
CXXFLAGS="$CXXFLAGS $switch"
|
CXXFLAGS="$CXXFLAGS $switch $lib"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||||
[eval $cachevar=yes],
|
[eval $cachevar=yes],
|
||||||
[eval $cachevar=no])
|
[eval $cachevar=no])
|
||||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||||
if eval test x\$$cachevar = xyes; then
|
if eval test x\$$cachevar = xyes; then
|
||||||
CXXFLAGS="$CXXFLAGS $switch"
|
CXXFLAGS="$CXXFLAGS $switch $lib"
|
||||||
ac_success=yes
|
ac_success=yes
|
||||||
break
|
break 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
done
|
||||||
fi])
|
fi])
|
||||||
|
|
||||||
m4_if([$1], [ext], [], [dnl
|
m4_if([$1], [ext], [], [dnl
|
||||||
if test x$ac_success = xno; then
|
if test x$ac_success = xno; then
|
||||||
for switch in -std=c++11 -std=c++0x; do
|
for switch in -std=c++11 -std=c++0x; do
|
||||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
for lib in "" -stdlib=libc++; do
|
||||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch$lib])
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch $lib,
|
||||||
$cachevar,
|
$cachevar,
|
||||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||||
CXXFLAGS="$CXXFLAGS $switch"
|
CXXFLAGS="$CXXFLAGS $switch $lib"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||||
[eval $cachevar=yes],
|
[eval $cachevar=yes],
|
||||||
[eval $cachevar=no])
|
[eval $cachevar=no])
|
||||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||||
if eval test x\$$cachevar = xyes; then
|
if eval test x\$$cachevar = xyes; then
|
||||||
CXXFLAGS="$CXXFLAGS $switch"
|
CXXFLAGS="$CXXFLAGS $switch $lib"
|
||||||
ac_success=yes
|
ac_success=yes
|
||||||
break
|
break 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
done
|
||||||
fi])
|
fi])
|
||||||
AC_LANG_POP([C++])
|
AC_LANG_POP([C++])
|
||||||
if test x$ax_cxx_compile_cxx11_required = xtrue; then
|
if test x$ax_cxx_compile_cxx11_required = xtrue; then
|
||||||
|
|
Loading…
Reference in New Issue