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.

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

mercurial