Bug 1295072 - Focus urlbar after opening an empty new tab r=kmag
[gecko.git] / build / autoconf / arch.m4
blob20af6ad7d3725d6279c76106a3a6f78714aaa13c
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_ARCH_OPTS],
8 dnl ========================================================
9 dnl = ARM toolchain tweaks
10 dnl ========================================================
12 MOZ_THUMB=toolchain-default
13 MOZ_THUMB_INTERWORK=toolchain-default
14 MOZ_FPU=toolchain-default
15 MOZ_FLOAT_ABI=toolchain-default
16 MOZ_SOFT_FLOAT=toolchain-default
17 MOZ_ALIGN=toolchain-default
19 MOZ_ARG_WITH_STRING(arch,
20 [  --with-arch=[[type|toolchain-default]]
21                            Use specific CPU features (-march=type). Resets
22                            thumb, fpu, float-abi, etc. defaults when set],
23     if test -z "$GNU_CC"; then
24         AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchains])
25     fi
26     MOZ_ARCH=$withval)
28 if test -z "$MOZ_ARCH"; then
29     dnl Defaults
30     case "${CPU_ARCH}-${OS_TARGET}" in
31     arm-Android)
32         MOZ_THUMB=yes
33         MOZ_ARCH=armv7-a
34         MOZ_FPU=vfp
35         MOZ_FLOAT_ABI=softfp
36         MOZ_ALIGN=no
37         ;;
38     arm-Darwin)
39         MOZ_ARCH=toolchain-default
40         ;;
41     esac
44 if test "$MOZ_ARCH" = "armv6" -a "$OS_TARGET" = "Android"; then
45    MOZ_FPU=vfp
46    MOZ_FLOAT_ABI=softfp
49 MOZ_ARG_WITH_STRING(thumb,
50 [  --with-thumb[[=yes|no|toolchain-default]]]
51 [                          Use Thumb instruction set (-mthumb)],
52     if test -z "$GNU_CC"; then
53         AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchains])
54     fi
55     MOZ_THUMB=$withval)
57 MOZ_ARG_WITH_STRING(thumb-interwork,
58 [  --with-thumb-interwork[[=yes|no|toolchain-default]]
59                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
60     if test -z "$GNU_CC"; then
61         AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchains])
62     fi
63     MOZ_THUMB_INTERWORK=$withval)
65 MOZ_ARG_WITH_STRING(fpu,
66 [  --with-fpu=[[type|toolchain-default]]
67                            Use specific FPU type (-mfpu=type)],
68     if test -z "$GNU_CC"; then
69         AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchains])
70     fi
71     MOZ_FPU=$withval)
73 MOZ_ARG_WITH_STRING(float-abi,
74 [  --with-float-abi=[[type|toolchain-default]]
75                            Use specific arm float ABI (-mfloat-abi=type)],
76     if test -z "$GNU_CC"; then
77         AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchains])
78     fi
79     MOZ_FLOAT_ABI=$withval)
81 MOZ_ARG_WITH_STRING(soft-float,
82 [  --with-soft-float[[=yes|no|toolchain-default]]
83                            Use soft float library (-msoft-float)],
84     if test -z "$GNU_CC"; then
85         AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchains])
86     fi
87     MOZ_SOFT_FLOAT=$withval)
89 case "$MOZ_ARCH" in
90 toolchain-default|"")
91     arch_flag=""
92     ;;
94     arch_flag="-march=$MOZ_ARCH"
95     ;;
96 esac
98 case "$MOZ_THUMB" in
99 yes)
100     MOZ_THUMB2=1
101     thumb_flag="-mthumb"
102     ;;
104     MOZ_THUMB2=
105     thumb_flag="-marm"
106     ;;
108     _SAVE_CFLAGS="$CFLAGS"
109     CFLAGS="$arch_flag"
110     AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
111         MOZ_THUMB2=1,
112         MOZ_THUMB2=)
113     CFLAGS="$_SAVE_CFLAGS"
114     thumb_flag=""
115     ;;
116 esac
118 if test "$MOZ_THUMB2" = 1; then
119     AC_DEFINE(MOZ_THUMB2)
122 case "$MOZ_THUMB_INTERWORK" in
123 yes)
124     thumb_interwork_flag="-mthumb-interwork"
125     ;;
127     thumb_interwork_flag="-mno-thumb-interwork"
128     ;;
129 *) # toolchain-default
130     thumb_interwork_flag=""
131     ;;
132 esac
134 case "$MOZ_FPU" in
135 toolchain-default|"")
136     fpu_flag=""
137     ;;
139     fpu_flag="-mfpu=$MOZ_FPU"
140     ;;
141 esac
143 case "$MOZ_FLOAT_ABI" in
144 toolchain-default|"")
145     float_abi_flag=""
146     ;;
148     float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
149     ;;
150 esac
152 case "$MOZ_SOFT_FLOAT" in
153 yes)
154     soft_float_flag="-msoft-float"
155     ;;
157     soft_float_flag="-mno-soft-float"
158     ;;
159 *) # toolchain-default
160     soft_float_flag=""
161     ;;
162 esac
164 case "$MOZ_ALIGN" in
166     align_flag="-mno-unaligned-access"
167     ;;
168 yes)
169     align_flag="-munaligned-access"
170     ;;
172     align_flag=""
173     ;;
174 esac
176 if test -n "$align_flag"; then
177   _SAVE_CFLAGS="$CFLAGS"
178   CFLAGS="$CFLAGS $align_flag"
179   AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
180   AC_TRY_COMPILE([],[],,align_flag="")
181   CFLAGS="$_SAVE_CFLAGS"
184 dnl Use echo to avoid accumulating space characters
185 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
186 if test -n "$all_flags"; then
187     _SAVE_CFLAGS="$CFLAGS"
188     CFLAGS="$all_flags"
189     AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
190     AC_TRY_COMPILE([],[return 0;],
191         AC_MSG_RESULT([yes]),
192         AC_MSG_ERROR([no]))
194     CFLAGS="$_SAVE_CFLAGS $all_flags"
195     CXXFLAGS="$CXXFLAGS $all_flags"
196     ASFLAGS="$ASFLAGS $all_flags"
197     if test -n "$thumb_flag"; then
198         LDFLAGS="$LDFLAGS $thumb_flag"
199     fi
202 AC_SUBST(MOZ_THUMB2)
204 if test "$CPU_ARCH" = "arm"; then
205   NEON_FLAGS="-mfpu=neon"
206   AC_MSG_CHECKING(for ARM SIMD support in compiler)
207   # We try to link so that this also fails when
208   # building with LTO.
209   AC_TRY_LINK([],
210                  [asm("uqadd8 r1, r1, r2");],
211                  result="yes", result="no")
212   AC_MSG_RESULT("$result")
213   if test "$result" = "yes"; then
214       AC_DEFINE(HAVE_ARM_SIMD)
215       HAVE_ARM_SIMD=1
216   fi
218   AC_MSG_CHECKING(ARM version support in compiler)
219   dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
220   ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]][[0-9]]*\).*/\1/p'`
221   AC_MSG_RESULT("$ARM_ARCH")
223   AC_MSG_CHECKING(for ARM NEON support in compiler)
224   # We try to link so that this also fails when
225   # building with LTO.
226   AC_TRY_LINK([],
227                  [asm(".fpu neon\n vadd.i8 d0, d0, d0");],
228                  result="yes", result="no")
229   AC_MSG_RESULT("$result")
230   if test "$result" = "yes"; then
231       AC_DEFINE(HAVE_ARM_NEON)
232       HAVE_ARM_NEON=1
234       dnl We don't need to build NEON support if we're targetting a non-NEON device.
235       dnl This matches media/webrtc/trunk/webrtc/build/common.gypi.
236       if test -n "$ARM_ARCH"; then
237           if test "$ARM_ARCH" -lt 7; then
238               BUILD_ARM_NEON=
239           else
240               AC_DEFINE(BUILD_ARM_NEON)
241               BUILD_ARM_NEON=1
242           fi
243       fi
244   fi
246 fi # CPU_ARCH = arm
248 AC_SUBST(HAVE_ARM_SIMD)
249 AC_SUBST(HAVE_ARM_NEON)
250 AC_SUBST(BUILD_ARM_NEON)
251 AC_SUBST(ARM_ARCH)
252 AC_SUBST_LIST(NEON_FLAGS)