diff --git a/build/autoconf/toolchain.m4 b/build/autoconf/toolchain.m4 index 7b5c6285a23b..c06c7fea4a16 100644 --- a/build/autoconf/toolchain.m4 +++ b/build/autoconf/toolchain.m4 @@ -223,14 +223,37 @@ if test -n "$CROSS_COMPILE"; then dnl When cross compile, we have no variable telling us what the host compiler is. Figure it out. cat > conftest.C </dev/null | grep COMPILER) +EOF +read dummy host_cxxcompiler HOST_CXX_VERSION </dev/null | grep COMPILER) +EOF rm conftest.C + if test "$host_compiler" != "$host_cxxcompiler"; then + AC_MSG_ERROR([Your C and C++ host compilers are different. You need to use the same compiler.]) + fi if test -n "$host_compiler"; then + if test "$host_compiler" = "GCC" ; then + changequote(<<,>>) + HOST_GCC_VERSION_FULL="$HOST_CXX_VERSION" + HOST_GCC_VERSION=`echo "$HOST_GCC_VERSION_FULL" | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/<<$>>1/;'` + + HOST_GCC_MAJOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>1 }'` + HOST_GCC_MINOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>2 }'` + changequote([,]) + + if test "$HOST_GCC_MAJOR_VERSION" -eq 4 -a "$HOST_GCC_MINOR_VERSION" -lt 6 || + test "$HOST_GCC_MAJOR_VERSION" -lt 4; then + AC_MSG_ERROR([Only GCC 4.6 or newer supported for host compiler]) + fi + fi + HOST_CXXFLAGS="$HOST_CXXFLAGS -std=gnu++0x" _SAVE_CXXFLAGS="$CXXFLAGS"