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 ...@@ -26,14 +26,15 @@ AC_PROG_CXX
AC_LANG([C++]) AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11([noext]) AX_CXX_COMPILE_STDCXX_11([noext])
ACX_PTHREAD ACX_PTHREAD
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
# We need gtest to use the same CXXFLAGS, especially -std and -stdlib, so export them before # AX_CXX_COMPILE_STDCXX_11 may have modified CXX, and we need gtest to use these modifications as
# configuring gtest. # well (especially -stdlib).
export CXXFLAGS export CXX
AC_CONFIG_SUBDIRS([gtest]) AC_CONFIG_SUBDIRS([gtest])
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
......
# ============================================================================ # ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# Additionally modified to detect -stdlib by Kenton Varda.
# ============================================================================ # ============================================================================
# #
# SYNOPSIS # SYNOPSIS
...@@ -21,6 +22,13 @@ ...@@ -21,6 +22,13 @@
# on Mac OSX 10.8, which ships with a very old libstdc++ but a relatively # on Mac OSX 10.8, which ships with a very old libstdc++ but a relatively
# new libc++. # 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 # LICENSE
# #
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
...@@ -80,14 +88,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl ...@@ -80,14 +88,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar, $cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS" [ac_save_CXX="$CXX"
CXXFLAGS="$CXXFLAGS $switch" CXX="$CXX $switch"
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"]) CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch" CXX="$CXX $switch"
ac_success=yes ac_success=yes
break break
fi fi
...@@ -100,14 +108,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl ...@@ -100,14 +108,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar, $cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS" [ac_save_CXX="$CXX"
CXXFLAGS="$CXXFLAGS $switch" CXX="$CXX $switch"
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"]) CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch" CXX="$CXX $switch"
ac_success=yes ac_success=yes
break break
fi fi
...@@ -130,14 +138,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl ...@@ -130,14 +138,14 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
# Try with -stdlib=libc++ # Try with -stdlib=libc++
AC_CACHE_CHECK(whether $CXX supports C++11 library features with -stdlib=libc++, AC_CACHE_CHECK(whether $CXX supports C++11 library features with -stdlib=libc++,
ax_cv_cxx_compile_cxx11_lib_libcxx, ax_cv_cxx_compile_cxx11_lib_libcxx,
[ac_save_CXXFLAGS="$CXXFLAGS" [ac_save_CXX="$CXX"
CXXFLAGS="$CXXFLAGS -stdlib=libc++" CXX="$CXX -stdlib=libc++"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody_lib])], 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=yes],
[eval ax_cv_cxx_compile_cxx11_lib_libcxx=no]) [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 if eval test x$ax_cv_cxx_compile_cxx11_lib_libcxx = xyes; then
CXXFLAGS="$CXXFLAGS -stdlib=libc++" CXX="$CXX -stdlib=libc++"
ac_success=yes ac_success=yes
break break
fi 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