From d337ceb76d898935560dc264cf2ad36b17017db7 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 26 Oct 2015 09:41:10 +0100 Subject: Use the CXX compiler only if it can create dynamic and static programs * configure.ac (CXX): Clear the variable if the C++ toolchain does not support static linking. * configure: Regenerate. --- configure.ac | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index e502aa5db2..3c7f6c0096 100644 --- a/configure.ac +++ b/configure.ac @@ -57,9 +57,26 @@ AC_PROG_CXX # It's useless to us if it can't link programs (e.g. missing -lstdc++). AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl AC_LANG_PUSH([C++]) +# Default, dynamic case. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [libc_cv_cxx_link_ok=yes], [libc_cv_cxx_link_ok=no]) +# Static case. +old_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -static" +AC_LINK_IFELSE([AC_LANG_SOURCE([ +#include + +int +main() +{ + std::cout << "Hello, world!"; + return 0; +} +])], + [], + [libc_cv_cxx_link_ok=no]) +LDFLAGS="$old_LDFLAGS" AC_LANG_POP([C++])]) AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=]) -- cgit 1.4.1