AArch64 support
[platform/upstream/js.git] / js / src / configure.in
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl vi: set tabstop=4 shiftwidth=4 expandtab:
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 *****
61
62 dnl Process this file with autoconf to produce a configure script.
63 dnl ========================================================
64
65 AC_PREREQ(2.13)
66 AC_INIT(jsapi.h)
67 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
68 AC_CONFIG_HEADER(js-config.h)
69 AC_CANONICAL_SYSTEM
70 TARGET_CPU="${target_cpu}"
71 TARGET_VENDOR="${target_vendor}"
72 TARGET_OS="${target_os}"
73
74 dnl ========================================================
75 dnl =
76 dnl = Don't change the following two lines.  Doing so breaks:
77 dnl =
78 dnl = CFLAGS="-foo" ./configure
79 dnl =
80 dnl ========================================================
81 CFLAGS="${CFLAGS=}"
82 CPPFLAGS="${CPPFLAGS=}"
83 CXXFLAGS="${CXXFLAGS=}"
84 LDFLAGS="${LDFLAGS=}"
85 HOST_CFLAGS="${HOST_CFLAGS=}"
86 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
87 HOST_LDFLAGS="${HOST_LDFLAGS=}"
88
89 dnl ========================================================
90 dnl = Preserve certain environment flags passed to configure
91 dnl = We want sub projects to receive the same flags
92 dnl = untainted by this configure script
93 dnl ========================================================
94 _SUBDIR_CC="$CC"
95 _SUBDIR_CXX="$CXX"
96 _SUBDIR_CFLAGS="$CFLAGS"
97 _SUBDIR_CPPFLAGS="$CPPFLAGS"
98 _SUBDIR_CXXFLAGS="$CXXFLAGS"
99 _SUBDIR_LDFLAGS="$LDFLAGS"
100 _SUBDIR_HOST_CC="$HOST_CC"
101 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
102 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
103 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
104 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
105
106 dnl Set the version number of the libs included with mozilla
107 dnl ========================================================
108 NSPR_VERSION=4
109
110 dnl Set the minimum version of toolkit libs used by mozilla
111 dnl ========================================================
112 PERL_VERSION=5.006
113 PYTHON_VERSION=2.5
114 WINDRES_VERSION=2.14.90
115 W32API_VERSION=3.8
116
117 MSMANIFEST_TOOL=
118
119 dnl Set various checks
120 dnl ========================================================
121 MISSING_X=
122 AC_PROG_AWK
123
124 dnl Initialize the Pthread test variables early so they can be
125 dnl  overridden by each platform.
126 dnl ========================================================
127 USE_PTHREADS=
128 _PTHREAD_LDFLAGS=""
129
130 dnl Do not allow a separate objdir build if a srcdir build exists.
131 dnl ==============================================================
132 _topsrcdir=`cd \`dirname $0\`; pwd`
133 _objdir=`pwd`
134
135 if test "$_topsrcdir" != "$_objdir"
136 then
137   # Check for a couple representative files in the source tree
138   _conflict_files=
139   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
140     if test -f $file; then
141       _conflict_files="$_conflict_files $file"
142     fi
143   done
144   if test "$_conflict_files"; then
145     echo "***"
146     echo "*   Your source tree contains these files:"
147     for file in $_conflict_files; do
148       echo "*         $file"
149     done
150     cat 1>&2 <<-EOF
151         *   This indicates that you previously built in the source tree.
152         *   A source tree build can confuse the separate objdir build.
153         *
154         *   To clean up the source tree:
155         *     1. cd $_topsrcdir
156         *     2. gmake distclean
157         ***
158         EOF
159     exit 1
160     break
161   fi
162 fi
163 MOZ_BUILD_ROOT=`pwd`
164
165 dnl Choose where to put the 'dist' directory.
166 dnl ==============================================================
167
168 MOZ_ARG_WITH_STRING(dist-dir,
169 [  --with-dist-dir=DIR     Use DIR as 'dist' staging area.  DIR may be
170                           relative to the top of SpiderMonkey build tree,
171                           or absolute.],
172     TOP_DIST=$withval,
173     TOP_DIST=dist)
174 AC_SUBST(TOP_DIST)
175
176 dnl Default to MSVC for win32 and gcc-4.2 for darwin
177 dnl ==============================================================
178 if test -z "$CROSS_COMPILE"; then
179 case "$target" in
180 *-cygwin*|*-mingw*|*-msvc*|*-mks*)
181     if test -z "$CC"; then CC=cl; fi
182     if test -z "$CXX"; then CXX=cl; fi
183     if test -z "$CPP"; then CPP="cl -E -nologo"; fi
184     if test -z "$CXXCPP"; then CXXCPP="cl -TP -E -nologo"; ac_cv_prog_CXXCPP="$CXXCPP"; fi
185     if test -z "$LD"; then LD=link; fi
186     if test -z "$AS"; then
187         case "${target_cpu}" in
188         i*86)
189             AS=ml;
190             ;;
191         x86_64)
192             AS=ml64;
193             ;;
194         esac
195     fi
196     if test -z "$MIDL"; then MIDL=midl; fi
197     ;;
198 *-darwin*)
199     if test -z "$CC"; then CC=gcc-4.2; fi
200     if test -z "$CXX"; then CXX=g++-4.2; fi
201     ;;
202 esac
203 fi
204
205 COMPILE_ENVIRONMENT=1
206 MOZ_ARG_DISABLE_BOOL(compile-environment,
207 [  --disable-compile-environment
208                           Disable compiler/library checks.],
209     COMPILE_ENVIRONMENT= )
210 AC_SUBST(COMPILE_ENVIRONMENT)
211
212 dnl Check for Perl first -- needed for win32 SDK checks
213 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
214 if test -z "$PERL" -o "$PERL" = ":"; then
215     AC_MSG_ERROR([perl not found in \$PATH])
216 fi
217
218 MOZ_ARG_ENABLE_BOOL(shared-js,
219 [  --disable-shared-js
220                           Do not create a shared library.],
221     DISABLE_SHARED_JS=0,
222     DISABLE_SHARED_JS=1)
223
224 if test "$DISABLE_SHARED_JS" = "1" ; then
225   AC_DEFINE(STATIC_EXPORTABLE_JS_API)
226 else
227   JS_SHARED_LIBRARY=1
228 fi
229 AC_SUBST(JS_SHARED_LIBRARY)
230
231 dnl ========================================================
232 dnl = Android uses a very custom (hacky) toolchain; we need to do this
233 dnl = here, so that the compiler checks can succeed
234 dnl ========================================================
235
236 MOZ_ARG_WITH_STRING(android-ndk,
237 [  --with-android-ndk=DIR
238                           location where the Android NDK can be found],
239     android_ndk=$withval)
240
241 MOZ_ARG_WITH_STRING(android-toolchain,
242 [  --with-android-toolchain=DIR
243                           location of the android toolchain, default NDK/build/prebuilt/HOST/arm-eabi-4.4.0],
244     android_toolchain=$withval)
245
246
247 MOZ_ARG_WITH_STRING(android-version,
248 [  --with-android-version=VER
249                           android platform version, default 5],
250     android_version=$withval,
251     android_version=5)
252
253 MOZ_ARG_WITH_STRING(android-sdk,
254 [  --with-android-sdk=DIR
255                           location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)],
256     android_sdk=$withval)
257
258 if test "$target" = "arm-android-eabi" ; then
259     if test -z "$android_ndk" ; then
260         AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
261     fi
262
263     if test -z "$android_sdk" ; then
264         AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
265     fi
266
267     android_platform_tools="$android_sdk"/../../platform-tools
268     if test ! -d "$android_platform_tools" ; then
269         android_platform_tools="$android_sdk"/tools # SDK Tools < r8
270     fi
271
272     if test -z "$android_toolchain" ; then
273         android_toolchain="$android_ndk"/build/prebuilt/`uname -s | tr "[[:upper:]]" "[[:lower:]]"`-x86/arm-eabi-4.4.0
274     fi
275
276     if test -z "$android_platform" ; then
277        android_platform="$android_ndk"/build/platforms/android-"$android_version"/arch-"$target_cpu"
278     fi
279
280     dnl set up compilers
281     AS="$android_toolchain"/bin/arm-eabi-as
282     CC="$android_toolchain"/bin/arm-eabi-gcc
283     CXX="$android_toolchain"/bin/arm-eabi-g++
284     CPP="$android_toolchain"/bin/arm-eabi-cpp
285     LD="$android_toolchain"/bin/arm-eabi-ld
286     AR="$android_toolchain"/bin/arm-eabi-ar
287     RANLIB="$android_toolchain"/bin/arm-eabi-ranlib
288     STRIP="$android_toolchain"/bin/arm-eabi-strip
289
290     CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
291     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
292     CXXFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CXXFLAGS"
293
294     dnl Add -llog by default, since we use it all over the place.
295     dnl Add --allow-shlib-undefined, because libGLESv2 links to an
296     dnl undefined symbol (present on the hardware, just not in the
297     dnl NDK.)
298     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
299
300     dnl prevent cross compile section from using these flags as host flags
301     if test -z "$HOST_CPPFLAGS" ; then
302         HOST_CPPFLAGS=" "
303     fi
304     if test -z "$HOST_CFLAGS" ; then
305         HOST_CFLAGS=" "
306     fi
307     if test -z "$HOST_CXXFLAGS" ; then
308         HOST_CXXFLAGS=" "
309     fi
310     if test -z "$HOST_LDFLAGS" ; then
311         HOST_LDFLAGS=" "
312     fi
313
314     ANDROID_NDK="${android_ndk}"
315     ANDROID_TOOLCHAIN="{android_toolchain}"
316     ANDROID_PLATFORM="{android_platform}"
317     ANDROID_SDK="${android_sdk}"
318     ANDROID_PLATFORM_TOOLS="${android_platform_tools}"
319     ANDROID_VERSION="${android_version}"
320
321     # save these for libffi's subconfigure,
322     # which doesn't know how to figure this stuff out on its own
323     ANDROID_CFLAGS="$CFLAGS"
324     ANDROID_CPPFLAGS="$CPPFLAGS"
325     ANDROID_LDFLAGS="$LDFLAGS"
326
327     AC_DEFINE(ANDROID)
328     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
329     AC_SUBST(ANDROID_VERSION)
330     CROSS_COMPILE=1
331     MOZ_CHROME_FILE_FORMAT=omni
332 fi
333
334 AC_SUBST(ANDROID_NDK)
335 AC_SUBST(ANDROID_TOOLCHAIN)
336 AC_SUBST(ANDROID_PLATFORM)
337 AC_SUBST(ANDROID_SDK)
338 AC_SUBST(ANDROID_PLATFORM_TOOLS)
339
340 dnl ========================================================
341 dnl Checks for compilers.
342 dnl ========================================================
343 dnl Set CROSS_COMPILE in the environment when running configure
344 dnl to use the cross-compile setup for now
345 dnl ========================================================
346
347 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
348 AR_FLAGS='cr $@'
349
350 if test "$COMPILE_ENVIRONMENT"; then
351
352 # Note:
353 #   In Mozilla, we use the names $target, $host and $build incorrectly, but are
354 #   too far gone to back out now. See Bug 475488:
355 #     - When we say $target, we mean $host, that is, the system on which
356 #       Mozilla will be run.
357 #     - When we say $host, we mean $build, that is, the system on which Mozilla
358 #       is built.
359 #     - $target (in its correct usage) is for compilers who generate code for a
360 #       different platform than $host, so it would not be used by Mozilla.
361 if test "$target" != "$host"; then
362     echo "cross compiling from $host to $target"
363
364     _SAVE_CC="$CC"
365     _SAVE_CFLAGS="$CFLAGS"
366     _SAVE_LDFLAGS="$LDFLAGS"
367
368     AC_MSG_CHECKING([for host c compiler])
369     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
370     if test -z "$HOST_CC"; then
371         AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
372     fi
373     AC_MSG_RESULT([$HOST_CC])
374     AC_MSG_CHECKING([for host c++ compiler])
375     AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
376     if test -z "$HOST_CXX"; then
377         AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
378     fi
379     AC_MSG_RESULT([$HOST_CXX])
380
381     if test -z "$HOST_CFLAGS"; then
382         HOST_CFLAGS="$CFLAGS"
383     fi
384     if test -z "$HOST_CXXFLAGS"; then
385         HOST_CXXFLAGS="$CXXFLAGS"
386     fi
387     if test -z "$HOST_LDFLAGS"; then
388         HOST_LDFLAGS="$LDFLAGS"
389     fi
390     if test -z "$HOST_AR_FLAGS"; then
391         HOST_AR_FLAGS="$AR_FLAGS"
392     fi
393     AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
394     AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
395     CC="$HOST_CC"
396     CFLAGS="$HOST_CFLAGS"
397     LDFLAGS="$HOST_LDFLAGS"
398
399     AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
400     AC_TRY_COMPILE([], [return(0);], 
401         [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
402         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
403
404     CC="$HOST_CXX"
405     CFLAGS="$HOST_CXXFLAGS"
406
407     AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
408     AC_TRY_COMPILE([], [return(0);], 
409         [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
410         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
411     
412     CC=$_SAVE_CC
413     CFLAGS=$_SAVE_CFLAGS
414     LDFLAGS=$_SAVE_LDFLAGS
415
416     case "$build:$target" in
417       powerpc-apple-darwin8*:i?86-apple-darwin*)
418         dnl The Darwin cross compiler doesn't necessarily point itself at a
419         dnl root that has libraries for the proper architecture, it defaults
420         dnl to the system root.  The libraries in the system root on current
421         dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
422         dnl checks will fail.  Fake a working SDK in that case.
423         _SAVE_CFLAGS=$CFLAGS
424         _SAVE_CXXFLAGS=$CXXLAGS
425         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk $CFLAGS"
426         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk $CXXFLAGS"
427         ;;
428     esac
429
430     case "$target" in
431     *symbian*)
432         AC_ARG_WITH(symbian-sdk,
433         [  --with-symbian-sdk=SYMBIAN_SDK_DIR
434                           The path to the Symbian SDK],
435         SYMBIAN_SDK_DIR=$withval)
436
437         OS_EXE_CFLAGS="$OS_EXE_CFLAGS -D__EXE__"
438         CFLAGS="-MD -nostdinc"
439         SYMBIAN_SYS_INCLUDE="-I$SYMBIAN_SDK_DIR/Epoc32/include -I$SYMBIAN_SDK_DIR/Epoc32/include/variant -I$SYMBIAN_SDK_DIR/Epoc32/include/stdapis"
440
441         case "$target" in
442         *-symbianelf)
443             OS_TARGET=GCCE
444             CC=arm-none-symbianelf-gcc.exe
445             CXX=arm-none-symbianelf-g++.exe
446             LD=arm-none-symbianelf-ld.exe
447             AR=arm-none-symbianelf-ar.exe
448             CPP=arm-none-symbianelf-cpp.exe
449             CFLAGS="$CFLAGS -c -Wall -Wno-unknown-pragmas -fexceptions -march=armv5t -mapcs -pipe -msoft-float"
450             CXXFLAGS="$CFLAGS -Wno-ctor-dtor-privacy"
451             GCCE_INCLUDE="-include $SYMBIAN_SDK_DIR/EPOC32/INCLUDE/GCCE/GCCE.h -D__PRODUCT_INCLUDE__=$SYMBIAN_SDK_DIR/Epoc32/include/variant/Symbian_OS_v9.2.hrh"
452             CFLAGS="$CFLAGS ${GCCE_INCLUDE} -x c"
453             CXXFLAGS="$CXXFLAGS ${GCCE_INCLUDE} -x c++"
454             CPPFLAGS="$CPPFLAGS ${SYMBIAN_SYS_INCLUDE}"
455             ;;
456         *-symbianwinscw)
457             dnl TODO: add emulator build code
458             OS_TARGET=WINSCW
459             ;;
460         esac
461         ;;
462     esac
463
464     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
465     unset ac_cv_prog_CC
466     AC_PROG_CC
467     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
468     unset ac_cv_prog_CXX
469     AC_PROG_CXX
470
471     case "$build:$target" in
472       powerpc-apple-darwin8*:i?86-apple-darwin*)
473         dnl Revert the changes made above.  From this point on, the target
474         dnl compiler will never be used without applying the SDK to CFLAGS
475         dnl (see --with-macos-sdk below).
476         CFLAGS=$_SAVE_CFLAGS
477         CXXFLAGS=$_SAVE_CXXFLAGS
478         ;;
479     esac
480
481     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
482     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
483     MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
484     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
485     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
486     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
487     AC_DEFINE(CROSS_COMPILE)
488
489     dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will
490     dnl have erroneously been set to "no", because the x86 build host is
491     dnl able to run ppc code in a translated environment, making a cross
492     dnl compiler appear native.  So we override that here.
493     cross_compiling=yes
494 else
495     AC_PROG_CC
496     AC_PROG_CXX
497     AC_PROG_RANLIB
498     MOZ_PATH_PROGS(AS, $AS as, $CC)
499     AC_CHECK_PROGS(AR, ar, :)
500     AC_CHECK_PROGS(LD, ld, :)
501     AC_CHECK_PROGS(STRIP, strip, :)
502     AC_CHECK_PROGS(WINDRES, windres, :)
503     if test -z "$HOST_CC"; then
504         HOST_CC='$(CC)'
505     fi
506     if test -z "$HOST_CFLAGS"; then
507         HOST_CFLAGS='$(CFLAGS)'
508     fi
509     if test -z "$HOST_CXX"; then
510         HOST_CXX='$(CXX)'
511     fi
512     if test -z "$HOST_CXXFLAGS"; then
513         HOST_CXXFLAGS='$(CXXFLAGS)'
514     fi
515     if test -z "$HOST_LDFLAGS"; then
516         HOST_LDFLAGS='$(LDFLAGS)'
517     fi
518     if test -z "$HOST_RANLIB"; then
519         HOST_RANLIB='$(RANLIB)'
520     fi
521     if test -z "$HOST_AR"; then
522         HOST_AR='$(AR)'
523     fi
524     if test -z "$HOST_AR_FLAGS"; then
525         HOST_AR_FLAGS='$(AR_FLAGS)'
526     fi
527 fi
528
529 GNU_AS=
530 GNU_LD=
531 GNU_CC=
532 GNU_CXX=
533 CC_VERSION='N/A'
534 CXX_VERSION='N/A'
535 if test "$GCC" = "yes"; then
536     GNU_CC=1
537     CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
538 fi
539 if test "$GXX" = "yes"; then
540     GNU_CXX=1
541     CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
542 fi
543 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
544     GNU_AS=1
545 fi
546 if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
547     GNU_LD=1
548 fi
549 if test "$GNU_CC"; then
550     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
551         GCC_USE_GNU_LD=1
552     fi
553 fi
554
555 INTEL_CC=
556 INTEL_CXX=
557 if test "$GCC" = yes; then
558    if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
559      INTEL_CC=1
560    fi
561 fi
562
563 if test "$GXX" = yes; then
564    if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
565      INTEL_CXX=1
566    fi
567 fi
568
569 dnl Special win32 checks
570 dnl ========================================================
571 case "$target" in
572 *-wince|*-winmo)
573     WINVER=500
574     WINSDK_TARGETVER=502
575     ;;
576 *)
577     WINVER=502
578     dnl Target the Windows 7 SDK by default
579     WINSDK_TARGETVER=601
580     ;;
581 esac
582
583 MOZ_ARG_WITH_STRING(windows-version,
584 [  --with-windows-version=WINSDK_TARGETVER
585                           Highest Windows version to target using this SDK
586                               502: Windows Server 2003
587                               600: Windows Vista
588                               601: Windows 7],
589   WINSDK_TARGETVER=$withval)
590
591 case "$WINSDK_TARGETVER" in
592 502|600|601)
593     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
594     ;;
595
596 *)
597     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER), must be 502, 600 or 601]);
598     ;;
599
600 esac
601
602 case "$target" in
603 *-cygwin*|*-mingw*|*-msvc*|*-mks*|*-wince|*-winmo)
604     if test "$GCC" != "yes"; then
605         # Check to see if we are really running in a msvc environemnt
606         _WIN32_MSVC=1
607
608         # Make sure compilers are valid
609         CFLAGS="$CFLAGS -TC -nologo"
610         CXXFLAGS="$CXXFLAGS -TP -nologo"
611         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
612         # _CRT_SECURE_NO_WARNINGS disables warnings about using MSVC-specific
613         # secure CRT functions.
614         CXXFLAGS="$CXXFLAGS -wd4345 -D_CRT_SECURE_NO_WARNINGS"
615         AC_LANG_SAVE
616         AC_LANG_C
617         AC_TRY_COMPILE([#include <stdio.h>],
618             [ printf("Hello World\n"); ],,
619             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
620
621         AC_LANG_CPLUSPLUS
622         AC_TRY_COMPILE([#include <new.h>],
623             [ unsigned *test = new unsigned(42); ],,
624             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
625         AC_LANG_RESTORE
626         
627         changequote(,)
628         _MSVC_VER_FILTER='s|.* ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
629         changequote([,])
630         
631         # Determine compiler version
632         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
633         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
634         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
635         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
636         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
637         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
638
639         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
640         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
641
642         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
643             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
644         fi
645
646         if test "$_CC_MAJOR_VERSION" = "14"; then
647             dnl Require VC8SP1 or newer.
648             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
649             if test "$_CC_RELEASE" -lt 50727 -o \
650                     \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
651               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.])
652             fi
653
654             _CC_SUITE=8
655             CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
656             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
657             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
658         elif test "$_CC_MAJOR_VERSION" = "15"; then
659             _CC_SUITE=9
660             CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
661             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
662             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
663         elif test "$_CC_MAJOR_VERSION" = "16"; then
664             _CC_SUITE=10
665             CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
666             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
667             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
668         else
669             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
670         fi
671
672         _MOZ_RTTI_FLAGS_ON='-GR'
673         _MOZ_RTTI_FLAGS_OFF='-GR-'
674         _MOZ_EXCEPTIONS_FLAGS_ON='-EHsc'
675         _MOZ_EXCEPTIONS_FLAGS_OFF=''
676
677         if test -n "$WIN32_REDIST_DIR"; then
678             WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
679         fi
680
681         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
682         dnl not something else like "magnetic tape manipulation utility".
683         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
684         if test -z "$MSMT_TOOL"; then
685           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
686         fi
687
688         changequote(,)
689         _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
690         changequote([,])
691         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
692         if test -z "$MSMANIFEST_TOOL_VERSION"; then
693           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
694         fi
695
696         MSMANIFEST_TOOL=1
697         unset MSMT_TOOL
698
699         # Check linker version
700         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
701         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
702         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
703             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
704         fi
705
706         INCREMENTAL_LINKER=1
707
708         # Identify which version of the SDK we're building with
709         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
710         # from there
711         AC_CHECK_HEADERS([winsdkver.h])
712         if test "$ac_cv_header_winsdkver_h" = "yes"; then
713             # Get the highest _WIN32_WINNT and NTDDI versions supported
714             # Take the higher of the two
715             # This is done because the Windows 7 beta SDK reports its
716             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
717             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
718                            ac_cv_winsdk_maxver,
719                            [cat > conftest.h <<EOF
720 #include <winsdkver.h>
721 #include <sdkddkver.h>
722
723 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
724 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
725 #else
726 #define WINSDK_MAXVER NTDDI_MAXVER
727 #endif
728
729 WINSDK_MAXVER
730 EOF
731                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
732                             rm -f conftest.h
733                            ])
734             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
735         else
736             # The Vista SDK is the only one to have sdkddkver.h but not
737             # WinSDKVer.h
738             AC_CHECK_HEADERS([sdkddkver.h])
739             if test "$ac_cv_header_sdkddkver_h" = "yes"; then
740                 MOZ_WINSDK_MAXVER=0x06000000
741             else
742                 # Assume the Server 2003 Platform SDK
743                 MOZ_WINSDK_MAXVER=0x05020000
744             fi
745         fi
746
747         unset _MSVC_VER_FILTER
748
749         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
750             [
751                 AC_LANG_SAVE
752                 AC_LANG_CPLUSPLUS
753                 _SAVE_CXXFLAGS="$CXXFLAGS"
754                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
755                 AC_TRY_COMPILE([#include <exception>],
756                             [std::_Throw(std::exception()); return 0;],
757                             ac_cv_have_std__Throw="yes",
758                             ac_cv_have_std__Throw="no")
759                 CXXFLAGS="$_SAVE_CXXFLAGS"
760                 AC_LANG_RESTORE
761             ])
762
763         if test "$ac_cv_have_std__Throw" == "yes"; then
764             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
765                            ac_cv_have_dllimport_exception_bug,
766                 [
767                     AC_LANG_SAVE
768                     AC_LANG_CPLUSPLUS
769                     _SAVE_CXXFLAGS="$CXXFLAGS"
770                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
771                     AC_TRY_LINK([#include <vector>],
772                                 [std::vector<int> v; return v.at(1);],
773                                 ac_cv_have_dllimport_exception_bug="no",
774                                 ac_cv_have_dllimport_exception_bug="yes")
775                     CXXFLAGS="$_SAVE_CXXFLAGS"
776                     AC_LANG_RESTORE
777                 ])
778             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
779                 WRAP_STL_INCLUDES=1
780                 MOZ_MSVC_STL_WRAP__Throw=1
781                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
782             fi
783         else
784             AC_CACHE_CHECK(for overridable _RAISE,
785                            ac_cv_have__RAISE,
786                 [
787                     AC_LANG_SAVE
788                     AC_LANG_CPLUSPLUS
789                     _SAVE_CXXFLAGS="$CXXFLAGS"
790                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
791                     AC_TRY_COMPILE([#include <xstddef>
792                                     #undef _RAISE
793                                     #define _RAISE(x) externallyDefinedFunction((x).what())
794                                     #include <vector>
795                                    ],
796                                    [std::vector<int> v; return v.at(1);],
797                                    ac_cv_have__RAISE="no",
798                                    ac_cv_have__RAISE="yes")
799                     CXXFLAGS="$_SAVE_CXXFLAGS"
800                     AC_LANG_RESTORE
801                 ])
802             if test "$ac_cv_have__RAISE" = "yes"; then
803                 WRAP_STL_INCLUDES=1
804                 MOZ_MSVC_STL_WRAP__RAISE=1
805                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
806             else
807                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
808             fi
809         fi
810
811         if test "$WRAP_STL_INCLUDES" = "1"; then
812             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
813         fi
814     else
815         # Check w32api version
816         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
817         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
818         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
819         AC_TRY_COMPILE([#include <w32api.h>],
820             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
821                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
822                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
823                 #error "test failed."
824             #endif
825             , [ res=yes ], [ res=no ])
826         AC_MSG_RESULT([$res])
827         if test "$res" != "yes"; then
828             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
829         fi
830         # Check windres version
831         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
832         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
833         AC_MSG_RESULT([$_WINDRES_VERSION])
834         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
835         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
836         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
837         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
838         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
839         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
840         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
841                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
842                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
843                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
844                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
845                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
846         then
847             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
848         fi
849
850         # Server 2003 is the highest version supported
851         MOZ_WINSDK_MAXVER=0x05020000
852     fi # !GNU_CC
853
854     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
855     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
856     # Require OS features provided by IE 5.0
857     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0500)
858
859     # If the maximum version supported by this SDK is lower than the target
860     # version, error out
861     AC_MSG_CHECKING([for Windows SDK being recent enough])
862     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
863         AC_MSG_RESULT("yes")
864     else
865         AC_MSG_RESULT("no")
866         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.])
867     fi
868
869     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
870     # Definitions matching sdkddkver.h
871     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WS03, 0x05020000)
872     AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
873     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
874     ;;
875 esac
876
877 dnl Test breaks icc on OS/2 && MSVC
878 if test "$CC" != "icc" -a -z "$_WIN32_MSVC"; then
879     AC_PROG_CC_C_O
880     if grep "NO_MINUS_C_MINUS_O 1" ./confdefs.h >/dev/null; then
881         USING_HCC=1
882         _OLDCC=$CC
883         _OLDCXX=$CXX
884         CC="${srcdir}/build/hcc '$CC'"
885         CXX="${srcdir}/build/hcpp '$CXX'"
886     fi
887 fi
888
889 AC_PROG_CPP
890 AC_PROG_CXXCPP
891
892 if test -n "$_WIN32_MSVC"; then
893     SKIP_PATH_CHECKS=1
894     SKIP_COMPILER_CHECKS=1
895     SKIP_LIBRARY_CHECKS=1
896
897     # Since we're skipping compiler and library checks, hard-code
898     # some facts here.
899
900     # Common to all MSVC environments:
901     # Windows lacks <stdint.h>, but has __int8, and so on.
902     AC_DEFINE(JS_HAVE___INTN)
903     AC_DEFINE(HAVE_LOCALECONV)
904
905     case "$target" in
906     *-wince|*-winmo)
907         AC_DEFINE(HAVE_SYSTEMTIMETOFILETIME)
908         AC_DEFINE(JS_CRTDEFS_H_HAS_INTPTR_T)
909         ;;
910     *)
911         AC_DEFINE(HAVE_SYSTEMTIMETOFILETIME)
912         AC_DEFINE(HAVE_GETSYSTEMTIMEASFILETIME)
913         # Windows <stddef.h> defines intptr_t and uintptr_t.
914         # VS2005: http://msdn.microsoft.com/en-us/library/323b6b3k(VS.80).aspx
915         # VS2008: http://msdn.microsoft.com/en-us/library/323b6b3k.aspx
916         AC_DEFINE(JS_STDDEF_H_HAS_INTPTR_T)
917         ;;
918     esac
919 fi
920
921 fi # COMPILE_ENVIRONMENT
922
923 if test "$cross_compiling"  = "yes"; then
924     CROSS_COMPILE=1
925 else
926     CROSS_COMPILE=
927 fi
928
929 # Check to see if we are running in a broken QEMU scratchbox.
930 # We know that anything below 1.0.16 is broken.
931 AC_CHECK_PROGS(SBCONF, sb-conf ve, "")
932 if test -n "$SBCONF"; then
933     _sb_version=`$SBCONF ve`
934     _sb_version_major=`echo $_sb_version | cut -f1 -d.`
935     _sb_version_minor=`echo $_sb_version | cut -f2 -d.`
936     _sb_version_point=`echo $_sb_version | cut -f3 -d.`
937     if test $_sb_version_major -eq 1 -a $_sb_version_minor -eq 0 -a $_sb_version_point -le 16; then
938         QEMU_CANT_RUN_JS_SHELL=1
939     fi
940 fi
941 AC_SUBST(QEMU_CANT_RUN_JS_SHELL)
942
943 AC_SUBST(_MSC_VER)
944
945 AC_SUBST(GNU_AS)
946 AC_SUBST(GNU_LD)
947 AC_SUBST(GNU_CC)
948 AC_SUBST(GNU_CXX)
949 AC_SUBST(INTEL_CC)
950 AC_SUBST(INTEL_CXX)
951
952 AC_SUBST(STL_FLAGS)
953 AC_SUBST(WRAP_STL_INCLUDES)
954 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
955 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
956
957 dnl ========================================================
958 dnl Checks for programs.
959 dnl ========================================================
960 AC_PROG_INSTALL
961 AC_PROG_LN_S
962
963 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
964 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
965 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
966 _perl_res=$?
967 AC_MSG_RESULT([$_perl_version])
968
969 if test "$_perl_res" != 0; then
970     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
971 fi
972 fi
973
974 AC_MSG_CHECKING([for full perl installation])
975 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
976 _perl_res=$?
977 if test "$_perl_res" != 0; then
978     AC_MSG_RESULT([no])
979     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
980 else
981     AC_MSG_RESULT([yes])    
982 fi
983
984 MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python2.6 python2.5 python)
985 if test -z "$PYTHON"; then
986     AC_MSG_ERROR([python was not found in \$PATH])
987 fi
988
989 if test -z "$COMPILE_ENVIRONMENT"; then
990     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
991 fi
992 AC_SUBST(NSINSTALL_BIN)
993
994 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
995 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
996 MOZ_PATH_PROG(UNZIP, unzip, :)
997 MOZ_PATH_PROGS(ZIP, zip)
998 if test -z "$ZIP" -o "$ZIP" = ":"; then
999     AC_MSG_ERROR([zip not found in \$PATH])
1000 fi
1001 MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
1002 MOZ_PATH_PROG(XARGS, xargs)
1003 if test -z "$XARGS" -o "$XARGS" = ":"; then
1004     AC_MSG_ERROR([xargs not found in \$PATH .])
1005 fi
1006
1007 if test "$COMPILE_ENVIRONMENT"; then
1008
1009 dnl ========================================================
1010 dnl = Mac OS X toolchain support
1011 dnl ========================================================
1012
1013 case "$target_os" in
1014 darwin*)
1015     dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
1016     dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
1017     dnl the environment and includedir purposes (when using an SDK, below),
1018     dnl but remember the full version number for the libdir (SDK).
1019     changequote(,)
1020     GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1021     GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1022     changequote([,])
1023     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
1024         dnl Bug 280479, but this keeps popping up in bug 292530 too because
1025         dnl 4.0.0/4061 is the default compiler in Tiger.
1026         changequote(,)
1027         GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
1028         changequote([,])
1029         if test "$GCC_BUILD" = "4061" ; then
1030             AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
1031 This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
1032 from building Mozilla. Upgrade to Xcode 2.1 or later.])
1033         fi
1034     fi
1035
1036     dnl xcodebuild needs GCC_VERSION defined in the environment, since it
1037     dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
1038     dnl /usr/bin/g(cc|++)-$GCC_VERSION.
1039     MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
1040
1041     case "$PBBUILD" in
1042       *xcodebuild*)
1043         changequote(,)
1044         XCODEBUILD_VERSION=`$PBBUILD -version 2>/dev/null | xargs | sed -e 's/.*DevToolsCore-\([0-9]*\).*/\1/'`
1045         changequote([,])
1046         if test -n "$XCODEBUILD_VERSION" && test "$XCODEBUILD_VERSION" -ge 620 ; then
1047           HAS_XCODE_2_1=1;
1048         fi
1049       ;;
1050     esac
1051
1052     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
1053     dnl it has moved into /usr/bin.
1054     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
1055     ;;
1056 esac
1057
1058 AC_SUBST(GCC_VERSION)
1059 AC_SUBST(XCODEBUILD_VERSION)
1060 AC_SUBST(HAS_XCODE_2_1)
1061
1062 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
1063 dnl that a universal binary is being produced.
1064 AC_SUBST(UNIVERSAL_BINARY)
1065
1066 dnl ========================================================
1067 dnl Check for MacOS deployment target version
1068 dnl ========================================================
1069
1070 MOZ_ARG_ENABLE_STRING(macos-target,
1071                       [  --enable-macos-target=VER (default=10.5)
1072                           Set the minimum MacOS version needed at runtime],
1073                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
1074
1075 case "$target" in
1076 *-darwin*)
1077     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1078         dnl Use the specified value
1079         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1080         AC_DEFINE_UNQUOTED(__ENVIRONMENT_MAC_OS_X_VERION_MIN_REQUIRED__,$_MACOSX_DEPLOYMENT_TARGET)
1081     else
1082         dnl No value specified on the command line or in the environment,
1083         dnl use architecture minimum.
1084         case "${target_cpu}" in
1085           ppc*)
1086             export MACOSX_DEPLOYMENT_TARGET=10.5
1087             ;;
1088           i*86)
1089             export MACOSX_DEPLOYMENT_TARGET=10.5
1090             ;;
1091           x86_64)
1092             export MACOSX_DEPLOYMENT_TARGET=10.6
1093             ;;
1094         esac
1095     fi
1096     ;;
1097 esac
1098
1099 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
1100
1101 dnl ========================================================
1102 dnl = Mac OS X SDK support
1103 dnl ========================================================
1104 MACOS_SDK_DIR=
1105 NEXT_ROOT=
1106 MOZ_ARG_WITH_STRING(macos-sdk,
1107 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
1108     MACOS_SDK_DIR=$withval)
1109
1110 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
1111 dnl NEXT_ROOT will be set and exported only if it's needed.
1112 AC_SUBST(MACOS_SDK_DIR)
1113 AC_SUBST(NEXT_ROOT)
1114
1115 if test "$MACOS_SDK_DIR"; then
1116   dnl Sync this section with the ones in NSPR and NSS.
1117   dnl Changes to the cross environment here need to be accounted for in
1118   dnl the libIDL checks (below) and xpidl build.
1119
1120   if test ! -d "$MACOS_SDK_DIR"; then
1121     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1122 specify a valid SDK.  SDKs are installed when the optional cross-development
1123 tools are selected during the Xcode/Developer Tools installation.])
1124   fi
1125
1126   GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1127   if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1128     AC_MSG_ERROR([You need to upgrade the compiler version to 4.x])
1129   else
1130     CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1131     CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
1132
1133     dnl CPP/CXXCPP needs to be set for AC_CHECK_HEADER.
1134     CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1135     CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
1136
1137     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
1138       dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
1139       dnl that supports -syslibroot.  Don't set NEXT_ROOT because it will
1140       dnl be ignored and cause warnings when -syslibroot is specified.
1141       dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
1142       dnl the -isysroot it receives, so this is only needed with 4.0.0.
1143       LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1144     fi
1145   fi
1146
1147   AC_LANG_SAVE
1148   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
1149   AC_LANG_CPLUSPLUS
1150   AC_TRY_COMPILE([#include <new>
1151                  int main() { return 0; }],
1152    result=yes,
1153    result=no)
1154   AC_LANG_RESTORE
1155   AC_MSG_RESULT($result)
1156
1157   if test "$result" = "no" ; then
1158     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
1159   fi
1160 fi
1161
1162 fi # COMPILE_ENVIRONMENT
1163
1164 if test -n "$MAKE"; then
1165   if test `echo $MAKE | grep -c make.py` != 1; then
1166      NOT_PYMAKE=$MAKE
1167   fi
1168 fi
1169
1170 case "$host_os" in
1171 cygwin*|mingw*|mks*|msvc*)
1172     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
1173     ;;
1174 *)
1175     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
1176     ;;
1177 esac
1178 if test "$GMAKE" = ":"; then
1179    AC_MSG_ERROR([GNU make not found])
1180 fi
1181 AC_SUBST(GMAKE)
1182
1183 if test "$COMPILE_ENVIRONMENT"; then
1184
1185 AC_PATH_XTRA
1186
1187 XCFLAGS="$X_CFLAGS"
1188
1189 fi # COMPILE_ENVIRONMENT
1190
1191 dnl ========================================================
1192 dnl set the defaults first
1193 dnl ========================================================
1194 AS_BIN=$AS
1195 AR_LIST='$(AR) t'
1196 AR_EXTRACT='$(AR) x'
1197 AR_DELETE='$(AR) d'
1198 AS='$(CC)'
1199 AS_DASH_C_FLAG='-c'
1200 DLL_PREFIX=lib
1201 LIB_PREFIX=lib
1202 DLL_SUFFIX=.so
1203 OBJ_SUFFIX=o
1204 LIB_SUFFIX=a
1205 ASM_SUFFIX=s
1206 IMPORT_LIB_SUFFIX=
1207 TARGET_MD_ARCH=unix
1208 DIRENT_INO=d_ino
1209 CYGWIN_WRAPPER=
1210 WIN_TOP_SRC=
1211 MOZ_USER_DIR=".mozilla"
1212
1213 MOZ_JS_LIBS='-L$(libdir) -lmozjs'
1214 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1215
1216 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1217
1218 USE_DEPENDENT_LIBS=1
1219
1220 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1221
1222 if test -n "$CROSS_COMPILE"; then
1223     OS_TARGET="${target_os}"
1224     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1225     OS_RELEASE=
1226     case "${target_os}" in
1227         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1228         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1229         gnu*)         OS_ARCH=GNU ;;
1230         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1231         mingw*)       OS_ARCH=WINNT ;;
1232         wince*)       OS_ARCH=WINCE ;;
1233         winmo*)       OS_ARCH=WINCE ;;
1234         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1235     esac
1236     case "${target}" in
1237         arm-android-eabi) OS_ARCH=Linux OS_TARGET=Android ;;
1238     esac
1239 else
1240     OS_TARGET=`uname -s`
1241     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1242     OS_RELEASE=`uname -r`
1243 fi
1244
1245 # Before this used `uname -m` when not cross compiling
1246 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1247 OS_TEST="${target_cpu}"
1248
1249 _COMPILER_PREFIX=
1250
1251 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1252
1253 #######################################################################
1254 # Master "Core Components" macros for getting the OS target           #
1255 #######################################################################
1256
1257 #
1258 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1259 # cross-compilation.
1260 #
1261
1262 #
1263 # Define and override various archtecture-specific variables, including
1264 # HOST_OS_ARCH
1265 # OS_ARCH
1266 # OS_TEST
1267 # OS_TARGET
1268 # OS_RELEASE
1269 # OS_MINOR_RELEASE
1270 #
1271
1272 case "$HOST_OS_ARCH" in
1273 cygwin*|mingw*|mks*|msvc*)
1274     HOST_OS_ARCH=WINNT
1275     ;;
1276 darwin*)
1277     HOST_OS_ARCH=Darwin
1278     ;;
1279 linux*)
1280     HOST_OS_ARCH=Linux
1281     ;;
1282 solaris*)
1283     HOST_OS_ARCH=SunOS
1284     SOLARIS_SUNPRO_CC=
1285     SOLARIS_SUNPRO_CXX=
1286     if test -z "$GNU_CC"; then
1287         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1288             SOLARIS_SUNPRO_CC=1
1289        fi
1290     fi
1291
1292     if test -z "$GNU_CXX"; then
1293        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1294            SOLARIS_SUNPRO_CXX=1
1295        fi
1296     fi
1297     AC_SUBST(SOLARIS_SUNPRO_CC)
1298     AC_SUBST(SOLARIS_SUNPRO_CXX)
1299     ;;
1300 BSD_386)
1301     HOST_OS_ARCH=BSD
1302     ;;
1303 dgux)
1304     HOST_OS_ARCH=DGUX
1305     ;;
1306 IRIX64)
1307     HOST_OS_ARCH=IRIX
1308     ;;
1309 UNIX_SV)
1310     if "`cat /etc/bcheckrc | grep -c NCR 2>/dev/null`" != "0"; then
1311         HOST_OS_ARCH=NCR
1312     else
1313         HOST_OS_ARCH=UNIXWARE
1314     fi
1315     ;;
1316 ncr)
1317     HOST_OS_ARCH=NCR
1318     ;;
1319 UNIX_SYSTEM_V)
1320     HOST_OS_ARCH=NEC
1321     ;;
1322 OSF1)
1323     ;;
1324 *OpenVMS*)
1325     HOST_OS_ARCH=OpenVMS
1326     ;;
1327 OS_2)
1328     HOST_OS_ARCH=OS2
1329     ;;
1330 QNX)
1331     ;;
1332 SCO_SV)
1333     HOST_OS_ARCH=SCOOS
1334     ;;
1335 SINIX-N | SINIX-Y | SINIX-Z |ReliantUNIX-M)
1336     HOST_OS_ARCH=SINIX
1337     ;;
1338 UnixWare)
1339     HOST_OS_ARCH=UNIXWARE
1340     ;;
1341 esac
1342
1343 case "$OS_ARCH" in
1344 WINNT)
1345     if test -z "$CROSS_COMPILE" ; then
1346         OS_TEST=`uname -p`
1347     fi
1348     ;;
1349 Windows_NT)
1350 #
1351 # If uname -s returns "Windows_NT", we assume that we are using
1352 # the uname.exe in MKS toolkit.
1353 #
1354 # The -r option of MKS uname only returns the major version number.
1355 # So we need to use its -v option to get the minor version number.
1356 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1357 #
1358     OS_ARCH=WINNT
1359     OS_TARGET=WINNT
1360     OS_MINOR_RELEASE=`uname -v`
1361     if test "$OS_MINOR_RELEASE" = "00"; then
1362         OS_MINOR_RELEASE=0
1363     fi
1364     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1365     ;;
1366 CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*)
1367 #
1368 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
1369 # the uname.exe in the Cygwin tools.
1370 # Prior to the Beta 20 release, Cygwin was called GNU-Win32.
1371 # If uname -s returns "CYGWIN32/NT", we assume that we are using
1372 # the uname.exe in the GNU-Win32 tools.
1373 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1374 # the uname.exe in the MSYS tools.
1375 #
1376     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1377     OS_ARCH=WINNT
1378     OS_TARGET=WINNT
1379     ;;
1380 AIX)
1381     OS_RELEASE=`uname -v`.`uname -r`
1382     OS_TEST=${target_cpu}
1383     if test -z "$GNU_CC"; then
1384         if test "`$CC -qversion 2>&1 | egrep -c 'IBM XL'`" != "0"; then
1385             AIX_IBM_XLC=1
1386         fi
1387     fi
1388     ;;
1389 BSD_386)
1390     OS_ARCH=BSD
1391     ;;
1392 dgux)
1393     OS_ARCH=DGUX
1394     ;;
1395 IRIX64)
1396     OS_ARCH=IRIX
1397     ;;
1398 UNIX_SV)
1399     if "`cat /etc/bcheckrc | grep -c NCR 2>/dev/null`" != "0"; then
1400         OS_ARCH=NCR
1401     else
1402         OS_ARCH=UNIXWARE
1403         OS_RELEASE=`uname -v`
1404     fi
1405     ;;
1406 ncr)
1407     OS_ARCH=NCR
1408     ;;
1409 UNIX_SYSTEM_V)
1410     OS_ARCH=NEC
1411     ;;
1412 OSF1)
1413     case `uname -v` in
1414     148)
1415         OS_RELEASE=V3.2C
1416         ;;
1417     564)
1418         OS_RELEASE=V4.0B
1419         ;;
1420     878)
1421         OS_RELEASE=V4.0D
1422         ;;
1423     esac
1424     ;;
1425 *OpenVMS*)
1426     OS_ARCH=OpenVMS
1427     OS_RELEASE=`uname -v`
1428     OS_TEST=`uname -p`
1429     ;;
1430 OS_2)
1431     OS_ARCH=OS2
1432     OS_TARGET=OS2
1433     OS_RELEASE=`uname -v`
1434     ;;
1435 QNX)
1436     if test "$OS_TARGET" != "NTO"; then
1437         changequote(,)
1438         OS_RELEASE=`uname -v | sed 's/^\([0-9]\)\([0-9]*\)$/\1.\2/'`
1439         changequote([,])
1440     fi
1441     OS_TEST=x86
1442     ;;
1443 SCO_SV)
1444     OS_ARCH=SCOOS
1445     OS_RELEASE=5.0
1446     ;;
1447 SINIX-N | SINIX-Y | SINIX-Z |ReliantUNIX-M)
1448     OS_ARCH=SINIX
1449     OS_TEST=`uname -p`
1450     ;;
1451 UnixWare)
1452     OS_ARCH=UNIXWARE
1453     OS_RELEASE=`uname -v`
1454     ;;
1455 WINCE)
1456     OS_ARCH=WINCE
1457     case "${target_os}" in
1458     *winmo)
1459         OS_TARGET=WINMO
1460         WINCE_WINDOWS_MOBILE=1
1461         AC_DEFINE(WINCE_WINDOWS_MOBILE)
1462         ;;
1463     *)
1464         OS_TARGET=WINCE
1465         ;;
1466     esac
1467     ;;
1468 Darwin)
1469     case "${target_cpu}" in
1470     powerpc*)
1471         OS_TEST=ppc
1472         ;;
1473     i*86*)
1474         OS_TEST=i386 
1475         ;;
1476     x86_64)
1477         OS_TEST=x86_64
1478         ;;
1479     *)
1480         if test -z "$CROSS_COMPILE" ; then
1481             OS_TEST=`uname -p`
1482         fi
1483         ;;
1484     esac
1485     ;;
1486 esac
1487
1488 if test "$OS_ARCH" = "NCR"; then
1489     changequote(,)
1490     OS_RELEASE=`awk '{print $3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$/\2.\3/'`
1491     changequote([,])
1492 fi
1493
1494 # Only set CPU_ARCH if we recognize the value of OS_TEST
1495
1496 case "$OS_TEST" in
1497 *86 | i86pc)
1498     CPU_ARCH=x86
1499     ;;
1500
1501 powerpc64 | ppc64)
1502     CPU_ARCH=ppc64
1503     ;;
1504
1505 powerpc | ppc | rs6000)
1506     CPU_ARCH=ppc
1507     ;;
1508
1509 Alpha | alpha | ALPHA)
1510     CPU_ARCH=Alpha
1511     ;;
1512
1513 s390)
1514     CPU_ARCH=s390
1515     ;;
1516
1517 s390x)
1518     CPU_ARCH=s390x
1519     ;;
1520
1521 hppa* | parisc)
1522     CPU_ARCH=hppa
1523     ;;
1524
1525 sun4u | sparc*)
1526     CPU_ARCH=sparc
1527     ;;
1528
1529 x86_64 | ia64)
1530     CPU_ARCH="$OS_TEST"
1531     ;;
1532
1533 arm*)
1534     CPU_ARCH=arm
1535     ;;
1536
1537 aarch64)
1538     CPU_ARCH=aarch64
1539     ;;
1540
1541 mips|mipsel)
1542     CPU_ARCH="mips"
1543     ;;
1544 esac
1545
1546 if test -z "$OS_TARGET"; then
1547     OS_TARGET=$OS_ARCH
1548 fi
1549 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1550
1551 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1552 dnl ===============================================================
1553 INTEL_ARCHITECTURE=
1554 case "$OS_TEST" in
1555     x86_64|i?86)
1556       INTEL_ARCHITECTURE=1
1557 esac
1558
1559 dnl ========================================================
1560 dnl GNU specific defaults
1561 dnl ========================================================
1562 if test "$GNU_CC"; then
1563     # FIXME: Let us build with strict aliasing. bug 414641.
1564     CFLAGS="$CFLAGS -fno-strict-aliasing"
1565     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1566     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1567     DSO_LDOPTS='-shared'
1568     if test "$GCC_USE_GNU_LD"; then
1569         # Don't allow undefined symbols in libraries
1570         DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1571     fi
1572     WARNINGS_AS_ERRORS='-Werror'
1573     DSO_CFLAGS=''
1574     DSO_PIC_CFLAGS='-fPIC'
1575     ASFLAGS="$ASFLAGS -fPIC"
1576     _MOZ_RTTI_FLAGS_ON=${_COMPILER_PREFIX}-frtti
1577     _MOZ_RTTI_FLAGS_OFF=${_COMPILER_PREFIX}-fno-rtti
1578     _MOZ_EXCEPTIONS_FLAGS_ON='-fexceptions'
1579     _MOZ_EXCEPTIONS_FLAGS_OFF='-fno-exceptions'
1580
1581     # Turn on GNU specific features
1582     # -Wall - turn on all warnings
1583     # -pedantic - make compiler warn about non-ANSI stuff, and
1584     #             be a little bit stricter
1585     # Warnings slamm took out for now (these were giving more noise than help):
1586     # -Wbad-function-cast - warns when casting a function to a new return type
1587     # -Wshadow - removed because it generates more noise than help --pete
1588     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith"
1589     if test -z "$INTEL_CC"; then
1590        # Don't use -Wcast-align with ICC
1591        case "$CPU_ARCH" in
1592            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1593            hppa | ia64 | sparc | arm)
1594            ;;
1595            *)
1596         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1597            ;;
1598        esac
1599     fi
1600
1601     dnl Turn pedantic on but disable the warnings for long long
1602     _PEDANTIC=1
1603
1604     if test -z "$INTEL_CC"; then
1605       _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
1606     fi
1607
1608     _DEFINES_CFLAGS='-include $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
1609     _USE_CPP_INCLUDE_FLAG=1
1610 elif test "$SOLARIS_SUNPRO_CC"; then
1611     DSO_CFLAGS=''
1612     if test "$CPU_ARCH" = "sparc"; then
1613         # for Sun Studio on Solaris/SPARC
1614         DSO_PIC_CFLAGS='-xcode=pic32'
1615     else
1616         DSO_PIC_CFLAGS='-KPIC'
1617     fi
1618     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
1619 else
1620     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1621     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1622
1623     DSO_LDOPTS='-shared'
1624     if test "$GNU_LD"; then
1625         # Don't allow undefined symbols in libraries
1626         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1627     fi
1628
1629     DSO_CFLAGS=''
1630     DSO_PIC_CFLAGS='-KPIC'
1631     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
1632 fi
1633
1634 if test "$GNU_CXX"; then
1635     # FIXME: Let us build with strict aliasing. bug 414641.
1636     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
1637     # Turn on GNU specific features
1638     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
1639     if test -z "$INTEL_CC"; then
1640        # Don't use -Wcast-align with ICC
1641        case "$CPU_ARCH" in
1642            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1643            hppa | ia64 | sparc | arm)
1644            ;;
1645            *)
1646         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1647            ;;
1648        esac
1649     fi
1650
1651     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/js-confdefs.h'
1652     _USE_CPP_INCLUDE_FLAG=1
1653
1654     AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
1655                    ac_has_wno_invalid_offsetof,
1656         [
1657             AC_LANG_SAVE
1658             AC_LANG_CPLUSPLUS
1659             _SAVE_CXXFLAGS="$CXXFLAGS"
1660             CXXFLAGS="$CXXFLAGS ${_COMPILER_PREFIX}-Wno-invalid-offsetof"
1661             AC_TRY_COMPILE([],
1662                            [return(0);],
1663                            ac_has_wno_invalid_offsetof="yes",
1664                            ac_has_wno_invalid_offsetof="no")
1665             CXXFLAGS="$_SAVE_CXXFLAGS"
1666             AC_LANG_RESTORE
1667         ])
1668     if test "$ac_has_wno_invalid_offsetof" = "yes"; then
1669         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-invalid-offsetof"
1670     fi
1671
1672     AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
1673                    ac_has_wno_variadic_macros,
1674         [
1675             AC_LANG_SAVE
1676             AC_LANG_CPLUSPLUS
1677             _SAVE_CXXFLAGS="$CXXFLAGS"
1678             CXXFLAGS="$CXXFLAGS ${_COMPILER_PREFIX}-Wno-variadic-macros"
1679             AC_TRY_COMPILE([],
1680                            [return(0);],
1681                            ac_has_wno_variadic_macros="yes",
1682                            ac_has_wno_variadic_macros="no")
1683             CXXFLAGS="$_SAVE_CXXFLAGS"
1684             AC_LANG_RESTORE
1685         ])
1686     if test "$ac_has_wno_variadic_macros" = "yes"; then
1687         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-variadic-macros"
1688     fi
1689
1690     AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
1691                    ac_has_werror_return_type,
1692         [
1693             AC_LANG_SAVE
1694             AC_LANG_CPLUSPLUS
1695             _SAVE_CXXFLAGS="$CXXFLAGS"
1696             CXXFLAGS="$CXXFLAGS -Werror=return-type"
1697             AC_TRY_COMPILE([],
1698                            [return(0);],
1699                            ac_has_werror_return_type="yes",
1700                            ac_has_werror_return_type="no")
1701             CXXFLAGS="$_SAVE_CXXFLAGS"
1702             AC_LANG_RESTORE
1703         ])
1704     if test "$ac_has_werror_return_type" = "yes"; then
1705         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
1706     fi
1707
1708 else
1709     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_JS_CONFDEFS_H_ $(ACDEFINES)'
1710 fi
1711
1712 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1713 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1714 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1715 dnl normal behavior.
1716 dnl ========================================================
1717 MKSHLIB_FORCE_ALL=
1718 MKSHLIB_UNFORCE_ALL=
1719
1720 if test "$COMPILE_ENVIRONMENT"; then
1721 if test "$GNU_CC"; then
1722   AC_MSG_CHECKING(whether ld has archive extraction flags)
1723   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1724    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1725     ac_cv_mkshlib_force_and_unforce="no"
1726     exec 3<&0 <<LOOP_INPUT
1727         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1728         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1729         force="-Wl,-all";              unforce="-Wl,-none"
1730 LOOP_INPUT
1731     while read line
1732     do
1733       eval $line
1734       LDFLAGS=$force
1735       LIBS=$unforce
1736       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1737     done
1738     exec 0<&3 3<&-
1739     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1740    ])
1741   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1742     AC_MSG_RESULT(no)
1743   else
1744     AC_MSG_RESULT(yes)
1745     eval $ac_cv_mkshlib_force_and_unforce
1746     MKSHLIB_FORCE_ALL=$force
1747     MKSHLIB_UNFORCE_ALL=$unforce
1748   fi
1749 fi # GNU_CC
1750 fi # COMPILE_ENVIRONMENT
1751
1752 dnl =================================================================
1753 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1754 dnl which is bad when cross compiling.
1755 dnl =================================================================
1756 if test "$COMPILE_ENVIRONMENT"; then
1757 configure_static_assert_macros='
1758 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1759 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1760 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1761 '
1762
1763 dnl test that the macros actually work:
1764 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1765 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1766  [AC_LANG_SAVE
1767   AC_LANG_C
1768   ac_cv_static_assertion_macros_work="yes"
1769   AC_TRY_COMPILE([$configure_static_assert_macros],
1770                  [CONFIGURE_STATIC_ASSERT(1)],
1771                  ,
1772                  ac_cv_static_assertion_macros_work="no")
1773   AC_TRY_COMPILE([$configure_static_assert_macros],
1774                  [CONFIGURE_STATIC_ASSERT(0)],
1775                  ac_cv_static_assertion_macros_work="no",
1776                  )
1777   AC_LANG_CPLUSPLUS
1778   AC_TRY_COMPILE([$configure_static_assert_macros],
1779                  [CONFIGURE_STATIC_ASSERT(1)],
1780                  ,
1781                  ac_cv_static_assertion_macros_work="no")
1782   AC_TRY_COMPILE([$configure_static_assert_macros],
1783                  [CONFIGURE_STATIC_ASSERT(0)],
1784                  ac_cv_static_assertion_macros_work="no",
1785                  )
1786   AC_LANG_RESTORE
1787  ])
1788 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1789 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1790     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1791 fi
1792 fi # COMPILE_ENVIRONMENT
1793
1794 dnl ========================================================
1795 dnl Checking for 64-bit OS
1796 dnl ========================================================
1797 if test "$COMPILE_ENVIRONMENT"; then
1798 AC_LANG_SAVE
1799 AC_LANG_C
1800 AC_MSG_CHECKING(for 64-bit OS)
1801 AC_TRY_COMPILE([$configure_static_assert_macros],
1802                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1803                result="yes", result="no")
1804 AC_MSG_RESULT("$result")
1805 if test "$result" = "yes"; then
1806     AC_DEFINE(HAVE_64BIT_OS)
1807     HAVE_64BIT_OS=1
1808 fi
1809 AC_SUBST(HAVE_64BIT_OS)
1810 AC_LANG_RESTORE
1811 fi # COMPILE_ENVIRONMENT
1812
1813 dnl ========================================================
1814 dnl Enable high-memory support on OS/2 by default.
1815 dnl ========================================================
1816 MOZ_OS2_HIGH_MEMORY=1
1817 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1818 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1819     MOZ_OS2_HIGH_MEMORY=,
1820     MOZ_OS2_HIGH_MEMORY=1 )
1821 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1822
1823 dnl ========================================================
1824 dnl = Use profiling compile flags
1825 dnl ========================================================
1826 MOZ_ARG_ENABLE_BOOL(profiling,
1827 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1828     MOZ_PROFILING=1,
1829     MOZ_PROFILING= )
1830
1831 dnl ========================================================
1832 dnl System overrides of the defaults for host
1833 dnl ========================================================
1834 case "$host" in
1835 *-beos*)
1836     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE -DNO_X11"
1837     HOST_NSPR_MDCPUCFG='\"md/_beos.cfg\"'
1838     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1839     ;;
1840
1841 *cygwin*|*mingw*|*mks*|*msvc*|*wince|*winmo)
1842     # we need Python 2.5 on Windows
1843     PYTHON_VERSION=2.5
1844     if test -n "$_WIN32_MSVC"; then
1845         HOST_AR=lib
1846         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1847         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1848         HOST_RANLIB='echo ranlib'
1849     else
1850         HOST_CFLAGS="$HOST_CFLAGS -mno-cygwin"
1851     fi
1852     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11"
1853     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1854     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1855     HOST_BIN_SUFFIX=.exe
1856     case "$host" in
1857     *mingw*)
1858     dnl MinGW/MSYS does not need CYGWIN_WRAPPER
1859         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1860         ;;
1861     *)
1862         CYGWIN_WRAPPER="${srcdir}/build/cygwin-wrapper"
1863         if test "`echo ${srcdir} | grep -c ^/ 2>/dev/null`" = 0; then
1864             _pwd=`pwd`
1865             CYGWIN_WRAPPER="${_pwd}/${srcdir}/build/cygwin-wrapper"
1866         fi
1867         if test "`${PERL} -v | grep -c cygwin  2>/dev/null`" = 0; then
1868             AS_PERL=1
1869             PERL="${CYGWIN_WRAPPER} $PERL"
1870         fi
1871
1872         if test "`${PYTHON} -c 'import sys; print sys.platform;'`" != "cygwin"; then
1873             PYTHON="${CYGWIN_WRAPPER} $PYTHON"
1874         fi
1875         ;;
1876     esac
1877
1878     case "${host_cpu}" in
1879     x86_64)
1880         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1881         ;;
1882     esac
1883     ;;
1884
1885 *-darwin*)
1886     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1887     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1888     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1889     ;;
1890
1891 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1892     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1893     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1894     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1895     ;;
1896
1897 *os2*)
1898     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1899     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1900     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1901     HOST_BIN_SUFFIX=.exe
1902     MOZ_FIX_LINK_PATHS=
1903     ;;
1904
1905 *-osf*)
1906     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1907     HOST_NSPR_MDCPUCFG='\"md/_osf1.cfg\"'
1908     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1909     ;;
1910
1911 *)
1912     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1913     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1914     ;;
1915 esac
1916
1917 dnl We require version 2.4 or newer of Python to build,
1918 dnl and 2.5 or newer on Windows.
1919 AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION but not 3.x])
1920 changequote(,)
1921 $PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
1922 _python_res=$?
1923 changequote([,])
1924 if test "$_python_res" != 0; then
1925     AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
1926 fi
1927 AC_MSG_RESULT([yes])
1928
1929 dnl ========================================================
1930 dnl System overrides of the defaults for target
1931 dnl ========================================================
1932
1933 case "$target" in
1934 *-aix*)
1935     AC_DEFINE(AIX)
1936     if test ! "$GNU_CC"; then
1937         if test ! "$HAVE_64BIT_OS"; then
1938             # Compiling with Visual Age C++ object model compat is the
1939             # default. To compile with object model ibm, add 
1940             # AIX_OBJMODEL=ibm to .mozconfig.
1941             if test "$AIX_OBJMODEL" = "ibm"; then
1942                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1943             else
1944                 AIX_OBJMODEL=compat
1945             fi
1946         else
1947             AIX_OBJMODEL=compat
1948         fi
1949         AC_SUBST(AIX_OBJMODEL)
1950         DSO_LDOPTS='-qmkshrobj=1'
1951         DSO_CFLAGS='-qflag=w:w'
1952         DSO_PIC_CFLAGS=
1953         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1954         MOZ_FIX_LINK_PATHS=
1955         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1956         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1957         if test "$COMPILE_ENVIRONMENT"; then
1958             AC_LANG_SAVE
1959             AC_LANG_CPLUSPLUS
1960             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1961             AC_TRY_COMPILE([],
1962                 [#if (__IBMCPP__ < 900)
1963                  #error "Bad compiler"
1964                  #endif],
1965                 _BAD_COMPILER=,_BAD_COMPILER=1)
1966             if test -n "$_BAD_COMPILER"; then
1967                 AC_MSG_RESULT([no])    
1968                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1969             else
1970                 AC_MSG_RESULT([yes])    
1971             fi
1972             AC_LANG_RESTORE
1973             TARGET_COMPILER_ABI="ibmc"
1974             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1975             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1976         fi
1977     fi
1978     case "${target_os}" in
1979     aix4.1*)
1980         DLL_SUFFIX='_shr.a'
1981         ;;
1982     esac
1983     if test "$COMPILE_ENVIRONMENT"; then
1984         AC_CHECK_HEADERS(sys/inttypes.h)
1985     fi
1986     AC_DEFINE(JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES)
1987     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1988     ;;
1989
1990 *-beos*)
1991     no_x=yes
1992     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1993     _PLATFORM_DEFAULT_TOOLKIT="cairo-beos"
1994     DSO_LDOPTS='-nostart'
1995     TK_LIBS='-lbe -lroot'
1996     LIBS="$LIBS -lbe"
1997     if test "$COMPILE_ENVIRONMENT"; then
1998         AC_CHECK_LIB(bind,main,LIBS="$LIBS -lbind")
1999         AC_CHECK_LIB(zeta,main,LIBS="$LIBS -lzeta")
2000     fi
2001     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-multichar"
2002     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-multichar"
2003     _MOZ_USE_RTTI=1
2004     USE_DEPENDENT_LIBS=
2005     MOZ_USER_DIR="Mozilla"
2006     ;;
2007
2008 *-bsdi*)
2009     dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
2010     _PEDANTIC=
2011     case $OS_RELEASE in
2012         4.*|5.*)
2013             STRIP="$STRIP -d"
2014             ;;
2015         *)
2016             DSO_CFLAGS=''
2017             DSO_LDOPTS='-r'
2018             _WARNINGS_CFLAGS="-Wall"
2019             _WARNINGS_CXXFLAGS="-Wall"
2020             # The test above doesn't work properly, at least on 3.1.
2021             MKSHLIB_FORCE_ALL=''
2022             MKSHLIB_UNFORCE_ALL=''
2023         ;;
2024     esac
2025     ;;
2026
2027 *-darwin*) 
2028     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2029     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2030     # If we're building with --enable-profiling, we need a frame pointer.
2031     if test -z "$MOZ_PROFILING"; then
2032         MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer"
2033     else
2034         MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer"
2035     fi
2036     _PEDANTIC=
2037     CFLAGS="$CFLAGS -fpascal-strings -fno-common"
2038     CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
2039     DLL_SUFFIX=".dylib"
2040     DSO_LDOPTS=''
2041     STRIP="$STRIP -x -S"
2042     _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
2043     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2044     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
2045     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
2046     # The ExceptionHandling framework is needed for Objective-C exception
2047     # logging code in nsObjCExceptions.h. Currently we only use that in debug
2048     # builds.
2049     MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
2050
2051     dnl DTrace and -dead_strip don't interact well. See bug 403132.
2052     dnl ===================================================================
2053     if test "x$enable_dtrace" = "xyes"; then
2054         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
2055     else
2056         dnl check for the presence of the -dead_strip linker flag
2057         AC_MSG_CHECKING([for -dead_strip option to ld])
2058         _SAVE_LDFLAGS=$LDFLAGS
2059         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
2060         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
2061         if test -n "$_HAVE_DEAD_STRIP" ; then
2062             AC_MSG_RESULT([yes])
2063             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
2064         else
2065             AC_MSG_RESULT([no])
2066         fi
2067         
2068         LDFLAGS=$_SAVE_LDFLAGS
2069     fi
2070     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
2071     ;;
2072
2073 *-freebsd*)
2074     if test `test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` != "elf"; then
2075         DLL_SUFFIX=".so.1.0"
2076         DSO_LDOPTS="-shared"
2077     fi
2078     if test ! "$GNU_CC"; then
2079         DSO_LDOPTS="-Bshareable $DSO_LDOPTS"
2080     fi
2081     ;; 
2082
2083 ia64*-hpux*)
2084     DLL_SUFFIX=".so"
2085     if test ! "$GNU_CC"; then
2086        DSO_LDOPTS='-b'
2087        DSO_CFLAGS=""
2088        DSO_PIC_CFLAGS=
2089        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2090        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2091        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2092     else
2093        DSO_LDOPTS='-b -E'
2094        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2095        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2096     fi
2097     MOZ_FIX_LINK_PATHS=
2098     SYSTEM_MAKEDEPEND=
2099     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2100     AC_DEFINE(_LARGEFILE64_SOURCE)
2101     ;;
2102
2103 *-hpux*)
2104     DLL_SUFFIX=".sl"
2105     if test ! "$GNU_CC"; then
2106         DSO_LDOPTS='-b -Wl,+s'
2107         DSO_CFLAGS=""
2108         DSO_PIC_CFLAGS="+Z"
2109         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2110         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2111         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2112     else
2113         DSO_LDOPTS='-b -E +s'
2114         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2115         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2116     fi
2117     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2118     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2119     ;;
2120
2121 *-irix5*)
2122     AC_DEFINE(IRIX)
2123     DSO_LDOPTS='-elf -shared'
2124
2125     if test "$GNU_CC"; then
2126        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2127        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2128        MKSHLIB_FORCE_ALL='-Wl,-all'
2129        MKSHLIB_UNFORCE_ALL='-Wl,-none'
2130        CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
2131     else
2132        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2133        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2134        MKSHLIB_FORCE_ALL='-all'
2135        MKSHLIB_UNFORCE_ALL='-none'
2136     fi
2137     ;;
2138
2139 *-irix6*)
2140     AC_DEFINE(IRIX)
2141     dnl the irix specific xptcinvoke code is written against the n32 ABI so we *must* 
2142     dnl compile and link using -n32
2143     USE_N32=1
2144     TARGET_COMPILER_ABI=n32
2145     DSO_LDOPTS='-elf -shared'
2146     MKSHLIB='$(CCC) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2147     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2148     _MOZ_EXCEPTIONS_FLAGS_OFF="-LANG:exceptions=OFF"
2149     _MOZ_EXCEPTIONS_FLAGS_ON="-LANG:exceptions=ON"
2150     if test "$GNU_CC"; then
2151        MKSHLIB_FORCE_ALL='-Wl,-all'
2152        MKSHLIB_UNFORCE_ALL='-Wl,-none'
2153        _WARNINGS_CFLAGS="-Wall"
2154        _WARNINGS_CXXFLAGS="-Wall"
2155        CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
2156     else
2157        MKSHLIB_FORCE_ALL='-all'
2158        MKSHLIB_UNFORCE_ALL='-none'
2159            AR_LIST="$AR t"
2160            AR_EXTRACT="$AR x"
2161            AR_DELETE="$AR d"
2162            AR='$(CXX) -ar'
2163            AR_FLAGS='-o $@'
2164        CFLAGS="$CFLAGS -woff 3262 -G 4"
2165        CXXFLAGS="$CXXFLAGS -woff 3262 -G 4"
2166        if test -n "$USE_N32"; then
2167            ASFLAGS="$ASFLAGS -n32"
2168            CFLAGS="$CFLAGS -n32"
2169            CXXFLAGS="$CXXFLAGS -n32"
2170            LDFLAGS="$LDFLAGS -n32"
2171        fi
2172        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2173        AC_MSG_WARN([Clearing MOZ_FIX_LINK_PATHS for OSF/1 as fix for bug 333545 (till the reference bug 332075 is fixed.])
2174        MOZ_FIX_LINK_PATHS=
2175     fi
2176     if test -z "$GNU_CXX"; then
2177       MIPSPRO_CXX=1
2178     fi
2179     ;;
2180
2181 *-*linux*)
2182     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2183     # Similarly for GNU_CXX and INTEL_CXX.
2184     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2185         # -Os has been broken on Intel's C/C++ compilers for quite a
2186         # while; Intel recommends against using it.
2187         MOZ_OPTIMIZE_FLAGS="-O2"
2188         MOZ_DEBUG_FLAGS="-g"
2189     elif test "$GNU_CC" -o "$GNU_CXX"; then
2190         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2191         case $GCC_VERSION in
2192         4.1.*|4.2.*|4.5.*)
2193             # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
2194             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2195         esac
2196         # If we're building with --enable-profiling, we need a frame pointer.
2197         if test -z "$MOZ_PROFILING"; then
2198             MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fomit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK"
2199         else
2200             MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-omit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK"
2201         fi
2202         MOZ_DEBUG_FLAGS="-g"
2203     fi
2204
2205     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2206
2207     case "${target_cpu}" in
2208     alpha*)
2209         CFLAGS="$CFLAGS -mieee"
2210         CXXFLAGS="$CXXFLAGS -mieee"
2211     ;;
2212     mips*)
2213         MOZ_DEBUG_FLAGS="-g" # We want inlining
2214     ;;
2215     esac
2216     ;;
2217
2218 *-wince*|*-winmo*)
2219     TARGET_COMPILER_ABI=msvc
2220     MOZ_TOOLS_DIR=`echo $MOZ_TOOLS`
2221     AR_LIST="$AR -list"
2222     AR_EXTRACT="$AR -extract"
2223     AR_DELETE="$AR d"
2224     AR_FLAGS='-OUT:"$@"'
2225     AS="$AS_BIN"
2226
2227     DSO_CFLAGS=
2228     DSO_PIC_CFLAGS=
2229     DLL_SUFFIX=.dll
2230     BIN_SUFFIX='.exe'
2231     if test -z "$RC"; then 
2232         RC=rc.exe  
2233     fi
2234     # certain versions of cygwin's makedepend barf on the 
2235     # #include <string> vs -I./dist/include/string issue so don't use it
2236     SYSTEM_MAKEDEPEND=
2237
2238     HOST_CC=cl
2239     HOST_CXX=cl
2240     HOST_LD=link
2241     HOST_AR='lib -OUT:$@'
2242     HOST_RANLIB='echo ranlib'
2243     HOST_CFLAGS="$HOST_CFLAGS -D_X86_"
2244         
2245         
2246     WARNINGS_AS_ERRORS='-WX'
2247     MOZ_OPTIMIZE_FLAGS='-Ox'
2248     AR_FLAGS='-NOLOGO -OUT:"$@"'
2249     ASM_SUFFIX=asm
2250     CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2251     CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2252     DLL_PREFIX=
2253     DOXYGEN=:
2254     DSO_LDOPTS=-SUBSYSTEM:WINDOWSCE
2255     DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2256     GARBAGE=
2257     IMPORT_LIB_SUFFIX=lib
2258     dnl Need to force-link against mozalloc because it's used in the shunt
2259     LIBS="$LIBS \$(LIBXUL_DIST)/lib/mozalloc.lib"
2260     LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2261     LIB_PREFIX=
2262     LIB_SUFFIX=lib 
2263     MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
2264     MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
2265     MKSHLIB_FORCE_ALL=
2266     MKSHLIB_UNFORCE_ALL=
2267     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2268     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2269     MOZ_DEBUG_FLAGS='-Zi'
2270     MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2271     MOZ_FIX_LINK_PATHS=
2272     MOZ_JS_LIBS='$(libdir)/mozjs.lib'
2273     OBJ_SUFFIX=obj
2274     RANLIB='echo not_ranlib'
2275     STRIP='echo not_strip'
2276     TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
2277     UNZIP=unzip
2278     XARGS=xargs
2279     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2280     ZIP=zip
2281
2282     AC_DEFINE(HAVE_SNPRINTF)
2283     AC_DEFINE(_WINDOWS)
2284     AC_DEFINE(WIN32)
2285     AC_DEFINE(XP_WIN)
2286     AC_DEFINE(XP_WIN32)
2287     AC_DEFINE(HW_THREADS)
2288     AC_DEFINE(STDC_HEADERS)
2289     AC_DEFINE(NEW_H, <new>)
2290     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2291     AC_DEFINE(HAVE_LOCALTIME_R)
2292
2293     TARGET_MD_ARCH=win32
2294     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2295     BIN_SUFFIX='.exe'
2296     MOZ_USER_DIR="Mozilla"
2297
2298     dnl Default to Windows Mobile components enabled
2299     WINCE_WINDOWS_MOBILE=1
2300
2301     MOZ_ARG_DISABLE_BOOL(windows-mobile-components,
2302     [  --disable-windows-mobile-components
2303                           Disable Windows Mobile specific components from
2304                           CE build],
2305     WINCE_WINDOWS_MOBILE=,
2306     WINCE_WINDOWS_MOBILE=1)
2307  
2308     if test "$WINCE_WINDOWS_MOBILE"; then
2309         AC_DEFINE(WINCE_WINDOWS_MOBILE)
2310     fi
2311 ;;
2312
2313 *-symbian*)
2314
2315     AC_DEFINE(XP_UNIX)
2316     AC_DEFINE(SYMBIAN)
2317     AC_DEFINE(__arm__)
2318     AC_DEFINE(__SYMBIAN32__)
2319     AC_DEFINE(_UNICODE)
2320     AC_DEFINE(NDEBUG)
2321     AC_DEFINE(__SUPPORT_CPP_EXCEPTIONS__)
2322     AC_DEFINE(MOZ_STDERR_TO_STDOUT)
2323     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2324     AC_DEFINE(HAVE_SOCKLEN_T)
2325     AC_DEFINE(__GCCE__)
2326
2327     CPU_ARCH=ARM
2328     OS_RELEASE=9.2
2329     OS_ARCH=SYMBIAN
2330     USE_PTHREADS=1
2331     LIB_SUFFIX=lib
2332     DLL_SUFFIX=dll
2333     MKSHLIB=
2334     DSO_LDOPTS=
2335     DSO_CFLAGS=
2336     VISIBILITY_FLAGS=
2337     TARGET_NSPR_MDCPUCFG='\"md/_symbian.cfg\"'
2338     RANLIB='echo no ranlib '
2339 ;;
2340
2341 *-mingw*|*-cygwin*|*-msvc*|*-mks*)
2342     DSO_CFLAGS=
2343     DSO_PIC_CFLAGS=
2344     DLL_SUFFIX=.dll
2345     RC=rc.exe
2346     # certain versions of cygwin's makedepend barf on the 
2347     # #include <string> vs -I./dist/include/string issue so don't use it
2348     SYSTEM_MAKEDEPEND=
2349     if test -n "$GNU_CC"; then
2350         CC="$CC -mno-cygwin"
2351         CXX="$CXX -mno-cygwin"
2352         CPP="$CPP -mno-cygwin"
2353         CFLAGS="$CFLAGS -mms-bitfields"
2354         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2355         DSO_LDOPTS='-shared'
2356         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2357         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2358         RC='$(WINDRES)'
2359         # Use temp file for windres (bug 213281)
2360         RCFLAGS='-O coff --use-temp-file'
2361         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2362         LIBS="$LIBS -lgdi32 -lwinmm -lwsock32"
2363         MOZ_JS_LIBS='-L$(libdir) -lmozjs'
2364         MOZ_FIX_LINK_PATHS=
2365         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2366         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2367         DLL_PREFIX=
2368         IMPORT_LIB_SUFFIX=dll.a
2369         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2370     else
2371         TARGET_COMPILER_ABI=msvc
2372         HOST_CC='$(CC)'
2373         HOST_CXX='$(CXX)'
2374         HOST_LD='$(LD)'
2375         if test "$AS_BIN"; then
2376             AS="$(basename "$AS_BIN")"
2377         fi
2378         AR='lib -NOLOGO -OUT:"$@"'
2379         AR_FLAGS=
2380         RANLIB='echo not_ranlib'
2381         STRIP='echo not_strip'
2382         PKG_SKIP_STRIP=1
2383         XARGS=xargs
2384         ZIP=zip
2385         UNZIP=unzip
2386         DOXYGEN=:
2387         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
2388         ASM_SUFFIX=asm
2389         OBJ_SUFFIX=obj
2390         LIB_SUFFIX=lib
2391         DLL_PREFIX=
2392         LIB_PREFIX=
2393         IMPORT_LIB_SUFFIX=lib
2394         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2395         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2396         MKSHLIB_FORCE_ALL=
2397         MKSHLIB_UNFORCE_ALL=
2398         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2399         _USE_CPP_INCLUDE_FLAG=1
2400         _DEFINES_CFLAGS='-FI $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
2401         _DEFINES_CXXFLAGS='-FI $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
2402         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2403         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2404         # MSVC warnings C4244 and C4800 are ubiquitous, useless, and annoying.
2405         CXXFLAGS="$CXXFLAGS -wd4244 -wd4800"
2406         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
2407         MOZ_DEBUG_FLAGS='-Zi'
2408         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2409         WARNINGS_AS_ERRORS='-WX'
2410         # If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer.
2411         if test -z "$MOZ_PROFILING"; then
2412             MOZ_OPTIMIZE_FLAGS='-O1'
2413         else
2414             MOZ_OPTIMIZE_FLAGS='-O1 -Oy-'
2415         fi
2416         MOZ_JS_LIBS='$(libdir)/mozjs.lib'
2417         MOZ_FIX_LINK_PATHS=
2418         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2419         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2420         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2421         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2422         if test $_MSC_VER -ge 1400; then
2423             LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2424             dnl For profile-guided optimization
2425             PROFILE_GEN_CFLAGS="-GL"
2426             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2427             dnl XXX: PGO builds can fail with warnings treated as errors,
2428             dnl specifically "no profile data available" appears to be
2429             dnl treated as an error sometimes. This might be a consequence
2430             dnl of using WARNINGS_AS_ERRORS in some modules, combined
2431             dnl with the linker doing most of the work in the whole-program
2432             dnl optimization/PGO case. I think it's probably a compiler bug,
2433             dnl but we work around it here.
2434             PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2435             dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2436             dnl Probably also a compiler bug, but what can you do?
2437             PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2438             LDFLAGS="$LDFLAGS -DYNAMICBASE"
2439         fi
2440     fi
2441     AC_DEFINE(HAVE_SNPRINTF)
2442     AC_DEFINE(_WINDOWS)
2443     AC_DEFINE(WIN32)
2444     AC_DEFINE(XP_WIN)
2445     AC_DEFINE(XP_WIN32)
2446     AC_DEFINE(HW_THREADS)
2447     AC_DEFINE(STDC_HEADERS)
2448     AC_DEFINE(NEW_H, <new>)
2449     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2450     TARGET_MD_ARCH=win32
2451     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2452     BIN_SUFFIX='.exe'
2453     MOZ_USER_DIR="Mozilla"
2454
2455     dnl Hardcode to win95 for now - cls
2456     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2457
2458     dnl set NO_X11 defines here as the general check is skipped on win32
2459     no_x=yes
2460     AC_DEFINE(NO_X11)
2461
2462     dnl MinGW/MSYS doesn't provide or need cygpath
2463     case "$host" in
2464     *-mingw*)
2465         CYGPATH_W=echo
2466         CYGPATH_S=cat
2467         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2468         ;;
2469     *-cygwin*|*-msvc*|*-mks*)
2470         CYGPATH_W="cygpath -a -w"
2471         CYGPATH_S="sed -e s|\\\\|/|g"
2472         MOZ_BUILD_ROOT=`$CYGPATH_W $MOZ_BUILD_ROOT | $CYGPATH_S`
2473         ;;
2474     esac
2475     case "$host" in
2476     *-mingw*|*-cygwin*|*-msvc*|*-mks*)
2477
2478     if test -z "$MOZ_TOOLS"; then
2479         AC_MSG_ERROR([MOZ_TOOLS is not set])
2480     fi
2481
2482     MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2483     if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2484         AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2485     fi
2486     MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2487     if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2488         AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2489     fi
2490     MOZ_TOOLS_DIR=`$CYGPATH_W $MOZ_TOOLS_DIR | $CYGPATH_S`
2491     ;;
2492     esac 
2493
2494
2495     case "$host_os" in
2496     cygwin*|msvc*|mks*)
2497         AC_MSG_WARN([Using a cygwin build environment is unsupported. Configure cannot check for the presence of necessary headers. Please upgrade to MozillaBuild; see https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
2498         ;;
2499     esac
2500
2501     case "$target" in
2502     i*86-*)
2503         if test "$HAVE_64BIT_OS"; then
2504             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2505         fi
2506
2507         if test $_MSC_VER -ge 1400; then
2508             LDFLAGS="$LDFLAGS -SAFESEH"
2509         fi
2510
2511         if test -n "$GNU_CC"; then
2512             CFLAGS="$CFLAGS -mstackrealign"
2513             CXXFLAGS="$CXXFLAGS -mstackrealign"
2514         fi
2515
2516         AC_CHECK_HEADERS(mmintrin.h)
2517         AC_DEFINE(_X86_)
2518         ;;
2519     alpha-*)
2520         AC_DEFINE(_ALPHA_)
2521         ;;
2522     mips-*)
2523         AC_DEFINE(_MIPS_)
2524         ;;
2525     x86_64-*)
2526         AC_DEFINE(_AMD64_)
2527         ;;
2528     *)
2529         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2530         ;;
2531     esac
2532
2533     if test "$HAVE_64BIT_OS"; then
2534         AC_DEFINE(_WIN64)
2535     fi
2536     ;;
2537
2538 *-netbsd*)
2539     DSO_CFLAGS=''
2540     CFLAGS="$CFLAGS -Dunix"
2541     CXXFLAGS="$CXXFLAGS -Dunix"
2542     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2543         DLL_SUFFIX=".so"
2544         DSO_PIC_CFLAGS='-fPIC -DPIC'
2545         DSO_LDOPTS='-shared'
2546         BIN_FLAGS='-Wl,--export-dynamic'
2547     else
2548         DSO_PIC_CFLAGS='-fPIC -DPIC'
2549         DLL_SUFFIX=".so.1.0"
2550         DSO_LDOPTS='-shared'
2551     fi
2552     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2553     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2554     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2555     if test "$LIBRUNPATH"; then
2556         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2557     fi
2558     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2559     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2560     ;;
2561
2562 *-nto*) 
2563         AC_DEFINE(NTO)  
2564         AC_DEFINE(_QNX_SOURCE)
2565         AC_DEFINE(_i386)
2566         OS_TARGET=NTO
2567         WARNINGS_AS_ERRORS=''
2568         MOZ_OPTIMIZE_FLAGS="-O"
2569         MOZ_DEBUG_FLAGS="-gstabs"
2570         USE_PTHREADS=1
2571         _PEDANTIC=
2572         LIBS="$LIBS -lsocket -lstdc++"
2573         _DEFINES_CFLAGS='-include $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT -D_POSIX_C_SOURCE=199506'
2574         _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/js-confdefs.h -D_POSIX_C_SOURCE=199506'
2575         if test "$with_x" != "yes"
2576         then
2577                 _PLATFORM_DEFAULT_TOOLKIT="photon"
2578             TK_CFLAGS='-I/usr/include/photon'
2579                 TK_LIBS='-lph'
2580         fi
2581         case "${target_cpu}" in
2582         ppc*)
2583         AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)        
2584         ;;
2585         esac
2586         ;;
2587
2588 *-openbsd*)
2589     DLL_SUFFIX=".so.1.0"
2590     DSO_CFLAGS=''
2591     DSO_PIC_CFLAGS='-fPIC'
2592     DSO_LDOPTS='-shared -fPIC'
2593     if test "$LIBRUNPATH"; then
2594         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2595     fi
2596     ;;
2597
2598 *-openvms*) 
2599     AC_DEFINE(NO_PW_GECOS)
2600     AC_DEFINE(NO_UDSOCK)
2601     AC_DEFINE(POLL_WITH_XCONNECTIONNUMBER)
2602     USE_PTHREADS=1
2603     MKSHLIB_FORCE_ALL='-all'
2604     MKSHLIB_UNFORCE_ALL='-none'
2605     AS='as'
2606     AS_DASH_C_FLAG='-Wc/names=as_is'
2607     AR_FLAGS='c $@'
2608     DSO_LDOPTS='-shared -auto_symvec'
2609     DSO_PIC_CFLAGS=
2610     MOZ_DEBUG_LDFLAGS='-g'
2611     COMPAQ_CXX=1
2612     CC_VERSION=`$CC -V 2>&1 | awk '/ C / { print $3 }'`
2613     CXX_VERSION=`$CXX -V 2>&1 | awk '/ C\+\+ / { print $3 }'`
2614     ;;
2615
2616
2617 *-os2*)
2618     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2619     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2620     AC_DEFINE(OS2)
2621     AC_DEFINE(XP_OS2)
2622     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2623     AC_DEFINE(TCPV40HDRS)
2624     DLL_PREFIX=
2625     LIB_PREFIX=
2626     LIB_SUFFIX=lib
2627     BIN_SUFFIX=".exe"
2628     DLL_SUFFIX=".dll"
2629     IMPORT_LIB_SUFFIX=lib
2630     DSO_PIC_CFLAGS=
2631     AR=emxomfar
2632     AR_FLAGS='r $@'
2633     CFLAGS="$CFLAGS -Zomf"
2634     CXXFLAGS="$CXXFLAGS -Zomf"
2635     DSO_LDOPTS='-Zdll'
2636     BIN_FLAGS='-Zlinker /ST:0x100000'
2637     IMPLIB='emximp -o'
2638     FILTER='true'
2639     LDFLAGS='-Zmap'
2640     WARNINGS_AS_ERRORS='-Werror'
2641     MOZ_DEBUG_FLAGS="-g -fno-inline"
2642     MOZ_OPTIMIZE_FLAGS="-O2"
2643     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2644     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2645     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2646     TARGET_MD_ARCH=os2
2647     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2648     RC=rc.exe
2649     RCFLAGS='-n'
2650     MOZ_USER_DIR="Mozilla"
2651
2652     if test "$MOZTOOLS"; then
2653         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2654     else
2655         AC_MSG_ERROR([MOZTOOLS is not set])
2656     fi
2657     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2658         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2659         LDFLAGS="$LDFLAGS -Zhigh-mem"
2660         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2661         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2662     fi
2663
2664     # GCC for OS/2 currently predefines these, but we don't want them
2665     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2666     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2667
2668     AC_CACHE_CHECK(for __declspec(dllexport),
2669         ac_os2_declspec,
2670         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2671                         [return 0;],
2672                         ac_os2_declspec="yes",
2673                         ac_os2_declspec="no")])
2674     if test "$ac_os2_declspec" != "yes"; then
2675         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2676     fi
2677     ;;
2678
2679 alpha*-*-osf*)
2680     if test "$GNU_CC"; then
2681       MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
2682       MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
2683
2684     else
2685         MOZ_DEBUG_FLAGS='-g'
2686         ASFLAGS='-I$(topsrcdir)/xpcom/reflect/xptcall/public -g'
2687         CFLAGS="$CFLAGS -ieee"
2688         CXXFLAGS="$CXXFLAGS "'-noexceptions -ieee  -ptr $(DIST)/cxx_repository'
2689         DSO_LDOPTS='-shared -msym -expect_unresolved \* -update_registry $(DIST)/so_locations'
2690         DSO_CFLAGS=
2691         DSO_PIC_CFLAGS=
2692         MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
2693         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
2694         MKSHLIB_FORCE_ALL='-all'
2695         MKSHLIB_UNFORCE_ALL='-none'
2696         dnl Might fix the libxpcom.so breakage on this platform as well....
2697         AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2698         AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2699     fi
2700     if test -z "$GNU_CXX"; then
2701       COMPAQ_CXX=1
2702     fi
2703     AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2704     ;;
2705
2706 *-qnx*) 
2707     DIRENT_INO=d_stat.st_ino
2708     dnl Solves the problems the QNX compiler has with nsCOMPtr.h.
2709     AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2710     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2711     dnl Explicit set STDC_HEADERS to workaround QNX 6.0's failing of std test
2712     AC_DEFINE(STDC_HEADERS)
2713     if test "$no_x" = "yes"; then
2714             _PLATFORM_DEFAULT_TOOLKIT='photon'
2715             TK_CFLAGS='-I/usr/nto/include/photon'
2716             TK_LIBS='-lphoton -lphrender'
2717     fi
2718     ;;
2719
2720 *-sco*) 
2721     AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2722     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2723     CXXFLAGS="$CXXFLAGS -I/usr/include/CC"
2724     if test ! "$GNU_CC"; then
2725        DSO_LDOPTS='-G'
2726     fi
2727     ;;
2728
2729 *-solaris*) 
2730     AC_DEFINE(SOLARIS)
2731     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2732     if test -z "$CROSS_COMPILE" && pkginfo -q SUNWpr && pkginfo -q SUNWprd; then
2733        NO_NSPR_CONFIG_SYSTEM_LDFLAGS="-L/usr/lib/mps -R/usr/lib/mps -lnspr4"
2734        NO_NSPR_CONFIG_SYSTEM_CFLAGS="-I/usr/include/mps"
2735        NO_NSPR_CONFIG_SYSTEM_VERSION=["`pkgparam SUNWpr SUNW_PRODVERS | sed -e 's/^[1-9][0-9]*\.[0-9][0-9]*$/&.0/'`"]
2736     fi
2737     SYSTEM_MAKEDEPEND=
2738     MOZ_FIX_LINK_PATHS=
2739     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2740     # libraries one level up (e.g. libnspr4.so)
2741     if test "$SOLARIS_SUNPRO_CC"; then
2742        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2743        LIBS="-lCrun -lCstd -lc $LIBS"
2744        NS_USE_NATIVE=1
2745        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2746        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2747        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2748        _MOZ_EXCEPTIONS_FLAGS_ON='-features=except'
2749        _MOZ_EXCEPTIONS_FLAGS_OFF='-features=no%except'
2750        LDFLAGS="-xildoff $LDFLAGS"
2751        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2752            _SAVE_LDFLAGS=$LDFLAGS
2753            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS" 
2754            AC_TRY_LINK([#include <stdio.h>],
2755                        [printf("Hello World\n");],
2756                        ,
2757                        [LDFLAGS=$_SAVE_LDFLAGS])
2758        fi
2759        WARNINGS_AS_ERRORS='-Werror'
2760        MOZ_OPTIMIZE_FLAGS="-xO4"
2761        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2762        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2763        MKSHLIB_FORCE_ALL='-z allextract'
2764        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2765        DSO_LDOPTS='-G'
2766        AR_LIST="$AR t"
2767        AR_EXTRACT="$AR x"
2768        AR_DELETE="$AR d"
2769        AR='$(CXX) -xar'
2770        AR_FLAGS='-o $@'
2771        AS='/usr/ccs/bin/as'
2772        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2773        AS_DASH_C_FLAG=''
2774        TARGET_COMPILER_ABI="sunc"
2775        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2776        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2777        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2778        AC_LANG_SAVE
2779        AC_LANG_CPLUSPLUS
2780        AC_TRY_COMPILE([],
2781            [#if (__SUNPRO_CC < 0x590)
2782            #error "Denied"
2783            #endif],
2784            _BAD_COMPILER=,_BAD_COMPILER=1)
2785        if test -n "$_BAD_COMPILER"; then
2786            _res="no"
2787            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2788        else
2789            _res="yes"
2790        fi
2791        AC_TRY_COMPILE([],
2792            [#if (__SUNPRO_CC >= 0x5100)
2793            #error "Sun C++ 5.10 or above"
2794            #endif],
2795            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2796        if test "$_ABOVE_SS12U1"; then
2797            # disable xannotate
2798            CXXFLAGS="$CXXFLAGS -xannotate=no"
2799        fi
2800        AC_MSG_RESULT([$_res])
2801        AC_LANG_RESTORE
2802     else
2803        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2804        LIBS="-lc $LIBS"
2805        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2806        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2807        ASFLAGS="$ASFLAGS -fPIC"
2808        DSO_LDOPTS='-shared'
2809        _WARNINGS_CFLAGS=''
2810        _WARNINGS_CXXFLAGS=''
2811        if test "$OS_RELEASE" = "5.3"; then
2812            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2813        fi
2814     fi
2815     if test "$OS_RELEASE" = "5.5.1"; then
2816         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2817     fi
2818     ;;
2819
2820 *-sunos*) 
2821     DSO_LDOPTS='-Bdynamic'
2822     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2823     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2824     AC_DEFINE(SUNOS4)
2825     AC_DEFINE(SPRINTF_RETURNS_STRING)
2826     case "$(target_os)" in
2827     sunos4.1*)
2828         DLL_SUFFIX='.so.1.0'
2829         ;;
2830     esac
2831     ;;
2832
2833 *-sysv4.2uw7*) 
2834         NSPR_LIBS="-lnspr$NSPR_VERSION -lplc$NSPR_VERSION -lplds$NSPR_VERSION -L/usr/ccs/lib -lcrt"
2835     ;;
2836
2837 *-os2*)
2838     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2839     ;;
2840
2841 *-android*)
2842     AC_DEFINE(NO_PW_GECOS)
2843     no_x=yes
2844     _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2845     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2846
2847     MOZ_GFX_OPTIMIZE_MOBILE=1
2848     # If we're building with --enable-profiling, we need a frame pointer.
2849     if test -z "$MOZ_PROFILING"; then
2850         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer"
2851     else
2852         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fno-omit-frame-pointer"
2853     fi
2854     # The Maemo builders don't know about this flag
2855     MOZ_ARM_VFP_FLAGS="-mfpu=vfp"
2856     ;;
2857
2858 esac
2859
2860 dnl Only one oddball right now (QNX), but this gives us flexibility
2861 dnl if any other platforms need to override this in the future.
2862 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2863
2864 dnl ========================================================
2865 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2866 dnl by now will not have any way to link most binaries (tests
2867 dnl as well as viewer, apprunner, etc.), because some symbols
2868 dnl will be left out of the "composite" .so's by ld as unneeded.
2869 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2870 dnl they can link in the static libs that provide the missing
2871 dnl symbols.
2872 dnl ========================================================
2873 NO_LD_ARCHIVE_FLAGS=
2874 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2875     NO_LD_ARCHIVE_FLAGS=1
2876 fi
2877 case "$target" in
2878 *-os2*)
2879     NO_LD_ARCHIVE_FLAGS=
2880     ;;
2881 *-aix4.3*|*-aix5*)
2882     NO_LD_ARCHIVE_FLAGS=
2883     ;;
2884 *-openvms*)
2885     NO_LD_ARCHIVE_FLAGS=
2886     ;;
2887 *-msvc*|*-mks*|*-mingw*|*-cygwin*|*-wince|*-winmo)
2888     if test -z "$GNU_CC"; then
2889         NO_LD_ARCHIVE_FLAGS=
2890     fi
2891     ;;
2892 esac
2893 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2894
2895 dnl ========================================================
2896 dnl = Flags to strip unused symbols from .so components
2897 dnl ========================================================
2898 case "$target" in
2899     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2900         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2901         ;;
2902     *-solaris*)
2903         if test -z "$GNU_CC"; then
2904          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2905         else
2906          if test -z "$GCC_USE_GNU_LD"; then
2907           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2908          else
2909           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2910          fi
2911         fi
2912         ;;
2913     *-nto*) 
2914         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2915         ;;
2916     *-darwin*)
2917         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2918         ;;
2919     *-cygwin*|*-mingw*|*-mks*|*-msvc|*-wince|*-winmo)
2920         if test -n "$GNU_CC"; then
2921            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2922         fi
2923         ;;
2924 esac
2925
2926 if test -z "$COMPILE_ENVIRONMENT"; then
2927     SKIP_COMPILER_CHECKS=1
2928     SKIP_LIBRARY_CHECKS=1
2929 fi
2930
2931 dnl Configure JIT support
2932
2933 case "$target" in
2934 i?86-*)
2935     ENABLE_TRACEJIT=1
2936     NANOJIT_ARCH=i386
2937     ENABLE_METHODJIT=1
2938     ENABLE_MONOIC=1
2939     ENABLE_POLYIC=1
2940     ENABLE_POLYIC_TYPED_ARRAY=1
2941     AC_DEFINE(JS_CPU_X86)
2942     AC_DEFINE(JS_NUNBOX32)
2943     ;;
2944 x86_64*-*)
2945     ENABLE_TRACEJIT=1
2946     NANOJIT_ARCH=X64
2947     ENABLE_METHODJIT=1
2948     ENABLE_MONOIC=1
2949     ENABLE_POLYIC=1
2950     ENABLE_POLYIC_TYPED_ARRAY=1
2951     AC_DEFINE(JS_CPU_X64)
2952     AC_DEFINE(JS_PUNBOX64)
2953     ;;
2954 arm*-*)
2955     ENABLE_TRACEJIT=1
2956     NANOJIT_ARCH=ARM
2957     ENABLE_METHODJIT=1
2958     ENABLE_MONOIC=1
2959     ENABLE_POLYIC=1
2960     AC_DEFINE(JS_CPU_ARM)
2961     AC_DEFINE(JS_NUNBOX32)
2962     ;;
2963 sparc*-*)
2964     ENABLE_TRACEJIT=1
2965     NANOJIT_ARCH=Sparc
2966     AC_DEFINE(JS_CPU_SPARC)
2967     ;;
2968 esac
2969
2970 MOZ_ARG_DISABLE_BOOL(methodjit,
2971 [  --disable-methodjit           Disable method JIT support],
2972   ENABLE_METHODJIT= )
2973
2974 MOZ_ARG_DISABLE_BOOL(monoic,
2975 [  --disable-monoic      Disable use of MICs by JIT compiler],
2976   ENABLE_MONOIC= )
2977
2978 MOZ_ARG_DISABLE_BOOL(polyic,
2979 [  --disable-polyic      Disable use of PICs by JIT compiler],
2980   ENABLE_POLYIC= )
2981
2982 MOZ_ARG_DISABLE_BOOL(tracejit,
2983 [  --disable-tracejit      Disable tracing JIT support],
2984   ENABLE_TRACEJIT=)
2985
2986 MOZ_ARG_ENABLE_BOOL(methodjit-spew,
2987 [  --enable-methodjit-spew      Enable method JIT spew support],
2988   ENABLE_METHODJIT_SPEW=1,
2989   ENABLE_METHODJIT_SPEW= )
2990
2991 AC_SUBST(ENABLE_METHODJIT)
2992
2993 if test "$ENABLE_METHODJIT"; then
2994     AC_DEFINE(JS_METHODJIT)
2995 fi
2996
2997 if test "$ENABLE_MONOIC"; then
2998     AC_DEFINE(JS_MONOIC)
2999 fi
3000
3001 if test "$ENABLE_POLYIC"; then
3002     AC_DEFINE(JS_POLYIC)
3003 fi
3004
3005 if test "$ENABLE_POLYIC_TYPED_ARRAY"; then
3006     AC_DEFINE(JS_POLYIC_TYPED_ARRAY)
3007 fi
3008
3009 if test "$ENABLE_METHODJIT_SPEW"; then
3010     AC_DEFINE(JS_METHODJIT_SPEW)
3011 fi
3012
3013 if test "$ENABLE_TRACEJIT"; then
3014
3015 AC_DEFINE(FEATURE_NANOJIT)
3016 AC_DEFINE(JS_TRACER)
3017
3018 case "$target" in
3019 i?86-*)
3020     AC_DEFINE(AVMPLUS_IA32)
3021     ;;
3022 x86_64*-*)
3023     AC_DEFINE(AVMPLUS_AMD64)
3024     AC_DEFINE(AVMPLUS_64BIT)
3025     ;;
3026 arm*-*)
3027     AC_DEFINE(AVMPLUS_ARM)
3028     ;;
3029 sparc-*)
3030     AC_DEFINE(AVMPLUS_SPARC)
3031     ;;
3032 esac
3033
3034 case "$target" in
3035 *-linux*|*-android-eabi)
3036     AC_DEFINE(AVMPLUS_UNIX)
3037     AC_DEFINE(AVMPLUS_LINUX)
3038     ;;
3039 *-darwin*)
3040     AC_DEFINE(AVMPLUS_UNIX)
3041     ;;
3042 *-solaris*)
3043     AC_DEFINE(AVMPLUS_UNIX)
3044     ;;
3045 *-freebsd*|*-kfreebsd*)
3046     AC_DEFINE(AVMPLUS_UNIX)
3047     ;;
3048 *-gnu*)
3049     AC_DEFINE(AVMPLUS_UNIX)
3050     ;;
3051 *-cygwin*|*-mingw*|*-mks*|*-msvc*|*-wince|*-winmo)
3052     AC_DEFINE(AVMPLUS_WIN32)
3053     ;;
3054 *-os2*)
3055     AC_DEFINE(AVMPLUS_OS2)
3056     ;;
3057 *)
3058     AC_MSG_ERROR([Unrecognized nanojit platform. Use --disable-tracejit to build without tracing JIT support.])
3059 esac
3060
3061 fi # ENABLE_TRACEJIT
3062
3063 AC_SUBST(ENABLE_TRACEJIT)
3064 AC_SUBST(NANOJIT_ARCH)
3065
3066 if test -z "$SKIP_COMPILER_CHECKS"; then
3067 dnl Checks for typedefs, structures, and compiler characteristics.
3068 dnl ========================================================
3069 AC_HEADER_STDC
3070 AC_C_CONST
3071 AC_TYPE_MODE_T
3072 AC_TYPE_OFF_T
3073 AC_TYPE_PID_T
3074 AC_TYPE_SIZE_T
3075 AC_LANG_CPLUSPLUS
3076 AC_MSG_CHECKING(for __stdcall)
3077 AC_CACHE_VAL(ac_cv___stdcall,
3078  [AC_TRY_COMPILE([template <typename Method> struct foo;
3079                   template <> struct foo<void (*)()> {};
3080                   template <> struct foo<void (__stdcall*)()> {};],
3081                  [],
3082                  [ac_cv___stdcall=true],
3083                  [ac_cv___stdcall=false])])
3084 if test "$ac_cv___stdcall" = true ; then
3085   AC_DEFINE(HAVE_STDCALL)
3086   AC_MSG_RESULT(yes)
3087 else
3088   AC_MSG_RESULT(no)
3089 fi
3090 AC_LANG_C
3091 AC_MSG_CHECKING(for ssize_t)
3092 AC_CACHE_VAL(ac_cv_type_ssize_t,
3093  [AC_TRY_COMPILE([#include <stdio.h>
3094                   #include <sys/types.h>],
3095                  [ssize_t foo = 0;],
3096                  [ac_cv_type_ssize_t=true],
3097                  [ac_cv_type_ssize_t=false])])
3098 if test "$ac_cv_type_ssize_t" = true ; then
3099   AC_DEFINE(HAVE_SSIZE_T)
3100   AC_MSG_RESULT(yes)
3101 else
3102   AC_MSG_RESULT(no)
3103 fi
3104 AC_STRUCT_ST_BLKSIZE
3105 AC_MSG_CHECKING(for siginfo_t)
3106 AC_CACHE_VAL(ac_cv_siginfo_t,
3107  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
3108                   #include <signal.h>],
3109                  [siginfo_t* info;],
3110                  [ac_cv_siginfo_t=true],
3111                  [ac_cv_siginfo_t=false])])
3112 if test "$ac_cv_siginfo_t" = true ; then
3113   AC_DEFINE(HAVE_SIGINFO_T)
3114   AC_MSG_RESULT(yes)
3115 else
3116   AC_MSG_RESULT(no)
3117 fi
3118
3119 dnl Find exact-width integer types, or figure them out
3120 dnl ourselves.
3121 dnl ========================================================
3122 dnl Once this is working, we can delete the code for int16_t,
3123 dnl etc. below.
3124
3125 AC_CHECK_HEADER(stdint.h)
3126 if test "$ac_cv_header_stdint_h" = yes; then
3127     AC_DEFINE(JS_HAVE_STDINT_H)
3128 else
3129     dnl We'll figure them out for ourselves.  List more likely types
3130     dnl earlier.  If we ever really encounter a size for which none of
3131     dnl the listed types are appropriate, we'll get a configure-time
3132     dnl error; just add the right answer.
3133     MOZ_N_BYTE_TYPE(JS_INT8_TYPE,  1, [char])
3134     MOZ_N_BYTE_TYPE(JS_INT16_TYPE, 2, [short int long])
3135     MOZ_N_BYTE_TYPE(JS_INT32_TYPE, 4, [int long 'long long' short])
3136     MOZ_N_BYTE_TYPE(JS_INT64_TYPE, 8, [int long 'long long'])
3137     MOZ_N_BYTE_TYPE(JS_INTPTR_TYPE, sizeof (void *),
3138                                       [int long 'long long' short])
3139 fi
3140
3141 MOZ_SIZE_OF_TYPE(JS_BYTES_PER_WORD, void*, 4 8)
3142 if test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "4"; then
3143   AC_DEFINE(JS_BITS_PER_WORD_LOG2, 5)
3144 elif test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "8"; then
3145   AC_DEFINE(JS_BITS_PER_WORD_LOG2, 6)
3146 else
3147   AC_MSG_ERROR([Unexpected JS_BYTES_PER_WORD])
3148 fi
3149
3150 MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
3151 MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14)
3152
3153 dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
3154 dnl ========================================================
3155 AC_MSG_CHECKING(for int16_t)
3156 AC_CACHE_VAL(ac_cv_int16_t,
3157  [AC_TRY_COMPILE([#include <stdio.h>
3158                   #include <sys/types.h>],
3159                  [int16_t foo = 0;],
3160                  [ac_cv_int16_t=true],
3161                  [ac_cv_int16_t=false])])
3162 if test "$ac_cv_int16_t" = true ; then
3163   AC_DEFINE(HAVE_INT16_T)
3164   AC_MSG_RESULT(yes)
3165 else
3166   AC_MSG_RESULT(no)
3167 fi
3168 AC_MSG_CHECKING(for int32_t)
3169 AC_CACHE_VAL(ac_cv_int32_t,
3170  [AC_TRY_COMPILE([#include <stdio.h>
3171                   #include <sys/types.h>],
3172                  [int32_t foo = 0;],
3173                  [ac_cv_int32_t=true],
3174                  [ac_cv_int32_t=false])])
3175 if test "$ac_cv_int32_t" = true ; then
3176   AC_DEFINE(HAVE_INT32_T)
3177   AC_MSG_RESULT(yes)
3178 else
3179   AC_MSG_RESULT(no)
3180 fi
3181 AC_MSG_CHECKING(for int64_t)
3182 AC_CACHE_VAL(ac_cv_int64_t,
3183  [AC_TRY_COMPILE([#include <stdio.h>
3184                   #include <sys/types.h>],
3185                  [int64_t foo = 0;],
3186                  [ac_cv_int64_t=true],
3187                  [ac_cv_int64_t=false])])
3188 if test "$ac_cv_int64_t" = true ; then
3189   AC_DEFINE(HAVE_INT64_T)
3190   AC_MSG_RESULT(yes)
3191 else
3192   AC_MSG_RESULT(no)
3193 fi
3194 AC_MSG_CHECKING(for int64)
3195 AC_CACHE_VAL(ac_cv_int64,
3196  [AC_TRY_COMPILE([#include <stdio.h>
3197                   #include <sys/types.h>],
3198                  [int64 foo = 0;],
3199                  [ac_cv_int64=true],
3200                  [ac_cv_int64=false])])
3201 if test "$ac_cv_int64" = true ; then
3202   AC_DEFINE(HAVE_INT64)
3203   AC_MSG_RESULT(yes)
3204 else
3205   AC_MSG_RESULT(no)
3206 fi
3207 AC_MSG_CHECKING(for uint)
3208 AC_CACHE_VAL(ac_cv_uint,
3209  [AC_TRY_COMPILE([#include <stdio.h>
3210                   #include <sys/types.h>],
3211                  [uint foo = 0;],
3212                  [ac_cv_uint=true],
3213                  [ac_cv_uint=false])])
3214 if test "$ac_cv_uint" = true ; then
3215   AC_DEFINE(HAVE_UINT)
3216   AC_MSG_RESULT(yes)
3217 else
3218   AC_MSG_RESULT(no)
3219 fi
3220 AC_MSG_CHECKING(for uint_t)
3221 AC_CACHE_VAL(ac_cv_uint_t,
3222  [AC_TRY_COMPILE([#include <stdio.h>
3223                   #include <sys/types.h>],
3224                  [uint_t foo = 0;],
3225                  [ac_cv_uint_t=true],
3226                  [ac_cv_uint_t=false])])
3227 if test "$ac_cv_uint_t" = true ; then
3228   AC_DEFINE(HAVE_UINT_T)
3229   AC_MSG_RESULT(yes)
3230 else
3231   AC_MSG_RESULT(no)
3232 fi
3233 AC_MSG_CHECKING(for uint16_t)
3234 AC_CACHE_VAL(ac_cv_uint16_t,
3235  [AC_TRY_COMPILE([#include <stdio.h>
3236                   #include <sys/types.h>],
3237                  [uint16_t foo = 0;],
3238                  [ac_cv_uint16_t=true],
3239                  [ac_cv_uint16_t=false])])
3240 if test "$ac_cv_uint16_t" = true ; then
3241   AC_DEFINE(HAVE_UINT16_T)
3242   AC_MSG_RESULT(yes)
3243 else
3244   AC_MSG_RESULT(no)
3245 fi
3246
3247 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
3248 dnl are defined when compiling C++ but not C.  Since the result of this
3249 dnl test is used only in C++, do it in C++.
3250 AC_LANG_CPLUSPLUS
3251
3252 AC_MSG_CHECKING(for uname.domainname)
3253 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
3254     [AC_TRY_COMPILE([#include <sys/utsname.h>],
3255         [ struct utsname *res; char *domain; 
3256             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
3257         [ac_cv_have_uname_domainname_field=true],
3258         [ac_cv_have_uname_domainname_field=false])])
3259
3260 if test "$ac_cv_have_uname_domainname_field" = "true"; then
3261     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
3262     AC_MSG_RESULT(yes)
3263 else
3264     AC_MSG_RESULT(no)
3265 fi
3266
3267 AC_MSG_CHECKING(for uname.__domainname)
3268 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
3269     [AC_TRY_COMPILE([#include <sys/utsname.h>],
3270         [ struct utsname *res; char *domain; 
3271             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
3272         [ac_cv_have_uname_us_domainname_field=true],
3273         [ac_cv_have_uname_us_domainname_field=false])])
3274
3275 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
3276     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
3277     AC_MSG_RESULT(yes)
3278 else
3279     AC_MSG_RESULT(no)
3280 fi
3281
3282 AC_LANG_C
3283
3284 dnl Check for .hidden assembler directive and visibility attribute.
3285 dnl Borrowed from glibc configure.in
3286 dnl ===============================================================
3287 if test "$GNU_CC"; then
3288   AC_CACHE_CHECK(for visibility(hidden) attribute,
3289                  ac_cv_visibility_hidden,
3290                  [cat > conftest.c <<EOF
3291                   int foo __attribute__ ((visibility ("hidden"))) = 1;
3292 EOF
3293                   ac_cv_visibility_hidden=no
3294                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3295                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3296                       ac_cv_visibility_hidden=yes
3297                     fi
3298                   fi
3299                   rm -f conftest.[cs]
3300                  ])
3301   if test "$ac_cv_visibility_hidden" = "yes"; then
3302     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
3303
3304     AC_CACHE_CHECK(for visibility(default) attribute,
3305                    ac_cv_visibility_default,
3306                    [cat > conftest.c <<EOF
3307                     int foo __attribute__ ((visibility ("default"))) = 1;
3308 EOF
3309                     ac_cv_visibility_default=no
3310                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3311                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3312                         ac_cv_visibility_default=yes
3313                       fi
3314                     fi
3315                     rm -f conftest.[cs]
3316                    ])
3317     if test "$ac_cv_visibility_default" = "yes"; then
3318       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
3319
3320       AC_CACHE_CHECK(for visibility pragma support,
3321                      ac_cv_visibility_pragma,
3322                      [cat > conftest.c <<EOF
3323 #pragma GCC visibility push(hidden)
3324                       int foo_hidden = 1;
3325 #pragma GCC visibility push(default)
3326                       int foo_default = 1;
3327 EOF
3328                       ac_cv_visibility_pragma=no
3329                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3330                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
3331                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
3332                             ac_cv_visibility_pragma=yes
3333                           fi
3334                         fi
3335                       fi
3336                       rm -f conftest.[cs]
3337                     ])
3338       if test "$ac_cv_visibility_pragma" = "yes"; then
3339         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
3340                        ac_cv_have_visibility_class_bug,
3341                        [cat > conftest.c <<EOF
3342 #pragma GCC visibility push(hidden)
3343 struct __attribute__ ((visibility ("default"))) TestStruct {
3344   static void Init();
3345 };
3346 __attribute__ ((visibility ("default"))) void TestFunc() {
3347   TestStruct::Init();
3348 }
3349 EOF
3350                        ac_cv_have_visibility_class_bug=no
3351                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3352                          ac_cv_have_visibility_class_bug=yes
3353                        else
3354                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
3355                            ac_cv_have_visibility_class_bug=yes
3356                          fi
3357                        fi
3358                        rm -rf conftest.{c,S}
3359                        ])
3360
3361         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
3362                        ac_cv_have_visibility_builtin_bug,
3363                        [cat > conftest.c <<EOF
3364 #pragma GCC visibility push(hidden)
3365 #pragma GCC visibility push(default)
3366 #include <string.h>
3367 #pragma GCC visibility pop
3368
3369 __attribute__ ((visibility ("default"))) void Func() {
3370   char c[[100]];
3371   memset(c, 0, sizeof(c));
3372 }
3373 EOF
3374                        ac_cv_have_visibility_builtin_bug=no
3375                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3376                          ac_cv_have_visibility_builtin_bug=yes
3377                        else
3378                          if test `grep -c "@PLT" conftest.S` = 0; then
3379                            ac_cv_visibility_builtin_bug=yes
3380                          fi
3381                        fi
3382                        rm -f conftest.{c,S}
3383                        ])
3384         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
3385                 "$ac_cv_have_visibility_class_bug" = "no"; then
3386           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers_js -include $(topsrcdir)/config/gcc_hidden.h'
3387           WRAP_SYSTEM_INCLUDES=1
3388           STL_FLAGS='-I$(DIST)/stl_wrappers'
3389           WRAP_STL_INCLUDES=1
3390         else
3391           VISIBILITY_FLAGS='-fvisibility=hidden'
3392         fi # have visibility pragma bug
3393       fi   # have visibility pragma
3394     fi     # have visibility(default) attribute
3395   fi       # have visibility(hidden) attribute
3396 fi         # GNU_CC
3397
3398 # visibility hidden flag for Sun Studio on Solaris
3399 if test "$SOLARIS_SUNPRO_CC"; then
3400 VISIBILITY_FLAGS='-xldscope=hidden'
3401 fi         # Sun Studio on Solaris
3402
3403 AC_SUBST(WRAP_SYSTEM_INCLUDES)
3404 AC_SUBST(VISIBILITY_FLAGS)
3405
3406 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
3407 dnl ========================================================
3408 if test "$GNU_CC"; then
3409   CFLAGS_save="${CFLAGS}"
3410   CFLAGS="${CFLAGS} -Werror"
3411   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
3412                  ac_cv_force_align_arg_pointer,
3413                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
3414                                  [],
3415                                  ac_cv_force_align_arg_pointer="yes",
3416                                  ac_cv_force_align_arg_pointer="no")])
3417   CFLAGS="${CFLAGS_save}"
3418   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
3419     HAVE_GCC_ALIGN_ARG_POINTER=1
3420   else
3421     HAVE_GCC_ALIGN_ARG_POINTER=
3422   fi
3423 fi
3424 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
3425
3426 dnl Checks for header files.
3427 dnl ========================================================
3428 AC_HEADER_DIRENT
3429 case "$target_os" in
3430 freebsd*)
3431 # for stuff like -lXshm
3432     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
3433     ;;
3434 esac
3435 AC_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h)
3436 AC_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h)
3437 AC_CHECK_HEADERS(gnu/libc-version.h nl_types.h)
3438 AC_CHECK_HEADERS(malloc.h)
3439 AC_CHECK_HEADERS(X11/XKBlib.h)
3440 AC_CHECK_HEADERS(io.h)
3441
3442 dnl These are all the places some variant of statfs can be hiding.
3443 AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
3444
3445 dnl Quota support
3446 AC_CHECK_HEADERS(sys/quota.h)
3447 AC_CHECK_HEADERS(linux/quota.h)
3448
3449 dnl Try for MMX support
3450 dnl NB - later gcc versions require -mmmx for this header to be successfully
3451 dnl included (or another option which implies it, such as -march=pentium-mmx)
3452 AC_CHECK_HEADERS(mmintrin.h)
3453
3454 dnl Check whether the compiler supports the new-style C++ standard
3455 dnl library headers (i.e. <new>) or needs the old "new.h"
3456 AC_LANG_CPLUSPLUS
3457 NEW_H=new.h
3458 AC_CHECK_HEADER(new, [NEW_H=new])
3459 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3460 AC_LANG_C
3461
3462 AC_ARG_ENABLE(dtrace,
3463               [  --enable-dtrace         build with dtrace support if available (default=no)],
3464               [enable_dtrace="yes"],)
3465 if test "x$enable_dtrace" = "xyes"; then
3466   AC_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3467   if test -n "$HAVE_DTRACE"; then
3468       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3469   else
3470       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3471   fi
3472 fi
3473 AC_SUBST(HAVE_DTRACE)
3474
3475 case $target in
3476 *-aix4.3*|*-aix5*)
3477         ;;
3478 *)
3479         AC_CHECK_HEADERS(sys/cdefs.h)
3480         ;;
3481 esac
3482
3483 dnl Performance measurement headers.
3484 AC_CHECK_HEADER(linux/perf_event.h, HAVE_LINUX_PERF_EVENT_H=1)
3485 AC_SUBST(HAVE_LINUX_PERF_EVENT_H)
3486
3487 dnl Checks for libraries.
3488 dnl ========================================================
3489 case $target in
3490 *-hpux11.*)
3491         ;;
3492 *)
3493         AC_CHECK_LIB(c_r, gethostbyname_r)
3494         ;;
3495 esac
3496
3497 dnl We don't want to link with libdl even if it's present on OS X, since
3498 dnl it's not used and not part of the default installation.
3499 dnl The same goes for BeOS. OS/2 has dlfcn in libc.
3500 dnl We don't want to link against libm or libpthread on Darwin since
3501 dnl they both are just symlinks to libSystem and explicitly linking
3502 dnl against libSystem causes issues when debugging (see bug 299601).
3503 case $target in
3504 *-darwin*)
3505     ;;
3506 *-beos*)
3507     ;;
3508 *-os2*)
3509     ;;
3510 *)
3511     AC_SEARCH_LIBS(dlopen, dl, 
3512         AC_CHECK_HEADER(dlfcn.h, 
3513         AC_DEFINE(HAVE_DLOPEN)))
3514     ;;
3515 esac
3516
3517 _SAVE_CFLAGS="$CFLAGS"
3518 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3519 AC_CHECK_FUNCS(dladdr)
3520 CFLAGS="$_SAVE_CFLAGS"
3521
3522 if test ! "$GNU_CXX"; then
3523
3524     case $target in
3525     *-aix*)
3526         AC_CHECK_LIB(C_r, demangle)
3527         ;;
3528      *)
3529         AC_CHECK_LIB(C, demangle)
3530         ;;
3531      esac
3532 fi
3533
3534 dnl OS/2 has socket in libc.
3535 case $target in
3536 *-os2*)
3537     ;;
3538 *)
3539     AC_CHECK_LIB(socket, socket)
3540 esac
3541
3542 AC_MSG_CHECKING(for ARM SIMD support in compiler)
3543 AC_TRY_COMPILE([],
3544                [asm("uqadd8 r1, r1, r2");],
3545                result="yes", result="no")
3546 AC_MSG_RESULT("$result")
3547 if test "$result" = "yes"; then
3548     AC_DEFINE(HAVE_ARM_SIMD)
3549     HAVE_ARM_SIMD=1
3550 fi
3551 AC_SUBST(HAVE_ARM_SIMD)
3552
3553 dnl ========================================================
3554 dnl = pthread support
3555 dnl = Start by checking whether the system support pthreads
3556 dnl ========================================================
3557 case "$target_os" in
3558 darwin*)
3559     USE_PTHREADS=1
3560     ;;
3561 *)
3562     MOZ_CHECK_PTHREADS(pthreads,
3563         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3564         MOZ_CHECK_PTHREADS(pthread,
3565             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3566             MOZ_CHECK_PTHREADS(c_r,
3567                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3568                 MOZ_CHECK_PTHREADS(c,
3569                     USE_PTHREADS=1
3570                 )
3571             )
3572         )
3573     )
3574     ;;
3575 esac
3576
3577 dnl ========================================================
3578 dnl Check the command line for --with-pthreads 
3579 dnl ========================================================
3580 MOZ_ARG_WITH_BOOL(pthreads,
3581 [  --with-pthreads         Force use of system pthread library with NSPR ],
3582 [ if test "$USE_PTHREADS"x = x; then
3583     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3584 fi],
3585     USE_PTHREADS=
3586     _PTHREAD_LDFLAGS=
3587 )
3588
3589 dnl ========================================================
3590 dnl Do the platform specific pthread hackery
3591 dnl ========================================================
3592 if test "$USE_PTHREADS"x != x
3593 then
3594         dnl
3595         dnl See if -pthread is supported.
3596         dnl
3597         rm -f conftest*
3598         ac_cv_have_dash_pthread=no
3599         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3600         echo 'int main() { return 0; }' | cat > conftest.c
3601         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3602         if test $? -eq 0; then
3603                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3604                         ac_cv_have_dash_pthread=yes
3605                 case "$target_os" in
3606                 freebsd*)
3607 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3608                 ;;
3609                 *)
3610                             CFLAGS="$CFLAGS -pthread"
3611                             CXXFLAGS="$CXXFLAGS -pthread"
3612                 ;;
3613                 esac
3614                 fi
3615         fi
3616         rm -f conftest*
3617     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3618
3619         dnl
3620         dnl See if -pthreads is supported.
3621         dnl
3622     ac_cv_have_dash_pthreads=no
3623     if test "$ac_cv_have_dash_pthread" = "no"; then
3624             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3625         echo 'int main() { return 0; }' | cat > conftest.c
3626             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3627         if test $? -eq 0; then
3628                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3629                             ac_cv_have_dash_pthreads=yes
3630                             CFLAGS="$CFLAGS -pthreads"
3631                             CXXFLAGS="$CXXFLAGS -pthreads"
3632                     fi
3633             fi
3634             rm -f conftest*
3635         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3636     fi
3637
3638         case "$target" in
3639             *-*-freebsd*)
3640                         AC_DEFINE(_REENTRANT)
3641                         AC_DEFINE(_THREAD_SAFE)
3642                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3643                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3644                                 _PTHREAD_LDFLAGS="-pthread"
3645                         else
3646                                 _PTHREAD_LDFLAGS="-lc_r"
3647                         fi
3648                         ;;
3649
3650             *-*-openbsd*|*-*-bsdi*)
3651                         AC_DEFINE(_REENTRANT)
3652                         AC_DEFINE(_THREAD_SAFE)
3653                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3654                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3655                 _PTHREAD_LDFLAGS="-pthread"
3656                         fi
3657                         ;;
3658
3659             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3660                         AC_DEFINE(_REENTRANT) 
3661                         ;;
3662
3663             *-*-nto*) 
3664                         AC_DEFINE(_REENTRANT) 
3665                         ;;
3666
3667             *-aix4.3*|*-aix5*)
3668                         AC_DEFINE(_REENTRANT) 
3669                         ;;
3670
3671             *-hpux11.*)
3672                         AC_DEFINE(_REENTRANT) 
3673                         ;;
3674
3675             alpha*-*-osf*)
3676                         AC_DEFINE(_REENTRANT)
3677                         ;;
3678
3679             *-*-solaris*) 
3680                         AC_DEFINE(_REENTRANT)
3681                         if test "$SOLARIS_SUNPRO_CC"; then
3682                                 CFLAGS="$CFLAGS -mt" 
3683                                 CXXFLAGS="$CXXFLAGS -mt" 
3684                         fi
3685                         ;;
3686         esac
3687     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3688 fi
3689
3690 dnl ========================================================
3691 dnl See if mmap sees writes
3692 dnl For cross compiling, just define it as no, which is a safe default
3693 dnl ========================================================
3694 AC_MSG_CHECKING(whether mmap() sees write()s)
3695
3696 changequote(,)
3697 mmap_test_prog='
3698     #include <stdlib.h>
3699     #include <unistd.h>
3700     #include <sys/mman.h>
3701     #include <sys/types.h>
3702     #include <sys/stat.h>
3703     #include <fcntl.h>
3704
3705     char fname[] = "conftest.file";
3706     char zbuff[1024]; /* Fractional page is probably worst case */
3707
3708     int main() {
3709         char *map;
3710         int fd;
3711         int i;
3712         unlink(fname);
3713         fd = open(fname, O_RDWR | O_CREAT, 0660);
3714         if(fd<0) return 1;
3715         unlink(fname);
3716         write(fd, zbuff, sizeof(zbuff));
3717         lseek(fd, 0, SEEK_SET);
3718         map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0);
3719         if(map==(char*)-1) return 2;
3720         for(i=0; fname[i]; i++) {
3721             int rc = write(fd, &fname[i], 1);
3722             if(map[i]!=fname[i]) return 4;
3723         }
3724         return 0;
3725     }
3726 '
3727 changequote([,])
3728
3729 AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes")
3730
3731 AC_MSG_RESULT("$result")
3732
3733 if test "$result" = "no"; then
3734     AC_DEFINE(MMAP_MISSES_WRITES)
3735 fi
3736
3737
3738 dnl Checks for library functions.
3739 dnl ========================================================
3740 AC_PROG_GCC_TRADITIONAL
3741 AC_FUNC_MEMCMP
3742 AC_CHECK_FUNCS([fchmod flockfile getc_unlocked _getc_nolock getpagesize \
3743                 lchown localtime_r lstat64 memmove random rint sbrk snprintf \
3744                 stat64 statvfs statvfs64 strerror strtok_r truncate64])
3745
3746 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock, and -lrt
3747 _SAVE_LDFLAGS=$LDFLAGS
3748 LDFLAGS="$LDFLAGS -lrt"
3749 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC) and -lrt,
3750                ac_cv_have_clock_monotonic,
3751                [AC_TRY_LINK([#include <time.h>],
3752                             [ struct timespec ts;
3753                               clock_gettime(CLOCK_MONOTONIC, &ts); ],
3754                             ac_cv_have_clock_monotonic=yes,
3755                             ac_cv_have_clock_monotonic=no)])
3756 LDFLAGS=$_SAVE_LDFLAGS
3757 if test "$ac_cv_have_clock_monotonic" = "yes"; then
3758     HAVE_CLOCK_MONOTONIC=1
3759     REALTIME_LIBS=-lrt
3760     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3761     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3762     AC_SUBST(REALTIME_LIBS)
3763 fi
3764
3765 dnl Windows functions, for mingw.
3766 AC_TRY_LINK([#include <windows.h>],
3767              [SYSTEMTIME st;FILETIME ft;SystemTimeToFileTime(&st,&ft);],
3768              ac_cv_have_systemtimetofiletime="yes",
3769              ac_cv_have_systemtimetofiletime="no")
3770 if test "$ac_cv_have_systemtimetofiletime" = "yes"; then
3771     AC_DEFINE(HAVE_SYSTEMTIMETOFILETIME)
3772 fi
3773 AC_TRY_LINK([#include <windows.h>],
3774              [FILETIME ft;GetSystemTimeAsFileTime(&ft);],
3775              ac_cv_have_getsystemtimeasfiletime="yes",
3776              ac_cv_have_getsystemtimeasfiletime="no")
3777 if test "$ac_cv_have_getsystemtimeasfiletime" = "yes"; then
3778     AC_DEFINE(HAVE_GETSYSTEMTIMEASFILETIME)
3779 fi
3780
3781 dnl check for wcrtomb/mbrtowc
3782 dnl =======================================================================
3783 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3784 AC_LANG_SAVE
3785 AC_LANG_CPLUSPLUS
3786 AC_CACHE_CHECK(for wcrtomb,
3787     ac_cv_have_wcrtomb,
3788     [AC_TRY_LINK([#include <wchar.h>],
3789                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3790                  ac_cv_have_wcrtomb="yes",
3791                  ac_cv_have_wcrtomb="no")])
3792 if test "$ac_cv_have_wcrtomb" = "yes"; then
3793     AC_DEFINE(HAVE_WCRTOMB)
3794 fi
3795 AC_CACHE_CHECK(for mbrtowc,
3796     ac_cv_have_mbrtowc,
3797     [AC_TRY_LINK([#include <wchar.h>],
3798                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3799                  ac_cv_have_mbrtowc="yes",
3800                  ac_cv_have_mbrtowc="no")])
3801 if test "$ac_cv_have_mbrtowc" = "yes"; then
3802     AC_DEFINE(HAVE_MBRTOWC)
3803 fi
3804 AC_LANG_RESTORE
3805 fi
3806
3807 AC_CACHE_CHECK(
3808     [for res_ninit()],
3809     ac_cv_func_res_ninit,
3810     [AC_TRY_LINK([
3811         #ifdef linux
3812         #define _BSD_SOURCE 1
3813         #endif
3814         #include <resolv.h>
3815         ],
3816         [int foo = res_ninit(&_res);],
3817         [ac_cv_func_res_ninit=yes],
3818         [ac_cv_func_res_ninit=no])
3819     ])
3820
3821 if test "$ac_cv_func_res_ninit" = "yes"; then
3822     AC_DEFINE(HAVE_RES_NINIT)
3823 dnl must add the link line we do something as foolish as this... dougt
3824 dnl else
3825 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3826 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3827 fi
3828
3829 AC_LANG_CPLUSPLUS
3830 AC_CACHE_CHECK(
3831     [for gnu_get_libc_version()],
3832     ac_cv_func_gnu_get_libc_version,
3833     [AC_TRY_LINK([
3834         #ifdef HAVE_GNU_LIBC_VERSION_H
3835         #include <gnu/libc-version.h>
3836         #endif
3837         ],
3838         [const char *glibc_version = gnu_get_libc_version();],
3839         [ac_cv_func_gnu_get_libc_version=yes],
3840         [ac_cv_func_gnu_get_libc_version=no] 
3841         )]
3842     )
3843
3844 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3845     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3846 fi
3847
3848 case $target_os in
3849     os2*|msvc*|mks*|cygwin*|mingw*|darwin*|wince*|winmo*|beos*)
3850         ;;
3851     *)
3852     
3853 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3854     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3855         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3856 _SAVE_LIBS=$LIBS
3857 LIBS="$LIBS $_ICONV_LIBS"
3858 AC_CACHE_CHECK(
3859     [for iconv()],
3860     ac_cv_func_iconv,
3861     [AC_TRY_LINK([
3862         #include <stdlib.h>
3863         #include <iconv.h>
3864         ],
3865         [
3866             iconv_t h = iconv_open("", "");
3867             iconv(h, NULL, NULL, NULL, NULL);
3868             iconv_close(h);
3869         ],
3870         [ac_cv_func_iconv=yes],
3871         [ac_cv_func_iconv=no] 
3872         )]
3873     )
3874 if test "$ac_cv_func_iconv" = "yes"; then
3875     AC_DEFINE(HAVE_ICONV)
3876     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3877     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3878     LIBICONV="$_ICONV_LIBS"
3879     AC_CACHE_CHECK(
3880         [for iconv() with const input],
3881         ac_cv_func_const_iconv,
3882         [AC_TRY_COMPILE([
3883             #include <stdlib.h>
3884             #include <iconv.h>
3885             ],
3886             [
3887                 const char *input = "testing";
3888                 iconv_t h = iconv_open("", "");
3889                 iconv(h, &input, NULL, NULL, NULL);
3890                 iconv_close(h);
3891             ],
3892             [ac_cv_func_const_iconv=yes],
3893             [ac_cv_func_const_iconv=no] 
3894             )]
3895         )
3896     if test "$ac_cv_func_const_iconv" = "yes"; then
3897         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3898     fi
3899 fi
3900 LIBS=$_SAVE_LIBS
3901
3902     ;;
3903 esac
3904
3905 AC_LANG_C
3906
3907 dnl **********************
3908 dnl *** va_copy checks ***
3909 dnl **********************
3910 dnl we currently check for all three va_copy possibilities, so we get
3911 dnl all results in config.log for bug reports.
3912 AC_MSG_CHECKING(for an implementation of va_copy())
3913 AC_CACHE_VAL(ac_cv_va_copy,[
3914     AC_TRY_RUN([
3915         #include <stdarg.h>
3916         void f (int i, ...) {
3917             va_list args1, args2;
3918             va_start (args1, i);
3919             va_copy (args2, args1);
3920             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3921                 exit (1);
3922             va_end (args1); va_end (args2);
3923         }
3924         int main() { f (0, 42); return 0; }],
3925         ac_cv_va_copy=yes,
3926         ac_cv_va_copy=no,
3927         ac_cv_va_copy=no
3928     )
3929 ])
3930 AC_MSG_RESULT($ac_cv_va_copy)
3931 AC_MSG_CHECKING(for an implementation of __va_copy())
3932 AC_CACHE_VAL(ac_cv___va_copy,[
3933     AC_TRY_RUN([
3934         #include <stdarg.h>
3935         void f (int i, ...) {
3936             va_list args1, args2;
3937             va_start (args1, i);
3938             __va_copy (args2, args1);
3939             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3940                 exit (1);
3941             va_end (args1); va_end (args2);
3942         }
3943         int main() { f (0, 42); return 0; }],
3944         ac_cv___va_copy=yes,
3945         ac_cv___va_copy=no,
3946         ac_cv___va_copy=no
3947     )
3948 ])
3949 AC_MSG_RESULT($ac_cv___va_copy)
3950 AC_MSG_CHECKING(whether va_lists can be copied by value)
3951 AC_CACHE_VAL(ac_cv_va_val_copy,[
3952     AC_TRY_RUN([
3953         #include <stdarg.h>
3954         void f (int i, ...) {
3955             va_list args1, args2;
3956             va_start (args1, i);
3957             args2 = args1;
3958             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3959                 exit (1);
3960             va_end (args1); va_end (args2);
3961         }
3962         int main() { f (0, 42); return 0; }],
3963         ac_cv_va_val_copy=yes,
3964         ac_cv_va_val_copy=no,
3965         ac_cv_va_val_copy=yes
3966     )
3967 ])
3968 if test "x$ac_cv_va_copy" = "xyes"; then
3969     AC_DEFINE(VA_COPY, va_copy)
3970     AC_DEFINE(HAVE_VA_COPY)
3971 elif test "x$ac_cv___va_copy" = "xyes"; then
3972     AC_DEFINE(VA_COPY, __va_copy)
3973     AC_DEFINE(HAVE_VA_COPY)
3974 fi
3975
3976 if test "x$ac_cv_va_val_copy" = "xno"; then
3977    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3978 fi
3979 AC_MSG_RESULT($ac_cv_va_val_copy)
3980
3981 dnl Check for dll-challenged libc's.
3982 dnl This check is apparently only needed for Linux.
3983 case "$target" in
3984         *-linux*)
3985             dnl ===================================================================
3986             _curdir=`pwd`
3987             export _curdir
3988             rm -rf conftest* _conftest
3989             mkdir _conftest
3990             cat >> conftest.C <<\EOF
3991 #include <stdio.h>
3992 #include <link.h>
3993 #include <dlfcn.h>
3994 #ifdef _dl_loaded
3995 void __dump_link_map(void) {
3996   struct link_map *map = _dl_loaded;
3997   while (NULL != map) {printf("0x%08x %s\n", map->l_addr, map->l_name); map = map->l_next;}
3998 }
3999 int main() {
4000   dlopen("./conftest1.so",RTLD_LAZY);
4001   dlopen("./../_conftest/conftest1.so",RTLD_LAZY);
4002   dlopen("CURDIR/_conftest/conftest1.so",RTLD_LAZY);
4003   dlopen("CURDIR/_conftest/../_conftest/conftest1.so",RTLD_LAZY);
4004   __dump_link_map();
4005 }
4006 #else
4007 /* _dl_loaded isn't defined, so this should be either a libc5 (glibc1) system, or a glibc2 system that doesn't have the multiple load bug (i.e., RH6.0).*/
4008 int main() { printf("./conftest1.so\n"); }
4009 #endif
4010 EOF
4011
4012             $PERL -p -i -e "s/CURDIR/\$ENV{_curdir}/g;" conftest.C
4013
4014             cat >> conftest1.C <<\EOF
4015 #include <stdio.h>
4016 void foo(void) {printf("foo in dll called\n");}
4017 EOF
4018             ${CXX-g++} -fPIC -c -g conftest1.C
4019             ${CXX-g++} -shared -Wl,-h -Wl,conftest1.so -o conftest1.so conftest1.o
4020             ${CXX-g++} -g conftest.C -o conftest -ldl
4021             cp -f conftest1.so conftest _conftest
4022             cd _conftest
4023             if test `./conftest | grep conftest1.so | wc -l` -gt 1
4024             then
4025                 echo
4026                 echo "*** Your libc has a bug that can result in loading the same dynamic"
4027                 echo "*** library multiple times.  This bug is known to be fixed in glibc-2.0.7-32"
4028                 echo "*** or later.  However, if you choose not to upgrade, the only effect"
4029                 echo "*** will be excessive memory usage at runtime."
4030                 echo
4031             fi
4032             cd ${_curdir}
4033             rm -rf conftest* _conftest
4034             dnl ===================================================================
4035             ;;
4036 esac
4037
4038 dnl ===================================================================
4039 dnl ========================================================
4040 dnl Put your C++ language/feature checks below
4041 dnl ========================================================
4042 AC_LANG_CPLUSPLUS
4043
4044 ARM_ABI_PREFIX=
4045 HAVE_GCC3_ABI=
4046 if test "$GNU_CC"; then
4047   if test "$CPU_ARCH" = "arm" ; then
4048     AC_CACHE_CHECK(for ARM EABI,
4049         ac_cv_gcc_arm_eabi,
4050         [AC_TRY_COMPILE([],
4051                         [
4052 #if defined(__ARM_EABI__)
4053   return 0;
4054 #else
4055 #error Not ARM EABI.
4056 #endif
4057                         ],
4058                         ac_cv_gcc_arm_eabi="yes",
4059                         ac_cv_gcc_arm_eabi="no")])
4060     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
4061         HAVE_ARM_EABI=1
4062         ARM_ABI_PREFIX=eabi-
4063     else
4064         ARM_ABI_PREFIX=oabi-
4065     fi
4066   fi
4067
4068   AC_CACHE_CHECK(for gcc 3.0 ABI,
4069       ac_cv_gcc_three_abi,
4070       [AC_TRY_COMPILE([],
4071                       [
4072 #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
4073   return 0;
4074 #else
4075 #error Not gcc3.
4076 #endif
4077                       ],
4078                       ac_cv_gcc_three_abi="yes",
4079                       ac_cv_gcc_three_abi="no")])
4080   if test "$ac_cv_gcc_three_abi" = "yes"; then
4081       TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
4082       HAVE_GCC3_ABI=1
4083   else
4084       TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc2}"
4085   fi
4086 fi
4087 AC_SUBST(HAVE_GCC3_ABI)
4088
4089
4090 AC_CACHE_CHECK(for C++ \"explicit\" keyword,
4091                ac_cv_cpp_explicit,
4092                [AC_TRY_COMPILE(class X {
4093                                public: explicit X(int i) : i_(i) {}
4094                                private: int i_;
4095                                };,
4096                                X x(3);,
4097                                ac_cv_cpp_explicit=yes,
4098                                ac_cv_cpp_explicit=no)])
4099 if test "$ac_cv_cpp_explicit" = yes ; then
4100    AC_DEFINE(HAVE_CPP_EXPLICIT)
4101 fi
4102
4103 AC_CACHE_CHECK(for C++ \"typename\" keyword,
4104                ac_cv_cpp_typename,
4105                [AC_TRY_COMPILE(class param {
4106                                public:
4107                                    typedef unsigned long num_type;
4108                                };
4109
4110                                template <class T> class tplt {
4111                                public:
4112                                    typedef typename T::num_type t_num_type;
4113                                    t_num_type foo(typename T::num_type num) {
4114                                        return num;
4115                                    }
4116                                };,
4117                                tplt<param> A;
4118                                A.foo(0);,
4119                                ac_cv_cpp_typename=yes,
4120                                ac_cv_cpp_typename=no)])
4121 if test "$ac_cv_cpp_typename" = yes ; then
4122    AC_DEFINE(HAVE_CPP_TYPENAME)
4123 fi
4124
4125 dnl Check for support of modern template specialization syntax
4126 dnl Test code and requirement from scc@netscape.com.
4127 dnl Autoconf cut-and-paste job by waterson@netscape.com
4128 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
4129                ac_cv_cpp_modern_specialize_template_syntax,
4130                [AC_TRY_COMPILE(template <class T> struct X { int a; };
4131                                class Y {};
4132                                template <> struct X<Y> { double a; };,
4133                                X<int> int_x;
4134                                X<Y> y_x;,
4135                                ac_cv_cpp_modern_specialize_template_syntax=yes,
4136                                ac_cv_cpp_modern_specialize_template_syntax=no)])
4137 if test "$ac_cv_cpp_modern_specialize_template_syntax" = yes ; then
4138   AC_DEFINE(HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX)
4139 fi
4140
4141
4142 dnl Some compilers support only full specialization, and some don't.
4143 AC_CACHE_CHECK(whether partial template specialization works,
4144                ac_cv_cpp_partial_specialization,
4145                [AC_TRY_COMPILE(template <class T> class Foo {};
4146                                template <class T> class Foo<T*> {};,
4147                                return 0;,
4148                                ac_cv_cpp_partial_specialization=yes,
4149                                ac_cv_cpp_partial_specialization=no)])
4150 if test "$ac_cv_cpp_partial_specialization" = yes ; then
4151   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
4152 fi
4153
4154 dnl Some compilers have limited support for operators with templates;
4155 dnl specifically, it is necessary to define derived operators when a base
4156 dnl class's operator declaration should suffice.
4157 AC_CACHE_CHECK(whether operators must be re-defined for templates derived from templates,
4158                ac_cv_need_derived_template_operators,
4159                [AC_TRY_COMPILE([template <class T> class Base { };
4160                                 template <class T>
4161                                 Base<T> operator+(const Base<T>& lhs, const Base<T>& rhs) { return lhs; }
4162                                 template <class T> class Derived : public Base<T> { };],
4163                                [Derived<char> a, b;
4164                                 Base<char> c = a + b;
4165                                 return 0;],
4166                                ac_cv_need_derived_template_operators=no,
4167                                ac_cv_need_derived_template_operators=yes)])
4168 if test "$ac_cv_need_derived_template_operators" = yes ; then
4169   AC_DEFINE(NEED_CPP_DERIVED_TEMPLATE_OPERATORS)
4170 fi
4171
4172
4173 dnl Some compilers have trouble detecting that a template class
4174 dnl that derives from another template is actually an instance
4175 dnl of the base class. This test checks for that.
4176 AC_CACHE_CHECK(whether we need to cast a derived template to pass as its base class,
4177                ac_cv_need_cpp_template_cast_to_base,
4178                [AC_TRY_COMPILE([template <class T> class Base { };
4179                                 template <class T> class Derived : public Base<T> { };
4180                                 template <class T> int foo(const Base<T>&) { return 0; }],
4181                                [Derived<char> bar; return foo(bar);],
4182                                ac_cv_need_cpp_template_cast_to_base=no,
4183                                ac_cv_need_cpp_template_cast_to_base=yes)])
4184 if test "$ac_cv_need_cpp_template_cast_to_base" = yes ; then
4185   AC_DEFINE(NEED_CPP_TEMPLATE_CAST_TO_BASE)
4186 fi
4187
4188 dnl Some compilers have trouble resolving the ambiguity between two
4189 dnl functions whose arguments differ only by cv-qualifications.
4190 AC_CACHE_CHECK(whether the compiler can resolve const ambiguities for templates,
4191                ac_cv_can_resolve_const_ambiguity,
4192                [AC_TRY_COMPILE([
4193                                 template <class T> class ptrClass {
4194                                   public: T* ptr;
4195                                 };
4196
4197                                 template <class T> T* a(ptrClass<T> *arg) {
4198                                   return arg->ptr;
4199                                 }
4200
4201                                 template <class T>
4202                                 const T* a(const ptrClass<T> *arg) {
4203                                   return arg->ptr;
4204                                 }
4205                                ],
4206                                [ ptrClass<int> i;
4207                                  a(&i); ],
4208                                ac_cv_can_resolve_const_ambiguity=yes,
4209                                ac_cv_can_resolve_const_ambiguity=no)])
4210 if test "$ac_cv_can_resolve_const_ambiguity" = no ; then
4211   AC_DEFINE(CANT_RESOLVE_CPP_CONST_AMBIGUITY)
4212 fi
4213
4214 dnl
4215 dnl We don't do exceptions on unix.  The only reason this used to be here
4216 dnl is that mozilla/xpcom/tests/TestCOMPtr.cpp has a test which uses 
4217 dnl exceptions.  But, we turn exceptions off by default and this test breaks.
4218 dnl So im commenting this out until someone writes some artificial 
4219 dnl intelligence to detect not only if the compiler has exceptions, but if 
4220 dnl they are enabled as well.
4221 dnl 
4222 dnl AC_CACHE_CHECK(for C++ \"exceptions\",
4223 dnl                ac_cv_cpp_exceptions,
4224 dnl                [AC_TRY_COMPILE(class X { public: X() {} };
4225 dnl                                static void F() { throw X(); },
4226 dnl                                try { F(); } catch(X & e) { },
4227 dnl                                ac_cv_cpp_exceptions=yes,
4228 dnl                                ac_cv_cpp_exceptions=no)])
4229 dnl if test $ac_cv_cpp_exceptions = yes ; then
4230 dnl    AC_DEFINE(HAVE_CPP_EXCEPTIONS)
4231 dnl fi
4232
4233 dnl Some compilers have marginal |using| support; for example, gcc-2.7.2.3
4234 dnl supports it well enough to allow us to use it to change access, but not
4235 dnl to resolve ambiguity. The next two tests determine how well the |using|
4236 dnl keyword is supported.
4237 dnl
4238 dnl Check to see if we can change access with |using|.  Test both a
4239 dnl legal and an illegal example.
4240 AC_CACHE_CHECK(whether the C++ \"using\" keyword can change access,
4241                ac_cv_cpp_access_changing_using2,
4242                [AC_TRY_COMPILE(
4243                    class A { protected: int foo() { return 0; } };
4244                    class B : public A { public: using A::foo; };,
4245                    B b; return b.foo();,
4246                    [AC_TRY_COMPILE(
4247                        class A { public: int foo() { return 1; } };
4248                        class B : public A { private: using A::foo; };,
4249                        B b; return b.foo();,
4250                        ac_cv_cpp_access_changing_using2=no,
4251                        ac_cv_cpp_access_changing_using2=yes)],
4252                    ac_cv_cpp_access_changing_using2=no)])
4253 if test "$ac_cv_cpp_access_changing_using2" = yes ; then
4254    AC_DEFINE(HAVE_CPP_ACCESS_CHANGING_USING)
4255 fi
4256
4257 dnl Check to see if we can resolve ambiguity with |using|.
4258 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
4259                ac_cv_cpp_ambiguity_resolving_using,
4260                [AC_TRY_COMPILE(class X { 
4261                                  public: int go(const X&) {return 3;}
4262                                          int jo(const X&) {return 3;}
4263                                };
4264                                class Y : public X {
4265                                  public:  int go(int) {return 2;}
4266                                           int jo(int) {return 2;}
4267                                           using X::jo;
4268                                  private: using X::go;
4269                                };,
4270                                X x; Y y; y.jo(x);,
4271                                ac_cv_cpp_ambiguity_resolving_using=yes,
4272                                ac_cv_cpp_ambiguity_resolving_using=no)])
4273 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
4274    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
4275 fi
4276
4277 dnl Check to see if the |std| namespace is supported. If so, we'll want
4278 dnl to qualify any standard library calls with "std::" to ensure that
4279 dnl those functions can be resolved.
4280 AC_CACHE_CHECK(for \"std::\" namespace,
4281                ac_cv_cpp_namespace_std,
4282                [AC_TRY_COMPILE([#include <algorithm>],
4283                                [return std::min(0, 1);],
4284                                ac_cv_cpp_namespace_std=yes,
4285                                ac_cv_cpp_namespace_std=no)])
4286 if test "$ac_cv_cpp_namespace_std" = yes ; then
4287    AC_DEFINE(HAVE_CPP_NAMESPACE_STD)
4288 fi
4289
4290 dnl Older compilers are overly ambitious with respect to using the standard
4291 dnl template library's |operator!=()| when |operator==()| is defined. In
4292 dnl which case, defining |operator!=()| in addition to |operator==()| causes
4293 dnl ambiguity at compile-time. This test checks for that case.
4294 AC_CACHE_CHECK(whether standard template operator!=() is ambiguous,
4295                ac_cv_cpp_unambiguous_std_notequal,
4296                [AC_TRY_COMPILE([#include <algorithm>
4297                                 struct T1 {};
4298                                 int operator==(const T1&, const T1&) { return 0; }
4299                                 int operator!=(const T1&, const T1&) { return 0; }],
4300                                [T1 a,b; return a != b;],
4301                                ac_cv_cpp_unambiguous_std_notequal=unambiguous,
4302                                ac_cv_cpp_unambiguous_std_notequal=ambiguous)])
4303 if test "$ac_cv_cpp_unambiguous_std_notequal" = unambiguous ; then
4304   AC_DEFINE(HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL)
4305 fi
4306
4307
4308 AC_CACHE_CHECK(for C++ reinterpret_cast,
4309                ac_cv_cpp_reinterpret_cast,
4310                [AC_TRY_COMPILE(struct X { int i; };
4311                                struct Y { int i; };,
4312                                X x; X*const z = &x;Y*y = reinterpret_cast<Y*>(z);,
4313                                ac_cv_cpp_reinterpret_cast=yes,
4314                                ac_cv_cpp_reinterpret_cast=no)])
4315 if test "$ac_cv_cpp_reinterpret_cast" = yes ; then
4316    AC_DEFINE(HAVE_CPP_NEW_CASTS)
4317 fi
4318
4319 dnl See if a dynamic_cast to void* gives the most derived object.
4320 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
4321                ac_cv_cpp_dynamic_cast_void_ptr,
4322                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
4323                             class Y { int j; public: virtual ~Y() { } };
4324                             class Z : public X, public Y { int k; };
4325
4326                             int main() {
4327                                  Z mdo;
4328                                  X *subx = (X*)&mdo;
4329                                  Y *suby = (Y*)&mdo;
4330                                  return !((((void*)&mdo != (void*)subx) &&
4331                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
4332                                           (((void*)&mdo != (void*)suby) &&
4333                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
4334                             }],
4335                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
4336                            ac_cv_cpp_dynamic_cast_void_ptr=no,
4337                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
4338 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
4339    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
4340 fi
4341
4342
4343 dnl note that this one is reversed - if the test fails, then
4344 dnl we require implementations of unused virtual methods. Which
4345 dnl really blows because it means we'll have useless vtable
4346 dnl bloat.
4347 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
4348                ac_cv_cpp_unused_required,
4349                [AC_TRY_LINK(class X {private: virtual void never_called();};,
4350                                X x;,
4351                                ac_cv_cpp_unused_required=no,
4352                                ac_cv_cpp_unused_required=yes)])
4353 if test "$ac_cv_cpp_unused_required" = yes ; then
4354    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
4355 fi
4356
4357
4358 dnl Some compilers have trouble comparing a constant reference to a templatized
4359 dnl class to zero, and require an explicit operator==() to be defined that takes
4360 dnl an int. This test separates the strong from the weak.
4361
4362 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
4363                ac_cv_trouble_comparing_to_zero,
4364                [AC_TRY_COMPILE([#include <algorithm>
4365                                 template <class T> class Foo {};
4366                                 class T2;
4367                                 template <class T> int operator==(const T2*, const T&) { return 0; }
4368                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
4369                                [Foo<int> f; return (0 != f);],
4370                                ac_cv_trouble_comparing_to_zero=no,
4371                                ac_cv_trouble_comparing_to_zero=yes)])
4372 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
4373   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
4374 fi
4375
4376 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
4377 _SAVE_LDFLAGS=$LDFLAGS
4378 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS"
4379 AC_CACHE_CHECK(for __thread keyword for TLS variables,
4380                ac_cv_thread_keyword,
4381                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
4382                             [return tlsIsMainThread;],
4383                             ac_cv_thread_keyword=yes,
4384                             ac_cv_thread_keyword=no)])
4385 LDFLAGS=$_SAVE_LDFLAGS
4386 if test "$ac_cv_thread_keyword" = yes; then
4387   # mips builds fail with TLS variables because of a binutils bug.
4388   # See bug 528687
4389   case "${target}" in
4390     mips*-*)
4391       :
4392       ;;
4393     *-android*)
4394       :
4395       ;;
4396     *)
4397       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
4398       ;;
4399   esac
4400 fi
4401
4402 dnl Check for the existence of various allocation headers/functions
4403
4404 MALLOC_H=
4405 AC_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
4406 if test "$MALLOC_H" = ""; then
4407   AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
4408   if test "$MALLOC_H" = ""; then
4409     AC_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
4410   fi
4411 fi
4412 if test "$MALLOC_H" != ""; then
4413    AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
4414 fi
4415
4416 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
4417 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
4418
4419 dnl See if compiler supports some gcc-style attributes
4420
4421 AC_CACHE_CHECK(for __attribute__((always_inline)),
4422                ac_cv_attribute_always_inline,
4423                [AC_TRY_COMPILE([],
4424                                [inline void f(void) __attribute__((always_inline));],
4425                                ac_cv_attribute_always_inline=yes,
4426                                ac_cv_attribute_always_inline=no)])
4427
4428 AC_CACHE_CHECK(for __attribute__((malloc)),
4429                ac_cv_attribute_malloc,
4430                [AC_TRY_COMPILE([],
4431                                [void* f(int) __attribute__((malloc));],
4432                                ac_cv_attribute_malloc=yes,
4433                                ac_cv_attribute_malloc=no)])
4434
4435 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
4436                ac_cv_attribute_warn_unused,
4437                [AC_TRY_COMPILE([],
4438                                [int f(void) __attribute__((warn_unused_result));],
4439                                ac_cv_attribute_warn_unused=yes,
4440                                ac_cv_attribute_warn_unused=no)])
4441
4442 AC_CACHE_CHECK(for __attribute__((noreturn)),
4443                ac_cv_attribute_noreturn,
4444                [AC_TRY_COMPILE([],
4445                                [void f(void) __attribute__((noreturn));],
4446                                ac_cv_attribute_noreturn=yes,
4447                                ac_cv_attribute_noreturn=no)])
4448  
4449 dnl End of C++ language/feature checks
4450 AC_LANG_C
4451
4452 dnl ========================================================
4453 dnl =  Internationalization checks
4454 dnl ========================================================
4455 dnl
4456 dnl Internationalization and Locale support is different
4457 dnl on various UNIX platforms.  Checks for specific i18n
4458 dnl features go here.
4459
4460 dnl check for LC_MESSAGES
4461 AC_CACHE_CHECK(for LC_MESSAGES,
4462                 ac_cv_i18n_lc_messages,
4463                 [AC_TRY_COMPILE([#include <locale.h>],
4464                                 [int category = LC_MESSAGES;],
4465                                 ac_cv_i18n_lc_messages=yes,
4466                                 ac_cv_i18n_lc_messages=no)])
4467 if test "$ac_cv_i18n_lc_messages" = yes; then
4468    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
4469 fi
4470
4471 AC_HAVE_FUNCS(localeconv)
4472
4473 fi # SKIP_COMPILER_CHECKS
4474
4475 TARGET_XPCOM_ABI=
4476 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
4477     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
4478 fi
4479
4480 dnl Mozilla specific options
4481 dnl ========================================================
4482 dnl The macros used for command line options
4483 dnl are defined in build/autoconf/altoptions.m4.
4484
4485 dnl If the compiler supports these attributes, define them as
4486 dnl convenience macros.
4487 if test "$ac_cv_attribute_always_inline" = yes ; then
4488   AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
4489 else
4490   AC_DEFINE(NS_ALWAYS_INLINE,)
4491 fi
4492
4493 if test "$ac_cv_attribute_malloc" = yes ; then
4494   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
4495 else
4496   AC_DEFINE(NS_ATTR_MALLOC,)
4497 fi
4498
4499 if test "$ac_cv_attribute_warn_unused" = yes ; then
4500   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
4501 else
4502   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
4503 fi
4504
4505 if test "$ac_cv_attribute_noreturn" = yes ; then
4506   AC_DEFINE(NS_NORETURN, [__attribute__((noreturn))])
4507 else
4508   AC_DEFINE(NS_NORETURN,)
4509 fi
4510
4511 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
4512 dnl features that Windows actually does support.
4513
4514 if test -n "$SKIP_COMPILER_CHECKS"; then
4515    dnl Windows has malloc.h
4516    AC_DEFINE(MALLOC_H, [<malloc.h>])
4517    AC_DEFINE(HAVE_FORCEINLINE)
4518    AC_DEFINE(HAVE_LOCALECONV)
4519 fi # SKIP_COMPILER_CHECKS
4520
4521 dnl ========================================================
4522 dnl =
4523 dnl = Check for external package dependencies
4524 dnl =
4525 dnl ========================================================
4526 MOZ_ARG_HEADER(External Packages)
4527
4528 dnl ========================================================
4529 dnl = Find the right NSPR to use.
4530 dnl ========================================================
4531 MOZ_ARG_WITH_BOOL(system-nspr,
4532 [  --with-system-nspr      Use an NSPR that is already built and installed.
4533                           Use the 'nspr-config' script in the current path,
4534                           or look for the script in the directories given with
4535                           --with-nspr-exec-prefix or --with-nspr-prefix.
4536                           (Those flags are only checked if you specify
4537                           --with-system-nspr.)],
4538     _USE_SYSTEM_NSPR=1 )
4539
4540 MOZ_ARG_WITH_STRING(nspr-cflags,
4541 [  --with-nspr-cflags=FLAGS
4542                           Pass FLAGS to CC when building code that uses NSPR.
4543                           Use this when there's no accurate nspr-config
4544                           script available.  This is the case when building
4545                           SpiderMonkey as part of the Mozilla tree: the
4546                           top-level configure script computes NSPR flags
4547                           that accomodate the quirks of that environment.],
4548     NSPR_CFLAGS=$withval)
4549 MOZ_ARG_WITH_STRING(nspr-libs,
4550 [  --with-nspr-libs=LIBS   Pass LIBS to LD when linking code that uses NSPR.
4551                           See --with-nspr-cflags for more details.],
4552     NSPR_LIBS=$withval)
4553 AC_SUBST(NSPR_CFLAGS)
4554 AC_SUBST(NSPR_LIBS)
4555
4556 dnl Pass either --with-system-nspr or (--with-nspr-cflags and
4557 dnl --with-nspr-libs), but not both.
4558 if test "$_USE_SYSTEM_NSPR" && (test "$NSPR_CFLAGS" -o "$NSPR_LIBS"); then
4559     AC_MSG_ERROR([--with-system-nspr and --with-nspr-libs/cflags are mutually exclusive.
4560 See 'configure --help'.])
4561 fi
4562
4563 dnl Top-level Mozilla switched to requiring NSPR 4.8.6 (bug 560582), but we don't need it in JS.
4564 if test -n "$_USE_SYSTEM_NSPR"; then
4565     MOZ_NATIVE_NSPR=
4566     AM_PATH_NSPR(4.7.0, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
4567 fi
4568
4569 if test -n "$MOZ_NATIVE_NSPR"; then
4570     _SAVE_CFLAGS=$CFLAGS
4571     CFLAGS="$CFLAGS $NSPR_CFLAGS"
4572     AC_TRY_COMPILE([#include "prlog.h"],
4573                 [#ifndef PR_STATIC_ASSERT
4574                  #error PR_STATIC_ASSERT not defined
4575                  #endif],
4576                 [MOZ_NATIVE_NSPR=1],
4577                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
4578     CFLAGS=$_SAVE_CFLAGS
4579 fi
4580
4581 dnl ========================================================
4582 dnl =
4583 dnl = Application
4584 dnl =
4585 dnl ========================================================
4586
4587 MOZ_ARG_HEADER(Application)
4588
4589 BUILD_STATIC_LIBS=
4590 ENABLE_TESTS=1
4591
4592 MOZ_THUMB2=
4593 USE_ARM_KUSER=
4594
4595 case "${target}" in
4596     arm-android-eabi)
4597         USE_ARM_KUSER=1
4598         MOZ_THUMB2=1
4599         ;;
4600 esac
4601
4602 dnl ========================================================
4603 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4604 dnl their usage and use them in spidermonkey.
4605 dnl ========================================================
4606 MOZ_ARG_WITH_BOOL(arm-kuser,
4607 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4608     USE_ARM_KUSER=1,)
4609 if test -n "$USE_ARM_KUSER"; then
4610    AC_DEFINE(USE_ARM_KUSER)
4611 fi
4612
4613 dnl ========================================================
4614 dnl =
4615 dnl = Components & Features
4616 dnl = 
4617 dnl ========================================================
4618 MOZ_ARG_HEADER(Components and Features)
4619
4620 dnl ========================================================
4621 dnl = Localization
4622 dnl ========================================================
4623 MOZ_ARG_ENABLE_STRING(ui-locale,
4624 [  --enable-ui-locale=ab-CD
4625                           Select the user interface locale (default: en-US)],
4626     MOZ_UI_LOCALE=$enableval )
4627 AC_SUBST(MOZ_UI_LOCALE)
4628
4629 dnl ========================================================
4630 dnl build the tests by default
4631 dnl ========================================================
4632 MOZ_ARG_DISABLE_BOOL(tests,
4633 [  --disable-tests         Do not build test libraries & programs],
4634     ENABLE_TESTS=,
4635     ENABLE_TESTS=1 )
4636
4637 dnl ========================================================
4638 dnl =
4639 dnl = Module specific options
4640 dnl =
4641 dnl ========================================================
4642 MOZ_ARG_HEADER(Individual module options)
4643
4644 dnl Setup default CPU arch for arm target
4645 case "$target_cpu" in
4646   arm*)
4647     MOZ_ARM_ARCH=armv7
4648   ;;
4649 esac
4650
4651 dnl ========================================================
4652 dnl =
4653 dnl = Debugging Options
4654 dnl = 
4655 dnl ========================================================
4656 MOZ_ARG_HEADER(Debugging and Optimizations)
4657
4658 dnl ========================================================
4659 dnl = Disable building with debug info.
4660 dnl = Debugging is OFF by default
4661 dnl ========================================================
4662 if test -z "$MOZ_DEBUG_FLAGS"; then
4663   MOZ_DEBUG_FLAGS="-g"
4664 fi
4665
4666 MOZ_ARG_ENABLE_STRING(debug,
4667 [  --enable-debug[=DBG]    Enable building with developer debug info
4668                            (using compiler flags DBG)],
4669 [ if test "$enableval" != "no"; then
4670     MOZ_DEBUG=1
4671     if test -n "$enableval" -a "$enableval" != "yes"; then
4672         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
4673         _MOZ_DEBUG_FLAGS_SET=1
4674     fi
4675   else
4676     MOZ_DEBUG=
4677   fi ],
4678   MOZ_DEBUG=)
4679
4680 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
4681 MOZ_ARG_WITH_STRING(debug-label,
4682 [  --with-debug-label=LABELS
4683                           Define DEBUG_<value> for each comma-separated
4684                           value given.],
4685 [ for option in `echo $withval | sed 's/,/ /g'`; do
4686     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
4687 done])
4688
4689 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
4690
4691 if test -n "$MOZ_DEBUG"; then
4692     AC_MSG_CHECKING([for valid debug flags])
4693     _SAVE_CFLAGS=$CFLAGS
4694     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
4695     AC_TRY_COMPILE([#include <stdio.h>], 
4696         [printf("Hello World\n");],
4697         _results=yes,
4698         _results=no)
4699     AC_MSG_RESULT([$_results])
4700     if test "$_results" = "no"; then
4701         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
4702     fi
4703     CFLAGS=$_SAVE_CFLAGS
4704 fi
4705
4706 dnl ========================================================
4707 dnl = Enable code optimization. ON by default.
4708 dnl ========================================================
4709 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
4710         MOZ_OPTIMIZE_FLAGS="-O"
4711 fi
4712
4713 MOZ_ARG_ENABLE_STRING(optimize,
4714 [  --disable-optimize      Disable compiler optimization
4715   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
4716 [ if test "$enableval" != "no"; then
4717     MOZ_OPTIMIZE=1
4718     if test -n "$enableval" -a "$enableval" != "yes"; then
4719         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
4720         MOZ_OPTIMIZE=2
4721     fi
4722 else
4723     MOZ_OPTIMIZE=
4724 fi ], MOZ_OPTIMIZE=1)
4725
4726 if test "$COMPILE_ENVIRONMENT"; then
4727 if test -n "$MOZ_OPTIMIZE"; then
4728     AC_MSG_CHECKING([for valid optimization flags])
4729     _SAVE_CFLAGS=$CFLAGS
4730     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
4731     AC_TRY_COMPILE([#include <stdio.h>], 
4732         [printf("Hello World\n");],
4733         _results=yes,
4734         _results=no)
4735     AC_MSG_RESULT([$_results])
4736     if test "$_results" = "no"; then
4737         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
4738     fi
4739     CFLAGS=$_SAVE_CFLAGS
4740 fi
4741 fi # COMPILE_ENVIRONMENT
4742
4743 AC_SUBST(MOZ_OPTIMIZE)
4744 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
4745 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
4746 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
4747
4748 dnl ========================================================
4749 dnl = (Deprecated) generation of debugger info for specific modules
4750 dnl ========================================================
4751 MOZ_ARG_ENABLE_STRING(debugger-info-modules,
4752 [  --enable-debugger-info-modules
4753                           Enable/disable debugger info for specific modules],
4754 [ if test "$enableval" != "no"; then
4755     AC_MSG_WARN([--enable-debugger-info-modules is deprecated, use --enable-debug-symbols instead])
4756     MOZ_DEBUG_SYMBOLS=1
4757   fi ])
4758
4759 dnl ========================================================
4760 dnl = Enable generation of debug symbols
4761 dnl ========================================================
4762 MOZ_ARG_ENABLE_STRING(debug-symbols,
4763 [  --enable-debug-symbols[=DBG]
4764                           Enable debugging symbols (using compiler flags DBG)],
4765 [ if test "$enableval" != "no"; then
4766       MOZ_DEBUG_SYMBOLS=1
4767       if test -n "$enableval" -a "$enableval" != "yes"; then
4768           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
4769               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
4770           else
4771               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
4772           fi
4773       fi
4774   fi ])
4775
4776 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
4777     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
4778     export MOZ_DEBUG_SYMBOLS
4779 fi
4780
4781 dnl ========================================================
4782 dnl = Disable any treating of compile warnings as errors
4783 dnl ========================================================
4784 MOZ_ARG_DISABLE_BOOL(warnings-as-errors,
4785 [  --disable-warnings-as-errors
4786                           Disable treating of warnings as errors],
4787     MOZ_DISABLE_WARNINGS_AS_ERRORS=1,
4788     MOZ_DISABLE_WARNINGS_AS_ERRORS= )
4789 if test "$MOZ_DISABLE_WARNINGS_AS_ERRORS"; then
4790    WARNINGS_AS_ERRORS=''
4791 fi
4792
4793 dnl = Enable trace malloc
4794 dnl ========================================================
4795 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
4796 MOZ_ARG_ENABLE_BOOL(trace-malloc,
4797 [  --enable-trace-malloc   Enable malloc tracing],
4798     NS_TRACE_MALLOC=1,
4799     NS_TRACE_MALLOC= )
4800 if test "$NS_TRACE_MALLOC"; then
4801   # Please, Mr. Linker Man, don't take away our symbol names
4802   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
4803   AC_DEFINE(NS_TRACE_MALLOC)
4804 fi
4805 AC_SUBST(NS_TRACE_MALLOC)
4806
4807 dnl ========================================================
4808 dnl = Enable jemalloc
4809 dnl ========================================================
4810 MOZ_ARG_ENABLE_BOOL(jemalloc,
4811 [  --enable-jemalloc       Replace memory allocator with jemalloc],
4812     MOZ_MEMORY=1,
4813     MOZ_MEMORY=)
4814
4815 if test "$NS_TRACE_MALLOC"; then
4816     MOZ_MEMORY=
4817 fi
4818
4819 if test "$MOZ_MEMORY"; then
4820
4821   dnl Don't try to run compiler tests on Windows  
4822   if test "$OS_ARCH" = "WINNT"; then
4823     if test -z "$HAVE_64BIT_OS"; then
4824       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
4825     else
4826       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
4827     fi
4828   else
4829     AC_CHECK_SIZEOF([int *], [4])
4830     case "${ac_cv_sizeof_int_p}" in
4831     4)
4832       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
4833       ;;
4834     8)
4835       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
4836       ;;
4837     *)
4838       AC_MSG_ERROR([Unexpected pointer size])
4839       ;;
4840     esac
4841   fi
4842
4843   AC_DEFINE(MOZ_MEMORY)
4844   if test "x$MOZ_DEBUG" = "x1"; then
4845     AC_DEFINE(MOZ_MEMORY_DEBUG)
4846   fi
4847   dnl The generic feature tests that determine how to compute ncpus are long and
4848   dnl complicated.  Therefore, simply define special cpp variables for the
4849   dnl platforms we have special knowledge of.
4850   case "${target}" in
4851   *-darwin*)
4852     AC_DEFINE(MOZ_MEMORY_DARWIN)
4853     ;;
4854   *-*freebsd*)
4855     AC_DEFINE(MOZ_MEMORY_BSD)
4856     ;;
4857   *-*linux*)
4858     AC_DEFINE(MOZ_MEMORY_LINUX)
4859     ;;
4860   *-netbsd*)
4861     AC_DEFINE(MOZ_MEMORY_BSD)
4862     ;;
4863   *-solaris*)
4864     AC_DEFINE(MOZ_MEMORY_SOLARIS)
4865     ;;
4866   *-msvc*|*-mks*|*-cygwin*|*-mingw*)
4867     AC_DEFINE(MOZ_MEMORY_WINDOWS)
4868     # the interesting bits will get passed down in MOZ_MEMORY_LDFLAGS
4869     ;;
4870   *-*wince)
4871     AC_DEFINE(MOZ_MEMORY_WINCE)
4872     AC_DEFINE(MOZ_MEMORY_WINDOWS)
4873     if test -z "$WINCE_WINDOWS_MOBILE"; then
4874       AC_DEFINE(MOZ_MEMORY_WINCE6)
4875     fi
4876     ;;
4877   *-*winmo)
4878     AC_DEFINE(MOZ_MEMORY_WINCE)
4879     AC_DEFINE(MOZ_MEMORY_WINDOWS)
4880     ;;
4881   *-android*)
4882     AC_DEFINE(MOZ_MEMORY_LINUX)
4883     AC_DEFINE(MOZ_MEMORY_ANDROID)
4884     ;;
4885   *)
4886     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
4887     ;;
4888   esac
4889
4890   if test "$OS_ARCH" != "Darwin"; then
4891     dnl NB: this must be kept in sync with jemalloc.h
4892     AC_DEFINE(HAVE_JEMALLOC_VALLOC)
4893     AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
4894     AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
4895   fi
4896 fi
4897 AC_SUBST(MOZ_MEMORY)
4898 AC_SUBST(MOZ_MEMORY_LDFLAGS)
4899
4900 dnl ========================================================
4901 dnl = Use malloc wrapper lib
4902 dnl ========================================================
4903 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
4904 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
4905     _WRAP_MALLOC=1,
4906     _WRAP_MALLOC= )
4907
4908 if test -n "$_WRAP_MALLOC"; then
4909     if test "$GNU_CC"; then
4910     WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup -Wl,--wrap -Wl,posix_memalign"
4911     MKSHLIB='$(CXX) $(DSO_LDOPTS) $(WRAP_MALLOC_CFLAGS) $(WRAP_MALLOC_LIB) -o $@'
4912     fi
4913 fi
4914
4915 dnl ========================================================
4916 dnl = Location of malloc wrapper lib
4917 dnl ========================================================
4918 MOZ_ARG_WITH_STRING(wrap-malloc,
4919 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
4920     WRAP_MALLOC_LIB=$withval)
4921
4922 dnl ========================================================
4923 dnl = Use JS Call tracing
4924 dnl ========================================================
4925 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
4926 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
4927     MOZ_TRACE_JSCALLS=1,
4928     MOZ_TRACE_JSCALLS= )
4929 if test -n "$MOZ_TRACE_JSCALLS"; then
4930     AC_DEFINE(MOZ_TRACE_JSCALLS)
4931 fi
4932
4933 dnl ========================================================
4934 dnl = Use TraceVis
4935 dnl ========================================================
4936 MOZ_ARG_ENABLE_BOOL(tracevis,
4937 [  --enable-tracevis       Enable TraceVis tracing tool (default=no)],
4938     MOZ_TRACEVIS=1,
4939     MOZ_TRACEVIS= )
4940 if test -n "$MOZ_TRACEVIS"; then
4941     AC_DEFINE(MOZ_TRACEVIS)
4942     if test -z "$ENABLE_TRACEJIT"; then
4943        AC_MSG_ERROR([--enable-tracevis is incompatible with --disable-tracejit])
4944     fi
4945 fi
4946
4947 dnl ========================================================
4948 dnl = Use GCTimer
4949 dnl ========================================================
4950 MOZ_ARG_ENABLE_BOOL(gctimer,
4951 [  --enable-gctimer        Enable GC timer (default=no)],
4952     MOZ_GCTIMER=1,
4953     MOZ_GCTIMER= )
4954 if test -n "$MOZ_GCTIMER"; then
4955     AC_DEFINE(MOZ_GCTIMER)
4956 fi
4957
4958 dnl ========================================================
4959 dnl = Use Valgrind
4960 dnl ========================================================
4961 MOZ_ARG_ENABLE_BOOL(valgrind,
4962 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
4963     MOZ_VALGRIND=1,
4964     MOZ_VALGRIND= )
4965 if test -n "$MOZ_VALGRIND"; then
4966     AC_CHECK_HEADER([valgrind/valgrind.h], [],
4967         AC_MSG_ERROR(
4968             [--enable-valgrind specified but Valgrind is not installed]))
4969     AC_DEFINE(MOZ_VALGRIND)
4970 fi
4971
4972 dnl ========================================================
4973 dnl jprof
4974 dnl ========================================================
4975 MOZ_ARG_ENABLE_BOOL(jprof,
4976 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
4977     MOZ_JPROF=1,
4978     MOZ_JPROF= )
4979 if test -n "$MOZ_JPROF"; then
4980     MOZ_PROFILING=1
4981     AC_DEFINE(MOZ_JPROF)
4982 fi
4983
4984 dnl ========================================================
4985 dnl shark
4986 dnl ========================================================
4987 MOZ_ARG_ENABLE_BOOL(shark,
4988 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
4989     MOZ_SHARK=1,
4990     MOZ_SHARK= )
4991 if test -n "$MOZ_SHARK"; then
4992     MOZ_PROFILING=1
4993     AC_DEFINE(MOZ_SHARK)
4994 fi
4995
4996 dnl ========================================================
4997 dnl callgrind
4998 dnl ========================================================
4999 MOZ_ARG_ENABLE_BOOL(callgrind,
5000 [  --enable-callgrind      Enable callgrind profiling],
5001     MOZ_CALLGRIND=1,
5002     MOZ_CALLGRIND= )
5003 if test -n "$MOZ_CALLGRIND"; then
5004     AC_DEFINE(MOZ_CALLGRIND)
5005 fi
5006
5007 dnl ========================================================
5008 dnl vtune
5009 dnl ========================================================
5010 MOZ_ARG_ENABLE_BOOL(vtune,
5011 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
5012     MOZ_VTUNE=1,
5013     MOZ_VTUNE= )
5014 if test -n "$MOZ_VTUNE"; then
5015     MOZ_PROFILING=1
5016     AC_DEFINE(MOZ_VTUNE)
5017 fi
5018
5019 dnl ========================================================
5020 dnl Profiling
5021 dnl ========================================================
5022 if test -n "$MOZ_PROFILING"; then
5023     AC_DEFINE(MOZ_PROFILING)
5024 fi
5025
5026 dnl ========================================================
5027 dnl Zealous JavaScript GC
5028 dnl ========================================================
5029 MOZ_ARG_ENABLE_BOOL(gczeal,
5030 [  --enable-gczeal         Enable zealous GCing],
5031     JS_GC_ZEAL=1,
5032     JS_GC_ZEAL= )
5033 if test -n "$JS_GC_ZEAL"; then
5034     AC_DEFINE(JS_GC_ZEAL)
5035 fi
5036
5037 dnl ======================================================
5038 dnl = Enable compiling with ccache
5039 dnl ======================================================
5040 MOZ_ARG_WITH_STRING(ccache,
5041 [  --with-ccache[=path/to/ccache]
5042                           Enable compiling with ccache],
5043     CCACHE=$withval, CCACHE="no")
5044
5045 if test "$CCACHE" != "no"; then
5046     if test -z "$CCACHE" -o "$CCACHE" = "yes"; then
5047         CCACHE=
5048     else
5049         if test ! -e "$CCACHE"; then
5050             AC_MSG_ERROR([$CCACHE not found])
5051         fi
5052     fi
5053     MOZ_PATH_PROGS(CCACHE, $CCACHE ccache)
5054     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
5055         AC_MSG_ERROR([ccache not found])
5056     elif test -x "$CCACHE"; then
5057         CC="$CCACHE $CC"
5058         CXX="$CCACHE $CXX"
5059     else
5060         AC_MSG_ERROR([$CCACHE is not executable])
5061     fi
5062 fi
5063
5064 dnl ========================================================
5065 dnl = Enable static checking using gcc-dehydra
5066 dnl ========================================================
5067
5068 MOZ_ARG_WITH_STRING(static-checking,
5069 [  --with-static-checking=path/to/gcc_dehydra.so
5070                           Enable static checking of code using GCC-dehydra],
5071     DEHYDRA_PATH=$withval,
5072     DEHYDRA_PATH= )
5073
5074 if test -n "$DEHYDRA_PATH"; then
5075     if test ! -f "$DEHYDRA_PATH"; then
5076         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
5077     fi
5078     AC_DEFINE(NS_STATIC_CHECKING)
5079 fi
5080 AC_SUBST(DEHYDRA_PATH)
5081
5082 dnl ========================================================
5083 dnl = Enable stripping of libs & executables
5084 dnl ========================================================
5085 MOZ_ARG_ENABLE_BOOL(strip,
5086 [  --enable-strip          Enable stripping of libs & executables ],
5087     ENABLE_STRIP=1,
5088     ENABLE_STRIP= )
5089
5090 dnl ========================================================
5091 dnl = Enable stripping of libs & executables when packaging
5092 dnl ========================================================
5093 MOZ_ARG_ENABLE_BOOL(install-strip,
5094 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
5095     PKG_SKIP_STRIP= ,
5096     PKG_SKIP_STRIP=1)
5097
5098 dnl ========================================================
5099 dnl = 
5100 dnl = Profiling and Instrumenting
5101 dnl = 
5102 dnl ========================================================
5103 MOZ_ARG_HEADER(Profiling and Instrumenting)
5104
5105 dnl ========================================================
5106 dnl = Enable timeline service, which provides lightweight
5107 dnl = instrumentation of mozilla for performance measurement.
5108 dnl = Timeline is off by default.
5109 dnl ========================================================
5110 MOZ_ARG_ENABLE_BOOL(timeline,
5111 [  --enable-timeline       Enable timeline services ],
5112     MOZ_TIMELINE=1,
5113     MOZ_TIMELINE= )
5114 if test -n "$MOZ_TIMELINE"; then
5115     AC_DEFINE(MOZ_TIMELINE)
5116 fi
5117
5118 dnl ========================================================
5119 dnl = Support for Quantify (Windows)
5120 dnl ========================================================
5121 MOZ_ARG_ENABLE_BOOL(quantify,
5122 [  --enable-quantify       Enable Quantify support (Windows only) ],
5123     MOZ_QUANTIFY=1,
5124     MOZ_QUANTIFY= )
5125
5126 dnl ========================================================
5127 dnl = Support for demangling undefined symbols
5128 dnl ========================================================
5129 if test -z "$SKIP_LIBRARY_CHECKS"; then
5130     AC_LANG_SAVE
5131     AC_LANG_CPLUSPLUS
5132     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
5133     AC_LANG_RESTORE
5134 fi
5135
5136 # Demangle only for debug or trace-malloc builds
5137 MOZ_DEMANGLE_SYMBOLS=
5138 if test "$HAVE_DEMANGLE" -a "$HAVE_GCC3_ABI" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
5139     MOZ_DEMANGLE_SYMBOLS=1
5140     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
5141 fi
5142 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
5143
5144 dnl ========================================================
5145 dnl = Support for gcc stack unwinding (from gcc 3.3)
5146 dnl ========================================================
5147 if test "$HAVE_GCC3_ABI" -a -z "$SKIP_LIBRARY_CHECKS"; then
5148     AC_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
5149 fi
5150
5151 dnl ========================================================
5152 dnl =
5153 dnl = Misc. Options
5154 dnl = 
5155 dnl ========================================================
5156 MOZ_ARG_HEADER(Misc. Options)
5157
5158 dnl ========================================================
5159 dnl update xterm title
5160 dnl ========================================================
5161 MOZ_ARG_ENABLE_BOOL(xterm-updates,
5162 [  --enable-xterm-updates  Update XTERM titles with current command.],
5163     MOZ_UPDATE_XTERM=1,
5164     MOZ_UPDATE_XTERM= )
5165
5166 if test -z "$SKIP_COMPILER_CHECKS"; then
5167 dnl ========================================================
5168 dnl =
5169 dnl = Compiler Options
5170 dnl = 
5171 dnl ========================================================
5172 MOZ_ARG_HEADER(Compiler Options)
5173
5174 dnl ========================================================
5175 dnl Check for gcc -pipe support
5176 dnl ========================================================
5177 AC_MSG_CHECKING([for gcc -pipe support])
5178 if test -n "$GNU_CC" -a -n "$GNU_CXX" -a -n "$GNU_AS"; then
5179     echo '#include <stdio.h>' > dummy-hello.c
5180     echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c
5181     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
5182     cat dummy-hello.s 2> /dev/null | ${AS_BIN} -o dummy-hello.S - 2>&5
5183     if test $? = 0; then
5184         _res_as_stdin="yes"
5185     else
5186         _res_as_stdin="no"
5187     fi
5188     if test "$_res_as_stdin" = "yes"; then
5189         _SAVE_CFLAGS=$CFLAGS
5190         CFLAGS="$CFLAGS -pipe"
5191         AC_TRY_COMPILE( [ #include <stdio.h> ],
5192             [printf("Hello World\n");],
5193             [_res_gcc_pipe="yes"],
5194             [_res_gcc_pipe="no"] )
5195         CFLAGS=$_SAVE_CFLAGS
5196     fi
5197     if test "$_res_as_stdin" = "yes" -a "$_res_gcc_pipe" = "yes"; then
5198         _res="yes";
5199         CFLAGS="$CFLAGS -pipe"
5200         CXXFLAGS="$CXXFLAGS -pipe"
5201     else
5202         _res="no"
5203     fi
5204     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
5205     AC_MSG_RESULT([$_res])
5206 else
5207     AC_MSG_RESULT([no])
5208 fi
5209
5210 dnl ========================================================
5211 dnl Profile guided optimization
5212 dnl ========================================================
5213 dnl Test for profiling options
5214 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
5215
5216 dnl Provide a switch to disable PGO even when called via profiledbuild.
5217 MOZ_ARG_DISABLE_BOOL(profile-guided-optimization,
5218 [  --disable-profile-guided-optimization
5219                           Don't build with PGO even if called via make profiledbuild],
5220 MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=1,
5221 MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=)
5222
5223 AC_SUBST(MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE)
5224
5225 _SAVE_CFLAGS="$CFLAGS"
5226 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
5227
5228 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
5229 AC_TRY_COMPILE([], [return 0;],
5230                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
5231                  result="yes" ], result="no")
5232 AC_MSG_RESULT([$result])
5233
5234 if test $result = "yes"; then
5235   PROFILE_GEN_LDFLAGS="-fprofile-generate"
5236   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch -freorder-blocks-and-partition"
5237   PROFILE_USE_LDFLAGS="-fprofile-use"
5238 fi
5239
5240 CFLAGS="$_SAVE_CFLAGS"
5241
5242 if test -n "$INTEL_CC"; then
5243   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
5244   PROFILE_GEN_LDFLAGS=
5245   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
5246   PROFILE_USE_LDFLAGS=
5247 fi
5248
5249 dnl Sun Studio on Solaris
5250 if test "$SOLARIS_SUNPRO_CC"; then
5251   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
5252   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
5253   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
5254   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
5255 fi
5256
5257 AC_SUBST(PROFILE_GEN_CFLAGS)
5258 AC_SUBST(PROFILE_GEN_LDFLAGS)
5259 AC_SUBST(PROFILE_USE_CFLAGS)
5260 AC_SUBST(PROFILE_USE_LDFLAGS)
5261
5262 AC_LANG_CPLUSPLUS
5263
5264 dnl ========================================================
5265 dnl Test for -pedantic bustage
5266 dnl ========================================================
5267 MOZ_ARG_DISABLE_BOOL(pedantic,
5268 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],
5269 _PEDANTIC= )
5270 if test "$_PEDANTIC"; then
5271     _SAVE_CXXFLAGS=$CXXFLAGS
5272     CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
5273     AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
5274     AC_TRY_COMPILE([$configure_static_assert_macros],
5275                    [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
5276                    result="no", result="yes" )
5277     AC_MSG_RESULT([$result])
5278     CXXFLAGS="$_SAVE_CXXFLAGS"
5279
5280     case "$result" in
5281     no)
5282         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
5283         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
5284         ;;
5285     yes)
5286         AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic.  Reconfigure using --disable-pedantic. ])
5287         ;;
5288     esac
5289 fi
5290
5291 dnl ========================================================
5292 dnl Test for correct temporary object destruction order
5293 dnl ========================================================
5294 dnl We want to make sure the compiler follows the C++ spec here as 
5295 dnl xpcom and the string classes depend on it (bug 235381).
5296 AC_MSG_CHECKING([for correct temporary object destruction order])
5297 AC_TRY_RUN([ class A {
5298              public:  A(int& x) : mValue(x) {}
5299                       ~A() { mValue--; }
5300                       operator char**() { return 0; }
5301              private:  int& mValue;
5302              };
5303              void func(char **arg) {}
5304              int m=2;
5305              void test() {
5306                   func(A(m));
5307                   if (m==1) m = 0;
5308              }
5309              int main() {
5310                  test();
5311                  return(m);
5312              }
5313              ],
5314      result="yes", result="no", result="maybe")
5315 AC_MSG_RESULT([$result])
5316
5317 if test "$result" = "no"; then
5318     AC_MSG_ERROR([Your compiler does not follow the C++ specification for temporary object destruction order.])
5319 fi
5320
5321 dnl ========================================================
5322 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
5323 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
5324 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
5325 dnl ========================================================
5326 _SAVE_CXXFLAGS=$CXXFLAGS
5327 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
5328 AC_CACHE_CHECK(for correct overload resolution with const and templates,
5329     ac_nscap_nonconst_opeq_bug,
5330     [AC_TRY_COMPILE([
5331                       template <class T>
5332                       class Pointer
5333                         {
5334                         public:
5335                           T* myPtr;
5336                         };
5337                       
5338                       template <class T, class U>
5339                       int operator==(const Pointer<T>& rhs, U* lhs)
5340                         {
5341                           return rhs.myPtr == lhs;
5342                         }
5343                       
5344                       template <class T, class U>
5345                       int operator==(const Pointer<T>& rhs, const U* lhs)
5346                         {
5347                           return rhs.myPtr == lhs;
5348                         }
5349                     ],
5350                     [
5351                       Pointer<int> foo;
5352                       const int* bar;
5353                       return foo == bar;
5354                     ],
5355                     ac_nscap_nonconst_opeq_bug="no",
5356                     ac_nscap_nonconst_opeq_bug="yes")])
5357 CXXFLAGS="$_SAVE_CXXFLAGS"
5358
5359 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
5360     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
5361 fi
5362
5363 dnl ========================================================
5364 dnl Check for tm_zone, tm_gmtoff in struct tm
5365 dnl ========================================================
5366 AC_CACHE_CHECK(for tm_zone tm_gmtoff in struct tm,
5367     ac_cv_struct_tm_zone_tm_gmtoff,
5368     [AC_TRY_COMPILE([#include <time.h>],
5369                     [struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;],
5370                     [ac_cv_struct_tm_zone_tm_gmtoff="yes"],
5371                     [ac_cv_struct_tm_zone_tm_gmtoff="no"])])
5372 if test "$ac_cv_struct_tm_zone_tm_gmtoff" = "yes" ; then
5373     AC_DEFINE(HAVE_TM_ZONE_TM_GMTOFF)
5374 fi
5375
5376 fi # SKIP_COMPILER_CHECKS
5377
5378 dnl ========================================================
5379 dnl C++ rtti
5380 dnl Should be smarter and check that the compiler does indeed have rtti
5381 dnl ========================================================
5382 MOZ_ARG_ENABLE_BOOL(cpp-rtti,
5383 [  --enable-cpp-rtti       Enable C++ RTTI ],
5384 [ _MOZ_USE_RTTI=1 ],
5385 [ _MOZ_USE_RTTI= ])
5386
5387 if test "$_MOZ_USE_RTTI"; then
5388    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_ON
5389 else
5390    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_OFF
5391 fi
5392
5393 AC_SUBST(_MOZ_RTTI_FLAGS_ON)
5394
5395 dnl ========================================================
5396 dnl C++ exceptions (g++/VC/irix6/Sun only - for now)
5397 dnl Should be smarter and check that the compiler does indeed have exceptions
5398 dnl ========================================================
5399 MOZ_ARG_ENABLE_BOOL(cpp-exceptions,
5400 [  --enable-cpp-exceptions Enable C++ exceptions ],
5401 [ _MOZ_CPP_EXCEPTIONS=1 ],
5402 [ _MOZ_CPP_EXCEPTIONS= ])
5403
5404 if test "$_MOZ_CPP_EXCEPTIONS"; then
5405     _MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_ON
5406     AC_DEFINE(MOZ_CPP_EXCEPTIONS)
5407 else
5408     _MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_OFF
5409 fi
5410
5411 AC_SUBST(_MOZ_EXCEPTIONS_FLAGS_ON)
5412
5413 # Irix & OSF native compilers do not like exception declarations 
5414 # when exceptions are disabled
5415 if test -n "$MIPSPRO_CXX" -o -n "$COMPAQ_CXX" -o -n "$VACPP"; then
5416     AC_DEFINE(CPP_THROW_NEW, [])
5417 else
5418     AC_DEFINE(CPP_THROW_NEW, [throw()])
5419 fi
5420 AC_LANG_C
5421
5422 dnl ========================================================
5423 dnl =
5424 dnl = Build depencency options
5425 dnl =
5426 dnl ========================================================
5427 MOZ_ARG_HEADER(Build dependencies)
5428
5429 dnl ========================================================
5430 dnl = Do not auto generate dependency info
5431 dnl ========================================================
5432 MOZ_AUTO_DEPS=1
5433 MOZ_ARG_DISABLE_BOOL(auto-deps,
5434 [  --disable-auto-deps     Do not automatically generate dependency info],
5435     MOZ_AUTO_DEPS=,
5436     MOZ_AUTO_DEPS=1)
5437
5438 if test -n "$MOZ_AUTO_DEPS"; then
5439 dnl ========================================================
5440 dnl = Use mkdepend instead of $CC -MD for dependency generation
5441 dnl ========================================================
5442 _cpp_md_flag=
5443 MOZ_ARG_DISABLE_BOOL(md,
5444 [  --disable-md            Do not use compiler-based dependencies ],
5445   [_cpp_md_flag=],
5446   [_cpp_md_flag=1],
5447   [dnl Default is to turn on -MD if using GNU-compatible compilers
5448    if test "$GNU_CC" -a "$GNU_CXX" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "WINCE"; then
5449      _cpp_md_flag=1
5450    fi
5451   dnl Default is to use -xM if using Sun Studio on Solaris
5452    if test "$SOLARIS_SUNPRO_CC"; then
5453      _cpp_md_flag=1
5454    fi])
5455 if test "$_cpp_md_flag"; then
5456   COMPILER_DEPEND=1
5457   if test "$OS_ARCH" = "OpenVMS"; then
5458     _DEPEND_CFLAGS='$(subst =, ,$(filter-out %/.pp,-MM=-MD=-MF=$(MDDEPDIR)/$(basename $(@F)).pp))'
5459   else
5460     _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(basename $(@F)).pp)'
5461   fi
5462   dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
5463   if test "$SOLARIS_SUNPRO_CC"; then
5464     _DEPEND_CFLAGS=
5465   fi
5466 else
5467   COMPILER_DEPEND=
5468   dnl Don't override this for MSVC
5469   if test -z "$_WIN32_MSVC"; then
5470     _USE_CPP_INCLUDE_FLAG=
5471     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
5472     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
5473   else
5474     echo '#include <stdio.h>' > dummy-hello.c
5475     changequote(,)
5476     CL_INCLUDES_PREFIX=`"${CC}" -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
5477     changequote([,])
5478     if test -z "$CL_INCLUDES_PREFIX"; then
5479         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
5480     fi
5481     AC_SUBST(CL_INCLUDES_PREFIX)
5482     rm -f dummy-hello.c
5483     _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
5484     dnl cl.py provides dependency generation for MSVC
5485     CC_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
5486     CXX_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
5487     COMPILER_DEPEND=1
5488   fi
5489 fi
5490 fi # MOZ_AUTO_DEPS
5491 MDDEPDIR='.deps'
5492 AC_SUBST(MOZ_AUTO_DEPS)
5493 AC_SUBST(COMPILER_DEPEND)
5494 AC_SUBST(MDDEPDIR)
5495 AC_SUBST(CC_WRAPPER)
5496 AC_SUBST(CXX_WRAPPER)
5497
5498
5499 dnl ========================================================
5500 dnl =
5501 dnl = Static Build Options
5502 dnl =
5503 dnl ========================================================
5504 MOZ_ARG_HEADER(Static build options)
5505
5506 MOZ_ARG_ENABLE_BOOL(static,
5507 [  --enable-static         Enable building of internal static libs],
5508     BUILD_STATIC_LIBS=1,
5509     BUILD_STATIC_LIBS=)
5510
5511 dnl ========================================================
5512 dnl = Link js shell to system readline
5513 dnl ========================================================
5514 MOZ_ARG_ENABLE_BOOL(readline,
5515 [  --enable-readline       Link js shell to system readline library],
5516     JS_WANT_READLINE=1,
5517     JS_WANT_READLINE= )
5518
5519 JS_NATIVE_EDITLINE=
5520 EDITLINE_LIBS=
5521 JS_DISABLE_SHELL=
5522
5523 case "$target" in
5524 *-wince*|*-winmo*|*-mingw*|*-cygwin*|*-msvc*|*-mks*)
5525     NO_EDITLINE=1
5526     ;;
5527 *-symbian*)
5528     NO_EDITLINE=1
5529     JS_DISABLE_SHELL=1
5530     ;;
5531 *)
5532     ;;
5533 esac
5534
5535 if test -z "$SKIP_LIBRARY_CHECKS" -a -z "$NO_EDITLINE"; then
5536   if test -n "$JS_WANT_READLINE"; then
5537     AC_CHECK_LIB(readline, readline,
5538                  EDITLINE_LIBS="-lreadline",
5539                  AC_MSG_ERROR([No system readline library found.]))
5540   else
5541     dnl By default, we use editline
5542     JS_NATIVE_EDITLINE=1
5543     EDITLINE_LIBS='$(DEPTH)/editline/$(LIB_PREFIX)editline.$(LIB_SUFFIX)'
5544   fi
5545
5546   dnl Either way, we want to build with line editing support.
5547   AC_DEFINE(EDITLINE)
5548 fi
5549 AC_SUBST(JS_NATIVE_EDITLINE)
5550 AC_SUBST(JS_DISABLE_SHELL)
5551 AC_SUBST(EDITLINE_LIBS)
5552
5553 dnl ========================================================
5554 dnl =
5555 dnl = Standalone module options
5556 dnl = 
5557 dnl ========================================================
5558 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
5559
5560 dnl ========================================================
5561 dnl = Build jsctypes if it's enabled
5562 dnl ========================================================
5563 MOZ_ARG_ENABLE_BOOL(ctypes,
5564 [  --enable-ctypes         Enable js-ctypes (default=no)],
5565     JS_HAS_CTYPES=1,
5566     JS_HAS_CTYPES= )
5567 AC_SUBST(JS_HAS_CTYPES)
5568 if test "$JS_HAS_CTYPES"; then
5569   dnl Error out if we're on MSVC and MASM is unavailable.
5570   if test -n "$_MSC_VER" -a \( "$AS" != "ml.exe" -a "$AS" != "ml64.exe" \); then
5571     AC_MSG_ERROR([\"$AS\" is not a suitable assembler to build js-ctypes. If you are building with MS Visual Studio 8 Express, you may download the MASM 8.0 package, upgrade to Visual Studio 9 Express, or install the Vista SDK. Or do not use --enable-ctypes.])
5572   fi
5573   AC_DEFINE(JS_HAS_CTYPES)
5574 fi
5575
5576 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
5577     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
5578 fi
5579
5580 MOZ_ARG_WITH_STRING(sync-build-files,
5581 [  --with-sync-build-files=DIR
5582                           Check that files in 'config' and 'build' match
5583                           their originals in 'DIR/config' and 'DIR/build'.
5584                           This helps keep the SpiderMonkey build machinery
5585                           in sync with Mozilla's, on which it is based.],
5586 [MOZ_SYNC_BUILD_FILES=$withval ] )
5587 AC_SUBST(MOZ_SYNC_BUILD_FILES)
5588
5589 dnl ========================================================
5590 dnl =
5591 dnl = Maintainer debug option (no --enable equivalent)
5592 dnl =
5593 dnl ========================================================
5594
5595 AC_SUBST(AR)
5596 AC_SUBST(AR_FLAGS)
5597 AC_SUBST(AR_LIST)
5598 AC_SUBST(AR_EXTRACT)
5599 AC_SUBST(AR_DELETE)
5600 AC_SUBST(AS)
5601 AC_SUBST(ASFLAGS)
5602 AC_SUBST(AS_DASH_C_FLAG)
5603 AC_SUBST(LD)
5604 AC_SUBST(RC)
5605 AC_SUBST(RCFLAGS)
5606 AC_SUBST(WINDRES)
5607 AC_SUBST(IMPLIB)
5608 AC_SUBST(FILTER)
5609 AC_SUBST(BIN_FLAGS)
5610 AC_SUBST(NS_USE_NATIVE)
5611 AC_SUBST(MOZ_JS_LIBS)
5612 AC_SUBST(MOZ_PSM)
5613 AC_SUBST(MOZ_DEBUG)
5614 AC_SUBST(MOZ_DEBUG_SYMBOLS)
5615 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
5616 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
5617 AC_SUBST(MOZ_DEBUG_FLAGS)
5618 AC_SUBST(MOZ_DEBUG_LDFLAGS)
5619 AC_SUBST(WARNINGS_AS_ERRORS)
5620 AC_SUBST(MOZ_LEAKY)
5621 AC_SUBST(MOZ_JPROF)
5622 AC_SUBST(MOZ_SHARK)
5623 AC_SUBST(MOZ_CALLGRIND)
5624 AC_SUBST(MOZ_VTUNE)
5625 AC_SUBST(MOZ_PROFILING)
5626 AC_SUBST(MOZ_JSLOADER)
5627 AC_SUBST(MOZ_QUANTIFY)
5628 AC_SUBST(LIBICONV)
5629
5630 AC_SUBST(BUILD_STATIC_LIBS)
5631 AC_SUBST(ENABLE_TESTS)
5632
5633 AC_SUBST(ENABLE_STRIP)
5634 AC_SUBST(PKG_SKIP_STRIP)
5635 AC_SUBST(INCREMENTAL_LINKER)
5636 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
5637 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
5638
5639 AC_SUBST(MOZ_FIX_LINK_PATHS)
5640
5641 AC_SUBST(USE_DEPENDENT_LIBS)
5642
5643 AC_SUBST(MOZ_BUILD_ROOT)
5644 AC_SUBST(MOZ_OS2_TOOLS)
5645
5646 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
5647 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
5648 AC_SUBST(MOZ_TIMELINE)
5649
5650 AC_SUBST(MOZ_APP_NAME)
5651 AC_SUBST(MOZ_APP_DISPLAYNAME)
5652 AC_SUBST(MOZ_APP_UA_NAME)
5653 AC_SUBST(MOZ_APP_VERSION)
5654 AC_SUBST(MOZ_UA_FIREFOX_VERSION)
5655 AC_SUBST(FIREFOX_VERSION)
5656
5657 AC_SUBST(MOZ_PKG_SPECIAL)
5658
5659 AC_SUBST(MOZILLA_OFFICIAL)
5660
5661 dnl win32 options
5662 AC_SUBST(MOZ_MAPINFO)
5663 AC_SUBST(MOZ_BROWSE_INFO)
5664 AC_SUBST(MOZ_TOOLS_DIR)
5665 AC_SUBST(CYGWIN_WRAPPER)
5666 AC_SUBST(AS_PERL)
5667 AC_SUBST(WIN32_REDIST_DIR)
5668 AC_SUBST(PYTHON)
5669
5670 AC_SUBST(WINCE)
5671 AC_SUBST(WINCE_SDK_DIR)
5672 AC_SUBST(WINCE_WINDOWS_MOBILE)
5673
5674 dnl Echo the CFLAGS to remove extra whitespace.
5675 CFLAGS=`echo \
5676         $_WARNINGS_CFLAGS \
5677         $CFLAGS`
5678
5679 CXXFLAGS=`echo \
5680         $_MOZ_RTTI_FLAGS \
5681         $_MOZ_EXCEPTIONS_FLAGS \
5682         $_WARNINGS_CXXFLAGS \
5683         $CXXFLAGS`
5684
5685 COMPILE_CFLAGS=`echo \
5686     $_DEFINES_CFLAGS \
5687         $_DEPEND_CFLAGS \
5688     $COMPILE_CFLAGS`
5689
5690 COMPILE_CXXFLAGS=`echo \
5691     $_DEFINES_CXXFLAGS \
5692         $_DEPEND_CFLAGS \
5693     $COMPILE_CXXFLAGS`
5694
5695 AC_SUBST(SYSTEM_MAKEDEPEND)
5696
5697 AC_SUBST(NSPR_CFLAGS)
5698 AC_SUBST(NSPR_LIBS)
5699 AC_SUBST(MOZ_NATIVE_NSPR)
5700
5701 AC_SUBST(CFLAGS)
5702 AC_SUBST(CXXFLAGS)
5703 AC_SUBST(CPPFLAGS)
5704 AC_SUBST(COMPILE_CFLAGS)
5705 AC_SUBST(COMPILE_CXXFLAGS)
5706 AC_SUBST(LDFLAGS)
5707 AC_SUBST(LIBS)
5708 AC_SUBST(CROSS_COMPILE)
5709
5710 AC_SUBST(HOST_CC)
5711 AC_SUBST(HOST_CXX)
5712 AC_SUBST(HOST_CFLAGS)
5713 AC_SUBST(HOST_CXXFLAGS)
5714 AC_SUBST(HOST_LDFLAGS)
5715 AC_SUBST(HOST_OPTIMIZE_FLAGS)
5716 AC_SUBST(HOST_AR)
5717 AC_SUBST(HOST_AR_FLAGS)
5718 AC_SUBST(HOST_LD)
5719 AC_SUBST(HOST_RANLIB)
5720 AC_SUBST(HOST_NSPR_MDCPUCFG)
5721 AC_SUBST(HOST_BIN_SUFFIX)
5722 AC_SUBST(HOST_OS_ARCH)
5723
5724 AC_SUBST(TARGET_CPU)
5725 AC_SUBST(TARGET_VENDOR)
5726 AC_SUBST(TARGET_OS)
5727 AC_SUBST(TARGET_NSPR_MDCPUCFG)
5728 AC_SUBST(TARGET_MD_ARCH)
5729 AC_SUBST(TARGET_XPCOM_ABI)
5730 AC_SUBST(OS_TARGET)
5731 AC_SUBST(OS_ARCH)
5732 AC_SUBST(OS_RELEASE)
5733 AC_SUBST(OS_TEST)
5734 AC_SUBST(CPU_ARCH)
5735 AC_SUBST(INTEL_ARCHITECTURE)
5736
5737 AC_SUBST(WRAP_MALLOC_CFLAGS)
5738 AC_SUBST(WRAP_MALLOC_LIB)
5739 AC_SUBST(MKSHLIB)
5740 AC_SUBST(MKCSHLIB)
5741 AC_SUBST(MKSHLIB_FORCE_ALL)
5742 AC_SUBST(MKSHLIB_UNFORCE_ALL)
5743 AC_SUBST(DSO_CFLAGS)
5744 AC_SUBST(DSO_PIC_CFLAGS)
5745 AC_SUBST(DSO_LDOPTS)
5746 AC_SUBST(LIB_PREFIX)
5747 AC_SUBST(DLL_PREFIX)
5748 AC_SUBST(DLL_SUFFIX)
5749 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
5750 AC_SUBST(LIB_SUFFIX)
5751 AC_SUBST(OBJ_SUFFIX)
5752 AC_SUBST(BIN_SUFFIX)
5753 AC_SUBST(ASM_SUFFIX)
5754 AC_SUBST(IMPORT_LIB_SUFFIX)
5755 AC_SUBST(USE_N32)
5756 AC_SUBST(CC_VERSION)
5757 AC_SUBST(CXX_VERSION)
5758 AC_SUBST(MSMANIFEST_TOOL)
5759
5760 if test "$USING_HCC"; then
5761    CC='${topsrcdir}/build/hcc'
5762    CC="$CC '$_OLDCC'"
5763    CXX='${topsrcdir}/build/hcpp'
5764    CXX="$CXX '$_OLDCXX'"
5765    AC_SUBST(CC)
5766    AC_SUBST(CXX)
5767 fi
5768
5769 AC_MSG_CHECKING([for posix_fallocate])
5770 AC_TRY_LINK([#define _XOPEN_SOURCE 600
5771   #include <fcntl.h>],
5772                  [posix_fallocate(0, 0, 0);],
5773                  [ac_cv___posix_fallocate=true],
5774                  [ac_cv___posix_fallocate=false])
5775
5776 if test "$ac_cv___posix_fallocate" = true ; then
5777   AC_DEFINE(HAVE_POSIX_FALLOCATE)
5778   AC_MSG_RESULT(yes)
5779 else
5780   AC_MSG_RESULT(no)
5781 fi
5782
5783 dnl Check for missing components
5784 if test "$COMPILE_ENVIRONMENT"; then
5785 if test "$MOZ_X11"; then
5786     dnl ====================================================
5787     dnl = Check if X headers exist
5788     dnl ====================================================
5789     _SAVE_CFLAGS=$CFLAGS
5790     CFLAGS="$CFLAGS $XCFLAGS"
5791     AC_TRY_COMPILE([
5792         #include <stdio.h>
5793         #include <stdlib.h>
5794         #include <X11/Xlib.h>
5795         #include <X11/Intrinsic.h>
5796     ],
5797     [
5798         Display *dpy = 0;
5799         if ((dpy = XOpenDisplay(NULL)) == NULL) {
5800             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
5801             exit(1);
5802         }
5803     ], [], 
5804     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
5805     CFLAGS="$_SAVE_CFLAGS"
5806
5807     if test ! -z "$MISSING_X"; then
5808         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
5809     fi
5810
5811 fi # MOZ_X11
5812 fi # COMPILE_ENVIRONMENT
5813
5814 dnl Set various defines and substitutions
5815 dnl ========================================================
5816
5817 if test "$OS_ARCH" = "BeOS"; then
5818   AC_DEFINE(XP_BEOS)
5819 elif test "$OS_ARCH" = "Darwin"; then
5820   AC_DEFINE(XP_MACOSX)
5821   AC_DEFINE(XP_UNIX)
5822   AC_DEFINE(UNIX_ASYNC_DNS)
5823 elif test "$OS_ARCH" = "OpenVMS"; then
5824   AC_DEFINE(XP_UNIX)
5825 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2" -a "$OS_ARCH" != "WINCE"; then
5826   AC_DEFINE(XP_UNIX)
5827   AC_DEFINE(UNIX_ASYNC_DNS)
5828 fi
5829
5830 AC_ARG_ENABLE(threadsafe,
5831               [  --enable-threadsafe     Enable support for multiple threads.],
5832               [AC_DEFINE(JS_THREADSAFE)],)
5833
5834 if test "$MOZ_DEBUG"; then
5835     AC_DEFINE(MOZ_REFLOW_PERF)
5836     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
5837 fi
5838
5839 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
5840     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
5841     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
5842     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
5843     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
5844     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
5845     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
5846     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
5847     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
5848 fi
5849
5850 dnl ========================================================
5851 dnl JavaScript shell
5852 dnl ========================================================
5853
5854 AC_HAVE_FUNCS(setlocale)
5855 AC_HAVE_FUNCS(localeconv)
5856
5857 dnl ========================================================
5858 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
5859 dnl ========================================================
5860 case "$host_os" in
5861 mingw*)
5862     WIN_TOP_SRC=`cd $srcdir; pwd -W`
5863     ;;
5864 cygwin*|msvc*|mks*)
5865     HOST_CC="\$(CYGWIN_WRAPPER) $HOST_CC"
5866     HOST_CXX="\$(CYGWIN_WRAPPER) $HOST_CXX"
5867     CC="\$(CYGWIN_WRAPPER) $CC"
5868     CXX="\$(CYGWIN_WRAPPER) $CXX"
5869     CPP="\$(CYGWIN_WRAPPER) $CPP"
5870     LD="\$(CYGWIN_WRAPPER) $LD"
5871     AS="\$(CYGWIN_WRAPPER) $AS"
5872     RC="\$(CYGWIN_WRAPPER) $RC"
5873     CYGDRIVE_MOUNT=`mount -p | awk '{ if (/^\//) { print $1; exit } }'`
5874     WIN_TOP_SRC=`cygpath -a -w $srcdir | sed -e 's|\\\\|/|g'`
5875     ;;
5876 esac
5877
5878 AC_SUBST(CYGDRIVE_MOUNT)
5879 AC_SUBST(WIN_TOP_SRC)
5880
5881 AC_SUBST(MOZILLA_VERSION)
5882
5883 AC_SUBST(ac_configure_args)
5884
5885 dnl Spit out some output
5886 dnl ========================================================
5887
5888 # Save the defines header file before autoconf removes it.
5889 # (Do not add AC_DEFINE calls after this line.)
5890   _CONFIG_TMP=confdefs-tmp.h
5891   _CONFIG_DEFS_H=js-confdefs.h
5892
5893   cat > $_CONFIG_TMP <<\EOF
5894 /* List of defines generated by configure. Included with preprocessor flag,
5895  * -include, to avoid long list of -D defines on the compile command-line.
5896  * Do not edit.
5897  */
5898
5899 #ifndef _JS_CONFDEFS_H_
5900 #define _JS_CONFDEFS_H_
5901 EOF
5902
5903 _EGREP_PATTERN='^#define ('
5904 if test -n "$_NON_GLOBAL_ACDEFINES"; then
5905     for f in $_NON_GLOBAL_ACDEFINES; do
5906         _EGREP_PATTERN="${_EGREP_PATTERN}$f|"
5907     done
5908 fi
5909 _EGREP_PATTERN="${_EGREP_PATTERN}dummy_never_defined)"
5910  
5911   sort confdefs.h | egrep -v "$_EGREP_PATTERN" >> $_CONFIG_TMP
5912
5913   cat >> $_CONFIG_TMP <<\EOF
5914
5915 #endif /* _JS_CONFDEFS_H_ */
5916
5917 EOF
5918
5919   # Only write js-confdefs.h when something changes (or it doesn't exist)
5920   if cmp -s $_CONFIG_TMP $_CONFIG_DEFS_H; then
5921     rm $_CONFIG_TMP
5922   else
5923     AC_MSG_RESULT("creating $_CONFIG_DEFS_H")
5924     mv -f $_CONFIG_TMP $_CONFIG_DEFS_H
5925
5926     echo ==== $_CONFIG_DEFS_H =================================
5927     cat $_CONFIG_DEFS_H
5928   fi
5929
5930 dnl Probably shouldn't call this manually but we always want the output of DEFS
5931 rm -f confdefs.h.save
5932 mv confdefs.h confdefs.h.save
5933 egrep -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
5934 AC_OUTPUT_MAKE_DEFS()
5935 MOZ_DEFINES=$DEFS
5936 AC_SUBST(MOZ_DEFINES)
5937 rm -f confdefs.h
5938 mv confdefs.h.save confdefs.h
5939
5940 MAKEFILES="
5941   Makefile
5942   shell/Makefile
5943   lirasm/Makefile
5944   jsapi-tests/Makefile
5945   tests/Makefile
5946   config/Makefile
5947   config/autoconf.mk
5948   config/mkdepend/Makefile
5949 "
5950
5951 if test -n "$JS_NATIVE_EDITLINE"; then
5952    MAKEFILES="$MAKEFILES
5953 editline/Makefile
5954 "
5955 fi
5956
5957 dnl 
5958 dnl Run a perl script to quickly create the makefiles.
5959 dnl If it succeeds, it outputs a shell command to set CONFIG_FILES
5960 dnl   for the files it cannot handle correctly. This way, config.status
5961 dnl   will handle these files.
5962 dnl If it fails, nothing is set and config.status will run as usual.
5963 dnl
5964 dnl This does not change the $MAKEFILES variable.
5965 dnl
5966 dnl OpenVMS gets a line overflow on the long eval command, so use a temp file.
5967 dnl
5968 if test -z "${AS_PERL}"; then
5969 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl > conftest.sh
5970 else
5971 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl -nowrap --cygwin-srcdir=$srcdir > conftest.sh
5972 fi
5973 . ./conftest.sh
5974 rm conftest.sh
5975
5976 echo $MAKEFILES > unallmakefiles
5977
5978 mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null
5979
5980 AC_OUTPUT($MAKEFILES)
5981
5982 dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world
5983 if cmp -s config/autoconf.mk config/autoconf.mk.orig; then
5984   echo "config/autoconf.mk is unchanged"
5985   mv -f config/autoconf.mk.orig config/autoconf.mk 2> /dev/null
5986 else
5987   rm -f config/autoconf.mk.orig 2> /dev/null
5988 fi
5989
5990 # Produce the js-config script at configure time; see the comments for
5991 # 'js-config' in Makefile.in.
5992 AC_MSG_RESULT(invoking make to create js-config script)
5993 $GMAKE js-config
5994
5995 # Build jsctypes if it's enabled.
5996 if test "$JS_HAS_CTYPES"; then
5997   # Run the libffi 'configure' script.
5998   ac_configure_args="--disable-shared --enable-static --disable-raw-api"
5999   if test "$MOZ_DEBUG"; then
6000     ac_configure_args="$ac_configure_args --enable-debug"
6001   fi
6002   if test "$DSO_PIC_CFLAGS"; then
6003     ac_configure_args="$ac_configure_args --with-pic"
6004   fi
6005   if test "$CROSS_COMPILE"; then
6006     case "$target" in
6007     *-mingw*)
6008       ac_configure_args="$ac_configure_args --build=$build --host=${target_cpu}-${target_os} HOST_CC=\"$HOST_CC\" CC=\"$CC\""
6009       ;;
6010     *-android*)
6011       CFLAGS="$ANDROID_CFLAGS"
6012       CPPFLAGS="$ANDROID_CPPFLAGS"
6013       LDFLAGS="$ANDROID_LDFLAGS"
6014
6015       export AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS CFLAGS LDFLAGS
6016
6017       ac_configure_args="$ac_configure_args --build=$build --host=${target_cpu}-${target_os} HOST_CC=\"$HOST_CC\""
6018       ;;
6019     *)
6020       ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\" CC=\"$CC\""
6021       ;;
6022     esac
6023   fi
6024   if test "$_MSC_VER"; then
6025     # Use a wrapper script for cl and ml that looks more like gcc.
6026     # autotools can't quite handle an MSVC build environment yet.
6027     ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
6028     case "${target_cpu}" in
6029     x86_64)
6030       # Need target since MSYS tools into mozilla-build may be 32bit
6031       ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/ctypes/libffi/msvcc.sh -m64\" --build=$build --host=$target"
6032       ;;
6033     *)
6034       ac_configure_args="$ac_configure_args CC=$_topsrcdir/ctypes/libffi/msvcc.sh"
6035       ;;
6036     esac
6037   fi
6038   if test "$SOLARIS_SUNPRO_CC"; then
6039     # Always use gcc for libffi on Solaris
6040     if test ! "$HAVE_64BIT_OS"; then
6041       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m32 LD= LDFLAGS="
6042     else
6043       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m64 LD= LDFLAGS="
6044     fi
6045   fi
6046   if test "$AIX_IBM_XLC"; then
6047     # Always use gcc for libffi on IBM AIX5/AIX6
6048     if test ! "$HAVE_64BIT_OS"; then
6049       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix32"
6050     else
6051       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix64"
6052     fi
6053   fi
6054   if test "$OS_ARCH" = "OS2"; then
6055     ac_configure_args="$ac_configure_args CFLAGS=-Zomf AR=emxomfar"
6056   fi
6057   if test -n "$MOZ_THUMB2"; then
6058     ac_configure_args="$ac_configure_args --enable-thumb2"
6059   fi
6060   if test -n "$MOZ_ARM_ARCH"; then
6061     ac_configure_args="$ac_configure_args --with-cpu-arch=$MOZ_ARM_ARCH"
6062   fi
6063
6064   # Use a separate cache file for libffi, since it does things differently
6065   # from our configure.
6066   mkdir -p $_objdir/ctypes/libffi
6067   old_cache_file=$cache_file
6068   cache_file=$_objdir/ctypes/libffi/config.cache
6069   old_config_files=$CONFIG_FILES
6070   unset CONFIG_FILES
6071   AC_OUTPUT_SUBDIRS(ctypes/libffi)
6072   cache_file=$old_cache_file
6073   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
6074   CONFIG_FILES=$old_config_files
6075 fi
6076