Bug 1295072 - Focus urlbar after opening an empty new tab r=kmag
[gecko.git] / build / autoconf / toolchain.m4
blob92000e3ee5ed5cebbaaa3542d54893ebdd1c0e1e
1 dnl This Source Code Form is subject to the terms of the Mozilla Public
2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 dnl Several autoconf functions AC_REQUIRE AC_PROG_CPP/AC_PROG_CXXCPP
6 dnl or AC_HEADER_STDC, meaning they are called even when we don't call
7 dnl them explicitly.
8 dnl However, theses checks are not necessary and python configure sets
9 dnl the corresponding variables already, so just skip those tests
10 dnl entirely.
11 define([AC_PROG_CPP],[])
12 define([AC_PROG_CXXCPP],[])
13 define([AC_HEADER_STDC], [])
15 AC_DEFUN([MOZ_TOOL_VARIABLES],
17 GNU_AS=
19 GNU_CC=
20 GNU_CXX=
21 if test "$CC_TYPE" = "gcc"; then
22     GNU_CC=1
23     GNU_CXX=1
26 if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then
27     GNU_AS=1
29 rm -f conftest.out
31 CLANG_CC=
32 CLANG_CXX=
33 CLANG_CL=
34 if test "$CC_TYPE" = "clang"; then
35     GNU_CC=1
36     GNU_CXX=1
37     CLANG_CC=1
38     CLANG_CXX=1
40 if test "$CC_TYPE" = "clang-cl"; then
41     CLANG_CL=1
44 if test "$GNU_CC"; then
45     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
46         GCC_USE_GNU_LD=1
47     fi
50 AC_SUBST(CLANG_CXX)
51 AC_SUBST(CLANG_CL)
54 AC_DEFUN([MOZ_CROSS_COMPILER],
56 echo "cross compiling from $host to $target"
58 if test -z "$HOST_AR_FLAGS"; then
59     HOST_AR_FLAGS="$AR_FLAGS"
61 AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
62 AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
64 dnl AC_CHECK_PROGS manually goes through $PATH, and as such fails to handle
65 dnl absolute or relative paths. Relative paths wouldn't work anyways, but
66 dnl absolute paths would. Trick AC_CHECK_PROGS into working in that case by
67 dnl adding / to PATH. This is temporary until this moves to moz.configure
68 dnl (soon).
69 _SAVE_PATH=$PATH
70 case "${TOOLCHAIN_PREFIX}" in
71 /*)
72     PATH="/:$PATH"
73     ;;
74 esac
75 AC_PROG_CC
76 AC_PROG_CXX
78 AC_CHECK_PROGS(RANLIB, "${TOOLCHAIN_PREFIX}ranlib", :)
79 AC_CHECK_PROGS(AR, "${TOOLCHAIN_PREFIX}ar", :)
80 AC_CHECK_PROGS(AS, "${TOOLCHAIN_PREFIX}as", :)
81 AC_CHECK_PROGS(LIPO, "${TOOLCHAIN_PREFIX}lipo", :)
82 AC_CHECK_PROGS(STRIP, "${TOOLCHAIN_PREFIX}strip", :)
83 AC_CHECK_PROGS(WINDRES, "${TOOLCHAIN_PREFIX}windres", :)
84 AC_CHECK_PROGS(OTOOL, "${TOOLCHAIN_PREFIX}otool", :)
85 AC_CHECK_PROGS(OBJCOPY, "${TOOLCHAIN_PREFIX}objcopy", :)
86 PATH=$_SAVE_PATH
89 AC_DEFUN([MOZ_CXX11],
91 dnl Updates to the test below should be duplicated further below for the
92 dnl cross-compiling case.
93 AC_LANG_CPLUSPLUS
94 if test "$GNU_CXX"; then
95     AC_CACHE_CHECK([whether 64-bits std::atomic requires -latomic],
96         ac_cv_needs_atomic,
97         AC_TRY_LINK(
98             [#include <cstdint>
99              #include <atomic>],
100             [ std::atomic<uint64_t> foo; foo = 1; ],
101             ac_cv_needs_atomic=no,
102             _SAVE_LIBS="$LIBS"
103             LIBS="$LIBS -latomic"
104             AC_TRY_LINK(
105                 [#include <cstdint>
106                  #include <atomic>],
107                 [ std::atomic<uint64_t> foo; foo = 1; ],
108                 ac_cv_needs_atomic=yes,
109                 ac_cv_needs_atomic="do not know; assuming no")
110             LIBS="$_SAVE_LIBS"
111         )
112     )
113     if test "$ac_cv_needs_atomic" = yes; then
114       MOZ_NEEDS_LIBATOMIC=1
115     else
116       MOZ_NEEDS_LIBATOMIC=
117     fi
118     AC_SUBST(MOZ_NEEDS_LIBATOMIC)
120 AC_LANG_C