michael@0: dnl This Source Code Form is subject to the terms of the Mozilla Public michael@0: dnl License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: AC_DEFUN([MOZ_TOOL_VARIABLES], michael@0: [ michael@0: GNU_AS= michael@0: GNU_LD= michael@0: GNU_CC= michael@0: GNU_CXX= michael@0: CC_VERSION='N/A' michael@0: CXX_VERSION='N/A' michael@0: if test "$GCC" = "yes"; then michael@0: GNU_CC=1 michael@0: CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` michael@0: fi michael@0: if test "$GXX" = "yes"; then michael@0: GNU_CXX=1 michael@0: CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'` michael@0: changequote(<<,>>) michael@0: GCC_VERSION_FULL=`echo "$CXX_VERSION" | $PERL -pe 's/^.*gcc version ([^ ]*).*/<<$>>1/'` michael@0: GCC_VERSION=`echo "$GCC_VERSION_FULL" | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/<<$>>1/;'` michael@0: michael@0: GCC_MAJOR_VERSION=`echo ${GCC_VERSION} | $AWK -F\. '{ print <<$>>1 }'` michael@0: GCC_MINOR_VERSION=`echo ${GCC_VERSION} | $AWK -F\. '{ print <<$>>2 }'` michael@0: changequote([,]) michael@0: fi michael@0: michael@0: if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then michael@0: GNU_AS=1 michael@0: fi michael@0: rm -f conftest.out michael@0: if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then michael@0: GNU_LD=1 michael@0: fi michael@0: if test "$GNU_CC"; then michael@0: if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then michael@0: GCC_USE_GNU_LD=1 michael@0: fi michael@0: fi michael@0: michael@0: INTEL_CC= michael@0: INTEL_CXX= michael@0: if test "$GCC" = yes; then michael@0: if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then michael@0: INTEL_CC=1 michael@0: fi michael@0: fi michael@0: michael@0: if test "$GXX" = yes; then michael@0: if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then michael@0: INTEL_CXX=1 michael@0: fi michael@0: fi michael@0: michael@0: CLANG_CC= michael@0: CLANG_CXX= michael@0: if test "`$CC -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then michael@0: CLANG_CC=1 michael@0: fi michael@0: michael@0: if test "`$CXX -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then michael@0: CLANG_CXX=1 michael@0: fi michael@0: AC_SUBST(CLANG_CXX) michael@0: ]) michael@0: michael@0: AC_DEFUN([MOZ_CROSS_COMPILER], michael@0: [ michael@0: echo "cross compiling from $host to $target" michael@0: michael@0: _SAVE_CC="$CC" michael@0: _SAVE_CFLAGS="$CFLAGS" michael@0: _SAVE_LDFLAGS="$LDFLAGS" michael@0: michael@0: AC_MSG_CHECKING([for host c compiler]) michael@0: AC_CHECK_PROGS(HOST_CC, cc gcc clang cl, "") michael@0: if test -z "$HOST_CC"; then michael@0: AC_MSG_ERROR([no acceptable c compiler found in \$PATH]) michael@0: fi michael@0: AC_MSG_RESULT([$HOST_CC]) michael@0: AC_MSG_CHECKING([for host c++ compiler]) michael@0: AC_CHECK_PROGS(HOST_CXX, c++ g++ clang++ cl, "") michael@0: if test -z "$HOST_CXX"; then michael@0: AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH]) michael@0: fi michael@0: AC_MSG_RESULT([$HOST_CXX]) michael@0: michael@0: if test -z "$HOST_CFLAGS"; then michael@0: HOST_CFLAGS="$CFLAGS" michael@0: fi michael@0: if test -z "$HOST_CXXFLAGS"; then michael@0: HOST_CXXFLAGS="$CXXFLAGS" michael@0: fi michael@0: if test -z "$HOST_LDFLAGS"; then michael@0: HOST_LDFLAGS="$LDFLAGS" michael@0: fi michael@0: if test -z "$HOST_AR_FLAGS"; then michael@0: HOST_AR_FLAGS="$AR_FLAGS" michael@0: fi michael@0: AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :) michael@0: AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :) michael@0: CC="$HOST_CC" michael@0: CFLAGS="$HOST_CFLAGS" michael@0: LDFLAGS="$HOST_LDFLAGS" michael@0: michael@0: AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works]) michael@0: AC_TRY_COMPILE([], [return(0);], michael@0: [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])], michael@0: AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) ) michael@0: michael@0: CC="$HOST_CXX" michael@0: CFLAGS="$HOST_CXXFLAGS" michael@0: AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works]) michael@0: AC_TRY_COMPILE([], [return(0);], michael@0: [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])], michael@0: AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) ) michael@0: michael@0: CC=$_SAVE_CC michael@0: CFLAGS=$_SAVE_CFLAGS michael@0: LDFLAGS=$_SAVE_LDFLAGS michael@0: michael@0: AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", :) michael@0: unset ac_cv_prog_CC michael@0: AC_PROG_CC michael@0: AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", :) michael@0: unset ac_cv_prog_CXX michael@0: AC_PROG_CXX michael@0: michael@0: AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", :) michael@0: AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", :) michael@0: MOZ_PATH_PROGS(AS, "${target_alias}-as" "${target}-as", :) michael@0: AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :) michael@0: AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", :) michael@0: AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :) michael@0: AC_DEFINE(CROSS_COMPILE) michael@0: CROSS_COMPILE=1 michael@0: michael@0: dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will michael@0: dnl dnl have erroneously been set to "no", because the x86 build host is michael@0: dnl dnl able to run ppc code in a translated environment, making a cross michael@0: dnl dnl compiler appear native. So we override that here. michael@0: cross_compiling=yes michael@0: ]) michael@0: michael@0: AC_DEFUN([MOZ_CXX11], michael@0: [ michael@0: dnl Check whether gcc's c++0x mode works michael@0: dnl Updates to the test below should be duplicated further below for the michael@0: dnl cross-compiling case. michael@0: AC_LANG_CPLUSPLUS michael@0: if test "$GNU_CXX"; then michael@0: CXXFLAGS="$CXXFLAGS -std=gnu++0x" michael@0: _ADDED_CXXFLAGS="-std=gnu++0x" michael@0: michael@0: AC_CACHE_CHECK(for gcc c++0x headers bug without rtti, michael@0: ac_cv_cxx0x_headers_bug, michael@0: [AC_TRY_COMPILE([#include ], [], michael@0: ac_cv_cxx0x_headers_bug="no", michael@0: ac_cv_cxx0x_headers_bug="yes")]) michael@0: michael@0: if test "$CLANG_CXX" -a "$ac_cv_cxx0x_headers_bug" = "yes"; then michael@0: CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers" michael@0: _ADDED_CXXFLAGS="$_ADDED_CXXFLAGS -I$_topsrcdir/build/unix/headers" michael@0: AC_CACHE_CHECK(whether workaround for gcc c++0x headers conflict with clang works, michael@0: ac_cv_cxx0x_clang_workaround, michael@0: [AC_TRY_COMPILE([#include ], [], michael@0: ac_cv_cxx0x_clang_workaround="yes", michael@0: ac_cv_cxx0x_clang_workaround="no")]) michael@0: michael@0: if test "ac_cv_cxx0x_clang_workaround" = "no"; then michael@0: AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain]) michael@0: fi michael@0: elif test "$ac_cv_cxx0x_headers_bug" = "yes"; then michael@0: AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain]) michael@0: fi michael@0: fi michael@0: if test -n "$CROSS_COMPILE"; then michael@0: dnl When cross compile, we have no variable telling us what the host compiler is. Figure it out. michael@0: cat > conftest.C <], [], michael@0: ac_cv_host_cxx0x_headers_bug="no", michael@0: ac_cv_host_cxx0x_headers_bug="yes")]) michael@0: michael@0: if test "$host_compiler" = CLANG -a "$ac_cv_host_cxx0x_headers_bug" = "yes"; then michael@0: CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers" michael@0: AC_CACHE_CHECK(whether workaround for host gcc c++0x headers conflict with host clang works, michael@0: ac_cv_host_cxx0x_clang_workaround, michael@0: [AC_TRY_COMPILE([#include ], [], michael@0: ac_cv_host_cxx0x_clang_workaround="yes", michael@0: ac_cv_host_cxx0x_clang_workaround="no")]) michael@0: michael@0: if test "ac_cv_host_cxx0x_clang_workaround" = "no"; then michael@0: AC_MSG_ERROR([Your host toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain]) michael@0: fi michael@0: HOST_CXXFLAGS="$CXXFLAGS" michael@0: elif test "$ac_cv_host_cxx0x_headers_bug" = "yes"; then michael@0: AC_MSG_ERROR([Your host toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain]) michael@0: fi michael@0: CXXFLAGS="$_SAVE_CXXFLAGS" michael@0: CPPFLAGS="$_SAVE_CPPFLAGS" michael@0: CXX="$_SAVE_CXX" michael@0: fi michael@0: elif test "$GNU_CXX"; then michael@0: HOST_CXXFLAGS="$HOST_CXXFLAGS $_ADDED_CXXFLAGS" michael@0: fi michael@0: AC_LANG_C michael@0: ])