Bug 739575 - Prioritize click-to-play over alternate content in nsObjectLoadingConten...
[gecko.git] / configure.in
bloba44d80dc817c7299040befe6c646af61accf6512
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=10509
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.11
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
205     # need override this flag since we don't use $(LDFLAGS) for this.
206     if test -z "$HOST_LDFLAGS" ; then
207         HOST_LDFLAGS=" "
208     fi
209     ;;
210 *-darwin*)
211     # we prefer gcc-4.2 over gcc on older darwin, so
212     # use that specific version if it's available.
213     MOZ_PATH_PROGS(CC, $CC gcc-4.2 gcc)
214     MOZ_PATH_PROGS(CXX, $CXX g++-4.2 g++)
215     ;;
216 esac
219 COMPILE_ENVIRONMENT=1
220 MOZ_ARG_DISABLE_BOOL(compile-environment,
221 [  --disable-compile-environment
222                           Disable compiler/library checks.],
223     COMPILE_ENVIRONMENT= )
224 AC_SUBST(COMPILE_ENVIRONMENT)
226 MOZ_ARG_WITH_STRING(l10n-base,
227 [  --with-l10n-base=DIR    path to l10n repositories],
228     L10NBASEDIR=$withval)
229 if test -n "$L10NBASEDIR"; then
230     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
231         AC_MSG_ERROR([--with-l10n-base must specify a path])
232     elif test -d "$L10NBASEDIR"; then
233         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
234     else
235         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
236     fi
238 AC_SUBST(L10NBASEDIR)
240 dnl Check for Perl first -- needed for win32 SDK checks
241 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
242 if test -z "$PERL" -o "$PERL" = ":"; then
243     AC_MSG_ERROR([perl not found in \$PATH])
246 dnl ========================================================
247 dnl = Android uses a very custom (hacky) toolchain; we need to do this
248 dnl = here, so that the compiler checks can succeed
249 dnl ========================================================
251 MOZ_ARG_WITH_STRING(android-ndk,
252 [  --with-android-ndk=DIR
253                           location where the Android NDK can be found],
254     android_ndk=$withval)
256 MOZ_ARG_WITH_STRING(android-toolchain,
257 [  --with-android-toolchain=DIR
258                           location of the android toolchain, default NDK/build/prebuilt/HOST/arm-eabi-4.4.0],
259     android_toolchain=$withval)
262 MOZ_ARG_WITH_STRING(android-version,
263 [  --with-android-version=VER
264                           android platform version, default 5],
265     android_version=$withval,
266     android_version=5)
268 MOZ_ARG_WITH_STRING(android-sdk,
269 [  --with-android-sdk=DIR
270                           location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)],
271     android_sdk=$withval)
273 MOZ_ARG_WITH_STRING(android-platform,
274 [  --with-android-platform=DIR
275                            location of platform dir, default NDK/build/platforms/android-5/arch-arm],
276     android_platform=$withval)
278 MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
279 [  --enable-android-libstdcxx
280                           use GNU libstdc++ instead of STLPort for NDK >= 5],
281     MOZ_ANDROID_LIBSTDCXX=1,
282     MOZ_ANDROID_LIBSTDCXX= )
284 case "$target" in
285 arm-linux*-android*|*-linuxandroid*)
286     android_tool_prefix="arm-linux-androideabi"
287     ;;
288 i?86-*android*)
289     android_tool_prefix="i686-android-linux"
290     ;;
291 arm-android-eabi)
292     android_tool_prefix="arm-eabi"
293     ;;
295     android_tool_prefix="$target_os"
296     ;;
297 esac
299 MOZ_ARG_WITH_STRING(gonk,
300 [  --with-gonk=DIR
301                location of gonk dir],
302     gonkdir=$withval)
304 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
305 [  --with-gonk-toolchain-prefix=DIR
306                           prefix to gonk toolchain commands],
307     gonk_toolchain_prefix=$withval)
309 if test -n "$gonkdir" ; then
310     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
311     android_source="$gonkdir"
312     ANDROID_SOURCE="$android_source"
314     dnl set up compilers
315     AS="$gonk_toolchain_prefix"as
316     CC="$gonk_toolchain_prefix"gcc
317     CXX="$gonk_toolchain_prefix"g++
318     CPP="$gonk_toolchain_prefix"cpp
319     LD="$gonk_toolchain_prefix"ld
320     AR="$gonk_toolchain_prefix"ar
321     RANLIB="$gonk_toolchain_prefix"ranlib
322     STRIP="$gonk_toolchain_prefix"strip
324     STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/"
325     STLPORT_LIBS="-lstlport"
327     CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/arch-arm/include -isystem $gonkdir/bionic/libc/kernel/arch-arm -isystem $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 -isystem $gonkdir/bionic -I$gonkdir/frameworks/base/include $CPPFLAGS -I$gonkdir/frameworks/base/services/sensorservice"
328     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
329     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS $STLPORT_CPPFLAGS"
330     LIBS="$LIBS $STLPORT_LIBS"
332     dnl Add -llog by default, since we use it all over the place.
333     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"
335     dnl prevent cross compile section from using these flags as host flags
336     if test -z "$HOST_CPPFLAGS" ; then
337         HOST_CPPFLAGS=" "
338     fi
339     if test -z "$HOST_CFLAGS" ; then
340         HOST_CFLAGS=" "
341     fi
342     if test -z "$HOST_CXXFLAGS" ; then
343         HOST_CXXFLAGS=" "
344     fi
345     if test -z "$HOST_LDFLAGS" ; then
346         HOST_LDFLAGS=" "
347     fi
349     AC_DEFINE(ANDROID)
350     AC_DEFINE(HAVE_SYS_UIO_H)
351     AC_DEFINE(HAVE_PTHREADS)
352     CROSS_COMPILE=1
353     MOZ_CHROME_FILE_FORMAT=omni
354     ZLIB_DIR=yes
355     direct_nspr_config=1
356 else
357 case "$target" in
358 *-android*|*-linuxandroid*)
359     if test -z "$android_ndk" ; then
360         AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
361     fi
363     if test -z "$android_sdk" ; then
364         AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
365     else
366         if ! test -e "$android_sdk"/source.properties ; then
367             AC_MSG_ERROR([The path in --with-android-sdk isn't valid (source.properties hasn't been found).])
368         fi
370         # Minimum Android SDK API Level we require.
371         android_min_api_level=13
373         # Get the api level from "$android_sdk"/source.properties.
374         android_api_level=`$AWK -F = '$1 == "AndroidVersion.ApiLevel" {print $2}' "$android_sdk"/source.properties`
376         if test -z "$android_api_level" ; then
377             AC_MSG_ERROR([Unexpected error: no AndroidVersion.ApiLevel field has been found in source.properties.])
378         fi
380         if ! test "$android_api_level" -eq "$android_api_level" ; then
381             AC_MSG_ERROR([Unexpected error: the found android api value isn't a number! (found $android_api_level)])
382         fi
384         if test $android_api_level -lt $android_min_api_level ; then
385             AC_MSG_ERROR([The given Android SDK provides API level $android_api_level ($android_min_api_level or higher required).])
386         fi
387     fi
389     android_platform_tools="$android_sdk"/../../platform-tools
390     if test ! -d "$android_platform_tools" ; then
391         android_platform_tools="$android_sdk"/tools # SDK Tools < r8
392     fi
394     if test -z "$android_toolchain" ; then
395         AC_MSG_CHECKING([for android toolchain directory])
397         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
399         android_toolchain="$android_ndk"/build/prebuilt/$kernel_name-x86/arm-eabi-4.4.0
401         # With newer NDK, the toolchain path has changed.
402         if ! test -d "$android_toolchain" ; then
403             android_toolchain="$android_ndk"/toolchains/arm-$kernel_name-androideabi-4.4.3/prebuilt/$kernel_name-x86
404         fi
406         if test -d "$android_toolchain" ; then
407             AC_MSG_RESULT([$android_toolchain])
408         else
409             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
410         fi
411     fi
413     if test -z "$android_platform" ; then
414         AC_MSG_CHECKING([for android platform directory])
416         android_platform="$android_ndk"/build/platforms/android-"$android_version"/arch-"$target_cpu"
418         # With newer NDK, the platform path has changed.
419         if ! test -d "$android_platform" ; then
420             android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_cpu"
421         fi
423         if test -d "$android_platform" ; then
424             AC_MSG_RESULT([$android_platform])
425         else
426             AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
427         fi
428     fi
430     dnl set up compilers
431     AS="$android_toolchain"/bin/"$android_tool_prefix"-as
432     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
433     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
434     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
435     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
436     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
437     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
438     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
439     OBJCOPY="$android_toolchain"/bin/"$android_tool_prefix"-objcopy
441     CPPFLAGS="-isystem $android_platform/usr/include $CPPFLAGS"
442     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
443     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
445     dnl Add -llog by default, since we use it all over the place.
446     dnl Add --allow-shlib-undefined, because libGLESv2 links to an
447     dnl undefined symbol (present on the hardware, just not in the
448     dnl NDK.)
449     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
451     dnl prevent cross compile section from using these flags as host flags
452     if test -z "$HOST_CPPFLAGS" ; then
453         HOST_CPPFLAGS=" "
454     fi
455     if test -z "$HOST_CFLAGS" ; then
456         HOST_CFLAGS=" "
457     fi
458     if test -z "$HOST_CXXFLAGS" ; then
459         HOST_CXXFLAGS=" "
460     fi
461     if test -z "$HOST_LDFLAGS" ; then
462         HOST_LDFLAGS=" "
463     fi
465     ANDROID_NDK="${android_ndk}"
466     ANDROID_TOOLCHAIN="${android_toolchain}"
467     ANDROID_PLATFORM="${android_platform}"
468     ANDROID_SDK="${android_sdk}"
469     ANDROID_PLATFORM_TOOLS="${android_platform_tools}"
470     ANDROID_VERSION="${android_version}"
471     if test -z "$ANDROID_PACKAGE_NAME" ; then
472         ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
473     fi
474     if test -z "$MOZ_MOBILE_COMPAT" ; then
475         MOZ_MOBILE_COMPAT='All'
476     fi
478     AC_DEFINE(ANDROID)
479     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
480     AC_SUBST(ANDROID_VERSION)
481     CROSS_COMPILE=1
482     MOZ_CHROME_FILE_FORMAT=omni
483     ZLIB_DIR=yes
484     ;;
485 *-linux*)
486     AC_PATH_PROG(OBJCOPY,objcopy)
487     ;;
488 esac
492 AC_SUBST(ANDROID_NDK)
493 AC_SUBST(ANDROID_TOOLCHAIN)
494 AC_SUBST(ANDROID_PLATFORM)
495 AC_SUBST(ANDROID_SDK)
496 AC_SUBST(ANDROID_PLATFORM_TOOLS)
497 AC_SUBST(ANDROID_PACKAGE_NAME)
498 AC_SUBST(MOZ_MOBILE_COMPAT)
499 AC_SUBST(OBJCOPY)
501 dnl ========================================================
502 dnl Checks for compilers.
503 dnl ========================================================
504 dnl Set CROSS_COMPILE in the environment when running configure
505 dnl to use the cross-compile setup for now
506 dnl ========================================================
508 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
509 AR_FLAGS='cr $@'
511 if test "$COMPILE_ENVIRONMENT"; then
513 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
514     echo "cross compiling from $host to $target"
515     cross_compiling=yes
517     _SAVE_CC="$CC"
518     _SAVE_CFLAGS="$CFLAGS"
519     _SAVE_LDFLAGS="$LDFLAGS"
521     AC_MSG_CHECKING([for host c compiler])
522     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
523     if test -z "$HOST_CC"; then
524         AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
525     fi
526     AC_MSG_RESULT([$HOST_CC])
527     AC_MSG_CHECKING([for host c++ compiler])
528     AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
529     if test -z "$HOST_CXX"; then
530         AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
531     fi
532     AC_MSG_RESULT([$HOST_CXX])
534     if test -z "$HOST_CFLAGS"; then
535         HOST_CFLAGS="$CFLAGS"
536     fi
537     if test -z "$HOST_CXXFLAGS"; then
538         HOST_CXXFLAGS="$CXXFLAGS"
539     fi
540     if test -z "$HOST_LDFLAGS"; then
541         HOST_LDFLAGS="$LDFLAGS"
542     fi
543     if test -z "$HOST_AR_FLAGS"; then
544         HOST_AR_FLAGS="$AR_FLAGS"
545     fi
546     AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
547     AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
548     CC="$HOST_CC"
549     CFLAGS="$HOST_CFLAGS"
550     LDFLAGS="$HOST_LDFLAGS"
552     AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
553     AC_TRY_COMPILE([], [return(0);],
554         [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
555         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
557     CC="$HOST_CXX"
558     CFLAGS="$HOST_CXXFLAGS"
560     AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
561     AC_TRY_COMPILE([], [return(0);],
562         [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
563         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
565     CC=$_SAVE_CC
566     CFLAGS=$_SAVE_CFLAGS
567     LDFLAGS=$_SAVE_LDFLAGS
569     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
570     unset ac_cv_prog_CC
571     AC_PROG_CC
572     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
573     unset ac_cv_prog_CXX
574     AC_PROG_CXX
576     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
577     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
578     MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
579     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
580     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
581     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
582     AC_DEFINE(CROSS_COMPILE)
583 else
584     AC_PROG_CC
585     case "$target" in
586     *-mingw*)
587       # Work around the conftest.exe access problem on Windows
588       sleep 1
589     esac
590     AC_PROG_CXX
591     AC_PROG_RANLIB
592     MOZ_PATH_PROGS(AS, $AS as, $CC)
593     AC_CHECK_PROGS(AR, ar, :)
594     AC_CHECK_PROGS(LD, ld, :)
595     AC_CHECK_PROGS(STRIP, strip, :)
596     AC_CHECK_PROGS(WINDRES, windres, :)
597     if test -z "$HOST_CC"; then
598         HOST_CC='$(CC)'
599     fi
600     if test -z "$HOST_CFLAGS"; then
601         HOST_CFLAGS='$(CFLAGS)'
602     fi
603     if test -z "$HOST_CXX"; then
604         HOST_CXX='$(CXX)'
605     fi
606     if test -z "$HOST_CXXFLAGS"; then
607         HOST_CXXFLAGS='$(CXXFLAGS)'
608     fi
609     if test -z "$HOST_LDFLAGS"; then
610         HOST_LDFLAGS='$(LDFLAGS)'
611     fi
612     if test -z "$HOST_RANLIB"; then
613         HOST_RANLIB='$(RANLIB)'
614     fi
615     if test -z "$HOST_AR"; then
616         HOST_AR='$(AR)'
617     fi
618     if test -z "$HOST_AR_FLAGS"; then
619         HOST_AR_FLAGS='$(AR_FLAGS)'
620     fi
623 GNU_AS=
624 GNU_LD=
625 GNU_CC=
626 GNU_CXX=
627 CC_VERSION='N/A'
628 CXX_VERSION='N/A'
629 if test "$GCC" = "yes"; then
630     GNU_CC=1
631     CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
633 if test "$GXX" = "yes"; then
634     GNU_CXX=1
635     CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
637 if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then
638     GNU_AS=1
640 rm -f conftest.out
641 if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
642     GNU_LD=1
644 if test "$GNU_CC"; then
645     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
646         GCC_USE_GNU_LD=1
647     fi
650 INTEL_CC=
651 INTEL_CXX=
652 if test "$GCC" = yes; then
653    if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
654      INTEL_CC=1
655    fi
658 if test "$GXX" = yes; then
659    if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
660      INTEL_CXX=1
661    fi
664 CLANG_CC=
665 CLANG_CXX=
666 if test "$GCC" = yes; then
667    if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then
668      CLANG_CC=1
669    fi
672 if test "$GXX" = yes; then
673    if test "`$CXX -v 2>&1 | grep -c 'clang version'`" != "0"; then
674      CLANG_CXX=1
675    fi
678 dnl ========================================================
679 dnl Special win32 checks
680 dnl ========================================================
682 # With win8, sdk target=602, WINVER=602
683 MOZ_ARG_ENABLE_BOOL(metro,
684 [  --enable-metro           Enable Windows Metro build targets],
685     MOZ_METRO=1,
686     MOZ_METRO=)
687 if test -n "$MOZ_METRO"; then
688     AC_DEFINE(MOZ_METRO)
689     # Target the Windows 8 Kit
690     WINSDK_TARGETVER=602
691     # Allow a higher api set
692     WINVER=602
693 else
694     # Target the Windows 7 SDK by default
695     WINSDK_TARGETVER=601
696     WINVER=502
699 if test -n "$MOZ_METRO"; then
700   case "$target" in
701   *-mingw*)
702     ;;
703   *)
704     AC_MSG_ERROR([Metro builds only valid on the windows platform.]);
705     ;;
706   esac
709 MOZ_ARG_WITH_STRING(windows-version,
710 [  --with-windows-version=WINSDK_TARGETVER
711                           Windows SDK version to target. Lowest version
712                           currently allowed is 601 (Win7), highest is 602 (Win8)],
713   WINSDK_TARGETVER=$withval)
715 # Currently only two sdk versions allowed, 601 and 602
716 case "$WINSDK_TARGETVER" in
717 601|602)
718     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
719     ;;
722     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
723     ;;
724 esac
726 case "$target" in
727 *-mingw*)
728     if test "$GCC" != "yes"; then
729         # Check to see if we are really running in a msvc environemnt
730         _WIN32_MSVC=1
731         AC_CHECK_PROGS(MIDL, midl)
733         # Make sure compilers are valid
734         CFLAGS="$CFLAGS -TC -nologo"
735         CXXFLAGS="$CXXFLAGS -TP -nologo"
736         AC_LANG_SAVE
737         AC_LANG_C
738         AC_TRY_COMPILE([#include <stdio.h>],
739             [ printf("Hello World\n"); ],,
740             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
742         AC_LANG_CPLUSPLUS
743         AC_TRY_COMPILE([#include <new.h>],
744             [ unsigned *test = new unsigned(42); ],,
745             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
746         AC_LANG_RESTORE
748         changequote(,)
749         _MSVC_VER_FILTER='s|.* ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
750         changequote([,])
752         # Determine compiler version
753         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
754         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
755         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
756         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
757         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
758         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
760         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
761         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
763         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
764             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
765         fi
767         if test "$_CC_MAJOR_VERSION" = "14"; then
768             dnl Require VC8SP1 or newer.
769             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
770             if test "$_CC_RELEASE" -lt 50727 -o \
771                     \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
772               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.])
773             fi
775             _CC_SUITE=8
776             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
777             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
778         elif test "$_CC_MAJOR_VERSION" = "15"; then
779             _CC_SUITE=9
780             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
781             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
782         elif test "$_CC_MAJOR_VERSION" = "16"; then
783             _CC_SUITE=10
784             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
785             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
786         elif test "$_CC_MAJOR_VERSION" = "17"; then
787             _CC_SUITE=11
788             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
789             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
790         else
791             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
792         fi
794         _MOZ_RTTI_FLAGS_ON='-GR'
795         _MOZ_RTTI_FLAGS_OFF='-GR-'
796         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
798         if test -n "$WIN32_REDIST_DIR"; then
799           if test ! -d "$WIN32_REDIST_DIR"; then
800             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
801           fi
802           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
803         fi
805         dnl Confirm we have the pri tools on win8 builds
806         if test -n "$MOZ_METRO"; then
807           AC_MSG_CHECKING([for makepri])
808           AC_CHECK_PROGS(MAKEPRI, makepri, "")
809           if test -z "MAKEPRI" ; then
810               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
811           fi
812           AC_SUBST(MAKEPRI)
813         fi
815         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
816         dnl not something else like "magnetic tape manipulation utility".
817         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
818         if test -z "$MSMT_TOOL"; then
819           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
820         fi
822         changequote(,)
823         _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
824         changequote([,])
825         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
826         if test -z "$MSMANIFEST_TOOL_VERSION"; then
827           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
828         fi
830         MSMANIFEST_TOOL=1
831         unset MSMT_TOOL
833         # Check linker version
834         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
835         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
836         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
837             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
838         fi
840         INCREMENTAL_LINKER=1
842         # Check midl version
843         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
844         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
845         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
846         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
847         # Add flags if necessary
848         AC_MSG_CHECKING([for midl flags])
849         case "$target" in
850         i*86-*)
851             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
852                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
853                 # MIDL version 7.00.0500 or later has no problem.
854                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
855                 AC_MSG_RESULT([need -env win32])
856             else
857                 AC_MSG_RESULT([none needed])
858             fi
859             ;;
860         x86_64-*)
861             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
862             ;;
863         *)
864             AC_MSG_RESULT([none needed])
865             ;;
866         esac
868         # Identify which version of the SDK we're building with
869         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
870         # from there
871         MOZ_CHECK_HEADERS([winsdkver.h])
872         if test "$ac_cv_header_winsdkver_h" = "yes"; then
873             # Get the highest _WIN32_WINNT and NTDDI versions supported
874             # Take the higher of the two
875             # This is done because the Windows 7 beta SDK reports its
876             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
877             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
878                            ac_cv_winsdk_maxver,
879                            [cat > conftest.h <<EOF
880 #include <winsdkver.h>
881 #include <sdkddkver.h>
883 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
884 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
885 #else
886 #define WINSDK_MAXVER NTDDI_MAXVER
887 #endif
889 WINSDK_MAXVER
891                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
892                             rm -f conftest.h
893                            ])
894             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
895         else
896             # Any SDK which doesn't have WinSDKVer.h is too old.
897             AC_MSG_ERROR([Your SDK does not have WinSDKVer.h. It is probably too old. Please upgrade to a newer SDK or 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.])
898         fi
900         unset _MSVC_VER_FILTER
902         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
903             [
904                 AC_LANG_SAVE
905                 AC_LANG_CPLUSPLUS
906                 _SAVE_CXXFLAGS="$CXXFLAGS"
907                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
908                 AC_TRY_COMPILE([#include <exception>],
909                             [std::_Throw(std::exception()); return 0;],
910                             ac_cv_have_std__Throw="yes",
911                             ac_cv_have_std__Throw="no")
912                 CXXFLAGS="$_SAVE_CXXFLAGS"
913                 AC_LANG_RESTORE
914             ])
916         if test "$ac_cv_have_std__Throw" = "yes"; then
917             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
918                            ac_cv_have_dllimport_exception_bug,
919                 [
920                     AC_LANG_SAVE
921                     AC_LANG_CPLUSPLUS
922                     _SAVE_CXXFLAGS="$CXXFLAGS"
923                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
924                     AC_TRY_LINK([#include <vector>],
925                                 [std::vector<int> v; return v.at(1);],
926                                 ac_cv_have_dllimport_exception_bug="no",
927                                 ac_cv_have_dllimport_exception_bug="yes")
928                     CXXFLAGS="$_SAVE_CXXFLAGS"
929                     AC_LANG_RESTORE
930                 ])
931             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
932                 WRAP_STL_INCLUDES=1
933                 MOZ_MSVC_STL_WRAP__Throw=1
934                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
935             fi
936         else
937             AC_CACHE_CHECK(for overridable _RAISE,
938                            ac_cv_have__RAISE,
939                 [
940                     AC_LANG_SAVE
941                     AC_LANG_CPLUSPLUS
942                     _SAVE_CXXFLAGS="$CXXFLAGS"
943                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
944                     AC_TRY_COMPILE([#include <xstddef>
945                                     #undef _RAISE
946                                     #define _RAISE(x) externallyDefinedFunction((x).what())
947                                     #include <vector>
948                                    ],
949                                    [std::vector<int> v; return v.at(1);],
950                                    ac_cv_have__RAISE="no",
951                                    ac_cv_have__RAISE="yes")
952                     CXXFLAGS="$_SAVE_CXXFLAGS"
953                     AC_LANG_RESTORE
954                 ])
955             if test "$ac_cv_have__RAISE" = "yes"; then
956                 WRAP_STL_INCLUDES=1
957                 MOZ_MSVC_STL_WRAP__RAISE=1
958                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
959             else
960                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
961             fi
962         fi
964         if test "$WRAP_STL_INCLUDES" = "1"; then
965             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
966         fi
967     else
968         # Check w32api version
969         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
970         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
971         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
972         AC_TRY_COMPILE([#include <w32api.h>],
973             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
974                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
975                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
976                 #error "test failed."
977             #endif
978             , [ res=yes ], [ res=no ])
979         AC_MSG_RESULT([$res])
980         if test "$res" != "yes"; then
981             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
982         fi
983         # Check windres version
984         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
985         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
986         AC_MSG_RESULT([$_WINDRES_VERSION])
987         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
988         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
989         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
990         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
991         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
992         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
993         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
994                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
995                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
996                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
997                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
998                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
999         then
1000             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
1001         fi
1003         MOZ_WINSDK_MAXVER=0x06020000
1004     fi # !GNU_CC
1006     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
1007     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
1008     # Require OS features provided by IE 6.0 SP2 (XP SP2)
1009     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
1011     # If the maximum version supported by this SDK is lower than the target
1012     # version, error out
1013     AC_MSG_CHECKING([for Windows SDK being recent enough])
1014     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
1015         AC_MSG_RESULT("yes")
1016     else
1017         AC_MSG_RESULT("no")
1018         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.])
1019     fi
1020     
1021     # Make sure the sdk / code we're targeting has the right toolset
1022     AC_MSG_CHECKING([SDK and tools are in sync])
1023     if test -n "$MOZ_METRO"; then
1024       if test "$MOZ_MSVCVERSION" -gt "10"; then
1025         AC_MSG_RESULT("yes")
1026       else
1027         AC_MSG_RESULT("no")
1028         AC_MSG_ERROR([Your MOZ_MSVCVERSION equals $MOZ_MSVCVERSION and you've enabled metro build support. You can't target metro without msvc 11 or higher. Disable metro support or switch to a newer set of tools.])
1029       fi
1030     fi
1031       
1032     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
1033     # Definitions matching sdkddkver.h
1034     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
1035     ;;
1036 esac
1038 AC_PROG_CPP
1039 AC_PROG_CXXCPP
1041 if test -n "$_WIN32_MSVC"; then
1042     SKIP_PATH_CHECKS=1
1043     SKIP_COMPILER_CHECKS=1
1044     SKIP_LIBRARY_CHECKS=1
1046     # Since we're skipping compiler and library checks, hard-code
1047     # some facts here.
1048     AC_DEFINE(HAVE_IO_H)
1049     AC_DEFINE(HAVE_SETBUF)
1050     AC_DEFINE(HAVE_ISATTY)
1053 fi # COMPILE_ENVIRONMENT
1055 AC_SUBST(MIDL_FLAGS)
1056 AC_SUBST(_MSC_VER)
1058 AC_SUBST(GNU_AS)
1059 AC_SUBST(GNU_LD)
1060 AC_SUBST(GNU_CC)
1061 AC_SUBST(GNU_CXX)
1062 AC_SUBST(INTEL_CC)
1063 AC_SUBST(INTEL_CXX)
1064 AC_SUBST(CLANG_CC)
1065 AC_SUBST(CLANG_CXX)
1067 AC_SUBST(STL_FLAGS)
1068 AC_SUBST(WRAP_STL_INCLUDES)
1069 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
1070 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
1072 dnl ========================================================
1073 dnl Checks for programs.
1074 dnl ========================================================
1075 AC_PROG_INSTALL
1076 AC_PROG_LN_S
1078 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
1079 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
1080 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
1081 _perl_res=$?
1082 AC_MSG_RESULT([$_perl_version])
1084 if test "$_perl_res" != 0; then
1085     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
1089 AC_MSG_CHECKING([for full perl installation])
1090 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
1091 _perl_res=$?
1092 if test "$_perl_res" != 0; then
1093     AC_MSG_RESULT([no])
1094     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
1095 else
1096     AC_MSG_RESULT([yes])
1099 MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python2.6 python2.5 python)
1100 if test -z "$PYTHON"; then
1101     AC_MSG_ERROR([python was not found in \$PATH])
1104 MOZ_ARG_WITH_BOOL(system-ply,
1105 [  --with-system-ply       Use system installed python ply library],
1106     [if $PYTHON -c 'import ply' 2>&5; then
1107          MOZ_SYSTEM_PLY=1
1108      else
1109          AC_MSG_ERROR([python ply library is not found but --with-system-ply was requested])
1110      fi])
1112 AC_SUBST(MOZ_SYSTEM_PLY)
1114 if test -z "$COMPILE_ENVIRONMENT"; then
1115     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
1117 AC_SUBST(NSINSTALL_BIN)
1119 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
1120 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
1121 MOZ_PATH_PROGS(UNZIP, unzip)
1122 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
1123     AC_MSG_ERROR([unzip not found in \$PATH])
1125 MOZ_PATH_PROGS(ZIP, zip)
1126 if test -z "$ZIP" -o "$ZIP" = ":"; then
1127     AC_MSG_ERROR([zip not found in \$PATH])
1129 MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
1130 MOZ_PATH_PROG(XARGS, xargs)
1131 if test -z "$XARGS" -o "$XARGS" = ":"; then
1132     AC_MSG_ERROR([xargs not found in \$PATH .])
1135 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
1136 AC_SUBST(RPMBUILD)
1138 if test "$COMPILE_ENVIRONMENT"; then
1140 dnl ========================================================
1141 dnl = Mac OS X toolchain support
1142 dnl ========================================================
1144 case "$target_os" in
1145 darwin*)
1146     dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
1147     dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
1148     dnl the environment and includedir purposes (when using an SDK, below),
1149     dnl but remember the full version number for the libdir (SDK).
1150     changequote(,)
1151     GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1152     GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1153     changequote([,])
1154     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
1155         dnl Bug 280479, but this keeps popping up in bug 292530 too because
1156         dnl 4.0.0/4061 is the default compiler in Tiger.
1157         changequote(,)
1158         GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
1159         changequote([,])
1160         if test "$GCC_BUILD" = "4061" ; then
1161             AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
1162 This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
1163 from building Mozilla. Upgrade to Xcode 2.1 or later.])
1164         fi
1165     fi
1167     dnl xcodebuild needs GCC_VERSION defined in the environment, since it
1168     dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
1169     dnl /usr/bin/g(cc|++)-$GCC_VERSION.
1170     MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
1172     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
1173     dnl it has moved into /usr/bin.
1174     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
1175     ;;
1176 esac
1178 AC_SUBST(GCC_VERSION)
1180 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
1181 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
1182 dnl when we can run target binaries.
1183 AC_SUBST(UNIVERSAL_BINARY)
1184 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
1186 dnl ========================================================
1187 dnl Check for MacOS deployment target version
1188 dnl ========================================================
1190 MOZ_ARG_ENABLE_STRING(macos-target,
1191                       [  --enable-macos-target=VER (default=10.5)
1192                           Set the minimum MacOS version needed at runtime],
1193                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
1195 case "$target" in
1196 *-darwin*)
1197     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1198         dnl Use the specified value
1199         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1200     else
1201         dnl No value specified on the command line or in the environment,
1202         dnl use architecture minimum.
1203         case "${target_cpu}" in
1204           i*86)
1205             export MACOSX_DEPLOYMENT_TARGET=10.5
1206             ;;
1207           x86_64)
1208             export MACOSX_DEPLOYMENT_TARGET=10.6
1209             ;;
1210         esac
1211     fi
1212     ;;
1213 esac
1215 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
1217 dnl ========================================================
1218 dnl = Mac OS X SDK support
1219 dnl ========================================================
1220 MACOS_SDK_DIR=
1221 NEXT_ROOT=
1222 MOZ_ARG_WITH_STRING(macos-sdk,
1223 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
1224     MACOS_SDK_DIR=$withval)
1226 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
1227 dnl NEXT_ROOT will be set and exported only if it's needed.
1228 AC_SUBST(MACOS_SDK_DIR)
1229 AC_SUBST(NEXT_ROOT)
1231 if test "$MACOS_SDK_DIR"; then
1232   dnl Sync this section with the ones in NSPR and NSS.
1233   dnl Changes to the cross environment here need to be accounted for in
1234   dnl the libIDL checks (below) and xpidl build.
1236   if test ! -d "$MACOS_SDK_DIR"; then
1237     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1238 specify a valid SDK.  SDKs are installed when the optional cross-development
1239 tools are selected during the Xcode/Developer Tools installation.])
1240   fi
1242   GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1243   if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1244     AC_MSG_ERROR([You need to upgrade the compiler version to 4.x])
1245   else
1246     CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1247     CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
1249     dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
1250     CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1251     CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
1253     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
1254       dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
1255       dnl that supports -syslibroot.  Don't set NEXT_ROOT because it will
1256       dnl be ignored and cause warnings when -syslibroot is specified.
1257       dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
1258       dnl the -isysroot it receives, so this is only needed with 4.0.0.
1259       LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1260     fi
1261   fi
1263   AC_LANG_SAVE
1264   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
1265   AC_LANG_CPLUSPLUS
1266   AC_TRY_COMPILE([#include <new>],[],
1267    result=yes,
1268    result=no)
1269   AC_LANG_RESTORE
1270   AC_MSG_RESULT($result)
1272   if test "$result" = "no" ; then
1273     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
1274   fi
1277 fi # COMPILE_ENVIRONMENT
1279 dnl clang prior to 2.9 (including Xcode 4) does not support all the
1280 dnl constructs required by the libtheora inline asm. This is used to
1281 dnl detect and disable it
1282 AC_MSG_CHECKING([whether the C compiler is clang older than version 2.9])
1283 AC_LANG_SAVE
1284 AC_LANG_C
1285 AC_TRY_COMPILE([
1286 #if defined(__clang__)
1287 # if __clang_major__<2 || (__clang_major__==2 && __clang_minor__<9)
1288 #  error "clang older than 2.9 detected"
1289 # endif
1290 #endif
1291                ],
1292                [],
1293                result="no",
1294                result="yes")
1295 AC_LANG_RESTORE
1296 AC_MSG_RESULT([$result])
1297 if test "$result" = "yes"; then
1298   MOZ_NO_THEORA_ASM=1
1300 dnl XCode 4.2 also shipped an llvm-gcc which couldn't compile
1301 dnl the libtheora inline asm.
1302 AC_MSG_CHECKING([bad gcc versions])
1303 if `$CC --version | grep -q "Apple Inc. build 5658"`; then
1304   AC_MSG_RESULT([Apple build 5658])
1305   MOZ_NO_THEORA_ASM=1
1306 else
1307   AC_MSG_RESULT([we're ok])
1310 AC_SUBST(MOZ_NO_THEORA_ASM)
1312 if test "x$MOZ_NO_THEORA_ASM" = x1; then
1313   AC_MSG_WARN([Disabling libtheora inline assembly])
1316 if test -n "$MAKE"; then
1317   if test `echo $MAKE | grep -c make.py` != 1; then
1318      NOT_PYMAKE=$MAKE
1319   fi
1322 case "$host_os" in
1323 mingw*)
1324     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
1325     ;;
1327     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
1328     ;;
1329 esac
1330 if test "$GMAKE" = ":"; then
1331    AC_MSG_ERROR([GNU make not found])
1333 AC_SUBST(GMAKE)
1335 if test "$COMPILE_ENVIRONMENT"; then
1337 AC_PATH_XTRA
1339 XCFLAGS="$X_CFLAGS"
1341 fi # COMPILE_ENVIRONMENT
1343 dnl ========================================================
1344 dnl set the defaults first
1345 dnl ========================================================
1346 AS_BIN=$AS
1347 AR_LIST='$(AR) t'
1348 AR_EXTRACT='$(AR) x'
1349 AR_DELETE='$(AR) d'
1350 AS='$(CC)'
1351 AS_DASH_C_FLAG='-c'
1352 DLL_PREFIX=lib
1353 LIB_PREFIX=lib
1354 DLL_SUFFIX=.so
1355 OBJ_SUFFIX=o
1356 LIB_SUFFIX=a
1357 ASM_SUFFIX=s
1358 IMPORT_LIB_SUFFIX=
1359 TARGET_MD_ARCH=unix
1360 DIRENT_INO=d_ino
1361 WIN_TOP_SRC=
1362 MOZ_USER_DIR=".mozilla"
1364 MOZ_JPEG_CFLAGS=
1365 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
1366 MOZ_ZLIB_CFLAGS=
1367 MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
1368 MOZ_BZ2_CFLAGS=
1369 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
1370 MOZ_PNG_CFLAGS=
1371 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
1373 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
1374 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
1375 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
1376 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1377 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
1378 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
1379 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1380 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
1382 MOZ_FS_LAYOUT=unix
1384 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1386 USE_DEPENDENT_LIBS=1
1388 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1390 if test -n "$CROSS_COMPILE"; then
1391     OS_TARGET="${target_os}"
1392     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1393     OS_RELEASE=
1394     case "${target_os}" in
1395         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1396         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1397         gnu*)         OS_ARCH=GNU ;;
1398         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1399         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1400         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1401     esac
1402     case "${target}" in
1403         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1404     esac
1405 else
1406     OS_TARGET=`uname -s`
1407     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1408     OS_RELEASE=`uname -r`
1411 # Before this used `uname -m` when not cross compiling
1412 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1413 OS_TEST="${target_cpu}"
1415 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1417 #######################################################################
1418 # Master "Core Components" macros for getting the OS target           #
1419 #######################################################################
1422 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1423 # cross-compilation.
1427 # Define and override various archtecture-specific variables, including
1428 # HOST_OS_ARCH
1429 # OS_ARCH
1430 # OS_TEST
1431 # OS_TARGET
1432 # OS_RELEASE
1433 # OS_MINOR_RELEASE
1436 case "$HOST_OS_ARCH" in
1437 mingw*)
1438     HOST_OS_ARCH=WINNT
1439     ;;
1440 darwin*)
1441     HOST_OS_ARCH=Darwin
1442     ;;
1443 linux*)
1444     HOST_OS_ARCH=Linux
1445     ;;
1446 solaris*)
1447     HOST_OS_ARCH=SunOS
1448     SOLARIS_SUNPRO_CC=
1449     SOLARIS_SUNPRO_CXX=
1450     if test -z "$GNU_CC"; then
1451         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1452             SOLARIS_SUNPRO_CC=1
1453        fi
1454     fi
1456     if test -z "$GNU_CXX"; then
1457        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1458            SOLARIS_SUNPRO_CXX=1
1459        fi
1460     fi
1461     AC_SUBST(SOLARIS_SUNPRO_CC)
1462     AC_SUBST(SOLARIS_SUNPRO_CXX)
1463     ;;
1464 BSD_386)
1465     HOST_OS_ARCH=BSD
1466     ;;
1467 OS_2)
1468     HOST_OS_ARCH=OS2
1469     ;;
1470 esac
1472 case "$OS_ARCH" in
1473 WINNT)
1474     if test -z "$CROSS_COMPILE" ; then
1475         OS_TEST=`uname -p`
1476     fi
1477     ;;
1478 Windows_NT)
1480 # If uname -s returns "Windows_NT", we assume that we are using
1481 # the uname.exe in MKS toolkit.
1483 # The -r option of MKS uname only returns the major version number.
1484 # So we need to use its -v option to get the minor version number.
1485 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1487     OS_ARCH=WINNT
1488     OS_TARGET=WINNT
1489     OS_MINOR_RELEASE=`uname -v`
1490     if test "$OS_MINOR_RELEASE" = "00"; then
1491         OS_MINOR_RELEASE=0
1492     fi
1493     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1494     ;;
1495 MINGW*_NT*)
1497 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1498 # the uname.exe in the MSYS tools.
1500     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1501     OS_ARCH=WINNT
1502     OS_TARGET=WINNT
1503     ;;
1504 AIX)
1505     OS_RELEASE=`uname -v`.`uname -r`
1506     OS_TEST=${target_cpu}
1507     ;;
1508 BSD_386)
1509     OS_ARCH=BSD
1510     ;;
1511 OS_2)
1512     OS_ARCH=OS2
1513     OS_TARGET=OS2
1514     OS_RELEASE=`uname -v`
1515     ;;
1516 Darwin)
1517     case "${target_cpu}" in
1518     powerpc*)
1519         OS_TEST=ppc
1520         ;;
1521     i*86*)
1522         OS_TEST=i386
1523         ;;
1524     x86_64)
1525         OS_TEST=x86_64
1526         ;;
1527     *)
1528         if test -z "$CROSS_COMPILE" ; then
1529             OS_TEST=`uname -p`
1530         fi
1531         ;;
1532     esac
1533     ;;
1534 esac
1536 # Only set CPU_ARCH if we recognize the value of OS_TEST
1538 case "$OS_TEST" in
1539 *86 | i86pc)
1540     CPU_ARCH=x86
1541     ;;
1543 powerpc64 | ppc64)
1544     CPU_ARCH=ppc64
1545     ;;
1547 powerpc | ppc | rs6000)
1548     CPU_ARCH=ppc
1549     ;;
1551 Alpha | alpha | ALPHA)
1552     CPU_ARCH=Alpha
1553     ;;
1555 s390)
1556     CPU_ARCH=s390
1557     ;;
1559 s390x)
1560     CPU_ARCH=s390x
1561     ;;
1563 hppa* | parisc)
1564     CPU_ARCH=hppa
1565     ;;
1567 sun4u | sparc*)
1568     CPU_ARCH=sparc
1569     ;;
1571 x86_64 | ia64)
1572     CPU_ARCH="$OS_TEST"
1573     ;;
1575 arm*)
1576     CPU_ARCH=arm
1577     ;;
1579 mips|mipsel)
1580     CPU_ARCH="mips"
1581     ;;
1582 esac
1584 if test -z "$OS_TARGET"; then
1585     OS_TARGET=$OS_ARCH
1587 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1589 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1590 dnl ===============================================================
1591 INTEL_ARCHITECTURE=
1592 case "$OS_TEST" in
1593     x86_64|i?86)
1594       INTEL_ARCHITECTURE=1
1595 esac
1597 dnl Configure platform-specific CPU architecture compiler options.
1598 dnl ==============================================================
1599 MOZ_ARCH_OPTS
1601 dnl =================================================================
1602 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1603 dnl which is bad when cross compiling.
1604 dnl =================================================================
1605 if test "$COMPILE_ENVIRONMENT"; then
1606 configure_static_assert_macros='
1607 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1608 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1609 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1612 dnl test that the macros actually work:
1613 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1614 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1615  [AC_LANG_SAVE
1616   AC_LANG_C
1617   ac_cv_static_assertion_macros_work="yes"
1618   AC_TRY_COMPILE([$configure_static_assert_macros],
1619                  [CONFIGURE_STATIC_ASSERT(1)],
1620                  ,
1621                  ac_cv_static_assertion_macros_work="no")
1622   AC_TRY_COMPILE([$configure_static_assert_macros],
1623                  [CONFIGURE_STATIC_ASSERT(0)],
1624                  ac_cv_static_assertion_macros_work="no",
1625                  )
1626   AC_LANG_CPLUSPLUS
1627   AC_TRY_COMPILE([$configure_static_assert_macros],
1628                  [CONFIGURE_STATIC_ASSERT(1)],
1629                  ,
1630                  ac_cv_static_assertion_macros_work="no")
1631   AC_TRY_COMPILE([$configure_static_assert_macros],
1632                  [CONFIGURE_STATIC_ASSERT(0)],
1633                  ac_cv_static_assertion_macros_work="no",
1634                  )
1635   AC_LANG_RESTORE
1636  ])
1637 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1638 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1639     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1641 fi # COMPILE_ENVIRONMENT
1643 dnl ========================================================
1644 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1645 dnl computed above.
1646 dnl ========================================================
1648 if test "$OS_TARGET" = "Android"; then
1649     case "${CPU_ARCH}-${MOZ_ARCH}" in
1650     arm-armv7*)
1651       ANDROID_CPU_ARCH=armeabi-v7a
1652       ;;
1653     arm-*)
1654       ANDROID_CPU_ARCH=armeabi
1655       ;;
1656     x86-*)
1657       ANDROID_CPU_ARCH=x86
1658       ;;
1659     esac
1662 if test "$OS_TARGET" = "Android" -a -z "$gonkdir"; then
1663     if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
1664        if test ! -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a" ; then
1665           AC_MSG_ERROR([Cannot find path to libstdc++ (NDK version >= 5?)])
1666        fi
1667        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"
1668        STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH"
1669        STLPORT_LIBS="-lstdc++"
1670     elif test -e "$android_ndk/sources/cxx-stl/stlport/src/iostream.cpp" ; then
1671        if test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
1672           STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
1673        elif test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
1674           STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
1675        else
1676           AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
1677        fi
1678        STLPORT_SOURCES="$android_ndk/sources/cxx-stl/stlport"
1679        STLPORT_CPPFLAGS="-I$_objdir/build/stlport -I$android_ndk/sources/cxx-stl/stlport/stlport"
1680        STLPORT_LIBS="-lstlport_static"
1681     elif test "$target" != "arm-android-eabi"; then
1682        dnl fail if we're not building with NDKr4
1683        AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
1684     fi
1685     CXXFLAGS="$CXXFLAGS $STLPORT_CPPFLAGS"
1686     LDFLAGS="$LDFLAGS $STLPORT_LDFLAGS"
1687     LIBS="$LIBS $STLPORT_LIBS"
1690 AC_SUBST([STLPORT_SOURCES])
1692 dnl ========================================================
1693 dnl Suppress Clang Argument Warnings
1694 dnl ========================================================
1695 if test -n "$CLANG_CC"; then
1696     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1697     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1699 if test -n "$CLANG_CXX"; then
1700     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1703 dnl ========================================================
1704 dnl = Use Address Sanitizer
1705 dnl ========================================================
1706 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1707 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1708     MOZ_ASAN=1,
1709     MOZ_ASAN= )
1710 if test -n "$MOZ_ASAN"; then
1711     MOZ_LLVM_HACKS=1
1712     AC_DEFINE(MOZ_ASAN)
1714 AC_SUBST(MOZ_ASAN)
1716 dnl ========================================================
1717 dnl = Enable hacks required for LLVM instrumentations
1718 dnl ========================================================
1719 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1720 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1721     MOZ_LLVM_HACKS=1,
1722     MOZ_LLVM_HACKS= )
1723 if test -n "$MOZ_LLVM_HACKS"; then
1724     MOZ_NO_WLZDEFS=1
1725     MOZ_CFLAGS_NSS=1
1727 AC_SUBST(MOZ_NO_WLZDEFS)
1728 AC_SUBST(MOZ_CFLAGS_NSS)
1730 dnl ========================================================
1731 dnl GNU specific defaults
1732 dnl ========================================================
1733 if test "$GNU_CC"; then
1734     # FIXME: Let us build with strict aliasing. bug 414641.
1735     CFLAGS="$CFLAGS -fno-strict-aliasing"
1736     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1737     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1738     DSO_LDOPTS='-shared'
1739     if test "$GCC_USE_GNU_LD"; then
1740         # Some tools like ASan use a runtime library that is only
1741         # linked against executables, so we must allow undefined
1742         # symbols for shared objects in some cases.
1743         if test -z "$MOZ_NO_WLZDEFS"; then
1744             # Don't allow undefined symbols in libraries
1745             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1746         fi
1747     fi
1748     WARNINGS_AS_ERRORS='-Werror -Wno-error=uninitialized'
1749     DSO_CFLAGS=''
1750     DSO_PIC_CFLAGS='-fPIC'
1751     ASFLAGS="$ASFLAGS -fPIC"
1752     _MOZ_RTTI_FLAGS_ON=-frtti
1753     _MOZ_RTTI_FLAGS_OFF=-fno-rtti
1755     # Turn on GNU-specific warnings:
1756     # -Wall - turn on a lot of warnings
1757     # -pedantic - this is turned on below
1758     # -Wpointer-arith - enabled with -pedantic, but good to have even if not
1759     # -Wdeclaration-after-statement - MSVC doesn't like these
1760     # -Werror=return-type - catches missing returns, zero false positives
1761     # -Wtype-limits - catches overflow bugs, few false positives
1762     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1763     #
1764     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1765     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1766     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1767     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1768     
1769     # Turn off the following warnings that -Wall/-pedantic turn on:
1770     # -Wno-unused - lots of violations in third-party code
1771     # -Wno-overlength-strings - we exceed the minimum maximum length frequently
1772     #
1773     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1774     MOZ_C_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_c_has_wno_overlength_strings)
1776     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1777        # Don't use -Wcast-align with ICC or clang
1778        case "$CPU_ARCH" in
1779            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1780            hppa | ia64 | sparc | arm)
1781            ;;
1782            *)
1783         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1784            ;;
1785        esac
1786     fi
1788     dnl Turn pedantic on but disable the warnings for long long
1789     _PEDANTIC=1
1791     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1792     _USE_CPP_INCLUDE_FLAG=1
1794 elif test "$SOLARIS_SUNPRO_CC"; then
1795     DSO_CFLAGS=''
1796     if test "$CPU_ARCH" = "sparc"; then
1797         # for Sun Studio on Solaris/SPARC
1798         DSO_PIC_CFLAGS='-xcode=pic32'
1799     else
1800         DSO_PIC_CFLAGS='-KPIC'
1801     fi
1802     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1803 else
1804     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1805     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1807     DSO_LDOPTS='-shared'
1808     if test "$GNU_LD"; then
1809         # Don't allow undefined symbols in libraries
1810         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1811     fi
1813     DSO_CFLAGS=''
1814     DSO_PIC_CFLAGS='-KPIC'
1815     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1818 if test "$GNU_CXX"; then
1819     # FIXME: Let us build with strict aliasing. bug 414641.
1820     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1822     # Turn on GNU-specific warnings:
1823     # -Wall - turn on a lot of warnings
1824     # -pedantic - this is turned on below
1825     # -Wpointer-arith - enabled with -pedantic, but good to have even if not
1826     # -Woverloaded-virtual - ???
1827     # -Werror=return-type - catches missing returns, zero false positives
1828     # -Wtype-limits - catches overflow bugs, few false positives
1829     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1830     #
1831     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1832     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1833     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1834     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1836     # Turn off the following warnings that -Wall/-pedantic turn on:
1837     # -Wno-ctor-dtor-privacy - ???
1838     # -Wno-overlength-strings - we exceed the minimum maximum length frequently 
1839     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1840     # -Wno-variadic-macros - ???
1841     #
1842     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-ctor-dtor-privacy"
1843     MOZ_CXX_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_cxx_has_wno_overlength_strings)
1844     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1845     MOZ_CXX_SUPPORTS_WARNING(-Wno-, variadic-macros, ac_cxx_has_wno_variadic_macros)
1847     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1848        # Don't use -Wcast-align with ICC or clang
1849        case "$CPU_ARCH" in
1850            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1851            hppa | ia64 | sparc | arm)
1852            ;;
1853            *)
1854         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1855            ;;
1856        esac
1857     fi
1859     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1860     _USE_CPP_INCLUDE_FLAG=1
1862     # Recent clang and gcc support C++11 deleted functions without warnings if
1863     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1864     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1865     # unused.  But clang's warning can be disabled, so when compiling with clang
1866     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1867     # deleted function syntax.
1868     if test "$CLANG_CXX"; then
1869         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1870         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1871     fi
1873 else
1874     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1877 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1878 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1879 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1880 dnl normal behavior.
1881 dnl ========================================================
1882 MKSHLIB_FORCE_ALL=
1883 MKSHLIB_UNFORCE_ALL=
1885 if test "$COMPILE_ENVIRONMENT"; then
1886 if test "$GNU_CC"; then
1887   AC_MSG_CHECKING(whether ld has archive extraction flags)
1888   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1889    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1890     ac_cv_mkshlib_force_and_unforce="no"
1891     exec 3<&0 <<LOOP_INPUT
1892         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1893         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1894         force="-Wl,-all";              unforce="-Wl,-none"
1895 LOOP_INPUT
1896     while read line
1897     do
1898       eval $line
1899       LDFLAGS=$force
1900       LIBS=$unforce
1901       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1902     done
1903     exec 0<&3 3<&-
1904     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1905    ])
1906   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1907     AC_MSG_RESULT(no)
1908   else
1909     AC_MSG_RESULT(yes)
1910     eval $ac_cv_mkshlib_force_and_unforce
1911     MKSHLIB_FORCE_ALL=$force
1912     MKSHLIB_UNFORCE_ALL=$unforce
1913   fi
1914 fi # GNU_CC
1915 fi # COMPILE_ENVIRONMENT
1917 dnl ========================================================
1918 dnl Checking for 64-bit OS
1919 dnl ========================================================
1920 if test "$COMPILE_ENVIRONMENT"; then
1921 AC_LANG_SAVE
1922 AC_LANG_C
1923 AC_MSG_CHECKING(for 64-bit OS)
1924 AC_TRY_COMPILE([$configure_static_assert_macros],
1925                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1926                result="yes", result="no")
1927 AC_MSG_RESULT("$result")
1928 if test "$result" = "yes"; then
1929     AC_DEFINE(HAVE_64BIT_OS)
1930     HAVE_64BIT_OS=1
1932 AC_SUBST(HAVE_64BIT_OS)
1933 AC_LANG_RESTORE
1934 fi # COMPILE_ENVIRONMENT
1936 dnl ========================================================
1937 dnl Enable high-memory support on OS/2 by default.
1938 dnl ========================================================
1939 MOZ_OS2_HIGH_MEMORY=1
1940 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1941 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1942     MOZ_OS2_HIGH_MEMORY=,
1943     MOZ_OS2_HIGH_MEMORY=1 )
1944 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1946 dnl ========================================================
1947 dnl = Use profiling compile flags
1948 dnl ========================================================
1949 MOZ_ARG_ENABLE_BOOL(profiling,
1950 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1951     MOZ_PROFILING=1,
1952     MOZ_PROFILING= )
1954 dnl ========================================================
1955 dnl = Use Valgrind
1956 dnl ========================================================
1957 MOZ_ARG_ENABLE_BOOL(valgrind,
1958 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1959     MOZ_VALGRIND=1,
1960     MOZ_VALGRIND= )
1961 if test -n "$MOZ_VALGRIND"; then
1962     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1963         AC_MSG_ERROR(
1964             [--enable-valgrind specified but Valgrind is not installed]))
1965     AC_DEFINE(MOZ_VALGRIND)
1967 AC_SUBST(MOZ_VALGRIND)
1969 dnl ========================================================
1970 dnl = Use DMD
1971 dnl ========================================================
1972 MOZ_ARG_ENABLE_BOOL(dmd,
1973 [  --enable-dmd            Enable DMD; also disables jemalloc (default=no)],
1974     MOZ_DMD=1,
1975     MOZ_DMD= )
1976 if test -n "$MOZ_DMD"; then
1977     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1978         AC_MSG_ERROR(
1979             [--enable-dmd specified but Valgrind is not installed]))
1980     AC_DEFINE(MOZ_DMD)
1982 AC_SUBST(MOZ_DMD)
1984 dnl ========================================================
1985 dnl jprof
1986 dnl ========================================================
1987 MOZ_ARG_ENABLE_BOOL(jprof,
1988 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1989     MOZ_JPROF=1,
1990     MOZ_JPROF= )
1991 if test -n "$MOZ_JPROF"; then
1992     MOZ_PROFILING=1
1993     AC_DEFINE(MOZ_JPROF)
1996 dnl ========================================================
1997 dnl SPS Profiler
1998 dnl ========================================================
1999 MOZ_ENABLE_PROFILER_SPS=1
2001 case "${OS_TARGET}" in
2002 Android)
2003     case "${CPU_ARCH}" in
2004     x86 | arm) ;;
2005     *)
2006         MOZ_ENABLE_PROFILER_SPS=
2007     esac
2008     ;;
2009 Linux)
2010     case "${CPU_ARCH}" in
2011     x86 | x86_64) ;;
2012     *)
2013         MOZ_ENABLE_PROFILER_SPS=
2014     esac
2015     ;;
2016 WINNT|Darwin) ;;
2018     MOZ_ENABLE_PROFILER_SPS=
2019     ;;
2020 esac
2022 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
2023     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
2026 dnl ========================================================
2027 dnl shark
2028 dnl ========================================================
2029 MOZ_ARG_ENABLE_BOOL(shark,
2030 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
2031     MOZ_SHARK=1,
2032     MOZ_SHARK= )
2033 if test -n "$MOZ_SHARK"; then
2034     MOZ_PROFILING=1
2035     AC_DEFINE(MOZ_SHARK)
2038 dnl ========================================================
2039 dnl callgrind
2040 dnl ========================================================
2041 MOZ_ARG_ENABLE_BOOL(callgrind,
2042 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
2043     MOZ_CALLGRIND=1,
2044     MOZ_CALLGRIND= )
2045 if test -n "$MOZ_CALLGRIND"; then
2046     MOZ_PROFILING=1
2047     AC_DEFINE(MOZ_CALLGRIND)
2050 dnl ========================================================
2051 dnl vtune
2052 dnl ========================================================
2053 MOZ_ARG_ENABLE_BOOL(vtune,
2054 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
2055     MOZ_VTUNE=1,
2056     MOZ_VTUNE= )
2057 if test -n "$MOZ_VTUNE"; then
2058     MOZ_PROFILING=1
2059     AC_DEFINE(MOZ_VTUNE)
2062 dnl ========================================================
2063 dnl Profiling
2064 dnl ========================================================
2065 if test -n "$MOZ_PROFILING"; then
2066     AC_DEFINE(MOZ_PROFILING)
2069 dnl ========================================================
2070 dnl System overrides of the defaults for host
2071 dnl ========================================================
2072 case "$host" in
2073 *mingw*)
2074     if test -n "$_WIN32_MSVC"; then
2075         HOST_AR=lib
2076         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
2077         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
2078         HOST_RANLIB='echo ranlib'
2079     else
2080         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
2081     fi
2082     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
2083     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
2084     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
2085     HOST_BIN_SUFFIX=.exe
2086     case "$host" in
2087     *mingw*)
2088         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
2089         ;;
2090     esac
2092     case "${host_cpu}" in
2093     i*86)
2094         if test -n "$_WIN32_MSVC"; then
2095             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
2096         fi
2097         ;;
2098     x86_64)
2099         if test -n "$_WIN32_MSVC"; then
2100             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
2101         fi
2102         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
2103         ;;
2104     esac
2105     ;;
2107 *-darwin*)
2108     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
2109     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2110     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
2111     ;;
2113 *-linux*|*-kfreebsd*-gnu|*-gnu*)
2114     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
2115     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2116     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
2117     ;;
2119 *os2*)
2120     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
2121     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2122     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
2123     HOST_BIN_SUFFIX=.exe
2124     MOZ_FIX_LINK_PATHS=
2125     ;;
2128     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
2129     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
2130     ;;
2131 esac
2133 dnl We require version 2.5 or newer of Python to build.
2134 AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION but not 3.x])
2135 changequote(,)
2136 $PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
2137 _python_res=$?
2138 changequote([,])
2139 if test "$_python_res" != 0; then
2140     AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
2142 AC_MSG_RESULT([yes])
2144 dnl Check for using a custom <stdint.h> implementation
2145 dnl ========================================================
2146 AC_MSG_CHECKING(for custom <stdint.h> implementation)
2147 if test "$MOZ_CUSTOM_STDINT_H"; then
2148   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
2149   AC_SUBST(MOZ_CUSTOM_STDINT_H)
2150   AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
2151 else
2152   AC_MSG_RESULT(none specified)
2155 dnl Get mozilla version from central milestone file
2156 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
2157 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
2159 dnl Get version of various core apps from the version files.
2160 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
2162 if test -z "$FIREFOX_VERSION"; then
2163     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
2166 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
2167 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
2168 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
2170 MOZ_DOING_LTO(lto_is_enabled)
2172 dnl ========================================================
2173 dnl System overrides of the defaults for target
2174 dnl ========================================================
2176 case "$target" in
2177 *-aix*)
2178     AC_DEFINE(AIX)
2179     if test ! "$GNU_CC"; then
2180         if test ! "$HAVE_64BIT_OS"; then
2181             # Compiling with Visual Age C++ object model compat is the
2182             # default. To compile with object model ibm, add
2183             # AIX_OBJMODEL=ibm to .mozconfig.
2184             if test "$AIX_OBJMODEL" = "ibm"; then
2185                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
2186             else
2187                 AIX_OBJMODEL=compat
2188             fi
2189         else
2190             AIX_OBJMODEL=compat
2191         fi
2192         AC_SUBST(AIX_OBJMODEL)
2193         DSO_LDOPTS='-qmkshrobj=1'
2194         DSO_CFLAGS='-qflag=w:w'
2195         DSO_PIC_CFLAGS=
2196         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
2197         MOZ_FIX_LINK_PATHS=
2198         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2199         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2200         if test "$COMPILE_ENVIRONMENT"; then
2201             AC_LANG_SAVE
2202             AC_LANG_CPLUSPLUS
2203             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
2204             AC_TRY_COMPILE([],
2205                 [#if (__IBMCPP__ < 900)
2206                  #error "Bad compiler"
2207                  #endif],
2208                 _BAD_COMPILER=,_BAD_COMPILER=1)
2209             if test -n "$_BAD_COMPILER"; then
2210                 AC_MSG_RESULT([no])
2211                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
2212             else
2213                 AC_MSG_RESULT([yes])
2214             fi
2215             AC_LANG_RESTORE
2216             TARGET_COMPILER_ABI="ibmc"
2217             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
2218             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
2219         fi
2220     fi
2221     case "${target_os}" in
2222     aix4.1*)
2223         DLL_SUFFIX='_shr.a'
2224         ;;
2225     esac
2226     if test "$COMPILE_ENVIRONMENT"; then
2227         MOZ_CHECK_HEADERS(sys/inttypes.h)
2228     fi
2229     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2230     ;;
2232 *-bsdi*)
2233     dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
2234     _PEDANTIC=
2235     case $OS_RELEASE in
2236         4.*|5.*)
2237             STRIP="$STRIP -d"
2238             ;;
2239         *)
2240             DSO_CFLAGS=''
2241             DSO_LDOPTS='-r'
2242             _WARNINGS_CFLAGS="-Wall"
2243             _WARNINGS_CXXFLAGS="-Wall"
2244             # The test above doesn't work properly, at least on 3.1.
2245             MKSHLIB_FORCE_ALL=''
2246             MKSHLIB_UNFORCE_ALL=''
2247         ;;
2248     esac
2249     ;;
2251 *-darwin*)
2252     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2253     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2254     MOZ_OPTIMIZE_FLAGS="-O3"
2255     _PEDANTIC=
2256     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
2257     if test "$HAVE_64BIT_OS"; then
2258         MOZ_MEMORY=1
2259     fi
2260     CFLAGS="$CFLAGS -fno-common"
2261     CXXFLAGS="$CXXFLAGS -fno-common"
2262     DLL_SUFFIX=".dylib"
2263     DSO_LDOPTS=''
2264     STRIP="$STRIP -x -S"
2265     # Check whether we're targeting OS X or iOS
2266     AC_CACHE_CHECK(for iOS target,
2267                    ac_cv_ios_target,
2268                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
2269 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
2270 #error not iOS
2271 #endif],
2272                                    [],
2273                                    ac_cv_ios_target="yes",
2274                                    ac_cv_ios_target="no")])
2275     if test "$ac_cv_ios_target" = "yes"; then
2276         AC_DEFINE(XP_IOS)
2277         AC_DEFINE(XP_DARWIN)
2278         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
2279     else
2280         AC_DEFINE(XP_MACOSX)
2281         AC_DEFINE(XP_DARWIN)
2282         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
2283         # The ExceptionHandling framework is needed for Objective-C exception
2284         # logging code in nsObjCExceptions.h. Currently we only use that in debug
2285         # builds.
2286         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
2287     fi
2288     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2291     if test "x$lto_is_enabled" = "xyes"; then
2292         echo "Skipping -dead_strip because lto is enabled."
2293     dnl DTrace and -dead_strip don't interact well. See bug 403132.
2294     dnl ===================================================================
2295     elif test "x$enable_dtrace" = "xyes"; then
2296         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
2297     else
2298         dnl check for the presence of the -dead_strip linker flag
2299         AC_MSG_CHECKING([for -dead_strip option to ld])
2300         _SAVE_LDFLAGS=$LDFLAGS
2301         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
2302         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
2303         if test -n "$_HAVE_DEAD_STRIP" ; then
2304             AC_MSG_RESULT([yes])
2305             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
2306         else
2307             AC_MSG_RESULT([no])
2308         fi
2310         LDFLAGS=$_SAVE_LDFLAGS
2311     fi
2312     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
2313     ;;
2315 *-freebsd*)
2316     if test `test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` != "elf"; then
2317         DLL_SUFFIX=".so.1.0"
2318         DSO_LDOPTS="-shared"
2319     fi
2320     if test ! "$GNU_CC"; then
2321         DSO_LDOPTS="-Bshareable $DSO_LDOPTS"
2322     fi
2323     ;;
2325 ia64*-hpux*)
2326     DLL_SUFFIX=".so"
2327     if test ! "$GNU_CC"; then
2328        DSO_LDOPTS='-b'
2329        DSO_CFLAGS=""
2330        DSO_PIC_CFLAGS=
2331        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2332        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2333        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2334     else
2335        DSO_LDOPTS='-b -E'
2336        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2337        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2338     fi
2339     MOZ_FIX_LINK_PATHS=
2340     SYSTEM_MAKEDEPEND=
2341     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2342     AC_DEFINE(_LARGEFILE64_SOURCE)
2343     ;;
2345 *-hpux*)
2346     DLL_SUFFIX=".sl"
2347     if test ! "$GNU_CC"; then
2348         DSO_LDOPTS='-b -Wl,+s'
2349         DSO_CFLAGS=""
2350         DSO_PIC_CFLAGS="+Z"
2351         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2352         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2353         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2354     else
2355         DSO_LDOPTS='-b -E +s'
2356         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2357         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2358     fi
2359     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2360     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2361     ;;
2363 *-android*|*-linuxandroid*)
2364     AC_DEFINE(NO_PW_GECOS)
2365     no_x=yes
2366     if test -n "$gonkdir"; then
2367         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2368         MOZ_B2G_RIL=1
2369         MOZ_B2G_BT=1
2370     else
2371         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2372         MOZ_LINKER=1
2373     fi
2374     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2376     MOZ_GFX_OPTIMIZE_MOBILE=1
2377     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2378     ;;
2380 *-*linux*)
2381     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2382     # Similarly for GNU_CXX and INTEL_CXX.
2383     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2384         # -Os has been broken on Intel's C/C++ compilers for quite a
2385         # while; Intel recommends against using it.
2386         MOZ_OPTIMIZE_FLAGS="-O2"
2387         MOZ_DEBUG_FLAGS="-g"
2388     elif test "$GNU_CC" -o "$GNU_CXX"; then
2389         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2390         case $GCC_VERSION in
2391         4.1.*|4.2.*|4.5.*)
2392             # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
2393             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2394         esac
2395         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2396         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2397         MOZ_DEBUG_FLAGS="-g"
2398     fi
2400     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2402     MOZ_MEMORY=1
2404     case "${target_cpu}" in
2405     alpha*)
2406         CFLAGS="$CFLAGS -mieee"
2407         CXXFLAGS="$CXXFLAGS -mieee"
2408     ;;
2409     i*86)
2410         USE_ELF_DYNSTR_GC=1
2411     ;;
2412     mips*)
2413         MOZ_DEBUG_FLAGS="-g" # We want inlining
2414     ;;
2415     esac
2417     if test -z "$MC"; then
2418         MC=mc.exe
2419     fi
2420     ;;
2421 *-mingw*)
2422     DSO_CFLAGS=
2423     DSO_PIC_CFLAGS=
2424     DLL_SUFFIX=.dll
2425     RC=rc.exe
2426     MC=mc.exe
2427     # certain versions of cygwin's makedepend barf on the
2428     # #include <string> vs -I./dist/include/string issue so don't use it
2429     SYSTEM_MAKEDEPEND=
2430     if test -n "$GNU_CC"; then
2431         CC="$CC -mwindows"
2432         CXX="$CXX -mwindows"
2433         CPP="$CPP -mwindows"
2434         CFLAGS="$CFLAGS -mms-bitfields"
2435         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2436         DSO_LDOPTS='-shared'
2437         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2438         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2439         RC='$(WINDRES)'
2440         # Use temp file for windres (bug 213281)
2441         RCFLAGS='-O coff --use-temp-file'
2442         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2443         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv"
2444         MOZ_FIX_LINK_PATHS=
2445         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2446         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2447         DLL_PREFIX=
2448         IMPORT_LIB_SUFFIX=dll.a
2449         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2450     else
2451         TARGET_COMPILER_ABI=msvc
2452         HOST_CC='$(CC)'
2453         HOST_CXX='$(CXX)'
2454         HOST_LD='$(LD)'
2455         if test "$AS_BIN"; then
2456             AS="$(basename "$AS_BIN")"
2457         fi
2458         AR='lib'
2459         AR_FLAGS='-NOLOGO -OUT:"$@"'
2460         AR_EXTRACT=
2461         RANLIB='echo not_ranlib'
2462         STRIP='echo not_strip'
2463         PKG_SKIP_STRIP=1
2464         XARGS=xargs
2465         ZIP=zip
2466         UNZIP=unzip
2467         DOXYGEN=:
2468         ASM_SUFFIX=asm
2469         OBJ_SUFFIX=obj
2470         LIB_SUFFIX=lib
2471         DLL_PREFIX=
2472         LIB_PREFIX=
2473         IMPORT_LIB_SUFFIX=lib
2474         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2475         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2476         MKSHLIB_FORCE_ALL=
2477         MKSHLIB_UNFORCE_ALL=
2478         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2479         _USE_CPP_INCLUDE_FLAG=1
2480         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2481         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2482         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2483         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2484         CXXFLAGS="$CXXFLAGS -wd4800" # disable warning "forcing value to bool"
2485         # make 'foo == bar;' error out
2486         CFLAGS="$CFLAGS -we4553"
2487         CXXFLAGS="$CXXFLAGS -we4553"
2488         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
2489         MOZ_DEBUG_FLAGS='-Zi'
2490         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2491         WARNINGS_AS_ERRORS='-WX'
2492         MOZ_OPTIMIZE_FLAGS='-O1'
2493         MOZ_FIX_LINK_PATHS=
2494         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2495         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2496         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2497         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2498         if test $_MSC_VER -ge 1400; then
2499             LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2500             dnl For profile-guided optimization
2501             PROFILE_GEN_CFLAGS="-GL"
2502             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2503             dnl XXX: PGO builds can fail with warnings treated as errors,
2504             dnl specifically "no profile data available" appears to be
2505             dnl treated as an error sometimes. This might be a consequence
2506             dnl of using WARNINGS_AS_ERRORS in some modules, combined
2507             dnl with the linker doing most of the work in the whole-program
2508             dnl optimization/PGO case. I think it's probably a compiler bug,
2509             dnl but we work around it here.
2510             PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2511             dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2512             dnl Probably also a compiler bug, but what can you do?
2513             PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2514             LDFLAGS="$LDFLAGS -DYNAMICBASE"
2515         fi
2516     fi
2517     MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg32$(VERSION_NUMBER),$(DEPTH)/media/libjpeg)'
2518     MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,png,$(DEPTH)/media/libpng)'
2519     AC_DEFINE(HAVE_SNPRINTF)
2520     AC_DEFINE(_WINDOWS)
2521     AC_DEFINE(WIN32)
2522     AC_DEFINE(XP_WIN)
2523     AC_DEFINE(XP_WIN32)
2524     AC_DEFINE(HW_THREADS)
2525     AC_DEFINE(STDC_HEADERS)
2526     AC_DEFINE(NEW_H, <new>)
2527     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2528     TARGET_MD_ARCH=win32
2529     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2530     BIN_SUFFIX='.exe'
2531     MOZ_USER_DIR="Mozilla"
2533     dnl Hardcode to win95 for now - cls
2534     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2536     dnl set NO_X11 defines here as the general check is skipped on win32
2537     no_x=yes
2538     AC_DEFINE(NO_X11)
2540     case "$host" in
2541     *-mingw*)
2542         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2543         L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2544         ;;
2545     esac
2547     case "$host" in
2548     *-mingw*)
2549         if test -z "$MOZ_TOOLS"; then
2550             AC_MSG_ERROR([MOZ_TOOLS is not set])
2551         fi
2552         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2553         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2554             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2555         fi
2556         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2557         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2558             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2559         fi
2560         ;;
2561     esac
2563     case "$host_os" in
2564     cygwin*|msvc*|mks*)
2565         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.])
2566         ;;
2567     esac
2569     case "$target" in
2570     i*86-*)
2571         if test "$HAVE_64BIT_OS"; then
2572             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2573         fi
2575         if test $_MSC_VER -ge 1400; then
2576             LDFLAGS="$LDFLAGS -SAFESEH"
2577         fi
2579         if test -n "$GNU_CC"; then
2580             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2581             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2582         else
2583             AC_DEFINE(HAVE_STDCALL)
2584             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2585         fi
2587         MOZ_CHECK_HEADERS(mmintrin.h)
2588         AC_DEFINE(_X86_)
2589         ;;
2590     x86_64-*)
2591         if test -n "$_WIN32_MSVC"; then
2592             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2593         fi
2594         AC_DEFINE(_AMD64_)
2595         ;;
2596     *)
2597         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2598         ;;
2599     esac
2601     if test "$HAVE_64BIT_OS"; then
2602         AC_DEFINE(_WIN64)
2603     fi
2604     ;;
2606 *-netbsd*)
2607     DSO_CFLAGS=''
2608     CFLAGS="$CFLAGS -Dunix"
2609     CXXFLAGS="$CXXFLAGS -Dunix"
2610     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2611         DLL_SUFFIX=".so"
2612         DSO_PIC_CFLAGS='-fPIC -DPIC'
2613         DSO_LDOPTS='-shared'
2614         BIN_FLAGS='-Wl,--export-dynamic'
2615     else
2616         DSO_PIC_CFLAGS='-fPIC -DPIC'
2617         DLL_SUFFIX=".so.1.0"
2618         DSO_LDOPTS='-shared'
2619     fi
2620     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2621     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2622     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2623     if test "$LIBRUNPATH"; then
2624         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2625     fi
2626     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2627     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2628     ;;
2630 *-openbsd*)
2631     if test "$SO_VERSION"; then
2632         DLL_SUFFIX=".so.$SO_VERSION"
2633     else
2634         DLL_SUFFIX=".so.1.0"
2635     fi
2636     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2637     DSO_CFLAGS=''
2638     DSO_PIC_CFLAGS='-fPIC'
2639     DSO_LDOPTS='-shared -fPIC'
2640     if test "$LIBRUNPATH"; then
2641         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2642     fi
2643     ;;
2645 *-os2*)
2646     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2647     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2648     AC_DEFINE(OS2)
2649     AC_DEFINE(XP_OS2)
2650     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2651     AC_DEFINE(TCPV40HDRS)
2652     DLL_PREFIX=
2653     LIB_PREFIX=
2654     LIB_SUFFIX=lib
2655     BIN_SUFFIX=".exe"
2656     DLL_SUFFIX=".dll"
2657     IMPORT_LIB_SUFFIX=lib
2658     DSO_PIC_CFLAGS=
2659     AR=emxomfar
2660     AR_FLAGS='r $@'
2661     CFLAGS="$CFLAGS -Zomf"
2662     CXXFLAGS="$CXXFLAGS -Zomf"
2663     DSO_LDOPTS='-Zdll'
2664     BIN_FLAGS='-Zlinker /ST:0x100000'
2665     IMPLIB='emximp -o'
2666     FILTER='true'
2667     LDFLAGS='-Zmap'
2668     WARNINGS_AS_ERRORS='-Werror'
2669     MOZ_DEBUG_FLAGS="-g -fno-inline"
2670     MOZ_OPTIMIZE_FLAGS="-O2"
2671     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2672     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2673     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2674     TARGET_MD_ARCH=os2
2675     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2676     RC=rc.exe
2677     MC=mc.exe
2678     RCFLAGS='-n'
2679     MOZ_USER_DIR="Mozilla"
2680     ZIP="$ZIP -X"
2682     if test "$MOZTOOLS"; then
2683         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2684     else
2685         AC_MSG_ERROR([MOZTOOLS is not set])
2686     fi
2687     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2688         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2689         LDFLAGS="$LDFLAGS -Zhigh-mem"
2690         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2691         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2692     fi
2694     # GCC for OS/2 currently predefines these, but we don't want them
2695     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2696     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2698     AC_CACHE_CHECK(for __declspec(dllexport),
2699         ac_os2_declspec,
2700         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2701                         [return 0;],
2702                         ac_os2_declspec="yes",
2703                         ac_os2_declspec="no")])
2704     if test "$ac_os2_declspec" != "yes"; then
2705         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2706     fi
2707     ;;
2709 *-solaris*)
2710     AC_DEFINE(SOLARIS)
2711     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2712     SYSTEM_MAKEDEPEND=
2713     MOZ_FIX_LINK_PATHS=
2714     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2715     # libraries one level up (e.g. libnspr4.so)
2716     if test "$SOLARIS_SUNPRO_CC"; then
2717        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2718        LIBS="-lCrun -lCstd -lc $LIBS"
2719        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2720        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2721        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2722        LDFLAGS="-xildoff $LDFLAGS"
2723        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2724            _SAVE_LDFLAGS=$LDFLAGS
2725            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2726            AC_TRY_LINK([#include <stdio.h>],
2727                        [printf("Hello World\n");],
2728                        ,
2729                        [LDFLAGS=$_SAVE_LDFLAGS])
2730        fi
2731        MOZ_OPTIMIZE_FLAGS="-xO4"
2732        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2733        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2734        MKSHLIB_FORCE_ALL='-z allextract'
2735        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2736        DSO_LDOPTS='-G'
2737        AR_LIST="$AR t"
2738        AR_EXTRACT="$AR x"
2739        AR_DELETE="$AR d"
2740        AR='$(CXX) -xar'
2741        AR_FLAGS='-o $@'
2742        AS='/usr/ccs/bin/as'
2743        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2744        AS_DASH_C_FLAG=''
2745        TARGET_COMPILER_ABI="sunc"
2746        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2747        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2748        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2749        AC_LANG_SAVE
2750        AC_LANG_CPLUSPLUS
2751        AC_TRY_COMPILE([],
2752            [#if (__SUNPRO_CC < 0x590)
2753            #error "Denied"
2754            #endif],
2755            _BAD_COMPILER=,_BAD_COMPILER=1)
2756        if test -n "$_BAD_COMPILER"; then
2757            _res="no"
2758            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2759        else
2760            _res="yes"
2761        fi
2762        AC_TRY_COMPILE([],
2763            [#if (__SUNPRO_CC >= 0x5100)
2764            #error "Sun C++ 5.10 or above"
2765            #endif],
2766            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2767        if test "$_ABOVE_SS12U1"; then
2768            # disable xannotate
2769            CXXFLAGS="$CXXFLAGS -xannotate=no"
2770        fi
2771        AC_MSG_RESULT([$_res])
2772        AC_LANG_RESTORE
2773     else
2774        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2775        LIBS="-lc $LIBS"
2776        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2777        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2778        ASFLAGS="$ASFLAGS -fPIC"
2779        DSO_LDOPTS='-shared'
2780        WARNINGS_AS_ERRORS='-Werror'
2781        _WARNINGS_CFLAGS=''
2782        _WARNINGS_CXXFLAGS=''
2783        if test "$OS_RELEASE" = "5.3"; then
2784            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2785        fi
2786     fi
2787     if test "$OS_RELEASE" = "5.5.1"; then
2788         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2789     fi
2790     ;;
2792 *-sunos*)
2793     DSO_LDOPTS='-Bdynamic'
2794     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2795     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2796     AC_DEFINE(SUNOS4)
2797     AC_DEFINE(SPRINTF_RETURNS_STRING)
2798     case "$(target_os)" in
2799     sunos4.1*)
2800         DLL_SUFFIX='.so.1.0'
2801         ;;
2802     esac
2803     ;;
2805 *-os2*)
2806     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2807     ;;
2809 esac
2811 AC_SUBST(MOZ_LINKER)
2812 if test -n "$MOZ_LINKER"; then
2813   AC_DEFINE(MOZ_LINKER)
2815 AC_SUBST(MOZ_ENABLE_SZIP)
2817 dnl Only one oddball right now (QNX), but this gives us flexibility
2818 dnl if any other platforms need to override this in the future.
2819 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2821 dnl ========================================================
2822 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2823 dnl by now will not have any way to link most binaries (tests
2824 dnl as well as viewer, apprunner, etc.), because some symbols
2825 dnl will be left out of the "composite" .so's by ld as unneeded.
2826 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2827 dnl they can link in the static libs that provide the missing
2828 dnl symbols.
2829 dnl ========================================================
2830 NO_LD_ARCHIVE_FLAGS=
2831 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2832     NO_LD_ARCHIVE_FLAGS=1
2834 case "$target" in
2835 *-os2*)
2836     NO_LD_ARCHIVE_FLAGS=
2837     ;;
2838 *-aix4.3*|*-aix5*)
2839     NO_LD_ARCHIVE_FLAGS=
2840     ;;
2841 *-mingw*)
2842     if test -z "$GNU_CC"; then
2843         NO_LD_ARCHIVE_FLAGS=
2844     fi
2845     ;;
2846 esac
2847 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2849 dnl ========================================================
2850 dnl = Flags to strip unused symbols from .so components and
2851 dnl = to export jemalloc symbols when linking a program
2852 dnl ========================================================
2853 case "$target" in
2854     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2855         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2856         ;;
2857     *-solaris*)
2858         if test -z "$GNU_CC"; then
2859          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2860         else
2861          if test -z "$GCC_USE_GNU_LD"; then
2862           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2863          else
2864           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2865          fi
2866         fi
2867         ;;
2868     *-darwin*)
2869         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2870         ;;
2871     *-mingw*)
2872         if test -n "$GNU_CC"; then
2873            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2874         fi
2875         ;;
2876 esac
2878 if test -z "$COMPILE_ENVIRONMENT"; then
2879     SKIP_COMPILER_CHECKS=1
2880     SKIP_LIBRARY_CHECKS=1
2883 if test -z "$SKIP_COMPILER_CHECKS"; then
2884 dnl Checks for typedefs, structures, and compiler characteristics.
2885 dnl ========================================================
2886 AC_HEADER_STDC
2887 AC_C_CONST
2888 AC_TYPE_MODE_T
2889 AC_TYPE_OFF_T
2890 AC_TYPE_PID_T
2891 AC_TYPE_SIZE_T
2892 AC_LANG_CPLUSPLUS
2893 AC_MSG_CHECKING(for __stdcall)
2894 AC_CACHE_VAL(ac_cv___stdcall,
2895  [AC_TRY_COMPILE([template <typename Method> struct foo;
2896                   template <> struct foo<void (*)()> {};
2897                   template <> struct foo<void (__stdcall*)()> {};],
2898                  [],
2899                  [ac_cv___stdcall=true],
2900                  [ac_cv___stdcall=false])])
2901 if test "$ac_cv___stdcall" = true ; then
2902   AC_DEFINE(HAVE_STDCALL)
2903   AC_MSG_RESULT(yes)
2904 else
2905   AC_MSG_RESULT(no)
2907 AC_LANG_C
2908 AC_MSG_CHECKING(for ssize_t)
2909 AC_CACHE_VAL(ac_cv_type_ssize_t,
2910  [AC_TRY_COMPILE([#include <stdio.h>
2911                   #include <sys/types.h>],
2912                  [ssize_t foo = 0;],
2913                  [ac_cv_type_ssize_t=true],
2914                  [ac_cv_type_ssize_t=false])])
2915 if test "$ac_cv_type_ssize_t" = true ; then
2916   AC_DEFINE(HAVE_SSIZE_T)
2917   AC_MSG_RESULT(yes)
2918 else
2919   AC_MSG_RESULT(no)
2921 AC_STRUCT_ST_BLKSIZE
2922 AC_MSG_CHECKING(for siginfo_t)
2923 AC_CACHE_VAL(ac_cv_siginfo_t,
2924  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2925                   #include <signal.h>],
2926                  [siginfo_t* info;],
2927                  [ac_cv_siginfo_t=true],
2928                  [ac_cv_siginfo_t=false])])
2929 if test "$ac_cv_siginfo_t" = true ; then
2930   AC_DEFINE(HAVE_SIGINFO_T)
2931   AC_MSG_RESULT(yes)
2932 else
2933   AC_MSG_RESULT(no)
2936 dnl Check for int64, uint, and uint_t.
2937 dnl ========================================================
2938 AC_MSG_CHECKING(for int64)
2939 AC_CACHE_VAL(ac_cv_int64,
2940  [AC_TRY_COMPILE([#include <stdio.h>
2941                   #include <sys/types.h>],
2942                  [int64 foo = 0;],
2943                  [ac_cv_int64=true],
2944                  [ac_cv_int64=false])])
2945 if test "$ac_cv_int64" = true ; then
2946   AC_DEFINE(HAVE_INT64)
2947   AC_MSG_RESULT(yes)
2948 else
2949   AC_MSG_RESULT(no)
2951 AC_MSG_CHECKING(for uint)
2952 AC_CACHE_VAL(ac_cv_uint,
2953  [AC_TRY_COMPILE([#include <stdio.h>
2954                   #include <sys/types.h>],
2955                  [uint foo = 0;],
2956                  [ac_cv_uint=true],
2957                  [ac_cv_uint=false])])
2958 if test "$ac_cv_uint" = true ; then
2959   AC_DEFINE(HAVE_UINT)
2960   AC_MSG_RESULT(yes)
2961 else
2962   AC_MSG_RESULT(no)
2964 AC_MSG_CHECKING(for uint_t)
2965 AC_CACHE_VAL(ac_cv_uint_t,
2966  [AC_TRY_COMPILE([#include <stdio.h>
2967                   #include <sys/types.h>],
2968                  [uint_t foo = 0;],
2969                  [ac_cv_uint_t=true],
2970                  [ac_cv_uint_t=false])])
2971 if test "$ac_cv_uint_t" = true ; then
2972   AC_DEFINE(HAVE_UINT_T)
2973   AC_MSG_RESULT(yes)
2974 else
2975   AC_MSG_RESULT(no)
2978 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
2979 dnl are defined when compiling C++ but not C.  Since the result of this
2980 dnl test is used only in C++, do it in C++.
2981 AC_LANG_CPLUSPLUS
2983 AC_MSG_CHECKING(for uname.domainname)
2984 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
2985     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2986         [ struct utsname *res; char *domain;
2987             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
2988         [ac_cv_have_uname_domainname_field=true],
2989         [ac_cv_have_uname_domainname_field=false])])
2991 if test "$ac_cv_have_uname_domainname_field" = "true"; then
2992     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
2993     AC_MSG_RESULT(yes)
2994 else
2995     AC_MSG_RESULT(no)
2998 AC_MSG_CHECKING(for uname.__domainname)
2999 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
3000     [AC_TRY_COMPILE([#include <sys/utsname.h>],
3001         [ struct utsname *res; char *domain;
3002             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
3003         [ac_cv_have_uname_us_domainname_field=true],
3004         [ac_cv_have_uname_us_domainname_field=false])])
3006 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
3007     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
3008     AC_MSG_RESULT(yes)
3009 else
3010     AC_MSG_RESULT(no)
3013 dnl ========================================================
3014 dnl C++ rtti
3015 dnl Should be smarter and check that the compiler does indeed have rtti
3016 dnl ========================================================
3018 MOZ_ARG_ENABLE_BOOL(cpp-rtti,
3019 [  --enable-cpp-rtti       Enable C++ RTTI ],
3020 [ _MOZ_USE_RTTI=1 ],
3021 [ _MOZ_USE_RTTI= ])
3023 if test "$_MOZ_USE_RTTI"; then
3024    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_ON
3025 else
3026    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_OFF
3029 AC_SUBST(_MOZ_RTTI_FLAGS_ON)
3031 dnl Check whether we can use gcc's c++0x mode
3032 AC_LANG_CPLUSPLUS
3034 if test "$GNU_CXX"; then
3035     _SAVE_CXXFLAGS=$CXXFLAGS
3036     CXXFLAGS="$CXXFLAGS -std=gnu++0x"
3038     if test -z "$_MOZ_USE_RTTI"; then
3039         CXXFLAGS="$CXXFLAGS $_MOZ_RTTI_FLAGS"
3040         AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
3041             ac_cv_cxx0x_headers_bug,
3042             [AC_TRY_COMPILE([#include <memory>], [],
3043                             ac_cv_cxx0x_headers_bug="no",
3044                             ac_cv_cxx0x_headers_bug="yes")])
3045         CXXFLAGS="$_SAVE_CXXFLAGS"
3046         if test "$ac_cv_cxx0x_headers_bug" = "no"; then
3047             CXXFLAGS="$CXXFLAGS -std=gnu++0x"
3048         fi
3049     fi
3052 dnl Check for usable char16_t (2 bytes, unsigned)
3053 dnl (we might not need the unsignedness check anymore)
3054 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
3055     ac_cv_have_usable_char16_t,
3056     [AC_TRY_COMPILE([$configure_static_assert_macros],
3057                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
3058                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
3059                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
3060                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
3061                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
3062                     ac_cv_have_usable_char16_t="yes",
3063                     ac_cv_have_usable_char16_t="no")])
3064 if test "$ac_cv_have_usable_char16_t" = "yes"; then
3065     AC_DEFINE(HAVE_CPP_CHAR16_T)
3066     HAVE_CPP_CHAR16_T=1
3067 elif test "$GNU_CXX"; then
3068     CXXFLAGS="$_SAVE_CXXFLAGS"
3071 dnl Check for usable wchar_t (2 bytes, unsigned)
3072 dnl (we really don't need the unsignedness check anymore)
3073 dnl ========================================================
3075 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
3076     ac_cv_have_usable_wchar_v2,
3077     [AC_TRY_COMPILE([#include <stddef.h>
3078                      $configure_static_assert_macros],
3079                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
3080                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
3081                     ac_cv_have_usable_wchar_v2="yes",
3082                     ac_cv_have_usable_wchar_v2="no")])
3083 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
3084     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
3085     HAVE_CPP_2BYTE_WCHAR_T=1
3086 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
3087 dnl This is really gcc-only
3088 dnl Do this test using CXX only since some versions of gcc
3089 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
3090 dnl only have short-wchar support for c++.
3091 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
3093     _SAVE_CXXFLAGS=$CXXFLAGS
3094     CXXFLAGS="$CXXFLAGS -fshort-wchar"
3096     AC_CACHE_CHECK(for compiler -fshort-wchar option,
3097         ac_cv_have_usable_wchar_option_v2,
3098         [AC_TRY_LINK([#include <stddef.h>
3099                       $configure_static_assert_macros],
3100                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
3101                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
3102                      ac_cv_have_usable_wchar_option_v2="yes",
3103                      ac_cv_have_usable_wchar_option_v2="no")])
3105     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
3106         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
3107         HAVE_CPP_2BYTE_WCHAR_T=1
3108         if test "$OS_TARGET" = Android; then
3109             WCHAR_CFLAGS="-fshort-wchar -Wl,--no-wchar-size-warning"
3110             CXXFLAGS="$CXXFLAGS -Wl,--no-wchar-size-warning"
3111             CFLAGS="$CFLAGS -Wl,--no-wchar-size-warning"
3112             DSO_LDOPTS="$DSO_LDOPTS -Wl,--no-wchar-size-warning"
3113         else
3114             WCHAR_CFLAGS="-fshort-wchar"
3115         fi
3116     else
3117         CXXFLAGS=$_SAVE_CXXFLAGS
3118     fi
3121 AC_LANG_C
3123 dnl Check for .hidden assembler directive and visibility attribute.
3124 dnl Borrowed from glibc configure.in
3125 dnl ===============================================================
3126 if test "$GNU_CC"; then
3127   AC_CACHE_CHECK(for visibility(hidden) attribute,
3128                  ac_cv_visibility_hidden,
3129                  [cat > conftest.c <<EOF
3130                   int foo __attribute__ ((visibility ("hidden"))) = 1;
3132                   ac_cv_visibility_hidden=no
3133                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3134                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3135                       ac_cv_visibility_hidden=yes
3136                     fi
3137                   fi
3138                   rm -f conftest.[cs]
3139                  ])
3140   if test "$ac_cv_visibility_hidden" = "yes"; then
3141     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
3143     AC_CACHE_CHECK(for visibility(default) attribute,
3144                    ac_cv_visibility_default,
3145                    [cat > conftest.c <<EOF
3146                     int foo __attribute__ ((visibility ("default"))) = 1;
3148                     ac_cv_visibility_default=no
3149                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3150                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3151                         ac_cv_visibility_default=yes
3152                       fi
3153                     fi
3154                     rm -f conftest.[cs]
3155                    ])
3156     if test "$ac_cv_visibility_default" = "yes"; then
3157       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
3159       AC_CACHE_CHECK(for visibility pragma support,
3160                      ac_cv_visibility_pragma,
3161                      [cat > conftest.c <<EOF
3162 #pragma GCC visibility push(hidden)
3163                       int foo_hidden = 1;
3164 #pragma GCC visibility push(default)
3165                       int foo_default = 1;
3167                       ac_cv_visibility_pragma=no
3168                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3169                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
3170                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
3171                             ac_cv_visibility_pragma=yes
3172                           fi
3173                         fi
3174                       fi
3175                       rm -f conftest.[cs]
3176                     ])
3177       if test "$ac_cv_visibility_pragma" = "yes"; then
3178         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
3179                        ac_cv_have_visibility_class_bug,
3180                        [cat > conftest.c <<EOF
3181 #pragma GCC visibility push(hidden)
3182 struct __attribute__ ((visibility ("default"))) TestStruct {
3183   static void Init();
3185 __attribute__ ((visibility ("default"))) void TestFunc() {
3186   TestStruct::Init();
3189                        ac_cv_have_visibility_class_bug=no
3190                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3191                          ac_cv_have_visibility_class_bug=yes
3192                        else
3193                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
3194                            ac_cv_have_visibility_class_bug=yes
3195                          fi
3196                        fi
3197                        rm -rf conftest.{c,S}
3198                        ])
3200         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
3201                        ac_cv_have_visibility_builtin_bug,
3202                        [cat > conftest.c <<EOF
3203 #pragma GCC visibility push(hidden)
3204 #pragma GCC visibility push(default)
3205 #include <string.h>
3206 #pragma GCC visibility pop
3208 __attribute__ ((visibility ("default"))) void Func() {
3209   char c[[100]];
3210   memset(c, 0, sizeof(c));
3213                        ac_cv_have_visibility_builtin_bug=no
3214                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3215                          ac_cv_have_visibility_builtin_bug=yes
3216                        else
3217                          if test `grep -c "@PLT" conftest.S` = 0; then
3218                            ac_cv_visibility_builtin_bug=yes
3219                          fi
3220                        fi
3221                        rm -f conftest.{c,S}
3222                        ])
3223         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
3224                 "$ac_cv_have_visibility_class_bug" = "no"; then
3225           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
3226           WRAP_SYSTEM_INCLUDES=1
3227           STL_FLAGS='-I$(DIST)/stl_wrappers'
3228           WRAP_STL_INCLUDES=1
3229         else
3230           VISIBILITY_FLAGS='-fvisibility=hidden'
3231         fi # have visibility pragma bug
3232       fi   # have visibility pragma
3233     fi     # have visibility(default) attribute
3234   fi       # have visibility(hidden) attribute
3235 fi         # GNU_CC
3237 # visibility hidden flag for Sun Studio on Solaris
3238 if test "$SOLARIS_SUNPRO_CC"; then
3239 VISIBILITY_FLAGS='-xldscope=hidden'
3240 fi         # Sun Studio on Solaris
3242 AC_SUBST(WRAP_SYSTEM_INCLUDES)
3243 AC_SUBST(VISIBILITY_FLAGS)
3245 MOZ_GCC_PR49911
3246 MOZ_COMPILER_OPTS
3248 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
3249 dnl ========================================================
3250 if test "$GNU_CC"; then
3251   CFLAGS_save="${CFLAGS}"
3252   CFLAGS="${CFLAGS} -Werror"
3253   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
3254                  ac_cv_force_align_arg_pointer,
3255                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
3256                                  [],
3257                                  ac_cv_force_align_arg_pointer="yes",
3258                                  ac_cv_force_align_arg_pointer="no")])
3259   CFLAGS="${CFLAGS_save}"
3260   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
3261     HAVE_GCC_ALIGN_ARG_POINTER=1
3262   else
3263     HAVE_GCC_ALIGN_ARG_POINTER=
3264   fi
3266 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
3268 dnl Checks for header files.
3269 dnl ========================================================
3270 AC_HEADER_DIRENT
3271 case "$target_os" in
3272 freebsd*|openbsd*)
3273 # for stuff like -lXshm
3274     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
3275     ;;
3276 esac
3277 MOZ_CHECK_COMMON_HEADERS
3279 dnl These are all the places some variant of statfs can be hiding.
3280 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
3282 dnl Quota support
3283 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
3284 MOZ_CHECK_HEADERS(linux/quota.h)
3286 dnl Try for MMX support
3287 dnl NB - later gcc versions require -mmmx for this header to be successfully
3288 dnl included (or another option which implies it, such as -march=pentium-mmx)
3289 MOZ_CHECK_HEADERS(mmintrin.h)
3291 dnl Check whether the compiler supports the new-style C++ standard
3292 dnl library headers (i.e. <new>) or needs the old "new.h"
3293 AC_LANG_CPLUSPLUS
3294 NEW_H=new.h
3295 MOZ_CHECK_HEADER(new, [NEW_H=new])
3296 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3297 AC_LANG_C
3299 AC_ARG_ENABLE(dtrace,
3300               [  --enable-dtrace         build with dtrace support if available (default=no)],
3301               [enable_dtrace="yes"],)
3302 if test "x$enable_dtrace" = "xyes"; then
3303   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3304   if test -n "$HAVE_DTRACE"; then
3305       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3306   else
3307       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3308   fi
3310 AC_SUBST(HAVE_DTRACE)
3312 case $target in
3313 *-aix4.3*|*-aix5*)
3314         ;;
3316         MOZ_CHECK_HEADERS(sys/cdefs.h)
3317         ;;
3318 esac
3320 dnl Checks for libraries.
3321 dnl ========================================================
3322 case $target in
3323 *-hpux11.*)
3324         ;;
3326         AC_CHECK_LIB(c_r, gethostbyname_r)
3327         ;;
3328 esac
3330 dnl We don't want to link with libdl even if it's present on OS X, since
3331 dnl it's not used and not part of the default installation. OS/2 has dlfcn
3332 dnl in libc.
3333 dnl We don't want to link against libm or libpthread on Darwin since
3334 dnl they both are just symlinks to libSystem and explicitly linking
3335 dnl against libSystem causes issues when debugging (see bug 299601).
3336 case $target in
3337 *-darwin*)
3338     ;;
3339 *-os2*)
3340     ;;
3342     AC_SEARCH_LIBS(dlopen, dl,
3343         MOZ_CHECK_HEADER(dlfcn.h,
3344         AC_DEFINE(HAVE_DLOPEN)))
3345     ;;
3346 esac
3348 _SAVE_CFLAGS="$CFLAGS"
3349 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3350 AC_CHECK_FUNCS(dladdr memmem)
3351 CFLAGS="$_SAVE_CFLAGS"
3353 if test ! "$GNU_CXX"; then
3355     case $target in
3356     *-aix*)
3357         AC_CHECK_LIB(C_r, demangle)
3358         ;;
3359      *)
3360         AC_CHECK_LIB(C, demangle)
3361         ;;
3362      esac
3365 dnl OS/2 has socket in libc.
3366 case $target in
3367 *-os2*)
3368     ;;
3370     AC_CHECK_LIB(socket, socket)
3371 esac
3373 XLDFLAGS="$X_LIBS"
3374 XLIBS="$X_EXTRA_LIBS"
3376 dnl ========================================================
3377 dnl Checks for X libraries.
3378 dnl Ordering is important.
3379 dnl Xt is dependent upon SM as of X11R6
3380 dnl ========================================================
3381 if test "$no_x" = "yes"; then
3382     AC_DEFINE(NO_X11)
3383 else
3384     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3385         XLIBS="-lX11 $XLIBS"
3386         _SAVE_LDFLAGS="$LDFLAGS"
3387         LDFLAGS="$XLDFLAGS $LDFLAGS"
3388         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3389                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3390         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3391                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3393         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3394         unset ac_cv_lib_Xt_XtFree
3395             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3396             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
3397         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3398                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3399         ])
3401     # AIX needs the motif library linked before libXt to prevent
3402     # crashes in plugins linked against Motif - Bug #98892
3403     case "${target_os}" in
3404     aix*)
3405         XT_LIBS="-lXm $XT_LIBS"
3406         ;;
3407     esac
3409     dnl ========================================================
3410     dnl = Check for XShm
3411     dnl ========================================================
3412     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3413         $XLIBS $XEXT_LIBS)
3415     dnl ========================================================
3416     dnl = Check for Xss
3417     dnl ========================================================
3418     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
3419         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
3420             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
3421              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
3423         LDFLAGS="$_SAVE_LDFLAGS"
3425     dnl ========================================================
3426     dnl = Check for freetype2 and its functionality
3427     dnl ========================================================
3428     PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
3430     if test "$_HAVE_FREETYPE2"; then
3431         _SAVE_LIBS="$LIBS"
3432         _SAVE_CFLAGS="$CFLAGS"
3433         LIBS="$LIBS $FT2_LIBS"
3434         CFLAGS="$CFLAGS $FT2_CFLAGS"
3436         AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
3437             ac_cv_member_FT_Bitmap_Size_y_ppem,
3438             [AC_TRY_COMPILE([#include <ft2build.h>
3439                              #include FT_FREETYPE_H],
3440                             [FT_Bitmap_Size s;
3441                              if (sizeof s.y_ppem) return 0;
3442                              return 1],
3443                             ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
3444                             ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
3445         if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
3446             HAVE_FT_BITMAP_SIZE_Y_PPEM=1
3447         else
3448             HAVE_FT_BITMAP_SIZE_Y_PPEM=0
3449         fi
3450         AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
3451                            $HAVE_FT_BITMAP_SIZE_Y_PPEM,
3452                            [FT_Bitmap_Size structure includes y_ppem field])
3454         AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
3456         LIBS="$_SAVE_LIBS"
3457         CFLAGS="$_SAVE_CFLAGS"
3458     fi
3460 fi # $no_x
3462 AC_SUBST(XCFLAGS)
3463 AC_SUBST(XLDFLAGS)
3464 AC_SUBST(XLIBS)
3465 AC_SUBST(XEXT_LIBS)
3466 AC_SUBST(XT_LIBS)
3467 AC_SUBST(XSS_LIBS)
3469 dnl ========================================================
3470 dnl = pthread support
3471 dnl = Start by checking whether the system support pthreads
3472 dnl ========================================================
3473 case "$target_os" in
3474 darwin*)
3475     USE_PTHREADS=1
3476     ;;
3478     MOZ_CHECK_PTHREADS(pthreads,
3479         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3480         MOZ_CHECK_PTHREADS(pthread,
3481             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3482             MOZ_CHECK_PTHREADS(c_r,
3483                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3484                 MOZ_CHECK_PTHREADS(c,
3485                     USE_PTHREADS=1
3486                 )
3487             )
3488         )
3489     )
3490     ;;
3491 esac
3493 dnl ========================================================
3494 dnl Check the command line for --with-pthreads
3495 dnl ========================================================
3496 MOZ_ARG_WITH_BOOL(pthreads,
3497 [  --with-pthreads         Force use of system pthread library with NSPR ],
3498 [ if test "$USE_PTHREADS"x = x; then
3499     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3500 fi],
3501     USE_PTHREADS=
3502     _PTHREAD_LDFLAGS=
3505 dnl ========================================================
3506 dnl Do the platform specific pthread hackery
3507 dnl ========================================================
3508 if test "$USE_PTHREADS"x != x
3509 then
3510         dnl
3511         dnl See if -pthread is supported.
3512         dnl
3513         rm -f conftest*
3514         ac_cv_have_dash_pthread=no
3515         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3516         echo 'int main() { return 0; }' | cat > conftest.c
3517         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3518         if test $? -eq 0; then
3519                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3520                         ac_cv_have_dash_pthread=yes
3521                 case "$target_os" in
3522                 freebsd*)
3523 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3524                 ;;
3525                 *)
3526                             CFLAGS="$CFLAGS -pthread"
3527                             CXXFLAGS="$CXXFLAGS -pthread"
3528                 ;;
3529                 esac
3530                 fi
3531         fi
3532         rm -f conftest*
3533     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3535         dnl
3536         dnl See if -pthreads is supported.
3537         dnl
3538     ac_cv_have_dash_pthreads=no
3539     if test "$ac_cv_have_dash_pthread" = "no"; then
3540             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3541         echo 'int main() { return 0; }' | cat > conftest.c
3542             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3543         if test $? -eq 0; then
3544                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3545                             ac_cv_have_dash_pthreads=yes
3546                             CFLAGS="$CFLAGS -pthreads"
3547                             CXXFLAGS="$CXXFLAGS -pthreads"
3548                     fi
3549             fi
3550             rm -f conftest*
3551         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3552     fi
3554         case "$target" in
3555             *-*-freebsd*)
3556                         AC_DEFINE(_REENTRANT)
3557                         AC_DEFINE(_THREAD_SAFE)
3558                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3559                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3560                                 _PTHREAD_LDFLAGS="-pthread"
3561                         else
3562                                 _PTHREAD_LDFLAGS="-lc_r"
3563                         fi
3564                         ;;
3566             *-*-openbsd*|*-*-bsdi*)
3567                         AC_DEFINE(_REENTRANT)
3568                         AC_DEFINE(_THREAD_SAFE)
3569                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3570                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3571                 _PTHREAD_LDFLAGS="-pthread"
3572                         fi
3573                         ;;
3575             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3576                         AC_DEFINE(_REENTRANT)
3577                         ;;
3579             *-aix4.3*|*-aix5*)
3580                         AC_DEFINE(_REENTRANT)
3581                         ;;
3583             *-hpux11.*)
3584                         AC_DEFINE(_REENTRANT)
3585                         ;;
3587             *-*-solaris*)
3588                         AC_DEFINE(_REENTRANT)
3589                         if test "$SOLARIS_SUNPRO_CC"; then
3590                                 CFLAGS="$CFLAGS -mt"
3591                                 CXXFLAGS="$CXXFLAGS -mt"
3592                         fi
3593                         ;;
3594         esac
3595     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3599 dnl Checks for library functions.
3600 dnl ========================================================
3601 AC_PROG_GCC_TRADITIONAL
3602 AC_FUNC_MEMCMP
3603 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf statvfs memmove rint stat64 lstat64 truncate64 statvfs64 setbuf isatty)
3604 AC_CHECK_FUNCS(flockfile getpagesize)
3605 AC_CHECK_FUNCS(localtime_r strtok_r)
3607 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3608 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3609                ac_cv_clock_monotonic,
3610                [for libs in "" -lrt; do
3611                     _SAVE_LDFLAGS="$LDFLAGS"
3612                     LDFLAGS="$LDFLAGS $libs"
3613                     AC_TRY_LINK([#include <time.h>],
3614                                  [ struct timespec ts;
3615                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3616                                  ac_cv_clock_monotonic=$libs
3617                                  break,
3618                                  ac_cv_clock_monotonic=no)
3619                     LDFLAGS="$_SAVE_LDFLAGS"
3620                 done])
3621 if test "$ac_cv_clock_monotonic" != "no"; then
3622     HAVE_CLOCK_MONOTONIC=1
3623     REALTIME_LIBS=$ac_cv_clock_monotonic
3624     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3625     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3626     AC_SUBST(REALTIME_LIBS)
3629 dnl check for wcrtomb/mbrtowc
3630 dnl =======================================================================
3631 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3632 AC_LANG_SAVE
3633 AC_LANG_CPLUSPLUS
3634 AC_CACHE_CHECK(for wcrtomb,
3635     ac_cv_have_wcrtomb,
3636     [AC_TRY_LINK([#include <wchar.h>],
3637                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3638                  ac_cv_have_wcrtomb="yes",
3639                  ac_cv_have_wcrtomb="no")])
3640 if test "$ac_cv_have_wcrtomb" = "yes"; then
3641     AC_DEFINE(HAVE_WCRTOMB)
3643 AC_CACHE_CHECK(for mbrtowc,
3644     ac_cv_have_mbrtowc,
3645     [AC_TRY_LINK([#include <wchar.h>],
3646                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3647                  ac_cv_have_mbrtowc="yes",
3648                  ac_cv_have_mbrtowc="no")])
3649 if test "$ac_cv_have_mbrtowc" = "yes"; then
3650     AC_DEFINE(HAVE_MBRTOWC)
3652 AC_LANG_RESTORE
3655 AC_CACHE_CHECK(
3656     [for res_ninit()],
3657     ac_cv_func_res_ninit,
3658     [AC_TRY_LINK([
3659         #ifdef linux
3660         #define _BSD_SOURCE 1
3661         #endif
3662         #include <resolv.h>
3663         ],
3664         [int foo = res_ninit(&_res);],
3665         [ac_cv_func_res_ninit=yes],
3666         [ac_cv_func_res_ninit=no])
3667     ])
3669 if test "$ac_cv_func_res_ninit" = "yes"; then
3670     AC_DEFINE(HAVE_RES_NINIT)
3671 dnl must add the link line we do something as foolish as this... dougt
3672 dnl else
3673 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3674 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3677 AC_LANG_CPLUSPLUS
3678 AC_CACHE_CHECK(
3679     [for gnu_get_libc_version()],
3680     ac_cv_func_gnu_get_libc_version,
3681     [AC_TRY_LINK([
3682         #ifdef HAVE_GNU_LIBC_VERSION_H
3683         #include <gnu/libc-version.h>
3684         #endif
3685         ],
3686         [const char *glibc_version = gnu_get_libc_version();],
3687         [ac_cv_func_gnu_get_libc_version=yes],
3688         [ac_cv_func_gnu_get_libc_version=no]
3689         )]
3690     )
3692 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3693     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3696 case $target_os in
3697     darwin*|mingw*|os2*)
3698         ;;
3699     *)
3701 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3702     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3703         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3704 _SAVE_LIBS=$LIBS
3705 LIBS="$LIBS $_ICONV_LIBS"
3706 AC_CACHE_CHECK(
3707     [for iconv()],
3708     ac_cv_func_iconv,
3709     [AC_TRY_LINK([
3710         #include <stdlib.h>
3711         #include <iconv.h>
3712         ],
3713         [
3714             iconv_t h = iconv_open("", "");
3715             iconv(h, NULL, NULL, NULL, NULL);
3716             iconv_close(h);
3717         ],
3718         [ac_cv_func_iconv=yes],
3719         [ac_cv_func_iconv=no]
3720         )]
3721     )
3722 if test "$ac_cv_func_iconv" = "yes"; then
3723     AC_DEFINE(HAVE_ICONV)
3724     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3725     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3726     LIBICONV="$_ICONV_LIBS"
3727     AC_CACHE_CHECK(
3728         [for iconv() with const input],
3729         ac_cv_func_const_iconv,
3730         [AC_TRY_COMPILE([
3731             #include <stdlib.h>
3732             #include <iconv.h>
3733             ],
3734             [
3735                 const char *input = "testing";
3736                 iconv_t h = iconv_open("", "");
3737                 iconv(h, &input, NULL, NULL, NULL);
3738                 iconv_close(h);
3739             ],
3740             [ac_cv_func_const_iconv=yes],
3741             [ac_cv_func_const_iconv=no]
3742             )]
3743         )
3744     if test "$ac_cv_func_const_iconv" = "yes"; then
3745         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3746     fi
3748 LIBS=$_SAVE_LIBS
3750     ;;
3751 esac
3753 AM_LANGINFO_CODESET
3755 AC_LANG_C
3757 dnl **********************
3758 dnl *** va_copy checks ***
3759 dnl **********************
3760 dnl we currently check for all three va_copy possibilities, so we get
3761 dnl all results in config.log for bug reports.
3762 AC_MSG_CHECKING(for an implementation of va_copy())
3763 AC_CACHE_VAL(ac_cv_va_copy,[
3764     AC_TRY_RUN([
3765         #include <stdarg.h>
3766         void f (int i, ...) {
3767             va_list args1, args2;
3768             va_start (args1, i);
3769             va_copy (args2, args1);
3770             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3771                 exit (1);
3772             va_end (args1); va_end (args2);
3773         }
3774         int main() { f (0, 42); return 0; }],
3775         ac_cv_va_copy=yes,
3776         ac_cv_va_copy=no,
3777         ac_cv_va_copy=no
3778     )
3780 AC_MSG_RESULT($ac_cv_va_copy)
3781 AC_MSG_CHECKING(for an implementation of __va_copy())
3782 AC_CACHE_VAL(ac_cv___va_copy,[
3783     AC_TRY_RUN([
3784         #include <stdarg.h>
3785         void f (int i, ...) {
3786             va_list args1, args2;
3787             va_start (args1, i);
3788             __va_copy (args2, args1);
3789             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3790                 exit (1);
3791             va_end (args1); va_end (args2);
3792         }
3793         int main() { f (0, 42); return 0; }],
3794         ac_cv___va_copy=yes,
3795         ac_cv___va_copy=no,
3796         ac_cv___va_copy=no
3797     )
3799 AC_MSG_RESULT($ac_cv___va_copy)
3800 AC_MSG_CHECKING(whether va_lists can be copied by value)
3801 AC_CACHE_VAL(ac_cv_va_val_copy,[
3802     AC_TRY_RUN([
3803         #include <stdarg.h>
3804         void f (int i, ...) {
3805             va_list args1, args2;
3806             va_start (args1, i);
3807             args2 = args1;
3808             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3809                 exit (1);
3810             va_end (args1); va_end (args2);
3811         }
3812         int main() { f (0, 42); return 0; }],
3813         ac_cv_va_val_copy=yes,
3814         ac_cv_va_val_copy=no,
3815         ac_cv_va_val_copy=yes
3816     )
3818 if test "x$ac_cv_va_copy" = "xyes"; then
3819     AC_DEFINE(VA_COPY, va_copy)
3820     AC_DEFINE(HAVE_VA_COPY)
3821 elif test "x$ac_cv___va_copy" = "xyes"; then
3822     AC_DEFINE(VA_COPY, __va_copy)
3823     AC_DEFINE(HAVE_VA_COPY)
3826 if test "x$ac_cv_va_val_copy" = "xno"; then
3827    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3829 AC_MSG_RESULT($ac_cv_va_val_copy)
3831 dnl ===================================================================
3832 dnl ========================================================
3833 dnl Put your C++ language/feature checks below
3834 dnl ========================================================
3835 AC_LANG_CPLUSPLUS
3837 ARM_ABI_PREFIX=
3838 if test "$GNU_CC"; then
3839   if test "$CPU_ARCH" = "arm" ; then
3840     AC_CACHE_CHECK(for ARM EABI,
3841         ac_cv_gcc_arm_eabi,
3842         [AC_TRY_COMPILE([],
3843                         [
3844 #if defined(__ARM_EABI__)
3845   return 0;
3846 #else
3847 #error Not ARM EABI.
3848 #endif
3849                         ],
3850                         ac_cv_gcc_arm_eabi="yes",
3851                         ac_cv_gcc_arm_eabi="no")])
3852     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3853         HAVE_ARM_EABI=1
3854         ARM_ABI_PREFIX=eabi-
3855     else
3856         ARM_ABI_PREFIX=oabi-
3857     fi
3858   fi
3860   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3863 dnl Check for support of modern template specialization syntax
3864 dnl Test code and requirement from scc@netscape.com.
3865 dnl Autoconf cut-and-paste job by waterson@netscape.com
3866 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
3867                ac_cv_cpp_modern_specialize_template_syntax,
3868                [AC_TRY_COMPILE(template <class T> struct X { int a; };
3869                                class Y {};
3870                                template <> struct X<Y> { double a; };,
3871                                X<int> int_x;
3872                                X<Y> y_x;,
3873                                ac_cv_cpp_modern_specialize_template_syntax=yes,
3874                                ac_cv_cpp_modern_specialize_template_syntax=no)])
3875 if test "$ac_cv_cpp_modern_specialize_template_syntax" = no ; then
3876   AC_MSG_ERROR([The C++ compiler does not support template specialization])
3879 dnl Some compilers support only full specialization, and some don't.
3880 AC_CACHE_CHECK(whether partial template specialization works,
3881                ac_cv_cpp_partial_specialization,
3882                [AC_TRY_COMPILE(template <class T> class Foo {};
3883                                template <class T> class Foo<T*> {};,
3884                                return 0;,
3885                                ac_cv_cpp_partial_specialization=yes,
3886                                ac_cv_cpp_partial_specialization=no)])
3887 if test "$ac_cv_cpp_partial_specialization" = yes ; then
3888   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
3891 dnl Check to see if we can resolve ambiguity with |using|.
3892 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3893                ac_cv_cpp_ambiguity_resolving_using,
3894                [AC_TRY_COMPILE(class X {
3895                                  public: int go(const X&) {return 3;}
3896                                          int jo(const X&) {return 3;}
3897                                };
3898                                class Y : public X {
3899                                  public:  int go(int) {return 2;}
3900                                           int jo(int) {return 2;}
3901                                           using X::jo;
3902                                  private: using X::go;
3903                                };,
3904                                X x; Y y; y.jo(x);,
3905                                ac_cv_cpp_ambiguity_resolving_using=yes,
3906                                ac_cv_cpp_ambiguity_resolving_using=no)])
3907 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3908    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3911 dnl See if a dynamic_cast to void* gives the most derived object.
3912 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3913                ac_cv_cpp_dynamic_cast_void_ptr,
3914                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3915                             class Y { int j; public: virtual ~Y() { } };
3916                             class Z : public X, public Y { int k; };
3918                             int main() {
3919                                  Z mdo;
3920                                  X *subx = (X*)&mdo;
3921                                  Y *suby = (Y*)&mdo;
3922                                  return !((((void*)&mdo != (void*)subx) &&
3923                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3924                                           (((void*)&mdo != (void*)suby) &&
3925                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3926                             }],
3927                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3928                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3929                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3930 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3931    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3935 dnl note that this one is reversed - if the test fails, then
3936 dnl we require implementations of unused virtual methods. Which
3937 dnl really blows because it means we'll have useless vtable
3938 dnl bloat.
3939 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3940                ac_cv_cpp_unused_required,
3941                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3942                                X x;,
3943                                ac_cv_cpp_unused_required=no,
3944                                ac_cv_cpp_unused_required=yes)])
3945 if test "$ac_cv_cpp_unused_required" = yes ; then
3946    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3950 dnl Some compilers have trouble comparing a constant reference to a templatized
3951 dnl class to zero, and require an explicit operator==() to be defined that takes
3952 dnl an int. This test separates the strong from the weak.
3954 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3955                ac_cv_trouble_comparing_to_zero,
3956                [AC_TRY_COMPILE([#include <algorithm>
3957                                 template <class T> class Foo {};
3958                                 class T2;
3959                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3960                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3961                                [Foo<int> f; return (0 != f);],
3962                                ac_cv_trouble_comparing_to_zero=no,
3963                                ac_cv_trouble_comparing_to_zero=yes)])
3964 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3965   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3968 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3969 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3970 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3971 # linking XUL.
3972 _SAVE_LDFLAGS=$LDFLAGS
3973 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3974 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3975                ac_cv_thread_keyword,
3976                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3977                             [return tlsIsMainThread;],
3978                             ac_cv_thread_keyword=yes,
3979                             ac_cv_thread_keyword=no)])
3980 LDFLAGS=$_SAVE_LDFLAGS
3981 # The custom dynamic linker doesn't support TLS variables
3982 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3983   # mips builds fail with TLS variables because of a binutils bug.
3984   # See bug 528687
3985   case "${target}" in
3986     mips*-*)
3987       :
3988       ;;
3989     *-android*|*-linuxandroid*)
3990       :
3991       ;;
3992     *)
3993       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3994       ;;
3995   esac
3998 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3999 if test -n "$MOZ_LINKER"; then
4000   if test "$CPU_ARCH" = arm; then
4001     dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
4002     ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
4003     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
4004     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
4005       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000"
4006       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000"
4007     fi
4008   fi
4011 dnl The custom linker doesn't support text relocations, but NDK >= r6b
4012 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
4013 dnl We however want to avoid these text relocations, and this can be done
4014 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
4015 dnl doesn't contain anything at all, beside placeholders for some sections,
4016 dnl and crtbegin only contains a finalizer function that calls
4017 dnl __cxa_finalize. The custom linker actually takes care of calling
4018 dnl __cxa_finalize when the library doesn't call it itself, which makes it
4019 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
4020 dnl link crtbegin and crtend at all.
4021 if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a "$OS_TARGET" = "Android"; then
4022   AC_CACHE_CHECK([whether the CRT objects have text relocations],
4023     ac_cv_crt_has_text_relocations,
4024     [echo 'int foo() { return 0; }' > conftest.cpp
4025      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
4026         test -s conftest${DLL_SUFFIX}; then
4027        if readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
4028          ac_cv_crt_has_text_relocations=yes
4029        else
4030          ac_cv_crt_has_text_relocations=no
4031        fi
4032      else
4033        AC_ERROR([couldn't compile a simple C file])
4034      fi
4035      rm -rf conftest*])
4036   if test "$ac_cv_crt_has_text_relocations" = yes; then
4037     dnl While we want libraries to skip the CRT files, we don't want
4038     dnl executables to be treated the same way. We thus set the flag
4039     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
4040     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
4041     dnl Using LDFLAGS in nspr is safe, since we only really build
4042     dnl libraries there.
4043     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
4044     NSPR_LDFLAGS=-nostartfiles
4045   fi
4048 dnl Check for the existence of various allocation headers/functions
4050 MALLOC_H=
4051 MOZ_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
4052 if test "$MALLOC_H" = ""; then
4053   MOZ_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
4054   if test "$MALLOC_H" = ""; then
4055     MOZ_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
4056   fi
4058 if test "$MALLOC_H" != ""; then
4059    AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
4062 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
4063 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
4065 dnl See if compiler supports some gcc-style attributes
4067 AC_CACHE_CHECK(for __attribute__((always_inline)),
4068                ac_cv_attribute_always_inline,
4069                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
4070                                [],
4071                                ac_cv_attribute_always_inline=yes,
4072                                ac_cv_attribute_always_inline=no)])
4074 AC_CACHE_CHECK(for __attribute__((malloc)),
4075                ac_cv_attribute_malloc,
4076                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
4077                                [],
4078                                ac_cv_attribute_malloc=yes,
4079                                ac_cv_attribute_malloc=no)])
4081 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
4082                ac_cv_attribute_warn_unused,
4083                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
4084                                [],
4085                                ac_cv_attribute_warn_unused=yes,
4086                                ac_cv_attribute_warn_unused=no)])
4088 dnl End of C++ language/feature checks
4089 AC_LANG_C
4091 dnl ========================================================
4092 dnl =  Internationalization checks
4093 dnl ========================================================
4095 dnl Internationalization and Locale support is different
4096 dnl on various UNIX platforms.  Checks for specific i18n
4097 dnl features go here.
4099 dnl check for LC_MESSAGES
4100 AC_CACHE_CHECK(for LC_MESSAGES,
4101                 ac_cv_i18n_lc_messages,
4102                 [AC_TRY_COMPILE([#include <locale.h>],
4103                                 [int category = LC_MESSAGES;],
4104                                 ac_cv_i18n_lc_messages=yes,
4105                                 ac_cv_i18n_lc_messages=no)])
4106 if test "$ac_cv_i18n_lc_messages" = yes; then
4107    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
4110 AC_HAVE_FUNCS(localeconv)
4111 fi # ! SKIP_COMPILER_CHECKS
4113 TARGET_XPCOM_ABI=
4114 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
4115     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
4118 dnl Mozilla specific options
4119 dnl ========================================================
4120 dnl The macros used for command line options
4121 dnl are defined in build/autoconf/altoptions.m4.
4123 dnl If the compiler supports these attributes, define them as
4124 dnl convenience macros.
4125 if test "$ac_cv_attribute_always_inline" = yes ; then
4126   AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
4127 else
4128   AC_DEFINE(NS_ALWAYS_INLINE,)
4131 if test "$ac_cv_attribute_malloc" = yes ; then
4132   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
4133 else
4134   AC_DEFINE(NS_ATTR_MALLOC,)
4137 if test "$ac_cv_attribute_warn_unused" = yes ; then
4138   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
4139 else
4140   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
4143 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
4144 dnl features that Windows actually does support.
4146 if test -n "$SKIP_COMPILER_CHECKS"; then
4147    dnl Windows has malloc.h
4148    AC_DEFINE(MALLOC_H, [<malloc.h>])
4149    AC_DEFINE(HAVE_FORCEINLINE)
4150    AC_DEFINE(HAVE_LOCALECONV)
4151 fi # SKIP_COMPILER_CHECKS
4153 dnl ========================================================
4154 dnl =
4155 dnl = Check for external package dependencies
4156 dnl =
4157 dnl ========================================================
4158 MOZ_ARG_HEADER(External Packages)
4160 MOZ_ARG_WITH_STRING(libxul-sdk,
4161 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
4162   LIBXUL_SDK_DIR=$withval)
4164 if test "$LIBXUL_SDK_DIR" = "yes"; then
4165     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
4166 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
4167     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
4169     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
4170         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
4171     fi
4174 AC_SUBST(LIBXUL_SDK)
4176 if test -n "$LIBXUL_SDK"; then
4177     LIBXUL_DIST="$LIBXUL_SDK"
4178 else
4179     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
4181 AC_SUBST(LIBXUL_DIST)
4183 SYSTEM_LIBXUL=
4185 MOZ_ARG_WITH_BOOL(system-libxul,
4186 [  --with-system-libxul    Use system installed libxul SDK],
4187     SYSTEM_LIBXUL=1)
4189 dnl ========================================================
4190 dnl = If NSPR was not detected in the system,
4191 dnl = use the one in the source tree (mozilla/nsprpub)
4192 dnl ========================================================
4193 MOZ_ARG_WITH_BOOL(system-nspr,
4194 [  --with-system-nspr      Use system installed NSPR],
4195     _USE_SYSTEM_NSPR=1 )
4197 if test -n "$_USE_SYSTEM_NSPR"; then
4198     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])])
4201 if test -n "$MOZ_NATIVE_NSPR"; then
4202     _SAVE_CFLAGS=$CFLAGS
4203     CFLAGS="$CFLAGS $NSPR_CFLAGS"
4204     AC_TRY_COMPILE([#include "prtypes.h"],
4205                 [#ifndef PR_STATIC_ASSERT
4206                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
4207                  #endif],
4208                 [MOZ_NATIVE_NSPR=1],
4209                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
4210     AC_TRY_COMPILE([#include "prtypes.h"],
4211                 [#ifndef PR_UINT64
4212                  #error PR_UINT64 not defined or requires including prtypes.h
4213                  #endif],
4214                 [MOZ_NATIVE_NSPR=1],
4215                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
4216     CFLAGS=$_SAVE_CFLAGS
4217 else
4218     if test "$OS_ARCH" = "WINNT"; then
4219         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
4220         if test -n "$GNU_CC"; then
4221             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
4222         else
4223             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
4224         fi
4225     else
4226         NSPR_CFLAGS='`$(LIBXUL_DIST)/sdk/bin/nspr-config --prefix='${LIBXUL_DIST}' --includedir='${LIBXUL_DIST}'/include/nspr --cflags`'
4227         NSPR_LIBS='`$(LIBXUL_DIST)/sdk/bin/nspr-config --prefix='${LIBXUL_DIST}' --libdir='${LIBXUL_DIST}'/lib --libs`'
4228     fi
4231 dnl system libevent Support
4232 dnl ========================================================
4233 MOZ_ARG_WITH_STRING(system-libevent,
4234 [  --with-system-libevent=[PFX]
4235                           Use system libevent [installed at prefix PFX]],
4236     LIBEVENT_DIR=$withval)
4238 _SAVE_CFLAGS=$CFLAGS
4239 _SAVE_LDFLAGS=$LDFLAGS
4240 _SAVE_LIBS=$LIBS
4241 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
4242     MOZ_NATIVE_LIBEVENT=
4243 else
4244     if test "${LIBEVENT_DIR}" = "yes"; then
4245         LIBEVENT_DIR=/usr
4246     fi
4247     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
4248     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
4249     MOZ_CHECK_HEADER(event.h,
4250         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
4251              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
4252          fi],
4253         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
4254     AC_CHECK_LIB(event, event_init,
4255                  [MOZ_NATIVE_LIBEVENT=1
4256                   MOZ_LIBEVENT_INCLUDES="${LIBEVENT_DIR}/include"
4257                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
4258                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_INCLUDES= MOZ_LIBEVENT_LIBS=])
4260 CFLAGS=$_SAVE_CFLAGS
4261 LDFLAGS=$_SAVE_LDFLAGS
4262 LIBS=$_SAVE_LIBS
4264 AC_SUBST(MOZ_NATIVE_LIBEVENT)
4265 AC_SUBST(MOZ_LIBEVENT_INCLUDES)
4266 AC_SUBST(MOZ_LIBEVENT_LIBS)
4268 dnl ========================================================
4269 dnl = If NSS was not detected in the system,
4270 dnl = use the one in the source tree (mozilla/security/nss)
4271 dnl ========================================================
4273 MOZ_ARG_WITH_BOOL(system-nss,
4274 [  --with-system-nss       Use system installed NSS],
4275     _USE_SYSTEM_NSS=1 )
4277 if test -n "$_USE_SYSTEM_NSS"; then
4278     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])])
4281 if test -n "$MOZ_NATIVE_NSS"; then
4282    NSS_LIBS="$NSS_LIBS -lcrmf"
4283 else
4284    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
4285    NSS_DEP_LIBS="\
4286         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
4287         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)smime$NSS_VERSION\$(DLL_SUFFIX) \
4288         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)ssl$NSS_VERSION\$(DLL_SUFFIX) \
4289         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nss$NSS_VERSION\$(DLL_SUFFIX) \
4290         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nssutil$NSS_VERSION\$(DLL_SUFFIX)"
4292    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
4293        NSS_LIBS="\
4294         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
4295         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
4296         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
4297         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
4298         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
4299    else
4300        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
4301    fi
4304 dnl ======================
4305 dnl Detect yasm
4306 dnl ======================
4308 AC_MSG_CHECKING([for YASM assembler])
4309 AC_CHECK_PROGS(YASM, yasm, "")
4311 if test -n "$YASM"; then
4312   dnl Pull out yasm's version string
4313   changequote(,)
4314   _YASM_VER_FILTER='s|.* \([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\).*|\1|p'
4315   changequote([,])
4317   YASM_VERSION=`yasm --version | sed -ne "$_YASM_VER_FILTER"`
4318   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
4319   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
4320   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
4321   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
4324 if test -z "$SKIP_LIBRARY_CHECKS"; then
4325 dnl system JPEG support
4326 dnl ========================================================
4327 MOZ_ARG_WITH_STRING(system-jpeg,
4328 [  --with-system-jpeg[=PFX]
4329                           Use system libjpeg [installed at prefix PFX]],
4330     JPEG_DIR=$withval)
4332 _SAVE_CFLAGS=$CFLAGS
4333 _SAVE_LDFLAGS=$LDFLAGS
4334 _SAVE_LIBS=$LIBS
4335 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
4336     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
4337     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
4339 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
4340     SYSTEM_JPEG=
4341 else
4342     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [SYSTEM_JPEG=1 JPEG_LIBS="-ljpeg $JPEG_LIBS"], SYSTEM_JPEG=, $JPEG_LIBS)
4345 if test "$SYSTEM_JPEG" = 1; then
4346     LIBS="$JPEG_LIBS $LIBS"
4347     AC_TRY_COMPILE([ #include <stdio.h>
4348                      #include <sys/types.h>
4349                      #include <jpeglib.h> ],
4350                    [ #if JPEG_LIB_VERSION < $MOZJPEG
4351                      #error "Insufficient JPEG library version ($MOZJPEG required)."
4352                      #endif ],
4353                    SYSTEM_JPEG=1,
4354                    [SYSTEM_JPEG= JPEG_CFLAGS= JPEG_LIBS=])
4356 CFLAGS=$_SAVE_CFLAGS
4357 LDFLAGS=$_SAVE_LDFLAGS
4358 LIBS=$_SAVE_LIBS
4360 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$SYSTEM_JPEG" = 1; then
4361     JPEG_CFLAGS="-I${JPEG_DIR}/include"
4362     JPEG_LIBS="-L${JPEG_DIR}/lib ${JPEG_LIBS}"
4365 dnl system ZLIB support
4366 dnl ========================================================
4367 MOZ_ARG_WITH_STRING(system-zlib,
4368 [  --with-system-zlib[=PFX]
4369                           Use system libz [installed at prefix PFX]],
4370     ZLIB_DIR=$withval)
4372 _SAVE_CFLAGS=$CFLAGS
4373 _SAVE_LDFLAGS=$LDFLAGS
4374 _SAVE_LIBS=$LIBS
4375 if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
4376     CFLAGS="-I${ZLIB_DIR}/include $CFLAGS"
4377     LDFLAGS="-L${ZLIB_DIR}/lib $LDFLAGS"
4379 if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
4380     SYSTEM_ZLIB=
4381 else
4382     AC_CHECK_LIB(z, gzread, [SYSTEM_ZLIB=1 ZLIB_LIBS="-lz $ZLIB_LIBS"],
4383         [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=], $ZLIB_LIBS)
4385 if test "$SYSTEM_ZLIB" = 1; then
4386     LIBS="$ZLIB_LIBS $LIBS"
4387     AC_TRY_COMPILE([ #include <stdio.h>
4388                      #include <string.h>
4389                      #include <zlib.h> ],
4390                    [ #if ZLIB_VERNUM < $MOZZLIB
4391                      #error "Insufficient zlib version ($MOZZLIB required)."
4392                      #endif ],
4393                    SYSTEM_ZLIB=1,
4394                    [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=])
4396 CFLAGS=$_SAVE_CFLAGS
4397 LDFLAGS=$_SAVE_LDFLAGS
4398 LIBS=$_SAVE_LIBS
4400 if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
4401     ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
4402     ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
4405 if test "$MOZ_LINKER" = 1 -a "$SYSTEM_ZLIB" != 1; then
4406     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
4409 dnl system BZIP2 Support
4410 dnl ========================================================
4411 MOZ_ARG_WITH_STRING(system-bz2,
4412 [  --with-system-bz2[=PFX]
4413                           Use system libbz2 [installed at prefix PFX]],
4414     BZ2_DIR=$withval)
4416 _SAVE_CFLAGS=$CFLAGS
4417 _SAVE_LDFLAGS=$LDFLAGS
4418 _SAVE_LIBS=$LIBS
4419 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4420     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4421     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4423 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4424     SYSTEM_BZ2=
4425 else
4426     AC_CHECK_LIB(bz2, BZ2_bzread, [SYSTEM_BZ2=1 BZ2_LIBS="-lbz2"],
4427         [SYSTEM_BZ2= BZ2_CFLAGS= BZ2_LIBS=])
4429 CFLAGS=$_SAVE_CFLAGS
4430 LDFLAGS=$_SAVE_LDFLAGS
4431 LIBS=$_SAVE_LIBS
4433 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$SYSTEM_BZ2" = 1; then
4434     BZ2_CFLAGS="-I${BZ2_DIR}/include"
4435     BZ2_LIBS="-L${BZ2_DIR}/lib ${BZ2_LIBS}"
4438 dnl system PNG Support
4439 dnl ========================================================
4440 MOZ_ARG_WITH_STRING(system-png,
4441 [  --with-system-png[=PFX]
4442                           Use system libpng [installed at prefix PFX]],
4443     PNG_DIR=$withval)
4445 _SAVE_CFLAGS=$CFLAGS
4446 _SAVE_LDFLAGS=$LDFLAGS
4447 _SAVE_LIBS=$LIBS
4448 CFLAGS="$ZLIB_CFLAGS $CFLAGS"
4449 LDFLAGS="$ZLIB_LIBS -lz $LDFLAGS"
4450 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4451     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4452     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4454 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4455     SYSTEM_PNG=
4456 else
4457     _SAVE_PNG_LIBS=$PNG_LIBS
4458     AC_CHECK_LIB(png, png_get_valid, [SYSTEM_PNG=1 PNG_LIBS="-lpng $PNG_LIBS"],
4459                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]),
4460                  $PNG_LIBS)
4461     AC_CHECK_LIB(png, png_get_acTL, ,
4462                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]),
4463                  $_SAVE_PNG_LIBS)
4465 if test "$SYSTEM_PNG" = 1; then
4466     LIBS="$PNG_LIBS $LIBS"
4467     AC_TRY_COMPILE([ #include <stdio.h>
4468                      #include <sys/types.h>
4469                      #include <png.h> ],
4470                    [ #if PNG_LIBPNG_VER < $MOZPNG
4471                      #error "Insufficient libpng version ($MOZPNG required)."
4472                      #endif
4473                      #ifndef PNG_UINT_31_MAX
4474                      #error "Insufficient libpng version."
4475                      #endif ],
4476                    SYSTEM_PNG=1,
4477                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4479 CFLAGS=$_SAVE_CFLAGS
4480 LDFLAGS=$_SAVE_LDFLAGS
4481 LIBS=$_SAVE_LIBS
4483 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$SYSTEM_PNG" = 1; then
4484     PNG_CFLAGS="-I${PNG_DIR}/include"
4485     PNG_LIBS="-L${PNG_DIR}/lib ${PNG_LIBS}"
4488 fi # SKIP_LIBRARY_CHECKS
4490 dnl system HunSpell Support
4491 dnl ========================================================
4492 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4493 [  --enable-system-hunspell
4494                           Use system hunspell (located with pkgconfig)],
4495     SYSTEM_HUNSPELL=1 )
4497 if test -n "$SYSTEM_HUNSPELL"; then
4498     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4501 AC_SUBST(SYSTEM_HUNSPELL)
4503 dnl ========================================================
4504 dnl system libffi Support
4505 dnl ========================================================
4506 MOZ_ARG_ENABLE_BOOL(system-ffi,
4507 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
4508     MOZ_NATIVE_FFI=1 )
4510 if test -n "$MOZ_NATIVE_FFI"; then
4511     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
4512     # for non-GCC compilers.
4513     if test -z "$GNU_CC"; then
4514         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
4515     else
4516         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
4517     fi
4518     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
4521 dnl ========================================================
4522 dnl Java SDK support
4523 dnl ========================================================
4525 JAVA_BIN_PATH=
4526 MOZ_ARG_WITH_STRING(java-bin-path,
4527 [  --with-java-bin-path=dir
4528                           Location of Java binaries (java, javac, jar)],
4529     JAVA_BIN_PATH=$withval)
4531 dnl ========================================================
4532 dnl =
4533 dnl = Application
4534 dnl =
4535 dnl ========================================================
4537 MOZ_ARG_HEADER(Application)
4539 ENABLE_TESTS=1
4540 ENABLE_SYSTEM_EXTENSION_DIRS=1
4541 MOZ_BRANDING_DIRECTORY=
4542 MOZ_OFFICIAL_BRANDING=
4543 MOZ_FEEDS=1
4544 MOZ_FLEXBOX=
4545 MOZ_WEBAPP_RUNTIME=
4546 MOZ_JSDEBUGGER=1
4547 MOZ_AUTH_EXTENSION=1
4548 MOZ_OGG=1
4549 MOZ_RAW=
4550 MOZ_SYDNEYAUDIO=
4551 MOZ_CUBEB=
4552 MOZ_VORBIS=
4553 MOZ_TREMOR=
4554 MOZ_WAVE=1
4555 MOZ_MEDIA=
4556 MOZ_WEBM=1
4557 MOZ_VP8_ERROR_CONCEALMENT=
4558 MOZ_VP8_ENCODER=
4559 VPX_AS=
4560 VPX_ASFLAGS=
4561 VPX_AS_DASH_C_FLAG=
4562 VPX_AS_CONVERSION=
4563 VPX_ASM_SUFFIX=
4564 VPX_X86_ASM=
4565 VPX_ARM_ASM=
4566 LIBJPEG_TURBO_AS=
4567 LIBJPEG_TURBO_ASFLAGS=
4568 LIBJPEG_TURBO_X86_ASM=
4569 LIBJPEG_TURBO_X64_ASM=
4570 LIBJPEG_TURBO_ARM_ASM=
4571 MOZ_PANGO=1
4572 MOZ_PERMISSIONS=1
4573 MOZ_PLACES=1
4574 MOZ_PREF_EXTENSIONS=1
4575 MOZ_PROFILELOCKING=1
4576 MOZ_PSM=1
4577 MOZ_REFLOW_PERF=
4578 MOZ_SAFE_BROWSING=
4579 MOZ_HELP_VIEWER=
4580 MOZ_SPELLCHECK=1
4581 MOZ_JAVA_COMPOSITOR=
4582 MOZ_ONLY_TOUCH_EVENTS=
4583 MOZ_SVG_DLISTS=
4584 MOZ_TOOLKIT_SEARCH=1
4585 MOZ_UI_LOCALE=en-US
4586 MOZ_UNIVERSALCHARDET=1
4587 MOZ_URL_CLASSIFIER=
4588 MOZ_XTF=1
4589 MOZ_XUL=1
4590 MOZ_ZIPWRITER=1
4591 NS_PRINTING=1
4592 MOZ_PDF_PRINTING=
4593 MOZ_DISABLE_DOMCRYPTO=
4594 NSS_DISABLE_DBM=
4595 NECKO_WIFI=1
4596 NECKO_COOKIES=1
4597 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
4598 USE_ARM_KUSER=
4599 BUILD_CTYPES=1
4600 MOZ_USE_NATIVE_POPUP_WINDOWS=
4601 MOZ_ANDROID_HISTORY=
4602 MOZ_WEBSMS_BACKEND=
4603 MOZ_GRAPHITE=1
4605 case "${target}" in
4606 *darwin*)
4607     ACCESSIBILITY=
4608     ;;
4610     ACCESSIBILITY=1
4611     ;;
4612 esac
4614 case "$target_os" in
4615     mingw*)
4616         NS_ENABLE_TSF=1
4617         AC_DEFINE(NS_ENABLE_TSF)
4618         ;;
4619 esac
4621 case "${target}" in
4622     *-android*|*-linuxandroid*)
4623         if test "$CPU_ARCH" = "arm" ; then
4624           USE_ARM_KUSER=1
4625         fi
4627         NSS_DISABLE_DBM=1
4628         NECKO_WIFI=
4629         MOZ_THEME_FASTSTRIPE=1
4630         MOZ_TREE_FREETYPE=1
4631         MOZ_MEMORY=1
4632         MOZ_RAW=1
4633         ;;
4634 esac
4636 MOZ_ARG_ENABLE_STRING(application,
4637 [  --enable-application=APP
4638                           Options include:
4639                             browser (Firefox)
4640                             xulrunner
4641                             tools/update-packaging (AUS-related packaging tools)],
4642 [ MOZ_BUILD_APP=$enableval ] )
4644 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4645 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4646   XULRUNNER_STUB_NAME=$withval)
4648 if test -z "$XULRUNNER_STUB_NAME"; then
4649   case "$target_os" in
4650   darwin*)
4651     XULRUNNER_STUB_NAME=xulrunner
4652     ;;
4653   *)
4654     XULRUNNER_STUB_NAME=xulrunner-stub
4655   esac
4657 AC_SUBST(XULRUNNER_STUB_NAME)
4659 AC_MSG_CHECKING([for application to build])
4660 if test -z "$MOZ_BUILD_APP"; then
4661   AC_MSG_RESULT([browser])
4662   MOZ_BUILD_APP=browser
4663 else
4664   # default mobile to be mobile/xul
4665   if test "$MOZ_BUILD_APP" = "mobile" ; then
4666     MOZ_BUILD_APP=mobile/xul
4667   fi
4668   # We have a valid application only if it has a build.mk file in its top
4669   # directory.
4670   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4671     AC_MSG_RESULT([none])
4672     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4673   else
4674     AC_MSG_RESULT([$MOZ_BUILD_APP])
4675   fi
4678 # Allow the application to influence configure with a confvars.sh script.
4680 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4681 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4682   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4683   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4684 else
4685   AC_MSG_RESULT([no])
4688 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4689 MOZ_ARG_WITH_STRING(app-name,
4690 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4691 WITH_APP_NAME=$withval,
4694 if test -n "$WITH_APP_NAME" ; then
4695     MOZ_APP_NAME="$WITH_APP_NAME"
4698 MOZ_ARG_WITH_STRING(app-basename,
4699 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4700 WITH_APP_BASENAME=$withval,
4703 if test -n "$WITH_APP_BASENAME" ; then
4704     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4707 # Now is a good time to test for logic errors, define mismatches, etc.
4708 case "$MOZ_BUILD_APP" in
4709 xulrunner)
4710   if test "$LIBXUL_SDK"; then
4711     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4712   fi
4713   ;;
4714 esac
4716 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4717 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4718 # MOZ_BUILD_APP.
4719 case "$MOZ_BUILD_APP" in
4720 browser)
4721   AC_DEFINE(MOZ_PHOENIX)
4722   ;;
4724 xulrunner)
4725   AC_DEFINE(MOZ_XULRUNNER)
4726   ;;
4727 esac
4729 AC_SUBST(MOZ_BUILD_APP)
4730 AC_SUBST(MOZ_PHOENIX)
4731 AC_SUBST(MOZ_XULRUNNER)
4733 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4735 dnl ========================================================
4736 dnl =
4737 dnl = Toolkit Options
4738 dnl =
4739 dnl ========================================================
4740 MOZ_ARG_HEADER(Toolkit Options)
4742     dnl ========================================================
4743     dnl = Select the default toolkit
4744     dnl ========================================================
4745         MOZ_ARG_ENABLE_STRING(default-toolkit,
4746         [  --enable-default-toolkit=TK
4747                           Select default toolkit
4748                           Platform specific defaults:
4749                             Mac OS X - cairo-cocoa
4750                             OS/2 - cairo-os2
4751                             Win32 - cairo-windows
4752                             * - cairo-gtk2
4753                             * - cairo-qt],
4754     [ _DEFAULT_TOOLKIT=$enableval ],
4755     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4757     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4758         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4759         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4760         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4761         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4762         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4763         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4764         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4765         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4766     then
4767         dnl nglayout only supports building with one toolkit,
4768         dnl so ignore everything after the first comma (",").
4769         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4770     else
4771         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4772     fi
4774 MOZ_ARG_WITHOUT_BOOL(x,
4775 [  --without-x              Build without X11],
4776     WITHOUT_X11=1)
4778 dnl ========================================================
4779 dnl = Enable the toolkit as needed                         =
4780 dnl ========================================================
4782 case "$MOZ_WIDGET_TOOLKIT" in
4784 cairo-windows)
4785     MOZ_WIDGET_TOOLKIT=windows
4786     MOZ_WEBGL=1
4787     MOZ_PDF_PRINTING=1
4788     MOZ_INSTRUMENT_EVENT_LOOP=1
4789     ;;
4791 cairo-gtk2|cairo-gtk2-x11)
4792     MOZ_WIDGET_TOOLKIT=gtk2
4793     MOZ_ENABLE_GTK2=1
4794     MOZ_ENABLE_XREMOTE=1
4795     MOZ_WEBGL=1
4796     MOZ_GL_DEFAULT_PROVIDER=GLX
4798     AC_DEFINE(MOZ_X11)
4799     MOZ_X11=1
4800     USE_FC_FREETYPE=1
4802     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4803     TK_LIBS='$(MOZ_GTK2_LIBS)'
4804     AC_DEFINE(MOZ_WIDGET_GTK2)
4805     MOZ_PDF_PRINTING=1
4806     MOZ_INSTRUMENT_EVENT_LOOP=1
4807     ;;
4809 cairo-qt)
4810     MOZ_WIDGET_TOOLKIT=qt
4811     MOZ_ENABLE_QT=1
4812     if test -z "$WITHOUT_X11"; then
4813       MOZ_ENABLE_XREMOTE=1
4814       MOZ_GL_DEFAULT_PROVIDER=GLX
4815       MOZ_X11=1
4816       AC_DEFINE(MOZ_X11)
4817       XT_LIBS=
4818     fi
4820     MOZ_WEBGL=1
4821     USE_ELF_DYNSTR_GC=
4822     USE_FC_FREETYPE=1
4823     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4824     TK_LIBS='$(MOZ_QT_LIBS)'
4825     AC_DEFINE(MOZ_WIDGET_QT)
4826     MOZ_PDF_PRINTING=1
4827     ;;
4829 cairo-os2)
4830     MOZ_WIDGET_TOOLKIT=os2
4831     USE_FC_FREETYPE=1
4832     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4833     TK_LIBS='$(MOZ_CAIRO_LIBS)'
4834     MOZ_PDF_PRINTING=1
4835     ;;
4837 cairo-cocoa)
4838     MOZ_WIDGET_TOOLKIT=cocoa
4839     AC_DEFINE(MOZ_WIDGET_COCOA)
4840     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4841     TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4842     TK_CFLAGS="-DNO_X11"
4843     CFLAGS="$CFLAGS $TK_CFLAGS"
4844     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4845     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4846     MOZ_USER_DIR="Mozilla"
4847     MOZ_FS_LAYOUT=bundle
4848     MOZ_WEBGL=1
4849     MOZ_INSTRUMENT_EVENT_LOOP=1
4850     ;;
4852 cairo-uikit)
4853     MOZ_WIDGET_TOOLKIT=uikit
4854     AC_DEFINE(MOZ_WIDGET_UIKIT)
4855     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4856     TK_CFLAGS="-DNO_X11"
4857     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4858     CFLAGS="$CFLAGS $TK_CFLAGS"
4859     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4860     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4861     MOZ_USER_DIR="Mozilla"
4862     MOZ_FS_LAYOUT=bundle
4863     ;;
4865 cairo-android)
4866     AC_DEFINE(MOZ_WIDGET_ANDROID)
4867     MOZ_WIDGET_TOOLKIT=android
4868     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4869     TK_LIBS='$(MOZ_CAIRO_LIBS)'
4870     MOZ_WEBGL=1
4871     MOZ_PDF_PRINTING=1
4872     MOZ_INSTRUMENT_EVENT_LOOP=1
4873     if test "$MOZ_BUILD_APP" = "mobile/xul"; then
4874         MOZ_OLD_LINKER=1
4875     fi
4876     ;;
4878 cairo-gonk)
4879     AC_DEFINE(MOZ_WIDGET_GONK)
4880     AC_DEFINE(MOZ_TOUCH)
4881     MOZ_WIDGET_TOOLKIT=gonk
4882     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4883     TK_LIBS='$(MOZ_CAIRO_LIBS)'
4884     MOZ_WEBGL=1
4885     MOZ_PDF_PRINTING=1
4886     MOZ_TOUCH=1
4887     ;;
4889 esac
4891 AC_SUBST(MOZ_OLD_LINKER)
4892 AC_SUBST(MOZ_PDF_PRINTING)
4893 if test "$MOZ_PDF_PRINTING"; then
4894    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4895    AC_DEFINE(MOZ_PDF_PRINTING)
4898 if test "$MOZ_ENABLE_XREMOTE"; then
4899     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4902 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4903    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4906 if test "$COMPILE_ENVIRONMENT"; then
4907   if test "$MOZ_ENABLE_GTK2"; then
4908     if test "$MOZ_X11"; then
4909       GDK_PACKAGES=gdk-x11-2.0
4910     fi
4912     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4913   fi
4915 fi # COMPILE_ENVIRONMENT
4917 AC_SUBST(MOZ_FS_LAYOUT)
4919 dnl ========================================================
4920 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4921 dnl their usage and use them in spidermonkey.
4922 dnl ========================================================
4923 MOZ_ARG_WITH_BOOL(arm-kuser,
4924 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4925     USE_ARM_KUSER=1,)
4926 if test -n "$USE_ARM_KUSER"; then
4927    AC_DEFINE(USE_ARM_KUSER)
4930 dnl ========================================================
4931 dnl = startup-notification support module
4932 dnl ========================================================
4934 if test "$MOZ_ENABLE_GTK2"
4935 then
4936     MOZ_ENABLE_STARTUP_NOTIFICATION=
4938     MOZ_ARG_ENABLE_BOOL(startup-notification,
4939     [  --enable-startup-notification
4940                           Enable startup-notification support (default: disabled) ],
4941         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4942         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4943     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4944     then
4945         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4946                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4947         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4948             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4949             then
4950                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4951             fi
4952             MOZ_ENABLE_STARTUP_NOTIFICATION=
4953         ])
4954     fi
4956     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4957         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4958     fi
4960     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4962 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4963 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4964 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4966 dnl ========================================================
4967 dnl = QT support
4968 dnl ========================================================
4969 if test "$MOZ_ENABLE_QT"
4970 then
4971     MOZ_ARG_WITH_STRING(qtdir,
4972     [  --with-qtdir=\$dir       Specify Qt directory ],
4973     [ QTDIR=$withval])
4975     if test -z "$QTDIR"; then
4976         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
4977         PKG_CHECK_MODULES(MOZ_QT5, QtWidgets QtMultimedia QtPrintSupport QtQuick1,
4978                       MOZ_ENABLE_QT5=1,
4979                       MOZ_ENABLE_QT5=)
4980         if test "$MOZ_ENABLE_QT5"; then
4981             echo "Using qt5"
4982             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT5_CFLAGS"
4983             MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT5_LIBS"
4984         fi
4986         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4987         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4988     else
4989         MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
4991         MOZ_QT_CFLAGS="-DQT_SHARED"
4992         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4993         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
4994         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4995         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4996         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4997         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4998         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4999         HOST_MOC="$QTDIR/bin/moc"
5000         HOST_RCC="$QTDIR/bin/rcc"
5002         # QtWidgets was introduced only in Qt5
5003         if test -d $QTDIR/include/QtWidgets; then
5004             echo "Using qt5"
5005             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
5006             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMultimedia"
5007             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
5008             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtQuick1"
5009             MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtWidgets -lQtMultimedia -lQtPrintSupport -lQtQuick1"
5010         fi
5011     fi
5012     if test -z "$HOST_MOC"; then
5013         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
5014 incorrect])
5015     fi
5016     if test -z "$HOST_RCC"; then
5017         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
5018 incorrect])
5019     fi
5021     MOC=$HOST_MOC
5022     RCC=$HOST_RCC
5024     MOZ_ENABLE_QMSYSTEM2=
5025     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
5026                       MOZ_ENABLE_QMSYSTEM2=1,
5027                       MOZ_ENABLE_QMSYSTEM2=)
5029     if test "$MOZ_ENABLE_QMSYSTEM2"; then
5030       MOZ_ENABLE_QMSYSTEM2=1
5031       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
5032       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
5033       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
5034     fi
5036     MOZ_ENABLE_QTNETWORK=
5037     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
5038                       MOZ_ENABLE_QTNETWORK=1,
5039                       MOZ_ENABLE_QTNETWORK=)
5041     if test "$MOZ_ENABLE_QTNETWORK"; then
5042       MOZ_ENABLE_QTNETWORK=1
5043       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
5044     fi
5046     MOZ_ENABLE_QTMOBILITY=
5047     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
5048                       MOZ_ENABLE_QTMOBILITY=1,
5049                       MOZ_ENABLE_QTMOBILITY=)
5050     if test "$MOZ_ENABLE_QTMOBILITY"; then
5051        MOZ_ENABLE_QTMOBILITY=1
5052        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
5053        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
5054     else
5055        AC_CHECK_LIB(QtSensors, main, [
5056           MOZ_ENABLE_QTMOBILITY=1
5057           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
5058           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
5059           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
5060           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
5061           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
5062        ])
5063     fi
5064     if test "$MOZ_ENABLE_QTMOBILITY"; then
5065        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
5066     fi
5069 AC_SUBST(GTK_CONFIG)
5070 AC_SUBST(TK_CFLAGS)
5071 AC_SUBST(TK_LIBS)
5073 AC_SUBST(MOZ_ENABLE_GTK2)
5074 AC_SUBST(MOZ_ENABLE_QT)
5075 AC_SUBST(MOZ_ENABLE_QTNETWORK)
5076 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
5077 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
5078 AC_SUBST(MOZ_ENABLE_XREMOTE)
5079 AC_SUBST(MOZ_GTK2_CFLAGS)
5080 AC_SUBST(MOZ_GTK2_LIBS)
5081 AC_SUBST(MOZ_QT_CFLAGS)
5082 AC_SUBST(MOZ_QT_LIBS)
5084 AC_SUBST(MOC)
5085 AC_SUBST(RCC)
5087 AC_SUBST(MOZ_X11)
5089 dnl ========================================================
5090 dnl =
5091 dnl = Components & Features
5092 dnl =
5093 dnl ========================================================
5094 MOZ_ARG_HEADER(Components and Features)
5096 dnl ========================================================
5097 dnl = Localization
5098 dnl ========================================================
5099 MOZ_ARG_ENABLE_STRING(ui-locale,
5100 [  --enable-ui-locale=ab-CD
5101                           Select the user interface locale (default: en-US)],
5102     MOZ_UI_LOCALE=$enableval )
5103 AC_SUBST(MOZ_UI_LOCALE)
5105 dnl ========================================================
5106 dnl = Trademarked Branding
5107 dnl ========================================================
5108 MOZ_ARG_ENABLE_BOOL(official-branding,
5109 [  --enable-official-branding
5110                           Enable Official mozilla.org Branding
5111                           Do not distribute builds with
5112                           --enable-official-branding unless you have
5113                           permission to use trademarks per
5114                           http://www.mozilla.org/foundation/trademarks/ .],
5116   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
5117     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
5118   else
5119     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
5120     MOZ_OFFICIAL_BRANDING=1
5121   fi
5122 ], MOZ_OFFICIAL_BRANDING=)
5124 AC_SUBST(MOZ_OFFICIAL_BRANDING)
5125 if test -n "$MOZ_OFFICIAL_BRANDING"; then
5126   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
5129 MOZ_ARG_WITH_STRING(branding,
5130 [  --with-branding=dir     Use branding from the specified directory.],
5131     MOZ_BRANDING_DIRECTORY=$withval)
5133 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
5134 if test -z "$REAL_BRANDING_DIRECTORY"; then
5135   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
5138 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
5139   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
5142 AC_SUBST(MOZ_BRANDING_DIRECTORY)
5144 dnl ========================================================
5145 dnl = Distribution ID
5146 dnl ========================================================
5147 MOZ_ARG_WITH_STRING(distribution-id,
5148 [  --with-distribution-id=ID
5149                           Set distribution-specific id (default=org.mozilla)],
5150 [ val=`echo $withval`
5151     MOZ_DISTRIBUTION_ID="$val"])
5153 if test -z "$MOZ_DISTRIBUTION_ID"; then
5154    MOZ_DISTRIBUTION_ID="org.mozilla"
5157 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
5158 AC_SUBST(MOZ_DISTRIBUTION_ID)
5161 dnl ========================================================
5162 dnl complex text support off by default
5163 dnl ========================================================
5164 MOZ_ARG_DISABLE_BOOL(pango,
5165 [  --disable-pango         Disable usage of Pango ],
5166     MOZ_PANGO=,
5167     MOZ_PANGO=1)
5169 dnl ========================================================
5170 dnl = Pango
5171 dnl ========================================================
5172 if test "$MOZ_ENABLE_GTK2"
5173 then
5174     AC_SUBST(MOZ_PANGO)
5176     PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
5178     PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
5179     AC_SUBST(MOZ_PANGO_CFLAGS)
5180     AC_SUBST(MOZ_PANGO_LIBS)
5181     if test "$MOZ_PANGO"
5182     then
5183         AC_DEFINE(MOZ_PANGO)
5184     else
5185         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0 fontconfig)
5186         AC_SUBST(FT2_CFLAGS)
5187         AC_SUBST(FT2_LIBS)
5188     fi
5191 if test "$MOZ_ENABLE_QT"
5192 then
5193     if test "$MOZ_PANGO"
5194     then
5195         PKG_CHECK_MODULES(MOZ_PANGO, [pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION],
5196         [
5197             AC_SUBST(MOZ_PANGO_CFLAGS)
5198             AC_SUBST(MOZ_PANGO_LIBS)
5199             AC_DEFINE(MOZ_PANGO)
5200         ],
5201         [
5202             echo "Pango library not found, will use FT2 font engine"
5203             MOZ_PANGO=
5204         ])
5205     fi
5206     AC_SUBST(MOZ_PANGO)
5209 dnl ========================================================
5210 dnl = GnomeVFS, GIO and GConf support module
5211 dnl ========================================================
5213 if test "$MOZ_X11"
5214 then
5215     dnl build the gnomevfs extension by default only when the
5216     dnl GTK2 toolkit is in use.
5217     if test "$MOZ_ENABLE_GTK2"
5218     then
5219         MOZ_ENABLE_GNOMEVFS=1
5220         MOZ_ENABLE_GCONF=1
5221     fi
5223     dnl ========================================================
5224     dnl = GnomeVFS support module
5225     dnl ========================================================
5226     MOZ_ARG_DISABLE_BOOL(gnomevfs,
5227     [  --disable-gnomevfs      Disable GnomeVFS support ],
5228         MOZ_ENABLE_GNOMEVFS=,
5229         MOZ_ENABLE_GNOMEVFS=force)
5231     if test "$MOZ_ENABLE_GNOMEVFS"
5232     then
5233         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
5234             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
5235             MOZ_ENABLE_GNOMEVFS=1
5236             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
5237         ],[
5238             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
5239             then
5240                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
5241             fi
5242             MOZ_ENABLE_GNOMEVFS=
5243         ])
5244     else
5245         if test `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
5246             PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
5247               MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
5248             ])
5249         fi
5250     fi
5252     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
5253     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
5254     AC_SUBST(MOZ_GNOMEVFS_LIBS)
5256     dnl ========================================================
5257     dnl = GIO support module
5258     dnl ========================================================
5259     MOZ_ARG_ENABLE_BOOL(gio,
5260     [  --enable-gio            Enable GIO support (default: disabled)],
5261         MOZ_ENABLE_GIO=force,
5262         MOZ_ENABLE_GIO=)
5264     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK2"
5265     then
5266         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
5267                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
5268         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
5269             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
5270             MOZ_ENABLE_GIO=1
5271             AC_DEFINE(MOZ_ENABLE_GIO)
5272         ],[
5273             if test "$MOZ_ENABLE_GIO" = "force"
5274             then
5275                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
5276             fi
5277             MOZ_ENABLE_GIO=
5278         ])
5279     fi
5281     AC_SUBST(MOZ_ENABLE_GIO)
5282     AC_SUBST(MOZ_GIO_CFLAGS)
5283     AC_SUBST(MOZ_GIO_LIBS)
5285     dnl ========================================================
5286     dnl = GConf support module
5287     dnl ========================================================
5288     MOZ_ARG_DISABLE_BOOL(gconf,
5289     [  --disable-gconf      Disable Gconf support ],
5290         MOZ_ENABLE_GCONF=,
5291         MOZ_ENABLE_GCONF=force)
5293     if test "$MOZ_ENABLE_GCONF"
5294     then
5295         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
5296             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
5297             MOZ_ENABLE_GCONF=1
5298         ],[
5299             if test "$MOZ_ENABLE_GCONF" = "force"
5300             then
5301                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
5302             fi
5303             MOZ_ENABLE_GCONF=
5304         ])
5305     fi
5307     if test "$MOZ_ENABLE_GCONF"; then
5308         AC_DEFINE(MOZ_ENABLE_GCONF)
5309     fi
5311     AC_SUBST(MOZ_ENABLE_GCONF)
5312     AC_SUBST(MOZ_GCONF_CFLAGS)
5313     AC_SUBST(MOZ_GCONF_LIBS)
5316 dnl ========================================================
5317 dnl = libproxy support
5318 dnl ========================================================
5320 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5321 then
5322     MOZ_ENABLE_LIBPROXY=
5324     MOZ_ARG_ENABLE_BOOL(libproxy,
5325     [  --enable-libproxy         Enable libproxy support ],
5326     MOZ_ENABLE_LIBPROXY=1,
5327     MOZ_ENABLE_LIBPROXY=)
5329     if test "$MOZ_ENABLE_LIBPROXY"
5330     then
5331         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
5332         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
5333     fi
5335 AC_SUBST(MOZ_ENABLE_LIBPROXY)
5336 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
5337 AC_SUBST(MOZ_LIBPROXY_LIBS)
5339 dnl ========================================================
5340 dnl = libnotify support
5341 dnl ========================================================
5343 if test "$MOZ_ENABLE_GTK2"
5344 then
5345     MOZ_ENABLE_LIBNOTIFY=1
5347     MOZ_ARG_DISABLE_BOOL(libnotify,
5348     [  --disable-libnotify     Disable libnotify support ],
5349     MOZ_ENABLE_LIBNOTIFY=,
5350     MOZ_ENABLE_LIBNOTIFY=1)
5352     if test "$MOZ_ENABLE_LIBNOTIFY"
5353     then
5354         AC_DEFINE(MOZ_ENABLE_LIBNOTIFY)
5355     fi
5358 if test -z "$SKIP_LIBRARY_CHECKS"
5359 then
5360     if test "$MOZ_ENABLE_GTK2"
5361     then
5362         if test "$MOZ_ENABLE_LIBNOTIFY"
5363         then
5364             PKG_CHECK_MODULES(MOZ_LIBNOTIFY, libnotify >= $LIBNOTIFY_VERSION)
5365         fi
5366     fi
5368 AC_SUBST(MOZ_ENABLE_LIBNOTIFY)
5369 AC_SUBST(MOZ_LIBNOTIFY_CFLAGS)
5370 AC_SUBST(MOZ_LIBNOTIFY_LIBS)
5372 dnl ========================================================
5373 dnl = GNOME component (mozgnome)
5374 dnl ========================================================
5376 # The GNOME component is built if one of
5377 # gnome-vfs, gio, gconf or libnotify is available.
5378 if test "$MOZ_ENABLE_GCONF" -o \
5379    "$MOZ_ENABLE_GNOMEVFS" -o \
5380    "$MOZ_ENABLE_GIO" -o \
5381    "$MOZ_ENABLE_LIBNOTIFY"; then
5382     MOZ_ENABLE_GNOME_COMPONENT=1
5383 else
5384     MOZ_ENABLE_GNOME_COMPONENT=
5386 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
5388 dnl ========================================================
5389 dnl = libgnomeui support module
5390 dnl ========================================================
5392 if test "$MOZ_ENABLE_GTK2"
5393 then
5394     MOZ_ENABLE_GNOMEUI=1
5396     MOZ_ARG_DISABLE_BOOL(gnomeui,
5397     [  --disable-gnomeui       Disable libgnomeui support (default: auto, optional at runtime) ],
5398         MOZ_ENABLE_GNOMEUI=,
5399         MOZ_ENABLE_GNOMEUI=force)
5401     if test "$MOZ_ENABLE_GNOMEUI"
5402     then
5403         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
5404         [
5405             MOZ_GNOMEUI_LIBS=`echo $MOZ_GNOMEUI_LIBS | sed 's/-llinc\>//'`
5406             MOZ_ENABLE_GNOMEUI=1
5407         ],[
5408             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5409             then
5410                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5411             fi
5412             MOZ_ENABLE_GNOMEUI=
5413         ])
5414     fi
5416     if test "$MOZ_ENABLE_GNOMEUI"; then
5417         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5418     fi
5421 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5422 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5423 AC_SUBST(MOZ_GNOMEUI_LIBS)
5425 dnl ========================================================
5426 dnl = dbus support
5427 dnl ========================================================
5429 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5430 then
5431     MOZ_ENABLE_DBUS=1
5433     MOZ_ARG_DISABLE_BOOL(dbus,
5434     [  --disable-dbus          Disable dbus support ],
5435         MOZ_ENABLE_DBUS=,
5436         MOZ_ENABLE_DBUS=1)
5438     if test "$MOZ_ENABLE_DBUS"
5439     then
5440         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
5441         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5442         AC_DEFINE(MOZ_ENABLE_DBUS)
5443     fi
5445 AC_SUBST(MOZ_ENABLE_DBUS)
5446 AC_SUBST(MOZ_DBUS_CFLAGS)
5447 AC_SUBST(MOZ_DBUS_LIBS)
5448 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5449 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5451 dnl ========================================================
5452 dnl = Enable Android History instead of Places
5453 dnl ========================================================
5454 if test -n "$MOZ_ANDROID_HISTORY"; then
5455      dnl Do this if defined in confvars.sh
5456      AC_DEFINE(MOZ_ANDROID_HISTORY)
5460 dnl ========================================================
5461 dnl = Build with the Android Java compositor
5462 dnl ========================================================
5463 if test -n "$MOZ_JAVA_COMPOSITOR"; then
5464      dnl Do this if defined in confvars.sh
5465      AC_DEFINE(MOZ_JAVA_COMPOSITOR)
5468 dnl ========================================================
5469 dnl = Disable WebSMS backend
5470 dnl ========================================================
5471 MOZ_ARG_DISABLE_BOOL(websms-backend,
5472 [  --disable-websms-backend
5473                            Disable WebSMS backend],
5474     MOZ_WEBSMS_BACKEND=,
5475     MOZ_WEBSMS_BACKEND=1)
5477 if test -n "$MOZ_WEBSMS_BACKEND"; then
5478     AC_DEFINE(MOZ_WEBSMS_BACKEND)
5481 dnl ========================================================
5482 dnl = Build Personal Security Manager
5483 dnl ========================================================
5484 MOZ_ARG_DISABLE_BOOL(crypto,
5485 [  --disable-crypto        Disable crypto support (Personal Security Manager)],
5486     MOZ_PSM=,
5487     MOZ_PSM=1 )
5489 dnl ========================================================
5490 dnl = JS Debugger XPCOM component (js/jsd)
5491 dnl ========================================================
5492 MOZ_ARG_DISABLE_BOOL(jsd,
5493 [  --disable-jsd           Disable JavaScript debug library],
5494     MOZ_JSDEBUGGER=,
5495     MOZ_JSDEBUGGER=1)
5498 dnl ========================================================
5499 dnl = Enable IPDL's "expensive" unit tests
5500 dnl ========================================================
5501 MOZ_IPDL_TESTS=
5503 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5504 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5505     MOZ_IPDL_TESTS=1,
5506     MOZ_IPDL_TESTS=)
5508 if test -n "$MOZ_IPDL_TESTS"; then
5509     AC_DEFINE(MOZ_IPDL_TESTS)
5512 AC_SUBST(MOZ_IPDL_TESTS)
5514 dnl ========================================================
5515 dnl = Turns off code necessary for e10s compatibility
5516 dnl ========================================================
5517 dnl This is a temporary flag to be removed in bug 662601 when
5518 dnl it's no longer needed
5520 MOZ_E10S_COMPAT=
5522 MOZ_ARG_ENABLE_BOOL(e10s-compat,
5523 [  --enable-e10s-compat     Turns off code for e10s compat],
5524     MOZ_E10S_COMPAT=1,
5525     MOZ_E10S_COMPAT=)
5527 if test -n "$MOZ_E10S_COMPAT"; then
5528     AC_DEFINE(MOZ_E10S_COMPAT)
5531 dnl ========================================================
5532 dnl = Disable building dbm
5533 dnl ========================================================
5534 MOZ_ARG_DISABLE_BOOL(dbm,
5535 [  --disable-dbm           Disable building dbm],
5536     NSS_DISABLE_DBM=1,
5537     NSS_DISABLE_DBM=)
5539 dnl bi-directional support always on
5540 IBMBIDI=1
5541 AC_DEFINE(IBMBIDI)
5543 dnl ========================================================
5544 dnl accessibility support on by default on all platforms
5545 dnl except OS X.
5546 dnl ========================================================
5547 MOZ_ARG_DISABLE_BOOL(accessibility,
5548 [  --disable-accessibility Disable accessibility support (off by default on OS X)],
5549     ACCESSIBILITY=,
5550     ACCESSIBILITY=1 )
5551 if test "$ACCESSIBILITY"; then
5552     AC_DEFINE(ACCESSIBILITY)
5555 dnl ========================================================
5556 dnl Disable printing
5557 dnl ========================================================
5558 MOZ_ARG_DISABLE_BOOL(printing,
5559 [  --disable-printing      Disable printing support],
5560     NS_PRINTING=,
5561     NS_PRINTING=1)
5563 if test "$NS_PRINTING"; then
5564     AC_DEFINE(NS_PRINTING)
5565     AC_DEFINE(NS_PRINT_PREVIEW)
5568 dnl ========================================================
5569 dnl = Enable Raw Codecs
5570 dnl ========================================================
5571 MOZ_ARG_ENABLE_BOOL(raw,
5572 [  --enable-raw           Enable support for RAW media],
5573     MOZ_RAW=1,
5574     MOZ_RAW=)
5576 if test -n "$MOZ_RAW"; then
5577     AC_DEFINE(MOZ_RAW)
5578     MOZ_MEDIA=1
5581 AC_SUBST(MOZ_RAW)
5583 dnl ========================================================
5584 dnl = Disable Ogg Codecs
5585 dnl ========================================================
5586 MOZ_ARG_DISABLE_BOOL(ogg,
5587 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5588     MOZ_OGG=,
5589     MOZ_OGG=1)
5591 if test -n "$MOZ_OGG"; then
5592     AC_DEFINE(MOZ_OGG)
5593     MOZ_SYDNEYAUDIO=1
5594     MOZ_CUBEB=1
5595     MOZ_MEDIA=1
5596     case "$target_cpu" in
5597     arm*)
5598         MOZ_TREMOR=1
5599     ;;
5600     *)
5601         MOZ_VORBIS=1
5602     ;;
5603     esac
5605     dnl Checks for __attribute__(aligned()) directive
5606     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5607         [ac_cv_c_attribute_aligned],
5608         [ac_cv_c_attribute_aligned=0
5609          CFLAGS_save="${CFLAGS}"
5610          CFLAGS="${CFLAGS} -Werror"
5611          for ac_cv_c_attr_align_try in 64 32 16 8; do
5612            echo "trying $ac_cv_c_attr_align_try"
5613            AC_TRY_COMPILE([],
5614                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5615                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5616            if test "$ac_cv_c_attribute_aligned" != 0; then
5617              break;
5618            fi
5619          done
5620            CFLAGS="${CFLAGS_save}"])
5621     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5622       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5623                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5624     fi
5627 dnl ========================================================
5628 dnl = Disable VP8 decoder support
5629 dnl ========================================================
5630 MOZ_ARG_DISABLE_BOOL(webm,
5631 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5632     MOZ_WEBM=,
5633     MOZ_WEBM=1)
5635 dnl system libvpx Support
5636 dnl ========================================================
5637 MOZ_ARG_WITH_BOOL(system-libvpx,
5638 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5639     MOZ_NATIVE_LIBVPX=1)
5641 MOZ_LIBVPX_INCLUDES=
5642 MOZ_LIBVPX_LIBS=
5644 if test -n "$MOZ_WEBM"; then
5645     AC_DEFINE(MOZ_WEBM)
5646     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5647         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5648     fi
5649     if test -n "$MOZ_VP8_ENCODER" ; then
5650         AC_DEFINE(MOZ_VP8_ENCODER)
5651     fi
5653     if test -n "$MOZ_NATIVE_LIBVPX"; then
5654         dnl ============================
5655         dnl === libvpx Version check ===
5656         dnl ============================
5657         dnl Check to see if we have a system libvpx package.
5658         PKG_CHECK_MODULES(LIBVPX, vpx >= 1.0.0)
5660         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [], 
5661          [AC_MSG_ERROR([Couldn't find vpx/vpx_decoder.h which is required for build with system libvpx. Use --without-system-libvpx to build with in-tree libvpx.])])
5663         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [], 
5664          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5665     fi
5668 AC_SUBST(MOZ_NATIVE_LIBVPX)
5669 AC_SUBST(MOZ_LIBVPX_INCLUDES)
5670 AC_SUBST(MOZ_LIBVPX_LIBS)
5672 if test -n "$MOZ_WEBM" -a -z "$MOZ_NATIVE_LIBVPX"; then
5673     MOZ_SYDNEYAUDIO=1
5674     MOZ_CUBEB=1
5675     MOZ_MEDIA=1
5676     case "$target_cpu" in
5677     arm*)
5678         MOZ_TREMOR=1
5679     ;;
5680     *)
5681         MOZ_VORBIS=1
5682     ;;
5683     esac
5686     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5687     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5688     dnl We currently require gcc on all arm platforms.
5689     VPX_AS=$YASM
5690     VPX_ASM_SUFFIX=asm
5691     VPX_NEED_OBJ_INT_EXTRACT=
5693     dnl See if we have assembly on this platform.
5694     case "$OS_ARCH:$CPU_ARCH" in
5695     Linux:x86)
5696       VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5697       VPX_X86_ASM=1
5698     ;;
5699     Linux:x86_64)
5700       VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5701       VPX_X86_ASM=1
5702     ;;
5703     SunOS:x86)
5704       VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5705       VPX_X86_ASM=1
5706     ;;
5707     SunOS:x86_64)
5708       VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5709       VPX_X86_ASM=1
5710     ;;
5711     Darwin:x86)
5712       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5713       VPX_X86_ASM=1
5714     ;;
5715     Darwin:x86_64)
5716       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5717       VPX_X86_ASM=1
5718     ;;
5719     WINNT:x86_64)
5720       if test -z "$GNU_CC"; then
5721         VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5722         VPX_X86_ASM=1
5723       fi
5724     ;;
5725     WINNT:x86)
5726       if test -z "$GNU_CC"; then
5727         dnl Check for yasm 1.1 or greater.
5728         if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5729           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.])
5730         elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5731           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.])
5732         else
5733           VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5734           VPX_X86_ASM=1
5735           dnl The encoder needs obj_int_extract to get asm offsets.
5736         fi
5737       fi
5738     ;;
5739     *:arm*)
5740       if test -n "$GNU_AS" ; then
5741         VPX_AS=$AS
5742         dnl These flags are a lie; they're just used to enable the requisite
5743         dnl opcodes; actual arch detection is done at runtime.
5744         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5745         VPX_DASH_C_FLAG="-c"
5746         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5747         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5748         VPX_ARM_ASM=1
5749       fi
5750     esac
5752     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5753       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.])
5754     fi
5756     if test -n "$MOZ_VP8_ENCODER" -a \
5757             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5758       dnl We prefer to get asm offsets using inline assembler, which the above
5759       dnl compilers can do. When we're not using one of those, we have to fall
5760       dnl back to obj_int_extract, which reads them from a compiled object
5761       dnl file. Unfortunately, that only works if we're compiling on a system
5762       dnl with the header files for the appropriate object file format.
5763       VPX_NEED_OBJ_INT_EXTRACT=1
5764     fi
5766     if test -n "$VPX_X86_ASM"; then
5767       AC_DEFINE(VPX_X86_ASM)
5768     elif test -n "$VPX_ARM_ASM"; then
5769       AC_DEFINE(VPX_ARM_ASM)
5770     else
5771       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5772     fi
5775 dnl ========================================================
5776 dnl = Disable Wave decoder support
5777 dnl ========================================================
5778 MOZ_ARG_DISABLE_BOOL(wave,
5779 [  --disable-wave          Disable Wave decoder support],
5780     MOZ_WAVE=,
5781     MOZ_WAVE=1)
5783 if test -n "$MOZ_WAVE"; then
5784     AC_DEFINE(MOZ_WAVE)
5785     MOZ_SYDNEYAUDIO=1
5786     MOZ_CUBEB=1
5787     MOZ_MEDIA=1
5790 dnl ========================================================
5791 dnl = Handle dependent SYDNEYAUDIO, CUBEB, and MEDIA defines
5792 dnl ========================================================
5794 if test -n "$MOZ_SYDNEYAUDIO"; then
5795     AC_DEFINE(MOZ_SYDNEYAUDIO)
5798 if test -n "$MOZ_CUBEB"; then
5799     case "$target" in
5800     *-mingw*)
5801         AC_DEFINE(MOZ_CUBEB)
5802         ;;
5803     *)
5804         dnl Other targets will be enabled soon.
5805         ;;
5806     esac
5809 if test -n "$MOZ_MEDIA"; then
5810     AC_DEFINE(MOZ_MEDIA)
5813 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5814     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/])
5817 if test -n "$MOZ_VORBIS"; then
5818     AC_DEFINE(MOZ_VORBIS)
5821 if test -n "$MOZ_TREMOR"; then
5822     AC_DEFINE(MOZ_TREMOR)
5825 dnl ========================================================
5826 dnl = Check alsa availability on Linux if using sydneyaudio
5827 dnl ========================================================
5829 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5830 if test -n "$MOZ_SYDNEYAUDIO"; then
5831    case "$target_os" in
5832 linux*)
5833       PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5834          [echo "$MOZ_ALSA_PKG_ERRORS"
5835           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.)])])
5836       ;;
5837    esac
5840 dnl ========================================================
5841 dnl = Enable GStreamer
5842 dnl ========================================================
5843 MOZ_ARG_ENABLE_BOOL(gstreamer,
5844 [  --enable-gstreamer           Enable GStreamer support],
5845 MOZ_GSTREAMER=1,
5846 MOZ_GSTREAMER=)
5848 if test "$MOZ_GSTREAMER"; then
5849     # API version, eg 0.10, 1.0 etc
5850     GST_API_VERSION=0.10
5851     # core/base release number
5852     # depend on >= 0.10.33 as that's when the playbin2 source-setup signal was
5853     # introduced
5854     GST_VERSION=0.10.33
5855     PKG_CHECK_MODULES(GSTREAMER,
5856                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5857                       gstreamer-app-$GST_API_VERSION
5858                       gstreamer-plugins-base-$GST_API_VERSION)
5859     if test -n "$GSTREAMER_LIBS"; then
5860        _SAVE_LDFLAGS=$LDFLAGS
5861        LDFLAGS="$LDFLAGS -lgstvideo-$GST_API_VERSION"
5862        AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5863        if test -n "$_HAVE_LIBGSTVIDEO" ; then
5864           GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5865        else
5866           AC_MSG_ERROR([gstreamer video backend requires libgstvideo])
5867        fi
5868        LDFLAGS=$_SAVE_LDFLAGS
5869     else
5870        AC_MSG_ERROR([gstreamer backend requires the gstreamer packages])
5871     fi
5873 AC_SUBST(GSTREAMER_CFLAGS)
5874 AC_SUBST(GSTREAMER_LIBS)
5875 AC_SUBST(MOZ_GSTREAMER)
5877 if test -n "$MOZ_GSTREAMER"; then
5878    AC_DEFINE(MOZ_GSTREAMER)
5879    MOZ_MEDIA=1
5883 dnl ========================================================
5884 dnl Permissions System
5885 dnl ========================================================
5886 MOZ_ARG_DISABLE_BOOL(permissions,
5887 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5888     MOZ_PERMISSIONS=,
5889     MOZ_PERMISSIONS=1
5892 dnl ========================================================
5893 dnl NegotiateAuth
5894 dnl ========================================================
5895 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5896 [  --disable-negotiateauth Disable GSS-API negotiation ],
5897     MOZ_AUTH_EXTENSION=,
5898     MOZ_AUTH_EXTENSION=1 )
5900 dnl ========================================================
5901 dnl XTF
5902 dnl ========================================================
5903 MOZ_ARG_DISABLE_BOOL(xtf,
5904 [  --disable-xtf           Disable XTF (pluggable xml tags) support],
5905     MOZ_XTF=,
5906     MOZ_XTF=1 )
5907 if test "$MOZ_XTF"; then
5908   AC_DEFINE(MOZ_XTF)
5911 dnl ========================================================
5912 dnl Pref extensions (autoconfig)
5913 dnl ========================================================
5914 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5915 [  --disable-pref-extensions
5916                           Disable pref extensions such as autoconfig],
5917   MOZ_PREF_EXTENSIONS=,
5918   MOZ_PREF_EXTENSIONS=1 )
5920 dnl ========================================================
5921 dnl Searching of system directories for extensions.
5922 dnl Note: this switch is meant to be used for test builds
5923 dnl whose behavior should not depend on what happens to be
5924 dnl installed on the local machine.
5925 dnl ========================================================
5926 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5927 [  --disable-system-extension-dirs
5928                           Disable searching system- and account-global
5929                           directories for extensions of any kind; use
5930                           only profile-specific extension directories],
5931   ENABLE_SYSTEM_EXTENSION_DIRS=,
5932   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5933 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5934   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5937 dnl ========================================================
5938 dnl = Universalchardet
5939 dnl ========================================================
5940 MOZ_ARG_DISABLE_BOOL(universalchardet,
5941 [  --disable-universalchardet
5942                           Disable universal encoding detection],
5943   MOZ_UNIVERSALCHARDET=,
5944   MOZ_UNIVERSALCHARDET=1 )
5946 if test -n "${JAVA_BIN_PATH}"; then
5947   dnl Look for javac and jar in the specified path.
5948   JAVA_PATH="$JAVA_BIN_PATH"
5949 else
5950   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5951   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5954 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5955 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5956 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5958 if test -n "${JAVA_BIN_PATH}" -o \
5959   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5960   if test -z "$JAVA" -o "$JAVA" = ":" -o -z "$JAVAC" -o "$JAVAC" = ":" -o -z "$JAR" -o "$JAR" = ":"; then
5961     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}])
5962   fi
5965 dnl ========================================================
5966 dnl = ANGLE OpenGL->D3D translator for WebGL
5967 dnl = * only applies to win32
5968 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5969 dnl ========================================================
5970 MOZ_ANGLE=
5971 MOZ_DIRECTX_SDK_PATH=
5972 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5973 MOZ_D3DX9_VERSION=
5974 MOZ_D3DX9_CAB=
5975 MOZ_D3DCOMPILER_CAB=
5976 MOZ_D3DX9_DLL=
5977 MOZ_D3DCOMPILER_DLL=
5978 case "$target_os" in
5979 *mingw*)
5980     MOZ_ANGLE=1
5981     ;;
5982 esac
5984 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5985 case "${target_cpu}" in
5986 i*86)
5987   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5988   ;;
5989 x86_64)
5990   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5991   ;;
5992 esac
5994 if test -n "$MOZ_ANGLE"; then
5995 MOZ_ARG_DISABLE_BOOL(angle,
5996 [  --disable-angle     Disable building of ANGLE for WebGL->D3D translation],
5997     MOZ_ANGLE=,
5998     MOZ_ANGLE=1)
6000 if test -n "$MOZ_ANGLE"; then
6001   if test -z "$_WIN32_MSVC"; then
6002     AC_MSG_ERROR([Building ANGLE requires MSVC.  To build without ANGLE, reconfigure with --disable-angle.])
6003   fi
6005   # Get the SDK path from the registry.
6006   # First try to get the June 2010 SDK
6007   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
6008   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
6009     # Otherwise just take whatever comes first
6010     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
6011   fi
6013   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
6014     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.])
6015   else
6016     MOZ_DIRECTX_SDK_PATH=`reg query "$MOZ_DIRECTX_SDK_REG_KEY" //v InstallPath | grep REG_SZ | sed 's/.*\([[a-zA-Z]]\)\\:\\\\/\\1\\:\\\\/'`
6017   fi
6019   MOZ_ANGLE=
6021   if test -n "$MOZ_DIRECTX_SDK_PATH" ; then
6022     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
6023       AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
6024       MOZ_ANGLE=1
6025     fi
6026   fi
6028   if test -z "$MOZ_ANGLE" ; then
6029     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.])
6030   fi
6032   if test -n "$MOZ_ANGLE" ; then
6033     # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
6034     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'`
6036     if test -z "$MOZ_D3DX9_VERSION" ; then
6037       AC_MSG_ERROR([Couldn't determine the D3DX9 version, needed for ANGLE. To explicitly build without ANGLE, reconfigure with --disable-angle.])
6038     fi
6040     if test -n "$MOZ_ANGLE" ; then
6041       MOZ_D3DX9_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *d3dx9_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
6042       MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
6044       MOZ_D3DX9_DLL=d3dx9_$MOZ_D3DX9_VERSION.dll
6045       MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
6046     fi
6047   fi
6051 dnl ========================================================
6052 dnl = Breakpad crash reporting (on by default on supported platforms)
6053 dnl ========================================================
6055 case $target in
6056 i?86-*-mingw*|x86_64-*-mingw*)
6057   MOZ_CRASHREPORTER=1
6058   ;;
6059 i?86-apple-darwin*|powerpc-apple-darwin*|x86_64-apple-darwin*)
6060   MOZ_CRASHREPORTER=1
6061   ;;
6062 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
6063   if test "$MOZ_ENABLE_GTK2"; then
6064     MOZ_CRASHREPORTER=1
6065   fi
6066   ;;
6067 *-android*|*-linuxandroid*)
6068   MOZ_CRASHREPORTER=1
6069   ;;
6070 *solaris*)
6071   MOZ_CRASHREPORTER=1
6072   ;;
6073 esac
6075 MOZ_ARG_DISABLE_BOOL(crashreporter,
6076 [  --disable-crashreporter Disable breakpad crash reporting],
6077     MOZ_CRASHREPORTER=,
6078     MOZ_CRASHREPORTER=1)
6080 if test -n "$MOZ_CRASHREPORTER"; then
6081    AC_DEFINE(MOZ_CRASHREPORTER)
6083   if (test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS") && \
6084     test -z "$SKIP_LIBRARY_CHECKS"; then
6085     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
6086     AC_SUBST(MOZ_GTHREAD_CFLAGS)
6087     AC_SUBST(MOZ_GTHREAD_LIBS)
6089     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.])])
6090   fi
6092   if (test "$OS_ARCH" != "$HOST_OS_ARCH"); then
6093     AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.  Use --disable-crashreporter.])
6094   fi
6097 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
6098 [  --with-crashreporter-enable-percent=NN
6099                           Enable sending crash reports by default on NN% of users. (default=100)],
6100 [ val=`echo $withval | sed 's/[^0-9]//g'`
6101     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
6103 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
6104    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6106 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6108 dnl ========================================================
6109 dnl = libjpeg-turbo configuration
6110 dnl ========================================================
6111 MOZ_LIBJPEG_TURBO=
6112 if test -z "$SYSTEM_JPEG"; then
6113     MOZ_LIBJPEG_TURBO=1
6116 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6117 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6118     MOZ_LIBJPEG_TURBO=,
6119     MOZ_LIBJPEG_TURBO=1)
6121 if test "$SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6122     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6125 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6126 dnl files.
6128 if test -n "$MOZ_LIBJPEG_TURBO"; then
6130   dnl Do we support libjpeg-turbo on this platform?
6131   case "$OS_ARCH:$OS_TEST" in
6132   Linux:x86|Linux:i?86)
6133     LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6134     LIBJPEG_TURBO_X86_ASM=1
6135   ;;
6136   Linux:x86_64)
6137     LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6138     LIBJPEG_TURBO_X64_ASM=1
6139   ;;
6140   SunOS:i?86)
6141     LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6142     LIBJPEG_TURBO_X86_ASM=1
6143   ;;
6144   SunOS:x86_64)
6145     LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6146     LIBJPEG_TURBO_X64_ASM=1
6147   ;;
6148   Darwin:i?86)
6149     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6150     LIBJPEG_TURBO_X86_ASM=1
6151   ;;
6152   Darwin:x86_64)
6153     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6154     LIBJPEG_TURBO_X64_ASM=1
6155   ;;
6156   WINNT:x86|WINNT:i?86)
6157     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6158     LIBJPEG_TURBO_X86_ASM=1
6159   ;;
6160   WINNT:x86_64)
6161     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6162     LIBJPEG_TURBO_X64_ASM=1
6163   ;;
6164   *:arm*)
6165     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6166     LIBJPEG_TURBO_ARM_ASM=1
6167   ;;
6168   esac
6172 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6173 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6174 dnl it doesn't exist or we have too old of a version.
6175 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6176     AC_MSG_CHECKING([for Yasm assembler])
6177     AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "")
6179     if test -z "$LIBJPEG_TURBO_AS" ; then
6180         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.])
6181     fi
6183     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6184     dnl on Linux and 1.1 or newer everywhere else.
6185     if test "$OS_ARCH" = "Linux" ; then
6186         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
6187             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.])
6188         fi
6189     else
6190         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6191             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.])
6192         fi
6193     fi
6196 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6197 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6198 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6199     echo "Using $AS as the assembler for ARM code."
6200     LIBJPEG_TURBO_AS=$AS
6203 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6204     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6205 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6206     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6207 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6208     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6209 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6210     dnl Warn if we're not building the optimized routines, even though the user
6211     dnl didn't specify --disable-libjpeg-turbo.
6212     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6215 dnl ========================================================
6216 dnl = Enable compilation of specific extension modules
6217 dnl ========================================================
6219 MOZ_ARG_ENABLE_STRING(extensions,
6220 [  --enable-extensions     Enable extensions],
6221 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6222     if test "$option" = "yes" -o "$option" = "all"; then
6223         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6224     elif test "$option" = "no" -o "$option" = "none"; then
6225         MOZ_EXTENSIONS=""
6226     elif test "$option" = "default"; then
6227         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6228     elif test `echo "$option" | grep -c \^-` != 0; then
6229         option=`echo $option | sed 's/^-//'`
6230         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6231     else
6232         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6233     fi
6234 done],
6235     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6237 if test -z "$MOZ_ENABLE_GNOMEVFS" -a -z "$MOZ_GNOMEVFS_LIBS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6238     # Suppress warning on non-X11 platforms
6239     if test -n "$MOZ_X11"; then
6240         AC_MSG_WARN([Cannot build gnomevfs without required libraries. Removing gnomevfs from MOZ_EXTENSIONS.])
6241     fi
6242     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6245 dnl Do not build gnomevfs with libxul based apps
6246 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6247     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6250 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6251     # Suppress warning on non-X11 platforms
6252     if test -n "$MOZ_X11"; then
6253         AC_MSG_WARN([Cannot build gio without required libraries. Removing gio from MOZ_EXTENSIONS.])
6254     fi
6255     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6258 dnl Do not build gio with libxul based apps
6259 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6260     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6263 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6264     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6265     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6268 dnl xforms requires xtf
6269 if test -z "$MOZ_XTF" -a `echo "$MOZ_EXTENSIONS" | grep -c xforms` -ne 0; then
6270     AC_MSG_WARN([Cannot build XForms without XTF support.  Removing XForms from MOZ_EXTENSIONS.])
6271     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|xforms||g'`
6274 dnl Remove dupes
6275 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6277 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6278 dnl when trying to build a nonexistent extension.
6279 for extension in $MOZ_EXTENSIONS; do
6280     if test ! -d "${srcdir}/extensions/${extension}"; then
6281         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6282     fi
6283 done
6285 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6286   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6289 dnl ========================================================
6290 dnl CSS3 Flexbox Support
6291 dnl ========================================================
6292 if test -n "$MOZ_FLEXBOX"; then
6293   AC_DEFINE(MOZ_FLEXBOX)
6296 dnl ========================================================
6297 dnl SVG Display Lists
6298 dnl ========================================================
6299 if test -n "$MOZ_SVG_DLISTS"; then
6300   AC_DEFINE(MOZ_SVG_DLISTS)
6303 dnl ========================================================
6304 dnl Build Freetype in the tree
6305 dnl ========================================================
6306 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6307 [  --enable-tree-freetype  Enable Tree FreeType],
6308     MOZ_TREE_FREETYPE=1,
6309     MOZ_TREE_FREETYPE= )
6310 if test -n "$MOZ_TREE_FREETYPE"; then
6311    if test -n "$_WIN32_MSVC"; then
6312       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6313    fi
6314    AC_DEFINE(MOZ_TREE_FREETYPE)
6315    AC_SUBST(MOZ_TREE_FREETYPE)
6316    MOZ_ENABLE_CAIRO_FT=1
6317    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6318    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6319    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6320    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6321    CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6322    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6323    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6324    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6325    AC_SUBST(CAIRO_FT_CFLAGS)
6328 dnl ========================================================
6329 dnl Installer
6330 dnl ========================================================
6331 dnl Abort Windows build if the required major version and
6332 dnl minimum minor version of Unicode NSIS isn't in the path
6333 dnl (unless in case of cross compiling, for which Unicode
6334 dnl is not yet sufficient).
6335 if test "$OS_ARCH" = "WINNT"; then
6336     REQ_NSIS_MAJOR_VER=2
6337     MIN_NSIS_MINOR_VER=33
6338     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensisu makensis)
6339     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6340       AC_MSG_RESULT([yes])
6341       changequote(,)
6342       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\)\-Unicode$/\1/g'`
6343       changequote([,])
6344       if test ! "$MAKENSISU_VER" = ""; then
6345           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6346           MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6347       fi
6348       AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6349       if test "$MAKENSISU_VER" = "" || \
6350          test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6351               ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6352           AC_MSG_RESULT([no])
6353           if test -z "$CROSS_COMPILE"; then
6354             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.])
6355           else
6356             MAKENSISU=
6357           fi
6358       fi
6359     elif test -z "$CROSS_COMPILE"; then
6360       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.])
6361     else
6362       MAKENSISU=
6363     fi
6366 dnl ========================================================
6367 dnl Web App Runtime
6368 dnl ========================================================
6369 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6370 [  --disable-webapp-runtime  Disable Web App Runtime],
6371     MOZ_WEBAPP_RUNTIME=,
6372     MOZ_WEBAPP_RUNTIME=1)
6373 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6374     MOZ_WEBAPP_RUNTIME=
6376 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6377 if test "$MOZ_WEBAPP_RUNTIME"; then
6378     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6381 AC_MSG_CHECKING([for tar archiver])
6382 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6383 if test -z "$TAR"; then
6384     AC_MSG_ERROR([no tar archiver found in \$PATH])
6386 AC_MSG_RESULT([$TAR])
6387 AC_SUBST(TAR)
6389 AC_MSG_CHECKING([for wget])
6390 AC_CHECK_PROGS(WGET, wget, "")
6391 AC_MSG_RESULT([$WGET])
6392 AC_SUBST(WGET)
6394 dnl ========================================================
6395 dnl Maintenance Service
6396 dnl ========================================================
6398 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6399 [  --enable-maintenance-service       Enable building of maintenanceservice],
6400     MOZ_MAINTENANCE_SERVICE=1,
6401     MOZ_MAINTENANCE_SERVICE= )
6403 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6404   if test "$OS_ARCH" = "WINNT"; then
6405     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6406   else
6407     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6408   fi
6411 dnl ========================================================
6412 dnl Verify MAR signatures
6413 dnl ========================================================
6415 MOZ_ARG_ENABLE_BOOL(verify-mar,
6416 [  --enable-verify-mar     Enable verifying MAR signatures],
6417     MOZ_VERIFY_MAR_SIGNATURE=1,
6418     MOZ_VERIFY_MAR_SIGNATURE= )
6420 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6421   if test "$OS_ARCH" = "WINNT"; then
6422     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6423   else
6424     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6425   fi
6428 dnl ========================================================
6429 dnl Enable building the signmar program.
6430 dnl This option is much different than the --enable-verify-mar option.
6431 dnl --enable-verify-mar is for enabling the verification check on MAR
6432 dnl files in the updater.  The --enable-signmar option is for building
6433 dnl the signmar program.
6434 dnl ========================================================
6436 MOZ_ARG_ENABLE_BOOL(signmar,
6437 [  --enable-signmar     Enable building the signmar program],
6438     MOZ_ENABLE_SIGNMAR=1,
6439     MOZ_ENABLE_SIGNMAR= )
6441 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6442   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6445 dnl ========================================================
6446 dnl Updater
6447 dnl ========================================================
6449 MOZ_ARG_DISABLE_BOOL(updater,
6450 [  --disable-updater       Disable building of updater],
6451     MOZ_UPDATER=,
6452     MOZ_UPDATER=1 )
6454 if test -n "$MOZ_UPDATER"; then
6455     AC_DEFINE(MOZ_UPDATER)
6458 # app update channel is 'default' when not supplied.
6459 MOZ_ARG_ENABLE_STRING([update-channel],
6460 [  --enable-update-channel=CHANNEL
6461                           Select application update channel (default=default)],
6462     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
6464 if test -z "$MOZ_UPDATE_CHANNEL"; then
6465     MOZ_UPDATE_CHANNEL=default
6467 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
6468 AC_SUBST(MOZ_UPDATE_CHANNEL)
6470 # tools/update-packaging is not checked out by default.
6471 MOZ_ARG_ENABLE_BOOL(update-packaging,
6472 [  --enable-update-packaging
6473                           Enable tools/update-packaging],
6474     MOZ_UPDATE_PACKAGING=1,
6475     MOZ_UPDATE_PACKAGING= )
6476 AC_SUBST(MOZ_UPDATE_PACKAGING)
6478 dnl ========================================================
6479 dnl leaky
6480 dnl ========================================================
6481 MOZ_ARG_ENABLE_BOOL(leaky,
6482 [  --enable-leaky          Build leaky memory tool],
6483     MOZ_LEAKY=1,
6484     MOZ_LEAKY=)
6487 dnl ========================================================
6488 dnl build the tests by default
6489 dnl ========================================================
6490 MOZ_ARG_DISABLE_BOOL(tests,
6491 [  --disable-tests         Do not build test libraries & programs],
6492     ENABLE_TESTS=,
6493     ENABLE_TESTS=1 )
6495 dnl ========================================================
6496 dnl parental controls (for Windows Vista)
6497 dnl ========================================================
6498 MOZ_ARG_DISABLE_BOOL(parental-controls,
6499 [  --disable-parental-controls
6500                           Do not build parental controls],
6501    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6502    MOZ_DISABLE_PARENTAL_CONTROLS=)
6503 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6504     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6507 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6509 dnl ========================================================
6510 dnl = Disable DOMCrypto
6511 dnl ========================================================
6512 if test -n "$MOZ_DISABLE_DOMCRYPTO"; then
6513     AC_DEFINE(MOZ_DISABLE_DOMCRYPTO)
6516 dnl ========================================================
6517 dnl =
6518 dnl = Module specific options
6519 dnl =
6520 dnl ========================================================
6521 MOZ_ARG_HEADER(Individual module options)
6523 dnl ========================================================
6524 dnl = Disable feed handling components
6525 dnl ========================================================
6526 MOZ_ARG_DISABLE_BOOL(feeds,
6527 [  --disable-feeds         Disable feed handling and processing components],
6528     MOZ_FEEDS=,
6529     MOZ_FEEDS=1 )
6530 if test -n "$MOZ_FEEDS"; then
6531     AC_DEFINE(MOZ_FEEDS)
6532 else
6533     if test "$MOZ_BUILD_APP" = "browser"; then
6534         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6535     fi
6538 dnl ========================================================
6539 dnl Check for sqlite
6540 dnl ========================================================
6542 MOZ_NATIVE_SQLITE=
6543 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6544 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6545 MOZ_NATIVE_SQLITE=1,
6546 MOZ_NATIVE_SQLITE= )
6548 if test -z "$MOZ_NATIVE_SQLITE"
6549 then
6550     SQLITE_CFLAGS=
6551     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6552 else
6553     dnl ============================
6554     dnl === SQLite Version check ===
6555     dnl ============================
6556     dnl Check to see if the system SQLite package is new enough.
6557     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6559     dnl ==================================
6560     dnl === SQLITE_SECURE_DELETE check ===
6561     dnl ==================================
6562     dnl Check to see if the system SQLite package is compiled with
6563     dnl SQLITE_SECURE_DELETE enabled.
6564     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6565     _SAVE_CFLAGS="$CFLAGS"
6566     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6567     _SAVE_LIBS="$LIBS"
6568     LIBS="$LIBS $SQLITE_LIBS"
6569     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6570         AC_TRY_RUN([
6571             #include "sqlite3.h"
6573             int main(int argc, char **argv){
6574               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6575             }],
6576             ac_cv_sqlite_secure_delete=yes,
6577             ac_cv_sqlite_secure_delete=no,
6578             ac_cv_sqlite_secure_delete=no
6579         )
6580     ])
6581     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6582     CFLAGS="$_SAVE_CFLAGS"
6583     LIBS="$_SAVE_LIBS"
6584     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6585         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6586     fi
6588     dnl ===============================
6589     dnl === SQLITE_THREADSAFE check ===
6590     dnl ===============================
6591     dnl Check to see if the system SQLite package is compiled with
6592     dnl SQLITE_THREADSAFE enabled.
6593     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6594     _SAVE_CFLAGS="$CFLAGS"
6595     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6596     _SAVE_LIBS="$LIBS"
6597     LIBS="$LIBS $SQLITE_LIBS"
6598     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6599         AC_TRY_RUN([
6600             #include "sqlite3.h"
6602             int main(int argc, char **argv){
6603               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6604             }],
6605             ac_cv_sqlite_threadsafe=yes,
6606             ac_cv_sqlite_threadsafe=no,
6607             ac_cv_sqlite_threadsafe=no
6608         )
6609     ])
6610     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6611     CFLAGS="$_SAVE_CFLAGS"
6612     LIBS="$_SAVE_LIBS"
6613     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6614         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6615     fi
6617     dnl ================================
6618     dnl === SQLITE_ENABLE_FTS3 check ===
6619     dnl ================================
6620     dnl check to see if the system SQLite package is compiled with
6621     dnl SQLITE_ENABLE_FTS3 enabled.
6622     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6623     _SAVE_CFLAGS="$CFLAGS"
6624     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6625     _SAVE_LIBS="$LIBS"
6626     LIBS="$LIBS $SQLITE_LIBS"
6627     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6628         AC_TRY_RUN([
6629             #include "sqlite3.h"
6631             int main(int argc, char **argv){
6632               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6633             }],
6634             ac_cv_sqlite_enable_fts3=yes,
6635             ac_cv_sqlite_enable_fts3=no,
6636             ac_cv_sqlite_enable_fts3=no
6637         )
6638     ])
6639     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6640     CFLAGS="$_SAVE_CFLAGS"
6641     LIBS="$_SAVE_LIBS"
6642     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6643         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6644     fi
6646     dnl =========================================
6647     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6648     dnl =========================================
6649     dnl check to see if the system SQLite package is compiled with
6650     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6651     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6652     _SAVE_CFLAGS="$CFLAGS"
6653     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6654     _SAVE_LIBS="$LIBS"
6655     LIBS="$LIBS $SQLITE_LIBS"
6656     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6657         AC_TRY_RUN([
6658             #include "sqlite3.h"
6660             int main(int argc, char **argv){
6661               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6662             }],
6663             ac_cv_sqlite_enable_unlock_notify=yes,
6664             ac_cv_sqlite_enable_unlock_notify=no,
6665             ac_cv_sqlite_enable_unlock_notify=no
6666         )
6667     ])
6668     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6669     CFLAGS="$_SAVE_CFLAGS"
6670     LIBS="$_SAVE_LIBS"
6671     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6672         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6673     fi
6676 if test -n "$MOZ_NATIVE_SQLITE"; then
6677     AC_DEFINE(MOZ_NATIVE_SQLITE)
6679 AC_SUBST(MOZ_NATIVE_SQLITE)
6681 dnl ========================================================
6682 dnl = Enable help viewer (off by default)
6683 dnl ========================================================
6684 if test -n "$MOZ_HELP_VIEWER"; then
6685      dnl Do this if defined in confvars.sh
6686      AC_DEFINE(MOZ_HELP_VIEWER)
6689 dnl ========================================================
6690 dnl = Enable safe browsing (anti-phishing)
6691 dnl ========================================================
6692 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6693 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6694     MOZ_SAFE_BROWSING=1,
6695     MOZ_SAFE_BROWSING= )
6696 if test -n "$MOZ_SAFE_BROWSING"; then
6697     AC_DEFINE(MOZ_SAFE_BROWSING)
6699 AC_SUBST(MOZ_SAFE_BROWSING)
6701 dnl ========================================================
6702 dnl = Enable url-classifier
6703 dnl ========================================================
6704 dnl Implicitly enabled by default if building with safe-browsing
6705 if test -n "$MOZ_SAFE_BROWSING"; then
6706     MOZ_URL_CLASSIFIER=1
6708 MOZ_ARG_ENABLE_BOOL(url-classifier,
6709 [  --enable-url-classifier Enable url classifier module],
6710     MOZ_URL_CLASSIFIER=1,
6711     MOZ_URL_CLASSIFIER= )
6712 if test -n "$MOZ_URL_CLASSIFIER"; then
6713     AC_DEFINE(MOZ_URL_CLASSIFIER)
6715 AC_SUBST(MOZ_URL_CLASSIFIER)
6717 dnl ========================================================
6718 dnl = Disable zipwriter
6719 dnl ========================================================
6720 MOZ_ARG_DISABLE_BOOL(zipwriter,
6721 [  --disable-zipwriter     Disable zipwriter component],
6722     MOZ_ZIPWRITER=,
6723     MOZ_ZIPWRITER=1 )
6724 AC_SUBST(MOZ_ZIPWRITER)
6726 dnl ========================================================
6727 dnl = libconic
6728 dnl ========================================================
6729 dnl superseded by QtNetwork starting from 4.7
6730 MOZ_ENABLE_LIBCONIC=1
6732 if test -n "$MOZ_ENABLE_QT"; then
6733   if test "$MOZ_ENABLE_QTNETWORK"; then
6734     MOZ_ENABLE_LIBCONIC=
6735   fi
6738 MOZ_ARG_DISABLE_BOOL(libconic,
6739 [  --disable-libconic      Disable libconic],
6740     MOZ_ENABLE_LIBCONIC=,
6741     MOZ_ENABLE_LIBCONIC=1 )
6743 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6744     PKG_CHECK_MODULES(LIBCONIC, conic,
6745                       MOZ_ENABLE_LIBCONIC=1,
6746                       MOZ_ENABLE_LIBCONIC=)
6748 if test "$MOZ_ENABLE_LIBCONIC"; then
6749     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6752 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6753 AC_SUBST(LIBCONIC_CFLAGS)
6754 AC_SUBST(LIBCONIC_LIBS)
6756 dnl ========================================================
6757 dnl = Maemo checks
6758 dnl ========================================================
6760 MAEMO_SDK_TARGET_VER=-1
6762 MOZ_ARG_WITH_STRING(maemo-version,
6763 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6764                           Maemo SDK Version],
6765   MAEMO_SDK_TARGET_VER=$withval)
6767 case "$MAEMO_SDK_TARGET_VER" in
6769     MOZ_PLATFORM_MAEMO=5
6770     ;;
6773     MOZ_PLATFORM_MAEMO=6
6774     ;;
6777     dnl We aren't compiling for Maemo, move on.
6778     ;;
6780     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6781     ;;
6782 esac
6784 if test $MOZ_PLATFORM_MAEMO; then
6785    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6787    if test -z "$MOZ_ENABLE_DBUS"; then
6788        AC_MSG_ERROR([DBus is required when building for Maemo])
6789    fi
6791    MOZ_GFX_OPTIMIZE_MOBILE=1
6792    MOZ_GL_DEFAULT_PROVIDER=EGL
6793    MOZ_MAEMO_LIBLOCATION=
6795    if test $MOZ_PLATFORM_MAEMO = 5; then
6796       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6797       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6798           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6799       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6800                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6802       AC_SUBST(XCOMPOSITE_LIBS)
6804       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6805       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6806       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6807       if test -z "$_LIB_FOUND"; then
6808          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6809       fi
6812       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6813       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6814       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6815       if test -z "$_LIB_FOUND"; then
6816          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6817       fi
6819       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6820       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6821       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6822       if test -z "$_LIB_FOUND"; then
6823          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6824       fi
6826    fi
6827    if test $MOZ_PLATFORM_MAEMO = 6; then
6829       PKG_CHECK_MODULES(LIBCONTENTMANAGER, ContentManager QtSparql,
6830                         _LIB_FOUND=1,
6831                         _LIB_FOUND=)
6832       if test "$_LIB_FOUND"; then
6833          MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTMANAGER_LIBS"
6834          MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTMANAGER_CFLAGS"
6835          MOZ_ENABLE_CONTENTMANAGER=1
6836          AC_DEFINE(MOZ_ENABLE_CONTENTMANAGER)
6837       else
6838          AC_MSG_WARN([Cannot find libcontentmanager and or QtSparql building for Maemo 6])
6839       fi
6840       AC_SUBST(MOZ_ENABLE_CONTENTMANAGER)
6842       dnl ========================================================
6843       dnl = Enable meego libcontentaction
6844       dnl ========================================================
6845       MOZ_ARG_ENABLE_BOOL(meegocontentaction,
6846       [  --enable-meegocontentaction           Enable meegocontentaction support],
6847          MOZ_MEEGOCONTENTACTION=1,
6848          MOZ_MEEGOCONTENTACTION=)
6850       if test -n "$MOZ_MEEGOCONTENTACTION"; then
6852          PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
6853          if test "$_LIB_FOUND"; then
6854             MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
6855             MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
6856             MOZ_ENABLE_CONTENTACTION=1
6857             AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
6858             AC_SUBST(MOZ_ENABLE_CONTENTACTION)
6859          fi
6860       fi
6862       MOZ_ARG_ENABLE_BOOL(meegotouch,
6863       [  --enable-meegotouch  Enable meegotouch support],
6864          MOZ_MEEGOTOUCHENABLED=1,
6865          MOZ_MEEGOTOUCHENABLED=)
6867       if test -n "$MOZ_MEEGOTOUCHENABLED"; then
6868           PKG_CHECK_MODULES(MOZ_MEEGOTOUCH, meegotouchcore, _LIB_FOUND=1, _LIB_FOUND=)
6869           if test "$_LIB_FOUND"; then
6870               MOZ_QT_CFLAGS="$MOZ_MEEGOTOUCH_CFLAGS $MOZ_QT_CFLAGS"
6871               MOZ_QT_LIBS="$MOZ_MEEGOTOUCH_LIBS $MOZ_QT_LIBS"
6872               AC_DEFINE(MOZ_ENABLE_MEEGOTOUCH)
6873           else
6874               AC_MSG_WARN([Cannot meegotouchcore-dev. Disabling Meegotouch support.])
6875           fi
6876       fi
6877    fi
6879    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
6880    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
6881    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
6882    if test "$_LIB_FOUND"; then
6883       MOZ_MAEMO_LIBLOCATION=1
6884       AC_DEFINE(MOZ_MAEMO_LIBLOCATION)
6885    else
6886       AC_MSG_WARN([Cannot liblocation-dev. Disabling Maemo geolocation.])
6887    fi
6888    AC_SUBST(MOZ_MAEMO_LIBLOCATION)
6890    PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=)
6891    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS"
6892    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS"
6893    if test "$_LIB_FOUND"; then
6894       MOZ_ENABLE_MEEGOTOUCHSHARE=1
6895       AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE)
6896    else
6897       AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.])
6898    fi
6899    AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE)
6901    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6902    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6905 dnl ========================================================
6906 dnl = XRender Composite
6907 dnl ========================================================
6908 MOZ_ARG_ENABLE_BOOL(egl-xrender-composite,
6909 [  --enable-egl-xrender-composite
6910                           Enable EGL xrender composite optimizations],
6911     MOZ_EGL_XRENDER_COMPOSITE=1)
6913 if test -n "$MOZ_EGL_XRENDER_COMPOSITE"; then
6914     AC_DEFINE(MOZ_EGL_XRENDER_COMPOSITE)
6917 AC_SUBST(MOZ_EGL_XRENDER_COMPOSITE)
6919 dnl ========================================================
6920 dnl GL provider
6921 dnl ========================================================
6922 MOZ_GL_PROVIDER=
6923 MOZ_ARG_WITH_STRING(gl-provider,
6924 [  --with-gl-provider=ID
6925                           Set GL provider backend type],
6926 [ val=`echo $withval`
6927     MOZ_GL_PROVIDER="$val"])
6929 if test -n "$MOZ_GL_PROVIDER"; then
6930 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6931 AC_SUBST(MOZ_GL_PROVIDER)
6932 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6934 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6936 dnl ========================================================
6937 dnl = faststripe theme
6938 dnl ========================================================
6939 MOZ_ARG_ENABLE_BOOL(faststripe,
6940 [  --enable-faststripe     Use faststripe theme],
6941     MOZ_THEME_FASTSTRIPE=1,
6942     MOZ_THEME_FASTSTRIPE= )
6943 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6945 dnl ========================================================
6946 dnl =
6947 dnl = Feature options that require extra sources to be pulled
6948 dnl =
6949 dnl ========================================================
6950 dnl MOZ_ARG_HEADER(Features that require extra sources)
6952 dnl ========================================================
6953 dnl =
6954 dnl = Debugging Options
6955 dnl =
6956 dnl ========================================================
6957 MOZ_ARG_HEADER(Debugging and Optimizations)
6959 dnl ========================================================
6960 dnl = Disable building with debug info.
6961 dnl = Debugging is OFF by default
6962 dnl ========================================================
6963 if test -z "$MOZ_DEBUG_FLAGS"; then
6964   MOZ_DEBUG_FLAGS="-g"
6967 MOZ_ARG_ENABLE_STRING(debug,
6968 [  --enable-debug[=DBG]    Enable building with developer debug info
6969                            (using compiler flags DBG)],
6970 [ if test "$enableval" != "no"; then
6971     MOZ_DEBUG=1
6972     if test -n "$enableval" -a "$enableval" != "yes"; then
6973         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6974         _MOZ_DEBUG_FLAGS_SET=1
6975     fi
6976   else
6977     MOZ_DEBUG=
6978   fi ],
6979   MOZ_DEBUG=)
6981 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
6982 MOZ_ARG_WITH_STRING(debug-label,
6983 [  --with-debug-label=LABELS
6984                           Define DEBUG_<value> for each comma-separated
6985                           value given.],
6986 [ for option in `echo $withval | sed 's/,/ /g'`; do
6987     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
6988 done])
6990 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
6992 if test -n "$MOZ_DEBUG"; then
6993     AC_MSG_CHECKING([for valid debug flags])
6994     _SAVE_CFLAGS=$CFLAGS
6995     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
6996     AC_TRY_COMPILE([#include <stdio.h>],
6997         [printf("Hello World\n");],
6998         _results=yes,
6999         _results=no)
7000     AC_MSG_RESULT([$_results])
7001     if test "$_results" = "no"; then
7002         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
7003     fi
7004     CFLAGS=$_SAVE_CFLAGS
7007 dnl ========================================================
7008 dnl enable mobile optimizations
7009 dnl ========================================================
7010 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
7011 [  --enable-mobile-optimize
7012                           Enable mobile optimizations],
7013     MOZ_GFX_OPTIMIZE_MOBILE=1)
7015 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
7017 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
7018     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
7021 dnl ========================================================
7022 dnl = Enable code optimization. ON by default.
7023 dnl ========================================================
7024 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
7025         MOZ_OPTIMIZE_FLAGS="-O"
7028 MOZ_ARG_ENABLE_STRING(optimize,
7029 [  --disable-optimize      Disable compiler optimization
7030   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
7031 [ if test "$enableval" != "no"; then
7032     MOZ_OPTIMIZE=1
7033     if test -n "$enableval" -a "$enableval" != "yes"; then
7034         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
7035         MOZ_OPTIMIZE=2
7036     fi
7037 else
7038     MOZ_OPTIMIZE=
7039 fi ], MOZ_OPTIMIZE=1)
7041 MOZ_SET_FRAMEPTR_FLAGS
7043 if test "$COMPILE_ENVIRONMENT"; then
7044 if test -n "$MOZ_OPTIMIZE"; then
7045     AC_MSG_CHECKING([for valid optimization flags])
7046     _SAVE_CFLAGS=$CFLAGS
7047     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
7048     AC_TRY_COMPILE([#include <stdio.h>],
7049         [printf("Hello World\n");],
7050         _results=yes,
7051         _results=no)
7052     AC_MSG_RESULT([$_results])
7053     if test "$_results" = "no"; then
7054         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
7055     fi
7056     CFLAGS=$_SAVE_CFLAGS
7058 fi # COMPILE_ENVIRONMENT
7060 AC_SUBST(MOZ_OPTIMIZE)
7061 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
7062 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
7063 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
7064 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
7065 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
7067 dnl ========================================================
7068 dnl = Enable generation of debug symbols
7069 dnl ========================================================
7070 MOZ_ARG_ENABLE_STRING(debug-symbols,
7071 [  --enable-debug-symbols[=DBG]
7072                           Enable debugging symbols (using compiler flags DBG)],
7073 [ if test "$enableval" != "no"; then
7074       MOZ_DEBUG_SYMBOLS=1
7075       if test -n "$enableval" -a "$enableval" != "yes"; then
7076           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
7077               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
7078           else
7079               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
7080           fi
7081       fi
7082   else
7083       MOZ_DEBUG_SYMBOLS=
7084   fi ],
7085   MOZ_DEBUG_SYMBOLS=1)
7087 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
7088     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
7089     export MOZ_DEBUG_SYMBOLS
7092 dnl ========================================================
7093 dnl = Enable any treating of compile warnings as errors
7094 dnl ========================================================
7095 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
7096 [  --enable-warnings-as-errors
7097                           Enable treating of warnings as errors],
7098     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
7099     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
7100 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
7101    WARNINGS_AS_ERRORS=''
7104 dnl ========================================================
7105 dnl = Disable runtime logging checks
7106 dnl ========================================================
7107 MOZ_ARG_DISABLE_BOOL(logging,
7108 [  --disable-logging       Disable logging facilities],
7109     NS_DISABLE_LOGGING=1,
7110     NS_DISABLE_LOGGING= )
7111 if test "$NS_DISABLE_LOGGING"; then
7112     AC_DEFINE(NS_DISABLE_LOGGING)
7113 else
7114     AC_DEFINE(MOZ_LOGGING)
7117 dnl ========================================================
7118 dnl = This will enable logging of addref, release, ctor, dtor.
7119 dnl ========================================================
7120 _ENABLE_LOGREFCNT=42
7121 MOZ_ARG_ENABLE_BOOL(logrefcnt,
7122 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
7123     _ENABLE_LOGREFCNT=1,
7124     _ENABLE_LOGREFCNT= )
7125 if test "$_ENABLE_LOGREFCNT" = "1"; then
7126     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
7127 elif test -z "$_ENABLE_LOGREFCNT"; then
7128     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
7131 dnl ========================================================
7132 dnl moz_dump_painting
7133 dnl ========================================================
7134 MOZ_ARG_ENABLE_BOOL(dump-painting,
7135 [  --enable-dump-painting          Enable paint debugging.],
7136     MOZ_DUMP_PAINTING=1,
7137     MOZ_DUMP_PAINTING= )
7138 if test -n "$MOZ_DUMP_PAINTING"; then
7139     AC_DEFINE(MOZ_DUMP_PAINTING)
7140     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
7142 if test -n "$MOZ_DEBUG"; then
7143     AC_DEFINE(MOZ_DUMP_PAINTING)
7146 dnl ========================================================
7147 dnl = Enable trace malloc
7148 dnl ========================================================
7149 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
7150 MOZ_ARG_ENABLE_BOOL(trace-malloc,
7151 [  --enable-trace-malloc   Enable malloc tracing; also disables jemalloc],
7152     NS_TRACE_MALLOC=1,
7153     NS_TRACE_MALLOC= )
7154 if test "$NS_TRACE_MALLOC"; then
7155   # Please, Mr. Linker Man, don't take away our symbol names
7156   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
7157   USE_ELF_DYNSTR_GC=
7158   AC_DEFINE(NS_TRACE_MALLOC)
7160 AC_SUBST(NS_TRACE_MALLOC)
7162 dnl ========================================================
7163 dnl = Enable jemalloc
7164 dnl ========================================================
7165 MOZ_ARG_ENABLE_BOOL(jemalloc,
7166 [  --enable-jemalloc       Replace memory allocator with jemalloc],
7167     MOZ_MEMORY=1,
7168     MOZ_MEMORY=)
7170 if test "$NS_TRACE_MALLOC"; then
7171     MOZ_MEMORY=
7173 if test "$MOZ_DMD"; then
7174     MOZ_MEMORY=
7177 if test "${OS_TARGET}" = "Android"; then
7178   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
7179   :
7180 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
7181   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
7182   if test -z "$GNU_CC"; then
7183     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7184   else
7185     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
7186   fi
7187 else
7188   dnl On other Unix systems, we only want to link executables against mozglue
7189   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib) $(MKSHLIB_UNFORCE_ALL)'
7190   if test -n "$GNU_CC"; then
7191     dnl And we need mozglue symbols to be exported.
7192     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
7193   fi
7194   if test "$MOZ_LINKER" = 1; then
7195     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $ZLIB_LIBS"
7196   fi
7199 if test -z "$MOZ_MEMORY"; then
7200   case "${target}" in
7201     *-mingw*)
7202       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7203         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.])
7204       fi
7205       ;;
7206   esac
7207 else
7208   dnl Don't try to run compiler tests on Windows
7209   if test "$OS_ARCH" = "WINNT"; then
7210     if test -z "$HAVE_64BIT_OS"; then
7211       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7212     else
7213       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7214     fi
7215   else
7216     AC_CHECK_SIZEOF([int *], [4])
7217     case "${ac_cv_sizeof_int_p}" in
7218     4)
7219       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7220       ;;
7221     8)
7222       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7223       ;;
7224     *)
7225       AC_MSG_ERROR([Unexpected pointer size])
7226       ;;
7227     esac
7228   fi
7230   AC_DEFINE(MOZ_MEMORY)
7231   if test "x$MOZ_DEBUG" = "x1"; then
7232     AC_DEFINE(MOZ_MEMORY_DEBUG)
7233   fi
7234   dnl The generic feature tests that determine how to compute ncpus are long and
7235   dnl complicated.  Therefore, simply define special cpp variables for the
7236   dnl platforms we have special knowledge of.
7237   case "${target}" in
7238   *-darwin*)
7239     AC_DEFINE(MOZ_MEMORY_DARWIN)
7240     ;;
7241   *-*freebsd*)
7242     AC_DEFINE(MOZ_MEMORY_BSD)
7243     ;;
7244   *-android*|*-linuxandroid*)
7245     AC_DEFINE(MOZ_MEMORY_LINUX)
7246     AC_DEFINE(MOZ_MEMORY_ANDROID)
7247     _WRAP_MALLOC=1
7248     MOZ_GLUE_LDFLAGS=
7249     ;;
7250   *-*linux*)
7251     AC_DEFINE(MOZ_MEMORY_LINUX)
7252     ;;
7253   *-netbsd*)
7254     AC_DEFINE(MOZ_MEMORY_BSD)
7255     ;;
7256   *-solaris*)
7257     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7258     ;;
7259   *-mingw*)
7260     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7261     if test -z "$MOZ_DEBUG"; then
7262       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7263     else
7264       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7265     fi
7266     dnl Look for a broken crtdll.obj
7267     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7268     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7269     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7270       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7271       dnl Also pass this to NSPR/NSS
7272       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7273     else
7274       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7275     fi
7276     rm crtdll.obj
7278     export DLLFLAGS
7279     ;;
7280   *)
7281     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7282     ;;
7283   esac
7284 fi # MOZ_MEMORY
7285 AC_SUBST(MOZ_MEMORY)
7286 AC_SUBST(MOZ_GLUE_LDFLAGS)
7287 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7288 AC_SUBST(WIN32_CRT_LIBS)
7289 dnl Need to set this for make because NSS doesn't have configure
7290 AC_SUBST(DLLFLAGS)
7292 dnl We need to wrap dlopen and related functions on Android because we use
7293 dnl our own linker.
7294 if test "$OS_TARGET" = Android; then
7295     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7296     if test -n "$MOZ_OLD_LINKER"; then
7297         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
7298     fi
7299     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7300     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7303 dnl ========================================================
7304 dnl = Use malloc wrapper lib
7305 dnl ========================================================
7306 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7307 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7308     _WRAP_MALLOC=1,
7309     _WRAP_MALLOC= )
7311 if test -n "$_WRAP_MALLOC"; then
7312     if test -n "$GNU_CC"; then
7313         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7314         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7315         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7316         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7317     else
7318         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7319     fi
7322 dnl ========================================================
7323 dnl = Location of malloc wrapper lib
7324 dnl ========================================================
7325 MOZ_ARG_WITH_STRING(wrap-malloc,
7326 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7327     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7329 dnl ========================================================
7330 dnl = Use JS Call tracing
7331 dnl ========================================================
7332 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7333 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7334     MOZ_TRACE_JSCALLS=1,
7335     MOZ_TRACE_JSCALLS= )
7336 if test -n "$MOZ_TRACE_JSCALLS"; then
7337     AC_DEFINE(MOZ_TRACE_JSCALLS)
7340 dnl ========================================================
7341 dnl = Use incremental GC
7342 dnl ========================================================
7343 JSGC_INCREMENTAL=1
7344 MOZ_ARG_DISABLE_BOOL(gcincremental,
7345 [  --disable-gcincremental Disable incremental GC],
7346     JSGC_INCREMENTAL= )
7347 if test -n "$JSGC_INCREMENTAL"; then
7348     AC_DEFINE(JSGC_INCREMENTAL)
7351 dnl ========================================================
7352 dnl ETW - Event Tracing for Windows
7353 dnl ========================================================
7354 MOZ_ARG_ENABLE_BOOL(ETW,
7355 [  --enable-ETW            Enable ETW (Event Tracing for Windows) event reporting],
7356     MOZ_ETW=1,
7357     MOZ_ETW= )
7358 if test -n "$MOZ_ETW"; then
7359     AC_DEFINE(MOZ_ETW)
7362 if test -n "$MOZ_ETW"; then
7363     if test -z "$MOZ_WINSDK_TARGETVER"; then
7364         AC_MSG_ERROR([--enable-ETW is only valid on Windows])
7365     fi
7368 dnl ========================================================
7369 dnl Zealous JavaScript GC
7370 dnl ========================================================
7371 MOZ_ARG_ENABLE_BOOL(gczeal,
7372 [  --enable-gczeal         Enable zealous JavaScript GCing],
7373     JS_GC_ZEAL=1,
7374     JS_GC_ZEAL= )
7375 if test -n "$JS_GC_ZEAL"; then
7376     AC_DEFINE(JS_GC_ZEAL)
7379 dnl ========================================================
7380 dnl JS opt-mode assertions and minidump instrumentation
7381 dnl ========================================================
7382 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7383 [  --enable-js-diagnostics
7384                           Enable JS diagnostic assertions and breakpad data],
7385     JS_CRASH_DIAGNOSTICS=1,
7386     JS_CRASH_DIAGNOSTICS= )
7387 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7388     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7391 dnl ======================================================
7392 dnl = Enable compiling with ccache
7393 dnl ======================================================
7394 MOZ_ARG_WITH_STRING(ccache,
7395 [  --with-ccache[=path/to/ccache]
7396                           Enable compiling with ccache],
7397     CCACHE=$withval, CCACHE="no")
7399 if test "$CCACHE" != "no"; then
7400     if test -z "$CCACHE" -o "$CCACHE" = "yes"; then
7401         CCACHE=
7402     else
7403         if test ! -e "$CCACHE"; then
7404             AC_MSG_ERROR([$CCACHE not found])
7405         fi
7406     fi
7407     MOZ_PATH_PROGS(CCACHE, $CCACHE ccache)
7408     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
7409         AC_MSG_ERROR([ccache not found])
7410     elif test -x "$CCACHE"; then
7411         CC="$CCACHE $CC"
7412         CXX="$CCACHE $CXX"
7413     else
7414         AC_MSG_ERROR([$CCACHE is not executable])
7415     fi
7418 dnl ========================================================
7419 dnl = Enable static checking using gcc-dehydra
7420 dnl ========================================================
7422 MOZ_ARG_WITH_STRING(static-checking,
7423 [  --with-static-checking=path/to/gcc_dehydra.so
7424                           Enable static checking of code using GCC-dehydra],
7425     DEHYDRA_PATH=$withval,
7426     DEHYDRA_PATH= )
7428 if test -n "$DEHYDRA_PATH"; then
7429     if test ! -f "$DEHYDRA_PATH"; then
7430         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7431     fi
7432     AC_DEFINE(NS_STATIC_CHECKING)
7434 AC_SUBST(DEHYDRA_PATH)
7436 dnl ========================================================
7437 dnl = Enable stripping of libs & executables
7438 dnl ========================================================
7439 MOZ_ARG_ENABLE_BOOL(strip,
7440 [  --enable-strip          Enable stripping of libs & executables ],
7441     ENABLE_STRIP=1,
7442     ENABLE_STRIP= )
7444 dnl ========================================================
7445 dnl = Enable stripping of libs & executables when packaging
7446 dnl ========================================================
7447 MOZ_ARG_ENABLE_BOOL(install-strip,
7448 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7449     PKG_SKIP_STRIP= ,
7450     PKG_SKIP_STRIP=1)
7452 dnl ========================================================
7453 dnl = --enable-elf-dynstr-gc
7454 dnl ========================================================
7455 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7456 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7457     USE_ELF_DYNSTR_GC=1,
7458     USE_ELF_DYNSTR_GC= )
7460 dnl ========================================================
7461 dnl = --disable-elf-hack
7462 dnl ========================================================
7464 USE_ELF_HACK=1
7465 MOZ_ARG_DISABLE_BOOL(elf-hack,
7466 [  --disable-elf-hack      Disable elf hacks],
7467     USE_ELF_HACK=,
7468     USE_ELF_HACK=1)
7470 # Only enable elfhack where supported
7471 if test "$USE_ELF_HACK" = 1; then
7472     case "${HOST_OS_ARCH},${OS_ARCH}" in
7473     Linux,Linux)
7474         case "${CPU_ARCH}" in
7475         arm | x86 | x86_64)
7476             USE_ELF_HACK=1
7477             ;;
7478         *)
7479             USE_ELF_HACK=
7480             ;;
7481         esac
7482         ;;
7483     *)
7484         USE_ELF_HACK=
7485         ;;
7486     esac
7489 if test "$USE_ELF_HACK" = 1; then
7490     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7491     dnl memory addresses it maps to. The result is that by the time elfhack
7492     dnl kicks in, it is not possible to apply relocations because of that,
7493     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7494     dnl segment. It makes elfhack mostly useless, so considering the problems
7495     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7496     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7497     dnl the linker creates PT_GNU_RELRO segments.
7498     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7499         LINK_WITH_PT_GNU_RELRO,
7500         [echo "int main() {return 0;}" > conftest.${ac_ext}
7501          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7502             test -s conftest${ac_exeext}; then
7503             if readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7504                 LINK_WITH_PT_GNU_RELRO=yes
7505             else
7506                 LINK_WITH_PT_GNU_RELRO=no
7507             fi
7508          else
7509              dnl We really don't expect to get here, but just in case
7510              AC_ERROR([couldn't compile a simple C file])
7511          fi
7512          rm -rf conftest*])
7513     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7514         AC_MSG_WARN([Disabling elfhack])
7515         USE_ELF_HACK=
7516     fi
7519 dnl ========================================================
7520 dnl = libstdc++ compatibility hacks
7521 dnl ========================================================
7523 STDCXX_COMPAT=
7524 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7525 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7526     STDCXX_COMPAT=stdc++compat.cpp)
7528 AC_SUBST(STDCXX_COMPAT)
7530 if test -n "$STDCXX_COMPAT"; then
7531    eval $(CXX="$CXX" MACOS_SDK_DIR="$MACOS_SDK_DIR" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7532    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7533    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7536 dnl ========================================================
7537 dnl =
7538 dnl = Profiling and Instrumenting
7539 dnl =
7540 dnl ========================================================
7541 MOZ_ARG_HEADER(Profiling and Instrumenting)
7543 dnl ========================================================
7544 dnl = Enable NS_FUNCTION_TIMER, which provides Function
7545 dnl = timing for identifying code bottlenecks
7546 dnl = NS_FUNCTION_TIMER is off by default.
7547 dnl ========================================================
7548 MOZ_ARG_ENABLE_BOOL(functiontimer,
7549 [  --enable-functiontimer  Enable NS_FUNCTION_TIMER ],
7550     NS_FUNCTION_TIMER=1,
7551     NS_FUNCTION_TIMER= )
7552 if test -n "$NS_FUNCTION_TIMER"; then
7553     AC_DEFINE(NS_FUNCTION_TIMER)
7556 dnl ========================================================
7557 dnl Turn on reflow counting
7558 dnl ========================================================
7559 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7560 [  --enable-reflow-perf    Enable reflow performance tracing],
7561     MOZ_REFLOW_PERF=1,
7562     MOZ_REFLOW_PERF= )
7563 if test -n "$MOZ_REFLOW_PERF"; then
7564     AC_DEFINE(MOZ_REFLOW_PERF)
7567 dnl ========================================================
7568 dnl Enable code size metrics.
7569 dnl ========================================================
7570 MOZ_ARG_ENABLE_BOOL(codesighs,
7571 [  --enable-codesighs      Enable code size analysis tools],
7572     _ENABLE_CODESIGHS=1,
7573     _ENABLE_CODESIGHS= )
7574 if test -n "$_ENABLE_CODESIGHS"; then
7575     if test -d $srcdir/tools/codesighs; then
7576         MOZ_MAPINFO=1
7577     else
7578         AC_MSG_ERROR([Codesighs directory $srcdir/tools/codesighs required.])
7579     fi
7582 dnl ========================================================
7583 dnl = Support for Quantify (Windows)
7584 dnl ========================================================
7585 MOZ_ARG_ENABLE_BOOL(quantify,
7586 [  --enable-quantify       Enable Quantify support (Windows only) ],
7587     MOZ_QUANTIFY=1,
7588     MOZ_QUANTIFY= )
7590 dnl ========================================================
7591 dnl = Enable Radio Interface for B2G (Gonk usually)
7592 dnl ========================================================
7593 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7594 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7595     MOZ_B2G_RIL=1,
7596     MOZ_B2G_RIL= )
7597 if test -n "$MOZ_B2G_RIL"; then
7598    AC_DEFINE(MOZ_B2G_RIL)
7600 AC_SUBST(MOZ_B2G_RIL)
7602 dnl ========================================================
7603 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7604 dnl ========================================================
7605 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7606 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7607     MOZ_B2G_BT=1,
7608     MOZ_B2G_BT= )
7609 if test -n "$MOZ_B2G_BT"; then
7610    AC_DEFINE(MOZ_B2G_BT)
7612 AC_SUBST(MOZ_B2G_BT)
7614 dnl ========================================================
7615 dnl = Support for demangling undefined symbols
7616 dnl ========================================================
7617 if test -z "$SKIP_LIBRARY_CHECKS"; then
7618     AC_LANG_SAVE
7619     AC_LANG_CPLUSPLUS
7620     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7621     AC_LANG_RESTORE
7624 # Demangle only for debug or trace-malloc builds
7625 MOZ_DEMANGLE_SYMBOLS=
7626 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
7627     MOZ_DEMANGLE_SYMBOLS=1
7628     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7630 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7632 dnl ========================================================
7633 dnl = Support for gcc stack unwinding (from gcc 3.3)
7634 dnl ========================================================
7635 if test -z "$SKIP_LIBRARY_CHECKS"; then
7636     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7639 dnl ========================================================
7640 dnl JIT observers
7641 dnl ========================================================
7643 MOZ_ARG_WITH_STRING(jitreport-granularity,
7644 [  --jitreport-granularity=N
7645                            Default granularity at which to report JIT code
7646                            to external tools
7647                              0 - no info
7648                              1 - code ranges for whole functions only
7649                              2 - per-line information
7650                              3 - per-op information],
7651   JITREPORT_GRANULARITY=$withval,
7652   JITREPORT_GRANULARITY=3)
7654 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7656 dnl ========================================================
7657 dnl =
7658 dnl = Misc. Options
7659 dnl =
7660 dnl ========================================================
7661 MOZ_ARG_HEADER(Misc. Options)
7663 dnl ========================================================
7664 dnl update xterm title
7665 dnl ========================================================
7666 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7667 [  --enable-xterm-updates  Update XTERM titles with current command.],
7668     MOZ_UPDATE_XTERM=1,
7669     MOZ_UPDATE_XTERM= )
7671 dnl =========================================================
7672 dnl = Chrome format
7673 dnl =========================================================
7674 MOZ_ARG_ENABLE_STRING([chrome-format],
7675 [  --enable-chrome-format=jar|flat|both|symlink|omni
7676                           Select FORMAT of chrome files (default=jar)],
7677     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7679 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7680     MOZ_CHROME_FILE_FORMAT=jar
7683 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7684     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7685     test "$MOZ_CHROME_FILE_FORMAT" != "symlink" &&
7686     test "$MOZ_CHROME_FILE_FORMAT" != "both" &&
7687     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7688     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, symlink, or omni])
7691 dnl =========================================================
7692 dnl Omnijar packaging (bug 552121)
7693 dnl =========================================================
7694 dnl Omnijar packaging is compatible with flat packaging.
7695 dnl In unpackaged builds, omnijar looks for files as if
7696 dnl things were flat packaged. After packaging, all files
7697 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7698 dnl is set to flat since putting files into jars is only
7699 dnl done during packaging with omnijar.
7700 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7701     MOZ_OMNIJAR=1
7702     AC_DEFINE(MOZ_OMNIJAR)
7703     if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$OS_TARGET" = "Android"; then
7704         MOZ_CHROME_FILE_FORMAT=flat
7705     else
7706         MOZ_CHROME_FILE_FORMAT=symlink
7707     fi
7708 elif test "$MOZ_CHROME_FILE_FORMAT" = "jar"; then
7709     AC_DEFINE(MOZ_CHROME_FILE_FORMAT_JAR)
7712 OMNIJAR_NAME=omni.ja
7713 AC_SUBST(OMNIJAR_NAME)
7714 AC_SUBST(MOZ_OMNIJAR)
7716 dnl ========================================================
7717 dnl = Define default location for MOZILLA_FIVE_HOME
7718 dnl ========================================================
7719 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7720 [  --with-default-mozilla-five-home
7721                           Set the default value for MOZILLA_FIVE_HOME],
7722 [ val=`echo $withval`
7723   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7725 dnl ========================================================
7726 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7727 dnl ========================================================
7728 MOZ_ARG_WITH_STRING(user-appdir,
7729 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7730 [ val=`echo $withval`
7731 if echo "$val" | grep "\/" >/dev/null; then
7732     AC_MSG_ERROR("Homedir must be single relative path.")
7733 else
7734     MOZ_USER_DIR="$val"
7735 fi])
7737 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7739 dnl ========================================================
7740 dnl = Doxygen configuration
7741 dnl ========================================================
7742 dnl Use commas to specify multiple dirs to this arg
7743 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7744 MOZ_ARG_WITH_STRING(doc-input-dirs,
7745 [  --with-doc-input-dirs=DIRS
7746                           Header/idl dirs to create docs from],
7747 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7748 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7750 dnl Use commas to specify multiple dirs to this arg
7751 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7752 MOZ_ARG_WITH_STRING(doc-include-dirs,
7753 [  --with-doc-include-dirs=DIRS
7754                           Include dirs to preprocess doc headers],
7755 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7756 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7758 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7759 MOZ_ARG_WITH_STRING(doc-output-dir,
7760 [  --with-doc-output-dir=DIR
7761                           Dir to generate docs into],
7762 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7763 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7765 if test -z "$SKIP_COMPILER_CHECKS"; then
7766 dnl ========================================================
7767 dnl =
7768 dnl = Compiler Options
7769 dnl =
7770 dnl ========================================================
7771 MOZ_ARG_HEADER(Compiler Options)
7773 dnl ========================================================
7774 dnl Check for gcc -pipe support
7775 dnl ========================================================
7776 AC_MSG_CHECKING([for -pipe support])
7777 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7778     dnl Any gcc that supports firefox supports -pipe.
7779     CFLAGS="$CFLAGS -pipe"
7780     CXXFLAGS="$CXXFLAGS -pipe"
7781     AC_MSG_RESULT([yes])
7782 else
7783     AC_MSG_RESULT([no])
7786 dnl ========================================================
7787 dnl Profile guided optimization (gcc checks)
7788 dnl ========================================================
7789 dnl Test for profiling options
7790 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7792 _SAVE_CFLAGS="$CFLAGS"
7793 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7795 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7796 AC_TRY_COMPILE([], [return 0;],
7797                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7798                  result="yes" ], result="no")
7799 AC_MSG_RESULT([$result])
7801 if test $result = "yes"; then
7802   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7803   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7804   PROFILE_USE_LDFLAGS="-fprofile-use"
7807 CFLAGS="$_SAVE_CFLAGS"
7809 if test -n "$INTEL_CC"; then
7810   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7811   PROFILE_GEN_LDFLAGS=
7812   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7813   PROFILE_USE_LDFLAGS=
7816 dnl Sun Studio on Solaris
7817 if test "$SOLARIS_SUNPRO_CC"; then
7818   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7819   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7820   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7821   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7824 AC_SUBST(PROFILE_GEN_CFLAGS)
7825 AC_SUBST(PROFILE_GEN_LDFLAGS)
7826 AC_SUBST(PROFILE_USE_CFLAGS)
7827 AC_SUBST(PROFILE_USE_LDFLAGS)
7829 AC_LANG_CPLUSPLUS
7831 dnl ========================================================
7832 dnl Test for -pedantic bustage
7833 dnl ========================================================
7834 MOZ_ARG_DISABLE_BOOL(pedantic,
7835 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],
7836 _PEDANTIC= )
7837 if test "$_PEDANTIC"; then
7838     _SAVE_CXXFLAGS=$CXXFLAGS
7839     CXXFLAGS="$CXXFLAGS -pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7840     AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
7841     AC_TRY_COMPILE([$configure_static_assert_macros],
7842                    [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
7843                    result="no", result="yes" )
7844     AC_MSG_RESULT([$result])
7845     CXXFLAGS="$_SAVE_CXXFLAGS"
7847     case "$result" in
7848     no)
7849         _WARNINGS_CFLAGS="-pedantic ${_WARNINGS_CFLAGS} -Wno-long-long"
7850         _WARNINGS_CXXFLAGS="-pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7851         ;;
7852     yes)
7853         AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic.  Reconfigure using --disable-pedantic. ])
7854         ;;
7855     esac
7858 dnl ========================================================
7859 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7860 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7861 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7862 dnl ========================================================
7863 _SAVE_CXXFLAGS=$CXXFLAGS
7864 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7865 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7866     ac_nscap_nonconst_opeq_bug,
7867     [AC_TRY_COMPILE([
7868                       template <class T>
7869                       class Pointer
7870                         {
7871                         public:
7872                           T* myPtr;
7873                         };
7875                       template <class T, class U>
7876                       int operator==(const Pointer<T>& rhs, U* lhs)
7877                         {
7878                           return rhs.myPtr == lhs;
7879                         }
7881                       template <class T, class U>
7882                       int operator==(const Pointer<T>& rhs, const U* lhs)
7883                         {
7884                           return rhs.myPtr == lhs;
7885                         }
7886                     ],
7887                     [
7888                       Pointer<int> foo;
7889                       const int* bar;
7890                       return foo == bar;
7891                     ],
7892                     ac_nscap_nonconst_opeq_bug="no",
7893                     ac_nscap_nonconst_opeq_bug="yes")])
7894 CXXFLAGS="$_SAVE_CXXFLAGS"
7896 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7897     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7899 fi # ! SKIP_COMPILER_CHECKS
7901 AC_DEFINE(CPP_THROW_NEW, [throw()])
7902 AC_LANG_C
7904 if test "$COMPILE_ENVIRONMENT"; then
7905 MOZ_EXPAND_LIBS
7906 fi # COMPILE_ENVIRONMENT
7908 dnl ========================================================
7909 dnl =
7910 dnl = Build depencency options
7911 dnl =
7912 dnl ========================================================
7913 MOZ_ARG_HEADER(Build dependencies)
7915 dnl ========================================================
7916 dnl = Do not auto generate dependency info
7917 dnl ========================================================
7918 MOZ_AUTO_DEPS=1
7919 MOZ_ARG_DISABLE_BOOL(auto-deps,
7920 [  --disable-auto-deps     Do not automatically generate dependency info],
7921     MOZ_AUTO_DEPS=,
7922     MOZ_AUTO_DEPS=1)
7924 if test -n "$MOZ_AUTO_DEPS"; then
7925 dnl ========================================================
7926 dnl = Use mkdepend instead of $CC -MD for dependency generation
7927 dnl ========================================================
7928 _cpp_md_flag=
7929 MOZ_ARG_DISABLE_BOOL(md,
7930 [  --disable-md            Do not use compiler-based dependencies ],
7931   [_cpp_md_flag=],
7932   [_cpp_md_flag=1],
7933   [dnl Default is to turn on -MD if using GNU-compatible compilers
7934    if test "$GNU_CC" -a "$GNU_CXX"; then
7935      _cpp_md_flag=1
7936    fi
7937   dnl Default is to use -xM if using Sun Studio on Solaris
7938    if test "$SOLARIS_SUNPRO_CC"; then
7939      _cpp_md_flag=1
7940    fi])
7941 if test "$_cpp_md_flag"; then
7942   COMPILER_DEPEND=1
7943   _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(basename $(@F)).pp)'
7944   dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7945   if test "$SOLARIS_SUNPRO_CC"; then
7946     _DEPEND_CFLAGS=
7947   fi
7948 else
7949   COMPILER_DEPEND=
7950   dnl Don't override this for MSVC
7951   if test -z "$_WIN32_MSVC"; then
7952     _USE_CPP_INCLUDE_FLAG=
7953     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7954     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7955   else
7956     echo '#include <stdio.h>' > dummy-hello.c
7957     changequote(,)
7958     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
7959     changequote([,])
7960     if test -z "$CL_INCLUDES_PREFIX"; then
7961         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7962     fi
7963     AC_SUBST(CL_INCLUDES_PREFIX)
7964     rm -f dummy-hello.c
7965     _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
7966     dnl cl.py provides dependency generation for MSVC
7967     CC_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
7968     CXX_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
7969     COMPILER_DEPEND=1
7970   fi
7972 fi # MOZ_AUTO_DEPS
7973 MDDEPDIR='.deps'
7974 AC_SUBST(MOZ_AUTO_DEPS)
7975 AC_SUBST(COMPILER_DEPEND)
7976 AC_SUBST(MDDEPDIR)
7977 AC_SUBST(CC_WRAPPER)
7978 AC_SUBST(CXX_WRAPPER)
7981 dnl ========================================================
7982 dnl =
7983 dnl = Static Build Options
7984 dnl =
7985 dnl ========================================================
7986 MOZ_ARG_HEADER(Static build options)
7988 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
7989 if test "$OS_ARCH" = "WINNT" -a "$CPU_ARCH" != "x86_64" ; then
7990   ENABLE_SHARED_JS=1
7993 MOZ_ARG_ENABLE_BOOL(shared-js,
7994 [  --enable-shared-js
7995                           Create a shared JavaScript library.],
7996     ENABLE_SHARED_JS=1,
7997     ENABLE_SHARED_JS=)
7999 if test -n "$ENABLE_SHARED_JS"; then
8000   JS_SHARED_LIBRARY=1
8001   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
8002 else
8003   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
8004   AC_DEFINE(MOZ_STATIC_JS)
8006 AC_SUBST(JS_SHARED_LIBRARY)
8008 AC_SUBST(LIBXUL_LIBS)
8009 XPCOM_LIBS="$LIBXUL_LIBS"
8011 dnl ========================================================
8012 dnl =
8013 dnl = Standalone module options
8014 dnl =
8015 dnl ========================================================
8016 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
8018 dnl Check for GLib.
8019 dnl ========================================================
8021 if test -z "$SKIP_PATH_CHECKS"; then
8022 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
8023     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
8024         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
8025     else
8026         AM_PATH_GLIB(${GLIB_VERSION})
8027     fi
8031 if test -z "${GLIB_GMODULE_LIBS}" \
8032    -a -n "${GLIB_CONFIG}"\
8033     -a "${GLIB_CONFIG}" != no\
8034 ; then
8035     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
8038 AC_SUBST(GLIB_CFLAGS)
8039 AC_SUBST(GLIB_LIBS)
8040 AC_SUBST(GLIB_GMODULE_LIBS)
8042 dnl ========================================================
8043 dnl Graphics checks.
8044 dnl ========================================================
8046 if test "${OS_ARCH}" = "Darwin" -o "${MOZ_WIDGET_TOOLKIT}" = "android" -o "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
8047 MOZ_ENABLE_SKIA=1
8048 else
8049 MOZ_ENABLE_SKIA=
8052 MOZ_ARG_ENABLE_BOOL(skia,
8053 [  --enable-skia   Enable use of Skia],
8054 MOZ_ENABLE_SKIA=1,
8055 MOZ_ENABLE_SKIA=)
8057 dnl ========================================================
8058 dnl Check for cairo
8059 dnl ========================================================
8060 MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8062 MOZ_TREE_CAIRO=1
8063 MOZ_ARG_ENABLE_BOOL(system-cairo,
8064 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8065 MOZ_TREE_CAIRO=,
8066 MOZ_TREE_CAIRO=1 )
8068 MOZ_TREE_PIXMAN=1
8069 MOZ_ARG_ENABLE_BOOL(system-pixman,
8070 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8071 MOZ_TREE_PIXMAN=,
8072 MOZ_TREE_PIXMAN=1 )
8074 # Check for headers defining standard int types.
8075 MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8077 if test "$MOZ_TREE_CAIRO"; then
8078     AC_DEFINE(MOZ_TREE_CAIRO)
8080     # For now we assume that we will have a uint64_t available through
8081     # one of the above headers or mozstdint.h.
8082     AC_DEFINE(HAVE_UINT64_T)
8084     # Define macros for cairo-features.h
8085     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8086     if test "$MOZ_X11"; then
8087         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8088         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8089         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8090         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8091         MOZ_ENABLE_CAIRO_FT=1
8092         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8093     fi
8094     case "$MOZ_WIDGET_TOOLKIT" in
8095       qt)
8096         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8097         ;;
8098       cocoa | uikit)
8099         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8100         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8101         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8102         ;;
8103       windows)
8104         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8105         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8106         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8107             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8108             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8109             MOZ_ENABLE_D2D_SURFACE=1
8110             MOZ_ENABLE_DWRITE_FONT=1
8111         else
8112             WIN32_DWRITE_FONT_FEATURE=
8113             WIN32_D2D_SURFACE_FEATURE=
8114         fi
8116         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8118         dnl D3D10 Layers depend on D2D Surfaces.
8119         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8120           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8121         fi
8122         ;;
8123       os2)
8124         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
8125         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8126         MOZ_ENABLE_CAIRO_FT=1
8127         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
8128         CAIRO_FT_LIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
8129         ;;
8130     esac
8131     if test "$USE_FC_FREETYPE"; then
8132         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8133     fi
8134     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8135     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8136     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8137     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8138     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8139     AC_SUBST(CAIRO_FT_CFLAGS)
8141     AC_SUBST(PS_SURFACE_FEATURE)
8142     AC_SUBST(PDF_SURFACE_FEATURE)
8143     AC_SUBST(SVG_SURFACE_FEATURE)
8144     AC_SUBST(XLIB_SURFACE_FEATURE)
8145     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8146     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8147     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8148     AC_SUBST(WIN32_SURFACE_FEATURE)
8149     AC_SUBST(OS2_SURFACE_FEATURE)
8150     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8151     AC_SUBST(FT_FONT_FEATURE)
8152     AC_SUBST(FC_FONT_FEATURE)
8153     AC_SUBST(WIN32_FONT_FEATURE)
8154     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8155     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8156     AC_SUBST(QUARTZ_FONT_FEATURE)
8157     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8158     AC_SUBST(QT_SURFACE_FEATURE)
8159     AC_SUBST(TEE_SURFACE_FEATURE)
8161     MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
8163     if test "$MOZ_TREE_PIXMAN"; then
8164         AC_DEFINE(MOZ_TREE_PIXMAN)
8165         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS"' $(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8166     else
8167         PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8168         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $PIXMAN_CFLAGS"
8169         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $PIXMAN_LIBS"
8170     fi
8172     if test "$MOZ_X11"; then
8173         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS -lXrender -lfreetype -lfontconfig"
8174     fi
8176     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8177     mv -f $CAIRO_FEATURES_H "$CAIRO_FEATURES_H".orig 2> /dev/null
8179 else
8180    PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION pixman-1 freetype2 fontconfig)
8181    MOZ_CAIRO_CFLAGS=$CAIRO_CFLAGS
8182    MOZ_CAIRO_LIBS=$CAIRO_LIBS
8183    PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8184    if test "$MOZ_X11"; then
8185         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8186         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8187         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8188    fi
8191 AC_SUBST(MOZ_TREE_CAIRO)
8192 AC_SUBST(MOZ_CAIRO_CFLAGS)
8193 AC_SUBST(MOZ_CAIRO_LIBS)
8194 AC_SUBST(MOZ_TREE_PIXMAN)
8196 dnl ========================================================
8197 dnl qcms
8198 dnl ========================================================
8200 QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
8201 AC_SUBST(QCMS_LIBS)
8203 dnl ========================================================
8204 dnl HarfBuzz
8205 dnl ========================================================
8206 MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
8207 AC_SUBST(MOZ_HARFBUZZ_LIBS)
8209 dnl ========================================================
8210 dnl SIL Graphite
8211 dnl ========================================================
8212 if test "$MOZ_GRAPHITE"; then
8213   MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
8214   AC_DEFINE(MOZ_GRAPHITE)
8215 else
8216   MOZ_GRAPHITE_LIBS=
8218 AC_SUBST(MOZ_GRAPHITE)
8219 AC_SUBST(MOZ_GRAPHITE_LIBS)
8221 dnl ========================================================
8222 dnl OTS
8223 dnl ========================================================
8224 MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
8225 AC_SUBST(MOZ_OTS_LIBS)
8227 dnl ========================================================
8228 dnl Skia 
8229 dnl ========================================================
8230 if test "$MOZ_ENABLE_SKIA"; then
8231   MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
8232   AC_DEFINE(MOZ_ENABLE_SKIA)
8233 else
8234   MOZ_SKIA_LIBS=
8236 AC_SUBST(MOZ_ENABLE_SKIA)
8237 AC_SUBST(MOZ_SKIA_LIBS)
8239 dnl ========================================================
8240 dnl disable xul
8241 dnl ========================================================
8242 MOZ_ARG_DISABLE_BOOL(xul,
8243 [  --disable-xul           Disable XUL],
8244     MOZ_XUL= )
8245 if test "$MOZ_XUL"; then
8246   AC_DEFINE(MOZ_XUL)
8247 else
8248   dnl remove extensions that require XUL
8249   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8252 AC_SUBST(MOZ_XUL)
8254 dnl ========================================================
8255 dnl disable profile locking
8256 dnl   do no use this in applications that can have more than
8257 dnl   one process accessing the profile directory.
8258 dnl ========================================================
8259 MOZ_ARG_DISABLE_BOOL(profilelocking,
8260 [  --disable-profilelocking
8261                           Disable profile locking],
8262     MOZ_PROFILELOCKING=,
8263     MOZ_PROFILELOCKING=1 )
8264 if test "$MOZ_PROFILELOCKING"; then
8265   AC_DEFINE(MOZ_PROFILELOCKING)
8268 dnl ========================================================
8269 dnl necko configuration options
8270 dnl ========================================================
8273 dnl option to disable various necko protocols
8275 MOZ_ARG_ENABLE_STRING(necko-protocols,
8276 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8277                           Enable/disable specific protocol handlers],
8278 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8279     if test "$option" = "yes" -o "$option" = "all"; then
8280         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8281     elif test "$option" = "no" -o "$option" = "none"; then
8282         NECKO_PROTOCOLS=""
8283     elif test "$option" = "default"; then
8284         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8285     elif test `echo "$option" | grep -c \^-` != 0; then
8286         option=`echo $option | sed 's/^-//'`
8287         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8288     else
8289         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8290     fi
8291 done],
8292     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8293 dnl Remove dupes
8294 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8295 AC_SUBST(NECKO_PROTOCOLS)
8296 for p in $NECKO_PROTOCOLS; do
8297     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8298 done
8301 dnl option to disable necko's wifi scanner
8303 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8304 [  --disable-necko-wifi    Disable necko wifi scanner],
8305     NECKO_WIFI=,
8306     NECKO_WIFI=1)
8308 if test "$OS_ARCH" = "OS2"; then
8309   dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
8310   NECKO_WIFI=
8312 if test "$NECKO_WIFI" -a \
8313         "$OS_ARCH" != "Linux" -a \
8314         "$OS_ARCH" != "Darwin" -a \
8315         "$OS_ARCH" != "SunOS" -a \
8316         "$OS_ARCH" != "WINNT"; then
8317   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
8320 if test -z "$SKIP_LIBRARY_CHECKS" -a "$NECKO_WIFI" -a "$OS_ARCH" = "Linux"
8321 then
8322   MOZ_CHECK_HEADER([iwlib.h])
8323   if test "$ac_cv_header_iwlib_h" != "yes"; then
8324     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])
8325   fi
8328 if test "$NECKO_WIFI"; then
8329   AC_DEFINE(NECKO_WIFI)
8331 AC_SUBST(NECKO_WIFI)
8334 dnl option to disable cookies
8336 MOZ_ARG_DISABLE_BOOL(cookies,
8337 [  --disable-cookies       Disable cookie support],
8338     NECKO_COOKIES=,
8339     NECKO_COOKIES=1)
8340 AC_SUBST(NECKO_COOKIES)
8341 if test "$NECKO_COOKIES"; then
8342     AC_DEFINE(NECKO_COOKIES)
8346 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8348 MOZ_ARG_DISABLE_BOOL(ctypes,
8349 [  --disable-ctypes        Disable js-ctypes],
8350     BUILD_CTYPES=,
8351     BUILD_CTYPES=1)
8352 AC_SUBST(BUILD_CTYPES)
8353 if test "$BUILD_CTYPES"; then
8354     AC_DEFINE(BUILD_CTYPES)
8357 dnl NECKO_ configuration options are not global
8358 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_"
8360 dnl Build Places if required
8361 if test "$MOZ_PLACES"; then
8362   AC_DEFINE(MOZ_PLACES)
8365 dnl Build Sync Services if required
8366 AC_SUBST(MOZ_SERVICES_SYNC)
8367 if test -n "$MOZ_SERVICES_SYNC"; then
8368   AC_DEFINE(MOZ_SERVICES_SYNC)
8371 dnl ========================================================
8372 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
8373     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8376 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8377   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8380 if test "$MOZ_APP_COMPONENT_MODULES"; then
8381   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8384 dnl ========================================================
8385 dnl =
8386 dnl = Maintainer debug option (no --enable equivalent)
8387 dnl =
8388 dnl ========================================================
8390 AC_SUBST(AR)
8391 AC_SUBST(AR_FLAGS)
8392 AC_SUBST(AR_LIST)
8393 AC_SUBST(AR_EXTRACT)
8394 AC_SUBST(AR_DELETE)
8395 AC_SUBST(AS)
8396 AC_SUBST(ASFLAGS)
8397 AC_SUBST(AS_DASH_C_FLAG)
8398 AC_SUBST(LD)
8399 AC_SUBST(RC)
8400 AC_SUBST(RCFLAGS)
8401 AC_SUBST(MC)
8402 AC_SUBST(WINDRES)
8403 AC_SUBST(IMPLIB)
8404 AC_SUBST(FILTER)
8405 AC_SUBST(BIN_FLAGS)
8406 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8407 AC_SUBST(MOZ_UPDATE_XTERM)
8408 AC_SUBST(MOZ_PLATFORM_MAEMO)
8409 AC_SUBST(MOZ_AUTH_EXTENSION)
8410 AC_SUBST(MOZ_PERMISSIONS)
8411 AC_SUBST(MOZ_XTF)
8412 AC_SUBST(MOZ_PREF_EXTENSIONS)
8413 AC_SUBST(MOZ_JS_LIBS)
8414 AC_SUBST(MOZ_PSM)
8415 AC_SUBST(MOZ_DEBUG)
8416 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8417 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8418 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8419 AC_SUBST(MOZ_DEBUG_FLAGS)
8420 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8421 AC_SUBST(WARNINGS_AS_ERRORS)
8422 AC_SUBST(MOZ_EXTENSIONS)
8423 AC_SUBST(MOZ_JSDEBUGGER)
8424 AC_SUBST(MOZ_LOG_REFCNT)
8425 AC_SUBST(MOZ_LEAKY)
8426 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8427 AC_SUBST(MOZ_JPROF)
8428 AC_SUBST(MOZ_SHARK)
8429 AC_SUBST(MOZ_CALLGRIND)
8430 AC_SUBST(MOZ_VTUNE)
8431 AC_SUBST(MOZ_ETW)
8432 AC_SUBST(MOZ_PROFILING)
8433 AC_SUBST(MOZ_QUANTIFY)
8434 AC_SUBST(LIBICONV)
8435 AC_SUBST(MOZ_PLACES)
8436 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8437 AC_SUBST(MOZ_FEEDS)
8438 AC_SUBST(NS_PRINTING)
8439 AC_SUBST(MOZ_WEBGL)
8440 AC_SUBST(MOZ_HELP_VIEWER)
8442 AC_SUBST(JAVA)
8443 AC_SUBST(JAVAC)
8444 AC_SUBST(JAR)
8446 AC_SUBST(MOZ_PROFILELOCKING)
8448 AC_SUBST(ENABLE_TESTS)
8449 AC_SUBST(ENABLE_MARIONETTE)
8450 AC_SUBST(IBMBIDI)
8451 AC_SUBST(MOZ_UNIVERSALCHARDET)
8452 AC_SUBST(ACCESSIBILITY)
8453 AC_SUBST(MOZ_SPELLCHECK)
8454 AC_SUBST(MOZ_JAVA_COMPOSITOR)
8455 AC_SUBST(MOZ_ONLY_TOUCH_EVENTS)
8456 AC_SUBST(MOZ_USER_DIR)
8457 AC_SUBST(MOZ_CRASHREPORTER)
8458 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8459 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8460 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8461 AC_SUBST(MOZ_UPDATER)
8462 AC_SUBST(MOZ_ANGLE)
8463 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8464 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8465 AC_SUBST(MOZ_D3DX9_VERSION)
8466 AC_SUBST(MOZ_D3DX9_CAB)
8467 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8468 AC_SUBST(MOZ_D3DX9_DLL)
8469 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8470 AC_SUBST(MOZ_METRO)
8472 AC_SUBST(MOZ_ANDROID_HISTORY)
8473 AC_SUBST(MOZ_WEBSMS_BACKEND)
8474 AC_SUBST(ENABLE_STRIP)
8475 AC_SUBST(PKG_SKIP_STRIP)
8476 AC_SUBST(STRIP_FLAGS)
8477 AC_SUBST(USE_ELF_DYNSTR_GC)
8478 AC_SUBST(USE_ELF_HACK)
8479 AC_SUBST(INCREMENTAL_LINKER)
8480 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8481 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8483 AC_SUBST(MOZ_FIX_LINK_PATHS)
8484 AC_SUBST(XPCOM_LIBS)
8485 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8486 AC_SUBST(XPCOM_GLUE_LDOPTS)
8487 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8489 AC_SUBST(USE_DEPENDENT_LIBS)
8491 AC_SUBST(MOZ_BUILD_ROOT)
8492 AC_SUBST(MOZ_OS2_TOOLS)
8494 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8495 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8497 dnl ========================================================
8498 dnl = Mac bundle name prefix
8499 dnl ========================================================
8500 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8501 [  --with-macbundlename-prefix=prefix
8502                           Prefix for MOZ_MACBUNDLE_NAME],
8503 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8505 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8506 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8507   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8510 if test "$MOZ_DEBUG"; then
8511   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8512 else
8513   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8515 AC_SUBST(MOZ_MACBUNDLE_NAME)
8517 # The following variables are available to branding and application
8518 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8519 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8520 # impacts profile location and user-visible fields.
8521 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8522 # versions of a given application (e.g. Aurora and Firefox both use
8523 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8524 # for application.ini's "Name" field, which controls profile location in
8525 # the absence of a "Profile" field (see below), and various system
8526 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8527 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8528 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8529 # builds (e.g. Aurora for Firefox).
8530 # - MOZ_APP_VERSION: Defines the application version number.
8531 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8532 # defaults to a lowercase form of MOZ_APP_BASENAME.
8533 # - MOZ_APP_PROFILE: When set, used for application.ini's
8534 # "Profile" field, which controls profile location.
8535 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8536 # crash reporter server url.
8537 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8538 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8540 if test -z "$MOZ_APP_NAME"; then
8541    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8544 # For extensions and langpacks, we require a max version that is compatible
8545 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8546 # 10.0a1 and 10.0a2 aren't affected
8547 # 10.0 becomes 10.0.*
8548 # 10.0.1 becomes 10.0.*
8549 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8550 if test -z "$IS_ALPHA"; then
8551   changequote(,)
8552   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*.[0-9]*\).*|\1|"`.*
8553   changequote([,])
8554 else
8555   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8558 AC_SUBST(MOZ_APP_NAME)
8559 AC_SUBST(MOZ_APP_DISPLAYNAME)
8560 AC_SUBST(MOZ_APP_BASENAME)
8561 AC_SUBST(MOZ_APP_VENDOR)
8562 AC_SUBST(MOZ_APP_PROFILE)
8563 AC_SUBST(MOZ_APP_ID)
8564 AC_SUBST(MAR_CHANNEL_ID)
8565 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8566 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8567 AC_SUBST(MOZ_EXTENSION_MANAGER)
8568 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8569 AC_SUBST(MOZ_APP_UA_NAME)
8570 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8571 AC_SUBST(MOZ_APP_VERSION)
8572 AC_SUBST(MOZ_APP_MAXVERSION)
8573 AC_DEFINE_UNQUOTED(MOZ_UA_FIREFOX_VERSION, "$FIREFOX_VERSION")
8574 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8575 AC_SUBST(FIREFOX_VERSION)
8576 AC_DEFINE_UNQUOTED(MOZ_UA_BUILDID, "$MOZ_UA_BUILDID")
8577 AC_SUBST(MOZ_UA_BUILDID)
8579 # We can't use the static application.ini data when building against
8580 # a libxul SDK.
8581 if test -n "$LIBXUL_SDK"; then
8582     MOZ_APP_STATIC_INI=
8584 AC_SUBST(MOZ_APP_STATIC_INI)
8586 AC_SUBST(MOZ_PKG_SPECIAL)
8588 AC_SUBST(MOZILLA_OFFICIAL)
8590 if test "$MOZ_TELEMETRY_REPORTING"; then
8591     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8594 dnl win32 options
8595 AC_SUBST(MOZ_MAPINFO)
8596 AC_SUBST(MOZ_BROWSE_INFO)
8597 AC_SUBST(MOZ_TOOLS_DIR)
8598 AC_SUBST(WIN32_REDIST_DIR)
8599 AC_SUBST(PYTHON)
8600 AC_SUBST(MAKENSISU)
8602 dnl Echo the CFLAGS to remove extra whitespace.
8603 CFLAGS=`echo \
8604         $_WARNINGS_CFLAGS \
8605         $CFLAGS`
8607 CXXFLAGS=`echo \
8608         $_MOZ_RTTI_FLAGS \
8609         $_WARNINGS_CXXFLAGS \
8610         $CXXFLAGS`
8612 COMPILE_CFLAGS=`echo \
8613     $_DEFINES_CFLAGS \
8614         $_DEPEND_CFLAGS \
8615     $COMPILE_CFLAGS`
8617 COMPILE_CXXFLAGS=`echo \
8618     $_DEFINES_CXXFLAGS \
8619         $_DEPEND_CFLAGS \
8620     $COMPILE_CXXFLAGS`
8622 AC_SUBST(SYSTEM_MAKEDEPEND)
8623 AC_SUBST(SYSTEM_LIBXUL)
8624 AC_SUBST(SYSTEM_JPEG)
8625 AC_SUBST(SYSTEM_PNG)
8626 AC_SUBST(SYSTEM_ZLIB)
8627 AC_SUBST(SYSTEM_BZ2)
8629 AC_SUBST(JPEG_CFLAGS)
8630 AC_SUBST(JPEG_LIBS)
8631 AC_SUBST(ZLIB_CFLAGS)
8632 AC_SUBST(ZLIB_LIBS)
8633 AC_SUBST(BZ2_CFLAGS)
8634 AC_SUBST(BZ2_LIBS)
8635 AC_SUBST(PNG_CFLAGS)
8636 AC_SUBST(PNG_LIBS)
8638 AC_SUBST(MOZ_FLEXBOX)
8639 AC_SUBST(MOZ_JPEG_CFLAGS)
8640 AC_SUBST(MOZ_JPEG_LIBS)
8641 AC_SUBST(MOZ_ZLIB_CFLAGS)
8642 AC_SUBST(MOZ_ZLIB_LIBS)
8643 AC_SUBST(MOZ_BZ2_CFLAGS)
8644 AC_SUBST(MOZ_BZ2_LIBS)
8645 AC_SUBST(MOZ_PNG_CFLAGS)
8646 AC_SUBST(MOZ_PNG_LIBS)
8648 AC_SUBST(NSPR_CFLAGS)
8649 AC_SUBST(NSPR_LIBS)
8650 AC_SUBST(MOZ_NATIVE_NSPR)
8652 AC_SUBST(NSS_CFLAGS)
8653 AC_SUBST(NSS_LIBS)
8654 AC_SUBST(NSS_DEP_LIBS)
8655 AC_SUBST(MOZ_NATIVE_NSS)
8656 AC_SUBST(NSS_DISABLE_DBM)
8658 AC_SUBST(CFLAGS)
8659 AC_SUBST(CXXFLAGS)
8660 AC_SUBST(CPPFLAGS)
8661 AC_SUBST(COMPILE_CFLAGS)
8662 AC_SUBST(COMPILE_CXXFLAGS)
8663 AC_SUBST(LDFLAGS)
8664 AC_SUBST(LIBS)
8665 AC_SUBST(CROSS_COMPILE)
8666 AC_SUBST(WCHAR_CFLAGS)
8668 AC_SUBST(HOST_CC)
8669 AC_SUBST(HOST_CXX)
8670 AC_SUBST(HOST_CFLAGS)
8671 AC_SUBST(HOST_CXXFLAGS)
8672 AC_SUBST(HOST_LDFLAGS)
8673 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8674 AC_SUBST(HOST_AR)
8675 AC_SUBST(HOST_AR_FLAGS)
8676 AC_SUBST(HOST_LD)
8677 AC_SUBST(HOST_RANLIB)
8678 AC_SUBST(HOST_NSPR_MDCPUCFG)
8679 AC_SUBST(HOST_BIN_SUFFIX)
8680 AC_SUBST(HOST_OS_ARCH)
8682 AC_SUBST(TARGET_CPU)
8683 AC_SUBST(TARGET_VENDOR)
8684 AC_SUBST(TARGET_OS)
8685 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8686 AC_SUBST(TARGET_MD_ARCH)
8687 AC_SUBST(TARGET_XPCOM_ABI)
8688 AC_SUBST(OS_TARGET)
8689 AC_SUBST(OS_ARCH)
8690 AC_SUBST(OS_RELEASE)
8691 AC_SUBST(OS_TEST)
8692 AC_SUBST(CPU_ARCH)
8693 AC_SUBST(INTEL_ARCHITECTURE)
8695 AC_SUBST(MOZ_DISABLE_JAR_PACKAGING)
8696 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8698 AC_SUBST(WRAP_LDFLAGS)
8699 AC_SUBST(MKSHLIB)
8700 AC_SUBST(MKCSHLIB)
8701 AC_SUBST(MKSHLIB_FORCE_ALL)
8702 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8703 AC_SUBST(DSO_CFLAGS)
8704 AC_SUBST(DSO_PIC_CFLAGS)
8705 AC_SUBST(DSO_LDOPTS)
8706 AC_SUBST(LIB_PREFIX)
8707 AC_SUBST(DLL_PREFIX)
8708 AC_SUBST(DLL_SUFFIX)
8709 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8710 AC_SUBST(LIB_SUFFIX)
8711 AC_SUBST(OBJ_SUFFIX)
8712 AC_SUBST(BIN_SUFFIX)
8713 AC_SUBST(ASM_SUFFIX)
8714 AC_SUBST(IMPORT_LIB_SUFFIX)
8715 AC_SUBST(USE_N32)
8716 AC_SUBST(CC_VERSION)
8717 AC_SUBST(CXX_VERSION)
8718 AC_SUBST(MSMANIFEST_TOOL)
8719 AC_SUBST(NS_ENABLE_TSF)
8720 AC_SUBST(MOZ_NSS_PATCH)
8721 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8722 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8724 AC_SUBST(MOZ_MEDIA)
8725 AC_SUBST(MOZ_SYDNEYAUDIO)
8726 AC_SUBST(MOZ_CUBEB)
8727 AC_SUBST(MOZ_WAVE)
8728 AC_SUBST(MOZ_VORBIS)
8729 AC_SUBST(MOZ_TREMOR)
8730 AC_SUBST(MOZ_WEBM)
8731 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8732 AC_SUBST(MOZ_VP8_ENCODER)
8733 AC_SUBST(MOZ_OGG)
8734 AC_SUBST(MOZ_ALSA_LIBS)
8735 AC_SUBST(MOZ_ALSA_CFLAGS)
8736 AC_SUBST(VPX_AS)
8737 AC_SUBST(VPX_ASFLAGS)
8738 AC_SUBST(VPX_DASH_C_FLAG)
8739 AC_SUBST(VPX_AS_CONVERSION)
8740 AC_SUBST(VPX_ASM_SUFFIX)
8741 AC_SUBST(VPX_X86_ASM)
8742 AC_SUBST(VPX_ARM_ASM)
8743 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8744 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8745 AC_SUBST(LIBJPEG_TURBO_AS)
8746 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8747 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8748 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8749 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8751 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8753 AC_MSG_CHECKING([for posix_fallocate])
8754 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8755   #include <fcntl.h>],
8756                  [posix_fallocate(0, 0, 0);],
8757                  [ac_cv___posix_fallocate=true],
8758                  [ac_cv___posix_fallocate=false])
8760 if test "$ac_cv___posix_fallocate" = true ; then
8761   AC_DEFINE(HAVE_POSIX_FALLOCATE)
8762   AC_MSG_RESULT(yes)
8763 else
8764   AC_MSG_RESULT(no)
8767 dnl Check for missing components
8768 if test "$COMPILE_ENVIRONMENT"; then
8769 if test "$MOZ_X11"; then
8770     if test "$WITHOUT_X11"; then
8771         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8772     fi
8773     dnl ====================================================
8774     dnl = Check if X headers exist
8775     dnl ====================================================
8776     _SAVE_CFLAGS=$CFLAGS
8777     CFLAGS="$CFLAGS $XCFLAGS"
8778     AC_TRY_COMPILE([
8779         #include <stdio.h>
8780         #include <stdlib.h>
8781         #include <X11/Xlib.h>
8782         #include <X11/Intrinsic.h>
8783         #include <X11/extensions/XShm.h>
8784     ],
8785     [
8786         Display *dpy = 0;
8787         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8788             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8789             exit(1);
8790         }
8791     ], [],
8792     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8793     CFLAGS="$_SAVE_CFLAGS"
8795     if test -n "$MISSING_X"; then
8796         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8797     fi
8799 fi # MOZ_X11
8801 dnl Check for headers, etc. needed by WebGL.
8802 if test "$MOZ_GL_DEFAULT_PROVIDER" = "GLX"; then
8803     MOZ_CHECK_HEADER(GL/glx.h)
8804     if test "$ac_cv_header_GL_glx_h" != "yes"; then
8805         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))])
8806     fi
8807 fi # MOZ_GL_DEFAULT_PROVIDER=GLX
8808 fi # COMPILE_ENVIRONMENT
8810 if test "$USE_FC_FREETYPE"; then
8811     if test "$COMPILE_ENVIRONMENT"; then
8812         _SAVE_CPPFLAGS="$CPPFLAGS"
8813         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8814         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8815             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8816         CPPFLAGS="$_SAVE_CPPFLAGS"
8817     else
8818         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8819     fi
8822 dnl Set various defines and substitutions
8823 dnl ========================================================
8825 if test "$OS_ARCH" = "Darwin"; then
8826   AC_DEFINE(XP_UNIX)
8827   AC_DEFINE(UNIX_ASYNC_DNS)
8828 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
8829   AC_DEFINE(XP_UNIX)
8830   AC_DEFINE(UNIX_ASYNC_DNS)
8833 if test "$MOZ_DEBUG"; then
8834     AC_DEFINE(MOZ_REFLOW_PERF)
8835     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8838 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
8839     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8840     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8841     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8842     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8843     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8844     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8845     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8846     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8849 case "$host_os" in
8850 mingw*)
8851     WIN_TOP_SRC=`cd $srcdir; pwd -W`
8852     ;;
8853 esac
8855 AC_SUBST(WIN_TOP_SRC)
8857 AC_SUBST(MOZILLA_VERSION)
8859 AC_SUBST(ac_configure_args)
8861 dnl Spit out some output
8862 dnl ========================================================
8864 dnl The following defines are used by xpcom
8865 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8866 CPP_THROW_NEW
8867 HAVE_CPP_2BYTE_WCHAR_T
8868 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8869 HAVE_CPP_CHAR16_T
8870 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8871 HAVE_CPP_PARTIAL_SPECIALIZATION
8872 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8873 HAVE_STATVFS
8874 NEED_CPP_UNUSED_IMPLEMENTATIONS
8875 NEW_H
8876 HAVE_GETPAGESIZE
8877 HAVE_ICONV
8878 HAVE_ICONV_WITH_CONST_INPUT
8879 HAVE_MBRTOWC
8880 HAVE_SYS_MOUNT_H
8881 HAVE_SYS_VFS_H
8882 HAVE_WCRTOMB
8885 AC_CONFIG_HEADER(
8886 netwerk/necko-config.h
8887 xpcom/xpcom-config.h
8888 xpcom/xpcom-private.h
8891 # Hack around an Apple bug that effects the egrep that comes with OS X 10.7.
8892 # "arch -arch i386 egrep" always uses the 32-bit Intel part of the egrep fat
8893 # binary, even on 64-bit systems.  It should work on OS X 10.4.5 and up.  We
8894 # (apparently) only need this hack when egrep's "pattern" is particularly
8895 # long (as in the following code).  See bug 655339.
8896 case "$host" in
8897 *-apple-darwin*)
8898     FIXED_EGREP="arch -arch i386 egrep"
8899     ;;
8901     FIXED_EGREP="egrep"
8902     ;;
8903 esac
8905 # Save the defines header file before autoconf removes it.
8906 # (Do not add AC_DEFINE calls after this line.)
8907   _CONFIG_TMP=confdefs-tmp.h
8908   _CONFIG_DEFS_H=mozilla-config.h
8910   cat > $_CONFIG_TMP <<\EOF
8911 /* List of defines generated by configure. Included with preprocessor flag,
8912  * -include, to avoid long list of -D defines on the compile command-line.
8913  * Do not edit.
8914  */
8916 #ifndef _MOZILLA_CONFIG_H_
8917 #define _MOZILLA_CONFIG_H_
8920 _EGREP_PATTERN='^#define ('
8921 if test -n "$_NON_GLOBAL_ACDEFINES"; then
8922     for f in $_NON_GLOBAL_ACDEFINES; do
8923         _EGREP_PATTERN="${_EGREP_PATTERN}$f|"
8924     done
8926 _EGREP_PATTERN="${_EGREP_PATTERN}dummy_never_defined)"
8928   sort confdefs.h | $FIXED_EGREP -v "$_EGREP_PATTERN" >> $_CONFIG_TMP
8930   if test "$?" != 0; then
8931     AC_MSG_ERROR([Error outputting config definitions])
8932   fi
8934   cat >> $_CONFIG_TMP <<\EOF
8936 /* The c99 defining the limit macros (UINT32_MAX for example), says:
8937  * C++ implementations should define these macros only when __STDC_LIMIT_MACROS
8938  * is defined before <stdint.h> is included. */
8939 #define __STDC_LIMIT_MACROS
8941 /* Force-include hunspell_alloc_hooks.h for hunspell, so that we don't need to
8942  * modify it directly.
8944  * HUNSPELL_STATIC is defined in extensions/spellcheck/hunspell/src/Makefile.in,
8945  * unless --enable-system-hunspell is defined.
8946  */
8947 #if defined(HUNSPELL_STATIC)
8948 #include "hunspell_alloc_hooks.h"
8949 #endif
8951 #endif /* _MOZILLA_CONFIG_H_ */
8955   # Only write mozilla-config.h when something changes (or it doesn't exist)
8956   if cmp -s $_CONFIG_TMP $_CONFIG_DEFS_H; then
8957     rm $_CONFIG_TMP
8958   else
8959     AC_MSG_RESULT("creating $_CONFIG_DEFS_H")
8960     mv -f $_CONFIG_TMP $_CONFIG_DEFS_H
8962     echo ==== $_CONFIG_DEFS_H =================================
8963     cat $_CONFIG_DEFS_H
8964   fi
8966 dnl Probably shouldn't call this manually but we always want the output of DEFS
8967 rm -f confdefs.h.save
8968 mv confdefs.h confdefs.h.save
8969 $FIXED_EGREP -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
8970 if test "$?" != 0; then
8971   AC_MSG_ERROR([Error outputting confdefs.h])
8973 AC_OUTPUT_MAKE_DEFS()
8974 MOZ_DEFINES=$DEFS
8975 AC_SUBST(MOZ_DEFINES)
8976 rm -f confdefs.h
8977 mv confdefs.h.save confdefs.h
8979 dnl Load the list of Makefiles to generate.
8980 dnl   To add new Makefiles, edit allmakefiles.sh.
8981 dnl   allmakefiles.sh sets the variable, MAKEFILES.
8982 . ${srcdir}/allmakefiles.sh
8984 dnl Run a perl script to quickly create the makefiles.
8985 dnl If it succeeds, it outputs a shell command to set CONFIG_FILES
8986 dnl   for the files it cannot handle correctly. This way, config.status
8987 dnl   will handle these files.
8988 dnl If it fails, nothing is set and config.status will run as usual.
8990 dnl This does not change the $MAKEFILES variable.
8992 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl > conftest.sh
8993 . ./conftest.sh
8994 rm conftest.sh
8996 echo $MAKEFILES > unallmakefiles
8998 mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null
9000 AC_OUTPUT($MAKEFILES)
9002 # Generate a JSON config file for unittest harnesses etc to read
9003 # build configuration details from in a standardized way.
9004 OS_TARGET=${OS_TARGET} TARGET_CPU=${TARGET_CPU} MOZ_DEBUG=${MOZ_DEBUG} \
9005 MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \
9006   $PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp
9007 if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then
9008   rm ./mozinfo.json.tmp
9009 else
9010   mv -f ./mozinfo.json.tmp ./mozinfo.json
9013 dnl Prevent the regeneration of cairo-features.h forcing rebuilds of gfx stuff
9014 if test "$CAIRO_FEATURES_H"; then
9015   if cmp -s $CAIRO_FEATURES_H "$CAIRO_FEATURES_H".orig; then
9016     echo "$CAIRO_FEATURES_H is unchanged"
9017     mv -f "$CAIRO_FEATURES_H".orig "$CAIRO_FEATURES_H" 2> /dev/null
9018   else
9019     rm -f "$CAIRO_FEATURES_H".orig 2> /dev/null
9020   fi
9023 dnl Build libunwind for Android profiling builds
9024 if test "$OS_TARGET" = "Android" -a "$MOZ_PROFILING"; then
9025   old_ac_configure_arg="$ac_configure_args"
9026   ac_configure_args="--build=${build} --host=${target_alias} --disable-shared --enable-block-signals=no"
9027   if test "$MOZ_DEBUG"; then
9028     ac_configure_args="$ac_configure_args --enable-debug"
9029   fi
9030   if test "$DSO_PIC_CFLAGS"; then
9031     ac_configure_args="$ac_configure_args --with-pic"
9032   fi
9033   ac_configure_args="$ac_configure_args \
9034       CC=\"$CC\" \
9035       CXX=\"$CXX\" \
9036       CPP=\"$CPP\" \
9037       CFLAGS=\"$CFLAGS\" \
9038       CXXFLAGS=\"$CXXFLAGS\" \
9039       CPPFLAGS=\"$CPPFLAGS\" \
9040       LD=\"$LD\" \
9041       LDFLAGS=\"$LDFLAGS\" \
9042       AR=\"$AR\" \
9043       RANLIB=\"$RANLIB\" \
9044       STRIP=\"$STRIP\" \
9045       LIBS=\"$LIBS\""
9047   # Use a separate cache file for libunwind, since it does not use caching.
9048   mkdir -p $_objdir/tools/profiler/libunwind/src
9049   old_cache_file=$cache_file
9050   cache_file=$_objdir/tools/profiler/libunwind/src/config.cache
9051   old_config_files=$CONFIG_FILES
9052   unset CONFIG_FILES
9053   AC_OUTPUT_SUBDIRS(tools/profiler/libunwind/src)
9054   cache_file=$old_cache_file
9055   ac_configure_args="$old_ac_configure_args"
9056   CONFIG_FILES=$old_config_files
9059 # Run freetype configure script
9061 if test "$MOZ_TREE_FREETYPE"; then
9062    export CFLAGS="$CFLAGS -std=c99"
9063    export CPPFLAGS="$CPPFLAGS"
9064    export CXXFLAGS="$CXXFLAGS"
9065    export LDFLAGS="$LDFLAGS"
9066    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9067    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes"
9068    AC_OUTPUT_SUBDIRS(modules/freetype2)
9071 if test -z "$direct_nspr_config"; then
9072     dnl ========================================================
9073     dnl = Setup a nice relatively clean build environment for
9074     dnl = sub-configures.
9075     dnl ========================================================
9076     CC="$_SUBDIR_CC"
9077     CXX="$_SUBDIR_CXX"
9078     CFLAGS="$_SUBDIR_CFLAGS"
9079     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9080     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9081     LDFLAGS="$_SUBDIR_LDFLAGS"
9082     HOST_CC="$_SUBDIR_HOST_CC"
9083     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9084     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9085     RC=
9088 unset MAKEFILES
9089 unset CONFIG_FILES
9091 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9092 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9094 export WRAP_LDFLAGS
9096 if test -n "$_WRAP_MALLOC"; then
9097     # Avoid doubling wrap malloc arguments
9098     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9101 if test -z "$MOZ_NATIVE_NSPR"; then
9102     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9103     if test -z "$MOZ_DEBUG"; then
9104         ac_configure_args="$ac_configure_args --disable-debug"
9105     else
9106         ac_configure_args="$ac_configure_args --enable-debug"
9107     fi
9108     if test "$MOZ_OPTIMIZE" = "1"; then
9109         ac_configure_args="$ac_configure_args --enable-optimize"
9110     elif test -z "$MOZ_OPTIMIZE"; then
9111         ac_configure_args="$ac_configure_args --disable-optimize"
9112     fi
9113     if test -n "$HAVE_64BIT_OS"; then
9114         ac_configure_args="$ac_configure_args --enable-64bit"
9115     fi
9116     if test -n "$USE_ARM_KUSER"; then
9117         ac_configure_args="$ac_configure_args --with-arm-kuser"
9118     fi
9119     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9120     if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9121       # dladdr is supported by the new linker, even when the system linker doesn't
9122       # support it. Trick nspr into using dladdr when it's not supported.
9123       _SAVE_CPPFLAGS="$CPPFLAGS"
9124       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9125     fi
9126     _SAVE_LDFLAGS="$LDFLAGS"
9127     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9128     AC_OUTPUT_SUBDIRS(nsprpub)
9129     LDFLAGS="$_SAVE_LDFLAGS"
9130     if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a "$ac_cv_func_dladdr" = no; then
9131       unset CPPFLAGS
9132       CPPFLAGS="$_SAVE_CFLAGS"
9133     fi
9134     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9137 if test -z "$MOZ_NATIVE_NSPR"; then
9138     # Hack to deal with the fact that we use NSPR_CFLAGS everywhere
9139     AC_MSG_WARN([Recreating autoconf.mk with updated nspr-config output])
9140     if test "$OS_ARCH" != "WINNT"; then
9141        NSPR_LIBS=`./nsprpub/config/nspr-config --prefix=$LIBXUL_DIST --exec-prefix=$MOZ_BUILD_ROOT/dist --libdir=$LIBXUL_DIST/lib --libs`
9142        $PERL -pi.bak -e "s '^NSPR_LIBS\\s*=.*'NSPR_LIBS = $NSPR_LIBS'" config/autoconf.mk
9143        NSPR_CFLAGS=`./nsprpub/config/nspr-config --prefix=$LIBXUL_DIST --exec-prefix=$MOZ_BUILD_ROOT/dist --includedir=$LIBXUL_DIST/include/nspr --cflags`
9144        $PERL -pi.bak -e "s '^NSPR_CFLAGS\\s*=.*'NSPR_CFLAGS = $NSPR_CFLAGS'" config/autoconf.mk
9145     fi
9146     rm -f config/autoconf.mk.bak
9149 dnl ========================================================
9150 dnl = Setup a nice relatively clean build environment for
9151 dnl = sub-configures.
9152 dnl ========================================================
9153 CC="$_SUBDIR_CC"
9154 CXX="$_SUBDIR_CXX"
9155 CFLAGS="$_SUBDIR_CFLAGS"
9156 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9157 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9158 LDFLAGS="$_SUBDIR_LDFLAGS"
9159 HOST_CC="$_SUBDIR_HOST_CC"
9160 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9161 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9164 # Run the SpiderMonkey 'configure' script.
9165 dist=$MOZ_BUILD_ROOT/dist
9166 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9167 ac_configure_args="$ac_configure_args --enable-threadsafe"
9168 if test "$BUILD_CTYPES"; then
9169     # Build js-ctypes on the platforms we can.
9170     ac_configure_args="$ac_configure_args --enable-ctypes"
9172 if test -z "$JS_SHARED_LIBRARY" ; then
9173     ac_configure_args="$ac_configure_args --disable-shared-js"
9175 if test -z "$MOZ_NATIVE_NSPR"; then
9176     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9177     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9179 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
9180 ac_configure_args="$ac_configure_args --prefix=$dist"
9181 ac_configure_args="$ac_configure_args --with-sync-build-files=$_topsrcdir"
9182 if test "$MOZ_MEMORY"; then
9183    ac_configure_args="$ac_configure_args --enable-jemalloc"
9185 if test -n "$MOZ_GLUE_LDFLAGS"; then
9186    export MOZ_GLUE_LDFLAGS
9188 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9189    export MOZ_GLUE_PROGRAM_LDFLAGS
9191 export MOZ_APP_NAME
9192 export STLPORT_CPPFLAGS
9193 export STLPORT_LDFLAGS
9194 export STLPORT_LIBS
9195 AC_OUTPUT_SUBDIRS(js/src)
9196 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9198 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
9200 dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world
9201 dnl Needs to be at the end to respect possible changes from NSPR configure
9202 if cmp -s config/autoconf.mk config/autoconf.mk.orig; then
9203   echo "config/autoconf.mk is unchanged"
9204   mv -f config/autoconf.mk.orig config/autoconf.mk 2> /dev/null
9205 else
9206   rm -f config/autoconf.mk.orig 2> /dev/null