bug 715586: checksums.py should generate sha1 and md5 checksums. r=catlee,ted
[gecko.git] / configure.in
blob2d69f07f55f9aa92977418ad9984b21a292e6a2e
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3 dnl ***** BEGIN LICENSE BLOCK *****
4 dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 dnl
6 dnl The contents of this file are subject to the Mozilla Public License Version
7 dnl 1.1 (the "License"); you may not use this file except in compliance with
8 dnl the License. You may obtain a copy of the License at
9 dnl http://www.mozilla.org/MPL/
10 dnl
11 dnl Software distributed under the License is distributed on an "AS IS" basis,
12 dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 dnl for the specific language governing rights and limitations under the
14 dnl License.
15 dnl
16 dnl The Original Code is this file as it was released upon August 6, 1998.
17 dnl
18 dnl The Initial Developer of the Original Code is
19 dnl Christopher Seawood.
20 dnl Portions created by the Initial Developer are Copyright (C) 1998-2001
21 dnl the Initial Developer. All Rights Reserved.
22 dnl
23 dnl Contributor(s):
24 dnl   Jamie Zawinski <jwz@jwz.org>
25 dnl   gettimeofday args check
26 dnl   Christopher Blizzard <blizzard@appliedtheory.com>
27 dnl   gnomefe update & enable-pthreads
28 dnl   Ramiro Estrugo <ramiro@netscape.com>
29 dnl   X11 makedepend support
30 dnl   Insure support.
31 dnl   Henry Sobotka <sobotka@axess.com>
32 dnl   OS/2 support
33 dnl   Dan Mosedale <dmose@mozilla.org>
34 dnl   LDAP support
35 dnl   Seth Spitzer <sspitzer@netscape.com>
36 dnl   xpctools support
37 dnl   Benjamin Smedberg <benjamin@smedbergs.us>
38 dnl   Howard Chu <hyc@symas.com>
39 dnl   MSYS support
40 dnl   Mark Mentovai <mark@moxienet.com>:
41 dnl   Mac OS X 10.4 support
42 dnl   Giorgio Maone <g.maone@informaction.com>
43 dnl   MSVC l10n compatible version check
44 dnl   Ben Turner <mozilla@songbirdnest.com>
45 dnl   Windows x64 support
46 dnl   Makoto Kato <m_kato@ga2.so-net.ne.jp>
47 dnl
48 dnl Alternatively, the contents of this file may be used under the terms of
49 dnl either the GNU General Public License Version 2 or later (the "GPL"), or
50 dnl the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
51 dnl in which case the provisions of the GPL or the LGPL are applicable instead
52 dnl of those above. If you wish to allow use of your version of this file only
53 dnl under the terms of either the GPL or the LGPL, and not to allow others to
54 dnl use your version of this file under the terms of the MPL, indicate your
55 dnl decision by deleting the provisions above and replace them with the notice
56 dnl and other provisions required by the GPL or the LGPL. If you do not delete
57 dnl the provisions above, a recipient may use your version of this file under
58 dnl the terms of any one of the MPL, the GPL or the LGPL.
59 dnl
60 dnl ***** END LICENSE BLOCK *****
62 dnl Process this file with autoconf to produce a configure script.
63 dnl ========================================================
65 AC_PREREQ(2.13)
66 AC_INIT(config/config.mk)
67 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
68 AC_CANONICAL_SYSTEM
69 TARGET_CPU="${target_cpu}"
70 TARGET_VENDOR="${target_vendor}"
71 TARGET_OS="${target_os}"
73 MOZ_DEB_TIMESTAMP=`date +"%a, %d  %b %Y %T %z"   2>&1`
74 AC_SUBST(MOZ_DEB_TIMESTAMP)
76 dnl ========================================================
77 dnl =
78 dnl = Don't change the following two lines.  Doing so breaks:
79 dnl =
80 dnl = CFLAGS="-foo" ./configure
81 dnl =
82 dnl ========================================================
83 CFLAGS="${CFLAGS=}"
84 CPPFLAGS="${CPPFLAGS=}"
85 CXXFLAGS="${CXXFLAGS=}"
86 LDFLAGS="${LDFLAGS=}"
87 HOST_CFLAGS="${HOST_CFLAGS=}"
88 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
89 HOST_LDFLAGS="${HOST_LDFLAGS=}"
91 dnl ========================================================
92 dnl = Preserve certain environment flags passed to configure
93 dnl = We want sub projects to receive the same flags
94 dnl = untainted by this configure script
95 dnl ========================================================
96 _SUBDIR_CC="$CC"
97 _SUBDIR_CXX="$CXX"
98 _SUBDIR_CFLAGS="$CFLAGS"
99 _SUBDIR_CPPFLAGS="$CPPFLAGS"
100 _SUBDIR_CXXFLAGS="$CXXFLAGS"
101 _SUBDIR_LDFLAGS="$LDFLAGS"
102 _SUBDIR_HOST_CC="$HOST_CC"
103 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
104 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
105 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
106 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
108 dnl Set the version number of the libs included with mozilla
109 dnl ========================================================
110 MOZJPEG=62
111 MOZPNG=10401
112 MOZZLIB=0x1230
113 NSPR_VERSION=4
114 NSS_VERSION=3
116 dnl Set the minimum version of toolkit libs used by mozilla
117 dnl ========================================================
118 GLIB_VERSION=1.2.0
119 PERL_VERSION=5.006
120 PYTHON_VERSION=2.5
121 CAIRO_VERSION=1.10
122 PANGO_VERSION=1.14.0
123 GTK2_VERSION=2.10.0
124 WINDRES_VERSION=2.14.90
125 W32API_VERSION=3.14
126 GNOMEVFS_VERSION=2.0
127 GNOMEUI_VERSION=2.2.0
128 GCONF_VERSION=1.2.1
129 GIO_VERSION=2.18
130 STARTUP_NOTIFICATION_VERSION=0.8
131 DBUS_VERSION=0.60
132 SQLITE_VERSION=3.7.7.1
133 LIBNOTIFY_VERSION=0.4
135 MSMANIFEST_TOOL=
137 dnl Set various checks
138 dnl ========================================================
139 MISSING_X=
140 AC_PROG_AWK
142 dnl Initialize the Pthread test variables early so they can be
143 dnl  overridden by each platform.
144 dnl ========================================================
145 USE_PTHREADS=
146 _PTHREAD_LDFLAGS=""
148 dnl Do not allow a separate objdir build if a srcdir build exists.
149 dnl ==============================================================
150 _topsrcdir=`cd \`dirname $0\`; pwd`
151 _objdir=`pwd`
153 if test "$_topsrcdir" != "$_objdir"
154 then
155   # Check for a couple representative files in the source tree
156   _conflict_files=
157   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
158     if test -f $file; then
159       _conflict_files="$_conflict_files $file"
160     fi
161   done
162   if test "$_conflict_files"; then
163     echo "***"
164     echo "*   Your source tree contains these files:"
165     for file in $_conflict_files; do
166       echo "*         $file"
167     done
168     cat 1>&2 <<-EOF
169         *   This indicates that you previously built in the source tree.
170         *   A source tree build can confuse the separate objdir build.
171         *
172         *   To clean up the source tree:
173         *     1. cd $_topsrcdir
174         *     2. gmake distclean
175         ***
176         EOF
177     exit 1
178     break
179   fi
181 MOZ_BUILD_ROOT=`pwd`
183 dnl Default to MSVC for win32 and gcc for darwin
184 dnl ==============================================================
185 if test -z "$CROSS_COMPILE"; then
186 case "$target" in
187 *-mingw*)
188     if test -z "$CC"; then CC=cl; fi
189     if test -z "$CXX"; then CXX=cl; fi
190     if test -z "$CPP"; then CPP="cl -E -nologo"; fi
191     if test -z "$CXXCPP"; then CXXCPP="cl -TP -E -nologo"; ac_cv_prog_CXXCPP="$CXXCPP"; fi
192     if test -z "$LD"; then LD=link; fi
193     if test -z "$AS"; then
194         case "${target_cpu}" in
195         i*86)
196             AS=ml;
197             ;;
198         x86_64)
199             AS=ml64;
200             ;;
201         esac
202     fi
203     if test -z "$MIDL"; then MIDL=midl; fi
204     ;;
205 *-darwin*)
206     # we prefer gcc-4.2 over gcc on older darwin, so
207     # use that specific version if it's available.
208     MOZ_PATH_PROGS(CC, $CC gcc-4.2 gcc)
209     MOZ_PATH_PROGS(CXX, $CXX g++-4.2 g++)
210     ;;
211 esac
214 COMPILE_ENVIRONMENT=1
215 MOZ_ARG_DISABLE_BOOL(compile-environment,
216 [  --disable-compile-environment
217                           Disable compiler/library checks.],
218     COMPILE_ENVIRONMENT= )
219 AC_SUBST(COMPILE_ENVIRONMENT)
221 MOZ_ARG_WITH_STRING(l10n-base,
222 [  --with-l10n-base=DIR    path to l10n repositories],
223     L10NBASEDIR=$withval)
224 if test -n "$L10NBASEDIR"; then
225     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
226         AC_MSG_ERROR([--with-l10n-base must specify a path])
227     elif test -d "$L10NBASEDIR"; then
228         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
229     else
230         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
231     fi
233 AC_SUBST(L10NBASEDIR)
235 dnl Check for Perl first -- needed for win32 SDK checks
236 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
237 if test -z "$PERL" -o "$PERL" = ":"; then
238     AC_MSG_ERROR([perl not found in \$PATH])
241 dnl ========================================================
242 dnl = Android uses a very custom (hacky) toolchain; we need to do this
243 dnl = here, so that the compiler checks can succeed
244 dnl ========================================================
246 MOZ_ARG_WITH_STRING(android-ndk,
247 [  --with-android-ndk=DIR
248                           location where the Android NDK can be found],
249     android_ndk=$withval)
251 MOZ_ARG_WITH_STRING(android-toolchain,
252 [  --with-android-toolchain=DIR
253                           location of the android toolchain, default NDK/build/prebuilt/HOST/arm-eabi-4.4.0],
254     android_toolchain=$withval)
257 MOZ_ARG_WITH_STRING(android-version,
258 [  --with-android-version=VER
259                           android platform version, default 5],
260     android_version=$withval,
261     android_version=5)
263 MOZ_ARG_WITH_STRING(android-sdk,
264 [  --with-android-sdk=DIR
265                           location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)],
266     android_sdk=$withval)
268 MOZ_ARG_WITH_STRING(android-platform,
269 [  --with-android-platform=DIR
270                            location of platform dir, default NDK/build/platforms/android-5/arch-arm],
271     android_platform=$withval)
273 MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
274 [  --enable-android-libstdcxx
275                           use GNU libstdc++ instead of STLPort for NDK >= 5],
276     MOZ_ANDROID_LIBSTDCXX=1,
277     MOZ_ANDROID_LIBSTDCXX= )
279 case "$target" in
280 arm-linux*-android*|*-linuxandroid*)
281     android_tool_prefix="arm-linux-androideabi"
282     ;;
283 i?86-*android*)
284     android_tool_prefix="i686-android-linux"
285     ;;
286 arm-android-eabi)
287     android_tool_prefix="arm-eabi"
288     ;;
290     android_tool_prefix="$target_os"
291     ;;
292 esac
294 MOZ_ARG_WITH_STRING(gonk,
295 [  --with-gonk=DIR
296                location of gonk dir],
297     gonkdir=$withval)
299 if test -n "$gonkdir" ; then
300     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
301     gonk_toolchain="$gonkdir"/prebuilt/$kernel_name-x86/toolchain/arm-eabi-4.4.3
303     dnl set up compilers
304     AS="$gonk_toolchain"/bin/"$android_tool_prefix"-as
305     CC="$gonk_toolchain"/bin/"$android_tool_prefix"-gcc
306     CXX="$gonk_toolchain"/bin/"$android_tool_prefix"-g++
307     CPP="$gonk_toolchain"/bin/"$android_tool_prefix"-cpp
308     LD="$gonk_toolchain"/bin/"$android_tool_prefix"-ld
309     AR="$gonk_toolchain"/bin/"$android_tool_prefix"-ar
310     RANLIB="$gonk_toolchain"/bin/"$android_tool_prefix"-ranlib
311     STRIP="$gonk_toolchain"/bin/"$android_tool_prefix"-strip
313     STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/"
314     STLPORT_LIBS="-lstlport"
316     CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system/core/include -I$gonkdir/bionic -I$gonkdir/frameworks/base/include $STLPORT_CPPFLAGS $CPPFLAGS"
317     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
318     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
319     LIBS="$LIBS $STLPORT_LIBS"
321     dnl Add -llog by default, since we use it all over the place.
322     LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ -llog $LDFLAGS"
324     dnl prevent cross compile section from using these flags as host flags
325     if test -z "$HOST_CPPFLAGS" ; then
326         HOST_CPPFLAGS=" "
327     fi
328     if test -z "$HOST_CFLAGS" ; then
329         HOST_CFLAGS=" "
330     fi
331     if test -z "$HOST_CXXFLAGS" ; then
332         HOST_CXXFLAGS=" "
333     fi
334     if test -z "$HOST_LDFLAGS" ; then
335         HOST_LDFLAGS=" "
336     fi
338     AC_DEFINE(ANDROID)
339     AC_DEFINE(HAVE_SYS_UIO_H)
340     CROSS_COMPILE=1
341     MOZ_CHROME_FILE_FORMAT=omni
342     ZLIB_DIR=yes
343     direct_nspr_config=1
344 else
345 case "$target" in
346 *-android*|*-linuxandroid*)
347     if test -z "$android_ndk" ; then
348         AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
349     fi
351     if test -z "$android_sdk" ; then
352         AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
353     else
354         if ! test -e "$android_sdk"/source.properties ; then
355             AC_MSG_ERROR([The path in --with-android-sdk isn't valid (source.properties hasn't been found).])
356         fi
358         # Minimum Android SDK API Level we require.
359         android_min_api_level=13
361         # Get the api level from "$android_sdk"/source.properties.
362         android_api_level=`$AWK -F = '$1 == "AndroidVersion.ApiLevel" {print $2}' "$android_sdk"/source.properties`
364         if test -z "$android_api_level" ; then
365             AC_MSG_ERROR([Unexpected error: no AndroidVersion.ApiLevel field has been found in source.properties.])
366         fi
368         if ! test "$android_api_level" -eq "$android_api_level" ; then
369             AC_MSG_ERROR([Unexpected error: the found android api value isn't a number! (found $android_api_level)])
370         fi
372         if test $android_api_level -lt $android_min_api_level ; then
373             AC_MSG_ERROR([The given Android SDK provides API level $android_api_level ($android_min_api_level or higher required).])
374         fi
375     fi
377     android_platform_tools="$android_sdk"/../../platform-tools
378     if test ! -d "$android_platform_tools" ; then
379         android_platform_tools="$android_sdk"/tools # SDK Tools < r8
380     fi
382     if test -z "$android_toolchain" ; then
383         AC_MSG_CHECKING([for android toolchain directory])
385         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
387         android_toolchain="$android_ndk"/build/prebuilt/$kernel_name-x86/arm-eabi-4.4.0
389         # With newer NDK, the toolchain path has changed.
390         if ! test -d "$android_toolchain" ; then
391             android_toolchain="$android_ndk"/toolchains/arm-$kernel_name-androideabi-4.4.3/prebuilt/$kernel_name-x86
392         fi
394         if test -d "$android_toolchain" ; then
395             AC_MSG_RESULT([$android_toolchain])
396         else
397             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
398         fi
399     fi
401     if test -z "$android_platform" ; then
402         AC_MSG_CHECKING([for android platform directory])
404         android_platform="$android_ndk"/build/platforms/android-"$android_version"/arch-"$target_cpu"
406         # With newer NDK, the platform path has changed.
407         if ! test -d "$android_platform" ; then
408             android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_cpu"
409         fi
411         if test -d "$android_platform" ; then
412             AC_MSG_RESULT([$android_platform])
413         else
414             AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
415         fi
416     fi
418     dnl set up compilers
419     AS="$android_toolchain"/bin/"$android_tool_prefix"-as
420     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
421     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
422     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
423     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
424     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
425     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
426     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
427     OBJCOPY="$android_toolchain"/bin/"$android_tool_prefix"-objcopy
429     CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
430     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
431     CXXFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CXXFLAGS"
433     dnl Add -llog by default, since we use it all over the place.
434     dnl Add --allow-shlib-undefined, because libGLESv2 links to an
435     dnl undefined symbol (present on the hardware, just not in the
436     dnl NDK.)
437     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
439     dnl prevent cross compile section from using these flags as host flags
440     if test -z "$HOST_CPPFLAGS" ; then
441         HOST_CPPFLAGS=" "
442     fi
443     if test -z "$HOST_CFLAGS" ; then
444         HOST_CFLAGS=" "
445     fi
446     if test -z "$HOST_CXXFLAGS" ; then
447         HOST_CXXFLAGS=" "
448     fi
449     if test -z "$HOST_LDFLAGS" ; then
450         HOST_LDFLAGS=" "
451     fi
453     ANDROID_NDK="${android_ndk}"
454     ANDROID_TOOLCHAIN="${android_toolchain}"
455     ANDROID_PLATFORM="${android_platform}"
456     ANDROID_SDK="${android_sdk}"
457     ANDROID_PLATFORM_TOOLS="${android_platform_tools}"
458     ANDROID_VERSION="${android_version}"
459     if test -z "$ANDROID_PACKAGE_NAME" ; then
460         ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
461     fi
463     AC_DEFINE(ANDROID)
464     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
465     AC_SUBST(ANDROID_VERSION)
466     CROSS_COMPILE=1
467     MOZ_CHROME_FILE_FORMAT=omni
468     ZLIB_DIR=yes
469     ;;
470 *-linux*)
471     AC_PATH_PROG(OBJCOPY,objcopy)
472     ;;
473 esac
477 AC_SUBST(ANDROID_NDK)
478 AC_SUBST(ANDROID_TOOLCHAIN)
479 AC_SUBST(ANDROID_PLATFORM)
480 AC_SUBST(ANDROID_SDK)
481 AC_SUBST(ANDROID_PLATFORM_TOOLS)
482 AC_SUBST(ANDROID_PACKAGE_NAME)
483 AC_SUBST(OBJCOPY)
485 dnl ========================================================
486 dnl Checks for compilers.
487 dnl ========================================================
488 dnl Set CROSS_COMPILE in the environment when running configure
489 dnl to use the cross-compile setup for now
490 dnl ========================================================
492 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
493 AR_FLAGS='cr $@'
495 if test "$COMPILE_ENVIRONMENT"; then
497 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
498     echo "cross compiling from $host to $target"
499     cross_compiling=yes
501     _SAVE_CC="$CC"
502     _SAVE_CFLAGS="$CFLAGS"
503     _SAVE_LDFLAGS="$LDFLAGS"
505     AC_MSG_CHECKING([for host c compiler])
506     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
507     if test -z "$HOST_CC"; then
508         AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
509     fi
510     AC_MSG_RESULT([$HOST_CC])
511     AC_MSG_CHECKING([for host c++ compiler])
512     AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
513     if test -z "$HOST_CXX"; then
514         AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
515     fi
516     AC_MSG_RESULT([$HOST_CXX])
518     if test -z "$HOST_CFLAGS"; then
519         HOST_CFLAGS="$CFLAGS"
520     fi
521     if test -z "$HOST_CXXFLAGS"; then
522         HOST_CXXFLAGS="$CXXFLAGS"
523     fi
524     if test -z "$HOST_LDFLAGS"; then
525         HOST_LDFLAGS="$LDFLAGS"
526     fi
527     if test -z "$HOST_AR_FLAGS"; then
528         HOST_AR_FLAGS="$AR_FLAGS"
529     fi
530     AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
531     AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
532     CC="$HOST_CC"
533     CFLAGS="$HOST_CFLAGS"
534     LDFLAGS="$HOST_LDFLAGS"
536     AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
537     AC_TRY_COMPILE([], [return(0);],
538         [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
539         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
541     CC="$HOST_CXX"
542     CFLAGS="$HOST_CXXFLAGS"
544     AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
545     AC_TRY_COMPILE([], [return(0);],
546         [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
547         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
549     CC=$_SAVE_CC
550     CFLAGS=$_SAVE_CFLAGS
551     LDFLAGS=$_SAVE_LDFLAGS
553     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
554     unset ac_cv_prog_CC
555     AC_PROG_CC
556     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
557     unset ac_cv_prog_CXX
558     AC_PROG_CXX
560     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
561     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
562     MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
563     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
564     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
565     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
566     AC_DEFINE(CROSS_COMPILE)
567 else
568     AC_PROG_CC
569     AC_PROG_CXX
570     AC_PROG_RANLIB
571     MOZ_PATH_PROGS(AS, $AS as, $CC)
572     AC_CHECK_PROGS(AR, ar, :)
573     AC_CHECK_PROGS(LD, ld, :)
574     AC_CHECK_PROGS(STRIP, strip, :)
575     AC_CHECK_PROGS(WINDRES, windres, :)
576     if test -z "$HOST_CC"; then
577         HOST_CC='$(CC)'
578     fi
579     if test -z "$HOST_CFLAGS"; then
580         HOST_CFLAGS='$(CFLAGS)'
581     fi
582     if test -z "$HOST_CXX"; then
583         HOST_CXX='$(CXX)'
584     fi
585     if test -z "$HOST_CXXFLAGS"; then
586         HOST_CXXFLAGS='$(CXXFLAGS)'
587     fi
588     if test -z "$HOST_LDFLAGS"; then
589         HOST_LDFLAGS='$(LDFLAGS)'
590     fi
591     if test -z "$HOST_RANLIB"; then
592         HOST_RANLIB='$(RANLIB)'
593     fi
594     if test -z "$HOST_AR"; then
595         HOST_AR='$(AR)'
596     fi
597     if test -z "$HOST_AR_FLAGS"; then
598         HOST_AR_FLAGS='$(AR_FLAGS)'
599     fi
602 GNU_AS=
603 GNU_LD=
604 GNU_CC=
605 GNU_CXX=
606 CC_VERSION='N/A'
607 CXX_VERSION='N/A'
608 if test "$GCC" = "yes"; then
609     GNU_CC=1
610     CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
612 if test "$GXX" = "yes"; then
613     GNU_CXX=1
614     CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
616 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
617     GNU_AS=1
619 if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
620     GNU_LD=1
622 if test "$GNU_CC"; then
623     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
624         GCC_USE_GNU_LD=1
625     fi
628 INTEL_CC=
629 INTEL_CXX=
630 if test "$GCC" = yes; then
631    if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
632      INTEL_CC=1
633    fi
636 if test "$GXX" = yes; then
637    if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
638      INTEL_CXX=1
639    fi
642 CLANG_CC=
643 CLANG_CXX=
644 if test "$GCC" = yes; then
645    if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then
646      CLANG_CC=1
647    fi
650 if test "$GXX" = yes; then
651    if test "`$CXX -v 2>&1 | grep -c 'clang version'`" != "0"; then
652      CLANG_CXX=1
653    fi
656 dnl ========================================================
657 dnl Special win32 checks
658 dnl ========================================================
659 WINVER=502
660 dnl Target the Windows 7 SDK by default
661 WINSDK_TARGETVER=601
663 MOZ_ARG_WITH_STRING(windows-version,
664 [  --with-windows-version=WINSDK_TARGETVER
665                           Highest Windows version to target using this SDK
666                               502: Windows Server 2003
667                               600: Windows Vista
668                               601: Windows 7],
669   WINSDK_TARGETVER=$withval)
671 case "$WINSDK_TARGETVER" in
672 502|600|601)
673     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
674     ;;
677     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER), must be 502, 600 or 601]);
678     ;;
680 esac
682 if test -n "$COMPILE_ENVIRONMENT"; then
683 if test "$MOZ_WINSDK_TARGETVER" -lt "06000000"; then
684     # We can't build parental controls either
685     MOZ_DISABLE_PARENTAL_CONTROLS=1
689 case "$target" in
690 *-mingw*)
691     if test "$GCC" != "yes"; then
692         # Check to see if we are really running in a msvc environemnt
693         _WIN32_MSVC=1
694         AC_CHECK_PROGS(MIDL, midl)
696         # Make sure compilers are valid
697         CFLAGS="$CFLAGS -TC -nologo"
698         CXXFLAGS="$CXXFLAGS -TP -nologo"
699         AC_LANG_SAVE
700         AC_LANG_C
701         AC_TRY_COMPILE([#include <stdio.h>],
702             [ printf("Hello World\n"); ],,
703             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
705         AC_LANG_CPLUSPLUS
706         AC_TRY_COMPILE([#include <new.h>],
707             [ unsigned *test = new unsigned(42); ],,
708             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
709         AC_LANG_RESTORE
711         changequote(,)
712         _MSVC_VER_FILTER='s|.* ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
713         changequote([,])
715         # Determine compiler version
716         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
717         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
718         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
719         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
720         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
721         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
723         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
724         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
726         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
727             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
728         fi
730         if test "$_CC_MAJOR_VERSION" = "14"; then
731             dnl Require VC8SP1 or newer.
732             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
733             if test "$_CC_RELEASE" -lt 50727 -o \
734                     \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
735               AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. You probably need to install Service Pack 1 of Visual Studio 2005. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
736             fi
738             _CC_SUITE=8
739             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
740             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
741         elif test "$_CC_MAJOR_VERSION" = "15"; then
742             _CC_SUITE=9
743             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
744             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
745         elif test "$_CC_MAJOR_VERSION" = "16"; then
746             _CC_SUITE=10
747             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
748             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
749         elif test "$_CC_MAJOR_VERSION" = "17"; then
750             _CC_SUITE=11
751             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
752             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
753         else
754             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
755         fi
757         _MOZ_RTTI_FLAGS_ON='-GR'
758         _MOZ_RTTI_FLAGS_OFF='-GR-'
759         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
761         if test -n "$WIN32_REDIST_DIR"; then
762           if test ! -d "$WIN32_REDIST_DIR"; then
763             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
764           fi
765           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
766         fi
768         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
769         dnl not something else like "magnetic tape manipulation utility".
770         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
771         if test -z "$MSMT_TOOL"; then
772           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
773         fi
775         changequote(,)
776         _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
777         changequote([,])
778         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
779         if test -z "$MSMANIFEST_TOOL_VERSION"; then
780           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
781         fi
783         MSMANIFEST_TOOL=1
784         unset MSMT_TOOL
786         # Check linker version
787         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
788         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
789         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
790             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
791         fi
793         INCREMENTAL_LINKER=1
795         # Check midl version
796         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
797         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
798         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
799         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
800         # Add flags if necessary
801         AC_MSG_CHECKING([for midl flags])
802         case "$target" in
803         i*86-*)
804             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
805                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
806                 # MIDL version 7.00.0500 or later has no problem.
807                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
808                 AC_MSG_RESULT([need -env win32])
809             else
810                 AC_MSG_RESULT([none needed])
811             fi
812             ;;
813         x86_64-*)
814             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
815             ;;
816         *)
817             AC_MSG_RESULT([none needed])
818             ;;
819         esac
821         # Identify which version of the SDK we're building with
822         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
823         # from there
824         MOZ_CHECK_HEADERS([winsdkver.h])
825         if test "$ac_cv_header_winsdkver_h" = "yes"; then
826             # Get the highest _WIN32_WINNT and NTDDI versions supported
827             # Take the higher of the two
828             # This is done because the Windows 7 beta SDK reports its
829             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
830             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
831                            ac_cv_winsdk_maxver,
832                            [cat > conftest.h <<EOF
833 #include <winsdkver.h>
834 #include <sdkddkver.h>
836 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
837 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
838 #else
839 #define WINSDK_MAXVER NTDDI_MAXVER
840 #endif
842 WINSDK_MAXVER
844                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
845                             rm -f conftest.h
846                            ])
847             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
848         else
849             # The Vista SDK is the only one to have sdkddkver.h but not
850             # WinSDKVer.h
851             MOZ_CHECK_HEADERS([sdkddkver.h])
852             if test "$ac_cv_header_sdkddkver_h" = "yes"; then
853                 MOZ_WINSDK_MAXVER=0x06000000
854             else
855                 # Assume the Server 2003 Platform SDK
856                 MOZ_WINSDK_MAXVER=0x05020000
857             fi
858         fi
860         unset _MSVC_VER_FILTER
862         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
863             [
864                 AC_LANG_SAVE
865                 AC_LANG_CPLUSPLUS
866                 _SAVE_CXXFLAGS="$CXXFLAGS"
867                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
868                 AC_TRY_COMPILE([#include <exception>],
869                             [std::_Throw(std::exception()); return 0;],
870                             ac_cv_have_std__Throw="yes",
871                             ac_cv_have_std__Throw="no")
872                 CXXFLAGS="$_SAVE_CXXFLAGS"
873                 AC_LANG_RESTORE
874             ])
876         if test "$ac_cv_have_std__Throw" = "yes"; then
877             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
878                            ac_cv_have_dllimport_exception_bug,
879                 [
880                     AC_LANG_SAVE
881                     AC_LANG_CPLUSPLUS
882                     _SAVE_CXXFLAGS="$CXXFLAGS"
883                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
884                     AC_TRY_LINK([#include <vector>],
885                                 [std::vector<int> v; return v.at(1);],
886                                 ac_cv_have_dllimport_exception_bug="no",
887                                 ac_cv_have_dllimport_exception_bug="yes")
888                     CXXFLAGS="$_SAVE_CXXFLAGS"
889                     AC_LANG_RESTORE
890                 ])
891             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
892                 WRAP_STL_INCLUDES=1
893                 MOZ_MSVC_STL_WRAP__Throw=1
894                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
895             fi
896         else
897             AC_CACHE_CHECK(for overridable _RAISE,
898                            ac_cv_have__RAISE,
899                 [
900                     AC_LANG_SAVE
901                     AC_LANG_CPLUSPLUS
902                     _SAVE_CXXFLAGS="$CXXFLAGS"
903                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
904                     AC_TRY_COMPILE([#include <xstddef>
905                                     #undef _RAISE
906                                     #define _RAISE(x) externallyDefinedFunction((x).what())
907                                     #include <vector>
908                                    ],
909                                    [std::vector<int> v; return v.at(1);],
910                                    ac_cv_have__RAISE="no",
911                                    ac_cv_have__RAISE="yes")
912                     CXXFLAGS="$_SAVE_CXXFLAGS"
913                     AC_LANG_RESTORE
914                 ])
915             if test "$ac_cv_have__RAISE" = "yes"; then
916                 WRAP_STL_INCLUDES=1
917                 MOZ_MSVC_STL_WRAP__RAISE=1
918                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
919             else
920                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
921             fi
922         fi
924         if test "$WRAP_STL_INCLUDES" = "1"; then
925             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
926         fi
927     else
928         # Check w32api version
929         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
930         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
931         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
932         AC_TRY_COMPILE([#include <w32api.h>],
933             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
934                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
935                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
936                 #error "test failed."
937             #endif
938             , [ res=yes ], [ res=no ])
939         AC_MSG_RESULT([$res])
940         if test "$res" != "yes"; then
941             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
942         fi
943         # Check windres version
944         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
945         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
946         AC_MSG_RESULT([$_WINDRES_VERSION])
947         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
948         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
949         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
950         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
951         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
952         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
953         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
954                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
955                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
956                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
957                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
958                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
959         then
960             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
961         fi
963         MOZ_WINSDK_MAXVER=0x06010000
964     fi # !GNU_CC
966     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
967     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
968     # Require OS features provided by IE 5.0
969     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0500)
971     # If the maximum version supported by this SDK is lower than the target
972     # version, error out
973     AC_MSG_CHECKING([for Windows SDK being recent enough])
974     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
975         AC_MSG_RESULT("yes")
976     else
977         AC_MSG_RESULT("no")
978         AC_MSG_ERROR([You are targeting Windows version 0x$MOZ_WINSDK_TARGETVER, but your SDK only supports up to version $MOZ_WINSDK_MAXVER. Install and use an updated SDK, or target a lower version using --with-windows-version. Alternatively, try running the Windows SDK Configuration Tool and selecting a newer SDK. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
979     fi
981     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
982     # Definitions matching sdkddkver.h
983     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WS03, 0x05020000)
984     AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
985     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
986     ;;
987 esac
989 AC_PROG_CPP
990 AC_PROG_CXXCPP
992 if test -n "$_WIN32_MSVC"; then
993     SKIP_PATH_CHECKS=1
994     SKIP_COMPILER_CHECKS=1
995     SKIP_LIBRARY_CHECKS=1
997     # Since we're skipping compiler and library checks, hard-code
998     # some facts here.
999     AC_DEFINE(HAVE_IO_H)
1000     AC_DEFINE(HAVE_SETBUF)
1001     AC_DEFINE(HAVE_ISATTY)
1004 fi # COMPILE_ENVIRONMENT
1006 AC_SUBST(MIDL_FLAGS)
1007 AC_SUBST(_MSC_VER)
1009 AC_SUBST(GNU_AS)
1010 AC_SUBST(GNU_LD)
1011 AC_SUBST(GNU_CC)
1012 AC_SUBST(GNU_CXX)
1013 AC_SUBST(INTEL_CC)
1014 AC_SUBST(INTEL_CXX)
1015 AC_SUBST(CLANG_CC)
1016 AC_SUBST(CLANG_CXX)
1018 AC_SUBST(STL_FLAGS)
1019 AC_SUBST(WRAP_STL_INCLUDES)
1020 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
1021 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
1023 dnl ========================================================
1024 dnl Checks for programs.
1025 dnl ========================================================
1026 AC_PROG_INSTALL
1027 AC_PROG_LN_S
1029 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
1030 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
1031 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
1032 _perl_res=$?
1033 AC_MSG_RESULT([$_perl_version])
1035 if test "$_perl_res" != 0; then
1036     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
1040 AC_MSG_CHECKING([for full perl installation])
1041 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
1042 _perl_res=$?
1043 if test "$_perl_res" != 0; then
1044     AC_MSG_RESULT([no])
1045     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
1046 else
1047     AC_MSG_RESULT([yes])
1050 MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python2.6 python2.5 python)
1051 if test -z "$PYTHON"; then
1052     AC_MSG_ERROR([python was not found in \$PATH])
1055 if test -z "$COMPILE_ENVIRONMENT"; then
1056     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
1058 AC_SUBST(NSINSTALL_BIN)
1060 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
1061 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
1062 MOZ_PATH_PROGS(UNZIP, unzip)
1063 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
1064     AC_MSG_ERROR([unzip not found in \$PATH])
1066 MOZ_PATH_PROGS(ZIP, zip)
1067 if test -z "$ZIP" -o "$ZIP" = ":"; then
1068     AC_MSG_ERROR([zip not found in \$PATH])
1070 MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
1071 MOZ_PATH_PROG(XARGS, xargs)
1072 if test -z "$XARGS" -o "$XARGS" = ":"; then
1073     AC_MSG_ERROR([xargs not found in \$PATH .])
1076 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
1077 AC_SUBST(RPMBUILD)
1079 if test "$COMPILE_ENVIRONMENT"; then
1081 dnl ========================================================
1082 dnl = Mac OS X toolchain support
1083 dnl ========================================================
1085 case "$target_os" in
1086 darwin*)
1087     dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
1088     dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
1089     dnl the environment and includedir purposes (when using an SDK, below),
1090     dnl but remember the full version number for the libdir (SDK).
1091     changequote(,)
1092     GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1093     GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1094     changequote([,])
1095     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
1096         dnl Bug 280479, but this keeps popping up in bug 292530 too because
1097         dnl 4.0.0/4061 is the default compiler in Tiger.
1098         changequote(,)
1099         GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
1100         changequote([,])
1101         if test "$GCC_BUILD" = "4061" ; then
1102             AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
1103 This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
1104 from building Mozilla. Upgrade to Xcode 2.1 or later.])
1105         fi
1106     fi
1108     dnl xcodebuild needs GCC_VERSION defined in the environment, since it
1109     dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
1110     dnl /usr/bin/g(cc|++)-$GCC_VERSION.
1111     MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
1113     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
1114     dnl it has moved into /usr/bin.
1115     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
1116     ;;
1117 esac
1119 AC_SUBST(GCC_VERSION)
1121 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
1122 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
1123 dnl when we can run target binaries.
1124 AC_SUBST(UNIVERSAL_BINARY)
1125 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
1127 dnl ========================================================
1128 dnl Check for MacOS deployment target version
1129 dnl ========================================================
1131 MOZ_ARG_ENABLE_STRING(macos-target,
1132                       [  --enable-macos-target=VER (default=10.5)
1133                           Set the minimum MacOS version needed at runtime],
1134                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
1136 case "$target" in
1137 *-darwin*)
1138     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1139         dnl Use the specified value
1140         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1141     else
1142         dnl No value specified on the command line or in the environment,
1143         dnl use architecture minimum.
1144         case "${target_cpu}" in
1145           i*86)
1146             export MACOSX_DEPLOYMENT_TARGET=10.5
1147             ;;
1148           x86_64)
1149             export MACOSX_DEPLOYMENT_TARGET=10.6
1150             ;;
1151         esac
1152     fi
1153     ;;
1154 esac
1156 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
1158 dnl ========================================================
1159 dnl = Mac OS X SDK support
1160 dnl ========================================================
1161 MACOS_SDK_DIR=
1162 NEXT_ROOT=
1163 MOZ_ARG_WITH_STRING(macos-sdk,
1164 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
1165     MACOS_SDK_DIR=$withval)
1167 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
1168 dnl NEXT_ROOT will be set and exported only if it's needed.
1169 AC_SUBST(MACOS_SDK_DIR)
1170 AC_SUBST(NEXT_ROOT)
1172 if test "$MACOS_SDK_DIR"; then
1173   dnl Sync this section with the ones in NSPR and NSS.
1174   dnl Changes to the cross environment here need to be accounted for in
1175   dnl the libIDL checks (below) and xpidl build.
1177   if test ! -d "$MACOS_SDK_DIR"; then
1178     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1179 specify a valid SDK.  SDKs are installed when the optional cross-development
1180 tools are selected during the Xcode/Developer Tools installation.])
1181   fi
1183   GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1184   if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1185     AC_MSG_ERROR([You need to upgrade the compiler version to 4.x])
1186   else
1187     CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1188     CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
1190     dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
1191     CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1192     CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
1194     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
1195       dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
1196       dnl that supports -syslibroot.  Don't set NEXT_ROOT because it will
1197       dnl be ignored and cause warnings when -syslibroot is specified.
1198       dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
1199       dnl the -isysroot it receives, so this is only needed with 4.0.0.
1200       LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1201     fi
1202   fi
1204   AC_LANG_SAVE
1205   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
1206   AC_LANG_CPLUSPLUS
1207   AC_TRY_COMPILE([#include <new>],[],
1208    result=yes,
1209    result=no)
1210   AC_LANG_RESTORE
1211   AC_MSG_RESULT($result)
1213   if test "$result" = "no" ; then
1214     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
1215   fi
1218 fi # COMPILE_ENVIRONMENT
1220 dnl clang prior to 2.9 (including Xcode 4) does not support all the
1221 dnl constructs required by the libtheora inline asm. This is used to
1222 dnl detect and disable it
1223 AC_MSG_CHECKING([whether the C compiler is clang older than version 2.9])
1224 AC_LANG_SAVE
1225 AC_LANG_C
1226 AC_TRY_COMPILE([
1227 #if defined(__clang__)
1228 # if __clang_major__<2 || (__clang_major__==2 && __clang_minor__<9)
1229 #  error "clang older than 2.9 detected"
1230 # endif
1231 #endif
1232                ],
1233                [],
1234                result="no",
1235                result="yes")
1236 AC_LANG_RESTORE
1237 AC_MSG_RESULT([$result])
1238 if test "$result" = "yes"; then
1239   MOZ_NO_THEORA_ASM=1
1241 dnl XCode 4.2 also shipped an llvm-gcc which couldn't compile
1242 dnl the libtheora inline asm.
1243 AC_MSG_CHECKING([bad gcc versions])
1244 if `$CC --version | grep -q "Apple Inc. build 5658"`; then
1245   AC_MSG_RESULT([Apple build 5658])
1246   MOZ_NO_THEORA_ASM=1
1247 else
1248   AC_MSG_RESULT([we're ok])
1251 AC_SUBST(MOZ_NO_THEORA_ASM)
1253 if test "x$MOZ_NO_THEORA_ASM" = x1; then
1254   AC_MSG_WARN([Disabling libtheora inline assembly])
1257 if test -n "$MAKE"; then
1258   if test `echo $MAKE | grep -c make.py` != 1; then
1259      NOT_PYMAKE=$MAKE
1260   fi
1263 case "$host_os" in
1264 mingw*)
1265     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
1266     ;;
1268     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
1269     ;;
1270 esac
1271 if test "$GMAKE" = ":"; then
1272    AC_MSG_ERROR([GNU make not found])
1274 AC_SUBST(GMAKE)
1276 if test "$COMPILE_ENVIRONMENT"; then
1278 AC_PATH_XTRA
1280 XCFLAGS="$X_CFLAGS"
1282 fi # COMPILE_ENVIRONMENT
1284 dnl ========================================================
1285 dnl set the defaults first
1286 dnl ========================================================
1287 AS_BIN=$AS
1288 AR_LIST='$(AR) t'
1289 AR_EXTRACT='$(AR) x'
1290 AR_DELETE='$(AR) d'
1291 AS='$(CC)'
1292 AS_DASH_C_FLAG='-c'
1293 DLL_PREFIX=lib
1294 LIB_PREFIX=lib
1295 DLL_SUFFIX=.so
1296 OBJ_SUFFIX=o
1297 LIB_SUFFIX=a
1298 ASM_SUFFIX=s
1299 IMPORT_LIB_SUFFIX=
1300 TARGET_MD_ARCH=unix
1301 DIRENT_INO=d_ino
1302 WIN_TOP_SRC=
1303 MOZ_USER_DIR=".mozilla"
1305 MOZ_JPEG_CFLAGS=
1306 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
1307 MOZ_ZLIB_CFLAGS=
1308 MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
1309 MOZ_BZ2_CFLAGS=
1310 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
1311 MOZ_PNG_CFLAGS=
1312 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
1314 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
1315 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
1316 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
1317 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1318 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
1319 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
1320 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1321 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
1323 MOZ_FS_LAYOUT=unix
1325 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1327 USE_DEPENDENT_LIBS=1
1329 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1331 if test -n "$CROSS_COMPILE"; then
1332     OS_TARGET="${target_os}"
1333     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1334     OS_RELEASE=
1335     case "${target_os}" in
1336         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1337         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1338         gnu*)         OS_ARCH=GNU ;;
1339         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1340         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1341         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1342     esac
1343     case "${target}" in
1344         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1345     esac
1346 else
1347     OS_TARGET=`uname -s`
1348     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1349     OS_RELEASE=`uname -r`
1352 # Before this used `uname -m` when not cross compiling
1353 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1354 OS_TEST="${target_cpu}"
1356 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1358 #######################################################################
1359 # Master "Core Components" macros for getting the OS target           #
1360 #######################################################################
1363 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1364 # cross-compilation.
1368 # Define and override various archtecture-specific variables, including
1369 # HOST_OS_ARCH
1370 # OS_ARCH
1371 # OS_TEST
1372 # OS_TARGET
1373 # OS_RELEASE
1374 # OS_MINOR_RELEASE
1377 case "$HOST_OS_ARCH" in
1378 mingw*)
1379     HOST_OS_ARCH=WINNT
1380     ;;
1381 darwin*)
1382     HOST_OS_ARCH=Darwin
1383     ;;
1384 linux*)
1385     HOST_OS_ARCH=Linux
1386     ;;
1387 solaris*)
1388     HOST_OS_ARCH=SunOS
1389     SOLARIS_SUNPRO_CC=
1390     SOLARIS_SUNPRO_CXX=
1391     if test -z "$GNU_CC"; then
1392         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1393             SOLARIS_SUNPRO_CC=1
1394        fi
1395     fi
1397     if test -z "$GNU_CXX"; then
1398        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1399            SOLARIS_SUNPRO_CXX=1
1400        fi
1401     fi
1402     AC_SUBST(SOLARIS_SUNPRO_CC)
1403     AC_SUBST(SOLARIS_SUNPRO_CXX)
1404     ;;
1405 BSD_386)
1406     HOST_OS_ARCH=BSD
1407     ;;
1408 OS_2)
1409     HOST_OS_ARCH=OS2
1410     ;;
1411 esac
1413 case "$OS_ARCH" in
1414 WINNT)
1415     if test -z "$CROSS_COMPILE" ; then
1416         OS_TEST=`uname -p`
1417     fi
1418     ;;
1419 Windows_NT)
1421 # If uname -s returns "Windows_NT", we assume that we are using
1422 # the uname.exe in MKS toolkit.
1424 # The -r option of MKS uname only returns the major version number.
1425 # So we need to use its -v option to get the minor version number.
1426 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1428     OS_ARCH=WINNT
1429     OS_TARGET=WINNT
1430     OS_MINOR_RELEASE=`uname -v`
1431     if test "$OS_MINOR_RELEASE" = "00"; then
1432         OS_MINOR_RELEASE=0
1433     fi
1434     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1435     ;;
1436 MINGW*_NT*)
1438 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1439 # the uname.exe in the MSYS tools.
1441     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1442     OS_ARCH=WINNT
1443     OS_TARGET=WINNT
1444     ;;
1445 AIX)
1446     OS_RELEASE=`uname -v`.`uname -r`
1447     OS_TEST=${target_cpu}
1448     ;;
1449 BSD_386)
1450     OS_ARCH=BSD
1451     ;;
1452 OS_2)
1453     OS_ARCH=OS2
1454     OS_TARGET=OS2
1455     OS_RELEASE=`uname -v`
1456     ;;
1457 Darwin)
1458     case "${target_cpu}" in
1459     powerpc*)
1460         OS_TEST=ppc
1461         ;;
1462     i*86*)
1463         OS_TEST=i386
1464         ;;
1465     x86_64)
1466         OS_TEST=x86_64
1467         ;;
1468     *)
1469         if test -z "$CROSS_COMPILE" ; then
1470             OS_TEST=`uname -p`
1471         fi
1472         ;;
1473     esac
1474     ;;
1475 esac
1477 # Only set CPU_ARCH if we recognize the value of OS_TEST
1479 case "$OS_TEST" in
1480 *86 | i86pc)
1481     CPU_ARCH=x86
1482     ;;
1484 powerpc64 | ppc64)
1485     CPU_ARCH=ppc64
1486     ;;
1488 powerpc | ppc | rs6000)
1489     CPU_ARCH=ppc
1490     ;;
1492 Alpha | alpha | ALPHA)
1493     CPU_ARCH=Alpha
1494     ;;
1496 s390)
1497     CPU_ARCH=s390
1498     ;;
1500 s390x)
1501     CPU_ARCH=s390x
1502     ;;
1504 hppa* | parisc)
1505     CPU_ARCH=hppa
1506     ;;
1508 sun4u | sparc*)
1509     CPU_ARCH=sparc
1510     ;;
1512 x86_64 | ia64)
1513     CPU_ARCH="$OS_TEST"
1514     ;;
1516 arm*)
1517     CPU_ARCH=arm
1518     ;;
1520 mips|mipsel)
1521     CPU_ARCH="mips"
1522     ;;
1523 esac
1525 if test -z "$OS_TARGET"; then
1526     OS_TARGET=$OS_ARCH
1528 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1530 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1531 dnl ===============================================================
1532 INTEL_ARCHITECTURE=
1533 case "$OS_TEST" in
1534     x86_64|i?86)
1535       INTEL_ARCHITECTURE=1
1536 esac
1538 dnl ========================================================
1539 dnl = ARM toolchain tweaks
1540 dnl ========================================================
1542 dnl Defaults
1543 case "${CPU_ARCH}-${OS_TARGET}" in
1544 arm-Android)
1545     MOZ_THUMB=yes
1546     MOZ_ARCH=armv7-a
1547     MOZ_FPU=vfp
1548     MOZ_FLOAT_ABI=softfp
1549     ;;
1550 arm-*)
1551     if test -n "$MOZ_PLATFORM_MAEMO"; then
1552         MOZ_THUMB=no
1553         MOZ_ARCH=armv7-a
1554         MOZ_FLOAT_ABI=softfp
1555     fi
1556     if test "$MOZ_PLATFORM_MAEMO" = 6; then
1557         MOZ_THUMB=yes
1558     fi
1559     ;;
1560 esac
1562 dnl Kept for compatibility with some buildbot mozconfig
1563 MOZ_ARG_DISABLE_BOOL(thumb2, [], MOZ_THUMB=no, MOZ_THUMB=yes)
1565 MOZ_ARG_WITH_STRING(thumb,
1566 [  --with-thumb[[=yes|no|toolchain-default]]]
1567 [                          Use Thumb instruction set (-mthumb)],
1568     if test -z "$GNU_CC"; then
1569         AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchains])
1570     fi
1571     MOZ_THUMB=$withval)
1573 MOZ_ARG_WITH_STRING(thumb-interwork,
1574 [  --with-thumb-interwork[[=yes|no|toolchain-default]]
1575                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
1576     if test -z "$GNU_CC"; then
1577         AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchains])
1578     fi
1579     MOZ_THUMB_INTERWORK=$withval)
1581 MOZ_ARG_WITH_STRING(arch,
1582 [  --with-arch=[[type|toolchain-default]]
1583                            Use specific CPU features (-march=type)],
1584     if test -z "$GNU_CC"; then
1585         AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchains])
1586     fi
1587     MOZ_ARCH=$withval)
1589 MOZ_ARG_WITH_STRING(fpu,
1590 [  --with-fpu=[[type|toolchain-default]]
1591                            Use specific FPU type (-mfpu=type)],
1592     if test -z "$GNU_CC"; then
1593         AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchains])
1594     fi
1595     MOZ_FPU=$withval)
1597 MOZ_ARG_WITH_STRING(float-abi,
1598 [  --with-float-abi=[[type|toolchain-default]]
1599                            Use specific arm float ABI (-mfloat-abi=type)],
1600     if test -z "$GNU_CC"; then
1601         AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchains])
1602     fi
1603     MOZ_FLOAT_ABI=$withval)
1605 MOZ_ARG_WITH_STRING(soft-float,
1606 [  --with-soft-float[[=yes|no|toolchain-default]]
1607                            Use soft float library (-msoft-float)],
1608     if test -z "$GNU_CC"; then
1609         AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchains])
1610     fi
1611     MOZ_SOFT_FLOAT=$withval)
1613 case "$MOZ_ARCH" in
1614 toolchain-default|"")
1615     arch_flag=""
1616     ;;
1618     arch_flag="-march=$MOZ_ARCH"
1619     ;;
1620 esac
1622 case "$MOZ_THUMB" in
1623 yes)
1624     MOZ_THUMB2=1
1625     thumb_flag="-mthumb"
1626     ;;
1628     MOZ_THUMB2=
1629     thumb_flag="-marm"
1630     ;;
1632     _SAVE_CFLAGS="$CFLAGS"
1633     CFLAGS="$arch_flag"
1634     AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1635         MOZ_THUMB2=1,
1636         MOZ_THUMB2=)
1637     CFLAGS="$_SAVE_CFLAGS"
1638     thumb_flag=""
1639     ;;
1640 esac
1642 if test "$MOZ_THUMB2" = 1; then
1643     AC_DEFINE(MOZ_THUMB2)
1646 case "$MOZ_THUMB_INTERWORK" in
1647 yes)
1648     thumb_interwork_flag="-mthumb-interwork"
1649     ;;
1651     thumb_interwork_flag="-mno-thumb-interwork"
1652     ;;
1653 *) # toolchain-default
1654     thumb_interwork_flag=""
1655     ;;
1656 esac
1658 case "$MOZ_FPU" in
1659 toolchain-default|"")
1660     fpu_flag=""
1661     ;;
1663     fpu_flag="-mfpu=$MOZ_FPU"
1664     ;;
1665 esac
1667 case "$MOZ_FLOAT_ABI" in
1668 toolchain-default|"")
1669     float_abi_flag=""
1670     ;;
1672     float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1673     ;;
1674 esac
1676 case "$MOZ_SOFT_FLOAT" in
1677 yes)
1678     soft_float_flag="-msoft-float"
1679     ;;
1681     soft_float_flag="-mno-soft-float"
1682     ;;
1683 *) # toolchain-default
1684     soft_float_flag=""
1685     ;;
1686 esac
1688 dnl Use echo to avoid accumulating space characters
1689 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag`
1690 if test -n "$all_flags"; then
1691     _SAVE_CFLAGS="$CFLAGS"
1692     CFLAGS="$all_flags"
1693     AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1694     AC_TRY_COMPILE([],[return 0;],
1695         AC_MSG_RESULT([yes]),
1696         AC_MSG_ERROR([no]))
1698     CFLAGS="$_SAVE_CFLAGS $all_flags"
1699     CXXFLAGS="$CXXFLAGS $all_flags"
1700     ASFLAGS="$ASFLAGS $all_flags"
1701     if test -n "$thumb_flag"; then
1702         LDFLAGS="$LDFLAGS $thumb_flag"
1703     fi
1706 AC_SUBST(MOZ_THUMB2)
1708 if test "$CPU_ARCH" = "arm"; then
1709   AC_MSG_CHECKING(for ARM SIMD support in compiler)
1710   # We try to link so that this also fails when
1711   # building with LTO.
1712   AC_TRY_LINK([],
1713                  [asm("uqadd8 r1, r1, r2");],
1714                  result="yes", result="no")
1715   AC_MSG_RESULT("$result")
1716   if test "$result" = "yes"; then
1717       AC_DEFINE(HAVE_ARM_SIMD)
1718       HAVE_ARM_SIMD=1
1719   fi
1721   AC_MSG_CHECKING(for ARM NEON support in compiler)
1722   # We try to link so that this also fails when
1723   # building with LTO.
1724   AC_TRY_LINK([],
1725                  [asm(".fpu neon\n vadd.i8 d0, d0, d0");],
1726                  result="yes", result="no")
1727   AC_MSG_RESULT("$result")
1728   if test "$result" = "yes"; then
1729       AC_DEFINE(HAVE_ARM_NEON)
1730       HAVE_ARM_NEON=1
1731   fi
1732 fi # CPU_ARCH = arm
1734 AC_SUBST(HAVE_ARM_SIMD)
1735 AC_SUBST(HAVE_ARM_NEON)
1737 dnl =================================================================
1738 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1739 dnl which is bad when cross compiling.
1740 dnl =================================================================
1741 if test "$COMPILE_ENVIRONMENT"; then
1742 configure_static_assert_macros='
1743 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1744 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1745 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1748 dnl test that the macros actually work:
1749 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1750 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1751  [AC_LANG_SAVE
1752   AC_LANG_C
1753   ac_cv_static_assertion_macros_work="yes"
1754   AC_TRY_COMPILE([$configure_static_assert_macros],
1755                  [CONFIGURE_STATIC_ASSERT(1)],
1756                  ,
1757                  ac_cv_static_assertion_macros_work="no")
1758   AC_TRY_COMPILE([$configure_static_assert_macros],
1759                  [CONFIGURE_STATIC_ASSERT(0)],
1760                  ac_cv_static_assertion_macros_work="no",
1761                  )
1762   AC_LANG_CPLUSPLUS
1763   AC_TRY_COMPILE([$configure_static_assert_macros],
1764                  [CONFIGURE_STATIC_ASSERT(1)],
1765                  ,
1766                  ac_cv_static_assertion_macros_work="no")
1767   AC_TRY_COMPILE([$configure_static_assert_macros],
1768                  [CONFIGURE_STATIC_ASSERT(0)],
1769                  ac_cv_static_assertion_macros_work="no",
1770                  )
1771   AC_LANG_RESTORE
1772  ])
1773 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1774 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1775     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1777 fi # COMPILE_ENVIRONMENT
1779 dnl ========================================================
1780 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1781 dnl computed above.
1782 dnl ========================================================
1784 if test "$OS_TARGET" = "Android"; then
1785     case "${CPU_ARCH}-${MOZ_ARCH}" in
1786     arm-armv7*)
1787       ANDROID_CPU_ARCH=armeabi-v7a
1788       ;;
1789     arm-*)
1790       ANDROID_CPU_ARCH=armeabi
1791       ;;
1792     x86-*)
1793       ANDROID_CPU_ARCH=x86
1794       ;;
1795     esac
1797     if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
1798        if test ! -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a" ; then
1799           AC_MSG_ERROR([Cannot find path to libstdc++ (NDK version >= 5?)])
1800        fi
1801        STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include -D_GLIBCXX_PERMIT_BACKWARD_HASH"
1802        STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH"
1803        STLPORT_LIBS="-lstdc++"
1804     elif test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
1805        STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
1806        STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
1807        STLPORT_LIBS="-lstlport_static"
1808     elif  test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
1809        STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
1810        STLPORT_LDFLAGS="-L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH"
1811        STLPORT_LIBS="-lstlport_static"
1812     elif test "$target" != "arm-android-eabi"; then
1813        dnl fail if we're not building with NDKr4
1814        AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
1815     fi
1816     CPPFLAGS="$CPPFLAGS $STLPORT_CPPFLAGS"
1817     LDFLAGS="$LDFLAGS $STLPORT_LDFLAGS"
1818     LIBS="$LIBS $STLPORT_LIBS"
1821 dnl ========================================================
1822 dnl GNU specific defaults
1823 dnl ========================================================
1824 if test "$GNU_CC"; then
1825     # FIXME: Let us build with strict aliasing. bug 414641.
1826     CFLAGS="$CFLAGS -fno-strict-aliasing"
1827     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1828     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1829     DSO_LDOPTS='-shared'
1830     if test "$GCC_USE_GNU_LD"; then
1831         # Don't allow undefined symbols in libraries
1832         DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1833     fi
1834     WARNINGS_AS_ERRORS='-Werror -Wno-error=uninitialized'
1835     DSO_CFLAGS=''
1836     DSO_PIC_CFLAGS='-fPIC'
1837     ASFLAGS="$ASFLAGS -fPIC"
1838     _MOZ_RTTI_FLAGS_ON=-frtti
1839     _MOZ_RTTI_FLAGS_OFF=-fno-rtti
1841     # Turn on GNU specific features
1842     # -Wall - turn on all warnings
1843     # -pedantic - make compiler warn about non-ANSI stuff, and
1844     #             be a little bit stricter
1845     # -Wdeclaration-after-statement - MSVC doesn't like these
1846     # Warnings slamm took out for now (these were giving more noise than help):
1847     # -Wbad-function-cast - warns when casting a function to a new return type
1848     # -Wshadow - removed because it generates more noise than help --pete
1849     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith -Wdeclaration-after-statement"
1850     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1851        # Don't use -Wcast-align with ICC or clang
1852        case "$CPU_ARCH" in
1853            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1854            hppa | ia64 | sparc | arm)
1855            ;;
1856            *)
1857         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1858            ;;
1859        esac
1860     fi
1862     dnl Turn pedantic on but disable the warnings for long long
1863     _PEDANTIC=1
1865     if test -z "$INTEL_CC"; then
1866       _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
1867     fi
1869     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1870     _USE_CPP_INCLUDE_FLAG=1
1871 elif test "$SOLARIS_SUNPRO_CC"; then
1872     DSO_CFLAGS=''
1873     if test "$CPU_ARCH" = "sparc"; then
1874         # for Sun Studio on Solaris/SPARC
1875         DSO_PIC_CFLAGS='-xcode=pic32'
1876     else
1877         DSO_PIC_CFLAGS='-KPIC'
1878     fi
1879     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1880 else
1881     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1882     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1884     DSO_LDOPTS='-shared'
1885     if test "$GNU_LD"; then
1886         # Don't allow undefined symbols in libraries
1887         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1888     fi
1890     DSO_CFLAGS=''
1891     DSO_PIC_CFLAGS='-KPIC'
1892     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1895 if test "$GNU_CXX"; then
1896     # FIXME: Let us build with strict aliasing. bug 414641.
1897     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1898     # Turn on GNU specific features
1899     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
1900     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1901        # Don't use -Wcast-align with ICC or clang
1902        case "$CPU_ARCH" in
1903            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1904            hppa | ia64 | sparc | arm)
1905            ;;
1906            *)
1907         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1908            ;;
1909        esac
1910     fi
1912     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1913     _USE_CPP_INCLUDE_FLAG=1
1915     # Recent clang and gcc support C++11 deleted functions without warnings if
1916     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1917     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1918     # unused.  But clang's warning can be disabled, so when compiling with clang
1919     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1920     # deleted function syntax.
1921     if test "$CLANG_CXX"; then
1922         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1923     fi
1925     AC_CACHE_CHECK(whether the compiler supports -Wno-extended-offsetof,
1926                    ac_has_wno_extended_offsetof,
1927         [
1928             AC_LANG_SAVE
1929             AC_LANG_CPLUSPLUS
1930             _SAVE_CXXFLAGS="$CXXFLAGS"
1931             CXXFLAGS="$CXXFLAGS -Wno-extended-offsetof"
1932             AC_TRY_COMPILE([$configure_static_assert_macros
1933                             #ifndef __has_warning
1934                             #define __has_warning(x) 0
1935                             #endif],
1936                            [CONFIGURE_STATIC_ASSERT(__has_warning("-Wextended-offsetof"))],
1937                            ac_has_wno_extended_offsetof="yes",
1938                            ac_has_wno_extended_offsetof="no")
1939             CXXFLAGS="$_SAVE_CXXFLAGS"
1940             AC_LANG_RESTORE
1941         ])
1942     if test "$ac_has_wno_extended_offsetof" = "yes"; then
1943         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-extended-offsetof"
1944     fi
1946     AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
1947                    ac_has_wno_invalid_offsetof,
1948         [
1949             AC_LANG_SAVE
1950             AC_LANG_CPLUSPLUS
1951             _SAVE_CXXFLAGS="$CXXFLAGS"
1952             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
1953             AC_TRY_COMPILE([],
1954                            [return(0);],
1955                            ac_has_wno_invalid_offsetof="yes",
1956                            ac_has_wno_invalid_offsetof="no")
1957             CXXFLAGS="$_SAVE_CXXFLAGS"
1958             AC_LANG_RESTORE
1959         ])
1960     if test "$ac_has_wno_invalid_offsetof" = "yes"; then
1961         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
1962     fi
1964     AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
1965                    ac_has_wno_variadic_macros,
1966         [
1967             AC_LANG_SAVE
1968             AC_LANG_CPLUSPLUS
1969             _SAVE_CXXFLAGS="$CXXFLAGS"
1970             CXXFLAGS="$CXXFLAGS -Wno-variadic-macros"
1971             AC_TRY_COMPILE([],
1972                            [return(0);],
1973                            ac_has_wno_variadic_macros="yes",
1974                            ac_has_wno_variadic_macros="no")
1975             CXXFLAGS="$_SAVE_CXXFLAGS"
1976             AC_LANG_RESTORE
1977         ])
1978     if test "$ac_has_wno_variadic_macros" = "yes"; then
1979         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-variadic-macros"
1980     fi
1982     AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
1983                    ac_has_werror_return_type,
1984         [
1985             AC_LANG_SAVE
1986             AC_LANG_CPLUSPLUS
1987             _SAVE_CXXFLAGS="$CXXFLAGS"
1988             CXXFLAGS="$CXXFLAGS -Werror=return-type"
1989             AC_TRY_COMPILE([],
1990                            [return(0);],
1991                            ac_has_werror_return_type="yes",
1992                            ac_has_werror_return_type="no")
1993             CXXFLAGS="$_SAVE_CXXFLAGS"
1994             AC_LANG_RESTORE
1995         ])
1996     if test "$ac_has_werror_return_type" = "yes"; then
1997         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
1998     fi
2000 else
2001     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
2004 dnl gcc can come with its own linker so it is better to use the pass-thru calls
2005 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
2006 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
2007 dnl normal behavior.
2008 dnl ========================================================
2009 MKSHLIB_FORCE_ALL=
2010 MKSHLIB_UNFORCE_ALL=
2012 if test "$COMPILE_ENVIRONMENT"; then
2013 if test "$GNU_CC"; then
2014   AC_MSG_CHECKING(whether ld has archive extraction flags)
2015   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
2016    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
2017     ac_cv_mkshlib_force_and_unforce="no"
2018     exec 3<&0 <<LOOP_INPUT
2019         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
2020         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
2021         force="-Wl,-all";              unforce="-Wl,-none"
2022 LOOP_INPUT
2023     while read line
2024     do
2025       eval $line
2026       LDFLAGS=$force
2027       LIBS=$unforce
2028       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
2029     done
2030     exec 0<&3 3<&-
2031     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
2032    ])
2033   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
2034     AC_MSG_RESULT(no)
2035   else
2036     AC_MSG_RESULT(yes)
2037     eval $ac_cv_mkshlib_force_and_unforce
2038     MKSHLIB_FORCE_ALL=$force
2039     MKSHLIB_UNFORCE_ALL=$unforce
2040   fi
2041 fi # GNU_CC
2042 fi # COMPILE_ENVIRONMENT
2044 dnl ========================================================
2045 dnl Checking for 64-bit OS
2046 dnl ========================================================
2047 if test "$COMPILE_ENVIRONMENT"; then
2048 AC_LANG_SAVE
2049 AC_LANG_C
2050 AC_MSG_CHECKING(for 64-bit OS)
2051 AC_TRY_COMPILE([$configure_static_assert_macros],
2052                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
2053                result="yes", result="no")
2054 AC_MSG_RESULT("$result")
2055 if test "$result" = "yes"; then
2056     AC_DEFINE(HAVE_64BIT_OS)
2057     HAVE_64BIT_OS=1
2059 AC_SUBST(HAVE_64BIT_OS)
2060 AC_LANG_RESTORE
2061 fi # COMPILE_ENVIRONMENT
2063 dnl ========================================================
2064 dnl Enable high-memory support on OS/2 by default.
2065 dnl ========================================================
2066 MOZ_OS2_HIGH_MEMORY=1
2067 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
2068 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
2069     MOZ_OS2_HIGH_MEMORY=,
2070     MOZ_OS2_HIGH_MEMORY=1 )
2071 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
2073 dnl ========================================================
2074 dnl = Use profiling compile flags
2075 dnl ========================================================
2076 MOZ_ARG_ENABLE_BOOL(profiling,
2077 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
2078     MOZ_PROFILING=1,
2079     MOZ_PROFILING= )
2081 dnl ========================================================
2082 dnl = Use Valgrind
2083 dnl ========================================================
2084 MOZ_ARG_ENABLE_BOOL(valgrind,
2085 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
2086     MOZ_VALGRIND=1,
2087     MOZ_VALGRIND= )
2088 if test -n "$MOZ_VALGRIND"; then
2089     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
2090         AC_MSG_ERROR(
2091             [--enable-valgrind specified but Valgrind is not installed]))
2092     AC_DEFINE(MOZ_VALGRIND)
2094 AC_SUBST(MOZ_VALGRIND)
2096 dnl ========================================================
2097 dnl = Use DMD
2098 dnl ========================================================
2099 MOZ_ARG_ENABLE_BOOL(dmd,
2100 [  --enable-dmd            Enable DMD; also disables jemalloc (default=no)],
2101     MOZ_DMD=1,
2102     MOZ_DMD= )
2103 if test -n "$MOZ_DMD"; then
2104     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
2105         AC_MSG_ERROR(
2106             [--enable-dmd specified but Valgrind is not installed]))
2107     AC_DEFINE(MOZ_DMD)
2109 AC_SUBST(MOZ_DMD)
2111 dnl ========================================================
2112 dnl jprof
2113 dnl ========================================================
2114 MOZ_ARG_ENABLE_BOOL(jprof,
2115 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
2116     MOZ_JPROF=1,
2117     MOZ_JPROF= )
2118 if test -n "$MOZ_JPROF"; then
2119     MOZ_PROFILING=1
2120     AC_DEFINE(MOZ_JPROF)
2123 dnl ========================================================
2124 dnl SPS Profiler
2125 dnl ========================================================
2126 MOZ_ARG_ENABLE_BOOL(sps,
2127 [  --enable-sps          Enable sps profiling tool.],
2128     MOZ_ENABLE_PROFILER_SPS=1,
2129     MOZ_ENABLE_PROFILER_SPS= )
2130 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
2131     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
2134 dnl ========================================================
2135 dnl shark
2136 dnl ========================================================
2137 MOZ_ARG_ENABLE_BOOL(shark,
2138 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
2139     MOZ_SHARK=1,
2140     MOZ_SHARK= )
2141 if test -n "$MOZ_SHARK"; then
2142     MOZ_PROFILING=1
2143     AC_DEFINE(MOZ_SHARK)
2146 dnl ========================================================
2147 dnl callgrind
2148 dnl ========================================================
2149 MOZ_ARG_ENABLE_BOOL(callgrind,
2150 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
2151     MOZ_CALLGRIND=1,
2152     MOZ_CALLGRIND= )
2153 if test -n "$MOZ_CALLGRIND"; then
2154     MOZ_PROFILING=1
2155     AC_DEFINE(MOZ_CALLGRIND)
2158 dnl ========================================================
2159 dnl vtune
2160 dnl ========================================================
2161 MOZ_ARG_ENABLE_BOOL(vtune,
2162 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
2163     MOZ_VTUNE=1,
2164     MOZ_VTUNE= )
2165 if test -n "$MOZ_VTUNE"; then
2166     MOZ_PROFILING=1
2167     AC_DEFINE(MOZ_VTUNE)
2170 dnl ========================================================
2171 dnl Profiling
2172 dnl ========================================================
2173 if test -n "$MOZ_PROFILING"; then
2174     AC_DEFINE(MOZ_PROFILING)
2177 dnl ========================================================
2178 dnl System overrides of the defaults for host
2179 dnl ========================================================
2180 case "$host" in
2181 *mingw*)
2182     if test -n "$_WIN32_MSVC"; then
2183         HOST_AR=lib
2184         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
2185         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
2186         HOST_RANLIB='echo ranlib'
2187     else
2188         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
2189     fi
2190     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
2191     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
2192     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
2193     HOST_BIN_SUFFIX=.exe
2194     case "$host" in
2195     *mingw*)
2196         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
2197         ;;
2198     esac
2200     case "${host_cpu}" in
2201     x86_64)
2202         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
2203         ;;
2204     esac
2205     ;;
2207 *-darwin*)
2208     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
2209     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2210     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
2211     ;;
2213 *-linux*|*-kfreebsd*-gnu|*-gnu*)
2214     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
2215     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2216     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
2217     ;;
2219 *os2*)
2220     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
2221     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2222     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
2223     HOST_BIN_SUFFIX=.exe
2224     MOZ_FIX_LINK_PATHS=
2225     ;;
2228     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
2229     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
2230     ;;
2231 esac
2233 dnl We require version 2.5 or newer of Python to build.
2234 AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION but not 3.x])
2235 changequote(,)
2236 $PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
2237 _python_res=$?
2238 changequote([,])
2239 if test "$_python_res" != 0; then
2240     AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
2242 AC_MSG_RESULT([yes])
2244 dnl Check for using a custom <stdint.h> implementation
2245 dnl ========================================================
2246 AC_MSG_CHECKING(for custom <stdint.h> implementation)
2247 if test "$MOZ_CUSTOM_STDINT_H"; then
2248   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
2249   AC_SUBST(MOZ_CUSTOM_STDINT_H)
2250   AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
2251 else
2252   AC_MSG_RESULT(none specified)
2255 dnl Get mozilla version from central milestone file
2256 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
2258 dnl Get version of various core apps from the version files.
2259 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
2261 if test -z "$FIREFOX_VERSION"; then
2262     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
2265 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
2266 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
2268 MOZ_DOING_LTO(lto_is_enabled)
2270 dnl ========================================================
2271 dnl System overrides of the defaults for target
2272 dnl ========================================================
2274 case "$target" in
2275 *-aix*)
2276     AC_DEFINE(AIX)
2277     if test ! "$GNU_CC"; then
2278         if test ! "$HAVE_64BIT_OS"; then
2279             # Compiling with Visual Age C++ object model compat is the
2280             # default. To compile with object model ibm, add
2281             # AIX_OBJMODEL=ibm to .mozconfig.
2282             if test "$AIX_OBJMODEL" = "ibm"; then
2283                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
2284             else
2285                 AIX_OBJMODEL=compat
2286             fi
2287         else
2288             AIX_OBJMODEL=compat
2289         fi
2290         AC_SUBST(AIX_OBJMODEL)
2291         DSO_LDOPTS='-qmkshrobj=1'
2292         DSO_CFLAGS='-qflag=w:w'
2293         DSO_PIC_CFLAGS=
2294         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
2295         MOZ_FIX_LINK_PATHS=
2296         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2297         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2298         if test "$COMPILE_ENVIRONMENT"; then
2299             AC_LANG_SAVE
2300             AC_LANG_CPLUSPLUS
2301             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
2302             AC_TRY_COMPILE([],
2303                 [#if (__IBMCPP__ < 900)
2304                  #error "Bad compiler"
2305                  #endif],
2306                 _BAD_COMPILER=,_BAD_COMPILER=1)
2307             if test -n "$_BAD_COMPILER"; then
2308                 AC_MSG_RESULT([no])
2309                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
2310             else
2311                 AC_MSG_RESULT([yes])
2312             fi
2313             AC_LANG_RESTORE
2314             TARGET_COMPILER_ABI="ibmc"
2315             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
2316             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
2317         fi
2318     fi
2319     case "${target_os}" in
2320     aix4.1*)
2321         DLL_SUFFIX='_shr.a'
2322         ;;
2323     esac
2324     if test "$COMPILE_ENVIRONMENT"; then
2325         MOZ_CHECK_HEADERS(sys/inttypes.h)
2326     fi
2327     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2328     ;;
2330 *-bsdi*)
2331     dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
2332     _PEDANTIC=
2333     case $OS_RELEASE in
2334         4.*|5.*)
2335             STRIP="$STRIP -d"
2336             ;;
2337         *)
2338             DSO_CFLAGS=''
2339             DSO_LDOPTS='-r'
2340             _WARNINGS_CFLAGS="-Wall"
2341             _WARNINGS_CXXFLAGS="-Wall"
2342             # The test above doesn't work properly, at least on 3.1.
2343             MKSHLIB_FORCE_ALL=''
2344             MKSHLIB_UNFORCE_ALL=''
2345         ;;
2346     esac
2347     ;;
2349 *-darwin*)
2350     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2351     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2352     MOZ_OPTIMIZE_FLAGS="-O3"
2353     _PEDANTIC=
2354     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
2355     if test "$HAVE_64BIT_OS"; then
2356         MOZ_MEMORY=1
2357     fi
2358     CFLAGS="$CFLAGS -fno-common"
2359     CXXFLAGS="$CXXFLAGS -fno-common"
2360     DLL_SUFFIX=".dylib"
2361     DSO_LDOPTS=''
2362     STRIP="$STRIP -x -S"
2363     # Check whether we're targeting OS X or iOS
2364     AC_CACHE_CHECK(for iOS target,
2365                    ac_cv_ios_target,
2366                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
2367 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
2368 #error not iOS
2369 #endif],
2370                                    [],
2371                                    ac_cv_ios_target="yes",
2372                                    ac_cv_ios_target="no")])
2373     if test "$ac_cv_ios_target" = "yes"; then
2374         AC_DEFINE(XP_IOS)
2375         AC_DEFINE(XP_DARWIN)
2376         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
2377     else
2378         AC_DEFINE(XP_MACOSX)
2379         AC_DEFINE(XP_DARWIN)
2380         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
2381         # The ExceptionHandling framework is needed for Objective-C exception
2382         # logging code in nsObjCExceptions.h. Currently we only use that in debug
2383         # builds.
2384         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
2385     fi
2386     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2389     if test "x$lto_is_enabled" = "xyes"; then
2390         echo "Skipping -dead_strip because lto is enabled."
2391     dnl DTrace and -dead_strip don't interact well. See bug 403132.
2392     dnl ===================================================================
2393     elif test "x$enable_dtrace" = "xyes"; then
2394         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
2395     else
2396         dnl check for the presence of the -dead_strip linker flag
2397         AC_MSG_CHECKING([for -dead_strip option to ld])
2398         _SAVE_LDFLAGS=$LDFLAGS
2399         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
2400         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
2401         if test -n "$_HAVE_DEAD_STRIP" ; then
2402             AC_MSG_RESULT([yes])
2403             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
2404         else
2405             AC_MSG_RESULT([no])
2406         fi
2408         LDFLAGS=$_SAVE_LDFLAGS
2409     fi
2410     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
2411     ;;
2413 *-freebsd*)
2414     if test `test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` != "elf"; then
2415         DLL_SUFFIX=".so.1.0"
2416         DSO_LDOPTS="-shared"
2417     fi
2418     if test ! "$GNU_CC"; then
2419         DSO_LDOPTS="-Bshareable $DSO_LDOPTS"
2420     fi
2421     ;;
2423 ia64*-hpux*)
2424     DLL_SUFFIX=".so"
2425     if test ! "$GNU_CC"; then
2426        DSO_LDOPTS='-b'
2427        DSO_CFLAGS=""
2428        DSO_PIC_CFLAGS=
2429        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2430        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2431        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2432     else
2433        DSO_LDOPTS='-b -E'
2434        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2435        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2436     fi
2437     MOZ_FIX_LINK_PATHS=
2438     SYSTEM_MAKEDEPEND=
2439     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2440     AC_DEFINE(_LARGEFILE64_SOURCE)
2441     ;;
2443 *-hpux*)
2444     DLL_SUFFIX=".sl"
2445     if test ! "$GNU_CC"; then
2446         DSO_LDOPTS='-b -Wl,+s'
2447         DSO_CFLAGS=""
2448         DSO_PIC_CFLAGS="+Z"
2449         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2450         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2451         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2452     else
2453         DSO_LDOPTS='-b -E +s'
2454         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2455         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2456     fi
2457     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2458     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2459     ;;
2461 *-android*|*-linuxandroid*)
2462     AC_DEFINE(NO_PW_GECOS)
2463     no_x=yes
2464     if test -n "$gonkdir"; then
2465         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2466     else
2467         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2468         MOZ_LINKER=1
2469     fi
2470     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2472     MOZ_GFX_OPTIMIZE_MOBILE=1
2473     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2474     ;;
2476 *-*linux*)
2477     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2478     # Similarly for GNU_CXX and INTEL_CXX.
2479     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2480         # -Os has been broken on Intel's C/C++ compilers for quite a
2481         # while; Intel recommends against using it.
2482         MOZ_OPTIMIZE_FLAGS="-O2"
2483         MOZ_DEBUG_FLAGS="-g"
2484     elif test "$GNU_CC" -o "$GNU_CXX"; then
2485         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2486         case $GCC_VERSION in
2487         4.1.*|4.2.*|4.5.*)
2488             # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
2489             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2490         esac
2491         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2492         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2493         MOZ_DEBUG_FLAGS="-g"
2494     fi
2496     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2498     MOZ_MEMORY=1
2500     case "${target_cpu}" in
2501     alpha*)
2502         CFLAGS="$CFLAGS -mieee"
2503         CXXFLAGS="$CXXFLAGS -mieee"
2504     ;;
2505     i*86)
2506         USE_ELF_DYNSTR_GC=1
2507     ;;
2508     mips*)
2509         MOZ_DEBUG_FLAGS="-g" # We want inlining
2510     ;;
2511     esac
2513     if test -z "$MC"; then
2514         MC=mc.exe
2515     fi
2516     ;;
2517 *-mingw*)
2518     DSO_CFLAGS=
2519     DSO_PIC_CFLAGS=
2520     DLL_SUFFIX=.dll
2521     RC=rc.exe
2522     MC=mc.exe
2523     # certain versions of cygwin's makedepend barf on the
2524     # #include <string> vs -I./dist/include/string issue so don't use it
2525     SYSTEM_MAKEDEPEND=
2526     if test -n "$GNU_CC"; then
2527         CC="$CC -mwindows"
2528         CXX="$CXX -mwindows"
2529         CPP="$CPP -mwindows"
2530         CFLAGS="$CFLAGS -mms-bitfields"
2531         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2532         DSO_LDOPTS='-shared'
2533         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2534         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2535         RC='$(WINDRES)'
2536         # Use temp file for windres (bug 213281)
2537         RCFLAGS='-O coff --use-temp-file'
2538         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2539         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv"
2540         MOZ_FIX_LINK_PATHS=
2541         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2542         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2543         DLL_PREFIX=
2544         IMPORT_LIB_SUFFIX=dll.a
2545         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2546     else
2547         TARGET_COMPILER_ABI=msvc
2548         HOST_CC='$(CC)'
2549         HOST_CXX='$(CXX)'
2550         HOST_LD='$(LD)'
2551         if test "$AS_BIN"; then
2552             AS="$(basename "$AS_BIN")"
2553         fi
2554         AR='lib'
2555         AR_FLAGS='-NOLOGO -OUT:"$@"'
2556         AR_EXTRACT=
2557         RANLIB='echo not_ranlib'
2558         STRIP='echo not_strip'
2559         PKG_SKIP_STRIP=1
2560         XARGS=xargs
2561         ZIP=zip
2562         UNZIP=unzip
2563         DOXYGEN=:
2564         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
2565         ASM_SUFFIX=asm
2566         OBJ_SUFFIX=obj
2567         LIB_SUFFIX=lib
2568         DLL_PREFIX=
2569         LIB_PREFIX=
2570         IMPORT_LIB_SUFFIX=lib
2571         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2572         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2573         MKSHLIB_FORCE_ALL=
2574         MKSHLIB_UNFORCE_ALL=
2575         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2576         _USE_CPP_INCLUDE_FLAG=1
2577         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2578         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2579         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2580         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2581         CXXFLAGS="$CXXFLAGS -wd4800" # disable warning "forcing value to bool"
2582         # make 'foo == bar;' error out
2583         CFLAGS="$CFLAGS -we4553"
2584         CXXFLAGS="$CXXFLAGS -we4553"
2585         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
2586         MOZ_DEBUG_FLAGS='-Zi'
2587         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2588         WARNINGS_AS_ERRORS='-WX'
2589         MOZ_OPTIMIZE_FLAGS='-O1'
2590         MOZ_FIX_LINK_PATHS=
2591         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2592         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2593         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2594         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2595         if test $_MSC_VER -ge 1400; then
2596             LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2597             dnl For profile-guided optimization
2598             PROFILE_GEN_CFLAGS="-GL"
2599             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2600             dnl XXX: PGO builds can fail with warnings treated as errors,
2601             dnl specifically "no profile data available" appears to be
2602             dnl treated as an error sometimes. This might be a consequence
2603             dnl of using WARNINGS_AS_ERRORS in some modules, combined
2604             dnl with the linker doing most of the work in the whole-program
2605             dnl optimization/PGO case. I think it's probably a compiler bug,
2606             dnl but we work around it here.
2607             PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2608             dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2609             dnl Probably also a compiler bug, but what can you do?
2610             PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2611             LDFLAGS="$LDFLAGS -DYNAMICBASE"
2612         fi
2613     fi
2614     MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg32$(VERSION_NUMBER),$(DEPTH)/media/libjpeg)'
2615     MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,png,$(DEPTH)/media/libpng)'
2616     AC_DEFINE(HAVE_SNPRINTF)
2617     AC_DEFINE(_WINDOWS)
2618     AC_DEFINE(WIN32)
2619     AC_DEFINE(XP_WIN)
2620     AC_DEFINE(XP_WIN32)
2621     AC_DEFINE(HW_THREADS)
2622     AC_DEFINE(STDC_HEADERS)
2623     AC_DEFINE(NEW_H, <new>)
2624     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2625     TARGET_MD_ARCH=win32
2626     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2627     BIN_SUFFIX='.exe'
2628     MOZ_USER_DIR="Mozilla"
2630     dnl Hardcode to win95 for now - cls
2631     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2633     dnl set NO_X11 defines here as the general check is skipped on win32
2634     no_x=yes
2635     AC_DEFINE(NO_X11)
2637     case "$host" in
2638     *-mingw*)
2639         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2640         ;;
2641     esac
2643     case "$host" in
2644     *-mingw*)
2645         if test -z "$MOZ_TOOLS"; then
2646             AC_MSG_ERROR([MOZ_TOOLS is not set])
2647         fi
2648         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2649         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2650             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2651         fi
2652         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2653         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2654             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2655         fi
2656         ;;
2657     esac
2659     case "$host_os" in
2660     cygwin*|msvc*|mks*)
2661         AC_MSG_ERROR([Using a Cygwin build environment is unsupported. Configure cannot check for presence of necessary headers. Please upgrade to MozillaBuild; see https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
2662         ;;
2663     esac
2665     case "$target" in
2666     i*86-*)
2667         if test "$HAVE_64BIT_OS"; then
2668             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2669         fi
2671         if test $_MSC_VER -ge 1400; then
2672             LDFLAGS="$LDFLAGS -SAFESEH"
2673         fi
2675         if test -n "$GNU_CC"; then
2676             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2677             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2678         else
2679             AC_DEFINE(HAVE_STDCALL)
2680         fi
2682         MOZ_CHECK_HEADERS(mmintrin.h)
2683         AC_DEFINE(_X86_)
2684         ;;
2685     x86_64-*)
2686         AC_DEFINE(_AMD64_)
2687         ;;
2688     *)
2689         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2690         ;;
2691     esac
2693     if test "$HAVE_64BIT_OS"; then
2694         AC_DEFINE(_WIN64)
2695     fi
2696     ;;
2698 *-netbsd*)
2699     DSO_CFLAGS=''
2700     CFLAGS="$CFLAGS -Dunix"
2701     CXXFLAGS="$CXXFLAGS -Dunix"
2702     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2703         DLL_SUFFIX=".so"
2704         DSO_PIC_CFLAGS='-fPIC -DPIC'
2705         DSO_LDOPTS='-shared'
2706         BIN_FLAGS='-Wl,--export-dynamic'
2707     else
2708         DSO_PIC_CFLAGS='-fPIC -DPIC'
2709         DLL_SUFFIX=".so.1.0"
2710         DSO_LDOPTS='-shared'
2711     fi
2712     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2713     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2714     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2715     if test "$LIBRUNPATH"; then
2716         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2717     fi
2718     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2719     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2720     ;;
2722 *-openbsd*)
2723     if test "$SO_VERSION"; then
2724         DLL_SUFFIX=".so.$SO_VERSION"
2725     else
2726         DLL_SUFFIX=".so.1.0"
2727     fi
2728     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2729     DSO_CFLAGS=''
2730     DSO_PIC_CFLAGS='-fPIC'
2731     DSO_LDOPTS='-shared -fPIC'
2732     if test "$LIBRUNPATH"; then
2733         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2734     fi
2735     ;;
2737 *-os2*)
2738     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2739     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2740     AC_DEFINE(OS2)
2741     AC_DEFINE(XP_OS2)
2742     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2743     AC_DEFINE(TCPV40HDRS)
2744     DLL_PREFIX=
2745     LIB_PREFIX=
2746     LIB_SUFFIX=lib
2747     BIN_SUFFIX=".exe"
2748     DLL_SUFFIX=".dll"
2749     IMPORT_LIB_SUFFIX=lib
2750     DSO_PIC_CFLAGS=
2751     AR=emxomfar
2752     AR_FLAGS='r $@'
2753     CFLAGS="$CFLAGS -Zomf"
2754     CXXFLAGS="$CXXFLAGS -Zomf"
2755     DSO_LDOPTS='-Zdll'
2756     BIN_FLAGS='-Zlinker /ST:0x100000'
2757     IMPLIB='emximp -o'
2758     FILTER='true'
2759     LDFLAGS='-Zmap'
2760     WARNINGS_AS_ERRORS='-Werror'
2761     MOZ_DEBUG_FLAGS="-g -fno-inline"
2762     MOZ_OPTIMIZE_FLAGS="-O2"
2763     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2764     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2765     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2766     TARGET_MD_ARCH=os2
2767     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2768     RC=rc.exe
2769     MC=mc.exe
2770     RCFLAGS='-n'
2771     MOZ_USER_DIR="Mozilla"
2772     ZIP="$ZIP -X"
2774     if test "$MOZTOOLS"; then
2775         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2776     else
2777         AC_MSG_ERROR([MOZTOOLS is not set])
2778     fi
2779     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2780         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2781         LDFLAGS="$LDFLAGS -Zhigh-mem"
2782         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2783         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2784     fi
2786     # GCC for OS/2 currently predefines these, but we don't want them
2787     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2788     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2790     AC_CACHE_CHECK(for __declspec(dllexport),
2791         ac_os2_declspec,
2792         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2793                         [return 0;],
2794                         ac_os2_declspec="yes",
2795                         ac_os2_declspec="no")])
2796     if test "$ac_os2_declspec" != "yes"; then
2797         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2798     fi
2799     ;;
2801 *-solaris*)
2802     AC_DEFINE(SOLARIS)
2803     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2804     SYSTEM_MAKEDEPEND=
2805     MOZ_FIX_LINK_PATHS=
2806     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2807     # libraries one level up (e.g. libnspr4.so)
2808     if test "$SOLARIS_SUNPRO_CC"; then
2809        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2810        LIBS="-lCrun -lCstd -lc $LIBS"
2811        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2812        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2813        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2814        LDFLAGS="-xildoff $LDFLAGS"
2815        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2816            _SAVE_LDFLAGS=$LDFLAGS
2817            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2818            AC_TRY_LINK([#include <stdio.h>],
2819                        [printf("Hello World\n");],
2820                        ,
2821                        [LDFLAGS=$_SAVE_LDFLAGS])
2822        fi
2823        MOZ_OPTIMIZE_FLAGS="-xO4"
2824        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2825        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2826        MKSHLIB_FORCE_ALL='-z allextract'
2827        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2828        DSO_LDOPTS='-G'
2829        AR_LIST="$AR t"
2830        AR_EXTRACT="$AR x"
2831        AR_DELETE="$AR d"
2832        AR='$(CXX) -xar'
2833        AR_FLAGS='-o $@'
2834        AS='/usr/ccs/bin/as'
2835        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2836        AS_DASH_C_FLAG=''
2837        TARGET_COMPILER_ABI="sunc"
2838        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2839        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2840        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2841        AC_LANG_SAVE
2842        AC_LANG_CPLUSPLUS
2843        AC_TRY_COMPILE([],
2844            [#if (__SUNPRO_CC < 0x590)
2845            #error "Denied"
2846            #endif],
2847            _BAD_COMPILER=,_BAD_COMPILER=1)
2848        if test -n "$_BAD_COMPILER"; then
2849            _res="no"
2850            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2851        else
2852            _res="yes"
2853        fi
2854        AC_TRY_COMPILE([],
2855            [#if (__SUNPRO_CC >= 0x5100)
2856            #error "Sun C++ 5.10 or above"
2857            #endif],
2858            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2859        if test "$_ABOVE_SS12U1"; then
2860            # disable xannotate
2861            CXXFLAGS="$CXXFLAGS -xannotate=no"
2862        fi
2863        AC_MSG_RESULT([$_res])
2864        AC_LANG_RESTORE
2865     else
2866        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2867        LIBS="-lc $LIBS"
2868        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2869        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2870        ASFLAGS="$ASFLAGS -fPIC"
2871        DSO_LDOPTS='-shared'
2872        WARNINGS_AS_ERRORS='-Werror'
2873        _WARNINGS_CFLAGS=''
2874        _WARNINGS_CXXFLAGS=''
2875        if test "$OS_RELEASE" = "5.3"; then
2876            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2877        fi
2878     fi
2879     if test "$OS_RELEASE" = "5.5.1"; then
2880         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2881     fi
2882     ;;
2884 *-sunos*)
2885     DSO_LDOPTS='-Bdynamic'
2886     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2887     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2888     AC_DEFINE(SUNOS4)
2889     AC_DEFINE(SPRINTF_RETURNS_STRING)
2890     case "$(target_os)" in
2891     sunos4.1*)
2892         DLL_SUFFIX='.so.1.0'
2893         ;;
2894     esac
2895     ;;
2897 *-os2*)
2898     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2899     ;;
2901 esac
2903 AC_SUBST(MOZ_LINKER)
2905 dnl Only one oddball right now (QNX), but this gives us flexibility
2906 dnl if any other platforms need to override this in the future.
2907 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2909 dnl ========================================================
2910 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2911 dnl by now will not have any way to link most binaries (tests
2912 dnl as well as viewer, apprunner, etc.), because some symbols
2913 dnl will be left out of the "composite" .so's by ld as unneeded.
2914 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2915 dnl they can link in the static libs that provide the missing
2916 dnl symbols.
2917 dnl ========================================================
2918 NO_LD_ARCHIVE_FLAGS=
2919 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2920     NO_LD_ARCHIVE_FLAGS=1
2922 case "$target" in
2923 *-os2*)
2924     NO_LD_ARCHIVE_FLAGS=
2925     ;;
2926 *-aix4.3*|*-aix5*)
2927     NO_LD_ARCHIVE_FLAGS=
2928     ;;
2929 *-mingw*)
2930     if test -z "$GNU_CC"; then
2931         NO_LD_ARCHIVE_FLAGS=
2932     fi
2933     ;;
2934 esac
2935 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2937 dnl ========================================================
2938 dnl = Flags to strip unused symbols from .so components and
2939 dnl = to export jemalloc symbols when linking a program
2940 dnl ========================================================
2941 case "$target" in
2942     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2943         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2944         ;;
2945     *-solaris*)
2946         if test -z "$GNU_CC"; then
2947          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2948         else
2949          if test -z "$GCC_USE_GNU_LD"; then
2950           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2951          else
2952           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2953          fi
2954         fi
2955         ;;
2956     *-darwin*)
2957         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2958         ;;
2959     *-mingw*)
2960         if test -n "$GNU_CC"; then
2961            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2962         fi
2963         ;;
2964 esac
2966 if test -z "$COMPILE_ENVIRONMENT"; then
2967     SKIP_COMPILER_CHECKS=1
2968     SKIP_LIBRARY_CHECKS=1
2971 if test -z "$SKIP_COMPILER_CHECKS"; then
2972 dnl Checks for typedefs, structures, and compiler characteristics.
2973 dnl ========================================================
2974 AC_HEADER_STDC
2975 AC_C_CONST
2976 AC_TYPE_MODE_T
2977 AC_TYPE_OFF_T
2978 AC_TYPE_PID_T
2979 AC_TYPE_SIZE_T
2980 AC_LANG_CPLUSPLUS
2981 AC_MSG_CHECKING(for __stdcall)
2982 AC_CACHE_VAL(ac_cv___stdcall,
2983  [AC_TRY_COMPILE([template <typename Method> struct foo;
2984                   template <> struct foo<void (*)()> {};
2985                   template <> struct foo<void (__stdcall*)()> {};],
2986                  [],
2987                  [ac_cv___stdcall=true],
2988                  [ac_cv___stdcall=false])])
2989 if test "$ac_cv___stdcall" = true ; then
2990   AC_DEFINE(HAVE_STDCALL)
2991   AC_MSG_RESULT(yes)
2992 else
2993   AC_MSG_RESULT(no)
2995 AC_LANG_C
2996 AC_MSG_CHECKING(for ssize_t)
2997 AC_CACHE_VAL(ac_cv_type_ssize_t,
2998  [AC_TRY_COMPILE([#include <stdio.h>
2999                   #include <sys/types.h>],
3000                  [ssize_t foo = 0;],
3001                  [ac_cv_type_ssize_t=true],
3002                  [ac_cv_type_ssize_t=false])])
3003 if test "$ac_cv_type_ssize_t" = true ; then
3004   AC_DEFINE(HAVE_SSIZE_T)
3005   AC_MSG_RESULT(yes)
3006 else
3007   AC_MSG_RESULT(no)
3009 AC_STRUCT_ST_BLKSIZE
3010 AC_MSG_CHECKING(for siginfo_t)
3011 AC_CACHE_VAL(ac_cv_siginfo_t,
3012  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
3013                   #include <signal.h>],
3014                  [siginfo_t* info;],
3015                  [ac_cv_siginfo_t=true],
3016                  [ac_cv_siginfo_t=false])])
3017 if test "$ac_cv_siginfo_t" = true ; then
3018   AC_DEFINE(HAVE_SIGINFO_T)
3019   AC_MSG_RESULT(yes)
3020 else
3021   AC_MSG_RESULT(no)
3024 dnl Check for int64, uint, and uint_t.
3025 dnl ========================================================
3026 AC_MSG_CHECKING(for int64)
3027 AC_CACHE_VAL(ac_cv_int64,
3028  [AC_TRY_COMPILE([#include <stdio.h>
3029                   #include <sys/types.h>],
3030                  [int64 foo = 0;],
3031                  [ac_cv_int64=true],
3032                  [ac_cv_int64=false])])
3033 if test "$ac_cv_int64" = true ; then
3034   AC_DEFINE(HAVE_INT64)
3035   AC_MSG_RESULT(yes)
3036 else
3037   AC_MSG_RESULT(no)
3039 AC_MSG_CHECKING(for uint)
3040 AC_CACHE_VAL(ac_cv_uint,
3041  [AC_TRY_COMPILE([#include <stdio.h>
3042                   #include <sys/types.h>],
3043                  [uint foo = 0;],
3044                  [ac_cv_uint=true],
3045                  [ac_cv_uint=false])])
3046 if test "$ac_cv_uint" = true ; then
3047   AC_DEFINE(HAVE_UINT)
3048   AC_MSG_RESULT(yes)
3049 else
3050   AC_MSG_RESULT(no)
3052 AC_MSG_CHECKING(for uint_t)
3053 AC_CACHE_VAL(ac_cv_uint_t,
3054  [AC_TRY_COMPILE([#include <stdio.h>
3055                   #include <sys/types.h>],
3056                  [uint_t foo = 0;],
3057                  [ac_cv_uint_t=true],
3058                  [ac_cv_uint_t=false])])
3059 if test "$ac_cv_uint_t" = true ; then
3060   AC_DEFINE(HAVE_UINT_T)
3061   AC_MSG_RESULT(yes)
3062 else
3063   AC_MSG_RESULT(no)
3066 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
3067 dnl are defined when compiling C++ but not C.  Since the result of this
3068 dnl test is used only in C++, do it in C++.
3069 AC_LANG_CPLUSPLUS
3071 AC_MSG_CHECKING(for uname.domainname)
3072 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
3073     [AC_TRY_COMPILE([#include <sys/utsname.h>],
3074         [ struct utsname *res; char *domain;
3075             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
3076         [ac_cv_have_uname_domainname_field=true],
3077         [ac_cv_have_uname_domainname_field=false])])
3079 if test "$ac_cv_have_uname_domainname_field" = "true"; then
3080     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
3081     AC_MSG_RESULT(yes)
3082 else
3083     AC_MSG_RESULT(no)
3086 AC_MSG_CHECKING(for uname.__domainname)
3087 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
3088     [AC_TRY_COMPILE([#include <sys/utsname.h>],
3089         [ struct utsname *res; char *domain;
3090             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
3091         [ac_cv_have_uname_us_domainname_field=true],
3092         [ac_cv_have_uname_us_domainname_field=false])])
3094 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
3095     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
3096     AC_MSG_RESULT(yes)
3097 else
3098     AC_MSG_RESULT(no)
3101 dnl ========================================================
3102 dnl C++ rtti
3103 dnl Should be smarter and check that the compiler does indeed have rtti
3104 dnl ========================================================
3106 MOZ_ARG_ENABLE_BOOL(cpp-rtti,
3107 [  --enable-cpp-rtti       Enable C++ RTTI ],
3108 [ _MOZ_USE_RTTI=1 ],
3109 [ _MOZ_USE_RTTI= ])
3111 if test "$_MOZ_USE_RTTI"; then
3112    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_ON
3113 else
3114    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_OFF
3117 AC_SUBST(_MOZ_RTTI_FLAGS_ON)
3119 dnl Check whether we can use gcc's c++0x mode
3120 AC_LANG_CPLUSPLUS
3122 if test "$GNU_CXX"; then
3123     _SAVE_CXXFLAGS=$CXXFLAGS
3124     CXXFLAGS="$CXXFLAGS -std=gnu++0x"
3126     if test -z "$_MOZ_USE_RTTI"; then
3127         CXXFLAGS="$CXXFLAGS $_MOZ_RTTI_FLAGS"
3128         AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
3129             ac_cv_cxx0x_headers_bug,
3130             [AC_TRY_COMPILE([#include <memory>], [],
3131                             ac_cv_cxx0x_headers_bug="no",
3132                             ac_cv_cxx0x_headers_bug="yes")])
3133         CXXFLAGS="$_SAVE_CXXFLAGS"
3134         if test "$ac_cv_cxx0x_headers_bug" = "no"; then
3135             CXXFLAGS="$CXXFLAGS -std=gnu++0x"
3136         fi
3137     fi
3140 dnl Check for usable char16_t (2 bytes, unsigned)
3141 dnl (we might not need the unsignedness check anymore)
3142 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
3143     ac_cv_have_usable_char16_t,
3144     [AC_TRY_COMPILE([$configure_static_assert_macros],
3145                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
3146                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
3147                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
3148                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
3149                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
3150                     ac_cv_have_usable_char16_t="yes",
3151                     ac_cv_have_usable_char16_t="no")])
3152 if test "$ac_cv_have_usable_char16_t" = "yes"; then
3153     AC_DEFINE(HAVE_CPP_CHAR16_T)
3154     HAVE_CPP_CHAR16_T=1
3155 elif test "$GNU_CXX"; then
3156     CXXFLAGS="$_SAVE_CXXFLAGS"
3159 dnl Check for usable wchar_t (2 bytes, unsigned)
3160 dnl (we really don't need the unsignedness check anymore)
3161 dnl ========================================================
3163 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
3164     ac_cv_have_usable_wchar_v2,
3165     [AC_TRY_COMPILE([#include <stddef.h>
3166                      $configure_static_assert_macros],
3167                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
3168                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
3169                     ac_cv_have_usable_wchar_v2="yes",
3170                     ac_cv_have_usable_wchar_v2="no")])
3171 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
3172     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
3173     HAVE_CPP_2BYTE_WCHAR_T=1
3174 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
3175 dnl This is really gcc-only
3176 dnl Do this test using CXX only since some versions of gcc
3177 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
3178 dnl only have short-wchar support for c++.
3179 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
3181     _SAVE_CXXFLAGS=$CXXFLAGS
3182     CXXFLAGS="$CXXFLAGS -fshort-wchar"
3184     AC_CACHE_CHECK(for compiler -fshort-wchar option,
3185         ac_cv_have_usable_wchar_option_v2,
3186         [AC_TRY_LINK([#include <stddef.h>
3187                       $configure_static_assert_macros],
3188                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
3189                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
3190                      ac_cv_have_usable_wchar_option_v2="yes",
3191                      ac_cv_have_usable_wchar_option_v2="no")])
3193     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
3194         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
3195         HAVE_CPP_2BYTE_WCHAR_T=1
3196         if test "$OS_TARGET" = Android; then
3197             WCHAR_CFLAGS="-fshort-wchar -Wl,--no-wchar-size-warning"
3198             CXXFLAGS="$CXXFLAGS -Wl,--no-wchar-size-warning"
3199             CFLAGS="$CFLAGS -Wl,--no-wchar-size-warning"
3200             DSO_LDOPTS="$DSO_LDOPTS -Wl,--no-wchar-size-warning"
3201         else
3202             WCHAR_CFLAGS="-fshort-wchar"
3203         fi
3204     else
3205         CXXFLAGS=$_SAVE_CXXFLAGS
3206     fi
3209 AC_LANG_C
3211 dnl Check for .hidden assembler directive and visibility attribute.
3212 dnl Borrowed from glibc configure.in
3213 dnl ===============================================================
3214 if test "$GNU_CC"; then
3215   AC_CACHE_CHECK(for visibility(hidden) attribute,
3216                  ac_cv_visibility_hidden,
3217                  [cat > conftest.c <<EOF
3218                   int foo __attribute__ ((visibility ("hidden"))) = 1;
3220                   ac_cv_visibility_hidden=no
3221                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3222                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3223                       ac_cv_visibility_hidden=yes
3224                     fi
3225                   fi
3226                   rm -f conftest.[cs]
3227                  ])
3228   if test "$ac_cv_visibility_hidden" = "yes"; then
3229     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
3231     AC_CACHE_CHECK(for visibility(default) attribute,
3232                    ac_cv_visibility_default,
3233                    [cat > conftest.c <<EOF
3234                     int foo __attribute__ ((visibility ("default"))) = 1;
3236                     ac_cv_visibility_default=no
3237                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3238                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3239                         ac_cv_visibility_default=yes
3240                       fi
3241                     fi
3242                     rm -f conftest.[cs]
3243                    ])
3244     if test "$ac_cv_visibility_default" = "yes"; then
3245       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
3247       AC_CACHE_CHECK(for visibility pragma support,
3248                      ac_cv_visibility_pragma,
3249                      [cat > conftest.c <<EOF
3250 #pragma GCC visibility push(hidden)
3251                       int foo_hidden = 1;
3252 #pragma GCC visibility push(default)
3253                       int foo_default = 1;
3255                       ac_cv_visibility_pragma=no
3256                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3257                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
3258                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
3259                             ac_cv_visibility_pragma=yes
3260                           fi
3261                         fi
3262                       fi
3263                       rm -f conftest.[cs]
3264                     ])
3265       if test "$ac_cv_visibility_pragma" = "yes"; then
3266         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
3267                        ac_cv_have_visibility_class_bug,
3268                        [cat > conftest.c <<EOF
3269 #pragma GCC visibility push(hidden)
3270 struct __attribute__ ((visibility ("default"))) TestStruct {
3271   static void Init();
3273 __attribute__ ((visibility ("default"))) void TestFunc() {
3274   TestStruct::Init();
3277                        ac_cv_have_visibility_class_bug=no
3278                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3279                          ac_cv_have_visibility_class_bug=yes
3280                        else
3281                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
3282                            ac_cv_have_visibility_class_bug=yes
3283                          fi
3284                        fi
3285                        rm -rf conftest.{c,S}
3286                        ])
3288         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
3289                        ac_cv_have_visibility_builtin_bug,
3290                        [cat > conftest.c <<EOF
3291 #pragma GCC visibility push(hidden)
3292 #pragma GCC visibility push(default)
3293 #include <string.h>
3294 #pragma GCC visibility pop
3296 __attribute__ ((visibility ("default"))) void Func() {
3297   char c[[100]];
3298   memset(c, 0, sizeof(c));
3301                        ac_cv_have_visibility_builtin_bug=no
3302                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3303                          ac_cv_have_visibility_builtin_bug=yes
3304                        else
3305                          if test `grep -c "@PLT" conftest.S` = 0; then
3306                            ac_cv_visibility_builtin_bug=yes
3307                          fi
3308                        fi
3309                        rm -f conftest.{c,S}
3310                        ])
3311         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
3312                 "$ac_cv_have_visibility_class_bug" = "no"; then
3313           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
3314           WRAP_SYSTEM_INCLUDES=1
3315           STL_FLAGS='-I$(DIST)/stl_wrappers'
3316           WRAP_STL_INCLUDES=1
3317         else
3318           VISIBILITY_FLAGS='-fvisibility=hidden'
3319         fi # have visibility pragma bug
3320       fi   # have visibility pragma
3321     fi     # have visibility(default) attribute
3322   fi       # have visibility(hidden) attribute
3323 fi         # GNU_CC
3325 # visibility hidden flag for Sun Studio on Solaris
3326 if test "$SOLARIS_SUNPRO_CC"; then
3327 VISIBILITY_FLAGS='-xldscope=hidden'
3328 fi         # Sun Studio on Solaris
3330 AC_SUBST(WRAP_SYSTEM_INCLUDES)
3331 AC_SUBST(VISIBILITY_FLAGS)
3333 MOZ_GCC_PR49911
3335 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
3336 dnl ========================================================
3337 if test "$GNU_CC"; then
3338   CFLAGS_save="${CFLAGS}"
3339   CFLAGS="${CFLAGS} -Werror"
3340   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
3341                  ac_cv_force_align_arg_pointer,
3342                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
3343                                  [],
3344                                  ac_cv_force_align_arg_pointer="yes",
3345                                  ac_cv_force_align_arg_pointer="no")])
3346   CFLAGS="${CFLAGS_save}"
3347   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
3348     HAVE_GCC_ALIGN_ARG_POINTER=1
3349   else
3350     HAVE_GCC_ALIGN_ARG_POINTER=
3351   fi
3353 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
3355 dnl Checks for header files.
3356 dnl ========================================================
3357 AC_HEADER_DIRENT
3358 case "$target_os" in
3359 freebsd*|openbsd*)
3360 # for stuff like -lXshm
3361     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
3362     ;;
3363 esac
3364 MOZ_CHECK_COMMON_HEADERS
3366 dnl These are all the places some variant of statfs can be hiding.
3367 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
3369 dnl Quota support
3370 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
3371 MOZ_CHECK_HEADERS(linux/quota.h)
3373 dnl Try for MMX support
3374 dnl NB - later gcc versions require -mmmx for this header to be successfully
3375 dnl included (or another option which implies it, such as -march=pentium-mmx)
3376 MOZ_CHECK_HEADERS(mmintrin.h)
3378 dnl Check whether the compiler supports the new-style C++ standard
3379 dnl library headers (i.e. <new>) or needs the old "new.h"
3380 AC_LANG_CPLUSPLUS
3381 NEW_H=new.h
3382 MOZ_CHECK_HEADER(new, [NEW_H=new])
3383 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3384 AC_LANG_C
3386 AC_ARG_ENABLE(dtrace,
3387               [  --enable-dtrace         build with dtrace support if available (default=no)],
3388               [enable_dtrace="yes"],)
3389 if test "x$enable_dtrace" = "xyes"; then
3390   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3391   if test -n "$HAVE_DTRACE"; then
3392       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3393   else
3394       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3395   fi
3397 AC_SUBST(HAVE_DTRACE)
3399 case $target in
3400 *-aix4.3*|*-aix5*)
3401         ;;
3403         MOZ_CHECK_HEADERS(sys/cdefs.h)
3404         ;;
3405 esac
3407 dnl Checks for libraries.
3408 dnl ========================================================
3409 case $target in
3410 *-hpux11.*)
3411         ;;
3413         AC_CHECK_LIB(c_r, gethostbyname_r)
3414         ;;
3415 esac
3417 dnl We don't want to link with libdl even if it's present on OS X, since
3418 dnl it's not used and not part of the default installation. OS/2 has dlfcn
3419 dnl in libc.
3420 dnl We don't want to link against libm or libpthread on Darwin since
3421 dnl they both are just symlinks to libSystem and explicitly linking
3422 dnl against libSystem causes issues when debugging (see bug 299601).
3423 case $target in
3424 *-darwin*)
3425     ;;
3426 *-os2*)
3427     ;;
3429     AC_SEARCH_LIBS(dlopen, dl,
3430         MOZ_CHECK_HEADER(dlfcn.h,
3431         AC_DEFINE(HAVE_DLOPEN)))
3432     ;;
3433 esac
3435 _SAVE_CFLAGS="$CFLAGS"
3436 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3437 AC_CHECK_FUNCS(dladdr memmem)
3438 CFLAGS="$_SAVE_CFLAGS"
3440 if test ! "$GNU_CXX"; then
3442     case $target in
3443     *-aix*)
3444         AC_CHECK_LIB(C_r, demangle)
3445         ;;
3446      *)
3447         AC_CHECK_LIB(C, demangle)
3448         ;;
3449      esac
3452 dnl OS/2 has socket in libc.
3453 case $target in
3454 *-os2*)
3455     ;;
3457     AC_CHECK_LIB(socket, socket)
3458 esac
3460 XLDFLAGS="$X_LIBS"
3461 XLIBS="$X_EXTRA_LIBS"
3463 dnl ========================================================
3464 dnl Checks for X libraries.
3465 dnl Ordering is important.
3466 dnl Xt is dependent upon SM as of X11R6
3467 dnl ========================================================
3468 if test "$no_x" = "yes"; then
3469     AC_DEFINE(NO_X11)
3470 else
3471     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3472         XLIBS="-lX11 $XLIBS"
3473         _SAVE_LDFLAGS="$LDFLAGS"
3474         LDFLAGS="$XLDFLAGS $LDFLAGS"
3475         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3476                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3477         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3478                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3480         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3481         unset ac_cv_lib_Xt_XtFree
3482             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3483             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
3484         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3485                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3486         ])
3488     # AIX needs the motif library linked before libXt to prevent
3489     # crashes in plugins linked against Motif - Bug #98892
3490     case "${target_os}" in
3491     aix*)
3492         XT_LIBS="-lXm $XT_LIBS"
3493         ;;
3494     esac
3496     dnl ========================================================
3497     dnl = Check for XShm
3498     dnl ========================================================
3499     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3500         $XLIBS $XEXT_LIBS)
3502     dnl ========================================================
3503     dnl = Check for Xss
3504     dnl ========================================================
3505     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
3506         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
3507             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
3508              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
3510         LDFLAGS="$_SAVE_LDFLAGS"
3512     dnl ========================================================
3513     dnl = Check for freetype2 and its functionality
3514     dnl ========================================================
3515     AC_CHECK_FT2(6.1.0, [_HAVE_FREETYPE2=1], [_HAVE_FREETYPE2=])
3517     if test "$_HAVE_FREETYPE2"; then
3518         _SAVE_LIBS="$LIBS"
3519         _SAVE_CFLAGS="$CFLAGS"
3520         LIBS="$LIBS $FT2_LIBS"
3521         CFLAGS="$CFLAGS $FT2_CFLAGS"
3523         AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
3524             ac_cv_member_FT_Bitmap_Size_y_ppem,
3525             [AC_TRY_COMPILE([#include <ft2build.h>
3526                              #include FT_FREETYPE_H],
3527                             [FT_Bitmap_Size s;
3528                              if (sizeof s.y_ppem) return 0;
3529                              return 1],
3530                             ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
3531                             ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
3532         if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
3533             HAVE_FT_BITMAP_SIZE_Y_PPEM=1
3534         else
3535             HAVE_FT_BITMAP_SIZE_Y_PPEM=0
3536         fi
3537         AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
3538                            $HAVE_FT_BITMAP_SIZE_Y_PPEM,
3539                            [FT_Bitmap_Size structure includes y_ppem field])
3541         AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
3543         LIBS="$_SAVE_LIBS"
3544         CFLAGS="$_SAVE_CFLAGS"
3545     fi
3547 fi # $no_x
3549 AC_SUBST(XCFLAGS)
3550 AC_SUBST(XLDFLAGS)
3551 AC_SUBST(XLIBS)
3552 AC_SUBST(XEXT_LIBS)
3553 AC_SUBST(XT_LIBS)
3554 AC_SUBST(XSS_LIBS)
3556 dnl ========================================================
3557 dnl = pthread support
3558 dnl = Start by checking whether the system support pthreads
3559 dnl ========================================================
3560 case "$target_os" in
3561 darwin*)
3562     USE_PTHREADS=1
3563     ;;
3565     MOZ_CHECK_PTHREADS(pthreads,
3566         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3567         MOZ_CHECK_PTHREADS(pthread,
3568             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3569             MOZ_CHECK_PTHREADS(c_r,
3570                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3571                 MOZ_CHECK_PTHREADS(c,
3572                     USE_PTHREADS=1
3573                 )
3574             )
3575         )
3576     )
3577     ;;
3578 esac
3580 dnl ========================================================
3581 dnl Check the command line for --with-pthreads
3582 dnl ========================================================
3583 MOZ_ARG_WITH_BOOL(pthreads,
3584 [  --with-pthreads         Force use of system pthread library with NSPR ],
3585 [ if test "$USE_PTHREADS"x = x; then
3586     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3587 fi],
3588     USE_PTHREADS=
3589     _PTHREAD_LDFLAGS=
3592 dnl ========================================================
3593 dnl Do the platform specific pthread hackery
3594 dnl ========================================================
3595 if test "$USE_PTHREADS"x != x
3596 then
3597         dnl
3598         dnl See if -pthread is supported.
3599         dnl
3600         rm -f conftest*
3601         ac_cv_have_dash_pthread=no
3602         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3603         echo 'int main() { return 0; }' | cat > conftest.c
3604         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3605         if test $? -eq 0; then
3606                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3607                         ac_cv_have_dash_pthread=yes
3608                 case "$target_os" in
3609                 freebsd*)
3610 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3611                 ;;
3612                 *)
3613                             CFLAGS="$CFLAGS -pthread"
3614                             CXXFLAGS="$CXXFLAGS -pthread"
3615                 ;;
3616                 esac
3617                 fi
3618         fi
3619         rm -f conftest*
3620     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3622         dnl
3623         dnl See if -pthreads is supported.
3624         dnl
3625     ac_cv_have_dash_pthreads=no
3626     if test "$ac_cv_have_dash_pthread" = "no"; then
3627             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3628         echo 'int main() { return 0; }' | cat > conftest.c
3629             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3630         if test $? -eq 0; then
3631                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3632                             ac_cv_have_dash_pthreads=yes
3633                             CFLAGS="$CFLAGS -pthreads"
3634                             CXXFLAGS="$CXXFLAGS -pthreads"
3635                     fi
3636             fi
3637             rm -f conftest*
3638         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3639     fi
3641         case "$target" in
3642             *-*-freebsd*)
3643                         AC_DEFINE(_REENTRANT)
3644                         AC_DEFINE(_THREAD_SAFE)
3645                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3646                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3647                                 _PTHREAD_LDFLAGS="-pthread"
3648                         else
3649                                 _PTHREAD_LDFLAGS="-lc_r"
3650                         fi
3651                         ;;
3653             *-*-openbsd*|*-*-bsdi*)
3654                         AC_DEFINE(_REENTRANT)
3655                         AC_DEFINE(_THREAD_SAFE)
3656                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3657                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3658                 _PTHREAD_LDFLAGS="-pthread"
3659                         fi
3660                         ;;
3662             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3663                         AC_DEFINE(_REENTRANT)
3664                         ;;
3666             *-aix4.3*|*-aix5*)
3667                         AC_DEFINE(_REENTRANT)
3668                         ;;
3670             *-hpux11.*)
3671                         AC_DEFINE(_REENTRANT)
3672                         ;;
3674             *-*-solaris*)
3675                         AC_DEFINE(_REENTRANT)
3676                         if test "$SOLARIS_SUNPRO_CC"; then
3677                                 CFLAGS="$CFLAGS -mt"
3678                                 CXXFLAGS="$CXXFLAGS -mt"
3679                         fi
3680                         ;;
3681         esac
3682     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3686 dnl Checks for library functions.
3687 dnl ========================================================
3688 AC_PROG_GCC_TRADITIONAL
3689 AC_FUNC_MEMCMP
3690 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf statvfs memmove rint stat64 lstat64 truncate64 statvfs64 setbuf isatty)
3691 AC_CHECK_FUNCS(flockfile getpagesize)
3692 AC_CHECK_FUNCS(localtime_r strtok_r)
3694 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock, and -lrt
3695 _SAVE_LDFLAGS=$LDFLAGS
3696 LDFLAGS="$LDFLAGS -lrt"
3697 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC) and -lrt,
3698                ac_cv_have_clock_monotonic,
3699                [AC_TRY_LINK([#include <time.h>],
3700                             [ struct timespec ts;
3701                               clock_gettime(CLOCK_MONOTONIC, &ts); ],
3702                             ac_cv_have_clock_monotonic=yes,
3703                             ac_cv_have_clock_monotonic=no)])
3704 LDFLAGS=$_SAVE_LDFLAGS
3705 if test "$ac_cv_have_clock_monotonic" = "yes"; then
3706     HAVE_CLOCK_MONOTONIC=1
3707     REALTIME_LIBS=-lrt
3708     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3709     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3710     AC_SUBST(REALTIME_LIBS)
3713 dnl check for wcrtomb/mbrtowc
3714 dnl =======================================================================
3715 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3716 AC_LANG_SAVE
3717 AC_LANG_CPLUSPLUS
3718 AC_CACHE_CHECK(for wcrtomb,
3719     ac_cv_have_wcrtomb,
3720     [AC_TRY_LINK([#include <wchar.h>],
3721                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3722                  ac_cv_have_wcrtomb="yes",
3723                  ac_cv_have_wcrtomb="no")])
3724 if test "$ac_cv_have_wcrtomb" = "yes"; then
3725     AC_DEFINE(HAVE_WCRTOMB)
3727 AC_CACHE_CHECK(for mbrtowc,
3728     ac_cv_have_mbrtowc,
3729     [AC_TRY_LINK([#include <wchar.h>],
3730                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3731                  ac_cv_have_mbrtowc="yes",
3732                  ac_cv_have_mbrtowc="no")])
3733 if test "$ac_cv_have_mbrtowc" = "yes"; then
3734     AC_DEFINE(HAVE_MBRTOWC)
3736 AC_LANG_RESTORE
3739 AC_CACHE_CHECK(
3740     [for res_ninit()],
3741     ac_cv_func_res_ninit,
3742     [AC_TRY_LINK([
3743         #ifdef linux
3744         #define _BSD_SOURCE 1
3745         #endif
3746         #include <resolv.h>
3747         ],
3748         [int foo = res_ninit(&_res);],
3749         [ac_cv_func_res_ninit=yes],
3750         [ac_cv_func_res_ninit=no])
3751     ])
3753 if test "$ac_cv_func_res_ninit" = "yes"; then
3754     AC_DEFINE(HAVE_RES_NINIT)
3755 dnl must add the link line we do something as foolish as this... dougt
3756 dnl else
3757 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3758 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3761 AC_LANG_CPLUSPLUS
3762 AC_CACHE_CHECK(
3763     [for gnu_get_libc_version()],
3764     ac_cv_func_gnu_get_libc_version,
3765     [AC_TRY_LINK([
3766         #ifdef HAVE_GNU_LIBC_VERSION_H
3767         #include <gnu/libc-version.h>
3768         #endif
3769         ],
3770         [const char *glibc_version = gnu_get_libc_version();],
3771         [ac_cv_func_gnu_get_libc_version=yes],
3772         [ac_cv_func_gnu_get_libc_version=no]
3773         )]
3774     )
3776 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3777     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3780 case $target_os in
3781     darwin*|mingw*|os2*)
3782         ;;
3783     *)
3785 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3786     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3787         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3788 _SAVE_LIBS=$LIBS
3789 LIBS="$LIBS $_ICONV_LIBS"
3790 AC_CACHE_CHECK(
3791     [for iconv()],
3792     ac_cv_func_iconv,
3793     [AC_TRY_LINK([
3794         #include <stdlib.h>
3795         #include <iconv.h>
3796         ],
3797         [
3798             iconv_t h = iconv_open("", "");
3799             iconv(h, NULL, NULL, NULL, NULL);
3800             iconv_close(h);
3801         ],
3802         [ac_cv_func_iconv=yes],
3803         [ac_cv_func_iconv=no]
3804         )]
3805     )
3806 if test "$ac_cv_func_iconv" = "yes"; then
3807     AC_DEFINE(HAVE_ICONV)
3808     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3809     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3810     LIBICONV="$_ICONV_LIBS"
3811     AC_CACHE_CHECK(
3812         [for iconv() with const input],
3813         ac_cv_func_const_iconv,
3814         [AC_TRY_COMPILE([
3815             #include <stdlib.h>
3816             #include <iconv.h>
3817             ],
3818             [
3819                 const char *input = "testing";
3820                 iconv_t h = iconv_open("", "");
3821                 iconv(h, &input, NULL, NULL, NULL);
3822                 iconv_close(h);
3823             ],
3824             [ac_cv_func_const_iconv=yes],
3825             [ac_cv_func_const_iconv=no]
3826             )]
3827         )
3828     if test "$ac_cv_func_const_iconv" = "yes"; then
3829         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3830     fi
3832 LIBS=$_SAVE_LIBS
3834     ;;
3835 esac
3837 AM_LANGINFO_CODESET
3839 AC_LANG_C
3841 dnl **********************
3842 dnl *** va_copy checks ***
3843 dnl **********************
3844 dnl we currently check for all three va_copy possibilities, so we get
3845 dnl all results in config.log for bug reports.
3846 AC_MSG_CHECKING(for an implementation of va_copy())
3847 AC_CACHE_VAL(ac_cv_va_copy,[
3848     AC_TRY_RUN([
3849         #include <stdarg.h>
3850         void f (int i, ...) {
3851             va_list args1, args2;
3852             va_start (args1, i);
3853             va_copy (args2, args1);
3854             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3855                 exit (1);
3856             va_end (args1); va_end (args2);
3857         }
3858         int main() { f (0, 42); return 0; }],
3859         ac_cv_va_copy=yes,
3860         ac_cv_va_copy=no,
3861         ac_cv_va_copy=no
3862     )
3864 AC_MSG_RESULT($ac_cv_va_copy)
3865 AC_MSG_CHECKING(for an implementation of __va_copy())
3866 AC_CACHE_VAL(ac_cv___va_copy,[
3867     AC_TRY_RUN([
3868         #include <stdarg.h>
3869         void f (int i, ...) {
3870             va_list args1, args2;
3871             va_start (args1, i);
3872             __va_copy (args2, args1);
3873             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3874                 exit (1);
3875             va_end (args1); va_end (args2);
3876         }
3877         int main() { f (0, 42); return 0; }],
3878         ac_cv___va_copy=yes,
3879         ac_cv___va_copy=no,
3880         ac_cv___va_copy=no
3881     )
3883 AC_MSG_RESULT($ac_cv___va_copy)
3884 AC_MSG_CHECKING(whether va_lists can be copied by value)
3885 AC_CACHE_VAL(ac_cv_va_val_copy,[
3886     AC_TRY_RUN([
3887         #include <stdarg.h>
3888         void f (int i, ...) {
3889             va_list args1, args2;
3890             va_start (args1, i);
3891             args2 = args1;
3892             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3893                 exit (1);
3894             va_end (args1); va_end (args2);
3895         }
3896         int main() { f (0, 42); return 0; }],
3897         ac_cv_va_val_copy=yes,
3898         ac_cv_va_val_copy=no,
3899         ac_cv_va_val_copy=yes
3900     )
3902 if test "x$ac_cv_va_copy" = "xyes"; then
3903     AC_DEFINE(VA_COPY, va_copy)
3904     AC_DEFINE(HAVE_VA_COPY)
3905 elif test "x$ac_cv___va_copy" = "xyes"; then
3906     AC_DEFINE(VA_COPY, __va_copy)
3907     AC_DEFINE(HAVE_VA_COPY)
3910 if test "x$ac_cv_va_val_copy" = "xno"; then
3911    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3913 AC_MSG_RESULT($ac_cv_va_val_copy)
3915 dnl ===================================================================
3916 dnl ========================================================
3917 dnl Put your C++ language/feature checks below
3918 dnl ========================================================
3919 AC_LANG_CPLUSPLUS
3921 ARM_ABI_PREFIX=
3922 if test "$GNU_CC"; then
3923   if test "$CPU_ARCH" = "arm" ; then
3924     AC_CACHE_CHECK(for ARM EABI,
3925         ac_cv_gcc_arm_eabi,
3926         [AC_TRY_COMPILE([],
3927                         [
3928 #if defined(__ARM_EABI__)
3929   return 0;
3930 #else
3931 #error Not ARM EABI.
3932 #endif
3933                         ],
3934                         ac_cv_gcc_arm_eabi="yes",
3935                         ac_cv_gcc_arm_eabi="no")])
3936     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3937         HAVE_ARM_EABI=1
3938         ARM_ABI_PREFIX=eabi-
3939     else
3940         ARM_ABI_PREFIX=oabi-
3941     fi
3942   fi
3944   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3947 dnl Check for support of modern template specialization syntax
3948 dnl Test code and requirement from scc@netscape.com.
3949 dnl Autoconf cut-and-paste job by waterson@netscape.com
3950 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
3951                ac_cv_cpp_modern_specialize_template_syntax,
3952                [AC_TRY_COMPILE(template <class T> struct X { int a; };
3953                                class Y {};
3954                                template <> struct X<Y> { double a; };,
3955                                X<int> int_x;
3956                                X<Y> y_x;,
3957                                ac_cv_cpp_modern_specialize_template_syntax=yes,
3958                                ac_cv_cpp_modern_specialize_template_syntax=no)])
3959 if test "$ac_cv_cpp_modern_specialize_template_syntax" = no ; then
3960   AC_MSG_ERROR([The C++ compiler does not support template specialization])
3963 dnl Some compilers support only full specialization, and some don't.
3964 AC_CACHE_CHECK(whether partial template specialization works,
3965                ac_cv_cpp_partial_specialization,
3966                [AC_TRY_COMPILE(template <class T> class Foo {};
3967                                template <class T> class Foo<T*> {};,
3968                                return 0;,
3969                                ac_cv_cpp_partial_specialization=yes,
3970                                ac_cv_cpp_partial_specialization=no)])
3971 if test "$ac_cv_cpp_partial_specialization" = yes ; then
3972   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
3975 dnl Check to see if we can resolve ambiguity with |using|.
3976 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3977                ac_cv_cpp_ambiguity_resolving_using,
3978                [AC_TRY_COMPILE(class X {
3979                                  public: int go(const X&) {return 3;}
3980                                          int jo(const X&) {return 3;}
3981                                };
3982                                class Y : public X {
3983                                  public:  int go(int) {return 2;}
3984                                           int jo(int) {return 2;}
3985                                           using X::jo;
3986                                  private: using X::go;
3987                                };,
3988                                X x; Y y; y.jo(x);,
3989                                ac_cv_cpp_ambiguity_resolving_using=yes,
3990                                ac_cv_cpp_ambiguity_resolving_using=no)])
3991 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3992    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3995 dnl See if a dynamic_cast to void* gives the most derived object.
3996 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3997                ac_cv_cpp_dynamic_cast_void_ptr,
3998                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3999                             class Y { int j; public: virtual ~Y() { } };
4000                             class Z : public X, public Y { int k; };
4002                             int main() {
4003                                  Z mdo;
4004                                  X *subx = (X*)&mdo;
4005                                  Y *suby = (Y*)&mdo;
4006                                  return !((((void*)&mdo != (void*)subx) &&
4007                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
4008                                           (((void*)&mdo != (void*)suby) &&
4009                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
4010                             }],
4011                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
4012                            ac_cv_cpp_dynamic_cast_void_ptr=no,
4013                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
4014 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
4015    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
4019 dnl note that this one is reversed - if the test fails, then
4020 dnl we require implementations of unused virtual methods. Which
4021 dnl really blows because it means we'll have useless vtable
4022 dnl bloat.
4023 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
4024                ac_cv_cpp_unused_required,
4025                [AC_TRY_LINK(class X {private: virtual void never_called();};,
4026                                X x;,
4027                                ac_cv_cpp_unused_required=no,
4028                                ac_cv_cpp_unused_required=yes)])
4029 if test "$ac_cv_cpp_unused_required" = yes ; then
4030    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
4034 dnl Some compilers have trouble comparing a constant reference to a templatized
4035 dnl class to zero, and require an explicit operator==() to be defined that takes
4036 dnl an int. This test separates the strong from the weak.
4038 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
4039                ac_cv_trouble_comparing_to_zero,
4040                [AC_TRY_COMPILE([#include <algorithm>
4041                                 template <class T> class Foo {};
4042                                 class T2;
4043                                 template <class T> int operator==(const T2*, const T&) { return 0; }
4044                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
4045                                [Foo<int> f; return (0 != f);],
4046                                ac_cv_trouble_comparing_to_zero=no,
4047                                ac_cv_trouble_comparing_to_zero=yes)])
4048 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
4049   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
4052 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
4053 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
4054 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
4055 # linking XUL.
4056 _SAVE_LDFLAGS=$LDFLAGS
4057 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
4058 AC_CACHE_CHECK(for __thread keyword for TLS variables,
4059                ac_cv_thread_keyword,
4060                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
4061                             [return tlsIsMainThread;],
4062                             ac_cv_thread_keyword=yes,
4063                             ac_cv_thread_keyword=no)])
4064 LDFLAGS=$_SAVE_LDFLAGS
4065 # The custom dynamic linker doesn't support TLS variables
4066 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
4067   # mips builds fail with TLS variables because of a binutils bug.
4068   # See bug 528687
4069   case "${target}" in
4070     mips*-*)
4071       :
4072       ;;
4073     *-android*|*-linuxandroid*)
4074       :
4075       ;;
4076     *)
4077       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
4078       ;;
4079   esac
4082 dnl Check for the existence of various allocation headers/functions
4084 MALLOC_H=
4085 MOZ_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
4086 if test "$MALLOC_H" = ""; then
4087   MOZ_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
4088   if test "$MALLOC_H" = ""; then
4089     MOZ_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
4090   fi
4092 if test "$MALLOC_H" != ""; then
4093    AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
4096 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
4097 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
4099 dnl See if compiler supports some gcc-style attributes
4101 AC_CACHE_CHECK(for __attribute__((always_inline)),
4102                ac_cv_attribute_always_inline,
4103                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
4104                                [],
4105                                ac_cv_attribute_always_inline=yes,
4106                                ac_cv_attribute_always_inline=no)])
4108 AC_CACHE_CHECK(for __attribute__((malloc)),
4109                ac_cv_attribute_malloc,
4110                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
4111                                [],
4112                                ac_cv_attribute_malloc=yes,
4113                                ac_cv_attribute_malloc=no)])
4115 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
4116                ac_cv_attribute_warn_unused,
4117                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
4118                                [],
4119                                ac_cv_attribute_warn_unused=yes,
4120                                ac_cv_attribute_warn_unused=no)])
4122 dnl End of C++ language/feature checks
4123 AC_LANG_C
4125 dnl ========================================================
4126 dnl =  Internationalization checks
4127 dnl ========================================================
4129 dnl Internationalization and Locale support is different
4130 dnl on various UNIX platforms.  Checks for specific i18n
4131 dnl features go here.
4133 dnl check for LC_MESSAGES
4134 AC_CACHE_CHECK(for LC_MESSAGES,
4135                 ac_cv_i18n_lc_messages,
4136                 [AC_TRY_COMPILE([#include <locale.h>],
4137                                 [int category = LC_MESSAGES;],
4138                                 ac_cv_i18n_lc_messages=yes,
4139                                 ac_cv_i18n_lc_messages=no)])
4140 if test "$ac_cv_i18n_lc_messages" = yes; then
4141    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
4144 AC_HAVE_FUNCS(localeconv)
4145 fi # ! SKIP_COMPILER_CHECKS
4147 TARGET_XPCOM_ABI=
4148 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
4149     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
4152 dnl Mozilla specific options
4153 dnl ========================================================
4154 dnl The macros used for command line options
4155 dnl are defined in build/autoconf/altoptions.m4.
4157 dnl If the compiler supports these attributes, define them as
4158 dnl convenience macros.
4159 if test "$ac_cv_attribute_always_inline" = yes ; then
4160   AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
4161 else
4162   AC_DEFINE(NS_ALWAYS_INLINE,)
4165 if test "$ac_cv_attribute_malloc" = yes ; then
4166   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
4167 else
4168   AC_DEFINE(NS_ATTR_MALLOC,)
4171 if test "$ac_cv_attribute_warn_unused" = yes ; then
4172   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
4173 else
4174   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
4177 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
4178 dnl features that Windows actually does support.
4180 if test -n "$SKIP_COMPILER_CHECKS"; then
4181    dnl Windows has malloc.h
4182    AC_DEFINE(MALLOC_H, [<malloc.h>])
4183    AC_DEFINE(HAVE_FORCEINLINE)
4184    AC_DEFINE(HAVE_LOCALECONV)
4185 fi # SKIP_COMPILER_CHECKS
4187 dnl ========================================================
4188 dnl =
4189 dnl = Check for external package dependencies
4190 dnl =
4191 dnl ========================================================
4192 MOZ_ARG_HEADER(External Packages)
4194 MOZ_ARG_WITH_STRING(libxul-sdk,
4195 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
4196   LIBXUL_SDK_DIR=$withval)
4198 if test "$LIBXUL_SDK_DIR" = "yes"; then
4199     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
4200 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
4201     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
4203     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
4204         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
4205     fi
4208 AC_SUBST(LIBXUL_SDK)
4210 if test -n "$LIBXUL_SDK"; then
4211     LIBXUL_DIST="$LIBXUL_SDK"
4212 else
4213     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
4215 AC_SUBST(LIBXUL_DIST)
4217 SYSTEM_LIBXUL=
4219 MOZ_ARG_WITH_BOOL(system-libxul,
4220 [  --with-system-libxul    Use system installed libxul SDK],
4221     SYSTEM_LIBXUL=1)
4223 dnl ========================================================
4224 dnl = If NSPR was not detected in the system,
4225 dnl = use the one in the source tree (mozilla/nsprpub)
4226 dnl ========================================================
4227 MOZ_ARG_WITH_BOOL(system-nspr,
4228 [  --with-system-nspr      Use system installed NSPR],
4229     _USE_SYSTEM_NSPR=1 )
4231 if test -n "$_USE_SYSTEM_NSPR"; then
4232     AM_PATH_NSPR(4.9.0, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
4235 if test -n "$MOZ_NATIVE_NSPR"; then
4236     _SAVE_CFLAGS=$CFLAGS
4237     CFLAGS="$CFLAGS $NSPR_CFLAGS"
4238     AC_TRY_COMPILE([#include "prtypes.h"],
4239                 [#ifndef PR_STATIC_ASSERT
4240                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
4241                  #endif],
4242                 [MOZ_NATIVE_NSPR=1],
4243                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
4244     AC_TRY_COMPILE([#include "prtypes.h"],
4245                 [#ifndef PR_UINT64
4246                  #error PR_UINT64 not defined or requires including prtypes.h
4247                  #endif],
4248                 [MOZ_NATIVE_NSPR=1],
4249                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
4250     CFLAGS=$_SAVE_CFLAGS
4251 else
4252     if test "$OS_ARCH" = "WINNT"; then
4253         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
4254         if test -n "$GNU_CC"; then
4255             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
4256         else
4257             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
4258         fi
4259     else
4260         NSPR_CFLAGS='`$(LIBXUL_DIST)/sdk/bin/nspr-config --prefix='${LIBXUL_DIST}' --includedir='${LIBXUL_DIST}'/include/nspr --cflags`'
4261         NSPR_LIBS='`$(LIBXUL_DIST)/sdk/bin/nspr-config --prefix='${LIBXUL_DIST}' --libdir='${LIBXUL_DIST}'/lib --libs`'
4262     fi
4265 dnl system libevent Support
4266 dnl ========================================================
4267 MOZ_ARG_WITH_STRING(system-libevent,
4268 [  --with-system-libevent=[PFX]
4269                           Use system libevent [installed at prefix PFX]],
4270     LIBEVENT_DIR=$withval)
4272 _SAVE_CFLAGS=$CFLAGS
4273 _SAVE_LDFLAGS=$LDFLAGS
4274 _SAVE_LIBS=$LIBS
4275 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
4276     MOZ_NATIVE_LIBEVENT=
4277 else
4278     if test "${LIBEVENT_DIR}" = "yes"; then
4279         LIBEVENT_DIR=/usr
4280     fi
4281     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
4282     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
4283     MOZ_CHECK_HEADER(event.h,
4284         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
4285              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
4286          fi],
4287         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
4288     AC_CHECK_LIB(event, event_init,
4289                  [MOZ_NATIVE_LIBEVENT=1
4290                   MOZ_LIBEVENT_INCLUDES="${LIBEVENT_DIR}/include"
4291                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
4292                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_INCLUDES= MOZ_LIBEVENT_LIBS=])
4294 CFLAGS=$_SAVE_CFLAGS
4295 LDFLAGS=$_SAVE_LDFLAGS
4296 LIBS=$_SAVE_LIBS
4298 AC_SUBST(MOZ_NATIVE_LIBEVENT)
4299 AC_SUBST(MOZ_LIBEVENT_INCLUDES)
4300 AC_SUBST(MOZ_LIBEVENT_LIBS)
4302 dnl ========================================================
4303 dnl = If NSS was not detected in the system,
4304 dnl = use the one in the source tree (mozilla/security/nss)
4305 dnl ========================================================
4307 MOZ_ARG_WITH_BOOL(system-nss,
4308 [  --with-system-nss       Use system installed NSS],
4309     _USE_SYSTEM_NSS=1 )
4311 if test -n "$_USE_SYSTEM_NSS"; then
4312     AM_PATH_NSS(3.13.2, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
4315 if test -n "$MOZ_NATIVE_NSS"; then
4316    NSS_LIBS="$NSS_LIBS -lcrmf"
4317 else
4318    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
4319    NSS_DEP_LIBS="\
4320         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
4321         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)smime$NSS_VERSION\$(DLL_SUFFIX) \
4322         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)ssl$NSS_VERSION\$(DLL_SUFFIX) \
4323         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nss$NSS_VERSION\$(DLL_SUFFIX) \
4324         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nssutil$NSS_VERSION\$(DLL_SUFFIX)"
4326    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
4327        NSS_LIBS="\
4328         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
4329         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
4330         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
4331         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
4332         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
4333    else
4334        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
4335    fi
4338 dnl ======================
4339 dnl Detect yasm
4340 dnl ======================
4342 AC_MSG_CHECKING([for YASM assembler])
4343 AC_CHECK_PROGS(YASM, yasm, "")
4345 if test -n "$YASM"; then
4346   dnl Pull out yasm's version string
4347   changequote(,)
4348   _YASM_VER_FILTER='s|.* \([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\).*|\1|p'
4349   changequote([,])
4351   YASM_VERSION=`yasm --version | sed -ne "$_YASM_VER_FILTER"`
4352   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
4353   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
4354   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
4355   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
4358 if test -z "$SKIP_LIBRARY_CHECKS"; then
4359 dnl system JPEG support
4360 dnl ========================================================
4361 MOZ_ARG_WITH_STRING(system-jpeg,
4362 [  --with-system-jpeg[=PFX]
4363                           Use system libjpeg [installed at prefix PFX]],
4364     JPEG_DIR=$withval)
4366 _SAVE_CFLAGS=$CFLAGS
4367 _SAVE_LDFLAGS=$LDFLAGS
4368 _SAVE_LIBS=$LIBS
4369 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
4370     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
4371     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
4373 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
4374     SYSTEM_JPEG=
4375 else
4376     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [SYSTEM_JPEG=1 JPEG_LIBS="-ljpeg $JPEG_LIBS"], SYSTEM_JPEG=, $JPEG_LIBS)
4379 if test "$SYSTEM_JPEG" = 1; then
4380     LIBS="$JPEG_LIBS $LIBS"
4381     AC_TRY_COMPILE([ #include <stdio.h>
4382                      #include <sys/types.h>
4383                      #include <jpeglib.h> ],
4384                    [ #if JPEG_LIB_VERSION < $MOZJPEG
4385                      #error "Insufficient JPEG library version ($MOZJPEG required)."
4386                      #endif ],
4387                    SYSTEM_JPEG=1,
4388                    [SYSTEM_JPEG= JPEG_CFLAGS= JPEG_LIBS=])
4390 CFLAGS=$_SAVE_CFLAGS
4391 LDFLAGS=$_SAVE_LDFLAGS
4392 LIBS=$_SAVE_LIBS
4394 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$SYSTEM_JPEG" = 1; then
4395     JPEG_CFLAGS="-I${JPEG_DIR}/include"
4396     JPEG_LIBS="-L${JPEG_DIR}/lib ${JPEG_LIBS}"
4399 dnl system ZLIB support
4400 dnl ========================================================
4401 MOZ_ARG_WITH_STRING(system-zlib,
4402 [  --with-system-zlib[=PFX]
4403                           Use system libz [installed at prefix PFX]],
4404     ZLIB_DIR=$withval)
4406 _SAVE_CFLAGS=$CFLAGS
4407 _SAVE_LDFLAGS=$LDFLAGS
4408 _SAVE_LIBS=$LIBS
4409 if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
4410     CFLAGS="-I${ZLIB_DIR}/include $CFLAGS"
4411     LDFLAGS="-L${ZLIB_DIR}/lib $LDFLAGS"
4413 if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
4414     SYSTEM_ZLIB=
4415 else
4416     AC_CHECK_LIB(z, gzread, [SYSTEM_ZLIB=1 ZLIB_LIBS="-lz $ZLIB_LIBS"],
4417         [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=], $ZLIB_LIBS)
4419 if test "$SYSTEM_ZLIB" = 1; then
4420     LIBS="$ZLIB_LIBS $LIBS"
4421     AC_TRY_COMPILE([ #include <stdio.h>
4422                      #include <string.h>
4423                      #include <zlib.h> ],
4424                    [ #if ZLIB_VERNUM < $MOZZLIB
4425                      #error "Insufficient zlib version ($MOZZLIB required)."
4426                      #endif ],
4427                    SYSTEM_ZLIB=1,
4428                    [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=])
4430 CFLAGS=$_SAVE_CFLAGS
4431 LDFLAGS=$_SAVE_LDFLAGS
4432 LIBS=$_SAVE_LIBS
4434 if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
4435     ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
4436     ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
4439 if test "$MOZ_LINKER" = 1 -a "$SYSTEM_ZLIB" != 1; then
4440     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
4443 dnl system BZIP2 Support
4444 dnl ========================================================
4445 MOZ_ARG_WITH_STRING(system-bz2,
4446 [  --with-system-bz2[=PFX]
4447                           Use system libbz2 [installed at prefix PFX]],
4448     BZ2_DIR=$withval)
4450 _SAVE_CFLAGS=$CFLAGS
4451 _SAVE_LDFLAGS=$LDFLAGS
4452 _SAVE_LIBS=$LIBS
4453 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4454     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4455     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4457 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4458     SYSTEM_BZ2=
4459 else
4460     AC_CHECK_LIB(bz2, BZ2_bzread, [SYSTEM_BZ2=1 BZ2_LIBS="-lbz2"],
4461         [SYSTEM_BZ2= BZ2_CFLAGS= BZ2_LIBS=])
4463 CFLAGS=$_SAVE_CFLAGS
4464 LDFLAGS=$_SAVE_LDFLAGS
4465 LIBS=$_SAVE_LIBS
4467 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$SYSTEM_BZ2" = 1; then
4468     BZ2_CFLAGS="-I${BZ2_DIR}/include"
4469     BZ2_LIBS="-L${BZ2_DIR}/lib ${BZ2_LIBS}"
4472 dnl system PNG Support
4473 dnl ========================================================
4474 MOZ_ARG_WITH_STRING(system-png,
4475 [  --with-system-png[=PFX]
4476                           Use system libpng [installed at prefix PFX]],
4477     PNG_DIR=$withval)
4479 _SAVE_CFLAGS=$CFLAGS
4480 _SAVE_LDFLAGS=$LDFLAGS
4481 _SAVE_LIBS=$LIBS
4482 CFLAGS="$ZLIB_CFLAGS $CFLAGS"
4483 LDFLAGS="$ZLIB_LIBS -lz $LDFLAGS"
4484 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4485     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4486     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4488 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4489     SYSTEM_PNG=
4490 else
4491     _SAVE_PNG_LIBS=$PNG_LIBS
4492     AC_CHECK_LIB(png, png_get_valid, [SYSTEM_PNG=1 PNG_LIBS="-lpng $PNG_LIBS"],
4493                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]),
4494                  $PNG_LIBS)
4495     AC_CHECK_LIB(png, png_get_acTL, ,
4496                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]),
4497                  $_SAVE_PNG_LIBS)
4499 if test "$SYSTEM_PNG" = 1; then
4500     LIBS="$PNG_LIBS $LIBS"
4501     AC_TRY_COMPILE([ #include <stdio.h>
4502                      #include <sys/types.h>
4503                      #include <png.h> ],
4504                    [ #if PNG_LIBPNG_VER < $MOZPNG
4505                      #error "Insufficient libpng version ($MOZPNG required)."
4506                      #endif
4507                      #ifndef PNG_UINT_31_MAX
4508                      #error "Insufficient libpng version."
4509                      #endif ],
4510                    SYSTEM_PNG=1,
4511                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4513 CFLAGS=$_SAVE_CFLAGS
4514 LDFLAGS=$_SAVE_LDFLAGS
4515 LIBS=$_SAVE_LIBS
4517 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$SYSTEM_PNG" = 1; then
4518     PNG_CFLAGS="-I${PNG_DIR}/include"
4519     PNG_LIBS="-L${PNG_DIR}/lib ${PNG_LIBS}"
4522 fi # SKIP_LIBRARY_CHECKS
4524 dnl system HunSpell Support
4525 dnl ========================================================
4526 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4527 [  --enable-system-hunspell
4528                           Use system hunspell (located with pkgconfig)],
4529     SYSTEM_HUNSPELL=1 )
4531 if test -n "$SYSTEM_HUNSPELL"; then
4532     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4535 AC_SUBST(SYSTEM_HUNSPELL)
4537 dnl ========================================================
4538 dnl system libffi Support
4539 dnl ========================================================
4540 MOZ_ARG_ENABLE_BOOL(system-ffi,
4541 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
4542     MOZ_NATIVE_FFI=1 )
4544 if test -n "$MOZ_NATIVE_FFI"; then
4545     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
4546     # for non-GCC compilers.
4547     if test -z "$GNU_CC"; then
4548         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
4549     else
4550         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
4551     fi
4552     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
4555 dnl ========================================================
4556 dnl Java SDK support
4557 dnl ========================================================
4559 JAVA_BIN_PATH=
4560 MOZ_ARG_WITH_STRING(java-bin-path,
4561 [  --with-java-bin-path=dir
4562                           Location of Java binaries (java, javac, jar)],
4563     JAVA_BIN_PATH=$withval)
4565 dnl ========================================================
4566 dnl =
4567 dnl = Application
4568 dnl =
4569 dnl ========================================================
4571 MOZ_ARG_HEADER(Application)
4573 ENABLE_TESTS=1
4574 ENABLE_SYSTEM_EXTENSION_DIRS=1
4575 MOZ_BRANDING_DIRECTORY=
4576 MOZ_OFFICIAL_BRANDING=
4577 MOZ_FEEDS=1
4578 MOZ_INSTALLER=1
4579 MOZ_JSDEBUGGER=1
4580 MOZ_AUTH_EXTENSION=1
4581 MOZ_OGG=1
4582 MOZ_RAW=
4583 MOZ_SYDNEYAUDIO=
4584 MOZ_VORBIS=
4585 MOZ_TREMOR=
4586 MOZ_WAVE=1
4587 MOZ_MEDIA=
4588 MOZ_WEBM=1
4589 MOZ_VP8_ERROR_CONCEALMENT=
4590 MOZ_VP8_ENCODER=
4591 VPX_AS=
4592 VPX_ASFLAGS=
4593 VPX_AS_DASH_C_FLAG=
4594 VPX_AS_CONVERSION=
4595 VPX_ASM_SUFFIX=
4596 VPX_X86_ASM=
4597 VPX_ARM_ASM=
4598 LIBJPEG_TURBO_AS=
4599 LIBJPEG_TURBO_ASFLAGS=
4600 LIBJPEG_TURBO_X86_ASM=
4601 LIBJPEG_TURBO_X64_ASM=
4602 MOZ_PANGO=1
4603 MOZ_PERMISSIONS=1
4604 MOZ_PLACES=1
4605 MOZ_PREF_EXTENSIONS=1
4606 MOZ_PROFILELOCKING=1
4607 MOZ_PSM=1
4608 MOZ_REFLOW_PERF=
4609 MOZ_SAFE_BROWSING=
4610 MOZ_HELP_VIEWER=
4611 MOZ_SPELLCHECK=1
4612 MOZ_JAVA_COMPOSITOR=
4613 MOZ_SVG_DLISTS=
4614 MOZ_TOOLKIT_SEARCH=1
4615 MOZ_UI_LOCALE=en-US
4616 MOZ_UNIVERSALCHARDET=1
4617 MOZ_URL_CLASSIFIER=
4618 MOZ_XTF=1
4619 MOZ_XUL=1
4620 MOZ_ZIPWRITER=1
4621 NS_PRINTING=1
4622 MOZ_PDF_PRINTING=
4623 MOZ_DISABLE_DOMCRYPTO=
4624 NSS_DISABLE_DBM=
4625 NECKO_WIFI=1
4626 NECKO_COOKIES=1
4627 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
4628 USE_ARM_KUSER=
4629 BUILD_CTYPES=1
4630 MOZ_USE_NATIVE_POPUP_WINDOWS=
4631 MOZ_ANDROID_HISTORY=
4632 MOZ_GRAPHITE=1
4634 case "${target}" in
4635 *darwin*)
4636     ACCESSIBILITY=
4637     ;;
4639     ACCESSIBILITY=1
4640     ;;
4641 esac
4643 case "$target_os" in
4644     mingw*)
4645         NS_ENABLE_TSF=1
4646         if test -z "$GNU_CC"; then
4647             if test "$MOZ_WINSDK_TARGETVER" -lt "06000000"; then
4648                 NS_ENABLE_TSF=
4649             fi
4650         fi
4651         if test -n "$NS_ENABLE_TSF"; then
4652             AC_DEFINE(NS_ENABLE_TSF)
4653         fi
4654         ;;
4655 esac
4657 case "${target}" in
4658     *-android*|*-linuxandroid*)
4659         if test "$CPU_ARCH" = "arm" ; then
4660           USE_ARM_KUSER=1
4661         fi
4663         NSS_DISABLE_DBM=1
4664         MOZ_INSTALLER=
4665         NECKO_WIFI=
4666         MOZ_THEME_FASTSTRIPE=1
4667         MOZ_TREE_FREETYPE=1
4668         MOZ_MEMORY=1
4669         MOZ_RAW=1
4670         ;;
4671 esac
4673 MOZ_ARG_ENABLE_STRING(application,
4674 [  --enable-application=APP
4675                           Options include:
4676                             browser (Firefox)
4677                             xulrunner
4678                             tools/update-packaging (AUS-related packaging tools)],
4679 [ MOZ_BUILD_APP=$enableval ] )
4681 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4682 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4683   XULRUNNER_STUB_NAME=$withval)
4685 if test -z "$XULRUNNER_STUB_NAME"; then
4686   case "$target_os" in
4687   darwin*)
4688     XULRUNNER_STUB_NAME=xulrunner
4689     ;;
4690   *)
4691     XULRUNNER_STUB_NAME=xulrunner-stub
4692   esac
4694 AC_SUBST(XULRUNNER_STUB_NAME)
4696 AC_MSG_CHECKING([for application to build])
4697 if test -z "$MOZ_BUILD_APP"; then
4698   AC_MSG_RESULT([browser])
4699   MOZ_BUILD_APP=browser
4700 else
4701   # default mobile to be mobile/xul
4702   if test "$MOZ_BUILD_APP" = "mobile" ; then
4703     MOZ_BUILD_APP=mobile/xul
4704   fi
4705   # We have a valid application only if it has a build.mk file in its top
4706   # directory.
4707   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4708     AC_MSG_RESULT([none])
4709     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4710   else
4711     AC_MSG_RESULT([$MOZ_BUILD_APP])
4712   fi
4715 # Allow the application to influence configure with a confvars.sh script.
4717 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4718 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4719   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4720   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4721 else
4722   AC_MSG_RESULT([no])
4725 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4726 MOZ_ARG_WITH_STRING(app-name,
4727 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4728 WITH_APP_NAME=$withval,
4731 if test -n "$WITH_APP_NAME" ; then
4732     MOZ_APP_NAME="$WITH_APP_NAME"
4735 MOZ_ARG_WITH_STRING(app-basename,
4736 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4737 WITH_APP_BASENAME=$withval,
4740 if test -n "$WITH_APP_BASENAME" ; then
4741     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4744 # Now is a good time to test for logic errors, define mismatches, etc.
4745 case "$MOZ_BUILD_APP" in
4746 xulrunner)
4747   if test "$LIBXUL_SDK"; then
4748     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4749   fi
4750   ;;
4751 esac
4753 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4754 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4755 # MOZ_BUILD_APP.
4756 case "$MOZ_BUILD_APP" in
4757 browser)
4758   AC_DEFINE(MOZ_PHOENIX)
4759   ;;
4761 xulrunner)
4762   AC_DEFINE(MOZ_XULRUNNER)
4763   ;;
4764 esac
4766 AC_SUBST(MOZ_BUILD_APP)
4767 AC_SUBST(MOZ_PHOENIX)
4768 AC_SUBST(MOZ_XULRUNNER)
4770 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4772 dnl ========================================================
4773 dnl =
4774 dnl = Toolkit Options
4775 dnl =
4776 dnl ========================================================
4777 MOZ_ARG_HEADER(Toolkit Options)
4779     dnl ========================================================
4780     dnl = Select the default toolkit
4781     dnl ========================================================
4782         MOZ_ARG_ENABLE_STRING(default-toolkit,
4783         [  --enable-default-toolkit=TK
4784                           Select default toolkit
4785                           Platform specific defaults:
4786                             Mac OS X - cairo-cocoa
4787                             OS/2 - cairo-os2
4788                             Win32 - cairo-windows
4789                             * - cairo-gtk2
4790                             * - cairo-qt],
4791     [ _DEFAULT_TOOLKIT=$enableval ],
4792     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4794     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4795         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4796         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4797         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4798         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4799         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4800         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4801         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4802         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4803     then
4804         dnl nglayout only supports building with one toolkit,
4805         dnl so ignore everything after the first comma (",").
4806         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4807     else
4808         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4809     fi
4811 dnl ========================================================
4812 dnl = Enable the toolkit as needed                         =
4813 dnl ========================================================
4815 case "$MOZ_WIDGET_TOOLKIT" in
4817 cairo-windows)
4818     MOZ_WIDGET_TOOLKIT=windows
4819     MOZ_WEBGL=1
4820     MOZ_PDF_PRINTING=1
4821     MOZ_INSTRUMENT_EVENT_LOOP=1
4822     ;;
4824 cairo-gtk2|cairo-gtk2-x11)
4825     MOZ_WIDGET_TOOLKIT=gtk2
4826     MOZ_ENABLE_GTK2=1
4827     MOZ_ENABLE_XREMOTE=1
4828     MOZ_WEBGL=1
4829     MOZ_WEBGL_GLX=1
4831     AC_DEFINE(MOZ_X11)
4832     MOZ_X11=1
4833     USE_FC_FREETYPE=1
4835     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4836     TK_LIBS='$(MOZ_GTK2_LIBS)'
4837     AC_DEFINE(MOZ_WIDGET_GTK2)
4838     MOZ_PDF_PRINTING=1
4839     MOZ_INSTRUMENT_EVENT_LOOP=1
4840     ;;
4842 cairo-qt)
4843     MOZ_WIDGET_TOOLKIT=qt
4844     MOZ_ENABLE_QT=1
4845     MOZ_ENABLE_XREMOTE=1
4846     MOZ_WEBGL=1
4847     MOZ_WEBGL_GLX=1
4848     USE_ELF_DYNSTR_GC=
4850     AC_DEFINE(MOZ_X11)
4851     MOZ_X11=1
4852     USE_FC_FREETYPE=1
4853     XT_LIBS=
4855     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4856     TK_LIBS='$(MOZ_QT_LIBS)'
4857     AC_DEFINE(MOZ_WIDGET_QT)
4858     MOZ_PDF_PRINTING=1
4859     ;;
4861 cairo-os2)
4862     MOZ_WIDGET_TOOLKIT=os2
4863     USE_FC_FREETYPE=1
4864     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4865     TK_LIBS='$(MOZ_CAIRO_LIBS)'
4866     MOZ_PDF_PRINTING=1
4867     ;;
4869 cairo-cocoa)
4870     MOZ_WIDGET_TOOLKIT=cocoa
4871     AC_DEFINE(MOZ_WIDGET_COCOA)
4872     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4873     TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4874     TK_CFLAGS="-DNO_X11"
4875     CFLAGS="$CFLAGS $TK_CFLAGS"
4876     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4877     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4878     MOZ_USER_DIR="Mozilla"
4879     MOZ_FS_LAYOUT=bundle
4880     MOZ_WEBGL=1
4881     MOZ_INSTRUMENT_EVENT_LOOP=1
4882     ;;
4884 cairo-uikit)
4885     MOZ_WIDGET_TOOLKIT=uikit
4886     AC_DEFINE(MOZ_WIDGET_UIKIT)
4887     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4888     TK_CFLAGS="-DNO_X11"
4889     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4890     CFLAGS="$CFLAGS $TK_CFLAGS"
4891     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4892     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4893     MOZ_USER_DIR="Mozilla"
4894     MOZ_FS_LAYOUT=bundle
4895     ;;
4897 cairo-android)
4898     AC_DEFINE(MOZ_WIDGET_ANDROID)
4899     MOZ_WIDGET_TOOLKIT=android
4900     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4901     TK_LIBS='$(MOZ_CAIRO_LIBS)'
4902     MOZ_WEBGL=1
4903     MOZ_PDF_PRINTING=1
4904     MOZ_INSTRUMENT_EVENT_LOOP=1
4905     MOZ_OLD_LINKER=1
4906     ;;
4908 cairo-gonk)
4909     AC_DEFINE(MOZ_WIDGET_GONK)
4910     MOZ_WIDGET_TOOLKIT=gonk
4911     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4912     TK_LIBS='$(MOZ_CAIRO_LIBS)'
4913     MOZ_WEBGL=1
4914     MOZ_PDF_PRINTING=1
4915     MOZ_B2G_RIL=1
4916     ;;
4918 esac
4920 AC_SUBST(MOZ_OLD_LINKER)
4921 AC_SUBST(MOZ_PDF_PRINTING)
4922 if test "$MOZ_PDF_PRINTING"; then
4923    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4924    AC_DEFINE(MOZ_PDF_PRINTING)
4927 if test "$MOZ_ENABLE_XREMOTE"; then
4928     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4931 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4932    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4935 if test "$COMPILE_ENVIRONMENT"; then
4936   if test "$MOZ_ENABLE_GTK2"; then
4937     if test "$MOZ_X11"; then
4938       GDK_PACKAGES=gdk-x11-2.0
4939     fi
4941     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4942   fi
4944 fi # COMPILE_ENVIRONMENT
4946 AC_SUBST(MOZ_FS_LAYOUT)
4948 dnl ========================================================
4949 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4950 dnl their usage and use them in spidermonkey.
4951 dnl ========================================================
4952 MOZ_ARG_WITH_BOOL(arm-kuser,
4953 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4954     USE_ARM_KUSER=1,)
4955 if test -n "$USE_ARM_KUSER"; then
4956    AC_DEFINE(USE_ARM_KUSER)
4959 dnl ========================================================
4960 dnl = startup-notification support module
4961 dnl ========================================================
4963 if test "$MOZ_ENABLE_GTK2"
4964 then
4965     MOZ_ENABLE_STARTUP_NOTIFICATION=
4967     MOZ_ARG_ENABLE_BOOL(startup-notification,
4968     [  --enable-startup-notification
4969                           Enable startup-notification support (default: disabled) ],
4970         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4971         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4972     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4973     then
4974         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4975                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4976         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4977             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4978             then
4979                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4980             fi
4981             MOZ_ENABLE_STARTUP_NOTIFICATION=
4982         ])
4983     fi
4985     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4986         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4987     fi
4989     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4991 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4992 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4993 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4995 dnl ========================================================
4996 dnl = QT support
4997 dnl ========================================================
4998 if test "$MOZ_ENABLE_QT"
4999 then
5000     MOZ_ARG_WITH_STRING(qtdir,
5001     [  --with-qtdir=\$dir       Specify Qt directory ],
5002     [ QTDIR=$withval])
5004     if test -z "$QTDIR"; then
5005         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
5006         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
5007         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
5008     else
5009         MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
5011         MOZ_QT_CFLAGS="-DQT_SHARED"
5012         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
5013         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
5014         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
5015         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
5016         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
5017         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
5018         HOST_MOC="$QTDIR/bin/moc"
5019         HOST_RCC="$QTDIR/bin/rcc"
5020     fi
5021     if test -z "$HOST_MOC"; then
5022         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
5023 incorrect])
5024     fi
5025     if test -z "$HOST_RCC"; then
5026         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
5027 incorrect])
5028     fi
5030     MOC=$HOST_MOC
5031     RCC=$HOST_RCC
5033     MOZ_ENABLE_QMSYSTEM2=
5034     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
5035                       MOZ_ENABLE_QMSYSTEM2=1,
5036                       MOZ_ENABLE_QMSYSTEM2=)
5038     if test "$MOZ_ENABLE_QMSYSTEM2"; then
5039       MOZ_ENABLE_QMSYSTEM2=1
5040       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
5041       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
5042       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
5043     fi
5045     MOZ_ENABLE_QTNETWORK=
5046     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
5047                       MOZ_ENABLE_QTNETWORK=1,
5048                       MOZ_ENABLE_QTNETWORK=)
5050     if test "$MOZ_ENABLE_QTNETWORK"; then
5051       MOZ_ENABLE_QTNETWORK=1
5052       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
5053     fi
5055     MOZ_ENABLE_QTMOBILITY=
5056     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
5057                       MOZ_ENABLE_QTMOBILITY=1,
5058                       MOZ_ENABLE_QTMOBILITY=)
5059     if test "$MOZ_ENABLE_QTMOBILITY"; then
5060        MOZ_ENABLE_QTMOBILITY=1
5061        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
5062        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
5063     else
5064        AC_CHECK_LIB(QtSensors, main, [
5065           MOZ_ENABLE_QTMOBILITY=1
5066           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtMobility"
5067           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtSensors"
5068           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtFeedback"
5069           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtLocation"
5070           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
5071        ])
5072     fi
5073     if test "$MOZ_ENABLE_QTMOBILITY"; then
5074        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
5075     fi
5078 AC_SUBST(GTK_CONFIG)
5079 AC_SUBST(TK_CFLAGS)
5080 AC_SUBST(TK_LIBS)
5082 AC_SUBST(MOZ_ENABLE_GTK2)
5083 AC_SUBST(MOZ_ENABLE_QT)
5084 AC_SUBST(MOZ_ENABLE_QTNETWORK)
5085 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
5086 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
5087 AC_SUBST(MOZ_ENABLE_XREMOTE)
5088 AC_SUBST(MOZ_GTK2_CFLAGS)
5089 AC_SUBST(MOZ_GTK2_LIBS)
5090 AC_SUBST(MOZ_QT_CFLAGS)
5091 AC_SUBST(MOZ_QT_LIBS)
5093 AC_SUBST(MOC)
5094 AC_SUBST(RCC)
5096 AC_SUBST(MOZ_X11)
5098 dnl ========================================================
5099 dnl =
5100 dnl = Components & Features
5101 dnl =
5102 dnl ========================================================
5103 MOZ_ARG_HEADER(Components and Features)
5105 dnl ========================================================
5106 dnl = Localization
5107 dnl ========================================================
5108 MOZ_ARG_ENABLE_STRING(ui-locale,
5109 [  --enable-ui-locale=ab-CD
5110                           Select the user interface locale (default: en-US)],
5111     MOZ_UI_LOCALE=$enableval )
5112 AC_SUBST(MOZ_UI_LOCALE)
5114 dnl ========================================================
5115 dnl = Trademarked Branding
5116 dnl ========================================================
5117 MOZ_ARG_ENABLE_BOOL(official-branding,
5118 [  --enable-official-branding
5119                           Enable Official mozilla.org Branding
5120                           Do not distribute builds with
5121                           --enable-official-branding unless you have
5122                           permission to use trademarks per
5123                           http://www.mozilla.org/foundation/trademarks/ .],
5125   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
5126     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
5127   else
5128     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
5129     MOZ_OFFICIAL_BRANDING=1
5130   fi
5131 ], MOZ_OFFICIAL_BRANDING=)
5133 AC_SUBST(MOZ_OFFICIAL_BRANDING)
5134 if test -n "$MOZ_OFFICIAL_BRANDING"; then
5135   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
5138 MOZ_ARG_WITH_STRING(branding,
5139 [  --with-branding=dir     Use branding from the specified directory.],
5140     MOZ_BRANDING_DIRECTORY=$withval)
5142 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
5143 if test -z "$REAL_BRANDING_DIRECTORY"; then
5144   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
5147 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
5148   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
5151 AC_SUBST(MOZ_BRANDING_DIRECTORY)
5153 dnl ========================================================
5154 dnl = Distribution ID
5155 dnl ========================================================
5156 MOZ_ARG_WITH_STRING(distribution-id,
5157 [  --with-distribution-id=ID
5158                           Set distribution-specific id (default=org.mozilla)],
5159 [ val=`echo $withval`
5160     MOZ_DISTRIBUTION_ID="$val"])
5162 if test -z "$MOZ_DISTRIBUTION_ID"; then
5163    MOZ_DISTRIBUTION_ID="org.mozilla"
5166 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
5167 AC_SUBST(MOZ_DISTRIBUTION_ID)
5170 dnl ========================================================
5171 dnl complex text support off by default
5172 dnl ========================================================
5173 MOZ_ARG_DISABLE_BOOL(pango,
5174 [  --disable-pango         Disable usage of Pango ],
5175     MOZ_PANGO=,
5176     MOZ_PANGO=1)
5178 dnl ========================================================
5179 dnl = Pango
5180 dnl ========================================================
5181 if test "$MOZ_ENABLE_GTK2"
5182 then
5183     AC_SUBST(MOZ_PANGO)
5185     PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
5187     PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
5188     AC_SUBST(MOZ_PANGO_CFLAGS)
5189     AC_SUBST(MOZ_PANGO_LIBS)
5190     if test "$MOZ_PANGO"
5191     then
5192         AC_DEFINE(MOZ_PANGO)
5193     else
5194         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0 fontconfig)
5195         AC_SUBST(FT2_CFLAGS)
5196         AC_SUBST(FT2_LIBS)
5197     fi
5200 if test "$MOZ_ENABLE_QT"
5201 then
5202     if test "$MOZ_PANGO"
5203     then
5204         PKG_CHECK_MODULES(MOZ_PANGO, [pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION],
5205         [
5206             AC_SUBST(MOZ_PANGO_CFLAGS)
5207             AC_SUBST(MOZ_PANGO_LIBS)
5208             AC_DEFINE(MOZ_PANGO)
5209         ],
5210         [
5211             echo "Pango library not found, will use FT2 font engine"
5212             MOZ_PANGO=
5213         ])
5214     fi
5215     AC_SUBST(MOZ_PANGO)
5218 dnl ========================================================
5219 dnl = GnomeVFS, GIO and GConf support module
5220 dnl ========================================================
5222 if test "$MOZ_X11"
5223 then
5224     dnl build the gnomevfs extension by default only when the
5225     dnl GTK2 toolkit is in use.
5226     if test "$MOZ_ENABLE_GTK2"
5227     then
5228         MOZ_ENABLE_GNOMEVFS=1
5229         MOZ_ENABLE_GCONF=1
5230     fi
5232     dnl ========================================================
5233     dnl = GnomeVFS support module
5234     dnl ========================================================
5235     MOZ_ARG_DISABLE_BOOL(gnomevfs,
5236     [  --disable-gnomevfs      Disable GnomeVFS support ],
5237         MOZ_ENABLE_GNOMEVFS=,
5238         MOZ_ENABLE_GNOMEVFS=force)
5240     if test "$MOZ_ENABLE_GNOMEVFS"
5241     then
5242         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
5243             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
5244             MOZ_ENABLE_GNOMEVFS=1
5245             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
5246         ],[
5247             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
5248             then
5249                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
5250             fi
5251             MOZ_ENABLE_GNOMEVFS=
5252         ])
5253     else
5254         if test `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
5255             PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
5256               MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
5257             ])
5258         fi
5259     fi
5261     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
5262     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
5263     AC_SUBST(MOZ_GNOMEVFS_LIBS)
5265     dnl ========================================================
5266     dnl = GIO support module
5267     dnl ========================================================
5268     MOZ_ARG_ENABLE_BOOL(gio,
5269     [  --enable-gio            Enable GIO support (default: disabled)],
5270         MOZ_ENABLE_GIO=force,
5271         MOZ_ENABLE_GIO=)
5273     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK2"
5274     then
5275         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
5276                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
5277         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
5278             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
5279             MOZ_ENABLE_GIO=1
5280             AC_DEFINE(MOZ_ENABLE_GIO)
5281         ],[
5282             if test "$MOZ_ENABLE_GIO" = "force"
5283             then
5284                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
5285             fi
5286             MOZ_ENABLE_GIO=
5287         ])
5288     fi
5290     AC_SUBST(MOZ_ENABLE_GIO)
5291     AC_SUBST(MOZ_GIO_CFLAGS)
5292     AC_SUBST(MOZ_GIO_LIBS)
5294     dnl ========================================================
5295     dnl = GConf support module
5296     dnl ========================================================
5297     MOZ_ARG_DISABLE_BOOL(gconf,
5298     [  --disable-gconf      Disable Gconf support ],
5299         MOZ_ENABLE_GCONF=,
5300         MOZ_ENABLE_GCONF=force)
5302     if test "$MOZ_ENABLE_GCONF"
5303     then
5304         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
5305             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
5306             MOZ_ENABLE_GCONF=1
5307         ],[
5308             if test "$MOZ_ENABLE_GCONF" = "force"
5309             then
5310                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
5311             fi
5312             MOZ_ENABLE_GCONF=
5313         ])
5314     fi
5316     if test "$MOZ_ENABLE_GCONF"; then
5317         AC_DEFINE(MOZ_ENABLE_GCONF)
5318     fi
5320     AC_SUBST(MOZ_ENABLE_GCONF)
5321     AC_SUBST(MOZ_GCONF_CFLAGS)
5322     AC_SUBST(MOZ_GCONF_LIBS)
5325 dnl ========================================================
5326 dnl = libproxy support
5327 dnl ========================================================
5329 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5330 then
5331     MOZ_ENABLE_LIBPROXY=
5333     MOZ_ARG_ENABLE_BOOL(libproxy,
5334     [  --enable-libproxy         Enable libproxy support ],
5335     MOZ_ENABLE_LIBPROXY=1,
5336     MOZ_ENABLE_LIBPROXY=)
5338     if test "$MOZ_ENABLE_LIBPROXY"
5339     then
5340         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
5341         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
5342     fi
5344 AC_SUBST(MOZ_ENABLE_LIBPROXY)
5345 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
5346 AC_SUBST(MOZ_LIBPROXY_LIBS)
5348 dnl ========================================================
5349 dnl = libnotify support
5350 dnl ========================================================
5352 if test "$MOZ_ENABLE_GTK2"
5353 then
5354     MOZ_ENABLE_LIBNOTIFY=1
5356     MOZ_ARG_DISABLE_BOOL(libnotify,
5357     [  --disable-libnotify     Disable libnotify support ],
5358     MOZ_ENABLE_LIBNOTIFY=,
5359     MOZ_ENABLE_LIBNOTIFY=1)
5361     if test "$MOZ_ENABLE_LIBNOTIFY"
5362     then
5363         AC_DEFINE(MOZ_ENABLE_LIBNOTIFY)
5364     fi
5367 if test -z "$SKIP_LIBRARY_CHECKS"
5368 then
5369     if test "$MOZ_ENABLE_GTK2"
5370     then
5371         if test "$MOZ_ENABLE_LIBNOTIFY"
5372         then
5373             PKG_CHECK_MODULES(MOZ_LIBNOTIFY, libnotify >= $LIBNOTIFY_VERSION)
5374         fi
5375     fi
5377 AC_SUBST(MOZ_ENABLE_LIBNOTIFY)
5378 AC_SUBST(MOZ_LIBNOTIFY_CFLAGS)
5379 AC_SUBST(MOZ_LIBNOTIFY_LIBS)
5381 dnl ========================================================
5382 dnl = GNOME component (mozgnome)
5383 dnl ========================================================
5385 # The GNOME component is built if one of
5386 # gnome-vfs, gio, gconf or libnotify is available.
5387 if test "$MOZ_ENABLE_GCONF" -o \
5388    "$MOZ_ENABLE_GNOMEVFS" -o \
5389    "$MOZ_ENABLE_GIO" -o \
5390    "$MOZ_ENABLE_LIBNOTIFY"; then
5391     MOZ_ENABLE_GNOME_COMPONENT=1
5392 else
5393     MOZ_ENABLE_GNOME_COMPONENT=
5395 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
5397 dnl ========================================================
5398 dnl = libgnomeui support module
5399 dnl ========================================================
5401 if test "$MOZ_ENABLE_GTK2"
5402 then
5403     MOZ_ENABLE_GNOMEUI=1
5405     MOZ_ARG_DISABLE_BOOL(gnomeui,
5406     [  --disable-gnomeui       Disable libgnomeui support (default: auto, optional at runtime) ],
5407         MOZ_ENABLE_GNOMEUI=,
5408         MOZ_ENABLE_GNOMEUI=force)
5410     if test "$MOZ_ENABLE_GNOMEUI"
5411     then
5412         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
5413         [
5414             MOZ_GNOMEUI_LIBS=`echo $MOZ_GNOMEUI_LIBS | sed 's/-llinc\>//'`
5415             MOZ_ENABLE_GNOMEUI=1
5416         ],[
5417             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5418             then
5419                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5420             fi
5421             MOZ_ENABLE_GNOMEUI=
5422         ])
5423     fi
5425     if test "$MOZ_ENABLE_GNOMEUI"; then
5426         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5427     fi
5430 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5431 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5432 AC_SUBST(MOZ_GNOMEUI_LIBS)
5434 dnl ========================================================
5435 dnl = dbus support
5436 dnl ========================================================
5438 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5439 then
5440     MOZ_ENABLE_DBUS=1
5442     MOZ_ARG_DISABLE_BOOL(dbus,
5443     [  --disable-dbus          Disable dbus support ],
5444         MOZ_ENABLE_DBUS=,
5445         MOZ_ENABLE_DBUS=1)
5447     if test "$MOZ_ENABLE_DBUS"
5448     then
5449         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
5450         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5451         AC_DEFINE(MOZ_ENABLE_DBUS)
5452     fi
5454 AC_SUBST(MOZ_ENABLE_DBUS)
5455 AC_SUBST(MOZ_DBUS_CFLAGS)
5456 AC_SUBST(MOZ_DBUS_LIBS)
5457 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5458 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5460 dnl ========================================================
5461 dnl = Enable Android History instead of Places
5462 dnl ========================================================
5463 if test -n "$MOZ_ANDROID_HISTORY"; then
5464      dnl Do this if defined in confvars.sh
5465      AC_DEFINE(MOZ_ANDROID_HISTORY)
5469 dnl ========================================================
5470 dnl = Build Personal Security Manager
5471 dnl ========================================================
5472 MOZ_ARG_DISABLE_BOOL(crypto,
5473 [  --disable-crypto        Disable crypto support (Personal Security Manager)],
5474     MOZ_PSM=,
5475     MOZ_PSM=1 )
5477 dnl ========================================================
5478 dnl = JS Debugger XPCOM component (js/jsd)
5479 dnl ========================================================
5480 MOZ_ARG_DISABLE_BOOL(jsd,
5481 [  --disable-jsd           Disable JavaScript debug library],
5482     MOZ_JSDEBUGGER=,
5483     MOZ_JSDEBUGGER=1)
5486 dnl ========================================================
5487 dnl = Enable IPDL's "expensive" unit tests
5488 dnl ========================================================
5489 MOZ_IPDL_TESTS=
5491 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5492 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5493     MOZ_IPDL_TESTS=1,
5494     MOZ_IPDL_TESTS=)
5496 if test -n "$MOZ_IPDL_TESTS"; then
5497     AC_DEFINE(MOZ_IPDL_TESTS)
5500 AC_SUBST(MOZ_IPDL_TESTS)
5502 dnl ========================================================
5503 dnl = Turns off code necessary for e10s compatibility
5504 dnl ========================================================
5505 dnl This is a temporary flag to be removed in bug 662601 when
5506 dnl it's no longer needed
5508 MOZ_E10S_COMPAT=
5510 MOZ_ARG_ENABLE_BOOL(e10s-compat,
5511 [  --enable-e10s-compat     Turns off code for e10s compat],
5512     MOZ_E10S_COMPAT=1,
5513     MOZ_E10S_COMPAT=)
5515 if test -n "$MOZ_E10S_COMPAT"; then
5516     AC_DEFINE(MOZ_E10S_COMPAT)
5519 dnl ========================================================
5520 dnl = Disable building dbm
5521 dnl ========================================================
5522 MOZ_ARG_DISABLE_BOOL(dbm,
5523 [  --disable-dbm           Disable building dbm],
5524     NSS_DISABLE_DBM=1,
5525     NSS_DISABLE_DBM=)
5527 dnl bi-directional support always on
5528 IBMBIDI=1
5529 AC_DEFINE(IBMBIDI)
5531 dnl ========================================================
5532 dnl accessibility support on by default on all platforms
5533 dnl except OS X.
5534 dnl ========================================================
5535 MOZ_ARG_DISABLE_BOOL(accessibility,
5536 [  --disable-accessibility Disable accessibility support (off by default on OS X)],
5537     ACCESSIBILITY=,
5538     ACCESSIBILITY=1 )
5539 if test "$ACCESSIBILITY"; then
5540     AC_DEFINE(ACCESSIBILITY)
5543 dnl ========================================================
5544 dnl Disable printing
5545 dnl ========================================================
5546 MOZ_ARG_DISABLE_BOOL(printing,
5547 [  --disable-printing      Disable printing support],
5548     NS_PRINTING=,
5549     NS_PRINTING=1)
5551 if test "$NS_PRINTING"; then
5552     AC_DEFINE(NS_PRINTING)
5553     AC_DEFINE(NS_PRINT_PREVIEW)
5556 dnl ========================================================
5557 dnl = Enable Raw Codecs
5558 dnl ========================================================
5559 MOZ_ARG_ENABLE_BOOL(raw,
5560 [  --enable-raw           Enable support for RAW media],
5561     MOZ_RAW=1,
5562     MOZ_RAW=)
5564 if test -n "$MOZ_RAW"; then
5565     AC_DEFINE(MOZ_RAW)
5566     MOZ_MEDIA=1
5569 AC_SUBST(MOZ_RAW)
5571 dnl ========================================================
5572 dnl = Disable Ogg Codecs
5573 dnl ========================================================
5574 MOZ_ARG_DISABLE_BOOL(ogg,
5575 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5576     MOZ_OGG=,
5577     MOZ_OGG=1)
5579 if test -n "$MOZ_OGG"; then
5580     AC_DEFINE(MOZ_OGG)
5581     MOZ_SYDNEYAUDIO=1
5582     MOZ_MEDIA=1
5583     case "$target_cpu" in
5584     arm*)
5585         MOZ_TREMOR=1
5586     ;;
5587     *)
5588         MOZ_VORBIS=1
5589     ;;
5590     esac
5592     dnl Checks for __attribute__(aligned()) directive
5593     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5594         [ac_cv_c_attribute_aligned],
5595         [ac_cv_c_attribute_aligned=0
5596          CFLAGS_save="${CFLAGS}"
5597          CFLAGS="${CFLAGS} -Werror"
5598          for ac_cv_c_attr_align_try in 64 32 16 8; do
5599            echo "trying $ac_cv_c_attr_align_try"
5600            AC_TRY_COMPILE([],
5601                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5602                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5603            if test "$ac_cv_c_attribute_aligned" != 0; then
5604              break;
5605            fi
5606          done
5607            CFLAGS="${CFLAGS_save}"])
5608     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5609       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5610                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5611     fi
5614 dnl ========================================================
5615 dnl = Disable VP8 decoder support
5616 dnl ========================================================
5617 MOZ_ARG_DISABLE_BOOL(webm,
5618 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5619     MOZ_WEBM=,
5620     MOZ_WEBM=1)
5622 dnl system libvpx Support
5623 dnl ========================================================
5624 MOZ_ARG_WITH_STRING(system-libvpx,
5625 [  --with-system-libvpx=[PFX]
5626                           Use system libvpx [installed at prefix PFX]],
5627     LIBVPX_DIR=$withval)
5629 MOZ_NATIVE_LIBVPX=
5630 MOZ_LIBVPX_INCLUDES=
5631 MOZ_LIBVPX_LIBS=
5633 if test -n "$MOZ_WEBM"; then
5634     AC_DEFINE(MOZ_WEBM)
5635     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5636         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5637     fi
5638     if test -n "$MOZ_VP8_ENCODER" ; then
5639         AC_DEFINE(MOZ_VP8_ENCODER)
5640     fi
5642     if test -n "$LIBVPX_DIR" -a "$LIBVPX_DIR" != no; then
5643         _SAVE_CFLAGS=$CFLAGS
5644         _SAVE_LDFLAGS=$LDFLAGS
5645         _SAVE_LIBS=$LIBS
5646         if test "${LIBVPX_DIR}" = "yes"; then
5647             LIBVPX_DIR=/usr
5648         fi
5649         CFLAGS="-I${LIBVPX_DIR}/include $CFLAGS"
5650         LDFLAGS="-L${LIBVPX_DIR}/lib $LDFLAGS"
5651         MOZ_NATIVE_LIBVPX_DEC_TEST=
5652         MOZ_CHECK_HEADER(vpx/vpx_decoder.h,
5653             [if test ! -f "${LIBVPX_DIR}/include/vpx/vpx_decoder.h"; then
5654              AC_MSG_ERROR([vpx/vpx_decoder.h found, but is not in ${LIBVPX_DIR}/include])
5655             fi],
5656             AC_MSG_ERROR([--with-system-libvpx requested but vpx/vpx_decoder.h not found]))
5657         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver,
5658                      [MOZ_NATIVE_LIBVPX_DEC_TEST=1],
5659                      ([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found]))
5660         if test -n "$MOZ_NATIVE_LIBVPX_DEC_TEST" ; then
5661             AC_MSG_CHECKING([for libvpx version >= v0.9.7])
5662             dnl We need at least v0.9.7 to fix several crash bugs (for which we
5663             dnl had local patches prior to v0.9.7).
5664             dnl
5665             dnl This is a terrible test for the library version, but we don't
5666             dnl have a good one. There is no version number in a public header,
5667             dnl and testing the headers still doesn't guarantee we link against
5668             dnl the right version. While we could call vpx_codec_version() at
5669             dnl run-time, that would break cross-compiling. There are no
5670             dnl additional exported symbols between the v0.9.7 release and the
5671             dnl v0.9.6 one to check for.
5672             AC_TRY_COMPILE([
5673                 #include <vpx/vpx_decoder.h>
5674                 #if !defined(VPX_CODEC_USE_INPUT_PARTITION)
5675                     #error "test failed."
5676                 #endif
5677                 ],
5678                 [return 0;],
5679                 [AC_MSG_RESULT([yes])
5680                  MOZ_NATIVE_LIBVPX=1
5681                  AC_DEFINE(MOZ_NATIVE_LIBVPX)
5682                  MOZ_LIBVPX_INCLUDES="-I${LIBVPX_DIR}/include"
5683                  MOZ_LIBVPX_LIBS="-L${LIBVPX_DIR}/lib -lvpx"],
5684                 [AC_MSG_RESULT([no])
5685                  AC_MSG_ERROR([--with-system-libvpx requested but it is not v0.9.7 or later])])
5686         fi
5687         CFLAGS=$_SAVE_CFLAGS
5688         LDFLAGS=$_SAVE_LDFLAGS
5689         LIBS=$_SAVE_LIBS
5690     fi
5693 AC_SUBST(MOZ_NATIVE_LIBVPX)
5694 AC_SUBST(MOZ_LIBVPX_INCLUDES)
5695 AC_SUBST(MOZ_LIBVPX_LIBS)
5697 if test -n "$MOZ_WEBM" -a -z "$MOZ_NATIVE_LIBVPX"; then
5698     MOZ_SYDNEYAUDIO=1
5699     MOZ_MEDIA=1
5700     case "$target_cpu" in
5701     arm*)
5702         MOZ_TREMOR=1
5703     ;;
5704     *)
5705         MOZ_VORBIS=1
5706     ;;
5707     esac
5710     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5711     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5712     dnl We currently require gcc on all arm platforms.
5713     VPX_AS=$YASM
5714     VPX_ASM_SUFFIX=asm
5715     VPX_NEED_OBJ_INT_EXTRACT=
5717     dnl See if we have assembly on this platform.
5718     case "$OS_ARCH:$CPU_ARCH" in
5719     Linux:x86)
5720       VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5721       VPX_X86_ASM=1
5722     ;;
5723     Linux:x86_64)
5724       VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5725       VPX_X86_ASM=1
5726     ;;
5727     SunOS:x86)
5728       VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5729       VPX_X86_ASM=1
5730     ;;
5731     SunOS:x86_64)
5732       VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5733       VPX_X86_ASM=1
5734     ;;
5735     Darwin:x86)
5736       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5737       VPX_X86_ASM=1
5738     ;;
5739     Darwin:x86_64)
5740       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5741       VPX_X86_ASM=1
5742     ;;
5743     WINNT:x86_64)
5744       if test -z "$GNU_CC"; then
5745         VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5746         VPX_X86_ASM=1
5747       fi
5748     ;;
5749     WINNT:x86)
5750       if test -z "$GNU_CC"; then
5751         dnl Check for yasm 1.1 or greater.
5752         if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5753           AC_MSG_ERROR([yasm 1.1 or greater is required to build libvpx on Win32, but it appears not to be installed.  Install it (included in MozillaBuild 1.5.1 and newer) or configure with --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
5754         elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5755           AC_MSG_ERROR([yasm 1.1 or greater is required to build libvpx on Win32, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.  Upgrade to the newest version (included in MozillaBuild 1.5.1 and newer) or configure with --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
5756         else
5757           VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5758           VPX_X86_ASM=1
5759           dnl The encoder needs obj_int_extract to get asm offsets.
5760         fi
5761       fi
5762     ;;
5763     *:arm*)
5764       if test -n "$GNU_AS" ; then
5765         VPX_AS=$AS
5766         dnl These flags are a lie; they're just used to enable the requisite
5767         dnl opcodes; actual arch detection is done at runtime.
5768         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5769         VPX_DASH_C_FLAG="-c"
5770         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5771         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5772         VPX_ARM_ASM=1
5773       fi
5774     esac
5776     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5777       AC_MSG_ERROR([yasm is a required build tool for this architecture when webm is enabled. You may either install yasm or --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
5778     fi
5780     if test -n "$MOZ_VP8_ENCODER" -a \
5781             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5782       dnl We prefer to get asm offsets using inline assembler, which the above
5783       dnl compilers can do. When we're not using one of those, we have to fall
5784       dnl back to obj_int_extract, which reads them from a compiled object
5785       dnl file. Unfortunately, that only works if we're compiling on a system
5786       dnl with the header files for the appropriate object file format.
5787       VPX_NEED_OBJ_INT_EXTRACT=1
5788     fi
5790     if test -n "$VPX_X86_ASM"; then
5791       AC_DEFINE(VPX_X86_ASM)
5792     elif test -n "$VPX_ARM_ASM"; then
5793       AC_DEFINE(VPX_ARM_ASM)
5794     else
5795       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5796     fi
5799 dnl ========================================================
5800 dnl = Disable Wave decoder support
5801 dnl ========================================================
5802 MOZ_ARG_DISABLE_BOOL(wave,
5803 [  --disable-wave          Disable Wave decoder support],
5804     MOZ_WAVE=,
5805     MOZ_WAVE=1)
5807 if test -n "$MOZ_WAVE"; then
5808     AC_DEFINE(MOZ_WAVE)
5809     MOZ_SYDNEYAUDIO=1
5810     MOZ_MEDIA=1
5813 dnl ========================================================
5814 dnl = Handle dependent SYDNEYAUDIO and MEDIA defines
5815 dnl ========================================================
5817 if test -n "$MOZ_SYDNEYAUDIO"; then
5818     AC_DEFINE(MOZ_SYDNEYAUDIO)
5821 if test -n "$MOZ_MEDIA"; then
5822     AC_DEFINE(MOZ_MEDIA)
5825 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5826     AC_MSG_ERROR([MOZ_VORBIS and MOZ_TREMOR are mutually exclusive!  The build system should not allow them both to be set, but they are.  Please file a bug at https://bugzilla.mozilla.org/])
5829 if test -n "$MOZ_VORBIS"; then
5830     AC_DEFINE(MOZ_VORBIS)
5833 if test -n "$MOZ_TREMOR"; then
5834     AC_DEFINE(MOZ_TREMOR)
5837 dnl ========================================================
5838 dnl = Check alsa availability on Linux if using sydneyaudio
5839 dnl ========================================================
5841 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5842 if test -n "$MOZ_SYDNEYAUDIO"; then
5843    case "$target_os" in
5844 linux*)
5845       PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5846          [echo "$MOZ_ALSA_PKG_ERRORS"
5847           AC_MSG_ERROR([Need alsa for Ogg, Wave or WebM decoding on Linux.  Disable with --disable-ogg --disable-wave --disable-webm.  (On Ubuntu, you might try installing the package libasound2-dev.)])])
5848       ;;
5849    esac
5852 dnl ========================================================
5853 dnl Permissions System
5854 dnl ========================================================
5855 MOZ_ARG_DISABLE_BOOL(permissions,
5856 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5857     MOZ_PERMISSIONS=,
5858     MOZ_PERMISSIONS=1
5861 dnl ========================================================
5862 dnl NegotiateAuth
5863 dnl ========================================================
5864 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5865 [  --disable-negotiateauth Disable GSS-API negotiation ],
5866     MOZ_AUTH_EXTENSION=,
5867     MOZ_AUTH_EXTENSION=1 )
5869 dnl ========================================================
5870 dnl XTF
5871 dnl ========================================================
5872 MOZ_ARG_DISABLE_BOOL(xtf,
5873 [  --disable-xtf           Disable XTF (pluggable xml tags) support],
5874     MOZ_XTF=,
5875     MOZ_XTF=1 )
5876 if test "$MOZ_XTF"; then
5877   AC_DEFINE(MOZ_XTF)
5880 dnl ========================================================
5881 dnl Pref extensions (autoconfig)
5882 dnl ========================================================
5883 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5884 [  --disable-pref-extensions
5885                           Disable pref extensions such as autoconfig],
5886   MOZ_PREF_EXTENSIONS=,
5887   MOZ_PREF_EXTENSIONS=1 )
5889 dnl ========================================================
5890 dnl Searching of system directories for extensions.
5891 dnl Note: this switch is meant to be used for test builds
5892 dnl whose behavior should not depend on what happens to be
5893 dnl installed on the local machine.
5894 dnl ========================================================
5895 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5896 [  --disable-system-extension-dirs
5897                           Disable searching system- and account-global
5898                           directories for extensions of any kind; use
5899                           only profile-specific extension directories],
5900   ENABLE_SYSTEM_EXTENSION_DIRS=,
5901   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5902 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5903   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5906 dnl ========================================================
5907 dnl = Universalchardet
5908 dnl ========================================================
5909 MOZ_ARG_DISABLE_BOOL(universalchardet,
5910 [  --disable-universalchardet
5911                           Disable universal encoding detection],
5912   MOZ_UNIVERSALCHARDET=,
5913   MOZ_UNIVERSALCHARDET=1 )
5915 if test -n "${JAVA_BIN_PATH}"; then
5916   dnl Look for javac and jar in the specified path.
5917   JAVA_PATH="$JAVA_BIN_PATH"
5918 else
5919   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5920   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5923 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5924 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5925 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5927 if test -n "${JAVA_BIN_PATH}" -o "$OS_TARGET" = Android; then
5928   if test -z "$JAVA" -o "$JAVA" = ":" -o -z "$JAVAC" -o "$JAVAC" = ":" -o -z "$JAR" -o "$JAR" = ":"; then
5929     AC_MSG_ERROR([The programs java, javac and jar were not found.  Set \$JAVA_HOME to your java sdk directory or use --with-java-bin-path={java-bin-dir}])
5930   fi
5933 dnl ========================================================
5934 dnl = ANGLE OpenGL->D3D translator for WebGL
5935 dnl = * only applies to win32
5936 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5937 dnl ========================================================
5938 MOZ_ANGLE=
5939 MOZ_DIRECTX_SDK_PATH=
5940 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5941 MOZ_D3DX9_VERSION=
5942 MOZ_D3DX9_CAB=
5943 MOZ_D3DCOMPILER_CAB=
5944 MOZ_D3DX9_DLL=
5945 MOZ_D3DCOMPILER_DLL=
5946 case "$target_os" in
5947 *mingw*)
5948     MOZ_ANGLE=1
5949     ;;
5950 esac
5952 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5953 case "${target_cpu}" in
5954 i*86)
5955   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5956   ;;
5957 x86_64)
5958   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5959   ;;
5960 esac
5962 if test -n "$MOZ_ANGLE"; then
5963 MOZ_ARG_DISABLE_BOOL(angle,
5964 [  --disable-angle     Disable building of ANGLE for WebGL->D3D translation],
5965     MOZ_ANGLE=,
5966     MOZ_ANGLE=1)
5968 if test -n "$MOZ_ANGLE"; then
5969   if test -z "$_WIN32_MSVC"; then
5970     AC_MSG_ERROR([Building ANGLE requires MSVC.  To build without ANGLE, reconfigure with --disable-angle.])
5971   fi
5973   # Get the SDK path from the registry.
5974   # First try to get the June 2010 SDK
5975   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5976   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5977     # Otherwise just take whatever comes first
5978     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5979   fi
5981   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5982     AC_MSG_ERROR([Found the February 2010 DirectX SDK. This is too old. We now require the June 2010 DirectX SDK, or newer.  Upgrade your SDK or to explicitly build without ANGLE, reconfigure with --disable-angle.])
5983   else
5984     MOZ_DIRECTX_SDK_PATH=`reg query "$MOZ_DIRECTX_SDK_REG_KEY" //v InstallPath | grep REG_SZ | sed 's/.*\([[a-zA-Z]]\)\\:\\\\/\\1\\:\\\\/'`
5985   fi
5987   MOZ_ANGLE=
5989   if test -n "$MOZ_DIRECTX_SDK_PATH" ; then
5990     if test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h && test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5991       AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5992       MOZ_ANGLE=1
5993     fi
5994   fi
5996   if test -z "$MOZ_ANGLE" ; then
5997     AC_MSG_ERROR([Couldn't find the DirectX SDK, needed for ANGLE. Please install it (June 2010 or newer). To explicitly build without ANGLE, reconfigure with --disable-angle.])
5998   fi
6000   if test -n "$MOZ_ANGLE" ; then
6001     # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
6002     MOZ_D3DX9_VERSION=`dumpbin //headers "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/d3dx9.lib | egrep d3dx9_[[0-9]][[0-9]]\.dll | head -n1 | sed 's/.*\([[0-9]][[0-9]]\).*/\\1/g'`
6004     if test -z "$MOZ_D3DX9_VERSION" ; then
6005       AC_MSG_ERROR([Couldn't determine the D3DX9 version, needed for ANGLE. To explicitly build without ANGLE, reconfigure with --disable-angle.])
6006     fi
6008     if test -n "$MOZ_ANGLE" ; then
6009       MOZ_D3DX9_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *d3dx9_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
6010       MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
6012       MOZ_D3DX9_DLL=d3dx9_$MOZ_D3DX9_VERSION.dll
6013       MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
6014     fi
6015   fi
6019 dnl ========================================================
6020 dnl = Breakpad crash reporting (on by default on supported platforms)
6021 dnl ========================================================
6023 case $target in
6024 i?86-*-mingw*|x86_64-*-mingw*)
6025   MOZ_CRASHREPORTER=1
6026   ;;
6027 i?86-apple-darwin*|powerpc-apple-darwin*|x86_64-apple-darwin*)
6028   MOZ_CRASHREPORTER=1
6029   ;;
6030 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
6031   if test "$MOZ_ENABLE_GTK2"; then
6032     MOZ_CRASHREPORTER=1
6033   fi
6034   ;;
6035 *-android*|*-linuxandroid*)
6036   MOZ_CRASHREPORTER=1
6037   ;;
6038 *solaris*)
6039   MOZ_CRASHREPORTER=1
6040   ;;
6041 esac
6043 MOZ_ARG_DISABLE_BOOL(crashreporter,
6044 [  --disable-crashreporter Disable breakpad crash reporting],
6045     MOZ_CRASHREPORTER=,
6046     MOZ_CRASHREPORTER=1)
6048 if test -n "$MOZ_CRASHREPORTER"; then
6049    AC_DEFINE(MOZ_CRASHREPORTER)
6051   if (test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS") && \
6052     test -z "$SKIP_LIBRARY_CHECKS"; then
6053     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
6054     AC_SUBST(MOZ_GTHREAD_CFLAGS)
6055     AC_SUBST(MOZ_GTHREAD_LIBS)
6057     MOZ_CHECK_HEADERS([curl/curl.h], [], [AC_MSG_ERROR([Couldn't find curl/curl.h which is required for the crash reporter.  Use --disable-crashreporter to disable the crash reporter.])])
6058   fi
6060   if (test "$OS_ARCH" != "$HOST_OS_ARCH"); then
6061     AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.  Use --disable-crashreporter.])
6062   fi
6065 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
6066 [  --with-crashreporter-enable-percent=NN
6067                           Enable sending crash reports by default on NN% of users. (default=100)],
6068 [ val=`echo $withval | sed 's/[^0-9]//g'`
6069     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
6071 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
6072    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6074 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6076 dnl ========================================================
6077 dnl = libjpeg-turbo configuration
6078 dnl ========================================================
6079 MOZ_LIBJPEG_TURBO=
6080 if test -z "$SYSTEM_JPEG"; then
6081     MOZ_LIBJPEG_TURBO=1
6084 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6085 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6086     MOZ_LIBJPEG_TURBO=,
6087     MOZ_LIBJPEG_TURBO=1)
6089 if test "$SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6090     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6093 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6094 dnl files.
6096 if test -n "$MOZ_LIBJPEG_TURBO"; then
6098   dnl Do we support libjpeg-turbo on this platform?
6099   case "$OS_ARCH:$OS_TEST" in
6100   Linux:x86|Linux:i?86)
6101     LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6102     LIBJPEG_TURBO_X86_ASM=1
6103   ;;
6104   Linux:x86_64)
6105     LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6106     LIBJPEG_TURBO_X64_ASM=1
6107   ;;
6108   SunOS:i?86)
6109     LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6110     LIBJPEG_TURBO_X86_ASM=1
6111   ;;
6112   SunOS:x86_64)
6113     LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6114     LIBJPEG_TURBO_X64_ASM=1
6115   ;;
6116   Darwin:i?86)
6117     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6118     LIBJPEG_TURBO_X86_ASM=1
6119   ;;
6120   Darwin:x86_64)
6121     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6122     LIBJPEG_TURBO_X64_ASM=1
6123   ;;
6124   WINNT:x86|WINNT:i?86)
6125     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6126     LIBJPEG_TURBO_X86_ASM=1
6127   ;;
6128   WINNT:x86_64)
6129     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6130     LIBJPEG_TURBO_X64_ASM=1
6131   ;;
6132   esac
6136 dnl If we're on a system which supports libjpeg-turbo's asm routines and
6137 dnl --disable-libjpeg-turbo wasn't passed, check for yasm, and error out if it
6138 dnl doesn't exist or we have too old of a version.
6139 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6140     AC_MSG_CHECKING([for YASM assembler])
6141     AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "")
6143     if test -z "$LIBJPEG_TURBO_AS" ; then
6144         AC_MSG_ERROR([yasm is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you do not appear to have yasm installed.  Either install it or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
6145     fi
6147     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6148     dnl on Linux and 1.1 or newer everywhere else.
6149     if test "$OS_ARCH" = "Linux" ; then
6150         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -eq "0" -a "$_YASM_RELEASE" -lt "1" \) ; then
6151             AC_MSG_ERROR([yasm 1.0.1 or greater is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.$_YASM_RELEASE.  Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
6152         fi
6153     else
6154         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6155             AC_MSG_ERROR([yasm 1.1 or greater is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.  Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
6156         fi
6157     fi
6160 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6161     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6162 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6163     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6164 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6165     dnl Warn if we're not building the optimized routines, even though the user
6166     dnl didn't specify --disable-libjpeg-turbo.
6167     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6170 dnl ========================================================
6171 dnl = Enable compilation of specific extension modules
6172 dnl ========================================================
6174 MOZ_ARG_ENABLE_STRING(extensions,
6175 [  --enable-extensions     Enable extensions],
6176 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6177     if test "$option" = "yes" -o "$option" = "all"; then
6178         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6179     elif test "$option" = "no" -o "$option" = "none"; then
6180         MOZ_EXTENSIONS=""
6181     elif test "$option" = "default"; then
6182         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6183     elif test `echo "$option" | grep -c \^-` != 0; then
6184         option=`echo $option | sed 's/^-//'`
6185         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6186     else
6187         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6188     fi
6189 done],
6190     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6192 if test -z "$MOZ_ENABLE_GNOMEVFS" -a -z "$MOZ_GNOMEVFS_LIBS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6193     # Suppress warning on non-X11 platforms
6194     if test -n "$MOZ_X11"; then
6195         AC_MSG_WARN([Cannot build gnomevfs without required libraries. Removing gnomevfs from MOZ_EXTENSIONS.])
6196     fi
6197     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6200 dnl Do not build gnomevfs with libxul based apps
6201 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6202     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6205 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6206     # Suppress warning on non-X11 platforms
6207     if test -n "$MOZ_X11"; then
6208         AC_MSG_WARN([Cannot build gio without required libraries. Removing gio from MOZ_EXTENSIONS.])
6209     fi
6210     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6213 dnl Do not build gio with libxul based apps
6214 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6215     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6218 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6219     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6220     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6223 dnl xforms requires xtf
6224 if test -z "$MOZ_XTF" -a `echo "$MOZ_EXTENSIONS" | grep -c xforms` -ne 0; then
6225     AC_MSG_WARN([Cannot build XForms without XTF support.  Removing XForms from MOZ_EXTENSIONS.])
6226     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|xforms||g'`
6229 dnl Remove dupes
6230 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6232 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6233 dnl when trying to build a nonexistent extension.
6234 for extension in $MOZ_EXTENSIONS; do
6235     if test ! -d "${srcdir}/extensions/${extension}"; then
6236         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6237     fi
6238 done
6240 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6241   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6244 dnl ========================================================
6245 dnl SVG Display Lists
6246 dnl ========================================================
6247 if test -n "$MOZ_SVG_DLISTS"; then
6248   AC_DEFINE(MOZ_SVG_DLISTS)
6251 dnl ========================================================
6252 dnl Build Freetype in the tree
6253 dnl ========================================================
6254 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6255 [  --enable-tree-freetype  Enable Tree FreeType],
6256     MOZ_TREE_FREETYPE=1,
6257     MOZ_TREE_FREETYPE= )
6258 if test -n "$MOZ_TREE_FREETYPE"; then
6259    if test -n "$_WIN32_MSVC"; then
6260       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6261    fi
6262    AC_DEFINE(MOZ_TREE_FREETYPE)
6263    AC_SUBST(MOZ_TREE_FREETYPE)
6264    MOZ_ENABLE_CAIRO_FT=1
6265    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6266    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6267    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6268    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6269    CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6270    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6271    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6272    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6273    AC_SUBST(CAIRO_FT_CFLAGS)
6276 dnl ========================================================
6277 dnl Installer
6278 dnl ========================================================
6279 MOZ_ARG_DISABLE_BOOL(installer,
6280 [  --disable-installer     Disable building of installer],
6281     MOZ_INSTALLER=,
6282     MOZ_INSTALLER=1)
6283 if test -n "$MOZ_INSTALLER" -a "$OS_ARCH" = "WINNT"; then
6284     # Disable installer for Windows builds that use the new toolkit if the
6285     # required major version and minimum minor version of Unicode NSIS isn't in
6286     # the path.
6287     REQ_NSIS_MAJOR_VER=2
6288     MIN_NSIS_MINOR_VER=33
6289     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensisu makensis)
6290     if test -z "$MAKENSISU" -o "$MAKENSISU" = ":"; then
6291         AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS with a major version of $REQ_NSIS_MAJOR_VER and a minimum minor version of $MIN_NSIS_MINOR_VER in your path. To build without the installer reconfigure using --disable-installer.])
6292     fi
6293     changequote(,)
6294     MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\)\-Unicode$/\1/g'`
6295     changequote([,])
6296     if test ! "$MAKENSISU_VER" = ""; then
6297         MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6298         MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6299     fi
6300     AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6301     if test "$MAKENSISU_VER" = "" ||
6302        test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6303             ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6304         AC_MSG_RESULT([no])
6305         AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS with a major version of $REQ_NSIS_MAJOR_VER and a minimum minor version of $MIN_NSIS_MINOR_VER in your path. To build without the installer reconfigure using --disable-installer.])
6306     fi
6307     AC_MSG_RESULT([yes])
6310 AC_SUBST(MOZ_INSTALLER)
6312 AC_MSG_CHECKING([for tar archiver])
6313 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6314 if test -z "$TAR"; then
6315     AC_MSG_ERROR([no tar archiver found in \$PATH])
6317 AC_MSG_RESULT([$TAR])
6318 AC_SUBST(TAR)
6320 AC_MSG_CHECKING([for wget])
6321 AC_CHECK_PROGS(WGET, wget, "")
6322 AC_MSG_RESULT([$WGET])
6323 AC_SUBST(WGET)
6325 dnl ========================================================
6326 dnl Maintenance Service
6327 dnl ========================================================
6329 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6330 [  --enable-maintenance-service       Enable building of maintenanceservice],
6331     MOZ_MAINTENANCE_SERVICE=1,
6332     MOZ_MAINTENANCE_SERVICE= )
6334 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6335   if test "$OS_ARCH" = "WINNT"; then
6336     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6337   else
6338     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6339   fi
6342 dnl ========================================================
6343 dnl Updater
6344 dnl ========================================================
6346 MOZ_ARG_DISABLE_BOOL(updater,
6347 [  --disable-updater       Disable building of updater],
6348     MOZ_UPDATER=,
6349     MOZ_UPDATER=1 )
6351 if test -n "$MOZ_UPDATER"; then
6352     AC_DEFINE(MOZ_UPDATER)
6355 # app update channel is 'default' when not supplied.
6356 MOZ_ARG_ENABLE_STRING([update-channel],
6357 [  --enable-update-channel=CHANNEL
6358                           Select application update channel (default=default)],
6359     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
6361 if test -z "$MOZ_UPDATE_CHANNEL"; then
6362     MOZ_UPDATE_CHANNEL=default
6364 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
6365 AC_SUBST(MOZ_UPDATE_CHANNEL)
6367 # tools/update-packaging is not checked out by default.
6368 MOZ_ARG_ENABLE_BOOL(update-packaging,
6369 [  --enable-update-packaging
6370                           Enable tools/update-packaging],
6371     MOZ_UPDATE_PACKAGING=1,
6372     MOZ_UPDATE_PACKAGING= )
6373 AC_SUBST(MOZ_UPDATE_PACKAGING)
6375 dnl ========================================================
6376 dnl leaky
6377 dnl ========================================================
6378 MOZ_ARG_ENABLE_BOOL(leaky,
6379 [  --enable-leaky          Build leaky memory tool],
6380     MOZ_LEAKY=1,
6381     MOZ_LEAKY=)
6384 dnl ========================================================
6385 dnl build the tests by default
6386 dnl ========================================================
6387 MOZ_ARG_DISABLE_BOOL(tests,
6388 [  --disable-tests         Do not build test libraries & programs],
6389     ENABLE_TESTS=,
6390     ENABLE_TESTS=1 )
6392 dnl ========================================================
6393 dnl parental controls (for Windows Vista)
6394 dnl ========================================================
6395 MOZ_ARG_DISABLE_BOOL(parental-controls,
6396 [  --disable-parental-controls
6397                           Do not build parental controls],
6398    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6399    MOZ_DISABLE_PARENTAL_CONTROLS=)
6400 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6401     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6404 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6406 dnl ========================================================
6407 dnl = Disable DOMCrypto
6408 dnl ========================================================
6409 if test -n "$MOZ_DISABLE_DOMCRYPTO"; then
6410     AC_DEFINE(MOZ_DISABLE_DOMCRYPTO)
6413 dnl ========================================================
6414 dnl =
6415 dnl = Module specific options
6416 dnl =
6417 dnl ========================================================
6418 MOZ_ARG_HEADER(Individual module options)
6420 dnl ========================================================
6421 dnl = Disable feed handling components
6422 dnl ========================================================
6423 MOZ_ARG_DISABLE_BOOL(feeds,
6424 [  --disable-feeds         Disable feed handling and processing components],
6425     MOZ_FEEDS=,
6426     MOZ_FEEDS=1 )
6427 if test -n "$MOZ_FEEDS"; then
6428     AC_DEFINE(MOZ_FEEDS)
6429 else
6430     if test "$MOZ_BUILD_APP" = "browser"; then
6431         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6432     fi
6435 dnl ========================================================
6436 dnl Check for sqlite
6437 dnl ========================================================
6439 MOZ_NATIVE_SQLITE=
6440 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6441 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6442 MOZ_NATIVE_SQLITE=1,
6443 MOZ_NATIVE_SQLITE= )
6445 if test -z "$MOZ_NATIVE_SQLITE"
6446 then
6447     SQLITE_CFLAGS=
6448     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6449 else
6450     dnl ============================
6451     dnl === SQLite Version check ===
6452     dnl ============================
6453     dnl Check to see if the system SQLite package is new enough.
6454     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6456     dnl ==================================
6457     dnl === SQLITE_SECURE_DELETE check ===
6458     dnl ==================================
6459     dnl Check to see if the system SQLite package is compiled with
6460     dnl SQLITE_SECURE_DELETE enabled.
6461     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6462     _SAVE_CFLAGS="$CFLAGS"
6463     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6464     _SAVE_LIBS="$LIBS"
6465     LIBS="$LIBS $SQLITE_LIBS"
6466     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6467         AC_TRY_RUN([
6468             #include "sqlite3.h"
6470             int main(int argc, char **argv){
6471               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6472             }],
6473             ac_cv_sqlite_secure_delete=yes,
6474             ac_cv_sqlite_secure_delete=no,
6475             ac_cv_sqlite_secure_delete=no
6476         )
6477     ])
6478     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6479     CFLAGS="$_SAVE_CFLAGS"
6480     LIBS="$_SAVE_LIBS"
6481     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6482         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6483     fi
6485     dnl ===============================
6486     dnl === SQLITE_THREADSAFE check ===
6487     dnl ===============================
6488     dnl Check to see if the system SQLite package is compiled with
6489     dnl SQLITE_THREADSAFE enabled.
6490     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6491     _SAVE_CFLAGS="$CFLAGS"
6492     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6493     _SAVE_LIBS="$LIBS"
6494     LIBS="$LIBS $SQLITE_LIBS"
6495     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6496         AC_TRY_RUN([
6497             #include "sqlite3.h"
6499             int main(int argc, char **argv){
6500               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6501             }],
6502             ac_cv_sqlite_threadsafe=yes,
6503             ac_cv_sqlite_threadsafe=no,
6504             ac_cv_sqlite_threadsafe=no
6505         )
6506     ])
6507     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6508     CFLAGS="$_SAVE_CFLAGS"
6509     LIBS="$_SAVE_LIBS"
6510     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6511         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6512     fi
6514     dnl ================================
6515     dnl === SQLITE_ENABLE_FTS3 check ===
6516     dnl ================================
6517     dnl check to see if the system SQLite package is compiled with
6518     dnl SQLITE_ENABLE_FTS3 enabled.
6519     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6520     _SAVE_CFLAGS="$CFLAGS"
6521     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6522     _SAVE_LIBS="$LIBS"
6523     LIBS="$LIBS $SQLITE_LIBS"
6524     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6525         AC_TRY_RUN([
6526             #include "sqlite3.h"
6528             int main(int argc, char **argv){
6529               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6530             }],
6531             ac_cv_sqlite_enable_fts3=yes,
6532             ac_cv_sqlite_enable_fts3=no,
6533             ac_cv_sqlite_enable_fts3=no
6534         )
6535     ])
6536     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6537     CFLAGS="$_SAVE_CFLAGS"
6538     LIBS="$_SAVE_LIBS"
6539     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6540         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6541     fi
6543     dnl =========================================
6544     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6545     dnl =========================================
6546     dnl check to see if the system SQLite package is compiled with
6547     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6548     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6549     _SAVE_CFLAGS="$CFLAGS"
6550     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6551     _SAVE_LIBS="$LIBS"
6552     LIBS="$LIBS $SQLITE_LIBS"
6553     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6554         AC_TRY_RUN([
6555             #include "sqlite3.h"
6557             int main(int argc, char **argv){
6558               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6559             }],
6560             ac_cv_sqlite_enable_unlock_notify=yes,
6561             ac_cv_sqlite_enable_unlock_notify=no,
6562             ac_cv_sqlite_enable_unlock_notify=no
6563         )
6564     ])
6565     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6566     CFLAGS="$_SAVE_CFLAGS"
6567     LIBS="$_SAVE_LIBS"
6568     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6569         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6570     fi
6573 if test -n "$MOZ_NATIVE_SQLITE"; then
6574     AC_DEFINE(MOZ_NATIVE_SQLITE)
6576 AC_SUBST(MOZ_NATIVE_SQLITE)
6578 dnl ========================================================
6579 dnl = Enable help viewer (off by default)
6580 dnl ========================================================
6581 if test -n "$MOZ_HELP_VIEWER"; then
6582      dnl Do this if defined in confvars.sh
6583      AC_DEFINE(MOZ_HELP_VIEWER)
6586 dnl ========================================================
6587 dnl = Enable safe browsing (anti-phishing)
6588 dnl ========================================================
6589 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6590 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6591     MOZ_SAFE_BROWSING=1,
6592     MOZ_SAFE_BROWSING= )
6593 if test -n "$MOZ_SAFE_BROWSING"; then
6594     AC_DEFINE(MOZ_SAFE_BROWSING)
6596 AC_SUBST(MOZ_SAFE_BROWSING)
6598 dnl ========================================================
6599 dnl = Enable url-classifier
6600 dnl ========================================================
6601 dnl Implicitly enabled by default if building with safe-browsing
6602 if test -n "$MOZ_SAFE_BROWSING"; then
6603     MOZ_URL_CLASSIFIER=1
6605 MOZ_ARG_ENABLE_BOOL(url-classifier,
6606 [  --enable-url-classifier Enable url classifier module],
6607     MOZ_URL_CLASSIFIER=1,
6608     MOZ_URL_CLASSIFIER= )
6609 if test -n "$MOZ_URL_CLASSIFIER"; then
6610     AC_DEFINE(MOZ_URL_CLASSIFIER)
6612 AC_SUBST(MOZ_URL_CLASSIFIER)
6614 dnl ========================================================
6615 dnl = Disable zipwriter
6616 dnl ========================================================
6617 MOZ_ARG_DISABLE_BOOL(zipwriter,
6618 [  --disable-zipwriter     Disable zipwriter component],
6619     MOZ_ZIPWRITER=,
6620     MOZ_ZIPWRITER=1 )
6621 AC_SUBST(MOZ_ZIPWRITER)
6623 dnl ========================================================
6624 dnl = libconic
6625 dnl ========================================================
6626 dnl superseded by QtNetwork starting from 4.7
6627 MOZ_ENABLE_LIBCONIC=1
6629 if test -n "$MOZ_ENABLE_QT"; then
6630   if test "$MOZ_ENABLE_QTNETWORK"; then
6631     MOZ_ENABLE_LIBCONIC=
6632   fi
6635 MOZ_ARG_DISABLE_BOOL(libconic,
6636 [  --disable-libconic      Disable libconic],
6637     MOZ_ENABLE_LIBCONIC=,
6638     MOZ_ENABLE_LIBCONIC=1 )
6640 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6641     PKG_CHECK_MODULES(LIBCONIC, conic,
6642                       MOZ_ENABLE_LIBCONIC=1,
6643                       MOZ_ENABLE_LIBCONIC=)
6645 if test "$MOZ_ENABLE_LIBCONIC"; then
6646     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6649 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6650 AC_SUBST(LIBCONIC_CFLAGS)
6651 AC_SUBST(LIBCONIC_LIBS)
6653 dnl ========================================================
6654 dnl = Maemo checks
6655 dnl ========================================================
6657 MAEMO_SDK_TARGET_VER=-1
6659 MOZ_ARG_WITH_STRING(maemo-version,
6660 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6661                           Maemo SDK Version],
6662   MAEMO_SDK_TARGET_VER=$withval)
6664 case "$MAEMO_SDK_TARGET_VER" in
6666     MOZ_PLATFORM_MAEMO=5
6667     ;;
6670     MOZ_PLATFORM_MAEMO=6
6671     ;;
6674     dnl We aren't compiling for Maemo, move on.
6675     ;;
6677     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6678     ;;
6679 esac
6681 if test $MOZ_PLATFORM_MAEMO; then
6682    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6684    if test -z "$MOZ_ENABLE_DBUS"; then
6685        AC_MSG_ERROR([DBus is required when building for Maemo])
6686    fi
6688    MOZ_GFX_OPTIMIZE_MOBILE=1
6689    MOZ_WEBGL_GLX=
6690    MOZ_MAEMO_LIBLOCATION=
6692    if test $MOZ_PLATFORM_MAEMO = 5; then
6693       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6694       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6695           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6696       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6697                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6699       AC_SUBST(XCOMPOSITE_LIBS)
6701       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6702       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6703       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6704       if test -z "$_LIB_FOUND"; then
6705          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6706       fi
6709       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6710       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6711       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6712       if test -z "$_LIB_FOUND"; then
6713          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6714       fi
6716       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6717       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6718       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6719       if test -z "$_LIB_FOUND"; then
6720          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6721       fi
6723    fi
6724    if test $MOZ_PLATFORM_MAEMO = 6; then
6726       PKG_CHECK_MODULES(LIBCONTENTMANAGER, ContentManager QtSparql,
6727                         _LIB_FOUND=1,
6728                         _LIB_FOUND=)
6729       if test "$_LIB_FOUND"; then
6730          MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTMANAGER_LIBS"
6731          MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTMANAGER_CFLAGS"
6732          MOZ_ENABLE_CONTENTMANAGER=1
6733          AC_DEFINE(MOZ_ENABLE_CONTENTMANAGER)
6734       else
6735          AC_MSG_WARN([Cannot find libcontentmanager and or QtSparql building for Maemo 6])
6736       fi
6737       AC_SUBST(MOZ_ENABLE_CONTENTMANAGER)
6739       dnl ========================================================
6740       dnl = Enable meego libcontentaction
6741       dnl ========================================================
6742       MOZ_ARG_ENABLE_BOOL(meegocontentaction,
6743       [  --enable-meegocontentaction           Enable meegocontentaction support],
6744          MOZ_MEEGOCONTENTACTION=1,
6745          MOZ_MEEGOCONTENTACTION=)
6747       if test -n "$MOZ_MEEGOCONTENTACTION"; then
6749          PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
6750          if test "$_LIB_FOUND"; then
6751             MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
6752             MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
6753             MOZ_ENABLE_CONTENTACTION=1
6754             AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
6755             AC_SUBST(MOZ_ENABLE_CONTENTACTION)
6756          fi
6757       fi
6759       MOZ_ARG_ENABLE_BOOL(meegotouch,
6760       [  --enable-meegotouch  Enable meegotouch support],
6761          MOZ_MEEGOTOUCHENABLED=1,
6762          MOZ_MEEGOTOUCHENABLED=)
6764       if test -n "$MOZ_MEEGOTOUCHENABLED"; then
6765           PKG_CHECK_MODULES(MOZ_MEEGOTOUCH, meegotouchcore, _LIB_FOUND=1, _LIB_FOUND=)
6766           if test "$_LIB_FOUND"; then
6767               MOZ_QT_CFLAGS="$MOZ_MEEGOTOUCH_CFLAGS $MOZ_QT_CFLAGS"
6768               MOZ_QT_LIBS="$MOZ_MEEGOTOUCH_LIBS $MOZ_QT_LIBS"
6769               AC_DEFINE(MOZ_ENABLE_MEEGOTOUCH)
6770           else
6771               AC_MSG_WARN([Cannot meegotouchcore-dev. Disabling Meegotouch support.])
6772           fi
6773       fi
6774    fi
6776    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
6777    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
6778    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
6779    if test "$_LIB_FOUND"; then
6780       MOZ_MAEMO_LIBLOCATION=1
6781       AC_DEFINE(MOZ_MAEMO_LIBLOCATION)
6782    else
6783       AC_MSG_WARN([Cannot liblocation-dev. Disabling Maemo geolocation.])
6784    fi
6785    AC_SUBST(MOZ_MAEMO_LIBLOCATION)
6787    PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=)
6788    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS"
6789    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS"
6790    if test "$_LIB_FOUND"; then
6791       MOZ_ENABLE_MEEGOTOUCHSHARE=1
6792       AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE)
6793    else
6794       AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.])
6795    fi
6796    AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE)
6798    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6799    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6802 dnl ========================================================
6803 dnl = XRender Composite
6804 dnl ========================================================
6805 MOZ_ARG_ENABLE_BOOL(egl-xrender-composite,
6806 [  --enable-egl-xrender-composite
6807                           Enable EGL xrender composite optimizations],
6808     MOZ_EGL_XRENDER_COMPOSITE=1)
6810 if test -n "$MOZ_EGL_XRENDER_COMPOSITE"; then
6811     AC_DEFINE(MOZ_EGL_XRENDER_COMPOSITE)
6814 AC_SUBST(MOZ_EGL_XRENDER_COMPOSITE)
6816 dnl ========================================================
6817 dnl = faststripe theme
6818 dnl ========================================================
6819 MOZ_ARG_ENABLE_BOOL(faststripe,
6820 [  --enable-faststripe     Use faststripe theme],
6821     MOZ_THEME_FASTSTRIPE=1,
6822     MOZ_THEME_FASTSTRIPE= )
6823 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6825 dnl ========================================================
6826 dnl =
6827 dnl = Feature options that require extra sources to be pulled
6828 dnl =
6829 dnl ========================================================
6830 dnl MOZ_ARG_HEADER(Features that require extra sources)
6832 dnl ========================================================
6833 dnl =
6834 dnl = Debugging Options
6835 dnl =
6836 dnl ========================================================
6837 MOZ_ARG_HEADER(Debugging and Optimizations)
6839 dnl ========================================================
6840 dnl = Disable building with debug info.
6841 dnl = Debugging is OFF by default
6842 dnl ========================================================
6843 if test -z "$MOZ_DEBUG_FLAGS"; then
6844   MOZ_DEBUG_FLAGS="-g"
6847 MOZ_ARG_ENABLE_STRING(debug,
6848 [  --enable-debug[=DBG]    Enable building with developer debug info
6849                            (using compiler flags DBG)],
6850 [ if test "$enableval" != "no"; then
6851     MOZ_DEBUG=1
6852     if test -n "$enableval" -a "$enableval" != "yes"; then
6853         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6854         _MOZ_DEBUG_FLAGS_SET=1
6855     fi
6856   else
6857     MOZ_DEBUG=
6858   fi ],
6859   MOZ_DEBUG=)
6861 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
6862 MOZ_ARG_WITH_STRING(debug-label,
6863 [  --with-debug-label=LABELS
6864                           Define DEBUG_<value> for each comma-separated
6865                           value given.],
6866 [ for option in `echo $withval | sed 's/,/ /g'`; do
6867     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
6868 done])
6870 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
6872 if test -n "$MOZ_DEBUG"; then
6873     AC_MSG_CHECKING([for valid debug flags])
6874     _SAVE_CFLAGS=$CFLAGS
6875     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
6876     AC_TRY_COMPILE([#include <stdio.h>],
6877         [printf("Hello World\n");],
6878         _results=yes,
6879         _results=no)
6880     AC_MSG_RESULT([$_results])
6881     if test "$_results" = "no"; then
6882         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
6883     fi
6884     CFLAGS=$_SAVE_CFLAGS
6887 dnl ========================================================
6888 dnl enable mobile optimizations
6889 dnl ========================================================
6890 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6891 [  --enable-mobile-optimize
6892                           Enable mobile optimizations],
6893     MOZ_GFX_OPTIMIZE_MOBILE=1)
6895 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6897 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6898     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6901 dnl ========================================================
6902 dnl = Enable code optimization. ON by default.
6903 dnl ========================================================
6904 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6905         MOZ_OPTIMIZE_FLAGS="-O"
6908 MOZ_ARG_ENABLE_STRING(optimize,
6909 [  --disable-optimize      Disable compiler optimization
6910   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6911 [ if test "$enableval" != "no"; then
6912     MOZ_OPTIMIZE=1
6913     if test -n "$enableval" -a "$enableval" != "yes"; then
6914         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6915         MOZ_OPTIMIZE=2
6916     fi
6917 else
6918     MOZ_OPTIMIZE=
6919 fi ], MOZ_OPTIMIZE=1)
6921 MOZ_SET_FRAMEPTR_FLAGS
6923 if test "$COMPILE_ENVIRONMENT"; then
6924 if test -n "$MOZ_OPTIMIZE"; then
6925     AC_MSG_CHECKING([for valid optimization flags])
6926     _SAVE_CFLAGS=$CFLAGS
6927     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6928     AC_TRY_COMPILE([#include <stdio.h>],
6929         [printf("Hello World\n");],
6930         _results=yes,
6931         _results=no)
6932     AC_MSG_RESULT([$_results])
6933     if test "$_results" = "no"; then
6934         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6935     fi
6936     CFLAGS=$_SAVE_CFLAGS
6938 fi # COMPILE_ENVIRONMENT
6940 AC_SUBST(MOZ_OPTIMIZE)
6941 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
6942 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6943 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6944 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6945 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
6947 dnl ========================================================
6948 dnl = Enable generation of debug symbols
6949 dnl ========================================================
6950 MOZ_ARG_ENABLE_STRING(debug-symbols,
6951 [  --enable-debug-symbols[=DBG]
6952                           Enable debugging symbols (using compiler flags DBG)],
6953 [ if test "$enableval" != "no"; then
6954       MOZ_DEBUG_SYMBOLS=1
6955       if test -n "$enableval" -a "$enableval" != "yes"; then
6956           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
6957               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6958           else
6959               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
6960           fi
6961       fi
6962   else
6963       MOZ_DEBUG_SYMBOLS=
6964   fi ],
6965   MOZ_DEBUG_SYMBOLS=1)
6967 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
6968     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
6969     export MOZ_DEBUG_SYMBOLS
6972 dnl ========================================================
6973 dnl = Identical Code Folding
6974 dnl ========================================================
6976 MOZ_ARG_DISABLE_BOOL(icf,
6977 [  --disable-icf          Disable Identical Code Folding],
6978     MOZ_DISABLE_ICF=1,
6979     MOZ_DISABLE_ICF= )
6981 if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$MOZ_DISABLE_ICF"; then
6982     AC_CACHE_CHECK([whether the linker supports Identical Code Folding],
6983         LD_SUPPORTS_ICF,
6984         [echo 'int foo() {return 42;}' \
6985               'int bar() {return 42;}' \
6986               'int main() {return foo() - bar();}' > conftest.${ac_ext}
6987         # If the linker supports ICF, foo and bar symbols will have
6988         # the same address
6989         if AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS -Wl,--icf=safe -ffunction-sections conftest.${ac_ext} $LIBS 1>&2]) &&
6990            test -s conftest${ac_exeext} &&
6991            objdump -t conftest${ac_exeext} | awk '{a[[$6]] = $1} END {if (a[["foo"]] && (a[["foo"]] != a[["bar"]])) { exit 1 }}'; then
6992             LD_SUPPORTS_ICF=yes
6993         else
6994             LD_SUPPORTS_ICF=no
6995         fi
6996         rm -rf conftest*])
6997     if test "$LD_SUPPORTS_ICF" = yes; then
6998         LDFLAGS="$LDFLAGS -Wl,--icf=safe"
6999         CFLAGS="$CFLAGS -ffunction-sections"
7000         CXXFLAGS="$CXXFLAGS -ffunction-sections"
7001     fi
7004 dnl ========================================================
7005 dnl = Automatically remove dead symbols
7006 dnl ========================================================
7008 if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -n "$MOZ_DEBUG_FLAGS"; then
7009    dnl See bug 670659
7010    AC_CACHE_CHECK([whether removing dead symbols breaks debugging],
7011        GC_SECTIONS_BREAKS_DEBUG_RANGES,
7012        [echo 'int foo() {return 42;}' \
7013              'int bar() {return 1;}' \
7014              'int main() {return foo();}' > conftest.${ac_ext}
7015         if AC_TRY_COMMAND([${CC-cc} -o conftest.${ac_objext} $CFLAGS $MOZ_DEBUG_FLAGS -ffunction-sections -c conftest.${ac_ext} 1>&2]) &&
7016            AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS $MOZ_DEBUG_FLAGS -Wl,--gc-sections conftest.${ac_objext} $LIBS 1>&2]) &&
7017            test -s conftest${ac_exeext} -a -s conftest.${ac_objext}; then
7018             if test "`$PYTHON "$_topsrcdir"/build/unix/check_debug_ranges.py conftest.${ac_objext} conftest.${ac_ext}`" = \
7019                     "`$PYTHON "$_topsrcdir"/build/unix/check_debug_ranges.py conftest${ac_exeext} conftest.${ac_ext}`"; then
7020                 GC_SECTIONS_BREAKS_DEBUG_RANGES=no
7021             else
7022                 GC_SECTIONS_BREAKS_DEBUG_RANGES=yes
7023             fi
7024         else
7025              dnl We really don't expect to get here, but just in case
7026              GC_SECTIONS_BREAKS_DEBUG_RANGES="no, but it's broken in some other way"
7027         fi
7028         rm -rf conftest*])
7029     if test "$GC_SECTIONS_BREAKS_DEBUG_RANGES" = no; then
7030         DSO_LDOPTS="$DSO_LDOPTS -Wl,--gc-sections"
7031         case "$CFLAGS" in
7032         *-ffunction-sections*)
7033             CFLAGS="$CFLAGS -fdata-sections"
7034             CXXFLAGS="$CXXFLAGS -fdata-sections"
7035             ;;
7036         *)
7037             CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
7038             CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
7039             ;;
7040         esac
7041     fi
7044 dnl ========================================================
7045 dnl = Enable any treating of compile warnings as errors
7046 dnl ========================================================
7047 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
7048 [  --enable-warnings-as-errors
7049                           Enable treating of warnings as errors],
7050     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
7051     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
7052 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
7053    WARNINGS_AS_ERRORS=''
7056 dnl ========================================================
7057 dnl = Disable runtime logging checks
7058 dnl ========================================================
7059 MOZ_ARG_DISABLE_BOOL(logging,
7060 [  --disable-logging       Disable logging facilities],
7061     NS_DISABLE_LOGGING=1,
7062     NS_DISABLE_LOGGING= )
7063 if test "$NS_DISABLE_LOGGING"; then
7064     AC_DEFINE(NS_DISABLE_LOGGING)
7065 else
7066     AC_DEFINE(MOZ_LOGGING)
7069 dnl ========================================================
7070 dnl = This will enable logging of addref, release, ctor, dtor.
7071 dnl ========================================================
7072 _ENABLE_LOGREFCNT=42
7073 MOZ_ARG_ENABLE_BOOL(logrefcnt,
7074 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
7075     _ENABLE_LOGREFCNT=1,
7076     _ENABLE_LOGREFCNT= )
7077 if test "$_ENABLE_LOGREFCNT" = "1"; then
7078     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
7079 elif test -z "$_ENABLE_LOGREFCNT"; then
7080     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
7083 dnl ========================================================
7084 dnl moz_dump_painting
7085 dnl ========================================================
7086 MOZ_ARG_ENABLE_BOOL(dump-painting,
7087 [  --enable-dump-painting          Enable paint debugging.],
7088     MOZ_DUMP_PAINTING=1,
7089     MOZ_DUMP_PAINTING= )
7090 if test -n "$MOZ_DUMP_PAINTING"; then
7091     AC_DEFINE(MOZ_DUMP_PAINTING)
7092     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
7094 if test -n "$MOZ_DEBUG"; then
7095     AC_DEFINE(MOZ_DUMP_PAINTING)
7098 dnl ========================================================
7099 dnl = Enable trace malloc
7100 dnl ========================================================
7101 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
7102 MOZ_ARG_ENABLE_BOOL(trace-malloc,
7103 [  --enable-trace-malloc   Enable malloc tracing; also disables jemalloc],
7104     NS_TRACE_MALLOC=1,
7105     NS_TRACE_MALLOC= )
7106 if test "$NS_TRACE_MALLOC"; then
7107   # Please, Mr. Linker Man, don't take away our symbol names
7108   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
7109   USE_ELF_DYNSTR_GC=
7110   AC_DEFINE(NS_TRACE_MALLOC)
7112 AC_SUBST(NS_TRACE_MALLOC)
7114 dnl ========================================================
7115 dnl = Enable jemalloc
7116 dnl ========================================================
7117 MOZ_ARG_ENABLE_BOOL(jemalloc,
7118 [  --enable-jemalloc       Replace memory allocator with jemalloc],
7119     MOZ_MEMORY=1,
7120     MOZ_MEMORY=)
7122 if test "$NS_TRACE_MALLOC"; then
7123     MOZ_MEMORY=
7125 if test "$MOZ_DMD"; then
7126     MOZ_MEMORY=
7129 if test "${OS_TARGET}" = "Android"; then
7130   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
7131   :
7132 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
7133   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
7134   MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7135 else
7136   dnl On other Unix systems, we only want to link executables against mozglue
7137   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib) $(MKSHLIB_UNFORCE_ALL)'
7138   if test -n "$GNU_CC"; then
7139     dnl And we need mozglue symbols to be exported.
7140     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
7141   fi
7144 if test -z "$MOZ_MEMORY"; then
7145   case "${target}" in
7146     *-mingw*)
7147       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7148         AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
7149       fi
7150       ;;
7151   esac
7152 else
7153   dnl Don't try to run compiler tests on Windows
7154   if test "$OS_ARCH" = "WINNT"; then
7155     if test -z "$HAVE_64BIT_OS"; then
7156       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7157     else
7158       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7159     fi
7160   else
7161     AC_CHECK_SIZEOF([int *], [4])
7162     case "${ac_cv_sizeof_int_p}" in
7163     4)
7164       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7165       ;;
7166     8)
7167       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7168       ;;
7169     *)
7170       AC_MSG_ERROR([Unexpected pointer size])
7171       ;;
7172     esac
7173   fi
7175   AC_DEFINE(MOZ_MEMORY)
7176   if test "x$MOZ_DEBUG" = "x1"; then
7177     AC_DEFINE(MOZ_MEMORY_DEBUG)
7178   fi
7179   dnl The generic feature tests that determine how to compute ncpus are long and
7180   dnl complicated.  Therefore, simply define special cpp variables for the
7181   dnl platforms we have special knowledge of.
7182   case "${target}" in
7183   *-darwin*)
7184     AC_DEFINE(MOZ_MEMORY_DARWIN)
7185     ;;
7186   *-*freebsd*)
7187     AC_DEFINE(MOZ_MEMORY_BSD)
7188     ;;
7189   *-android*|*-linuxandroid*)
7190     AC_DEFINE(MOZ_MEMORY_LINUX)
7191     AC_DEFINE(MOZ_MEMORY_ANDROID)
7192     _WRAP_MALLOC=1
7193     MOZ_GLUE_LDFLAGS=
7194     ;;
7195   *-*linux*)
7196     AC_DEFINE(MOZ_MEMORY_LINUX)
7197     ;;
7198   *-netbsd*)
7199     AC_DEFINE(MOZ_MEMORY_BSD)
7200     ;;
7201   *-solaris*)
7202     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7203     ;;
7204   *-mingw*)
7205     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7206     if test -z "$MOZ_DEBUG"; then
7207       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7208     else
7209       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7210     fi
7211     dnl Look for a broken crtdll.obj
7212     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7213     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7214     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7215       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7216       dnl Also pass this to NSPR/NSS
7217       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7218     else
7219       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7220     fi
7221     rm crtdll.obj
7223     export DLLFLAGS
7224     ;;
7225   *)
7226     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7227     ;;
7228   esac
7230   if test "$OS_ARCH" != "WINNT"; then
7231     dnl NB: this must be kept in sync with jemalloc.h
7232     AC_DEFINE(HAVE_JEMALLOC_VALLOC)
7233   fi
7234   AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
7235   AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
7236 fi # MOZ_MEMORY
7237 AC_SUBST(MOZ_MEMORY)
7238 AC_SUBST(MOZ_GLUE_LDFLAGS)
7239 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7240 AC_SUBST(WIN32_CRT_LIBS)
7241 dnl Need to set this for make because NSS doesn't have configure
7242 AC_SUBST(DLLFLAGS)
7244 dnl We need to wrap dlopen and related functions on Android because we use
7245 dnl our own linker.
7246 if test "$OS_TARGET" = Android; then
7247     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7248     if test "$MOZ_WIDGET_TOOLKIT" = android; then
7249         if test -n "$MOZ_OLD_LINKER"; then
7250             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
7251         fi
7252         WRAP_LDFLAGS="${WRAP_LDFLAGS} --wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7253     fi
7256 dnl ========================================================
7257 dnl = Use malloc wrapper lib
7258 dnl ========================================================
7259 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7260 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7261     _WRAP_MALLOC=1,
7262     _WRAP_MALLOC= )
7264 if test -n "$_WRAP_MALLOC"; then
7265     if test -n "$GNU_CC"; then
7266         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7267         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7268         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_Free,--wrap=PR_Malloc,--wrap=PR_Calloc,--wrap=PR_Realloc"
7269         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7270         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7271     else
7272         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7273     fi
7276 dnl ========================================================
7277 dnl = Location of malloc wrapper lib
7278 dnl ========================================================
7279 MOZ_ARG_WITH_STRING(wrap-malloc,
7280 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7281     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7283 dnl ========================================================
7284 dnl = Use JS Call tracing
7285 dnl ========================================================
7286 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7287 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7288     MOZ_TRACE_JSCALLS=1,
7289     MOZ_TRACE_JSCALLS= )
7290 if test -n "$MOZ_TRACE_JSCALLS"; then
7291     AC_DEFINE(MOZ_TRACE_JSCALLS)
7294 dnl ========================================================
7295 dnl = Use incremental GC
7296 dnl ========================================================
7297 JSGC_INCREMENTAL=1
7298 MOZ_ARG_DISABLE_BOOL(gcincremental,
7299 [  --disable-gcincremental Disable incremental GC],
7300     JSGC_INCREMENTAL= )
7301 if test -n "$JSGC_INCREMENTAL"; then
7302     AC_DEFINE(JSGC_INCREMENTAL)
7305 dnl ========================================================
7306 dnl ETW - Event Tracing for Windows
7307 dnl ========================================================
7308 MOZ_ARG_ENABLE_BOOL(ETW,
7309 [  --enable-ETW            Enable ETW (Event Tracing for Windows) event reporting
7310                           (needs Windows Vista+ SDK)],
7311     MOZ_ETW=1,
7312     MOZ_ETW= )
7313 if test -n "$MOZ_ETW"; then
7314     AC_DEFINE(MOZ_ETW)
7317 if test -n "$MOZ_ETW"; then
7318     if test -z "$MOZ_WINSDK_TARGETVER"; then
7319         AC_MSG_ERROR([--enable-ETW is only valid on Windows])
7320     elif test "$MOZ_WINSDK_TARGETVER" -lt "06000000"; then
7321         AC_MSG_ERROR([--enable-ETW requires the Windows Vista SDK or newer])
7322     fi
7325 dnl ========================================================
7326 dnl Zealous JavaScript GC
7327 dnl ========================================================
7328 MOZ_ARG_ENABLE_BOOL(gczeal,
7329 [  --enable-gczeal         Enable zealous JavaScript GCing],
7330     JS_GC_ZEAL=1,
7331     JS_GC_ZEAL= )
7332 if test -n "$JS_GC_ZEAL"; then
7333     AC_DEFINE(JS_GC_ZEAL)
7336 dnl ========================================================
7337 dnl JS opt-mode assertions and minidump instrumentation
7338 dnl ========================================================
7339 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7340 [  --enable-js-diagnostics
7341                           Enable JS diagnostic assertions and breakpad data],
7342     JS_CRASH_DIAGNOSTICS=1,
7343     JS_CRASH_DIAGNOSTICS= )
7344 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7345     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7348 dnl ======================================================
7349 dnl = Enable compiling with ccache
7350 dnl ======================================================
7351 MOZ_ARG_WITH_STRING(ccache,
7352 [  --with-ccache[=path/to/ccache]
7353                           Enable compiling with ccache],
7354     CCACHE=$withval, CCACHE="no")
7356 if test "$CCACHE" != "no"; then
7357     if test -z "$CCACHE" -o "$CCACHE" = "yes"; then
7358         CCACHE=
7359     else
7360         if test ! -e "$CCACHE"; then
7361             AC_MSG_ERROR([$CCACHE not found])
7362         fi
7363     fi
7364     MOZ_PATH_PROGS(CCACHE, $CCACHE ccache)
7365     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
7366         AC_MSG_ERROR([ccache not found])
7367     elif test -x "$CCACHE"; then
7368         CC="$CCACHE $CC"
7369         CXX="$CCACHE $CXX"
7370     else
7371         AC_MSG_ERROR([$CCACHE is not executable])
7372     fi
7375 dnl ========================================================
7376 dnl = Enable static checking using gcc-dehydra
7377 dnl ========================================================
7379 MOZ_ARG_WITH_STRING(static-checking,
7380 [  --with-static-checking=path/to/gcc_dehydra.so
7381                           Enable static checking of code using GCC-dehydra],
7382     DEHYDRA_PATH=$withval,
7383     DEHYDRA_PATH= )
7385 if test -n "$DEHYDRA_PATH"; then
7386     if test ! -f "$DEHYDRA_PATH"; then
7387         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7388     fi
7389     AC_DEFINE(NS_STATIC_CHECKING)
7391 AC_SUBST(DEHYDRA_PATH)
7393 dnl ========================================================
7394 dnl = Enable stripping of libs & executables
7395 dnl ========================================================
7396 MOZ_ARG_ENABLE_BOOL(strip,
7397 [  --enable-strip          Enable stripping of libs & executables ],
7398     ENABLE_STRIP=1,
7399     ENABLE_STRIP= )
7401 dnl ========================================================
7402 dnl = Enable stripping of libs & executables when packaging
7403 dnl ========================================================
7404 MOZ_ARG_ENABLE_BOOL(install-strip,
7405 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7406     PKG_SKIP_STRIP= ,
7407     PKG_SKIP_STRIP=1)
7409 dnl ========================================================
7410 dnl = --enable-elf-dynstr-gc
7411 dnl ========================================================
7412 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7413 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7414     USE_ELF_DYNSTR_GC=1,
7415     USE_ELF_DYNSTR_GC= )
7417 dnl ========================================================
7418 dnl = --disable-elf-hack
7419 dnl ========================================================
7421 USE_ELF_HACK=1
7422 MOZ_ARG_DISABLE_BOOL(elf-hack,
7423 [  --disable-elf-hack      Disable elf hacks],
7424     USE_ELF_HACK=,
7425     USE_ELF_HACK=1)
7427 # Only enable elfhack where supported
7428 if test "$USE_ELF_HACK" = 1; then
7429     case "${HOST_OS_ARCH},${OS_ARCH}" in
7430     Linux,Linux)
7431         case "${CPU_ARCH}" in
7432         arm | x86 | x86_64)
7433             USE_ELF_HACK=1
7434             ;;
7435         *)
7436             USE_ELF_HACK=
7437             ;;
7438         esac
7439         ;;
7440     *)
7441         USE_ELF_HACK=
7442         ;;
7443     esac
7446 if test "$USE_ELF_HACK" = 1; then
7447     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7448     dnl memory addresses it maps to. The result is that by the time elfhack
7449     dnl kicks in, it is not possible to apply relocations because of that,
7450     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7451     dnl segment. It makes elfhack mostly useless, so considering the problems
7452     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7453     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7454     dnl the linker creates PT_GNU_RELRO segments.
7455     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7456         LINK_WITH_PT_GNU_RELRO,
7457         [echo "int main() {return 0;}" > conftest.${ac_ext}
7458          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7459             test -s conftest${ac_exeext}; then
7460             if readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7461                 LINK_WITH_PT_GNU_RELRO=yes
7462             else
7463                 LINK_WITH_PT_GNU_RELRO=no
7464             fi
7465          else
7466              dnl We really don't expect to get here, but just in case
7467              AC_ERROR([couldn't compile a simple C file])
7468          fi
7469          rm -rf conftest*])
7470     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7471         AC_MSG_WARN([Disabling elfhack])
7472         USE_ELF_HACK=
7473     fi
7476 dnl ========================================================
7477 dnl = libstdc++ compatibility hacks
7478 dnl ========================================================
7480 STDCXX_COMPAT=
7481 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7482 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7483     STDCXX_COMPAT=stdc++compat.cpp)
7485 AC_SUBST(STDCXX_COMPAT)
7487 if test -n "$STDCXX_COMPAT"; then
7488    eval $(CXX="$CXX" MACOS_SDK_DIR="$MACOS_SDK_DIR" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7489    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7490    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7493 dnl ========================================================
7494 dnl =
7495 dnl = Profiling and Instrumenting
7496 dnl =
7497 dnl ========================================================
7498 MOZ_ARG_HEADER(Profiling and Instrumenting)
7500 dnl ========================================================
7501 dnl = Enable NS_FUNCTION_TIMER, which provides Function
7502 dnl = timing for identifying code bottlenecks
7503 dnl = NS_FUNCTION_TIMER is off by default.
7504 dnl ========================================================
7505 MOZ_ARG_ENABLE_BOOL(functiontimer,
7506 [  --enable-functiontimer  Enable NS_FUNCTION_TIMER ],
7507     NS_FUNCTION_TIMER=1,
7508     NS_FUNCTION_TIMER= )
7509 if test -n "$NS_FUNCTION_TIMER"; then
7510     AC_DEFINE(NS_FUNCTION_TIMER)
7513 dnl ========================================================
7514 dnl Turn on reflow counting
7515 dnl ========================================================
7516 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7517 [  --enable-reflow-perf    Enable reflow performance tracing],
7518     MOZ_REFLOW_PERF=1,
7519     MOZ_REFLOW_PERF= )
7520 if test -n "$MOZ_REFLOW_PERF"; then
7521     AC_DEFINE(MOZ_REFLOW_PERF)
7524 dnl ========================================================
7525 dnl Enable code size metrics.
7526 dnl ========================================================
7527 MOZ_ARG_ENABLE_BOOL(codesighs,
7528 [  --enable-codesighs      Enable code size analysis tools],
7529     _ENABLE_CODESIGHS=1,
7530     _ENABLE_CODESIGHS= )
7531 if test -n "$_ENABLE_CODESIGHS"; then
7532     if test -d $srcdir/tools/codesighs; then
7533         MOZ_MAPINFO=1
7534     else
7535         AC_MSG_ERROR([Codesighs directory $srcdir/tools/codesighs required.])
7536     fi
7539 dnl ========================================================
7540 dnl = Support for Quantify (Windows)
7541 dnl ========================================================
7542 MOZ_ARG_ENABLE_BOOL(quantify,
7543 [  --enable-quantify       Enable Quantify support (Windows only) ],
7544     MOZ_QUANTIFY=1,
7545     MOZ_QUANTIFY= )
7547 dnl ========================================================
7548 dnl = Enable Radio Interface for B2G (Gonk usually)
7549 dnl ========================================================
7550 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7551 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7552     MOZ_B2G_RIL=1,
7553     MOZ_B2G_RIL= )
7554 if test -n "$MOZ_B2G_RIL"; then
7555    AC_DEFINE(MOZ_B2G_RIL)
7557 AC_SUBST(MOZ_B2G_RIL)
7559 dnl ========================================================
7560 dnl = Support for demangling undefined symbols
7561 dnl ========================================================
7562 if test -z "$SKIP_LIBRARY_CHECKS"; then
7563     AC_LANG_SAVE
7564     AC_LANG_CPLUSPLUS
7565     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7566     AC_LANG_RESTORE
7569 # Demangle only for debug or trace-malloc builds
7570 MOZ_DEMANGLE_SYMBOLS=
7571 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
7572     MOZ_DEMANGLE_SYMBOLS=1
7573     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7575 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7577 dnl ========================================================
7578 dnl = Support for gcc stack unwinding (from gcc 3.3)
7579 dnl ========================================================
7580 if test -z "$SKIP_LIBRARY_CHECKS"; then
7581     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7584 dnl ========================================================
7585 dnl JIT observers
7586 dnl ========================================================
7588 MOZ_ARG_WITH_STRING(jitreport-granularity,
7589 [  --jitreport-granularity=N
7590                            Default granularity at which to report JIT code
7591                            to external tools
7592                              0 - no info
7593                              1 - code ranges for whole functions only
7594                              2 - per-line information
7595                              3 - per-op information],
7596   JITREPORT_GRANULARITY=$withval,
7597   JITREPORT_GRANULARITY=3)
7599 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7601 dnl ========================================================
7602 dnl =
7603 dnl = Misc. Options
7604 dnl =
7605 dnl ========================================================
7606 MOZ_ARG_HEADER(Misc. Options)
7608 dnl ========================================================
7609 dnl update xterm title
7610 dnl ========================================================
7611 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7612 [  --enable-xterm-updates  Update XTERM titles with current command.],
7613     MOZ_UPDATE_XTERM=1,
7614     MOZ_UPDATE_XTERM= )
7616 dnl =========================================================
7617 dnl = Chrome format
7618 dnl =========================================================
7619 MOZ_ARG_ENABLE_STRING([chrome-format],
7620 [  --enable-chrome-format=jar|flat|both|symlink|omni
7621                           Select FORMAT of chrome files (default=jar)],
7622     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7624 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7625     MOZ_CHROME_FILE_FORMAT=jar
7628 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7629     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7630     test "$MOZ_CHROME_FILE_FORMAT" != "symlink" &&
7631     test "$MOZ_CHROME_FILE_FORMAT" != "both" &&
7632     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7633     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, symlink, or omni])
7636 dnl =========================================================
7637 dnl Omnijar packaging (bug 552121)
7638 dnl =========================================================
7639 dnl Omnijar packaging is compatible with flat packaging.
7640 dnl In unpackaged builds, omnijar looks for files as if
7641 dnl things were flat packaged. After packaging, all files
7642 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7643 dnl is set to flat since putting files into jars is only
7644 dnl done during packaging with omnijar.
7645 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7646     MOZ_OMNIJAR=1
7647     AC_DEFINE(MOZ_OMNIJAR)
7648     if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$OS_TARGET" = "Android"; then
7649         MOZ_CHROME_FILE_FORMAT=flat
7650     else
7651         MOZ_CHROME_FILE_FORMAT=symlink
7652     fi
7653 elif test "$MOZ_CHROME_FILE_FORMAT" = "jar"; then
7654     AC_DEFINE(MOZ_CHROME_FILE_FORMAT_JAR)
7657 OMNIJAR_NAME=omni.ja
7658 AC_SUBST(OMNIJAR_NAME)
7659 AC_SUBST(MOZ_OMNIJAR)
7661 dnl ========================================================
7662 dnl = Define default location for MOZILLA_FIVE_HOME
7663 dnl ========================================================
7664 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7665 [  --with-default-mozilla-five-home
7666                           Set the default value for MOZILLA_FIVE_HOME],
7667 [ val=`echo $withval`
7668   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7670 dnl ========================================================
7671 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7672 dnl ========================================================
7673 MOZ_ARG_WITH_STRING(user-appdir,
7674 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7675 [ val=`echo $withval`
7676 if echo "$val" | grep "\/" >/dev/null; then
7677     AC_MSG_ERROR("Homedir must be single relative path.")
7678 else
7679     MOZ_USER_DIR="$val"
7680 fi])
7682 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7684 dnl ========================================================
7685 dnl = Doxygen configuration
7686 dnl ========================================================
7687 dnl Use commas to specify multiple dirs to this arg
7688 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7689 MOZ_ARG_WITH_STRING(doc-input-dirs,
7690 [  --with-doc-input-dirs=DIRS
7691                           Header/idl dirs to create docs from],
7692 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7693 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7695 dnl Use commas to specify multiple dirs to this arg
7696 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7697 MOZ_ARG_WITH_STRING(doc-include-dirs,
7698 [  --with-doc-include-dirs=DIRS
7699                           Include dirs to preprocess doc headers],
7700 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7701 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7703 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7704 MOZ_ARG_WITH_STRING(doc-output-dir,
7705 [  --with-doc-output-dir=DIR
7706                           Dir to generate docs into],
7707 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7708 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7710 if test -z "$SKIP_COMPILER_CHECKS"; then
7711 dnl ========================================================
7712 dnl =
7713 dnl = Compiler Options
7714 dnl =
7715 dnl ========================================================
7716 MOZ_ARG_HEADER(Compiler Options)
7718 dnl ========================================================
7719 dnl Check for gcc -pipe support
7720 dnl ========================================================
7721 AC_MSG_CHECKING([for -pipe support])
7722 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7723     dnl Any gcc that supports firefox supports -pipe.
7724     CFLAGS="$CFLAGS -pipe"
7725     CXXFLAGS="$CXXFLAGS -pipe"
7726     AC_MSG_RESULT([yes])
7727 else
7728     AC_MSG_RESULT([no])
7731 dnl ========================================================
7732 dnl Profile guided optimization (gcc checks)
7733 dnl ========================================================
7734 dnl Test for profiling options
7735 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7737 _SAVE_CFLAGS="$CFLAGS"
7738 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7740 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7741 AC_TRY_COMPILE([], [return 0;],
7742                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7743                  result="yes" ], result="no")
7744 AC_MSG_RESULT([$result])
7746 if test $result = "yes"; then
7747   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7748   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7749   PROFILE_USE_LDFLAGS="-fprofile-use"
7752 CFLAGS="$_SAVE_CFLAGS"
7754 if test -n "$INTEL_CC"; then
7755   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7756   PROFILE_GEN_LDFLAGS=
7757   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7758   PROFILE_USE_LDFLAGS=
7761 dnl Sun Studio on Solaris
7762 if test "$SOLARIS_SUNPRO_CC"; then
7763   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7764   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7765   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7766   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7769 AC_SUBST(PROFILE_GEN_CFLAGS)
7770 AC_SUBST(PROFILE_GEN_LDFLAGS)
7771 AC_SUBST(PROFILE_USE_CFLAGS)
7772 AC_SUBST(PROFILE_USE_LDFLAGS)
7774 AC_LANG_CPLUSPLUS
7776 dnl ========================================================
7777 dnl Test for -pedantic bustage
7778 dnl ========================================================
7779 MOZ_ARG_DISABLE_BOOL(pedantic,
7780 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],
7781 _PEDANTIC= )
7782 if test "$_PEDANTIC"; then
7783     _SAVE_CXXFLAGS=$CXXFLAGS
7784     CXXFLAGS="$CXXFLAGS -pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7785     AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
7786     AC_TRY_COMPILE([$configure_static_assert_macros],
7787                    [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
7788                    result="no", result="yes" )
7789     AC_MSG_RESULT([$result])
7790     CXXFLAGS="$_SAVE_CXXFLAGS"
7792     case "$result" in
7793     no)
7794         _WARNINGS_CFLAGS="-pedantic ${_WARNINGS_CFLAGS} -Wno-long-long"
7795         _WARNINGS_CXXFLAGS="-pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7796         ;;
7797     yes)
7798         AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic.  Reconfigure using --disable-pedantic. ])
7799         ;;
7800     esac
7803 dnl ========================================================
7804 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7805 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7806 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7807 dnl ========================================================
7808 _SAVE_CXXFLAGS=$CXXFLAGS
7809 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7810 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7811     ac_nscap_nonconst_opeq_bug,
7812     [AC_TRY_COMPILE([
7813                       template <class T>
7814                       class Pointer
7815                         {
7816                         public:
7817                           T* myPtr;
7818                         };
7820                       template <class T, class U>
7821                       int operator==(const Pointer<T>& rhs, U* lhs)
7822                         {
7823                           return rhs.myPtr == lhs;
7824                         }
7826                       template <class T, class U>
7827                       int operator==(const Pointer<T>& rhs, const U* lhs)
7828                         {
7829                           return rhs.myPtr == lhs;
7830                         }
7831                     ],
7832                     [
7833                       Pointer<int> foo;
7834                       const int* bar;
7835                       return foo == bar;
7836                     ],
7837                     ac_nscap_nonconst_opeq_bug="no",
7838                     ac_nscap_nonconst_opeq_bug="yes")])
7839 CXXFLAGS="$_SAVE_CXXFLAGS"
7841 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7842     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7844 fi # ! SKIP_COMPILER_CHECKS
7846 AC_DEFINE(CPP_THROW_NEW, [throw()])
7847 AC_LANG_C
7849 dnl ========================================================
7850 dnl =
7851 dnl = Check what kind of list files are supported by the
7852 dnl = linker
7853 dnl =
7854 dnl ========================================================
7856 AC_CACHE_CHECK(what kind of list files are supported by the linker,
7857     EXPAND_LIBS_LIST_STYLE,
7858     [echo "int main() {return 0;}" > conftest.${ac_ext}
7859      if AC_TRY_COMMAND(${CC-cc} -o conftest.${OBJ_SUFFIX} -c $CFLAGS $CPPFLAGS conftest.${ac_ext} 1>&2) && test -s conftest.${OBJ_SUFFIX}; then
7860          echo "INPUT(conftest.${OBJ_SUFFIX})" > conftest.list
7861          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.list $LIBS 1>&2) && test -s conftest${ac_exeext}; then
7862              EXPAND_LIBS_LIST_STYLE=linkerscript
7863          else
7864              echo "conftest.${OBJ_SUFFIX}" > conftest.list
7865              if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS @conftest.list $LIBS 1>&2) && test -s conftest${ac_exeext}; then
7866                  EXPAND_LIBS_LIST_STYLE=list
7867              else
7868                  EXPAND_LIBS_LIST_STYLE=none
7869              fi
7870          fi
7871      else
7872          dnl We really don't expect to get here, but just in case
7873          AC_ERROR([couldn't compile a simple C file])
7874      fi
7875      rm -rf conftest*])
7877 LIBS_DESC_SUFFIX=desc
7878 AC_SUBST(LIBS_DESC_SUFFIX)
7879 AC_SUBST(EXPAND_LIBS_LIST_STYLE)
7881 dnl ========================================================
7882 dnl =
7883 dnl = Build depencency options
7884 dnl =
7885 dnl ========================================================
7886 MOZ_ARG_HEADER(Build dependencies)
7888 dnl ========================================================
7889 dnl = Do not auto generate dependency info
7890 dnl ========================================================
7891 MOZ_AUTO_DEPS=1
7892 MOZ_ARG_DISABLE_BOOL(auto-deps,
7893 [  --disable-auto-deps     Do not automatically generate dependency info],
7894     MOZ_AUTO_DEPS=,
7895     MOZ_AUTO_DEPS=1)
7897 if test -n "$MOZ_AUTO_DEPS"; then
7898 dnl ========================================================
7899 dnl = Use mkdepend instead of $CC -MD for dependency generation
7900 dnl ========================================================
7901 _cpp_md_flag=
7902 MOZ_ARG_DISABLE_BOOL(md,
7903 [  --disable-md            Do not use compiler-based dependencies ],
7904   [_cpp_md_flag=],
7905   [_cpp_md_flag=1],
7906   [dnl Default is to turn on -MD if using GNU-compatible compilers
7907    if test "$GNU_CC" -a "$GNU_CXX"; then
7908      _cpp_md_flag=1
7909    fi
7910   dnl Default is to use -xM if using Sun Studio on Solaris
7911    if test "$SOLARIS_SUNPRO_CC"; then
7912      _cpp_md_flag=1
7913    fi])
7914 if test "$_cpp_md_flag"; then
7915   COMPILER_DEPEND=1
7916   _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(basename $(@F)).pp)'
7917   dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7918   if test "$SOLARIS_SUNPRO_CC"; then
7919     _DEPEND_CFLAGS=
7920   fi
7921 else
7922   COMPILER_DEPEND=
7923   dnl Don't override this for MSVC
7924   if test -z "$_WIN32_MSVC"; then
7925     _USE_CPP_INCLUDE_FLAG=
7926     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7927     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7928   else
7929     echo '#include <stdio.h>' > dummy-hello.c
7930     changequote(,)
7931     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
7932     changequote([,])
7933     if test -z "$CL_INCLUDES_PREFIX"; then
7934         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7935     fi
7936     AC_SUBST(CL_INCLUDES_PREFIX)
7937     rm -f dummy-hello.c
7938     _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
7939     dnl cl.py provides dependency generation for MSVC
7940     CC_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
7941     CXX_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
7942     COMPILER_DEPEND=1
7943   fi
7945 fi # MOZ_AUTO_DEPS
7946 MDDEPDIR='.deps'
7947 AC_SUBST(MOZ_AUTO_DEPS)
7948 AC_SUBST(COMPILER_DEPEND)
7949 AC_SUBST(MDDEPDIR)
7950 AC_SUBST(CC_WRAPPER)
7951 AC_SUBST(CXX_WRAPPER)
7954 dnl ========================================================
7955 dnl =
7956 dnl = Static Build Options
7957 dnl =
7958 dnl ========================================================
7959 MOZ_ARG_HEADER(Static build options)
7961 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
7962 if test "$OS_ARCH" = "WINNT" -a "$CPU_ARCH" != "x86_64" ; then
7963   ENABLE_SHARED_JS=1
7966 MOZ_ARG_ENABLE_BOOL(shared-js,
7967 [  --enable-shared-js
7968                           Create a shared JavaScript library.],
7969     ENABLE_SHARED_JS=1,
7970     ENABLE_SHARED_JS=)
7972 if test -n "$ENABLE_SHARED_JS"; then
7973   JS_SHARED_LIBRARY=1
7974   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
7975 else
7976   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
7977   AC_DEFINE(MOZ_STATIC_JS)
7979 AC_SUBST(JS_SHARED_LIBRARY)
7981 AC_SUBST(LIBXUL_LIBS)
7982 XPCOM_LIBS="$LIBXUL_LIBS"
7984 dnl ========================================================
7985 dnl =
7986 dnl = Standalone module options
7987 dnl =
7988 dnl ========================================================
7989 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7991 dnl Check for GLib.
7992 dnl ========================================================
7994 if test -z "$SKIP_PATH_CHECKS"; then
7995 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
7996     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
7997         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
7998     else
7999         AM_PATH_GLIB(${GLIB_VERSION})
8000     fi
8004 if test -z "${GLIB_GMODULE_LIBS}" \
8005    -a -n "${GLIB_CONFIG}"\
8006     -a "${GLIB_CONFIG}" != no\
8007 ; then
8008     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
8011 AC_SUBST(GLIB_CFLAGS)
8012 AC_SUBST(GLIB_LIBS)
8013 AC_SUBST(GLIB_GMODULE_LIBS)
8015 dnl ========================================================
8016 dnl Graphics checks.
8017 dnl ========================================================
8019 if test "${OS_ARCH}" = "Darwin" -o "${MOZ_WIDGET_TOOLKIT}" = "android"; then
8020 MOZ_ENABLE_SKIA=1
8021 else
8022 MOZ_ENABLE_SKIA=
8025 MOZ_ARG_ENABLE_BOOL(skia,
8026 [  --enable-skia   Enable use of Skia],
8027 MOZ_ENABLE_SKIA=1,
8028 MOZ_ENABLE_SKIA=)
8030 dnl ========================================================
8031 dnl Check for cairo
8032 dnl ========================================================
8033 MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8035 MOZ_TREE_CAIRO=1
8036 MOZ_ARG_ENABLE_BOOL(system-cairo,
8037 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8038 MOZ_TREE_CAIRO=,
8039 MOZ_TREE_CAIRO=1 )
8041 MOZ_TREE_PIXMAN=1
8042 MOZ_ARG_ENABLE_BOOL(system-pixman,
8043 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8044 MOZ_TREE_PIXMAN=,
8045 MOZ_TREE_PIXMAN=1 )
8047 # Check for headers defining standard int types.
8048 MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8050 if test "$MOZ_TREE_CAIRO"; then
8051     AC_DEFINE(MOZ_TREE_CAIRO)
8053     # For now we assume that we will have a uint64_t available through
8054     # one of the above headers or mozstdint.h.
8055     AC_DEFINE(HAVE_UINT64_T)
8057     # Define macros for cairo-features.h
8058     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8059     if test "$MOZ_X11"; then
8060         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8061         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8062         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8063         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8064         MOZ_ENABLE_CAIRO_FT=1
8065         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8066     fi
8067     case "$MOZ_WIDGET_TOOLKIT" in
8068       qt)
8069         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8070         ;;
8071       cocoa | uikit)
8072         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8073         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8074         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8075         ;;
8076       windows)
8077         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8078         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8079         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8080             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8081             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8082             MOZ_ENABLE_D2D_SURFACE=1
8083             MOZ_ENABLE_DWRITE_FONT=1
8084         else
8085             WIN32_DWRITE_FONT_FEATURE=
8086             WIN32_D2D_SURFACE_FEATURE=
8087         fi
8089         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8091         dnl D3D10 Layers depend on D2D Surfaces.
8092         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8093           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8094         fi
8095         ;;
8096       os2)
8097         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
8098         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8099         MOZ_ENABLE_CAIRO_FT=1
8100         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
8101         CAIRO_FT_LIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
8102         ;;
8103     esac
8104     if test "$USE_FC_FREETYPE"; then
8105         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8106     fi
8107     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8108     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8109     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8110     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8111     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8112     AC_SUBST(CAIRO_FT_CFLAGS)
8114     if test "$MOZ_DEBUG"; then
8115       SANITY_CHECKING_FEATURE="#define CAIRO_DO_SANITY_CHECKING 1"
8116     else
8117       SANITY_CHECKING_FEATURE="#undef CAIRO_DO_SANITY_CHECKING"
8118     fi
8120     AC_SUBST(PS_SURFACE_FEATURE)
8121     AC_SUBST(PDF_SURFACE_FEATURE)
8122     AC_SUBST(SVG_SURFACE_FEATURE)
8123     AC_SUBST(XLIB_SURFACE_FEATURE)
8124     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8125     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8126     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8127     AC_SUBST(XCB_SURFACE_FEATURE)
8128     AC_SUBST(WIN32_SURFACE_FEATURE)
8129     AC_SUBST(OS2_SURFACE_FEATURE)
8130     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8131     AC_SUBST(FT_FONT_FEATURE)
8132     AC_SUBST(FC_FONT_FEATURE)
8133     AC_SUBST(WIN32_FONT_FEATURE)
8134     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8135     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8136     AC_SUBST(QUARTZ_FONT_FEATURE)
8137     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8138     AC_SUBST(QT_SURFACE_FEATURE)
8139     AC_SUBST(TEE_SURFACE_FEATURE)
8141     MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
8143     if test "$MOZ_TREE_PIXMAN"; then
8144         AC_DEFINE(MOZ_TREE_PIXMAN)
8145         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS"' $(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8146     else
8147         PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8148         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $PIXMAN_CFLAGS"
8149         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $PIXMAN_LIBS"
8150     fi
8152     if test "$MOZ_X11"; then
8153         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS -lXrender -lfreetype -lfontconfig"
8154     fi
8156     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8157     mv -f $CAIRO_FEATURES_H "$CAIRO_FEATURES_H".orig 2> /dev/null
8159 else
8160    PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION pixman-1 freetype2 fontconfig)
8161    MOZ_CAIRO_CFLAGS=$CAIRO_CFLAGS
8162    MOZ_CAIRO_LIBS=$CAIRO_LIBS
8163    PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8164    if test "$MOZ_X11"; then
8165         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8166         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8167         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8168    fi
8171 AC_SUBST(MOZ_TREE_CAIRO)
8172 AC_SUBST(MOZ_CAIRO_CFLAGS)
8173 AC_SUBST(MOZ_CAIRO_LIBS)
8174 AC_SUBST(MOZ_TREE_PIXMAN)
8176 dnl ========================================================
8177 dnl qcms
8178 dnl ========================================================
8180 QCMS_LIBS='$(call EXPAND_LIBNAME_PATH,mozqcms,$(DEPTH)/gfx/qcms)'
8181 AC_SUBST(QCMS_LIBS)
8183 dnl ========================================================
8184 dnl HarfBuzz
8185 dnl ========================================================
8186 MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
8187 AC_SUBST(MOZ_HARFBUZZ_LIBS)
8189 dnl ========================================================
8190 dnl SIL Graphite
8191 dnl ========================================================
8192 if test "$MOZ_GRAPHITE"; then
8193   MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
8194   AC_DEFINE(MOZ_GRAPHITE)
8195 else
8196   MOZ_GRAPHITE_LIBS=
8198 AC_SUBST(MOZ_GRAPHITE)
8199 AC_SUBST(MOZ_GRAPHITE_LIBS)
8201 dnl ========================================================
8202 dnl OTS
8203 dnl ========================================================
8204 MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
8205 AC_SUBST(MOZ_OTS_LIBS)
8207 dnl ========================================================
8208 dnl Skia 
8209 dnl ========================================================
8210 if test "$MOZ_ENABLE_SKIA"; then
8211   MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
8212   AC_DEFINE(MOZ_ENABLE_SKIA)
8213 else
8214   MOZ_SKIA_LIBS=
8216 AC_SUBST(MOZ_ENABLE_SKIA)
8217 AC_SUBST(MOZ_SKIA_LIBS)
8219 dnl ========================================================
8220 dnl disable xul
8221 dnl ========================================================
8222 MOZ_ARG_DISABLE_BOOL(xul,
8223 [  --disable-xul           Disable XUL],
8224     MOZ_XUL= )
8225 if test "$MOZ_XUL"; then
8226   AC_DEFINE(MOZ_XUL)
8227 else
8228   dnl remove extensions that require XUL
8229   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8232 AC_SUBST(MOZ_XUL)
8234 dnl ========================================================
8235 dnl disable profile locking
8236 dnl   do no use this in applications that can have more than
8237 dnl   one process accessing the profile directory.
8238 dnl ========================================================
8239 MOZ_ARG_DISABLE_BOOL(profilelocking,
8240 [  --disable-profilelocking
8241                           Disable profile locking],
8242     MOZ_PROFILELOCKING=,
8243     MOZ_PROFILELOCKING=1 )
8244 if test "$MOZ_PROFILELOCKING"; then
8245   AC_DEFINE(MOZ_PROFILELOCKING)
8248 dnl ========================================================
8249 dnl necko configuration options
8250 dnl ========================================================
8253 dnl option to disable various necko protocols
8255 MOZ_ARG_ENABLE_STRING(necko-protocols,
8256 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8257                           Enable/disable specific protocol handlers],
8258 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8259     if test "$option" = "yes" -o "$option" = "all"; then
8260         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8261     elif test "$option" = "no" -o "$option" = "none"; then
8262         NECKO_PROTOCOLS=""
8263     elif test "$option" = "default"; then
8264         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8265     elif test `echo "$option" | grep -c \^-` != 0; then
8266         option=`echo $option | sed 's/^-//'`
8267         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8268     else
8269         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8270     fi
8271 done],
8272     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8273 dnl Remove dupes
8274 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8275 AC_SUBST(NECKO_PROTOCOLS)
8276 for p in $NECKO_PROTOCOLS; do
8277     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8278 done
8281 dnl option to disable necko's wifi scanner
8283 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8284 [  --disable-necko-wifi    Disable necko wifi scanner],
8285     NECKO_WIFI=,
8286     NECKO_WIFI=1)
8288 if test "$OS_ARCH" = "OS2"; then
8289   dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
8290   NECKO_WIFI=
8292 if test "$NECKO_WIFI" -a \
8293         "$OS_ARCH" != "Linux" -a \
8294         "$OS_ARCH" != "Darwin" -a \
8295         "$OS_ARCH" != "SunOS" -a \
8296         "$OS_ARCH" != "WINNT"; then
8297   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
8300 if test -z "$SKIP_LIBRARY_CHECKS" -a "$NECKO_WIFI" -a "$OS_ARCH" = "Linux"
8301 then
8302   MOZ_CHECK_HEADER([iwlib.h])
8303   if test "$ac_cv_header_iwlib_h" != "yes"; then
8304     AC_MSG_ERROR([Can't find header iwlib.h for Necko WiFi scanning (might be in package libiw-dev (Ubuntu) or wireless-tools-devel (Fedora) or libiw-devel (openSUSE)); use --disable-necko-wifi to disable])
8305   fi
8308 if test "$NECKO_WIFI"; then
8309   AC_DEFINE(NECKO_WIFI)
8311 AC_SUBST(NECKO_WIFI)
8314 dnl option to disable cookies
8316 MOZ_ARG_DISABLE_BOOL(cookies,
8317 [  --disable-cookies       Disable cookie support],
8318     NECKO_COOKIES=,
8319     NECKO_COOKIES=1)
8320 AC_SUBST(NECKO_COOKIES)
8321 if test "$NECKO_COOKIES"; then
8322     AC_DEFINE(NECKO_COOKIES)
8326 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8328 MOZ_ARG_DISABLE_BOOL(ctypes,
8329 [  --disable-ctypes        Disable js-ctypes],
8330     BUILD_CTYPES=,
8331     BUILD_CTYPES=1)
8332 AC_SUBST(BUILD_CTYPES)
8333 if test "$BUILD_CTYPES"; then
8334     AC_DEFINE(BUILD_CTYPES)
8337 dnl NECKO_ configuration options are not global
8338 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_"
8340 dnl Build Places if required
8341 if test "$MOZ_PLACES"; then
8342   AC_DEFINE(MOZ_PLACES)
8345 dnl Build Sync Services if required
8346 AC_SUBST(MOZ_SERVICES_SYNC)
8347 if test -n "$MOZ_SERVICES_SYNC"; then
8348   AC_DEFINE(MOZ_SERVICES_SYNC)
8351 dnl ========================================================
8352 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
8353     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8356 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8357   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8360 if test "$MOZ_APP_COMPONENT_MODULES"; then
8361   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8364 dnl ========================================================
8365 dnl =
8366 dnl = Maintainer debug option (no --enable equivalent)
8367 dnl =
8368 dnl ========================================================
8370 AC_SUBST(AR)
8371 AC_SUBST(AR_FLAGS)
8372 AC_SUBST(AR_LIST)
8373 AC_SUBST(AR_EXTRACT)
8374 AC_SUBST(AR_DELETE)
8375 AC_SUBST(AS)
8376 AC_SUBST(ASFLAGS)
8377 AC_SUBST(AS_DASH_C_FLAG)
8378 AC_SUBST(LD)
8379 AC_SUBST(RC)
8380 AC_SUBST(RCFLAGS)
8381 AC_SUBST(MC)
8382 AC_SUBST(WINDRES)
8383 AC_SUBST(IMPLIB)
8384 AC_SUBST(FILTER)
8385 AC_SUBST(BIN_FLAGS)
8386 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8387 AC_SUBST(MOZ_UPDATE_XTERM)
8388 AC_SUBST(MOZ_PLATFORM_MAEMO)
8389 AC_SUBST(MOZ_AUTH_EXTENSION)
8390 AC_SUBST(MOZ_PERMISSIONS)
8391 AC_SUBST(MOZ_XTF)
8392 AC_SUBST(MOZ_PREF_EXTENSIONS)
8393 AC_SUBST(MOZ_JS_LIBS)
8394 AC_SUBST(MOZ_PSM)
8395 AC_SUBST(MOZ_DEBUG)
8396 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8397 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8398 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8399 AC_SUBST(MOZ_DEBUG_FLAGS)
8400 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8401 AC_SUBST(WARNINGS_AS_ERRORS)
8402 AC_SUBST(MOZ_EXTENSIONS)
8403 AC_SUBST(MOZ_JSDEBUGGER)
8404 AC_SUBST(MOZ_LOG_REFCNT)
8405 AC_SUBST(MOZ_LEAKY)
8406 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8407 AC_SUBST(MOZ_JPROF)
8408 AC_SUBST(MOZ_SHARK)
8409 AC_SUBST(MOZ_CALLGRIND)
8410 AC_SUBST(MOZ_VTUNE)
8411 AC_SUBST(MOZ_ETW)
8412 AC_SUBST(MOZ_PROFILING)
8413 AC_SUBST(MOZ_QUANTIFY)
8414 AC_SUBST(LIBICONV)
8415 AC_SUBST(MOZ_PLACES)
8416 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8417 AC_SUBST(MOZ_FEEDS)
8418 AC_SUBST(NS_PRINTING)
8419 AC_SUBST(MOZ_WEBGL)
8420 AC_SUBST(MOZ_HELP_VIEWER)
8422 AC_SUBST(JAVA)
8423 AC_SUBST(JAVAC)
8424 AC_SUBST(JAR)
8426 AC_SUBST(MOZ_PROFILELOCKING)
8428 AC_SUBST(ENABLE_TESTS)
8429 AC_SUBST(IBMBIDI)
8430 AC_SUBST(MOZ_UNIVERSALCHARDET)
8431 AC_SUBST(ACCESSIBILITY)
8432 AC_SUBST(MOZ_SPELLCHECK)
8433 AC_SUBST(MOZ_JAVA_COMPOSITOR)
8434 AC_SUBST(MOZ_USER_DIR)
8435 AC_SUBST(MOZ_CRASHREPORTER)
8436 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8437 AC_SUBST(MOZ_UPDATER)
8438 AC_SUBST(MOZ_ANGLE)
8439 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8440 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8441 AC_SUBST(MOZ_D3DX9_VERSION)
8442 AC_SUBST(MOZ_D3DX9_CAB)
8443 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8444 AC_SUBST(MOZ_D3DX9_DLL)
8445 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8447 AC_SUBST(MOZ_ANDROID_HISTORY)
8448 AC_SUBST(ENABLE_STRIP)
8449 AC_SUBST(PKG_SKIP_STRIP)
8450 AC_SUBST(USE_ELF_DYNSTR_GC)
8451 AC_SUBST(USE_ELF_HACK)
8452 AC_SUBST(INCREMENTAL_LINKER)
8453 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8454 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8456 AC_SUBST(MOZ_FIX_LINK_PATHS)
8457 AC_SUBST(XPCOM_LIBS)
8458 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8459 AC_SUBST(XPCOM_GLUE_LDOPTS)
8460 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8462 AC_SUBST(USE_DEPENDENT_LIBS)
8464 AC_SUBST(MOZ_BUILD_ROOT)
8465 AC_SUBST(MOZ_OS2_TOOLS)
8467 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8468 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8470 dnl ========================================================
8471 dnl = Mac bundle name prefix
8472 dnl ========================================================
8473 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8474 [  --with-macbundlename-prefix=prefix
8475                           Prefix for MOZ_MACBUNDLE_NAME],
8476 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8478 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8479 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8480   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8483 if test "$MOZ_DEBUG"; then
8484   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8485 else
8486   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8488 AC_SUBST(MOZ_MACBUNDLE_NAME)
8490 # The following variables are available to branding and application
8491 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8492 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8493 # impacts profile location and user-visible fields.
8494 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8495 # versions of a given application (e.g. Aurora and Firefox both use
8496 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8497 # for application.ini's "Name" field, which controls profile location in
8498 # the absence of a "Profile" field (see below), and various system
8499 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8500 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8501 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8502 # builds (e.g. Aurora for Firefox).
8503 # - MOZ_APP_VERSION: Defines the application version number.
8504 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8505 # defaults to a lowercase form of MOZ_APP_BASENAME.
8506 # - MOZ_APP_PROFILE: When set, used for application.ini's
8507 # "Profile" field, which controls profile location.
8508 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8509 # crash reporter server url.
8510 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8511 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8513 if test -z "$MOZ_APP_NAME"; then
8514    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8517 AC_SUBST(MOZ_APP_NAME)
8518 AC_SUBST(MOZ_APP_DISPLAYNAME)
8519 AC_SUBST(MOZ_APP_BASENAME)
8520 AC_SUBST(MOZ_APP_VENDOR)
8521 AC_SUBST(MOZ_APP_PROFILE)
8522 AC_SUBST(MOZ_APP_ID)
8523 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8524 AC_SUBST(MOZ_EXTENSION_MANAGER)
8525 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8526 AC_SUBST(MOZ_APP_UA_NAME)
8527 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8528 AC_SUBST(MOZ_APP_VERSION)
8529 AC_DEFINE_UNQUOTED(MOZ_UA_FIREFOX_VERSION, "$FIREFOX_VERSION")
8530 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8531 AC_SUBST(FIREFOX_VERSION)
8532 AC_DEFINE_UNQUOTED(MOZ_UA_BUILDID, "$MOZ_UA_BUILDID")
8533 AC_SUBST(MOZ_UA_BUILDID)
8535 # We can't use the static application.ini data when building against
8536 # a libxul SDK.
8537 if test -n "$LIBXUL_SDK"; then
8538     MOZ_APP_STATIC_INI=
8540 AC_SUBST(MOZ_APP_STATIC_INI)
8542 AC_SUBST(MOZ_PKG_SPECIAL)
8544 AC_SUBST(MOZILLA_OFFICIAL)
8546 if test "$MOZ_TELEMETRY_REPORTING"; then
8547     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8550 dnl win32 options
8551 AC_SUBST(MOZ_MAPINFO)
8552 AC_SUBST(MOZ_BROWSE_INFO)
8553 AC_SUBST(MOZ_TOOLS_DIR)
8554 AC_SUBST(WIN32_REDIST_DIR)
8555 AC_SUBST(PYTHON)
8556 AC_SUBST(MAKENSISU)
8558 dnl Echo the CFLAGS to remove extra whitespace.
8559 CFLAGS=`echo \
8560         $_WARNINGS_CFLAGS \
8561         $CFLAGS`
8563 CXXFLAGS=`echo \
8564         $_MOZ_RTTI_FLAGS \
8565         $_WARNINGS_CXXFLAGS \
8566         $CXXFLAGS`
8568 COMPILE_CFLAGS=`echo \
8569     $_DEFINES_CFLAGS \
8570         $_DEPEND_CFLAGS \
8571     $COMPILE_CFLAGS`
8573 COMPILE_CXXFLAGS=`echo \
8574     $_DEFINES_CXXFLAGS \
8575         $_DEPEND_CFLAGS \
8576     $COMPILE_CXXFLAGS`
8578 AC_SUBST(SYSTEM_MAKEDEPEND)
8579 AC_SUBST(SYSTEM_LIBXUL)
8580 AC_SUBST(SYSTEM_JPEG)
8581 AC_SUBST(SYSTEM_PNG)
8582 AC_SUBST(SYSTEM_ZLIB)
8583 AC_SUBST(SYSTEM_BZ2)
8585 AC_SUBST(JPEG_CFLAGS)
8586 AC_SUBST(JPEG_LIBS)
8587 AC_SUBST(ZLIB_CFLAGS)
8588 AC_SUBST(ZLIB_LIBS)
8589 AC_SUBST(BZ2_CFLAGS)
8590 AC_SUBST(BZ2_LIBS)
8591 AC_SUBST(PNG_CFLAGS)
8592 AC_SUBST(PNG_LIBS)
8594 AC_SUBST(MOZ_JPEG_CFLAGS)
8595 AC_SUBST(MOZ_JPEG_LIBS)
8596 AC_SUBST(MOZ_ZLIB_CFLAGS)
8597 AC_SUBST(MOZ_ZLIB_LIBS)
8598 AC_SUBST(MOZ_BZ2_CFLAGS)
8599 AC_SUBST(MOZ_BZ2_LIBS)
8600 AC_SUBST(MOZ_PNG_CFLAGS)
8601 AC_SUBST(MOZ_PNG_LIBS)
8603 AC_SUBST(NSPR_CFLAGS)
8604 AC_SUBST(NSPR_LIBS)
8605 AC_SUBST(MOZ_NATIVE_NSPR)
8607 AC_SUBST(NSS_CFLAGS)
8608 AC_SUBST(NSS_LIBS)
8609 AC_SUBST(NSS_DEP_LIBS)
8610 AC_SUBST(MOZ_NATIVE_NSS)
8611 AC_SUBST(NSS_DISABLE_DBM)
8613 AC_SUBST(CFLAGS)
8614 AC_SUBST(CXXFLAGS)
8615 AC_SUBST(CPPFLAGS)
8616 AC_SUBST(COMPILE_CFLAGS)
8617 AC_SUBST(COMPILE_CXXFLAGS)
8618 AC_SUBST(LDFLAGS)
8619 AC_SUBST(LIBS)
8620 AC_SUBST(CROSS_COMPILE)
8621 AC_SUBST(WCHAR_CFLAGS)
8623 AC_SUBST(HOST_CC)
8624 AC_SUBST(HOST_CXX)
8625 AC_SUBST(HOST_CFLAGS)
8626 AC_SUBST(HOST_CXXFLAGS)
8627 AC_SUBST(HOST_LDFLAGS)
8628 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8629 AC_SUBST(HOST_AR)
8630 AC_SUBST(HOST_AR_FLAGS)
8631 AC_SUBST(HOST_LD)
8632 AC_SUBST(HOST_RANLIB)
8633 AC_SUBST(HOST_NSPR_MDCPUCFG)
8634 AC_SUBST(HOST_BIN_SUFFIX)
8635 AC_SUBST(HOST_OS_ARCH)
8637 AC_SUBST(TARGET_CPU)
8638 AC_SUBST(TARGET_VENDOR)
8639 AC_SUBST(TARGET_OS)
8640 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8641 AC_SUBST(TARGET_MD_ARCH)
8642 AC_SUBST(TARGET_XPCOM_ABI)
8643 AC_SUBST(OS_TARGET)
8644 AC_SUBST(OS_ARCH)
8645 AC_SUBST(OS_RELEASE)
8646 AC_SUBST(OS_TEST)
8647 AC_SUBST(CPU_ARCH)
8648 AC_SUBST(INTEL_ARCHITECTURE)
8650 AC_SUBST(MOZ_DISABLE_JAR_PACKAGING)
8651 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8653 AC_SUBST(WRAP_LDFLAGS)
8654 AC_SUBST(MKSHLIB)
8655 AC_SUBST(MKCSHLIB)
8656 AC_SUBST(MKSHLIB_FORCE_ALL)
8657 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8658 AC_SUBST(DSO_CFLAGS)
8659 AC_SUBST(DSO_PIC_CFLAGS)
8660 AC_SUBST(DSO_LDOPTS)
8661 AC_SUBST(LIB_PREFIX)
8662 AC_SUBST(DLL_PREFIX)
8663 AC_SUBST(DLL_SUFFIX)
8664 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8665 AC_SUBST(LIB_SUFFIX)
8666 AC_SUBST(OBJ_SUFFIX)
8667 AC_SUBST(BIN_SUFFIX)
8668 AC_SUBST(ASM_SUFFIX)
8669 AC_SUBST(IMPORT_LIB_SUFFIX)
8670 AC_SUBST(USE_N32)
8671 AC_SUBST(CC_VERSION)
8672 AC_SUBST(CXX_VERSION)
8673 AC_SUBST(MSMANIFEST_TOOL)
8674 AC_SUBST(NS_ENABLE_TSF)
8675 AC_SUBST(MOZ_NSS_PATCH)
8676 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8677 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8679 AC_SUBST(MOZ_MEDIA)
8680 AC_SUBST(MOZ_SYDNEYAUDIO)
8681 AC_SUBST(MOZ_WAVE)
8682 AC_SUBST(MOZ_VORBIS)
8683 AC_SUBST(MOZ_TREMOR)
8684 AC_SUBST(MOZ_WEBM)
8685 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8686 AC_SUBST(MOZ_VP8_ENCODER)
8687 AC_SUBST(MOZ_OGG)
8688 AC_SUBST(MOZ_ALSA_LIBS)
8689 AC_SUBST(VPX_AS)
8690 AC_SUBST(VPX_ASFLAGS)
8691 AC_SUBST(VPX_DASH_C_FLAG)
8692 AC_SUBST(VPX_AS_CONVERSION)
8693 AC_SUBST(VPX_ASM_SUFFIX)
8694 AC_SUBST(VPX_X86_ASM)
8695 AC_SUBST(VPX_ARM_ASM)
8696 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8697 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8698 AC_SUBST(LIBJPEG_TURBO_AS)
8699 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8700 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8701 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8703 AC_MSG_CHECKING([for posix_fallocate])
8704 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8705   #include <fcntl.h>],
8706                  [posix_fallocate(0, 0, 0);],
8707                  [ac_cv___posix_fallocate=true],
8708                  [ac_cv___posix_fallocate=false])
8710 if test "$ac_cv___posix_fallocate" = true ; then
8711   AC_DEFINE(HAVE_POSIX_FALLOCATE)
8712   AC_MSG_RESULT(yes)
8713 else
8714   AC_MSG_RESULT(no)
8717 dnl Check for missing components
8718 if test "$COMPILE_ENVIRONMENT"; then
8719 if test "$MOZ_X11"; then
8720     dnl ====================================================
8721     dnl = Check if X headers exist
8722     dnl ====================================================
8723     _SAVE_CFLAGS=$CFLAGS
8724     CFLAGS="$CFLAGS $XCFLAGS"
8725     AC_TRY_COMPILE([
8726         #include <stdio.h>
8727         #include <stdlib.h>
8728         #include <X11/Xlib.h>
8729         #include <X11/Intrinsic.h>
8730         #include <X11/extensions/XShm.h>
8731     ],
8732     [
8733         Display *dpy = 0;
8734         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8735             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8736             exit(1);
8737         }
8738     ], [],
8739     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8740     CFLAGS="$_SAVE_CFLAGS"
8742     if test -n "$MISSING_X"; then
8743         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8744     fi
8746 fi # MOZ_X11
8748 dnl Check for headers, etc. needed by WebGL.
8749 if test -n "$MOZ_WEBGL_GLX"; then
8750     MOZ_CHECK_HEADER(GL/glx.h)
8751     if test "$ac_cv_header_GL_glx_h" != "yes"; then
8752         AC_MSG_ERROR([Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa-devel (openSUSE))])
8753     fi
8754 fi # MOZ_WEBGL_GLX
8755 fi # COMPILE_ENVIRONMENT
8757 if test "$USE_FC_FREETYPE"; then
8758     if test "$COMPILE_ENVIRONMENT"; then
8759         _SAVE_CPPFLAGS="$CPPFLAGS"
8760         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8761         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8762             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8763         CPPFLAGS="$_SAVE_CPPFLAGS"
8764     else
8765         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8766     fi
8769 dnl Set various defines and substitutions
8770 dnl ========================================================
8772 if test "$OS_ARCH" = "Darwin"; then
8773   AC_DEFINE(XP_UNIX)
8774   AC_DEFINE(UNIX_ASYNC_DNS)
8775 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
8776   AC_DEFINE(XP_UNIX)
8777   AC_DEFINE(UNIX_ASYNC_DNS)
8780 if test "$MOZ_DEBUG"; then
8781     AC_DEFINE(MOZ_REFLOW_PERF)
8782     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8785 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
8786     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8787     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8788     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8789     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8790     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8791     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8792     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8793     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8796 case "$host_os" in
8797 mingw*)
8798     WIN_TOP_SRC=`cd $srcdir; pwd -W`
8799     ;;
8800 esac
8802 AC_SUBST(WIN_TOP_SRC)
8804 AC_SUBST(MOZILLA_VERSION)
8806 AC_SUBST(ac_configure_args)
8808 dnl Spit out some output
8809 dnl ========================================================
8811 dnl The following defines are used by xpcom
8812 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8813 CPP_THROW_NEW
8814 HAVE_CPP_2BYTE_WCHAR_T
8815 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8816 HAVE_CPP_CHAR16_T
8817 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8818 HAVE_CPP_PARTIAL_SPECIALIZATION
8819 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8820 HAVE_STATVFS
8821 NEED_CPP_UNUSED_IMPLEMENTATIONS
8822 NEW_H
8823 HAVE_GETPAGESIZE
8824 HAVE_ICONV
8825 HAVE_ICONV_WITH_CONST_INPUT
8826 HAVE_MBRTOWC
8827 HAVE_SYS_MOUNT_H
8828 HAVE_SYS_VFS_H
8829 HAVE_WCRTOMB
8832 AC_CONFIG_HEADER(
8833 netwerk/necko-config.h
8834 xpcom/xpcom-config.h
8835 xpcom/xpcom-private.h
8838 # Hack around an Apple bug that effects the egrep that comes with OS X 10.7.
8839 # "arch -arch i386 egrep" always uses the 32-bit Intel part of the egrep fat
8840 # binary, even on 64-bit systems.  It should work on OS X 10.4.5 and up.  We
8841 # (apparently) only need this hack when egrep's "pattern" is particularly
8842 # long (as in the following code).  See bug 655339.
8843 case "$host" in
8844 *-apple-darwin*)
8845     FIXED_EGREP="arch -arch i386 egrep"
8846     ;;
8848     FIXED_EGREP="egrep"
8849     ;;
8850 esac
8852 # Save the defines header file before autoconf removes it.
8853 # (Do not add AC_DEFINE calls after this line.)
8854   _CONFIG_TMP=confdefs-tmp.h
8855   _CONFIG_DEFS_H=mozilla-config.h
8857   cat > $_CONFIG_TMP <<\EOF
8858 /* List of defines generated by configure. Included with preprocessor flag,
8859  * -include, to avoid long list of -D defines on the compile command-line.
8860  * Do not edit.
8861  */
8863 #ifndef _MOZILLA_CONFIG_H_
8864 #define _MOZILLA_CONFIG_H_
8867 _EGREP_PATTERN='^#define ('
8868 if test -n "$_NON_GLOBAL_ACDEFINES"; then
8869     for f in $_NON_GLOBAL_ACDEFINES; do
8870         _EGREP_PATTERN="${_EGREP_PATTERN}$f|"
8871     done
8873 _EGREP_PATTERN="${_EGREP_PATTERN}dummy_never_defined)"
8875   sort confdefs.h | $FIXED_EGREP -v "$_EGREP_PATTERN" >> $_CONFIG_TMP
8877   if test "$?" != 0; then
8878     AC_MSG_ERROR([Error outputting config definitions])
8879   fi
8881   cat >> $_CONFIG_TMP <<\EOF
8883 /* The c99 defining the limit macros (UINT32_MAX for example), says:
8884  * C++ implementations should define these macros only when __STDC_LIMIT_MACROS
8885  * is defined before <stdint.h> is included. */
8886 #define __STDC_LIMIT_MACROS
8888 /* Force-include hunspell_alloc_hooks.h for hunspell, so that we don't need to
8889  * modify it directly.
8891  * HUNSPELL_STATIC is defined in extensions/spellcheck/hunspell/src/Makefile.in,
8892  * unless --enable-system-hunspell is defined.
8893  */
8894 #if defined(HUNSPELL_STATIC)
8895 #include "hunspell_alloc_hooks.h"
8896 #endif
8898 #endif /* _MOZILLA_CONFIG_H_ */
8902   # Only write mozilla-config.h when something changes (or it doesn't exist)
8903   if cmp -s $_CONFIG_TMP $_CONFIG_DEFS_H; then
8904     rm $_CONFIG_TMP
8905   else
8906     AC_MSG_RESULT("creating $_CONFIG_DEFS_H")
8907     mv -f $_CONFIG_TMP $_CONFIG_DEFS_H
8909     echo ==== $_CONFIG_DEFS_H =================================
8910     cat $_CONFIG_DEFS_H
8911   fi
8913 dnl Probably shouldn't call this manually but we always want the output of DEFS
8914 rm -f confdefs.h.save
8915 mv confdefs.h confdefs.h.save
8916 $FIXED_EGREP -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
8917 if test "$?" != 0; then
8918   AC_MSG_ERROR([Error outputting confdefs.h])
8920 AC_OUTPUT_MAKE_DEFS()
8921 MOZ_DEFINES=$DEFS
8922 AC_SUBST(MOZ_DEFINES)
8923 rm -f confdefs.h
8924 mv confdefs.h.save confdefs.h
8926 dnl Load the list of Makefiles to generate.
8927 dnl   To add new Makefiles, edit allmakefiles.sh.
8928 dnl   allmakefiles.sh sets the variable, MAKEFILES.
8929 . ${srcdir}/allmakefiles.sh
8931 dnl Run a perl script to quickly create the makefiles.
8932 dnl If it succeeds, it outputs a shell command to set CONFIG_FILES
8933 dnl   for the files it cannot handle correctly. This way, config.status
8934 dnl   will handle these files.
8935 dnl If it fails, nothing is set and config.status will run as usual.
8937 dnl This does not change the $MAKEFILES variable.
8939 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl > conftest.sh
8940 . ./conftest.sh
8941 rm conftest.sh
8943 echo $MAKEFILES > unallmakefiles
8945 mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null
8947 AC_OUTPUT($MAKEFILES)
8949 # Generate a JSON config file for unittest harnesses etc to read
8950 # build configuration details from in a standardized way.
8951 OS_TARGET=${OS_TARGET} TARGET_CPU=${TARGET_CPU} MOZ_DEBUG=${MOZ_DEBUG} \
8952 MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \
8953   $PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp
8954 if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then
8955   rm ./mozinfo.json.tmp
8956 else
8957   mv -f ./mozinfo.json.tmp ./mozinfo.json
8960 dnl Prevent the regeneration of cairo-features.h forcing rebuilds of gfx stuff
8961 if test "$CAIRO_FEATURES_H"; then
8962   if cmp -s $CAIRO_FEATURES_H "$CAIRO_FEATURES_H".orig; then
8963     echo "$CAIRO_FEATURES_H is unchanged"
8964     mv -f "$CAIRO_FEATURES_H".orig "$CAIRO_FEATURES_H" 2> /dev/null
8965   else
8966     rm -f "$CAIRO_FEATURES_H".orig 2> /dev/null
8967   fi
8970 # Run freetype configure script
8972 if test "$MOZ_TREE_FREETYPE"; then
8973    export CFLAGS="$CFLAGS -std=c99"
8974    export CPPFLAGS="$CPPFLAGS"
8975    export CXXFLAGS="$CXXFLAGS"
8976    export LDFLAGS="$LDFLAGS"
8977    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
8978    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes"
8979    AC_OUTPUT_SUBDIRS(modules/freetype2)
8982 if test -z "$direct_nspr_config"; then
8983     dnl ========================================================
8984     dnl = Setup a nice relatively clean build environment for
8985     dnl = sub-configures.
8986     dnl ========================================================
8987     CC="$_SUBDIR_CC"
8988     CXX="$_SUBDIR_CXX"
8989     CFLAGS="$_SUBDIR_CFLAGS"
8990     CPPFLAGS="$_SUBDIR_CPPFLAGS"
8991     CXXFLAGS="$_SUBDIR_CXXFLAGS"
8992     LDFLAGS="$_SUBDIR_LDFLAGS"
8993     HOST_CC="$_SUBDIR_HOST_CC"
8994     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
8995     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
8996     RC=
8999 unset MAKEFILES
9000 unset CONFIG_FILES
9002 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9003 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9005 export WRAP_LDFLAGS
9007 if test -n "$_WRAP_MALLOC"; then
9008     # Avoid doubling wrap malloc arguments
9009     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9012 if test -z "$MOZ_NATIVE_NSPR"; then
9013     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9014     if test -z "$MOZ_DEBUG"; then
9015         ac_configure_args="$ac_configure_args --disable-debug"
9016     else
9017         ac_configure_args="$ac_configure_args --enable-debug"
9018     fi
9019     if test "$MOZ_OPTIMIZE" = "1"; then
9020         ac_configure_args="$ac_configure_args --enable-optimize"
9021     else
9022         ac_configure_args="$ac_configure_args --disable-optimize"
9023     fi
9024     if test -n "$HAVE_64BIT_OS"; then
9025         ac_configure_args="$ac_configure_args --enable-64bit"
9026     fi
9027     if test -n "$USE_ARM_KUSER"; then
9028         ac_configure_args="$ac_configure_args --with-arm-kuser"
9029     fi
9030     AC_OUTPUT_SUBDIRS(nsprpub)
9031     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9034 if test -z "$MOZ_NATIVE_NSPR"; then
9035     # Hack to deal with the fact that we use NSPR_CFLAGS everywhere
9036     AC_MSG_WARN([Recreating autoconf.mk with updated nspr-config output])
9037     if test "$OS_ARCH" != "WINNT"; then
9038        NSPR_LIBS=`./nsprpub/config/nspr-config --prefix=$LIBXUL_DIST --exec-prefix=$MOZ_BUILD_ROOT/dist --libdir=$LIBXUL_DIST/lib --libs`
9039        $PERL -pi.bak -e "s '^NSPR_LIBS\\s*=.*'NSPR_LIBS = $NSPR_LIBS'" config/autoconf.mk
9040        NSPR_CFLAGS=`./nsprpub/config/nspr-config --prefix=$LIBXUL_DIST --exec-prefix=$MOZ_BUILD_ROOT/dist --includedir=$LIBXUL_DIST/include/nspr --cflags`
9041        $PERL -pi.bak -e "s '^NSPR_CFLAGS\\s*=.*'NSPR_CFLAGS = $NSPR_CFLAGS'" config/autoconf.mk
9042     fi
9043     rm -f config/autoconf.mk.bak
9046 if test -n "$direct_nspr_config"; then
9047     dnl ========================================================
9048     dnl = Setup a nice relatively clean build environment for
9049     dnl = sub-configures.
9050     dnl ========================================================
9051     CC="$_SUBDIR_CC"
9052     CXX="$_SUBDIR_CXX"
9053     CFLAGS="$_SUBDIR_CFLAGS"
9054     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9055     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9056     LDFLAGS="$_SUBDIR_LDFLAGS"
9057     HOST_CC="$_SUBDIR_HOST_CC"
9058     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9059     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9060     RC=
9063 # Run the SpiderMonkey 'configure' script.
9064 dist=$MOZ_BUILD_ROOT/dist
9065 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9066 ac_configure_args="$ac_configure_args --enable-threadsafe"
9067 if test "$BUILD_CTYPES"; then
9068     # Build js-ctypes on the platforms we can.
9069     ac_configure_args="$ac_configure_args --enable-ctypes"
9071 if test -z "$JS_SHARED_LIBRARY" ; then
9072     ac_configure_args="$ac_configure_args --disable-shared-js"
9074 if test -z "$MOZ_NATIVE_NSPR"; then
9075     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9076     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9078 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
9079 ac_configure_args="$ac_configure_args --prefix=$dist"
9080 ac_configure_args="$ac_configure_args --with-sync-build-files=$_topsrcdir"
9081 if test "$MOZ_MEMORY"; then
9082    ac_configure_args="$ac_configure_args --enable-jemalloc"
9083    if test -n "$MOZ_GLUE_LDFLAGS"; then
9084      export MOZ_GLUE_LDFLAGS
9085    fi
9086    if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9087      export MOZ_GLUE_PROGRAM_LDFLAGS
9088    fi
9090 export MOZ_APP_NAME
9091 AC_OUTPUT_SUBDIRS(js/src)
9092 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9094 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
9096 dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world
9097 dnl Needs to be at the end to respect possible changes from NSPR configure
9098 if cmp -s config/autoconf.mk config/autoconf.mk.orig; then
9099   echo "config/autoconf.mk is unchanged"
9100   mv -f config/autoconf.mk.orig config/autoconf.mk 2> /dev/null
9101 else
9102   rm -f config/autoconf.mk.orig 2> /dev/null