build/autoconf/toolchain.m4

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 AC_DEFUN([MOZ_TOOL_VARIABLES],
     6 [
     7 GNU_AS=
     8 GNU_LD=
     9 GNU_CC=
    10 GNU_CXX=
    11 CC_VERSION='N/A'
    12 CXX_VERSION='N/A'
    13 if test "$GCC" = "yes"; then
    14     GNU_CC=1
    15     CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
    16 fi
    17 if test "$GXX" = "yes"; then
    18     GNU_CXX=1
    19     CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
    20     changequote(<<,>>)
    21     GCC_VERSION_FULL=`echo "$CXX_VERSION" | $PERL -pe 's/^.*gcc version ([^ ]*).*/<<$>>1/'`
    22     GCC_VERSION=`echo "$GCC_VERSION_FULL" | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/<<$>>1/;'`
    24     GCC_MAJOR_VERSION=`echo ${GCC_VERSION} | $AWK -F\. '{ print <<$>>1 }'`
    25     GCC_MINOR_VERSION=`echo ${GCC_VERSION} | $AWK -F\. '{ print <<$>>2 }'`
    26     changequote([,])
    27 fi
    29 if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then
    30     GNU_AS=1
    31 fi
    32 rm -f conftest.out
    33 if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
    34     GNU_LD=1
    35 fi
    36 if test "$GNU_CC"; then
    37     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
    38         GCC_USE_GNU_LD=1
    39     fi
    40 fi
    42 INTEL_CC=
    43 INTEL_CXX=
    44 if test "$GCC" = yes; then
    45    if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
    46      INTEL_CC=1
    47    fi
    48 fi
    50 if test "$GXX" = yes; then
    51    if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
    52      INTEL_CXX=1
    53    fi
    54 fi
    56 CLANG_CC=
    57 CLANG_CXX=
    58 if test "`$CC -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then
    59    CLANG_CC=1
    60 fi
    62 if test "`$CXX -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then
    63    CLANG_CXX=1
    64 fi
    65 AC_SUBST(CLANG_CXX)
    66 ])
    68 AC_DEFUN([MOZ_CROSS_COMPILER],
    69 [
    70 echo "cross compiling from $host to $target"
    72 _SAVE_CC="$CC"
    73 _SAVE_CFLAGS="$CFLAGS"
    74 _SAVE_LDFLAGS="$LDFLAGS"
    76 AC_MSG_CHECKING([for host c compiler])
    77 AC_CHECK_PROGS(HOST_CC, cc gcc clang cl, "")
    78 if test -z "$HOST_CC"; then
    79     AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
    80 fi
    81 AC_MSG_RESULT([$HOST_CC])
    82 AC_MSG_CHECKING([for host c++ compiler])
    83 AC_CHECK_PROGS(HOST_CXX, c++ g++ clang++ cl, "")
    84 if test -z "$HOST_CXX"; then
    85     AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
    86 fi
    87 AC_MSG_RESULT([$HOST_CXX])
    89 if test -z "$HOST_CFLAGS"; then
    90     HOST_CFLAGS="$CFLAGS"
    91 fi
    92 if test -z "$HOST_CXXFLAGS"; then
    93     HOST_CXXFLAGS="$CXXFLAGS"
    94 fi
    95 if test -z "$HOST_LDFLAGS"; then
    96     HOST_LDFLAGS="$LDFLAGS"
    97 fi
    98 if test -z "$HOST_AR_FLAGS"; then
    99     HOST_AR_FLAGS="$AR_FLAGS"
   100 fi
   101 AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
   102 AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
   103 CC="$HOST_CC"
   104 CFLAGS="$HOST_CFLAGS"
   105 LDFLAGS="$HOST_LDFLAGS"
   107 AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
   108 AC_TRY_COMPILE([], [return(0);],
   109     [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
   110     AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
   112 CC="$HOST_CXX"
   113 CFLAGS="$HOST_CXXFLAGS"
   114 AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
   115 AC_TRY_COMPILE([], [return(0);],
   116     [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
   117     AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
   119 CC=$_SAVE_CC
   120 CFLAGS=$_SAVE_CFLAGS
   121 LDFLAGS=$_SAVE_LDFLAGS
   123 AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", :)
   124 unset ac_cv_prog_CC
   125 AC_PROG_CC
   126 AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", :)
   127 unset ac_cv_prog_CXX
   128 AC_PROG_CXX
   130 AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", :)
   131 AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", :)
   132 MOZ_PATH_PROGS(AS, "${target_alias}-as" "${target}-as", :)
   133 AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :)
   134 AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", :)
   135 AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :)
   136 AC_DEFINE(CROSS_COMPILE)
   137 CROSS_COMPILE=1
   139 dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will
   140 dnl dnl have erroneously been set to "no", because the x86 build host is
   141 dnl dnl able to run ppc code in a translated environment, making a cross
   142 dnl dnl compiler appear native.  So we override that here.
   143 cross_compiling=yes
   144 ])
   146 AC_DEFUN([MOZ_CXX11],
   147 [
   148 dnl Check whether gcc's c++0x mode works
   149 dnl Updates to the test below should be duplicated further below for the
   150 dnl cross-compiling case.
   151 AC_LANG_CPLUSPLUS
   152 if test "$GNU_CXX"; then
   153     CXXFLAGS="$CXXFLAGS -std=gnu++0x"
   154     _ADDED_CXXFLAGS="-std=gnu++0x"
   156     AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
   157         ac_cv_cxx0x_headers_bug,
   158         [AC_TRY_COMPILE([#include <memory>], [],
   159                         ac_cv_cxx0x_headers_bug="no",
   160                         ac_cv_cxx0x_headers_bug="yes")])
   162     if test "$CLANG_CXX" -a "$ac_cv_cxx0x_headers_bug" = "yes"; then
   163         CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
   164         _ADDED_CXXFLAGS="$_ADDED_CXXFLAGS -I$_topsrcdir/build/unix/headers"
   165         AC_CACHE_CHECK(whether workaround for gcc c++0x headers conflict with clang works,
   166             ac_cv_cxx0x_clang_workaround,
   167             [AC_TRY_COMPILE([#include <memory>], [],
   168                             ac_cv_cxx0x_clang_workaround="yes",
   169                             ac_cv_cxx0x_clang_workaround="no")])
   171         if test "ac_cv_cxx0x_clang_workaround" = "no"; then
   172             AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
   173         fi
   174     elif test "$ac_cv_cxx0x_headers_bug" = "yes"; then
   175         AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
   176     fi
   177 fi
   178 if test -n "$CROSS_COMPILE"; then
   179     dnl When cross compile, we have no variable telling us what the host compiler is. Figure it out.
   180     cat > conftest.C <<EOF
   181 #if defined(__clang__)
   182 CLANG
   183 #elif defined(__GNUC__)
   184 GCC
   185 #endif
   186 EOF
   187     host_compiler=`$HOST_CXX -E conftest.C | egrep '(CLANG|GCC)'`
   188     rm conftest.C
   189     if test -n "$host_compiler"; then
   190         HOST_CXXFLAGS="$HOST_CXXFLAGS -std=gnu++0x"
   192         _SAVE_CXXFLAGS="$CXXFLAGS"
   193         _SAVE_CPPFLAGS="$CPPFLAGS"
   194         _SAVE_CXX="$CXX"
   195         CXXFLAGS="$HOST_CXXFLAGS"
   196         CPPFLAGS="$HOST_CPPFLAGS"
   197         CXX="$HOST_CXX"
   198         AC_CACHE_CHECK(for host gcc c++0x headers bug without rtti,
   199             ac_cv_host_cxx0x_headers_bug,
   200             [AC_TRY_COMPILE([#include <memory>], [],
   201                             ac_cv_host_cxx0x_headers_bug="no",
   202                             ac_cv_host_cxx0x_headers_bug="yes")])
   204         if test "$host_compiler" = CLANG -a "$ac_cv_host_cxx0x_headers_bug" = "yes"; then
   205             CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
   206             AC_CACHE_CHECK(whether workaround for host gcc c++0x headers conflict with host clang works,
   207                 ac_cv_host_cxx0x_clang_workaround,
   208                 [AC_TRY_COMPILE([#include <memory>], [],
   209                                 ac_cv_host_cxx0x_clang_workaround="yes",
   210                                 ac_cv_host_cxx0x_clang_workaround="no")])
   212             if test "ac_cv_host_cxx0x_clang_workaround" = "no"; then
   213                 AC_MSG_ERROR([Your host toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
   214             fi
   215             HOST_CXXFLAGS="$CXXFLAGS"
   216         elif test "$ac_cv_host_cxx0x_headers_bug" = "yes"; then
   217             AC_MSG_ERROR([Your host toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
   218         fi
   219         CXXFLAGS="$_SAVE_CXXFLAGS"
   220         CPPFLAGS="$_SAVE_CPPFLAGS"
   221         CXX="$_SAVE_CXX"
   222     fi
   223 elif test "$GNU_CXX"; then
   224     HOST_CXXFLAGS="$HOST_CXXFLAGS $_ADDED_CXXFLAGS"
   225 fi
   226 AC_LANG_C
   227 ])

mercurial