Commit db44f4f5 authored by Kenton Varda's avatar Kenton Varda

Work around libtool dropping -stdlib from CXXFLAGS when linking by putting it in CXX instead.

parent 451223a3
......@@ -26,14 +26,15 @@ AC_PROG_CXX
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11([noext])
ACX_PTHREAD
AC_PROG_LIBTOOL
LIBS="$PTHREAD_LIBS $LIBS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
# We need gtest to use the same CXXFLAGS, especially -std and -stdlib, so export them before
# configuring gtest.
export CXXFLAGS
# AX_CXX_COMPILE_STDCXX_11 may have modified CXX, and we need gtest to use these modifications as
# well (especially -stdlib).
export CXX
AC_CONFIG_SUBDIRS([gtest])
AC_CONFIG_FILES([Makefile])
......
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# Additionally modified to detect -stdlib by Kenton Varda.
# ============================================================================
#
# SYNOPSIS
......@@ -21,6 +22,13 @@
# on Mac OSX 10.8, which ships with a very old libstdc++ but a relatively
# new libc++.
#
# Both flags are actually added to CXX rather than CXXFLAGS to work around
# a bug in libtool: -stdlib is stripped from CXXFLAGS when linking dynamic
# libraries because it is not recognized. A patch was committed to mainline
# libtool in February 2012 but as of June 2013 there has not yet been a
# release containing this patch.
# http://git.savannah.gnu.org/gitweb/?p=libtool.git;a=commit;h=c0c49f289f22ae670066657c60905986da3b555f
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
......@@ -80,14 +88,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
CXX="$CXX $switch"
ac_success=yes
break
fi
......@@ -100,14 +108,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
CXX="$CXX $switch"
ac_success=yes
break
fi
......@@ -130,14 +138,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
# Try with -stdlib=libc++
AC_CACHE_CHECK(whether $CXX supports C++11 library features with -stdlib=libc++,
ax_cv_cxx_compile_cxx11_lib_libcxx,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
[ac_save_CXX="$CXX"
CXX="$CXX -stdlib=libc++"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody_lib])],
[eval ax_cv_cxx_compile_cxx11_lib_libcxx=yes],
[eval ax_cv_cxx_compile_cxx11_lib_libcxx=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
CXX="$ac_save_CXX"])
if eval test x$ax_cv_cxx_compile_cxx11_lib_libcxx = xyes; then
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
CXX="$CXX -stdlib=libc++"
ac_success=yes
break
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment