js-filter
[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 mips|mipsel)
1538     CPU_ARCH="mips"
1539     ;;
1540 esac
1541
1542 if test -z "$OS_TARGET"; then
1543     OS_TARGET=$OS_ARCH
1544 fi
1545 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1546
1547 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1548 dnl ===============================================================
1549 INTEL_ARCHITECTURE=
1550 case "$OS_TEST" in
1551     x86_64|i?86)
1552       INTEL_ARCHITECTURE=1
1553 esac
1554
1555 dnl ========================================================
1556 dnl GNU specific defaults
1557 dnl ========================================================
1558 if test "$GNU_CC"; then
1559     # FIXME: Let us build with strict aliasing. bug 414641.
1560     CFLAGS="$CFLAGS -fno-strict-aliasing"
1561     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1562     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1563     DSO_LDOPTS='-shared'
1564     if test "$GCC_USE_GNU_LD"; then
1565         # Don't allow undefined symbols in libraries
1566         DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1567     fi
1568     WARNINGS_AS_ERRORS='-Werror'
1569     DSO_CFLAGS=''
1570     DSO_PIC_CFLAGS='-fPIC'
1571     ASFLAGS="$ASFLAGS -fPIC"
1572     _MOZ_RTTI_FLAGS_ON=${_COMPILER_PREFIX}-frtti
1573     _MOZ_RTTI_FLAGS_OFF=${_COMPILER_PREFIX}-fno-rtti
1574     _MOZ_EXCEPTIONS_FLAGS_ON='-fexceptions'
1575     _MOZ_EXCEPTIONS_FLAGS_OFF='-fno-exceptions'
1576
1577     # Turn on GNU specific features
1578     # -Wall - turn on all warnings
1579     # -pedantic - make compiler warn about non-ANSI stuff, and
1580     #             be a little bit stricter
1581     # Warnings slamm took out for now (these were giving more noise than help):
1582     # -Wbad-function-cast - warns when casting a function to a new return type
1583     # -Wshadow - removed because it generates more noise than help --pete
1584     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith"
1585     if test -z "$INTEL_CC"; then
1586        # Don't use -Wcast-align with ICC
1587        case "$CPU_ARCH" in
1588            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1589            hppa | ia64 | sparc | arm)
1590            ;;
1591            *)
1592         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1593            ;;
1594        esac
1595     fi
1596
1597     dnl Turn pedantic on but disable the warnings for long long
1598     _PEDANTIC=1
1599
1600     if test -z "$INTEL_CC"; then
1601       _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
1602     fi
1603
1604     _DEFINES_CFLAGS='-include $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
1605     _USE_CPP_INCLUDE_FLAG=1
1606 elif test "$SOLARIS_SUNPRO_CC"; then
1607     DSO_CFLAGS=''
1608     if test "$CPU_ARCH" = "sparc"; then
1609         # for Sun Studio on Solaris/SPARC
1610         DSO_PIC_CFLAGS='-xcode=pic32'
1611     else
1612         DSO_PIC_CFLAGS='-KPIC'
1613     fi
1614     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
1615 else
1616     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1617     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1618
1619     DSO_LDOPTS='-shared'
1620     if test "$GNU_LD"; then
1621         # Don't allow undefined symbols in libraries
1622         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1623     fi
1624
1625     DSO_CFLAGS=''
1626     DSO_PIC_CFLAGS='-KPIC'
1627     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
1628 fi
1629
1630 if test "$GNU_CXX"; then
1631     # FIXME: Let us build with strict aliasing. bug 414641.
1632     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
1633     # Turn on GNU specific features
1634     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
1635     if test -z "$INTEL_CC"; then
1636        # Don't use -Wcast-align with ICC
1637        case "$CPU_ARCH" in
1638            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1639            hppa | ia64 | sparc | arm)
1640            ;;
1641            *)
1642         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1643            ;;
1644        esac
1645     fi
1646
1647     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/js-confdefs.h'
1648     _USE_CPP_INCLUDE_FLAG=1
1649
1650     AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
1651                    ac_has_wno_invalid_offsetof,
1652         [
1653             AC_LANG_SAVE
1654             AC_LANG_CPLUSPLUS
1655             _SAVE_CXXFLAGS="$CXXFLAGS"
1656             CXXFLAGS="$CXXFLAGS ${_COMPILER_PREFIX}-Wno-invalid-offsetof"
1657             AC_TRY_COMPILE([],
1658                            [return(0);],
1659                            ac_has_wno_invalid_offsetof="yes",
1660                            ac_has_wno_invalid_offsetof="no")
1661             CXXFLAGS="$_SAVE_CXXFLAGS"
1662             AC_LANG_RESTORE
1663         ])
1664     if test "$ac_has_wno_invalid_offsetof" = "yes"; then
1665         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-invalid-offsetof"
1666     fi
1667
1668     AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
1669                    ac_has_wno_variadic_macros,
1670         [
1671             AC_LANG_SAVE
1672             AC_LANG_CPLUSPLUS
1673             _SAVE_CXXFLAGS="$CXXFLAGS"
1674             CXXFLAGS="$CXXFLAGS ${_COMPILER_PREFIX}-Wno-variadic-macros"
1675             AC_TRY_COMPILE([],
1676                            [return(0);],
1677                            ac_has_wno_variadic_macros="yes",
1678                            ac_has_wno_variadic_macros="no")
1679             CXXFLAGS="$_SAVE_CXXFLAGS"
1680             AC_LANG_RESTORE
1681         ])
1682     if test "$ac_has_wno_variadic_macros" = "yes"; then
1683         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-variadic-macros"
1684     fi
1685
1686     AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
1687                    ac_has_werror_return_type,
1688         [
1689             AC_LANG_SAVE
1690             AC_LANG_CPLUSPLUS
1691             _SAVE_CXXFLAGS="$CXXFLAGS"
1692             CXXFLAGS="$CXXFLAGS -Werror=return-type"
1693             AC_TRY_COMPILE([],
1694                            [return(0);],
1695                            ac_has_werror_return_type="yes",
1696                            ac_has_werror_return_type="no")
1697             CXXFLAGS="$_SAVE_CXXFLAGS"
1698             AC_LANG_RESTORE
1699         ])
1700     if test "$ac_has_werror_return_type" = "yes"; then
1701         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
1702     fi
1703
1704 else
1705     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_JS_CONFDEFS_H_ $(ACDEFINES)'
1706 fi
1707
1708 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1709 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1710 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1711 dnl normal behavior.
1712 dnl ========================================================
1713 MKSHLIB_FORCE_ALL=
1714 MKSHLIB_UNFORCE_ALL=
1715
1716 if test "$COMPILE_ENVIRONMENT"; then
1717 if test "$GNU_CC"; then
1718   AC_MSG_CHECKING(whether ld has archive extraction flags)
1719   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1720    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1721     ac_cv_mkshlib_force_and_unforce="no"
1722     exec 3<&0 <<LOOP_INPUT
1723         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1724         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1725         force="-Wl,-all";              unforce="-Wl,-none"
1726 LOOP_INPUT
1727     while read line
1728     do
1729       eval $line
1730       LDFLAGS=$force
1731       LIBS=$unforce
1732       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1733     done
1734     exec 0<&3 3<&-
1735     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1736    ])
1737   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1738     AC_MSG_RESULT(no)
1739   else
1740     AC_MSG_RESULT(yes)
1741     eval $ac_cv_mkshlib_force_and_unforce
1742     MKSHLIB_FORCE_ALL=$force
1743     MKSHLIB_UNFORCE_ALL=$unforce
1744   fi
1745 fi # GNU_CC
1746 fi # COMPILE_ENVIRONMENT
1747
1748 dnl =================================================================
1749 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1750 dnl which is bad when cross compiling.
1751 dnl =================================================================
1752 if test "$COMPILE_ENVIRONMENT"; then
1753 configure_static_assert_macros='
1754 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1755 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1756 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1757 '
1758
1759 dnl test that the macros actually work:
1760 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1761 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1762  [AC_LANG_SAVE
1763   AC_LANG_C
1764   ac_cv_static_assertion_macros_work="yes"
1765   AC_TRY_COMPILE([$configure_static_assert_macros],
1766                  [CONFIGURE_STATIC_ASSERT(1)],
1767                  ,
1768                  ac_cv_static_assertion_macros_work="no")
1769   AC_TRY_COMPILE([$configure_static_assert_macros],
1770                  [CONFIGURE_STATIC_ASSERT(0)],
1771                  ac_cv_static_assertion_macros_work="no",
1772                  )
1773   AC_LANG_CPLUSPLUS
1774   AC_TRY_COMPILE([$configure_static_assert_macros],
1775                  [CONFIGURE_STATIC_ASSERT(1)],
1776                  ,
1777                  ac_cv_static_assertion_macros_work="no")
1778   AC_TRY_COMPILE([$configure_static_assert_macros],
1779                  [CONFIGURE_STATIC_ASSERT(0)],
1780                  ac_cv_static_assertion_macros_work="no",
1781                  )
1782   AC_LANG_RESTORE
1783  ])
1784 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1785 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1786     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1787 fi
1788 fi # COMPILE_ENVIRONMENT
1789
1790 dnl ========================================================
1791 dnl Checking for 64-bit OS
1792 dnl ========================================================
1793 if test "$COMPILE_ENVIRONMENT"; then
1794 AC_LANG_SAVE
1795 AC_LANG_C
1796 AC_MSG_CHECKING(for 64-bit OS)
1797 AC_TRY_COMPILE([$configure_static_assert_macros],
1798                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1799                result="yes", result="no")
1800 AC_MSG_RESULT("$result")
1801 if test "$result" = "yes"; then
1802     AC_DEFINE(HAVE_64BIT_OS)
1803     HAVE_64BIT_OS=1
1804 fi
1805 AC_SUBST(HAVE_64BIT_OS)
1806 AC_LANG_RESTORE
1807 fi # COMPILE_ENVIRONMENT
1808
1809 dnl ========================================================
1810 dnl Enable high-memory support on OS/2 by default.
1811 dnl ========================================================
1812 MOZ_OS2_HIGH_MEMORY=1
1813 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1814 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1815     MOZ_OS2_HIGH_MEMORY=,
1816     MOZ_OS2_HIGH_MEMORY=1 )
1817 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1818
1819 dnl ========================================================
1820 dnl = Use profiling compile flags
1821 dnl ========================================================
1822 MOZ_ARG_ENABLE_BOOL(profiling,
1823 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1824     MOZ_PROFILING=1,
1825     MOZ_PROFILING= )
1826
1827 dnl ========================================================
1828 dnl System overrides of the defaults for host
1829 dnl ========================================================
1830 case "$host" in
1831 *-beos*)
1832     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE -DNO_X11"
1833     HOST_NSPR_MDCPUCFG='\"md/_beos.cfg\"'
1834     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1835     ;;
1836
1837 *cygwin*|*mingw*|*mks*|*msvc*|*wince|*winmo)
1838     # we need Python 2.5 on Windows
1839     PYTHON_VERSION=2.5
1840     if test -n "$_WIN32_MSVC"; then
1841         HOST_AR=lib
1842         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1843         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1844         HOST_RANLIB='echo ranlib'
1845     else
1846         HOST_CFLAGS="$HOST_CFLAGS -mno-cygwin"
1847     fi
1848     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11"
1849     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1850     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1851     HOST_BIN_SUFFIX=.exe
1852     case "$host" in
1853     *mingw*)
1854     dnl MinGW/MSYS does not need CYGWIN_WRAPPER
1855         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1856         ;;
1857     *)
1858         CYGWIN_WRAPPER="${srcdir}/build/cygwin-wrapper"
1859         if test "`echo ${srcdir} | grep -c ^/ 2>/dev/null`" = 0; then
1860             _pwd=`pwd`
1861             CYGWIN_WRAPPER="${_pwd}/${srcdir}/build/cygwin-wrapper"
1862         fi
1863         if test "`${PERL} -v | grep -c cygwin  2>/dev/null`" = 0; then
1864             AS_PERL=1
1865             PERL="${CYGWIN_WRAPPER} $PERL"
1866         fi
1867
1868         if test "`${PYTHON} -c 'import sys; print sys.platform;'`" != "cygwin"; then
1869             PYTHON="${CYGWIN_WRAPPER} $PYTHON"
1870         fi
1871         ;;
1872     esac
1873
1874     case "${host_cpu}" in
1875     x86_64)
1876         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1877         ;;
1878     esac
1879     ;;
1880
1881 *-darwin*)
1882     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1883     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1884     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1885     ;;
1886
1887 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1888     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1889     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1890     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1891     ;;
1892
1893 *os2*)
1894     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1895     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1896     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1897     HOST_BIN_SUFFIX=.exe
1898     MOZ_FIX_LINK_PATHS=
1899     ;;
1900
1901 *-osf*)
1902     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1903     HOST_NSPR_MDCPUCFG='\"md/_osf1.cfg\"'
1904     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1905     ;;
1906
1907 *)
1908     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1909     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1910     ;;
1911 esac
1912
1913 dnl We require version 2.4 or newer of Python to build,
1914 dnl and 2.5 or newer on Windows.
1915 AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION but not 3.x])
1916 changequote(,)
1917 $PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
1918 _python_res=$?
1919 changequote([,])
1920 if test "$_python_res" != 0; then
1921     AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
1922 fi
1923 AC_MSG_RESULT([yes])
1924
1925 dnl ========================================================
1926 dnl System overrides of the defaults for target
1927 dnl ========================================================
1928
1929 case "$target" in
1930 *-aix*)
1931     AC_DEFINE(AIX)
1932     if test ! "$GNU_CC"; then
1933         if test ! "$HAVE_64BIT_OS"; then
1934             # Compiling with Visual Age C++ object model compat is the
1935             # default. To compile with object model ibm, add 
1936             # AIX_OBJMODEL=ibm to .mozconfig.
1937             if test "$AIX_OBJMODEL" = "ibm"; then
1938                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1939             else
1940                 AIX_OBJMODEL=compat
1941             fi
1942         else
1943             AIX_OBJMODEL=compat
1944         fi
1945         AC_SUBST(AIX_OBJMODEL)
1946         DSO_LDOPTS='-qmkshrobj=1'
1947         DSO_CFLAGS='-qflag=w:w'
1948         DSO_PIC_CFLAGS=
1949         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1950         MOZ_FIX_LINK_PATHS=
1951         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1952         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1953         if test "$COMPILE_ENVIRONMENT"; then
1954             AC_LANG_SAVE
1955             AC_LANG_CPLUSPLUS
1956             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1957             AC_TRY_COMPILE([],
1958                 [#if (__IBMCPP__ < 900)
1959                  #error "Bad compiler"
1960                  #endif],
1961                 _BAD_COMPILER=,_BAD_COMPILER=1)
1962             if test -n "$_BAD_COMPILER"; then
1963                 AC_MSG_RESULT([no])    
1964                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1965             else
1966                 AC_MSG_RESULT([yes])    
1967             fi
1968             AC_LANG_RESTORE
1969             TARGET_COMPILER_ABI="ibmc"
1970             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1971             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1972         fi
1973     fi
1974     case "${target_os}" in
1975     aix4.1*)
1976         DLL_SUFFIX='_shr.a'
1977         ;;
1978     esac
1979     if test "$COMPILE_ENVIRONMENT"; then
1980         AC_CHECK_HEADERS(sys/inttypes.h)
1981     fi
1982     AC_DEFINE(JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES)
1983     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1984     ;;
1985
1986 *-beos*)
1987     no_x=yes
1988     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1989     _PLATFORM_DEFAULT_TOOLKIT="cairo-beos"
1990     DSO_LDOPTS='-nostart'
1991     TK_LIBS='-lbe -lroot'
1992     LIBS="$LIBS -lbe"
1993     if test "$COMPILE_ENVIRONMENT"; then
1994         AC_CHECK_LIB(bind,main,LIBS="$LIBS -lbind")
1995         AC_CHECK_LIB(zeta,main,LIBS="$LIBS -lzeta")
1996     fi
1997     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-multichar"
1998     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-multichar"
1999     _MOZ_USE_RTTI=1
2000     USE_DEPENDENT_LIBS=
2001     MOZ_USER_DIR="Mozilla"
2002     ;;
2003
2004 *-bsdi*)
2005     dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
2006     _PEDANTIC=
2007     case $OS_RELEASE in
2008         4.*|5.*)
2009             STRIP="$STRIP -d"
2010             ;;
2011         *)
2012             DSO_CFLAGS=''
2013             DSO_LDOPTS='-r'
2014             _WARNINGS_CFLAGS="-Wall"
2015             _WARNINGS_CXXFLAGS="-Wall"
2016             # The test above doesn't work properly, at least on 3.1.
2017             MKSHLIB_FORCE_ALL=''
2018             MKSHLIB_UNFORCE_ALL=''
2019         ;;
2020     esac
2021     ;;
2022
2023 *-darwin*) 
2024     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2025     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2026     # If we're building with --enable-profiling, we need a frame pointer.
2027     if test -z "$MOZ_PROFILING"; then
2028         MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer"
2029     else
2030         MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer"
2031     fi
2032     _PEDANTIC=
2033     CFLAGS="$CFLAGS -fpascal-strings -fno-common"
2034     CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
2035     DLL_SUFFIX=".dylib"
2036     DSO_LDOPTS=''
2037     STRIP="$STRIP -x -S"
2038     _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
2039     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2040     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
2041     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
2042     # The ExceptionHandling framework is needed for Objective-C exception
2043     # logging code in nsObjCExceptions.h. Currently we only use that in debug
2044     # builds.
2045     MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
2046
2047     dnl DTrace and -dead_strip don't interact well. See bug 403132.
2048     dnl ===================================================================
2049     if test "x$enable_dtrace" = "xyes"; then
2050         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
2051     else
2052         dnl check for the presence of the -dead_strip linker flag
2053         AC_MSG_CHECKING([for -dead_strip option to ld])
2054         _SAVE_LDFLAGS=$LDFLAGS
2055         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
2056         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
2057         if test -n "$_HAVE_DEAD_STRIP" ; then
2058             AC_MSG_RESULT([yes])
2059             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
2060         else
2061             AC_MSG_RESULT([no])
2062         fi
2063         
2064         LDFLAGS=$_SAVE_LDFLAGS
2065     fi
2066     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
2067     ;;
2068
2069 *-freebsd*)
2070     if test `test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` != "elf"; then
2071         DLL_SUFFIX=".so.1.0"
2072         DSO_LDOPTS="-shared"
2073     fi
2074     if test ! "$GNU_CC"; then
2075         DSO_LDOPTS="-Bshareable $DSO_LDOPTS"
2076     fi
2077     ;; 
2078
2079 ia64*-hpux*)
2080     DLL_SUFFIX=".so"
2081     if test ! "$GNU_CC"; then
2082        DSO_LDOPTS='-b'
2083        DSO_CFLAGS=""
2084        DSO_PIC_CFLAGS=
2085        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2086        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2087        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2088     else
2089        DSO_LDOPTS='-b -E'
2090        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2091        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2092     fi
2093     MOZ_FIX_LINK_PATHS=
2094     SYSTEM_MAKEDEPEND=
2095     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2096     AC_DEFINE(_LARGEFILE64_SOURCE)
2097     ;;
2098
2099 *-hpux*)
2100     DLL_SUFFIX=".sl"
2101     if test ! "$GNU_CC"; then
2102         DSO_LDOPTS='-b -Wl,+s'
2103         DSO_CFLAGS=""
2104         DSO_PIC_CFLAGS="+Z"
2105         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2106         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2107         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2108     else
2109         DSO_LDOPTS='-b -E +s'
2110         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2111         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2112     fi
2113     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2114     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2115     ;;
2116
2117 *-irix5*)
2118     AC_DEFINE(IRIX)
2119     DSO_LDOPTS='-elf -shared'
2120
2121     if test "$GNU_CC"; then
2122        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2123        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2124        MKSHLIB_FORCE_ALL='-Wl,-all'
2125        MKSHLIB_UNFORCE_ALL='-Wl,-none'
2126        CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
2127     else
2128        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2129        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2130        MKSHLIB_FORCE_ALL='-all'
2131        MKSHLIB_UNFORCE_ALL='-none'
2132     fi
2133     ;;
2134
2135 *-irix6*)
2136     AC_DEFINE(IRIX)
2137     dnl the irix specific xptcinvoke code is written against the n32 ABI so we *must* 
2138     dnl compile and link using -n32
2139     USE_N32=1
2140     TARGET_COMPILER_ABI=n32
2141     DSO_LDOPTS='-elf -shared'
2142     MKSHLIB='$(CCC) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2143     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2144     _MOZ_EXCEPTIONS_FLAGS_OFF="-LANG:exceptions=OFF"
2145     _MOZ_EXCEPTIONS_FLAGS_ON="-LANG:exceptions=ON"
2146     if test "$GNU_CC"; then
2147        MKSHLIB_FORCE_ALL='-Wl,-all'
2148        MKSHLIB_UNFORCE_ALL='-Wl,-none'
2149        _WARNINGS_CFLAGS="-Wall"
2150        _WARNINGS_CXXFLAGS="-Wall"
2151        CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
2152     else
2153        MKSHLIB_FORCE_ALL='-all'
2154        MKSHLIB_UNFORCE_ALL='-none'
2155            AR_LIST="$AR t"
2156            AR_EXTRACT="$AR x"
2157            AR_DELETE="$AR d"
2158            AR='$(CXX) -ar'
2159            AR_FLAGS='-o $@'
2160        CFLAGS="$CFLAGS -woff 3262 -G 4"
2161        CXXFLAGS="$CXXFLAGS -woff 3262 -G 4"
2162        if test -n "$USE_N32"; then
2163            ASFLAGS="$ASFLAGS -n32"
2164            CFLAGS="$CFLAGS -n32"
2165            CXXFLAGS="$CXXFLAGS -n32"
2166            LDFLAGS="$LDFLAGS -n32"
2167        fi
2168        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2169        AC_MSG_WARN([Clearing MOZ_FIX_LINK_PATHS for OSF/1 as fix for bug 333545 (till the reference bug 332075 is fixed.])
2170        MOZ_FIX_LINK_PATHS=
2171     fi
2172     if test -z "$GNU_CXX"; then
2173       MIPSPRO_CXX=1
2174     fi
2175     ;;
2176
2177 *-*linux*)
2178     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2179     # Similarly for GNU_CXX and INTEL_CXX.
2180     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2181         # -Os has been broken on Intel's C/C++ compilers for quite a
2182         # while; Intel recommends against using it.
2183         MOZ_OPTIMIZE_FLAGS="-O2"
2184         MOZ_DEBUG_FLAGS="-g"
2185     elif test "$GNU_CC" -o "$GNU_CXX"; then
2186         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2187         case $GCC_VERSION in
2188         4.1.*|4.2.*|4.5.*)
2189             # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
2190             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2191         esac
2192         # If we're building with --enable-profiling, we need a frame pointer.
2193         if test -z "$MOZ_PROFILING"; then
2194             MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fomit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK"
2195         else
2196             MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-omit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK"
2197         fi
2198         MOZ_DEBUG_FLAGS="-g"
2199     fi
2200
2201     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2202
2203     case "${target_cpu}" in
2204     alpha*)
2205         CFLAGS="$CFLAGS -mieee"
2206         CXXFLAGS="$CXXFLAGS -mieee"
2207     ;;
2208     mips*)
2209         MOZ_DEBUG_FLAGS="-g" # We want inlining
2210     ;;
2211     esac
2212     ;;
2213
2214 *-wince*|*-winmo*)
2215     TARGET_COMPILER_ABI=msvc
2216     MOZ_TOOLS_DIR=`echo $MOZ_TOOLS`
2217     AR_LIST="$AR -list"
2218     AR_EXTRACT="$AR -extract"
2219     AR_DELETE="$AR d"
2220     AR_FLAGS='-OUT:"$@"'
2221     AS="$AS_BIN"
2222
2223     DSO_CFLAGS=
2224     DSO_PIC_CFLAGS=
2225     DLL_SUFFIX=.dll
2226     BIN_SUFFIX='.exe'
2227     if test -z "$RC"; then 
2228         RC=rc.exe  
2229     fi
2230     # certain versions of cygwin's makedepend barf on the 
2231     # #include <string> vs -I./dist/include/string issue so don't use it
2232     SYSTEM_MAKEDEPEND=
2233
2234     HOST_CC=cl
2235     HOST_CXX=cl
2236     HOST_LD=link
2237     HOST_AR='lib -OUT:$@'
2238     HOST_RANLIB='echo ranlib'
2239     HOST_CFLAGS="$HOST_CFLAGS -D_X86_"
2240         
2241         
2242     WARNINGS_AS_ERRORS='-WX'
2243     MOZ_OPTIMIZE_FLAGS='-Ox'
2244     AR_FLAGS='-NOLOGO -OUT:"$@"'
2245     ASM_SUFFIX=asm
2246     CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2247     CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2248     DLL_PREFIX=
2249     DOXYGEN=:
2250     DSO_LDOPTS=-SUBSYSTEM:WINDOWSCE
2251     DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2252     GARBAGE=
2253     IMPORT_LIB_SUFFIX=lib
2254     dnl Need to force-link against mozalloc because it's used in the shunt
2255     LIBS="$LIBS \$(LIBXUL_DIST)/lib/mozalloc.lib"
2256     LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2257     LIB_PREFIX=
2258     LIB_SUFFIX=lib 
2259     MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
2260     MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
2261     MKSHLIB_FORCE_ALL=
2262     MKSHLIB_UNFORCE_ALL=
2263     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2264     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2265     MOZ_DEBUG_FLAGS='-Zi'
2266     MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2267     MOZ_FIX_LINK_PATHS=
2268     MOZ_JS_LIBS='$(libdir)/mozjs.lib'
2269     OBJ_SUFFIX=obj
2270     RANLIB='echo not_ranlib'
2271     STRIP='echo not_strip'
2272     TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
2273     UNZIP=unzip
2274     XARGS=xargs
2275     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2276     ZIP=zip
2277
2278     AC_DEFINE(HAVE_SNPRINTF)
2279     AC_DEFINE(_WINDOWS)
2280     AC_DEFINE(WIN32)
2281     AC_DEFINE(XP_WIN)
2282     AC_DEFINE(XP_WIN32)
2283     AC_DEFINE(HW_THREADS)
2284     AC_DEFINE(STDC_HEADERS)
2285     AC_DEFINE(NEW_H, <new>)
2286     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2287     AC_DEFINE(HAVE_LOCALTIME_R)
2288
2289     TARGET_MD_ARCH=win32
2290     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2291     BIN_SUFFIX='.exe'
2292     MOZ_USER_DIR="Mozilla"
2293
2294     dnl Default to Windows Mobile components enabled
2295     WINCE_WINDOWS_MOBILE=1
2296
2297     MOZ_ARG_DISABLE_BOOL(windows-mobile-components,
2298     [  --disable-windows-mobile-components
2299                           Disable Windows Mobile specific components from
2300                           CE build],
2301     WINCE_WINDOWS_MOBILE=,
2302     WINCE_WINDOWS_MOBILE=1)
2303  
2304     if test "$WINCE_WINDOWS_MOBILE"; then
2305         AC_DEFINE(WINCE_WINDOWS_MOBILE)
2306     fi
2307 ;;
2308
2309 *-symbian*)
2310
2311     AC_DEFINE(XP_UNIX)
2312     AC_DEFINE(SYMBIAN)
2313     AC_DEFINE(__arm__)
2314     AC_DEFINE(__SYMBIAN32__)
2315     AC_DEFINE(_UNICODE)
2316     AC_DEFINE(NDEBUG)
2317     AC_DEFINE(__SUPPORT_CPP_EXCEPTIONS__)
2318     AC_DEFINE(MOZ_STDERR_TO_STDOUT)
2319     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2320     AC_DEFINE(HAVE_SOCKLEN_T)
2321     AC_DEFINE(__GCCE__)
2322
2323     CPU_ARCH=ARM
2324     OS_RELEASE=9.2
2325     OS_ARCH=SYMBIAN
2326     USE_PTHREADS=1
2327     LIB_SUFFIX=lib
2328     DLL_SUFFIX=dll
2329     MKSHLIB=
2330     DSO_LDOPTS=
2331     DSO_CFLAGS=
2332     VISIBILITY_FLAGS=
2333     TARGET_NSPR_MDCPUCFG='\"md/_symbian.cfg\"'
2334     RANLIB='echo no ranlib '
2335 ;;
2336
2337 *-mingw*|*-cygwin*|*-msvc*|*-mks*)
2338     DSO_CFLAGS=
2339     DSO_PIC_CFLAGS=
2340     DLL_SUFFIX=.dll
2341     RC=rc.exe
2342     # certain versions of cygwin's makedepend barf on the 
2343     # #include <string> vs -I./dist/include/string issue so don't use it
2344     SYSTEM_MAKEDEPEND=
2345     if test -n "$GNU_CC"; then
2346         CC="$CC -mno-cygwin"
2347         CXX="$CXX -mno-cygwin"
2348         CPP="$CPP -mno-cygwin"
2349         CFLAGS="$CFLAGS -mms-bitfields"
2350         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2351         DSO_LDOPTS='-shared'
2352         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2353         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2354         RC='$(WINDRES)'
2355         # Use temp file for windres (bug 213281)
2356         RCFLAGS='-O coff --use-temp-file'
2357         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2358         LIBS="$LIBS -lgdi32 -lwinmm -lwsock32"
2359         MOZ_JS_LIBS='-L$(libdir) -lmozjs'
2360         MOZ_FIX_LINK_PATHS=
2361         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2362         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2363         DLL_PREFIX=
2364         IMPORT_LIB_SUFFIX=dll.a
2365         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2366     else
2367         TARGET_COMPILER_ABI=msvc
2368         HOST_CC='$(CC)'
2369         HOST_CXX='$(CXX)'
2370         HOST_LD='$(LD)'
2371         if test "$AS_BIN"; then
2372             AS="$(basename "$AS_BIN")"
2373         fi
2374         AR='lib -NOLOGO -OUT:"$@"'
2375         AR_FLAGS=
2376         RANLIB='echo not_ranlib'
2377         STRIP='echo not_strip'
2378         PKG_SKIP_STRIP=1
2379         XARGS=xargs
2380         ZIP=zip
2381         UNZIP=unzip
2382         DOXYGEN=:
2383         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
2384         ASM_SUFFIX=asm
2385         OBJ_SUFFIX=obj
2386         LIB_SUFFIX=lib
2387         DLL_PREFIX=
2388         LIB_PREFIX=
2389         IMPORT_LIB_SUFFIX=lib
2390         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2391         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2392         MKSHLIB_FORCE_ALL=
2393         MKSHLIB_UNFORCE_ALL=
2394         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2395         _USE_CPP_INCLUDE_FLAG=1
2396         _DEFINES_CFLAGS='-FI $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
2397         _DEFINES_CXXFLAGS='-FI $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
2398         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2399         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2400         # MSVC warnings C4244 and C4800 are ubiquitous, useless, and annoying.
2401         CXXFLAGS="$CXXFLAGS -wd4244 -wd4800"
2402         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
2403         MOZ_DEBUG_FLAGS='-Zi'
2404         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2405         WARNINGS_AS_ERRORS='-WX'
2406         # If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer.
2407         if test -z "$MOZ_PROFILING"; then
2408             MOZ_OPTIMIZE_FLAGS='-O1'
2409         else
2410             MOZ_OPTIMIZE_FLAGS='-O1 -Oy-'
2411         fi
2412         MOZ_JS_LIBS='$(libdir)/mozjs.lib'
2413         MOZ_FIX_LINK_PATHS=
2414         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2415         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2416         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2417         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2418         if test $_MSC_VER -ge 1400; then
2419             LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2420             dnl For profile-guided optimization
2421             PROFILE_GEN_CFLAGS="-GL"
2422             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2423             dnl XXX: PGO builds can fail with warnings treated as errors,
2424             dnl specifically "no profile data available" appears to be
2425             dnl treated as an error sometimes. This might be a consequence
2426             dnl of using WARNINGS_AS_ERRORS in some modules, combined
2427             dnl with the linker doing most of the work in the whole-program
2428             dnl optimization/PGO case. I think it's probably a compiler bug,
2429             dnl but we work around it here.
2430             PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2431             dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2432             dnl Probably also a compiler bug, but what can you do?
2433             PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2434             LDFLAGS="$LDFLAGS -DYNAMICBASE"
2435         fi
2436     fi
2437     AC_DEFINE(HAVE_SNPRINTF)
2438     AC_DEFINE(_WINDOWS)
2439     AC_DEFINE(WIN32)
2440     AC_DEFINE(XP_WIN)
2441     AC_DEFINE(XP_WIN32)
2442     AC_DEFINE(HW_THREADS)
2443     AC_DEFINE(STDC_HEADERS)
2444     AC_DEFINE(NEW_H, <new>)
2445     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2446     TARGET_MD_ARCH=win32
2447     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2448     BIN_SUFFIX='.exe'
2449     MOZ_USER_DIR="Mozilla"
2450
2451     dnl Hardcode to win95 for now - cls
2452     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2453
2454     dnl set NO_X11 defines here as the general check is skipped on win32
2455     no_x=yes
2456     AC_DEFINE(NO_X11)
2457
2458     dnl MinGW/MSYS doesn't provide or need cygpath
2459     case "$host" in
2460     *-mingw*)
2461         CYGPATH_W=echo
2462         CYGPATH_S=cat
2463         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2464         ;;
2465     *-cygwin*|*-msvc*|*-mks*)
2466         CYGPATH_W="cygpath -a -w"
2467         CYGPATH_S="sed -e s|\\\\|/|g"
2468         MOZ_BUILD_ROOT=`$CYGPATH_W $MOZ_BUILD_ROOT | $CYGPATH_S`
2469         ;;
2470     esac
2471     case "$host" in
2472     *-mingw*|*-cygwin*|*-msvc*|*-mks*)
2473
2474     if test -z "$MOZ_TOOLS"; then
2475         AC_MSG_ERROR([MOZ_TOOLS is not set])
2476     fi
2477
2478     MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2479     if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2480         AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2481     fi
2482     MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2483     if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2484         AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2485     fi
2486     MOZ_TOOLS_DIR=`$CYGPATH_W $MOZ_TOOLS_DIR | $CYGPATH_S`
2487     ;;
2488     esac 
2489
2490
2491     case "$host_os" in
2492     cygwin*|msvc*|mks*)
2493         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.])
2494         ;;
2495     esac
2496
2497     case "$target" in
2498     i*86-*)
2499         if test "$HAVE_64BIT_OS"; then
2500             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2501         fi
2502
2503         if test $_MSC_VER -ge 1400; then
2504             LDFLAGS="$LDFLAGS -SAFESEH"
2505         fi
2506
2507         if test -n "$GNU_CC"; then
2508             CFLAGS="$CFLAGS -mstackrealign"
2509             CXXFLAGS="$CXXFLAGS -mstackrealign"
2510         fi
2511
2512         AC_CHECK_HEADERS(mmintrin.h)
2513         AC_DEFINE(_X86_)
2514         ;;
2515     alpha-*)
2516         AC_DEFINE(_ALPHA_)
2517         ;;
2518     mips-*)
2519         AC_DEFINE(_MIPS_)
2520         ;;
2521     x86_64-*)
2522         AC_DEFINE(_AMD64_)
2523         ;;
2524     *)
2525         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2526         ;;
2527     esac
2528
2529     if test "$HAVE_64BIT_OS"; then
2530         AC_DEFINE(_WIN64)
2531     fi
2532     ;;
2533
2534 *-netbsd*)
2535     DSO_CFLAGS=''
2536     CFLAGS="$CFLAGS -Dunix"
2537     CXXFLAGS="$CXXFLAGS -Dunix"
2538     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2539         DLL_SUFFIX=".so"
2540         DSO_PIC_CFLAGS='-fPIC -DPIC'
2541         DSO_LDOPTS='-shared'
2542         BIN_FLAGS='-Wl,--export-dynamic'
2543     else
2544         DSO_PIC_CFLAGS='-fPIC -DPIC'
2545         DLL_SUFFIX=".so.1.0"
2546         DSO_LDOPTS='-shared'
2547     fi
2548     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2549     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2550     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2551     if test "$LIBRUNPATH"; then
2552         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2553     fi
2554     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2555     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2556     ;;
2557
2558 *-nto*) 
2559         AC_DEFINE(NTO)  
2560         AC_DEFINE(_QNX_SOURCE)
2561         AC_DEFINE(_i386)
2562         OS_TARGET=NTO
2563         WARNINGS_AS_ERRORS=''
2564         MOZ_OPTIMIZE_FLAGS="-O"
2565         MOZ_DEBUG_FLAGS="-gstabs"
2566         USE_PTHREADS=1
2567         _PEDANTIC=
2568         LIBS="$LIBS -lsocket -lstdc++"
2569         _DEFINES_CFLAGS='-include $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT -D_POSIX_C_SOURCE=199506'
2570         _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/js-confdefs.h -D_POSIX_C_SOURCE=199506'
2571         if test "$with_x" != "yes"
2572         then
2573                 _PLATFORM_DEFAULT_TOOLKIT="photon"
2574             TK_CFLAGS='-I/usr/include/photon'
2575                 TK_LIBS='-lph'
2576         fi
2577         case "${target_cpu}" in
2578         ppc*)
2579         AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)        
2580         ;;
2581         esac
2582         ;;
2583
2584 *-openbsd*)
2585     DLL_SUFFIX=".so.1.0"
2586     DSO_CFLAGS=''
2587     DSO_PIC_CFLAGS='-fPIC'
2588     DSO_LDOPTS='-shared -fPIC'
2589     if test "$LIBRUNPATH"; then
2590         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2591     fi
2592     ;;
2593
2594 *-openvms*) 
2595     AC_DEFINE(NO_PW_GECOS)
2596     AC_DEFINE(NO_UDSOCK)
2597     AC_DEFINE(POLL_WITH_XCONNECTIONNUMBER)
2598     USE_PTHREADS=1
2599     MKSHLIB_FORCE_ALL='-all'
2600     MKSHLIB_UNFORCE_ALL='-none'
2601     AS='as'
2602     AS_DASH_C_FLAG='-Wc/names=as_is'
2603     AR_FLAGS='c $@'
2604     DSO_LDOPTS='-shared -auto_symvec'
2605     DSO_PIC_CFLAGS=
2606     MOZ_DEBUG_LDFLAGS='-g'
2607     COMPAQ_CXX=1
2608     CC_VERSION=`$CC -V 2>&1 | awk '/ C / { print $3 }'`
2609     CXX_VERSION=`$CXX -V 2>&1 | awk '/ C\+\+ / { print $3 }'`
2610     ;;
2611
2612
2613 *-os2*)
2614     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2615     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2616     AC_DEFINE(OS2)
2617     AC_DEFINE(XP_OS2)
2618     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2619     AC_DEFINE(TCPV40HDRS)
2620     DLL_PREFIX=
2621     LIB_PREFIX=
2622     LIB_SUFFIX=lib
2623     BIN_SUFFIX=".exe"
2624     DLL_SUFFIX=".dll"
2625     IMPORT_LIB_SUFFIX=lib
2626     DSO_PIC_CFLAGS=
2627     AR=emxomfar
2628     AR_FLAGS='r $@'
2629     CFLAGS="$CFLAGS -Zomf"
2630     CXXFLAGS="$CXXFLAGS -Zomf"
2631     DSO_LDOPTS='-Zdll'
2632     BIN_FLAGS='-Zlinker /ST:0x100000'
2633     IMPLIB='emximp -o'
2634     FILTER='true'
2635     LDFLAGS='-Zmap'
2636     WARNINGS_AS_ERRORS='-Werror'
2637     MOZ_DEBUG_FLAGS="-g -fno-inline"
2638     MOZ_OPTIMIZE_FLAGS="-O2"
2639     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2640     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2641     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2642     TARGET_MD_ARCH=os2
2643     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2644     RC=rc.exe
2645     RCFLAGS='-n'
2646     MOZ_USER_DIR="Mozilla"
2647
2648     if test "$MOZTOOLS"; then
2649         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2650     else
2651         AC_MSG_ERROR([MOZTOOLS is not set])
2652     fi
2653     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2654         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2655         LDFLAGS="$LDFLAGS -Zhigh-mem"
2656         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2657         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2658     fi
2659
2660     # GCC for OS/2 currently predefines these, but we don't want them
2661     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2662     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2663
2664     AC_CACHE_CHECK(for __declspec(dllexport),
2665         ac_os2_declspec,
2666         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2667                         [return 0;],
2668                         ac_os2_declspec="yes",
2669                         ac_os2_declspec="no")])
2670     if test "$ac_os2_declspec" != "yes"; then
2671         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2672     fi
2673     ;;
2674
2675 alpha*-*-osf*)
2676     if test "$GNU_CC"; then
2677       MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
2678       MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
2679
2680     else
2681         MOZ_DEBUG_FLAGS='-g'
2682         ASFLAGS='-I$(topsrcdir)/xpcom/reflect/xptcall/public -g'
2683         CFLAGS="$CFLAGS -ieee"
2684         CXXFLAGS="$CXXFLAGS "'-noexceptions -ieee  -ptr $(DIST)/cxx_repository'
2685         DSO_LDOPTS='-shared -msym -expect_unresolved \* -update_registry $(DIST)/so_locations'
2686         DSO_CFLAGS=
2687         DSO_PIC_CFLAGS=
2688         MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
2689         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
2690         MKSHLIB_FORCE_ALL='-all'
2691         MKSHLIB_UNFORCE_ALL='-none'
2692         dnl Might fix the libxpcom.so breakage on this platform as well....
2693         AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2694         AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2695     fi
2696     if test -z "$GNU_CXX"; then
2697       COMPAQ_CXX=1
2698     fi
2699     AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2700     ;;
2701
2702 *-qnx*) 
2703     DIRENT_INO=d_stat.st_ino
2704     dnl Solves the problems the QNX compiler has with nsCOMPtr.h.
2705     AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2706     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2707     dnl Explicit set STDC_HEADERS to workaround QNX 6.0's failing of std test
2708     AC_DEFINE(STDC_HEADERS)
2709     if test "$no_x" = "yes"; then
2710             _PLATFORM_DEFAULT_TOOLKIT='photon'
2711             TK_CFLAGS='-I/usr/nto/include/photon'
2712             TK_LIBS='-lphoton -lphrender'
2713     fi
2714     ;;
2715
2716 *-sco*) 
2717     AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2718     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2719     CXXFLAGS="$CXXFLAGS -I/usr/include/CC"
2720     if test ! "$GNU_CC"; then
2721        DSO_LDOPTS='-G'
2722     fi
2723     ;;
2724
2725 *-solaris*) 
2726     AC_DEFINE(SOLARIS)
2727     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2728     if test -z "$CROSS_COMPILE" && pkginfo -q SUNWpr && pkginfo -q SUNWprd; then
2729        NO_NSPR_CONFIG_SYSTEM_LDFLAGS="-L/usr/lib/mps -R/usr/lib/mps -lnspr4"
2730        NO_NSPR_CONFIG_SYSTEM_CFLAGS="-I/usr/include/mps"
2731        NO_NSPR_CONFIG_SYSTEM_VERSION=["`pkgparam SUNWpr SUNW_PRODVERS | sed -e 's/^[1-9][0-9]*\.[0-9][0-9]*$/&.0/'`"]
2732     fi
2733     SYSTEM_MAKEDEPEND=
2734     MOZ_FIX_LINK_PATHS=
2735     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2736     # libraries one level up (e.g. libnspr4.so)
2737     if test "$SOLARIS_SUNPRO_CC"; then
2738        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2739        LIBS="-lCrun -lCstd -lc $LIBS"
2740        NS_USE_NATIVE=1
2741        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2742        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2743        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2744        _MOZ_EXCEPTIONS_FLAGS_ON='-features=except'
2745        _MOZ_EXCEPTIONS_FLAGS_OFF='-features=no%except'
2746        LDFLAGS="-xildoff $LDFLAGS"
2747        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2748            _SAVE_LDFLAGS=$LDFLAGS
2749            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS" 
2750            AC_TRY_LINK([#include <stdio.h>],
2751                        [printf("Hello World\n");],
2752                        ,
2753                        [LDFLAGS=$_SAVE_LDFLAGS])
2754        fi
2755        WARNINGS_AS_ERRORS='-Werror'
2756        MOZ_OPTIMIZE_FLAGS="-xO4"
2757        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2758        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2759        MKSHLIB_FORCE_ALL='-z allextract'
2760        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2761        DSO_LDOPTS='-G'
2762        AR_LIST="$AR t"
2763        AR_EXTRACT="$AR x"
2764        AR_DELETE="$AR d"
2765        AR='$(CXX) -xar'
2766        AR_FLAGS='-o $@'
2767        AS='/usr/ccs/bin/as'
2768        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2769        AS_DASH_C_FLAG=''
2770        TARGET_COMPILER_ABI="sunc"
2771        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2772        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2773        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2774        AC_LANG_SAVE
2775        AC_LANG_CPLUSPLUS
2776        AC_TRY_COMPILE([],
2777            [#if (__SUNPRO_CC < 0x590)
2778            #error "Denied"
2779            #endif],
2780            _BAD_COMPILER=,_BAD_COMPILER=1)
2781        if test -n "$_BAD_COMPILER"; then
2782            _res="no"
2783            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2784        else
2785            _res="yes"
2786        fi
2787        AC_TRY_COMPILE([],
2788            [#if (__SUNPRO_CC >= 0x5100)
2789            #error "Sun C++ 5.10 or above"
2790            #endif],
2791            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2792        if test "$_ABOVE_SS12U1"; then
2793            # disable xannotate
2794            CXXFLAGS="$CXXFLAGS -xannotate=no"
2795        fi
2796        AC_MSG_RESULT([$_res])
2797        AC_LANG_RESTORE
2798     else
2799        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2800        LIBS="-lc $LIBS"
2801        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2802        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2803        ASFLAGS="$ASFLAGS -fPIC"
2804        DSO_LDOPTS='-shared'
2805        _WARNINGS_CFLAGS=''
2806        _WARNINGS_CXXFLAGS=''
2807        if test "$OS_RELEASE" = "5.3"; then
2808            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2809        fi
2810     fi
2811     if test "$OS_RELEASE" = "5.5.1"; then
2812         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2813     fi
2814     ;;
2815
2816 *-sunos*) 
2817     DSO_LDOPTS='-Bdynamic'
2818     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2819     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2820     AC_DEFINE(SUNOS4)
2821     AC_DEFINE(SPRINTF_RETURNS_STRING)
2822     case "$(target_os)" in
2823     sunos4.1*)
2824         DLL_SUFFIX='.so.1.0'
2825         ;;
2826     esac
2827     ;;
2828
2829 *-sysv4.2uw7*) 
2830         NSPR_LIBS="-lnspr$NSPR_VERSION -lplc$NSPR_VERSION -lplds$NSPR_VERSION -L/usr/ccs/lib -lcrt"
2831     ;;
2832
2833 *-os2*)
2834     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2835     ;;
2836
2837 *-android*)
2838     AC_DEFINE(NO_PW_GECOS)
2839     no_x=yes
2840     _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2841     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2842
2843     MOZ_GFX_OPTIMIZE_MOBILE=1
2844     # If we're building with --enable-profiling, we need a frame pointer.
2845     if test -z "$MOZ_PROFILING"; then
2846         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer"
2847     else
2848         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fno-omit-frame-pointer"
2849     fi
2850     # The Maemo builders don't know about this flag
2851     MOZ_ARM_VFP_FLAGS="-mfpu=vfp"
2852     ;;
2853
2854 esac
2855
2856 dnl Only one oddball right now (QNX), but this gives us flexibility
2857 dnl if any other platforms need to override this in the future.
2858 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2859
2860 dnl ========================================================
2861 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2862 dnl by now will not have any way to link most binaries (tests
2863 dnl as well as viewer, apprunner, etc.), because some symbols
2864 dnl will be left out of the "composite" .so's by ld as unneeded.
2865 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2866 dnl they can link in the static libs that provide the missing
2867 dnl symbols.
2868 dnl ========================================================
2869 NO_LD_ARCHIVE_FLAGS=
2870 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2871     NO_LD_ARCHIVE_FLAGS=1
2872 fi
2873 case "$target" in
2874 *-os2*)
2875     NO_LD_ARCHIVE_FLAGS=
2876     ;;
2877 *-aix4.3*|*-aix5*)
2878     NO_LD_ARCHIVE_FLAGS=
2879     ;;
2880 *-openvms*)
2881     NO_LD_ARCHIVE_FLAGS=
2882     ;;
2883 *-msvc*|*-mks*|*-mingw*|*-cygwin*|*-wince|*-winmo)
2884     if test -z "$GNU_CC"; then
2885         NO_LD_ARCHIVE_FLAGS=
2886     fi
2887     ;;
2888 esac
2889 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2890
2891 dnl ========================================================
2892 dnl = Flags to strip unused symbols from .so components
2893 dnl ========================================================
2894 case "$target" in
2895     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2896         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2897         ;;
2898     *-solaris*)
2899         if test -z "$GNU_CC"; then
2900          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2901         else
2902          if test -z "$GCC_USE_GNU_LD"; then
2903           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2904          else
2905           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2906          fi
2907         fi
2908         ;;
2909     *-nto*) 
2910         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2911         ;;
2912     *-darwin*)
2913         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2914         ;;
2915     *-cygwin*|*-mingw*|*-mks*|*-msvc|*-wince|*-winmo)
2916         if test -n "$GNU_CC"; then
2917            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2918         fi
2919         ;;
2920 esac
2921
2922 if test -z "$COMPILE_ENVIRONMENT"; then
2923     SKIP_COMPILER_CHECKS=1
2924     SKIP_LIBRARY_CHECKS=1
2925 fi
2926
2927 dnl Configure JIT support
2928
2929 case "$target" in
2930 i?86-*)
2931     ENABLE_TRACEJIT=1
2932     NANOJIT_ARCH=i386
2933     ENABLE_METHODJIT=1
2934     ENABLE_MONOIC=1
2935     ENABLE_POLYIC=1
2936     ENABLE_POLYIC_TYPED_ARRAY=1
2937     AC_DEFINE(JS_CPU_X86)
2938     AC_DEFINE(JS_NUNBOX32)
2939     ;;
2940 x86_64*-*)
2941     ENABLE_TRACEJIT=1
2942     NANOJIT_ARCH=X64
2943     ENABLE_METHODJIT=1
2944     ENABLE_MONOIC=1
2945     ENABLE_POLYIC=1
2946     ENABLE_POLYIC_TYPED_ARRAY=1
2947     AC_DEFINE(JS_CPU_X64)
2948     AC_DEFINE(JS_PUNBOX64)
2949     ;;
2950 arm*-*)
2951     ENABLE_TRACEJIT=1
2952     NANOJIT_ARCH=ARM
2953     ENABLE_METHODJIT=1
2954     ENABLE_MONOIC=1
2955     ENABLE_POLYIC=1
2956     AC_DEFINE(JS_CPU_ARM)
2957     AC_DEFINE(JS_NUNBOX32)
2958     ;;
2959 sparc*-*)
2960     ENABLE_TRACEJIT=1
2961     NANOJIT_ARCH=Sparc
2962     AC_DEFINE(JS_CPU_SPARC)
2963     ;;
2964 esac
2965
2966 MOZ_ARG_DISABLE_BOOL(methodjit,
2967 [  --disable-methodjit           Disable method JIT support],
2968   ENABLE_METHODJIT= )
2969
2970 MOZ_ARG_DISABLE_BOOL(monoic,
2971 [  --disable-monoic      Disable use of MICs by JIT compiler],
2972   ENABLE_MONOIC= )
2973
2974 MOZ_ARG_DISABLE_BOOL(polyic,
2975 [  --disable-polyic      Disable use of PICs by JIT compiler],
2976   ENABLE_POLYIC= )
2977
2978 MOZ_ARG_DISABLE_BOOL(tracejit,
2979 [  --disable-tracejit      Disable tracing JIT support],
2980   ENABLE_TRACEJIT=)
2981
2982 MOZ_ARG_ENABLE_BOOL(methodjit-spew,
2983 [  --enable-methodjit-spew      Enable method JIT spew support],
2984   ENABLE_METHODJIT_SPEW=1,
2985   ENABLE_METHODJIT_SPEW= )
2986
2987 AC_SUBST(ENABLE_METHODJIT)
2988
2989 if test "$ENABLE_METHODJIT"; then
2990     AC_DEFINE(JS_METHODJIT)
2991 fi
2992
2993 if test "$ENABLE_MONOIC"; then
2994     AC_DEFINE(JS_MONOIC)
2995 fi
2996
2997 if test "$ENABLE_POLYIC"; then
2998     AC_DEFINE(JS_POLYIC)
2999 fi
3000
3001 if test "$ENABLE_POLYIC_TYPED_ARRAY"; then
3002     AC_DEFINE(JS_POLYIC_TYPED_ARRAY)
3003 fi
3004
3005 if test "$ENABLE_METHODJIT_SPEW"; then
3006     AC_DEFINE(JS_METHODJIT_SPEW)
3007 fi
3008
3009 if test "$ENABLE_TRACEJIT"; then
3010
3011 AC_DEFINE(FEATURE_NANOJIT)
3012 AC_DEFINE(JS_TRACER)
3013
3014 case "$target" in
3015 i?86-*)
3016     AC_DEFINE(AVMPLUS_IA32)
3017     ;;
3018 x86_64*-*)
3019     AC_DEFINE(AVMPLUS_AMD64)
3020     AC_DEFINE(AVMPLUS_64BIT)
3021     ;;
3022 arm*-*)
3023     AC_DEFINE(AVMPLUS_ARM)
3024     ;;
3025 sparc-*)
3026     AC_DEFINE(AVMPLUS_SPARC)
3027     ;;
3028 esac
3029
3030 case "$target" in
3031 *-linux*|*-android-eabi)
3032     AC_DEFINE(AVMPLUS_UNIX)
3033     AC_DEFINE(AVMPLUS_LINUX)
3034     ;;
3035 *-darwin*)
3036     AC_DEFINE(AVMPLUS_UNIX)
3037     ;;
3038 *-solaris*)
3039     AC_DEFINE(AVMPLUS_UNIX)
3040     ;;
3041 *-freebsd*|*-kfreebsd*)
3042     AC_DEFINE(AVMPLUS_UNIX)
3043     ;;
3044 *-gnu*)
3045     AC_DEFINE(AVMPLUS_UNIX)
3046     ;;
3047 *-cygwin*|*-mingw*|*-mks*|*-msvc*|*-wince|*-winmo)
3048     AC_DEFINE(AVMPLUS_WIN32)
3049     ;;
3050 *-os2*)
3051     AC_DEFINE(AVMPLUS_OS2)
3052     ;;
3053 *)
3054     AC_MSG_ERROR([Unrecognized nanojit platform. Use --disable-tracejit to build without tracing JIT support.])
3055 esac
3056
3057 fi # ENABLE_TRACEJIT
3058
3059 AC_SUBST(ENABLE_TRACEJIT)
3060 AC_SUBST(NANOJIT_ARCH)
3061
3062 if test -z "$SKIP_COMPILER_CHECKS"; then
3063 dnl Checks for typedefs, structures, and compiler characteristics.
3064 dnl ========================================================
3065 AC_HEADER_STDC
3066 AC_C_CONST
3067 AC_TYPE_MODE_T
3068 AC_TYPE_OFF_T
3069 AC_TYPE_PID_T
3070 AC_TYPE_SIZE_T
3071 AC_LANG_CPLUSPLUS
3072 AC_MSG_CHECKING(for __stdcall)
3073 AC_CACHE_VAL(ac_cv___stdcall,
3074  [AC_TRY_COMPILE([template <typename Method> struct foo;
3075                   template <> struct foo<void (*)()> {};
3076                   template <> struct foo<void (__stdcall*)()> {};],
3077                  [],
3078                  [ac_cv___stdcall=true],
3079                  [ac_cv___stdcall=false])])
3080 if test "$ac_cv___stdcall" = true ; then
3081   AC_DEFINE(HAVE_STDCALL)
3082   AC_MSG_RESULT(yes)
3083 else
3084   AC_MSG_RESULT(no)
3085 fi
3086 AC_LANG_C
3087 AC_MSG_CHECKING(for ssize_t)
3088 AC_CACHE_VAL(ac_cv_type_ssize_t,
3089  [AC_TRY_COMPILE([#include <stdio.h>
3090                   #include <sys/types.h>],
3091                  [ssize_t foo = 0;],
3092                  [ac_cv_type_ssize_t=true],
3093                  [ac_cv_type_ssize_t=false])])
3094 if test "$ac_cv_type_ssize_t" = true ; then
3095   AC_DEFINE(HAVE_SSIZE_T)
3096   AC_MSG_RESULT(yes)
3097 else
3098   AC_MSG_RESULT(no)
3099 fi
3100 AC_STRUCT_ST_BLKSIZE
3101 AC_MSG_CHECKING(for siginfo_t)
3102 AC_CACHE_VAL(ac_cv_siginfo_t,
3103  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
3104                   #include <signal.h>],
3105                  [siginfo_t* info;],
3106                  [ac_cv_siginfo_t=true],
3107                  [ac_cv_siginfo_t=false])])
3108 if test "$ac_cv_siginfo_t" = true ; then
3109   AC_DEFINE(HAVE_SIGINFO_T)
3110   AC_MSG_RESULT(yes)
3111 else
3112   AC_MSG_RESULT(no)
3113 fi
3114
3115 dnl Find exact-width integer types, or figure them out
3116 dnl ourselves.
3117 dnl ========================================================
3118 dnl Once this is working, we can delete the code for int16_t,
3119 dnl etc. below.
3120
3121 AC_CHECK_HEADER(stdint.h)
3122 if test "$ac_cv_header_stdint_h" = yes; then
3123     AC_DEFINE(JS_HAVE_STDINT_H)
3124 else
3125     dnl We'll figure them out for ourselves.  List more likely types
3126     dnl earlier.  If we ever really encounter a size for which none of
3127     dnl the listed types are appropriate, we'll get a configure-time
3128     dnl error; just add the right answer.
3129     MOZ_N_BYTE_TYPE(JS_INT8_TYPE,  1, [char])
3130     MOZ_N_BYTE_TYPE(JS_INT16_TYPE, 2, [short int long])
3131     MOZ_N_BYTE_TYPE(JS_INT32_TYPE, 4, [int long 'long long' short])
3132     MOZ_N_BYTE_TYPE(JS_INT64_TYPE, 8, [int long 'long long'])
3133     MOZ_N_BYTE_TYPE(JS_INTPTR_TYPE, sizeof (void *),
3134                                       [int long 'long long' short])
3135 fi
3136
3137 MOZ_SIZE_OF_TYPE(JS_BYTES_PER_WORD, void*, 4 8)
3138 if test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "4"; then
3139   AC_DEFINE(JS_BITS_PER_WORD_LOG2, 5)
3140 elif test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "8"; then
3141   AC_DEFINE(JS_BITS_PER_WORD_LOG2, 6)
3142 else
3143   AC_MSG_ERROR([Unexpected JS_BYTES_PER_WORD])
3144 fi
3145
3146 MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
3147 MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14)
3148
3149 dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
3150 dnl ========================================================
3151 AC_MSG_CHECKING(for int16_t)
3152 AC_CACHE_VAL(ac_cv_int16_t,
3153  [AC_TRY_COMPILE([#include <stdio.h>
3154                   #include <sys/types.h>],
3155                  [int16_t foo = 0;],
3156                  [ac_cv_int16_t=true],
3157                  [ac_cv_int16_t=false])])
3158 if test "$ac_cv_int16_t" = true ; then
3159   AC_DEFINE(HAVE_INT16_T)
3160   AC_MSG_RESULT(yes)
3161 else
3162   AC_MSG_RESULT(no)
3163 fi
3164 AC_MSG_CHECKING(for int32_t)
3165 AC_CACHE_VAL(ac_cv_int32_t,
3166  [AC_TRY_COMPILE([#include <stdio.h>
3167                   #include <sys/types.h>],
3168                  [int32_t foo = 0;],
3169                  [ac_cv_int32_t=true],
3170                  [ac_cv_int32_t=false])])
3171 if test "$ac_cv_int32_t" = true ; then
3172   AC_DEFINE(HAVE_INT32_T)
3173   AC_MSG_RESULT(yes)
3174 else
3175   AC_MSG_RESULT(no)
3176 fi
3177 AC_MSG_CHECKING(for int64_t)
3178 AC_CACHE_VAL(ac_cv_int64_t,
3179  [AC_TRY_COMPILE([#include <stdio.h>
3180                   #include <sys/types.h>],
3181                  [int64_t foo = 0;],
3182                  [ac_cv_int64_t=true],
3183                  [ac_cv_int64_t=false])])
3184 if test "$ac_cv_int64_t" = true ; then
3185   AC_DEFINE(HAVE_INT64_T)
3186   AC_MSG_RESULT(yes)
3187 else
3188   AC_MSG_RESULT(no)
3189 fi
3190 AC_MSG_CHECKING(for int64)
3191 AC_CACHE_VAL(ac_cv_int64,
3192  [AC_TRY_COMPILE([#include <stdio.h>
3193                   #include <sys/types.h>],
3194                  [int64 foo = 0;],
3195                  [ac_cv_int64=true],
3196                  [ac_cv_int64=false])])
3197 if test "$ac_cv_int64" = true ; then
3198   AC_DEFINE(HAVE_INT64)
3199   AC_MSG_RESULT(yes)
3200 else
3201   AC_MSG_RESULT(no)
3202 fi
3203 AC_MSG_CHECKING(for uint)
3204 AC_CACHE_VAL(ac_cv_uint,
3205  [AC_TRY_COMPILE([#include <stdio.h>
3206                   #include <sys/types.h>],
3207                  [uint foo = 0;],
3208                  [ac_cv_uint=true],
3209                  [ac_cv_uint=false])])
3210 if test "$ac_cv_uint" = true ; then
3211   AC_DEFINE(HAVE_UINT)
3212   AC_MSG_RESULT(yes)
3213 else
3214   AC_MSG_RESULT(no)
3215 fi
3216 AC_MSG_CHECKING(for uint_t)
3217 AC_CACHE_VAL(ac_cv_uint_t,
3218  [AC_TRY_COMPILE([#include <stdio.h>
3219                   #include <sys/types.h>],
3220                  [uint_t foo = 0;],
3221                  [ac_cv_uint_t=true],
3222                  [ac_cv_uint_t=false])])
3223 if test "$ac_cv_uint_t" = true ; then
3224   AC_DEFINE(HAVE_UINT_T)
3225   AC_MSG_RESULT(yes)
3226 else
3227   AC_MSG_RESULT(no)
3228 fi
3229 AC_MSG_CHECKING(for uint16_t)
3230 AC_CACHE_VAL(ac_cv_uint16_t,
3231  [AC_TRY_COMPILE([#include <stdio.h>
3232                   #include <sys/types.h>],
3233                  [uint16_t foo = 0;],
3234                  [ac_cv_uint16_t=true],
3235                  [ac_cv_uint16_t=false])])
3236 if test "$ac_cv_uint16_t" = true ; then
3237   AC_DEFINE(HAVE_UINT16_T)
3238   AC_MSG_RESULT(yes)
3239 else
3240   AC_MSG_RESULT(no)
3241 fi
3242
3243 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
3244 dnl are defined when compiling C++ but not C.  Since the result of this
3245 dnl test is used only in C++, do it in C++.
3246 AC_LANG_CPLUSPLUS
3247
3248 AC_MSG_CHECKING(for uname.domainname)
3249 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
3250     [AC_TRY_COMPILE([#include <sys/utsname.h>],
3251         [ struct utsname *res; char *domain; 
3252             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
3253         [ac_cv_have_uname_domainname_field=true],
3254         [ac_cv_have_uname_domainname_field=false])])
3255
3256 if test "$ac_cv_have_uname_domainname_field" = "true"; then
3257     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
3258     AC_MSG_RESULT(yes)
3259 else
3260     AC_MSG_RESULT(no)
3261 fi
3262
3263 AC_MSG_CHECKING(for uname.__domainname)
3264 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
3265     [AC_TRY_COMPILE([#include <sys/utsname.h>],
3266         [ struct utsname *res; char *domain; 
3267             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
3268         [ac_cv_have_uname_us_domainname_field=true],
3269         [ac_cv_have_uname_us_domainname_field=false])])
3270
3271 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
3272     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
3273     AC_MSG_RESULT(yes)
3274 else
3275     AC_MSG_RESULT(no)
3276 fi
3277
3278 AC_LANG_C
3279
3280 dnl Check for .hidden assembler directive and visibility attribute.
3281 dnl Borrowed from glibc configure.in
3282 dnl ===============================================================
3283 if test "$GNU_CC"; then
3284   AC_CACHE_CHECK(for visibility(hidden) attribute,
3285                  ac_cv_visibility_hidden,
3286                  [cat > conftest.c <<EOF
3287                   int foo __attribute__ ((visibility ("hidden"))) = 1;
3288 EOF
3289                   ac_cv_visibility_hidden=no
3290                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3291                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3292                       ac_cv_visibility_hidden=yes
3293                     fi
3294                   fi
3295                   rm -f conftest.[cs]
3296                  ])
3297   if test "$ac_cv_visibility_hidden" = "yes"; then
3298     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
3299
3300     AC_CACHE_CHECK(for visibility(default) attribute,
3301                    ac_cv_visibility_default,
3302                    [cat > conftest.c <<EOF
3303                     int foo __attribute__ ((visibility ("default"))) = 1;
3304 EOF
3305                     ac_cv_visibility_default=no
3306                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3307                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3308                         ac_cv_visibility_default=yes
3309                       fi
3310                     fi
3311                     rm -f conftest.[cs]
3312                    ])
3313     if test "$ac_cv_visibility_default" = "yes"; then
3314       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
3315
3316       AC_CACHE_CHECK(for visibility pragma support,
3317                      ac_cv_visibility_pragma,
3318                      [cat > conftest.c <<EOF
3319 #pragma GCC visibility push(hidden)
3320                       int foo_hidden = 1;
3321 #pragma GCC visibility push(default)
3322                       int foo_default = 1;
3323 EOF
3324                       ac_cv_visibility_pragma=no
3325                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3326                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
3327                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
3328                             ac_cv_visibility_pragma=yes
3329                           fi
3330                         fi
3331                       fi
3332                       rm -f conftest.[cs]
3333                     ])
3334       if test "$ac_cv_visibility_pragma" = "yes"; then
3335         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
3336                        ac_cv_have_visibility_class_bug,
3337                        [cat > conftest.c <<EOF
3338 #pragma GCC visibility push(hidden)
3339 struct __attribute__ ((visibility ("default"))) TestStruct {
3340   static void Init();
3341 };
3342 __attribute__ ((visibility ("default"))) void TestFunc() {
3343   TestStruct::Init();
3344 }
3345 EOF
3346                        ac_cv_have_visibility_class_bug=no
3347                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3348                          ac_cv_have_visibility_class_bug=yes
3349                        else
3350                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
3351                            ac_cv_have_visibility_class_bug=yes
3352                          fi
3353                        fi
3354                        rm -rf conftest.{c,S}
3355                        ])
3356
3357         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
3358                        ac_cv_have_visibility_builtin_bug,
3359                        [cat > conftest.c <<EOF
3360 #pragma GCC visibility push(hidden)
3361 #pragma GCC visibility push(default)
3362 #include <string.h>
3363 #pragma GCC visibility pop
3364
3365 __attribute__ ((visibility ("default"))) void Func() {
3366   char c[[100]];
3367   memset(c, 0, sizeof(c));
3368 }
3369 EOF
3370                        ac_cv_have_visibility_builtin_bug=no
3371                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3372                          ac_cv_have_visibility_builtin_bug=yes
3373                        else
3374                          if test `grep -c "@PLT" conftest.S` = 0; then
3375                            ac_cv_visibility_builtin_bug=yes
3376                          fi
3377                        fi
3378                        rm -f conftest.{c,S}
3379                        ])
3380         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
3381                 "$ac_cv_have_visibility_class_bug" = "no"; then
3382           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers_js -include $(topsrcdir)/config/gcc_hidden.h'
3383           WRAP_SYSTEM_INCLUDES=1
3384           STL_FLAGS='-I$(DIST)/stl_wrappers'
3385           WRAP_STL_INCLUDES=1
3386         else
3387           VISIBILITY_FLAGS='-fvisibility=hidden'
3388         fi # have visibility pragma bug
3389       fi   # have visibility pragma
3390     fi     # have visibility(default) attribute
3391   fi       # have visibility(hidden) attribute
3392 fi         # GNU_CC
3393
3394 # visibility hidden flag for Sun Studio on Solaris
3395 if test "$SOLARIS_SUNPRO_CC"; then
3396 VISIBILITY_FLAGS='-xldscope=hidden'
3397 fi         # Sun Studio on Solaris
3398
3399 AC_SUBST(WRAP_SYSTEM_INCLUDES)
3400 AC_SUBST(VISIBILITY_FLAGS)
3401
3402 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
3403 dnl ========================================================
3404 if test "$GNU_CC"; then
3405   CFLAGS_save="${CFLAGS}"
3406   CFLAGS="${CFLAGS} -Werror"
3407   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
3408                  ac_cv_force_align_arg_pointer,
3409                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
3410                                  [],
3411                                  ac_cv_force_align_arg_pointer="yes",
3412                                  ac_cv_force_align_arg_pointer="no")])
3413   CFLAGS="${CFLAGS_save}"
3414   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
3415     HAVE_GCC_ALIGN_ARG_POINTER=1
3416   else
3417     HAVE_GCC_ALIGN_ARG_POINTER=
3418   fi
3419 fi
3420 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
3421
3422 dnl Checks for header files.
3423 dnl ========================================================
3424 AC_HEADER_DIRENT
3425 case "$target_os" in
3426 freebsd*)
3427 # for stuff like -lXshm
3428     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
3429     ;;
3430 esac
3431 AC_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h)
3432 AC_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h)
3433 AC_CHECK_HEADERS(gnu/libc-version.h nl_types.h)
3434 AC_CHECK_HEADERS(malloc.h)
3435 AC_CHECK_HEADERS(X11/XKBlib.h)
3436 AC_CHECK_HEADERS(io.h)
3437
3438 dnl These are all the places some variant of statfs can be hiding.
3439 AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
3440
3441 dnl Quota support
3442 AC_CHECK_HEADERS(sys/quota.h)
3443 AC_CHECK_HEADERS(linux/quota.h)
3444
3445 dnl Try for MMX support
3446 dnl NB - later gcc versions require -mmmx for this header to be successfully
3447 dnl included (or another option which implies it, such as -march=pentium-mmx)
3448 AC_CHECK_HEADERS(mmintrin.h)
3449
3450 dnl Check whether the compiler supports the new-style C++ standard
3451 dnl library headers (i.e. <new>) or needs the old "new.h"
3452 AC_LANG_CPLUSPLUS
3453 NEW_H=new.h
3454 AC_CHECK_HEADER(new, [NEW_H=new])
3455 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3456 AC_LANG_C
3457
3458 AC_ARG_ENABLE(dtrace,
3459               [  --enable-dtrace         build with dtrace support if available (default=no)],
3460               [enable_dtrace="yes"],)
3461 if test "x$enable_dtrace" = "xyes"; then
3462   AC_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3463   if test -n "$HAVE_DTRACE"; then
3464       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3465   else
3466       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3467   fi
3468 fi
3469 AC_SUBST(HAVE_DTRACE)
3470
3471 case $target in
3472 *-aix4.3*|*-aix5*)
3473         ;;
3474 *)
3475         AC_CHECK_HEADERS(sys/cdefs.h)
3476         ;;
3477 esac
3478
3479 dnl Performance measurement headers.
3480 AC_CHECK_HEADER(linux/perf_event.h, HAVE_LINUX_PERF_EVENT_H=1)
3481 AC_SUBST(HAVE_LINUX_PERF_EVENT_H)
3482
3483 dnl Checks for libraries.
3484 dnl ========================================================
3485 case $target in
3486 *-hpux11.*)
3487         ;;
3488 *)
3489         AC_CHECK_LIB(c_r, gethostbyname_r)
3490         ;;
3491 esac
3492
3493 dnl We don't want to link with libdl even if it's present on OS X, since
3494 dnl it's not used and not part of the default installation.
3495 dnl The same goes for BeOS. OS/2 has dlfcn in libc.
3496 dnl We don't want to link against libm or libpthread on Darwin since
3497 dnl they both are just symlinks to libSystem and explicitly linking
3498 dnl against libSystem causes issues when debugging (see bug 299601).
3499 case $target in
3500 *-darwin*)
3501     ;;
3502 *-beos*)
3503     ;;
3504 *-os2*)
3505     ;;
3506 *)
3507     AC_SEARCH_LIBS(dlopen, dl, 
3508         AC_CHECK_HEADER(dlfcn.h, 
3509         AC_DEFINE(HAVE_DLOPEN)))
3510     ;;
3511 esac
3512
3513 _SAVE_CFLAGS="$CFLAGS"
3514 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3515 AC_CHECK_FUNCS(dladdr)
3516 CFLAGS="$_SAVE_CFLAGS"
3517
3518 if test ! "$GNU_CXX"; then
3519
3520     case $target in
3521     *-aix*)
3522         AC_CHECK_LIB(C_r, demangle)
3523         ;;
3524      *)
3525         AC_CHECK_LIB(C, demangle)
3526         ;;
3527      esac
3528 fi
3529
3530 dnl OS/2 has socket in libc.
3531 case $target in
3532 *-os2*)
3533     ;;
3534 *)
3535     AC_CHECK_LIB(socket, socket)
3536 esac
3537
3538 AC_MSG_CHECKING(for ARM SIMD support in compiler)
3539 AC_TRY_COMPILE([],
3540                [asm("uqadd8 r1, r1, r2");],
3541                result="yes", result="no")
3542 AC_MSG_RESULT("$result")
3543 if test "$result" = "yes"; then
3544     AC_DEFINE(HAVE_ARM_SIMD)
3545     HAVE_ARM_SIMD=1
3546 fi
3547 AC_SUBST(HAVE_ARM_SIMD)
3548
3549 AC_MSG_CHECKING(for ARM NEON support in compiler)
3550 _SAVE_CFLAGS="$CFLAGS"
3551 if test "$GNU_CC"; then
3552   # gcc needs -mfpu=neon to recognize NEON instructions
3553   CFLAGS="$CFLAGS -mfpu=neon -mfloat-abi=softfp"
3554 fi
3555 AC_TRY_COMPILE([],
3556                [asm("vadd.i8 d0, d0, d0");],
3557                result="yes", result="no")
3558 AC_MSG_RESULT("$result")
3559 if test "$result" = "yes"; then
3560     AC_DEFINE(HAVE_ARM_NEON)
3561     HAVE_ARM_NEON=1
3562 fi
3563 CFLAGS="$_SAVE_CFLAGS"
3564 AC_SUBST(HAVE_ARM_NEON)
3565
3566 dnl ========================================================
3567 dnl = pthread support
3568 dnl = Start by checking whether the system support pthreads
3569 dnl ========================================================
3570 case "$target_os" in
3571 darwin*)
3572     USE_PTHREADS=1
3573     ;;
3574 *)
3575     MOZ_CHECK_PTHREADS(pthreads,
3576         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3577         MOZ_CHECK_PTHREADS(pthread,
3578             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3579             MOZ_CHECK_PTHREADS(c_r,
3580                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3581                 MOZ_CHECK_PTHREADS(c,
3582                     USE_PTHREADS=1
3583                 )
3584             )
3585         )
3586     )
3587     ;;
3588 esac
3589
3590 dnl ========================================================
3591 dnl Check the command line for --with-pthreads 
3592 dnl ========================================================
3593 MOZ_ARG_WITH_BOOL(pthreads,
3594 [  --with-pthreads         Force use of system pthread library with NSPR ],
3595 [ if test "$USE_PTHREADS"x = x; then
3596     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3597 fi],
3598     USE_PTHREADS=
3599     _PTHREAD_LDFLAGS=
3600 )
3601
3602 dnl ========================================================
3603 dnl Do the platform specific pthread hackery
3604 dnl ========================================================
3605 if test "$USE_PTHREADS"x != x
3606 then
3607         dnl
3608         dnl See if -pthread is supported.
3609         dnl
3610         rm -f conftest*
3611         ac_cv_have_dash_pthread=no
3612         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3613         echo 'int main() { return 0; }' | cat > conftest.c
3614         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3615         if test $? -eq 0; then
3616                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3617                         ac_cv_have_dash_pthread=yes
3618                 case "$target_os" in
3619                 freebsd*)
3620 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3621                 ;;
3622                 *)
3623                             CFLAGS="$CFLAGS -pthread"
3624                             CXXFLAGS="$CXXFLAGS -pthread"
3625                 ;;
3626                 esac
3627                 fi
3628         fi
3629         rm -f conftest*
3630     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3631
3632         dnl
3633         dnl See if -pthreads is supported.
3634         dnl
3635     ac_cv_have_dash_pthreads=no
3636     if test "$ac_cv_have_dash_pthread" = "no"; then
3637             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3638         echo 'int main() { return 0; }' | cat > conftest.c
3639             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3640         if test $? -eq 0; then
3641                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3642                             ac_cv_have_dash_pthreads=yes
3643                             CFLAGS="$CFLAGS -pthreads"
3644                             CXXFLAGS="$CXXFLAGS -pthreads"
3645                     fi
3646             fi
3647             rm -f conftest*
3648         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3649     fi
3650
3651         case "$target" in
3652             *-*-freebsd*)
3653                         AC_DEFINE(_REENTRANT)
3654                         AC_DEFINE(_THREAD_SAFE)
3655                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3656                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3657                                 _PTHREAD_LDFLAGS="-pthread"
3658                         else
3659                                 _PTHREAD_LDFLAGS="-lc_r"
3660                         fi
3661                         ;;
3662
3663             *-*-openbsd*|*-*-bsdi*)
3664                         AC_DEFINE(_REENTRANT)
3665                         AC_DEFINE(_THREAD_SAFE)
3666                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3667                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3668                 _PTHREAD_LDFLAGS="-pthread"
3669                         fi
3670                         ;;
3671
3672             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3673                         AC_DEFINE(_REENTRANT) 
3674                         ;;
3675
3676             *-*-nto*) 
3677                         AC_DEFINE(_REENTRANT) 
3678                         ;;
3679
3680             *-aix4.3*|*-aix5*)
3681                         AC_DEFINE(_REENTRANT) 
3682                         ;;
3683
3684             *-hpux11.*)
3685                         AC_DEFINE(_REENTRANT) 
3686                         ;;
3687
3688             alpha*-*-osf*)
3689                         AC_DEFINE(_REENTRANT)
3690                         ;;
3691
3692             *-*-solaris*) 
3693                         AC_DEFINE(_REENTRANT)
3694                         if test "$SOLARIS_SUNPRO_CC"; then
3695                                 CFLAGS="$CFLAGS -mt" 
3696                                 CXXFLAGS="$CXXFLAGS -mt" 
3697                         fi
3698                         ;;
3699         esac
3700     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3701 fi
3702
3703 dnl ========================================================
3704 dnl See if mmap sees writes
3705 dnl For cross compiling, just define it as no, which is a safe default
3706 dnl ========================================================
3707 AC_MSG_CHECKING(whether mmap() sees write()s)
3708
3709 changequote(,)
3710 mmap_test_prog='
3711     #include <stdlib.h>
3712     #include <unistd.h>
3713     #include <sys/mman.h>
3714     #include <sys/types.h>
3715     #include <sys/stat.h>
3716     #include <fcntl.h>
3717
3718     char fname[] = "conftest.file";
3719     char zbuff[1024]; /* Fractional page is probably worst case */
3720
3721     int main() {
3722         char *map;
3723         int fd;
3724         int i;
3725         unlink(fname);
3726         fd = open(fname, O_RDWR | O_CREAT, 0660);
3727         if(fd<0) return 1;
3728         unlink(fname);
3729         write(fd, zbuff, sizeof(zbuff));
3730         lseek(fd, 0, SEEK_SET);
3731         map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0);
3732         if(map==(char*)-1) return 2;
3733         for(i=0; fname[i]; i++) {
3734             int rc = write(fd, &fname[i], 1);
3735             if(map[i]!=fname[i]) return 4;
3736         }
3737         return 0;
3738     }
3739 '
3740 changequote([,])
3741
3742 AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes")
3743
3744 AC_MSG_RESULT("$result")
3745
3746 if test "$result" = "no"; then
3747     AC_DEFINE(MMAP_MISSES_WRITES)
3748 fi
3749
3750
3751 dnl Checks for library functions.
3752 dnl ========================================================
3753 AC_PROG_GCC_TRADITIONAL
3754 AC_FUNC_MEMCMP
3755 AC_CHECK_FUNCS([fchmod flockfile getc_unlocked _getc_nolock getpagesize \
3756                 lchown localtime_r lstat64 memmove random rint sbrk snprintf \
3757                 stat64 statvfs statvfs64 strerror strtok_r truncate64])
3758
3759 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock, and -lrt
3760 _SAVE_LDFLAGS=$LDFLAGS
3761 LDFLAGS="$LDFLAGS -lrt"
3762 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC) and -lrt,
3763                ac_cv_have_clock_monotonic,
3764                [AC_TRY_LINK([#include <time.h>],
3765                             [ struct timespec ts;
3766                               clock_gettime(CLOCK_MONOTONIC, &ts); ],
3767                             ac_cv_have_clock_monotonic=yes,
3768                             ac_cv_have_clock_monotonic=no)])
3769 LDFLAGS=$_SAVE_LDFLAGS
3770 if test "$ac_cv_have_clock_monotonic" = "yes"; then
3771     HAVE_CLOCK_MONOTONIC=1
3772     REALTIME_LIBS=-lrt
3773     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3774     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3775     AC_SUBST(REALTIME_LIBS)
3776 fi
3777
3778 dnl Windows functions, for mingw.
3779 AC_TRY_LINK([#include <windows.h>],
3780              [SYSTEMTIME st;FILETIME ft;SystemTimeToFileTime(&st,&ft);],
3781              ac_cv_have_systemtimetofiletime="yes",
3782              ac_cv_have_systemtimetofiletime="no")
3783 if test "$ac_cv_have_systemtimetofiletime" = "yes"; then
3784     AC_DEFINE(HAVE_SYSTEMTIMETOFILETIME)
3785 fi
3786 AC_TRY_LINK([#include <windows.h>],
3787              [FILETIME ft;GetSystemTimeAsFileTime(&ft);],
3788              ac_cv_have_getsystemtimeasfiletime="yes",
3789              ac_cv_have_getsystemtimeasfiletime="no")
3790 if test "$ac_cv_have_getsystemtimeasfiletime" = "yes"; then
3791     AC_DEFINE(HAVE_GETSYSTEMTIMEASFILETIME)
3792 fi
3793
3794 dnl check for wcrtomb/mbrtowc
3795 dnl =======================================================================
3796 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3797 AC_LANG_SAVE
3798 AC_LANG_CPLUSPLUS
3799 AC_CACHE_CHECK(for wcrtomb,
3800     ac_cv_have_wcrtomb,
3801     [AC_TRY_LINK([#include <wchar.h>],
3802                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3803                  ac_cv_have_wcrtomb="yes",
3804                  ac_cv_have_wcrtomb="no")])
3805 if test "$ac_cv_have_wcrtomb" = "yes"; then
3806     AC_DEFINE(HAVE_WCRTOMB)
3807 fi
3808 AC_CACHE_CHECK(for mbrtowc,
3809     ac_cv_have_mbrtowc,
3810     [AC_TRY_LINK([#include <wchar.h>],
3811                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3812                  ac_cv_have_mbrtowc="yes",
3813                  ac_cv_have_mbrtowc="no")])
3814 if test "$ac_cv_have_mbrtowc" = "yes"; then
3815     AC_DEFINE(HAVE_MBRTOWC)
3816 fi
3817 AC_LANG_RESTORE
3818 fi
3819
3820 AC_CACHE_CHECK(
3821     [for res_ninit()],
3822     ac_cv_func_res_ninit,
3823     [AC_TRY_LINK([
3824         #ifdef linux
3825         #define _BSD_SOURCE 1
3826         #endif
3827         #include <resolv.h>
3828         ],
3829         [int foo = res_ninit(&_res);],
3830         [ac_cv_func_res_ninit=yes],
3831         [ac_cv_func_res_ninit=no])
3832     ])
3833
3834 if test "$ac_cv_func_res_ninit" = "yes"; then
3835     AC_DEFINE(HAVE_RES_NINIT)
3836 dnl must add the link line we do something as foolish as this... dougt
3837 dnl else
3838 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3839 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3840 fi
3841
3842 AC_LANG_CPLUSPLUS
3843 AC_CACHE_CHECK(
3844     [for gnu_get_libc_version()],
3845     ac_cv_func_gnu_get_libc_version,
3846     [AC_TRY_LINK([
3847         #ifdef HAVE_GNU_LIBC_VERSION_H
3848         #include <gnu/libc-version.h>
3849         #endif
3850         ],
3851         [const char *glibc_version = gnu_get_libc_version();],
3852         [ac_cv_func_gnu_get_libc_version=yes],
3853         [ac_cv_func_gnu_get_libc_version=no] 
3854         )]
3855     )
3856
3857 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3858     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3859 fi
3860
3861 case $target_os in
3862     os2*|msvc*|mks*|cygwin*|mingw*|darwin*|wince*|winmo*|beos*)
3863         ;;
3864     *)
3865     
3866 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3867     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3868         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3869 _SAVE_LIBS=$LIBS
3870 LIBS="$LIBS $_ICONV_LIBS"
3871 AC_CACHE_CHECK(
3872     [for iconv()],
3873     ac_cv_func_iconv,
3874     [AC_TRY_LINK([
3875         #include <stdlib.h>
3876         #include <iconv.h>
3877         ],
3878         [
3879             iconv_t h = iconv_open("", "");
3880             iconv(h, NULL, NULL, NULL, NULL);
3881             iconv_close(h);
3882         ],
3883         [ac_cv_func_iconv=yes],
3884         [ac_cv_func_iconv=no] 
3885         )]
3886     )
3887 if test "$ac_cv_func_iconv" = "yes"; then
3888     AC_DEFINE(HAVE_ICONV)
3889     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3890     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3891     LIBICONV="$_ICONV_LIBS"
3892     AC_CACHE_CHECK(
3893         [for iconv() with const input],
3894         ac_cv_func_const_iconv,
3895         [AC_TRY_COMPILE([
3896             #include <stdlib.h>
3897             #include <iconv.h>
3898             ],
3899             [
3900                 const char *input = "testing";
3901                 iconv_t h = iconv_open("", "");
3902                 iconv(h, &input, NULL, NULL, NULL);
3903                 iconv_close(h);
3904             ],
3905             [ac_cv_func_const_iconv=yes],
3906             [ac_cv_func_const_iconv=no] 
3907             )]
3908         )
3909     if test "$ac_cv_func_const_iconv" = "yes"; then
3910         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3911     fi
3912 fi
3913 LIBS=$_SAVE_LIBS
3914
3915     ;;
3916 esac
3917
3918 AC_LANG_C
3919
3920 dnl **********************
3921 dnl *** va_copy checks ***
3922 dnl **********************
3923 dnl we currently check for all three va_copy possibilities, so we get
3924 dnl all results in config.log for bug reports.
3925 AC_MSG_CHECKING(for an implementation of va_copy())
3926 AC_CACHE_VAL(ac_cv_va_copy,[
3927     AC_TRY_RUN([
3928         #include <stdarg.h>
3929         void f (int i, ...) {
3930             va_list args1, args2;
3931             va_start (args1, i);
3932             va_copy (args2, args1);
3933             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3934                 exit (1);
3935             va_end (args1); va_end (args2);
3936         }
3937         int main() { f (0, 42); return 0; }],
3938         ac_cv_va_copy=yes,
3939         ac_cv_va_copy=no,
3940         ac_cv_va_copy=no
3941     )
3942 ])
3943 AC_MSG_RESULT($ac_cv_va_copy)
3944 AC_MSG_CHECKING(for an implementation of __va_copy())
3945 AC_CACHE_VAL(ac_cv___va_copy,[
3946     AC_TRY_RUN([
3947         #include <stdarg.h>
3948         void f (int i, ...) {
3949             va_list args1, args2;
3950             va_start (args1, i);
3951             __va_copy (args2, args1);
3952             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3953                 exit (1);
3954             va_end (args1); va_end (args2);
3955         }
3956         int main() { f (0, 42); return 0; }],
3957         ac_cv___va_copy=yes,
3958         ac_cv___va_copy=no,
3959         ac_cv___va_copy=no
3960     )
3961 ])
3962 AC_MSG_RESULT($ac_cv___va_copy)
3963 AC_MSG_CHECKING(whether va_lists can be copied by value)
3964 AC_CACHE_VAL(ac_cv_va_val_copy,[
3965     AC_TRY_RUN([
3966         #include <stdarg.h>
3967         void f (int i, ...) {
3968             va_list args1, args2;
3969             va_start (args1, i);
3970             args2 = args1;
3971             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3972                 exit (1);
3973             va_end (args1); va_end (args2);
3974         }
3975         int main() { f (0, 42); return 0; }],
3976         ac_cv_va_val_copy=yes,
3977         ac_cv_va_val_copy=no,
3978         ac_cv_va_val_copy=yes
3979     )
3980 ])
3981 if test "x$ac_cv_va_copy" = "xyes"; then
3982     AC_DEFINE(VA_COPY, va_copy)
3983     AC_DEFINE(HAVE_VA_COPY)
3984 elif test "x$ac_cv___va_copy" = "xyes"; then
3985     AC_DEFINE(VA_COPY, __va_copy)
3986     AC_DEFINE(HAVE_VA_COPY)
3987 fi
3988
3989 if test "x$ac_cv_va_val_copy" = "xno"; then
3990    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3991 fi
3992 AC_MSG_RESULT($ac_cv_va_val_copy)
3993
3994 dnl Check for dll-challenged libc's.
3995 dnl This check is apparently only needed for Linux.
3996 case "$target" in
3997         *-linux*)
3998             dnl ===================================================================
3999             _curdir=`pwd`
4000             export _curdir
4001             rm -rf conftest* _conftest
4002             mkdir _conftest
4003             cat >> conftest.C <<\EOF
4004 #include <stdio.h>
4005 #include <link.h>
4006 #include <dlfcn.h>
4007 #ifdef _dl_loaded
4008 void __dump_link_map(void) {
4009   struct link_map *map = _dl_loaded;
4010   while (NULL != map) {printf("0x%08x %s\n", map->l_addr, map->l_name); map = map->l_next;}
4011 }
4012 int main() {
4013   dlopen("./conftest1.so",RTLD_LAZY);
4014   dlopen("./../_conftest/conftest1.so",RTLD_LAZY);
4015   dlopen("CURDIR/_conftest/conftest1.so",RTLD_LAZY);
4016   dlopen("CURDIR/_conftest/../_conftest/conftest1.so",RTLD_LAZY);
4017   __dump_link_map();
4018 }
4019 #else
4020 /* _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).*/
4021 int main() { printf("./conftest1.so\n"); }
4022 #endif
4023 EOF
4024
4025             $PERL -p -i -e "s/CURDIR/\$ENV{_curdir}/g;" conftest.C
4026
4027             cat >> conftest1.C <<\EOF
4028 #include <stdio.h>
4029 void foo(void) {printf("foo in dll called\n");}
4030 EOF
4031             ${CXX-g++} -fPIC -c -g conftest1.C
4032             ${CXX-g++} -shared -Wl,-h -Wl,conftest1.so -o conftest1.so conftest1.o
4033             ${CXX-g++} -g conftest.C -o conftest -ldl
4034             cp -f conftest1.so conftest _conftest
4035             cd _conftest
4036             if test `./conftest | grep conftest1.so | wc -l` -gt 1
4037             then
4038                 echo
4039                 echo "*** Your libc has a bug that can result in loading the same dynamic"
4040                 echo "*** library multiple times.  This bug is known to be fixed in glibc-2.0.7-32"
4041                 echo "*** or later.  However, if you choose not to upgrade, the only effect"
4042                 echo "*** will be excessive memory usage at runtime."
4043                 echo
4044             fi
4045             cd ${_curdir}
4046             rm -rf conftest* _conftest
4047             dnl ===================================================================
4048             ;;
4049 esac
4050
4051 dnl ===================================================================
4052 dnl ========================================================
4053 dnl Put your C++ language/feature checks below
4054 dnl ========================================================
4055 AC_LANG_CPLUSPLUS
4056
4057 ARM_ABI_PREFIX=
4058 HAVE_GCC3_ABI=
4059 if test "$GNU_CC"; then
4060   if test "$CPU_ARCH" = "arm" ; then
4061     AC_CACHE_CHECK(for ARM EABI,
4062         ac_cv_gcc_arm_eabi,
4063         [AC_TRY_COMPILE([],
4064                         [
4065 #if defined(__ARM_EABI__)
4066   return 0;
4067 #else
4068 #error Not ARM EABI.
4069 #endif
4070                         ],
4071                         ac_cv_gcc_arm_eabi="yes",
4072                         ac_cv_gcc_arm_eabi="no")])
4073     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
4074         HAVE_ARM_EABI=1
4075         ARM_ABI_PREFIX=eabi-
4076     else
4077         ARM_ABI_PREFIX=oabi-
4078     fi
4079   fi
4080
4081   AC_CACHE_CHECK(for gcc 3.0 ABI,
4082       ac_cv_gcc_three_abi,
4083       [AC_TRY_COMPILE([],
4084                       [
4085 #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
4086   return 0;
4087 #else
4088 #error Not gcc3.
4089 #endif
4090                       ],
4091                       ac_cv_gcc_three_abi="yes",
4092                       ac_cv_gcc_three_abi="no")])
4093   if test "$ac_cv_gcc_three_abi" = "yes"; then
4094       TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
4095       HAVE_GCC3_ABI=1
4096   else
4097       TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc2}"
4098   fi
4099 fi
4100 AC_SUBST(HAVE_GCC3_ABI)
4101
4102
4103 AC_CACHE_CHECK(for C++ \"explicit\" keyword,
4104                ac_cv_cpp_explicit,
4105                [AC_TRY_COMPILE(class X {
4106                                public: explicit X(int i) : i_(i) {}
4107                                private: int i_;
4108                                };,
4109                                X x(3);,
4110                                ac_cv_cpp_explicit=yes,
4111                                ac_cv_cpp_explicit=no)])
4112 if test "$ac_cv_cpp_explicit" = yes ; then
4113    AC_DEFINE(HAVE_CPP_EXPLICIT)
4114 fi
4115
4116 AC_CACHE_CHECK(for C++ \"typename\" keyword,
4117                ac_cv_cpp_typename,
4118                [AC_TRY_COMPILE(class param {
4119                                public:
4120                                    typedef unsigned long num_type;
4121                                };
4122
4123                                template <class T> class tplt {
4124                                public:
4125                                    typedef typename T::num_type t_num_type;
4126                                    t_num_type foo(typename T::num_type num) {
4127                                        return num;
4128                                    }
4129                                };,
4130                                tplt<param> A;
4131                                A.foo(0);,
4132                                ac_cv_cpp_typename=yes,
4133                                ac_cv_cpp_typename=no)])
4134 if test "$ac_cv_cpp_typename" = yes ; then
4135    AC_DEFINE(HAVE_CPP_TYPENAME)
4136 fi
4137
4138 dnl Check for support of modern template specialization syntax
4139 dnl Test code and requirement from scc@netscape.com.
4140 dnl Autoconf cut-and-paste job by waterson@netscape.com
4141 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
4142                ac_cv_cpp_modern_specialize_template_syntax,
4143                [AC_TRY_COMPILE(template <class T> struct X { int a; };
4144                                class Y {};
4145                                template <> struct X<Y> { double a; };,
4146                                X<int> int_x;
4147                                X<Y> y_x;,
4148                                ac_cv_cpp_modern_specialize_template_syntax=yes,
4149                                ac_cv_cpp_modern_specialize_template_syntax=no)])
4150 if test "$ac_cv_cpp_modern_specialize_template_syntax" = yes ; then
4151   AC_DEFINE(HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX)
4152 fi
4153
4154
4155 dnl Some compilers support only full specialization, and some don't.
4156 AC_CACHE_CHECK(whether partial template specialization works,
4157                ac_cv_cpp_partial_specialization,
4158                [AC_TRY_COMPILE(template <class T> class Foo {};
4159                                template <class T> class Foo<T*> {};,
4160                                return 0;,
4161                                ac_cv_cpp_partial_specialization=yes,
4162                                ac_cv_cpp_partial_specialization=no)])
4163 if test "$ac_cv_cpp_partial_specialization" = yes ; then
4164   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
4165 fi
4166
4167 dnl Some compilers have limited support for operators with templates;
4168 dnl specifically, it is necessary to define derived operators when a base
4169 dnl class's operator declaration should suffice.
4170 AC_CACHE_CHECK(whether operators must be re-defined for templates derived from templates,
4171                ac_cv_need_derived_template_operators,
4172                [AC_TRY_COMPILE([template <class T> class Base { };
4173                                 template <class T>
4174                                 Base<T> operator+(const Base<T>& lhs, const Base<T>& rhs) { return lhs; }
4175                                 template <class T> class Derived : public Base<T> { };],
4176                                [Derived<char> a, b;
4177                                 Base<char> c = a + b;
4178                                 return 0;],
4179                                ac_cv_need_derived_template_operators=no,
4180                                ac_cv_need_derived_template_operators=yes)])
4181 if test "$ac_cv_need_derived_template_operators" = yes ; then
4182   AC_DEFINE(NEED_CPP_DERIVED_TEMPLATE_OPERATORS)
4183 fi
4184
4185
4186 dnl Some compilers have trouble detecting that a template class
4187 dnl that derives from another template is actually an instance
4188 dnl of the base class. This test checks for that.
4189 AC_CACHE_CHECK(whether we need to cast a derived template to pass as its base class,
4190                ac_cv_need_cpp_template_cast_to_base,
4191                [AC_TRY_COMPILE([template <class T> class Base { };
4192                                 template <class T> class Derived : public Base<T> { };
4193                                 template <class T> int foo(const Base<T>&) { return 0; }],
4194                                [Derived<char> bar; return foo(bar);],
4195                                ac_cv_need_cpp_template_cast_to_base=no,
4196                                ac_cv_need_cpp_template_cast_to_base=yes)])
4197 if test "$ac_cv_need_cpp_template_cast_to_base" = yes ; then
4198   AC_DEFINE(NEED_CPP_TEMPLATE_CAST_TO_BASE)
4199 fi
4200
4201 dnl Some compilers have trouble resolving the ambiguity between two
4202 dnl functions whose arguments differ only by cv-qualifications.
4203 AC_CACHE_CHECK(whether the compiler can resolve const ambiguities for templates,
4204                ac_cv_can_resolve_const_ambiguity,
4205                [AC_TRY_COMPILE([
4206                                 template <class T> class ptrClass {
4207                                   public: T* ptr;
4208                                 };
4209
4210                                 template <class T> T* a(ptrClass<T> *arg) {
4211                                   return arg->ptr;
4212                                 }
4213
4214                                 template <class T>
4215                                 const T* a(const ptrClass<T> *arg) {
4216                                   return arg->ptr;
4217                                 }
4218                                ],
4219                                [ ptrClass<int> i;
4220                                  a(&i); ],
4221                                ac_cv_can_resolve_const_ambiguity=yes,
4222                                ac_cv_can_resolve_const_ambiguity=no)])
4223 if test "$ac_cv_can_resolve_const_ambiguity" = no ; then
4224   AC_DEFINE(CANT_RESOLVE_CPP_CONST_AMBIGUITY)
4225 fi
4226
4227 dnl
4228 dnl We don't do exceptions on unix.  The only reason this used to be here
4229 dnl is that mozilla/xpcom/tests/TestCOMPtr.cpp has a test which uses 
4230 dnl exceptions.  But, we turn exceptions off by default and this test breaks.
4231 dnl So im commenting this out until someone writes some artificial 
4232 dnl intelligence to detect not only if the compiler has exceptions, but if 
4233 dnl they are enabled as well.
4234 dnl 
4235 dnl AC_CACHE_CHECK(for C++ \"exceptions\",
4236 dnl                ac_cv_cpp_exceptions,
4237 dnl                [AC_TRY_COMPILE(class X { public: X() {} };
4238 dnl                                static void F() { throw X(); },
4239 dnl                                try { F(); } catch(X & e) { },
4240 dnl                                ac_cv_cpp_exceptions=yes,
4241 dnl                                ac_cv_cpp_exceptions=no)])
4242 dnl if test $ac_cv_cpp_exceptions = yes ; then
4243 dnl    AC_DEFINE(HAVE_CPP_EXCEPTIONS)
4244 dnl fi
4245
4246 dnl Some compilers have marginal |using| support; for example, gcc-2.7.2.3
4247 dnl supports it well enough to allow us to use it to change access, but not
4248 dnl to resolve ambiguity. The next two tests determine how well the |using|
4249 dnl keyword is supported.
4250 dnl
4251 dnl Check to see if we can change access with |using|.  Test both a
4252 dnl legal and an illegal example.
4253 AC_CACHE_CHECK(whether the C++ \"using\" keyword can change access,
4254                ac_cv_cpp_access_changing_using2,
4255                [AC_TRY_COMPILE(
4256                    class A { protected: int foo() { return 0; } };
4257                    class B : public A { public: using A::foo; };,
4258                    B b; return b.foo();,
4259                    [AC_TRY_COMPILE(
4260                        class A { public: int foo() { return 1; } };
4261                        class B : public A { private: using A::foo; };,
4262                        B b; return b.foo();,
4263                        ac_cv_cpp_access_changing_using2=no,
4264                        ac_cv_cpp_access_changing_using2=yes)],
4265                    ac_cv_cpp_access_changing_using2=no)])
4266 if test "$ac_cv_cpp_access_changing_using2" = yes ; then
4267    AC_DEFINE(HAVE_CPP_ACCESS_CHANGING_USING)
4268 fi
4269
4270 dnl Check to see if we can resolve ambiguity with |using|.
4271 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
4272                ac_cv_cpp_ambiguity_resolving_using,
4273                [AC_TRY_COMPILE(class X { 
4274                                  public: int go(const X&) {return 3;}
4275                                          int jo(const X&) {return 3;}
4276                                };
4277                                class Y : public X {
4278                                  public:  int go(int) {return 2;}
4279                                           int jo(int) {return 2;}
4280                                           using X::jo;
4281                                  private: using X::go;
4282                                };,
4283                                X x; Y y; y.jo(x);,
4284                                ac_cv_cpp_ambiguity_resolving_using=yes,
4285                                ac_cv_cpp_ambiguity_resolving_using=no)])
4286 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
4287    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
4288 fi
4289
4290 dnl Check to see if the |std| namespace is supported. If so, we'll want
4291 dnl to qualify any standard library calls with "std::" to ensure that
4292 dnl those functions can be resolved.
4293 AC_CACHE_CHECK(for \"std::\" namespace,
4294                ac_cv_cpp_namespace_std,
4295                [AC_TRY_COMPILE([#include <algorithm>],
4296                                [return std::min(0, 1);],
4297                                ac_cv_cpp_namespace_std=yes,
4298                                ac_cv_cpp_namespace_std=no)])
4299 if test "$ac_cv_cpp_namespace_std" = yes ; then
4300    AC_DEFINE(HAVE_CPP_NAMESPACE_STD)
4301 fi
4302
4303 dnl Older compilers are overly ambitious with respect to using the standard
4304 dnl template library's |operator!=()| when |operator==()| is defined. In
4305 dnl which case, defining |operator!=()| in addition to |operator==()| causes
4306 dnl ambiguity at compile-time. This test checks for that case.
4307 AC_CACHE_CHECK(whether standard template operator!=() is ambiguous,
4308                ac_cv_cpp_unambiguous_std_notequal,
4309                [AC_TRY_COMPILE([#include <algorithm>
4310                                 struct T1 {};
4311                                 int operator==(const T1&, const T1&) { return 0; }
4312                                 int operator!=(const T1&, const T1&) { return 0; }],
4313                                [T1 a,b; return a != b;],
4314                                ac_cv_cpp_unambiguous_std_notequal=unambiguous,
4315                                ac_cv_cpp_unambiguous_std_notequal=ambiguous)])
4316 if test "$ac_cv_cpp_unambiguous_std_notequal" = unambiguous ; then
4317   AC_DEFINE(HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL)
4318 fi
4319
4320
4321 AC_CACHE_CHECK(for C++ reinterpret_cast,
4322                ac_cv_cpp_reinterpret_cast,
4323                [AC_TRY_COMPILE(struct X { int i; };
4324                                struct Y { int i; };,
4325                                X x; X*const z = &x;Y*y = reinterpret_cast<Y*>(z);,
4326                                ac_cv_cpp_reinterpret_cast=yes,
4327                                ac_cv_cpp_reinterpret_cast=no)])
4328 if test "$ac_cv_cpp_reinterpret_cast" = yes ; then
4329    AC_DEFINE(HAVE_CPP_NEW_CASTS)
4330 fi
4331
4332 dnl See if a dynamic_cast to void* gives the most derived object.
4333 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
4334                ac_cv_cpp_dynamic_cast_void_ptr,
4335                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
4336                             class Y { int j; public: virtual ~Y() { } };
4337                             class Z : public X, public Y { int k; };
4338
4339                             int main() {
4340                                  Z mdo;
4341                                  X *subx = (X*)&mdo;
4342                                  Y *suby = (Y*)&mdo;
4343                                  return !((((void*)&mdo != (void*)subx) &&
4344                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
4345                                           (((void*)&mdo != (void*)suby) &&
4346                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
4347                             }],
4348                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
4349                            ac_cv_cpp_dynamic_cast_void_ptr=no,
4350                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
4351 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
4352    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
4353 fi
4354
4355
4356 dnl note that this one is reversed - if the test fails, then
4357 dnl we require implementations of unused virtual methods. Which
4358 dnl really blows because it means we'll have useless vtable
4359 dnl bloat.
4360 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
4361                ac_cv_cpp_unused_required,
4362                [AC_TRY_LINK(class X {private: virtual void never_called();};,
4363                                X x;,
4364                                ac_cv_cpp_unused_required=no,
4365                                ac_cv_cpp_unused_required=yes)])
4366 if test "$ac_cv_cpp_unused_required" = yes ; then
4367    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
4368 fi
4369
4370
4371 dnl Some compilers have trouble comparing a constant reference to a templatized
4372 dnl class to zero, and require an explicit operator==() to be defined that takes
4373 dnl an int. This test separates the strong from the weak.
4374
4375 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
4376                ac_cv_trouble_comparing_to_zero,
4377                [AC_TRY_COMPILE([#include <algorithm>
4378                                 template <class T> class Foo {};
4379                                 class T2;
4380                                 template <class T> int operator==(const T2*, const T&) { return 0; }
4381                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
4382                                [Foo<int> f; return (0 != f);],
4383                                ac_cv_trouble_comparing_to_zero=no,
4384                                ac_cv_trouble_comparing_to_zero=yes)])
4385 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
4386   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
4387 fi
4388
4389 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
4390 _SAVE_LDFLAGS=$LDFLAGS
4391 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS"
4392 AC_CACHE_CHECK(for __thread keyword for TLS variables,
4393                ac_cv_thread_keyword,
4394                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
4395                             [return tlsIsMainThread;],
4396                             ac_cv_thread_keyword=yes,
4397                             ac_cv_thread_keyword=no)])
4398 LDFLAGS=$_SAVE_LDFLAGS
4399 if test "$ac_cv_thread_keyword" = yes; then
4400   # mips builds fail with TLS variables because of a binutils bug.
4401   # See bug 528687
4402   case "${target}" in
4403     mips*-*)
4404       :
4405       ;;
4406     *-android*)
4407       :
4408       ;;
4409     *)
4410       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
4411       ;;
4412   esac
4413 fi
4414
4415 dnl Check for the existence of various allocation headers/functions
4416
4417 MALLOC_H=
4418 AC_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
4419 if test "$MALLOC_H" = ""; then
4420   AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
4421   if test "$MALLOC_H" = ""; then
4422     AC_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
4423   fi
4424 fi
4425 if test "$MALLOC_H" != ""; then
4426    AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
4427 fi
4428
4429 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
4430 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
4431
4432 dnl See if compiler supports some gcc-style attributes
4433
4434 AC_CACHE_CHECK(for __attribute__((always_inline)),
4435                ac_cv_attribute_always_inline,
4436                [AC_TRY_COMPILE([],
4437                                [inline void f(void) __attribute__((always_inline));],
4438                                ac_cv_attribute_always_inline=yes,
4439                                ac_cv_attribute_always_inline=no)])
4440
4441 AC_CACHE_CHECK(for __attribute__((malloc)),
4442                ac_cv_attribute_malloc,
4443                [AC_TRY_COMPILE([],
4444                                [void* f(int) __attribute__((malloc));],
4445                                ac_cv_attribute_malloc=yes,
4446                                ac_cv_attribute_malloc=no)])
4447
4448 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
4449                ac_cv_attribute_warn_unused,
4450                [AC_TRY_COMPILE([],
4451                                [int f(void) __attribute__((warn_unused_result));],
4452                                ac_cv_attribute_warn_unused=yes,
4453                                ac_cv_attribute_warn_unused=no)])
4454
4455 AC_CACHE_CHECK(for __attribute__((noreturn)),
4456                ac_cv_attribute_noreturn,
4457                [AC_TRY_COMPILE([],
4458                                [void f(void) __attribute__((noreturn));],
4459                                ac_cv_attribute_noreturn=yes,
4460                                ac_cv_attribute_noreturn=no)])
4461  
4462 dnl End of C++ language/feature checks
4463 AC_LANG_C
4464
4465 dnl ========================================================
4466 dnl =  Internationalization checks
4467 dnl ========================================================
4468 dnl
4469 dnl Internationalization and Locale support is different
4470 dnl on various UNIX platforms.  Checks for specific i18n
4471 dnl features go here.
4472
4473 dnl check for LC_MESSAGES
4474 AC_CACHE_CHECK(for LC_MESSAGES,
4475                 ac_cv_i18n_lc_messages,
4476                 [AC_TRY_COMPILE([#include <locale.h>],
4477                                 [int category = LC_MESSAGES;],
4478                                 ac_cv_i18n_lc_messages=yes,
4479                                 ac_cv_i18n_lc_messages=no)])
4480 if test "$ac_cv_i18n_lc_messages" = yes; then
4481    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
4482 fi
4483
4484 AC_HAVE_FUNCS(localeconv)
4485
4486 fi # SKIP_COMPILER_CHECKS
4487
4488 TARGET_XPCOM_ABI=
4489 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
4490     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
4491 fi
4492
4493 dnl Mozilla specific options
4494 dnl ========================================================
4495 dnl The macros used for command line options
4496 dnl are defined in build/autoconf/altoptions.m4.
4497
4498 dnl If the compiler supports these attributes, define them as
4499 dnl convenience macros.
4500 if test "$ac_cv_attribute_always_inline" = yes ; then
4501   AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
4502 else
4503   AC_DEFINE(NS_ALWAYS_INLINE,)
4504 fi
4505
4506 if test "$ac_cv_attribute_malloc" = yes ; then
4507   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
4508 else
4509   AC_DEFINE(NS_ATTR_MALLOC,)
4510 fi
4511
4512 if test "$ac_cv_attribute_warn_unused" = yes ; then
4513   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
4514 else
4515   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
4516 fi
4517
4518 if test "$ac_cv_attribute_noreturn" = yes ; then
4519   AC_DEFINE(NS_NORETURN, [__attribute__((noreturn))])
4520 else
4521   AC_DEFINE(NS_NORETURN,)
4522 fi
4523
4524 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
4525 dnl features that Windows actually does support.
4526
4527 if test -n "$SKIP_COMPILER_CHECKS"; then
4528    dnl Windows has malloc.h
4529    AC_DEFINE(MALLOC_H, [<malloc.h>])
4530    AC_DEFINE(HAVE_FORCEINLINE)
4531    AC_DEFINE(HAVE_LOCALECONV)
4532 fi # SKIP_COMPILER_CHECKS
4533
4534 dnl ========================================================
4535 dnl =
4536 dnl = Check for external package dependencies
4537 dnl =
4538 dnl ========================================================
4539 MOZ_ARG_HEADER(External Packages)
4540
4541 dnl ========================================================
4542 dnl = Find the right NSPR to use.
4543 dnl ========================================================
4544 MOZ_ARG_WITH_BOOL(system-nspr,
4545 [  --with-system-nspr      Use an NSPR that is already built and installed.
4546                           Use the 'nspr-config' script in the current path,
4547                           or look for the script in the directories given with
4548                           --with-nspr-exec-prefix or --with-nspr-prefix.
4549                           (Those flags are only checked if you specify
4550                           --with-system-nspr.)],
4551     _USE_SYSTEM_NSPR=1 )
4552
4553 MOZ_ARG_WITH_STRING(nspr-cflags,
4554 [  --with-nspr-cflags=FLAGS
4555                           Pass FLAGS to CC when building code that uses NSPR.
4556                           Use this when there's no accurate nspr-config
4557                           script available.  This is the case when building
4558                           SpiderMonkey as part of the Mozilla tree: the
4559                           top-level configure script computes NSPR flags
4560                           that accomodate the quirks of that environment.],
4561     NSPR_CFLAGS=$withval)
4562 MOZ_ARG_WITH_STRING(nspr-libs,
4563 [  --with-nspr-libs=LIBS   Pass LIBS to LD when linking code that uses NSPR.
4564                           See --with-nspr-cflags for more details.],
4565     NSPR_LIBS=$withval)
4566 AC_SUBST(NSPR_CFLAGS)
4567 AC_SUBST(NSPR_LIBS)
4568
4569 dnl Pass either --with-system-nspr or (--with-nspr-cflags and
4570 dnl --with-nspr-libs), but not both.
4571 if test "$_USE_SYSTEM_NSPR" && (test "$NSPR_CFLAGS" -o "$NSPR_LIBS"); then
4572     AC_MSG_ERROR([--with-system-nspr and --with-nspr-libs/cflags are mutually exclusive.
4573 See 'configure --help'.])
4574 fi
4575
4576 dnl Top-level Mozilla switched to requiring NSPR 4.8.6 (bug 560582), but we don't need it in JS.
4577 if test -n "$_USE_SYSTEM_NSPR"; then
4578     MOZ_NATIVE_NSPR=
4579     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])])
4580 fi
4581
4582 if test -n "$MOZ_NATIVE_NSPR"; then
4583     _SAVE_CFLAGS=$CFLAGS
4584     CFLAGS="$CFLAGS $NSPR_CFLAGS"
4585     AC_TRY_COMPILE([#include "prlog.h"],
4586                 [#ifndef PR_STATIC_ASSERT
4587                  #error PR_STATIC_ASSERT not defined
4588                  #endif],
4589                 [MOZ_NATIVE_NSPR=1],
4590                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
4591     CFLAGS=$_SAVE_CFLAGS
4592 fi
4593
4594 dnl ========================================================
4595 dnl =
4596 dnl = Application
4597 dnl =
4598 dnl ========================================================
4599
4600 MOZ_ARG_HEADER(Application)
4601
4602 BUILD_STATIC_LIBS=
4603 ENABLE_TESTS=1
4604
4605 MOZ_THUMB2=
4606 USE_ARM_KUSER=
4607
4608 case "${target}" in
4609     arm-android-eabi)
4610         USE_ARM_KUSER=1
4611         MOZ_THUMB2=1
4612         ;;
4613 esac
4614
4615 dnl ========================================================
4616 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4617 dnl their usage and use them in spidermonkey.
4618 dnl ========================================================
4619 MOZ_ARG_WITH_BOOL(arm-kuser,
4620 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4621     USE_ARM_KUSER=1,)
4622 if test -n "$USE_ARM_KUSER"; then
4623    AC_DEFINE(USE_ARM_KUSER)
4624 fi
4625
4626 dnl ========================================================
4627 dnl =
4628 dnl = Components & Features
4629 dnl = 
4630 dnl ========================================================
4631 MOZ_ARG_HEADER(Components and Features)
4632
4633 dnl ========================================================
4634 dnl = Localization
4635 dnl ========================================================
4636 MOZ_ARG_ENABLE_STRING(ui-locale,
4637 [  --enable-ui-locale=ab-CD
4638                           Select the user interface locale (default: en-US)],
4639     MOZ_UI_LOCALE=$enableval )
4640 AC_SUBST(MOZ_UI_LOCALE)
4641
4642 dnl ========================================================
4643 dnl build the tests by default
4644 dnl ========================================================
4645 MOZ_ARG_DISABLE_BOOL(tests,
4646 [  --disable-tests         Do not build test libraries & programs],
4647     ENABLE_TESTS=,
4648     ENABLE_TESTS=1 )
4649
4650 dnl ========================================================
4651 dnl =
4652 dnl = Module specific options
4653 dnl =
4654 dnl ========================================================
4655 MOZ_ARG_HEADER(Individual module options)
4656
4657 dnl Setup default CPU arch for arm target
4658 case "$target_cpu" in
4659   arm*)
4660     MOZ_ARM_ARCH=armv7
4661   ;;
4662 esac
4663 dnl ========================================================
4664 dnl = Enable building the Thumb2 instruction set
4665 dnl ========================================================
4666 MOZ_ARG_ENABLE_BOOL(thumb2,
4667  [  --enable-thumb2         Enable Thumb2 instruction set (implies ARMv7)],
4668     MOZ_THUMB2=1,
4669     MOZ_THUMB2=)
4670 if test -n "$MOZ_THUMB2"; then
4671   MOZ_ARM_ARCH=armv7
4672 fi
4673
4674 dnl ========================================================
4675 dnl = Enable building for ARM specific CPU features
4676 dnl ========================================================
4677 MOZ_ARG_WITH_STRING(cpu-arch,
4678 [  --with-cpu-arch=arch      Use specific arm architecture CPU features, default armv7],
4679     MOZ_ARM_ARCH=$withval)
4680
4681 if test -n "$MOZ_THUMB2"; then
4682   case "$target_cpu" in
4683     arm*)
4684       if test "$MOZ_ARM_ARCH" != "armv7"; then
4685         AC_MSG_ERROR([--enable-thumb2 is not compatible with cpu-arch=$MOZ_ARM_ARCH])
4686       fi
4687       if test "$GNU_CC"; then
4688         AC_DEFINE(MOZ_THUMB2)
4689         AC_DEFINE(MOZ_ARM_ARCH)
4690         CFLAGS="$CFLAGS -march=armv7-a -mthumb -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
4691         CXXFLAGS="$CXXFLAGS -march=armv7-a -mthumb -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
4692         ASFLAGS="$ASFLAGS -march=armv7-a -mthumb -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
4693       else
4694         AC_MSG_ERROR([--enable-thumb2 is not supported for non-GNU toolchains])
4695       fi
4696     ;;
4697     *)
4698       AC_MSG_ERROR([--enable-thumb2 is not supported for non-ARM CPU architectures])
4699     ;;
4700   esac
4701 elif test "$MOZ_ARM_ARCH" = "armv7"; then
4702   case "$target_cpu" in
4703     arm*)
4704       if test "$GNU_CC"; then
4705         AC_DEFINE(MOZ_ARM_ARCH)
4706         CFLAGS="$CFLAGS -march=armv7-a -marm -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
4707         CXXFLAGS="$CXXFLAGS -march=armv7-a -marm -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
4708         ASFLAGS="$ASFLAGS -march=armv7-a -marm -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
4709       else
4710         AC_MSG_ERROR([--with-cpu-arch=armv7 is not supported for non-GNU toolchains])
4711       fi
4712     ;;
4713     *)
4714       AC_MSG_ERROR([--with-cpu-arch=armv7 is not supported for non-ARM CPU architectures])
4715     ;;
4716   esac
4717 else
4718   case "$target_cpu" in
4719     arm*)
4720       if test "$GNU_CC"; then
4721         CFLAGS="$CFLAGS -march=armv5te -mthumb-interwork -msoft-float"
4722         CXXFLAGS="$CXXFLAGS -march=armv5te -mthumb-interwork -msoft-float"
4723         ASFLAGS="$ASFLAGS -march=armv5te -mthumb-interwork -msoft-float"
4724       fi
4725       ;;
4726   esac
4727 fi
4728
4729 AC_SUBST(MOZ_THUMB2)
4730 AC_SUBST(MOZ_ARM_ARCH)
4731
4732 dnl ========================================================
4733 dnl =
4734 dnl = Debugging Options
4735 dnl = 
4736 dnl ========================================================
4737 MOZ_ARG_HEADER(Debugging and Optimizations)
4738
4739 dnl ========================================================
4740 dnl = Disable building with debug info.
4741 dnl = Debugging is OFF by default
4742 dnl ========================================================
4743 if test -z "$MOZ_DEBUG_FLAGS"; then
4744   MOZ_DEBUG_FLAGS="-g"
4745 fi
4746
4747 MOZ_ARG_ENABLE_STRING(debug,
4748 [  --enable-debug[=DBG]    Enable building with developer debug info
4749                            (using compiler flags DBG)],
4750 [ if test "$enableval" != "no"; then
4751     MOZ_DEBUG=1
4752     if test -n "$enableval" -a "$enableval" != "yes"; then
4753         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
4754         _MOZ_DEBUG_FLAGS_SET=1
4755     fi
4756   else
4757     MOZ_DEBUG=
4758   fi ],
4759   MOZ_DEBUG=)
4760
4761 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
4762 MOZ_ARG_WITH_STRING(debug-label,
4763 [  --with-debug-label=LABELS
4764                           Define DEBUG_<value> for each comma-separated
4765                           value given.],
4766 [ for option in `echo $withval | sed 's/,/ /g'`; do
4767     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
4768 done])
4769
4770 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
4771
4772 if test -n "$MOZ_DEBUG"; then
4773     AC_MSG_CHECKING([for valid debug flags])
4774     _SAVE_CFLAGS=$CFLAGS
4775     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
4776     AC_TRY_COMPILE([#include <stdio.h>], 
4777         [printf("Hello World\n");],
4778         _results=yes,
4779         _results=no)
4780     AC_MSG_RESULT([$_results])
4781     if test "$_results" = "no"; then
4782         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
4783     fi
4784     CFLAGS=$_SAVE_CFLAGS
4785 fi
4786
4787 dnl ========================================================
4788 dnl = Enable code optimization. ON by default.
4789 dnl ========================================================
4790 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
4791         MOZ_OPTIMIZE_FLAGS="-O"
4792 fi
4793
4794 MOZ_ARG_ENABLE_STRING(optimize,
4795 [  --disable-optimize      Disable compiler optimization
4796   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
4797 [ if test "$enableval" != "no"; then
4798     MOZ_OPTIMIZE=1
4799     if test -n "$enableval" -a "$enableval" != "yes"; then
4800         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
4801         MOZ_OPTIMIZE=2
4802     fi
4803 else
4804     MOZ_OPTIMIZE=
4805 fi ], MOZ_OPTIMIZE=1)
4806
4807 if test "$COMPILE_ENVIRONMENT"; then
4808 if test -n "$MOZ_OPTIMIZE"; then
4809     AC_MSG_CHECKING([for valid optimization flags])
4810     _SAVE_CFLAGS=$CFLAGS
4811     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
4812     AC_TRY_COMPILE([#include <stdio.h>], 
4813         [printf("Hello World\n");],
4814         _results=yes,
4815         _results=no)
4816     AC_MSG_RESULT([$_results])
4817     if test "$_results" = "no"; then
4818         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
4819     fi
4820     CFLAGS=$_SAVE_CFLAGS
4821 fi
4822 fi # COMPILE_ENVIRONMENT
4823
4824 AC_SUBST(MOZ_OPTIMIZE)
4825 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
4826 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
4827 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
4828
4829 dnl ========================================================
4830 dnl = (Deprecated) generation of debugger info for specific modules
4831 dnl ========================================================
4832 MOZ_ARG_ENABLE_STRING(debugger-info-modules,
4833 [  --enable-debugger-info-modules
4834                           Enable/disable debugger info for specific modules],
4835 [ if test "$enableval" != "no"; then
4836     AC_MSG_WARN([--enable-debugger-info-modules is deprecated, use --enable-debug-symbols instead])
4837     MOZ_DEBUG_SYMBOLS=1
4838   fi ])
4839
4840 dnl ========================================================
4841 dnl = Enable generation of debug symbols
4842 dnl ========================================================
4843 MOZ_ARG_ENABLE_STRING(debug-symbols,
4844 [  --enable-debug-symbols[=DBG]
4845                           Enable debugging symbols (using compiler flags DBG)],
4846 [ if test "$enableval" != "no"; then
4847       MOZ_DEBUG_SYMBOLS=1
4848       if test -n "$enableval" -a "$enableval" != "yes"; then
4849           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
4850               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
4851           else
4852               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
4853           fi
4854       fi
4855   fi ])
4856
4857 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
4858     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
4859     export MOZ_DEBUG_SYMBOLS
4860 fi
4861
4862 dnl ========================================================
4863 dnl = Disable any treating of compile warnings as errors
4864 dnl ========================================================
4865 MOZ_ARG_DISABLE_BOOL(warnings-as-errors,
4866 [  --disable-warnings-as-errors
4867                           Disable treating of warnings as errors],
4868     MOZ_DISABLE_WARNINGS_AS_ERRORS=1,
4869     MOZ_DISABLE_WARNINGS_AS_ERRORS= )
4870 if test "$MOZ_DISABLE_WARNINGS_AS_ERRORS"; then
4871    WARNINGS_AS_ERRORS=''
4872 fi
4873
4874 dnl = Enable trace malloc
4875 dnl ========================================================
4876 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
4877 MOZ_ARG_ENABLE_BOOL(trace-malloc,
4878 [  --enable-trace-malloc   Enable malloc tracing],
4879     NS_TRACE_MALLOC=1,
4880     NS_TRACE_MALLOC= )
4881 if test "$NS_TRACE_MALLOC"; then
4882   # Please, Mr. Linker Man, don't take away our symbol names
4883   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
4884   AC_DEFINE(NS_TRACE_MALLOC)
4885 fi
4886 AC_SUBST(NS_TRACE_MALLOC)
4887
4888 dnl ========================================================
4889 dnl = Enable jemalloc
4890 dnl ========================================================
4891 MOZ_ARG_ENABLE_BOOL(jemalloc,
4892 [  --enable-jemalloc       Replace memory allocator with jemalloc],
4893     MOZ_MEMORY=1,
4894     MOZ_MEMORY=)
4895
4896 if test "$NS_TRACE_MALLOC"; then
4897     MOZ_MEMORY=
4898 fi
4899
4900 if test "$MOZ_MEMORY"; then
4901
4902   dnl Don't try to run compiler tests on Windows  
4903   if test "$OS_ARCH" = "WINNT"; then
4904     if test -z "$HAVE_64BIT_OS"; then
4905       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
4906     else
4907       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
4908     fi
4909   else
4910     AC_CHECK_SIZEOF([int *], [4])
4911     case "${ac_cv_sizeof_int_p}" in
4912     4)
4913       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
4914       ;;
4915     8)
4916       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
4917       ;;
4918     *)
4919       AC_MSG_ERROR([Unexpected pointer size])
4920       ;;
4921     esac
4922   fi
4923
4924   AC_DEFINE(MOZ_MEMORY)
4925   if test "x$MOZ_DEBUG" = "x1"; then
4926     AC_DEFINE(MOZ_MEMORY_DEBUG)
4927   fi
4928   dnl The generic feature tests that determine how to compute ncpus are long and
4929   dnl complicated.  Therefore, simply define special cpp variables for the
4930   dnl platforms we have special knowledge of.
4931   case "${target}" in
4932   *-darwin*)
4933     AC_DEFINE(MOZ_MEMORY_DARWIN)
4934     ;;
4935   *-*freebsd*)
4936     AC_DEFINE(MOZ_MEMORY_BSD)
4937     ;;
4938   *-*linux*)
4939     AC_DEFINE(MOZ_MEMORY_LINUX)
4940     ;;
4941   *-netbsd*)
4942     AC_DEFINE(MOZ_MEMORY_BSD)
4943     ;;
4944   *-solaris*)
4945     AC_DEFINE(MOZ_MEMORY_SOLARIS)
4946     ;;
4947   *-msvc*|*-mks*|*-cygwin*|*-mingw*)
4948     AC_DEFINE(MOZ_MEMORY_WINDOWS)
4949     # the interesting bits will get passed down in MOZ_MEMORY_LDFLAGS
4950     ;;
4951   *-*wince)
4952     AC_DEFINE(MOZ_MEMORY_WINCE)
4953     AC_DEFINE(MOZ_MEMORY_WINDOWS)
4954     if test -z "$WINCE_WINDOWS_MOBILE"; then
4955       AC_DEFINE(MOZ_MEMORY_WINCE6)
4956     fi
4957     ;;
4958   *-*winmo)
4959     AC_DEFINE(MOZ_MEMORY_WINCE)
4960     AC_DEFINE(MOZ_MEMORY_WINDOWS)
4961     ;;
4962   *-android*)
4963     AC_DEFINE(MOZ_MEMORY_LINUX)
4964     AC_DEFINE(MOZ_MEMORY_ANDROID)
4965     ;;
4966   *)
4967     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
4968     ;;
4969   esac
4970
4971   if test "$OS_ARCH" != "Darwin"; then
4972     dnl NB: this must be kept in sync with jemalloc.h
4973     AC_DEFINE(HAVE_JEMALLOC_VALLOC)
4974     AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
4975     AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
4976   fi
4977 fi
4978 AC_SUBST(MOZ_MEMORY)
4979 AC_SUBST(MOZ_MEMORY_LDFLAGS)
4980
4981 dnl ========================================================
4982 dnl = Use malloc wrapper lib
4983 dnl ========================================================
4984 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
4985 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
4986     _WRAP_MALLOC=1,
4987     _WRAP_MALLOC= )
4988
4989 if test -n "$_WRAP_MALLOC"; then
4990     if test "$GNU_CC"; then
4991     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"
4992     MKSHLIB='$(CXX) $(DSO_LDOPTS) $(WRAP_MALLOC_CFLAGS) $(WRAP_MALLOC_LIB) -o $@'
4993     fi
4994 fi
4995
4996 dnl ========================================================
4997 dnl = Location of malloc wrapper lib
4998 dnl ========================================================
4999 MOZ_ARG_WITH_STRING(wrap-malloc,
5000 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
5001     WRAP_MALLOC_LIB=$withval)
5002
5003 dnl ========================================================
5004 dnl = Use JS Call tracing
5005 dnl ========================================================
5006 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
5007 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
5008     MOZ_TRACE_JSCALLS=1,
5009     MOZ_TRACE_JSCALLS= )
5010 if test -n "$MOZ_TRACE_JSCALLS"; then
5011     AC_DEFINE(MOZ_TRACE_JSCALLS)
5012 fi
5013
5014 dnl ========================================================
5015 dnl = Use TraceVis
5016 dnl ========================================================
5017 MOZ_ARG_ENABLE_BOOL(tracevis,
5018 [  --enable-tracevis       Enable TraceVis tracing tool (default=no)],
5019     MOZ_TRACEVIS=1,
5020     MOZ_TRACEVIS= )
5021 if test -n "$MOZ_TRACEVIS"; then
5022     AC_DEFINE(MOZ_TRACEVIS)
5023     if test -z "$ENABLE_TRACEJIT"; then
5024        AC_MSG_ERROR([--enable-tracevis is incompatible with --disable-tracejit])
5025     fi
5026 fi
5027
5028 dnl ========================================================
5029 dnl = Use GCTimer
5030 dnl ========================================================
5031 MOZ_ARG_ENABLE_BOOL(gctimer,
5032 [  --enable-gctimer        Enable GC timer (default=no)],
5033     MOZ_GCTIMER=1,
5034     MOZ_GCTIMER= )
5035 if test -n "$MOZ_GCTIMER"; then
5036     AC_DEFINE(MOZ_GCTIMER)
5037 fi
5038
5039 dnl ========================================================
5040 dnl = Use Valgrind
5041 dnl ========================================================
5042 MOZ_ARG_ENABLE_BOOL(valgrind,
5043 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
5044     MOZ_VALGRIND=1,
5045     MOZ_VALGRIND= )
5046 if test -n "$MOZ_VALGRIND"; then
5047     AC_CHECK_HEADER([valgrind/valgrind.h], [],
5048         AC_MSG_ERROR(
5049             [--enable-valgrind specified but Valgrind is not installed]))
5050     AC_DEFINE(MOZ_VALGRIND)
5051 fi
5052
5053 dnl ========================================================
5054 dnl jprof
5055 dnl ========================================================
5056 MOZ_ARG_ENABLE_BOOL(jprof,
5057 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
5058     MOZ_JPROF=1,
5059     MOZ_JPROF= )
5060 if test -n "$MOZ_JPROF"; then
5061     MOZ_PROFILING=1
5062     AC_DEFINE(MOZ_JPROF)
5063 fi
5064
5065 dnl ========================================================
5066 dnl shark
5067 dnl ========================================================
5068 MOZ_ARG_ENABLE_BOOL(shark,
5069 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
5070     MOZ_SHARK=1,
5071     MOZ_SHARK= )
5072 if test -n "$MOZ_SHARK"; then
5073     MOZ_PROFILING=1
5074     AC_DEFINE(MOZ_SHARK)
5075 fi
5076
5077 dnl ========================================================
5078 dnl callgrind
5079 dnl ========================================================
5080 MOZ_ARG_ENABLE_BOOL(callgrind,
5081 [  --enable-callgrind      Enable callgrind profiling],
5082     MOZ_CALLGRIND=1,
5083     MOZ_CALLGRIND= )
5084 if test -n "$MOZ_CALLGRIND"; then
5085     AC_DEFINE(MOZ_CALLGRIND)
5086 fi
5087
5088 dnl ========================================================
5089 dnl vtune
5090 dnl ========================================================
5091 MOZ_ARG_ENABLE_BOOL(vtune,
5092 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
5093     MOZ_VTUNE=1,
5094     MOZ_VTUNE= )
5095 if test -n "$MOZ_VTUNE"; then
5096     MOZ_PROFILING=1
5097     AC_DEFINE(MOZ_VTUNE)
5098 fi
5099
5100 dnl ========================================================
5101 dnl Profiling
5102 dnl ========================================================
5103 if test -n "$MOZ_PROFILING"; then
5104     AC_DEFINE(MOZ_PROFILING)
5105 fi
5106
5107 dnl ========================================================
5108 dnl Zealous JavaScript GC
5109 dnl ========================================================
5110 MOZ_ARG_ENABLE_BOOL(gczeal,
5111 [  --enable-gczeal         Enable zealous GCing],
5112     JS_GC_ZEAL=1,
5113     JS_GC_ZEAL= )
5114 if test -n "$JS_GC_ZEAL"; then
5115     AC_DEFINE(JS_GC_ZEAL)
5116 fi
5117
5118 dnl ======================================================
5119 dnl = Enable compiling with ccache
5120 dnl ======================================================
5121 MOZ_ARG_WITH_STRING(ccache,
5122 [  --with-ccache[=path/to/ccache]
5123                           Enable compiling with ccache],
5124     CCACHE=$withval, CCACHE="no")
5125
5126 if test "$CCACHE" != "no"; then
5127     if test -z "$CCACHE" -o "$CCACHE" = "yes"; then
5128         CCACHE=
5129     else
5130         if test ! -e "$CCACHE"; then
5131             AC_MSG_ERROR([$CCACHE not found])
5132         fi
5133     fi
5134     MOZ_PATH_PROGS(CCACHE, $CCACHE ccache)
5135     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
5136         AC_MSG_ERROR([ccache not found])
5137     elif test -x "$CCACHE"; then
5138         CC="$CCACHE $CC"
5139         CXX="$CCACHE $CXX"
5140     else
5141         AC_MSG_ERROR([$CCACHE is not executable])
5142     fi
5143 fi
5144
5145 dnl ========================================================
5146 dnl = Enable static checking using gcc-dehydra
5147 dnl ========================================================
5148
5149 MOZ_ARG_WITH_STRING(static-checking,
5150 [  --with-static-checking=path/to/gcc_dehydra.so
5151                           Enable static checking of code using GCC-dehydra],
5152     DEHYDRA_PATH=$withval,
5153     DEHYDRA_PATH= )
5154
5155 if test -n "$DEHYDRA_PATH"; then
5156     if test ! -f "$DEHYDRA_PATH"; then
5157         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
5158     fi
5159     AC_DEFINE(NS_STATIC_CHECKING)
5160 fi
5161 AC_SUBST(DEHYDRA_PATH)
5162
5163 dnl ========================================================
5164 dnl = Enable stripping of libs & executables
5165 dnl ========================================================
5166 MOZ_ARG_ENABLE_BOOL(strip,
5167 [  --enable-strip          Enable stripping of libs & executables ],
5168     ENABLE_STRIP=1,
5169     ENABLE_STRIP= )
5170
5171 dnl ========================================================
5172 dnl = Enable stripping of libs & executables when packaging
5173 dnl ========================================================
5174 MOZ_ARG_ENABLE_BOOL(install-strip,
5175 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
5176     PKG_SKIP_STRIP= ,
5177     PKG_SKIP_STRIP=1)
5178
5179 dnl ========================================================
5180 dnl = 
5181 dnl = Profiling and Instrumenting
5182 dnl = 
5183 dnl ========================================================
5184 MOZ_ARG_HEADER(Profiling and Instrumenting)
5185
5186 dnl ========================================================
5187 dnl = Enable timeline service, which provides lightweight
5188 dnl = instrumentation of mozilla for performance measurement.
5189 dnl = Timeline is off by default.
5190 dnl ========================================================
5191 MOZ_ARG_ENABLE_BOOL(timeline,
5192 [  --enable-timeline       Enable timeline services ],
5193     MOZ_TIMELINE=1,
5194     MOZ_TIMELINE= )
5195 if test -n "$MOZ_TIMELINE"; then
5196     AC_DEFINE(MOZ_TIMELINE)
5197 fi
5198
5199 dnl ========================================================
5200 dnl = Support for Quantify (Windows)
5201 dnl ========================================================
5202 MOZ_ARG_ENABLE_BOOL(quantify,
5203 [  --enable-quantify       Enable Quantify support (Windows only) ],
5204     MOZ_QUANTIFY=1,
5205     MOZ_QUANTIFY= )
5206
5207 dnl ========================================================
5208 dnl = Support for demangling undefined symbols
5209 dnl ========================================================
5210 if test -z "$SKIP_LIBRARY_CHECKS"; then
5211     AC_LANG_SAVE
5212     AC_LANG_CPLUSPLUS
5213     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
5214     AC_LANG_RESTORE
5215 fi
5216
5217 # Demangle only for debug or trace-malloc builds
5218 MOZ_DEMANGLE_SYMBOLS=
5219 if test "$HAVE_DEMANGLE" -a "$HAVE_GCC3_ABI" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
5220     MOZ_DEMANGLE_SYMBOLS=1
5221     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
5222 fi
5223 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
5224
5225 dnl ========================================================
5226 dnl = Support for gcc stack unwinding (from gcc 3.3)
5227 dnl ========================================================
5228 if test "$HAVE_GCC3_ABI" -a -z "$SKIP_LIBRARY_CHECKS"; then
5229     AC_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
5230 fi
5231
5232 dnl ========================================================
5233 dnl =
5234 dnl = Misc. Options
5235 dnl = 
5236 dnl ========================================================
5237 MOZ_ARG_HEADER(Misc. Options)
5238
5239 dnl ========================================================
5240 dnl update xterm title
5241 dnl ========================================================
5242 MOZ_ARG_ENABLE_BOOL(xterm-updates,
5243 [  --enable-xterm-updates  Update XTERM titles with current command.],
5244     MOZ_UPDATE_XTERM=1,
5245     MOZ_UPDATE_XTERM= )
5246
5247 if test -z "$SKIP_COMPILER_CHECKS"; then
5248 dnl ========================================================
5249 dnl =
5250 dnl = Compiler Options
5251 dnl = 
5252 dnl ========================================================
5253 MOZ_ARG_HEADER(Compiler Options)
5254
5255 dnl ========================================================
5256 dnl Check for gcc -pipe support
5257 dnl ========================================================
5258 AC_MSG_CHECKING([for gcc -pipe support])
5259 if test -n "$GNU_CC" -a -n "$GNU_CXX" -a -n "$GNU_AS"; then
5260     echo '#include <stdio.h>' > dummy-hello.c
5261     echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c
5262     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
5263     cat dummy-hello.s 2> /dev/null | ${AS_BIN} -o dummy-hello.S - 2>&5
5264     if test $? = 0; then
5265         _res_as_stdin="yes"
5266     else
5267         _res_as_stdin="no"
5268     fi
5269     if test "$_res_as_stdin" = "yes"; then
5270         _SAVE_CFLAGS=$CFLAGS
5271         CFLAGS="$CFLAGS -pipe"
5272         AC_TRY_COMPILE( [ #include <stdio.h> ],
5273             [printf("Hello World\n");],
5274             [_res_gcc_pipe="yes"],
5275             [_res_gcc_pipe="no"] )
5276         CFLAGS=$_SAVE_CFLAGS
5277     fi
5278     if test "$_res_as_stdin" = "yes" -a "$_res_gcc_pipe" = "yes"; then
5279         _res="yes";
5280         CFLAGS="$CFLAGS -pipe"
5281         CXXFLAGS="$CXXFLAGS -pipe"
5282     else
5283         _res="no"
5284     fi
5285     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
5286     AC_MSG_RESULT([$_res])
5287 else
5288     AC_MSG_RESULT([no])
5289 fi
5290
5291 dnl ========================================================
5292 dnl Profile guided optimization
5293 dnl ========================================================
5294 dnl Test for profiling options
5295 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
5296
5297 dnl Provide a switch to disable PGO even when called via profiledbuild.
5298 MOZ_ARG_DISABLE_BOOL(profile-guided-optimization,
5299 [  --disable-profile-guided-optimization
5300                           Don't build with PGO even if called via make profiledbuild],
5301 MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=1,
5302 MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=)
5303
5304 AC_SUBST(MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE)
5305
5306 _SAVE_CFLAGS="$CFLAGS"
5307 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
5308
5309 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
5310 AC_TRY_COMPILE([], [return 0;],
5311                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
5312                  result="yes" ], result="no")
5313 AC_MSG_RESULT([$result])
5314
5315 if test $result = "yes"; then
5316   PROFILE_GEN_LDFLAGS="-fprofile-generate"
5317   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch -freorder-blocks-and-partition"
5318   PROFILE_USE_LDFLAGS="-fprofile-use"
5319 fi
5320
5321 CFLAGS="$_SAVE_CFLAGS"
5322
5323 if test -n "$INTEL_CC"; then
5324   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
5325   PROFILE_GEN_LDFLAGS=
5326   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
5327   PROFILE_USE_LDFLAGS=
5328 fi
5329
5330 dnl Sun Studio on Solaris
5331 if test "$SOLARIS_SUNPRO_CC"; then
5332   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
5333   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
5334   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
5335   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
5336 fi
5337
5338 AC_SUBST(PROFILE_GEN_CFLAGS)
5339 AC_SUBST(PROFILE_GEN_LDFLAGS)
5340 AC_SUBST(PROFILE_USE_CFLAGS)
5341 AC_SUBST(PROFILE_USE_LDFLAGS)
5342
5343 AC_LANG_CPLUSPLUS
5344
5345 dnl ========================================================
5346 dnl Test for -pedantic bustage
5347 dnl ========================================================
5348 MOZ_ARG_DISABLE_BOOL(pedantic,
5349 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],
5350 _PEDANTIC= )
5351 if test "$_PEDANTIC"; then
5352     _SAVE_CXXFLAGS=$CXXFLAGS
5353     CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
5354     AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
5355     AC_TRY_COMPILE([$configure_static_assert_macros],
5356                    [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
5357                    result="no", result="yes" )
5358     AC_MSG_RESULT([$result])
5359     CXXFLAGS="$_SAVE_CXXFLAGS"
5360
5361     case "$result" in
5362     no)
5363         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
5364         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
5365         ;;
5366     yes)
5367         AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic.  Reconfigure using --disable-pedantic. ])
5368         ;;
5369     esac
5370 fi
5371
5372 dnl ========================================================
5373 dnl Test for correct temporary object destruction order
5374 dnl ========================================================
5375 dnl We want to make sure the compiler follows the C++ spec here as 
5376 dnl xpcom and the string classes depend on it (bug 235381).
5377 AC_MSG_CHECKING([for correct temporary object destruction order])
5378 AC_TRY_RUN([ class A {
5379              public:  A(int& x) : mValue(x) {}
5380                       ~A() { mValue--; }
5381                       operator char**() { return 0; }
5382              private:  int& mValue;
5383              };
5384              void func(char **arg) {}
5385              int m=2;
5386              void test() {
5387                   func(A(m));
5388                   if (m==1) m = 0;
5389              }
5390              int main() {
5391                  test();
5392                  return(m);
5393              }
5394              ],
5395      result="yes", result="no", result="maybe")
5396 AC_MSG_RESULT([$result])
5397
5398 if test "$result" = "no"; then
5399     AC_MSG_ERROR([Your compiler does not follow the C++ specification for temporary object destruction order.])
5400 fi
5401
5402 dnl ========================================================
5403 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
5404 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
5405 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
5406 dnl ========================================================
5407 _SAVE_CXXFLAGS=$CXXFLAGS
5408 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
5409 AC_CACHE_CHECK(for correct overload resolution with const and templates,
5410     ac_nscap_nonconst_opeq_bug,
5411     [AC_TRY_COMPILE([
5412                       template <class T>
5413                       class Pointer
5414                         {
5415                         public:
5416                           T* myPtr;
5417                         };
5418                       
5419                       template <class T, class U>
5420                       int operator==(const Pointer<T>& rhs, U* lhs)
5421                         {
5422                           return rhs.myPtr == lhs;
5423                         }
5424                       
5425                       template <class T, class U>
5426                       int operator==(const Pointer<T>& rhs, const U* lhs)
5427                         {
5428                           return rhs.myPtr == lhs;
5429                         }
5430                     ],
5431                     [
5432                       Pointer<int> foo;
5433                       const int* bar;
5434                       return foo == bar;
5435                     ],
5436                     ac_nscap_nonconst_opeq_bug="no",
5437                     ac_nscap_nonconst_opeq_bug="yes")])
5438 CXXFLAGS="$_SAVE_CXXFLAGS"
5439
5440 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
5441     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
5442 fi
5443
5444 dnl ========================================================
5445 dnl Check for tm_zone, tm_gmtoff in struct tm
5446 dnl ========================================================
5447 AC_CACHE_CHECK(for tm_zone tm_gmtoff in struct tm,
5448     ac_cv_struct_tm_zone_tm_gmtoff,
5449     [AC_TRY_COMPILE([#include <time.h>],
5450                     [struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;],
5451                     [ac_cv_struct_tm_zone_tm_gmtoff="yes"],
5452                     [ac_cv_struct_tm_zone_tm_gmtoff="no"])])
5453 if test "$ac_cv_struct_tm_zone_tm_gmtoff" = "yes" ; then
5454     AC_DEFINE(HAVE_TM_ZONE_TM_GMTOFF)
5455 fi
5456
5457 fi # SKIP_COMPILER_CHECKS
5458
5459 dnl ========================================================
5460 dnl C++ rtti
5461 dnl Should be smarter and check that the compiler does indeed have rtti
5462 dnl ========================================================
5463 MOZ_ARG_ENABLE_BOOL(cpp-rtti,
5464 [  --enable-cpp-rtti       Enable C++ RTTI ],
5465 [ _MOZ_USE_RTTI=1 ],
5466 [ _MOZ_USE_RTTI= ])
5467
5468 if test "$_MOZ_USE_RTTI"; then
5469    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_ON
5470 else
5471    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_OFF
5472 fi
5473
5474 AC_SUBST(_MOZ_RTTI_FLAGS_ON)
5475
5476 dnl ========================================================
5477 dnl C++ exceptions (g++/VC/irix6/Sun only - for now)
5478 dnl Should be smarter and check that the compiler does indeed have exceptions
5479 dnl ========================================================
5480 MOZ_ARG_ENABLE_BOOL(cpp-exceptions,
5481 [  --enable-cpp-exceptions Enable C++ exceptions ],
5482 [ _MOZ_CPP_EXCEPTIONS=1 ],
5483 [ _MOZ_CPP_EXCEPTIONS= ])
5484
5485 if test "$_MOZ_CPP_EXCEPTIONS"; then
5486     _MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_ON
5487     AC_DEFINE(MOZ_CPP_EXCEPTIONS)
5488 else
5489     _MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_OFF
5490 fi
5491
5492 AC_SUBST(_MOZ_EXCEPTIONS_FLAGS_ON)
5493
5494 # Irix & OSF native compilers do not like exception declarations 
5495 # when exceptions are disabled
5496 if test -n "$MIPSPRO_CXX" -o -n "$COMPAQ_CXX" -o -n "$VACPP"; then
5497     AC_DEFINE(CPP_THROW_NEW, [])
5498 else
5499     AC_DEFINE(CPP_THROW_NEW, [throw()])
5500 fi
5501 AC_LANG_C
5502
5503 dnl ========================================================
5504 dnl =
5505 dnl = Build depencency options
5506 dnl =
5507 dnl ========================================================
5508 MOZ_ARG_HEADER(Build dependencies)
5509
5510 dnl ========================================================
5511 dnl = Do not auto generate dependency info
5512 dnl ========================================================
5513 MOZ_AUTO_DEPS=1
5514 MOZ_ARG_DISABLE_BOOL(auto-deps,
5515 [  --disable-auto-deps     Do not automatically generate dependency info],
5516     MOZ_AUTO_DEPS=,
5517     MOZ_AUTO_DEPS=1)
5518
5519 if test -n "$MOZ_AUTO_DEPS"; then
5520 dnl ========================================================
5521 dnl = Use mkdepend instead of $CC -MD for dependency generation
5522 dnl ========================================================
5523 _cpp_md_flag=
5524 MOZ_ARG_DISABLE_BOOL(md,
5525 [  --disable-md            Do not use compiler-based dependencies ],
5526   [_cpp_md_flag=],
5527   [_cpp_md_flag=1],
5528   [dnl Default is to turn on -MD if using GNU-compatible compilers
5529    if test "$GNU_CC" -a "$GNU_CXX" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "WINCE"; then
5530      _cpp_md_flag=1
5531    fi
5532   dnl Default is to use -xM if using Sun Studio on Solaris
5533    if test "$SOLARIS_SUNPRO_CC"; then
5534      _cpp_md_flag=1
5535    fi])
5536 if test "$_cpp_md_flag"; then
5537   COMPILER_DEPEND=1
5538   if test "$OS_ARCH" = "OpenVMS"; then
5539     _DEPEND_CFLAGS='$(subst =, ,$(filter-out %/.pp,-MM=-MD=-MF=$(MDDEPDIR)/$(basename $(@F)).pp))'
5540   else
5541     _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(basename $(@F)).pp)'
5542   fi
5543   dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
5544   if test "$SOLARIS_SUNPRO_CC"; then
5545     _DEPEND_CFLAGS=
5546   fi
5547 else
5548   COMPILER_DEPEND=
5549   dnl Don't override this for MSVC
5550   if test -z "$_WIN32_MSVC"; then
5551     _USE_CPP_INCLUDE_FLAG=
5552     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
5553     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
5554   else
5555     echo '#include <stdio.h>' > dummy-hello.c
5556     changequote(,)
5557     CL_INCLUDES_PREFIX=`"${CC}" -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
5558     changequote([,])
5559     if test -z "$CL_INCLUDES_PREFIX"; then
5560         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
5561     fi
5562     AC_SUBST(CL_INCLUDES_PREFIX)
5563     rm -f dummy-hello.c
5564     _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
5565     dnl cl.py provides dependency generation for MSVC
5566     CC_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
5567     CXX_WRAPPER="$PYTHON -O $_topsrcdirwin/build/cl.py"
5568     COMPILER_DEPEND=1
5569   fi
5570 fi
5571 fi # MOZ_AUTO_DEPS
5572 MDDEPDIR='.deps'
5573 AC_SUBST(MOZ_AUTO_DEPS)
5574 AC_SUBST(COMPILER_DEPEND)
5575 AC_SUBST(MDDEPDIR)
5576 AC_SUBST(CC_WRAPPER)
5577 AC_SUBST(CXX_WRAPPER)
5578
5579
5580 dnl ========================================================
5581 dnl =
5582 dnl = Static Build Options
5583 dnl =
5584 dnl ========================================================
5585 MOZ_ARG_HEADER(Static build options)
5586
5587 MOZ_ARG_ENABLE_BOOL(static,
5588 [  --enable-static         Enable building of internal static libs],
5589     BUILD_STATIC_LIBS=1,
5590     BUILD_STATIC_LIBS=)
5591
5592 dnl ========================================================
5593 dnl = Link js shell to system readline
5594 dnl ========================================================
5595 MOZ_ARG_ENABLE_BOOL(readline,
5596 [  --enable-readline       Link js shell to system readline library],
5597     JS_WANT_READLINE=1,
5598     JS_WANT_READLINE= )
5599
5600 JS_NATIVE_EDITLINE=
5601 EDITLINE_LIBS=
5602 JS_DISABLE_SHELL=
5603
5604 case "$target" in
5605 *-wince*|*-winmo*|*-mingw*|*-cygwin*|*-msvc*|*-mks*)
5606     NO_EDITLINE=1
5607     ;;
5608 *-symbian*)
5609     NO_EDITLINE=1
5610     JS_DISABLE_SHELL=1
5611     ;;
5612 *)
5613     ;;
5614 esac
5615
5616 if test -z "$SKIP_LIBRARY_CHECKS" -a -z "$NO_EDITLINE"; then
5617   if test -n "$JS_WANT_READLINE"; then
5618     AC_CHECK_LIB(readline, readline,
5619                  EDITLINE_LIBS="-lreadline",
5620                  AC_MSG_ERROR([No system readline library found.]))
5621   else
5622     dnl By default, we use editline
5623     JS_NATIVE_EDITLINE=1
5624     EDITLINE_LIBS='$(DEPTH)/editline/$(LIB_PREFIX)editline.$(LIB_SUFFIX)'
5625   fi
5626
5627   dnl Either way, we want to build with line editing support.
5628   AC_DEFINE(EDITLINE)
5629 fi
5630 AC_SUBST(JS_NATIVE_EDITLINE)
5631 AC_SUBST(JS_DISABLE_SHELL)
5632 AC_SUBST(EDITLINE_LIBS)
5633
5634 dnl ========================================================
5635 dnl =
5636 dnl = Standalone module options
5637 dnl = 
5638 dnl ========================================================
5639 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
5640
5641 dnl ========================================================
5642 dnl = Build jsctypes if it's enabled
5643 dnl ========================================================
5644 MOZ_ARG_ENABLE_BOOL(ctypes,
5645 [  --enable-ctypes         Enable js-ctypes (default=no)],
5646     JS_HAS_CTYPES=1,
5647     JS_HAS_CTYPES= )
5648 AC_SUBST(JS_HAS_CTYPES)
5649 if test "$JS_HAS_CTYPES"; then
5650   dnl Error out if we're on MSVC and MASM is unavailable.
5651   if test -n "$_MSC_VER" -a \( "$AS" != "ml.exe" -a "$AS" != "ml64.exe" \); then
5652     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.])
5653   fi
5654   AC_DEFINE(JS_HAS_CTYPES)
5655 fi
5656
5657 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
5658     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
5659 fi
5660
5661 MOZ_ARG_WITH_STRING(sync-build-files,
5662 [  --with-sync-build-files=DIR
5663                           Check that files in 'config' and 'build' match
5664                           their originals in 'DIR/config' and 'DIR/build'.
5665                           This helps keep the SpiderMonkey build machinery
5666                           in sync with Mozilla's, on which it is based.],
5667 [MOZ_SYNC_BUILD_FILES=$withval ] )
5668 AC_SUBST(MOZ_SYNC_BUILD_FILES)
5669
5670 dnl ========================================================
5671 dnl =
5672 dnl = Maintainer debug option (no --enable equivalent)
5673 dnl =
5674 dnl ========================================================
5675
5676 AC_SUBST(AR)
5677 AC_SUBST(AR_FLAGS)
5678 AC_SUBST(AR_LIST)
5679 AC_SUBST(AR_EXTRACT)
5680 AC_SUBST(AR_DELETE)
5681 AC_SUBST(AS)
5682 AC_SUBST(ASFLAGS)
5683 AC_SUBST(AS_DASH_C_FLAG)
5684 AC_SUBST(LD)
5685 AC_SUBST(RC)
5686 AC_SUBST(RCFLAGS)
5687 AC_SUBST(WINDRES)
5688 AC_SUBST(IMPLIB)
5689 AC_SUBST(FILTER)
5690 AC_SUBST(BIN_FLAGS)
5691 AC_SUBST(NS_USE_NATIVE)
5692 AC_SUBST(MOZ_JS_LIBS)
5693 AC_SUBST(MOZ_PSM)
5694 AC_SUBST(MOZ_DEBUG)
5695 AC_SUBST(MOZ_DEBUG_SYMBOLS)
5696 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
5697 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
5698 AC_SUBST(MOZ_DEBUG_FLAGS)
5699 AC_SUBST(MOZ_DEBUG_LDFLAGS)
5700 AC_SUBST(WARNINGS_AS_ERRORS)
5701 AC_SUBST(MOZ_LEAKY)
5702 AC_SUBST(MOZ_JPROF)
5703 AC_SUBST(MOZ_SHARK)
5704 AC_SUBST(MOZ_CALLGRIND)
5705 AC_SUBST(MOZ_VTUNE)
5706 AC_SUBST(MOZ_PROFILING)
5707 AC_SUBST(MOZ_JSLOADER)
5708 AC_SUBST(MOZ_QUANTIFY)
5709 AC_SUBST(LIBICONV)
5710
5711 AC_SUBST(BUILD_STATIC_LIBS)
5712 AC_SUBST(ENABLE_TESTS)
5713
5714 AC_SUBST(ENABLE_STRIP)
5715 AC_SUBST(PKG_SKIP_STRIP)
5716 AC_SUBST(INCREMENTAL_LINKER)
5717 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
5718 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
5719
5720 AC_SUBST(MOZ_FIX_LINK_PATHS)
5721
5722 AC_SUBST(USE_DEPENDENT_LIBS)
5723
5724 AC_SUBST(MOZ_BUILD_ROOT)
5725 AC_SUBST(MOZ_OS2_TOOLS)
5726
5727 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
5728 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
5729 AC_SUBST(MOZ_TIMELINE)
5730
5731 AC_SUBST(MOZ_APP_NAME)
5732 AC_SUBST(MOZ_APP_DISPLAYNAME)
5733 AC_SUBST(MOZ_APP_UA_NAME)
5734 AC_SUBST(MOZ_APP_VERSION)
5735 AC_SUBST(MOZ_UA_FIREFOX_VERSION)
5736 AC_SUBST(FIREFOX_VERSION)
5737
5738 AC_SUBST(MOZ_PKG_SPECIAL)
5739
5740 AC_SUBST(MOZILLA_OFFICIAL)
5741
5742 dnl win32 options
5743 AC_SUBST(MOZ_MAPINFO)
5744 AC_SUBST(MOZ_BROWSE_INFO)
5745 AC_SUBST(MOZ_TOOLS_DIR)
5746 AC_SUBST(CYGWIN_WRAPPER)
5747 AC_SUBST(AS_PERL)
5748 AC_SUBST(WIN32_REDIST_DIR)
5749 AC_SUBST(PYTHON)
5750
5751 AC_SUBST(WINCE)
5752 AC_SUBST(WINCE_SDK_DIR)
5753 AC_SUBST(WINCE_WINDOWS_MOBILE)
5754
5755 dnl Echo the CFLAGS to remove extra whitespace.
5756 CFLAGS=`echo \
5757         $_WARNINGS_CFLAGS \
5758         $CFLAGS`
5759
5760 CXXFLAGS=`echo \
5761         $_MOZ_RTTI_FLAGS \
5762         $_MOZ_EXCEPTIONS_FLAGS \
5763         $_WARNINGS_CXXFLAGS \
5764         $CXXFLAGS`
5765
5766 COMPILE_CFLAGS=`echo \
5767     $_DEFINES_CFLAGS \
5768         $_DEPEND_CFLAGS \
5769     $COMPILE_CFLAGS`
5770
5771 COMPILE_CXXFLAGS=`echo \
5772     $_DEFINES_CXXFLAGS \
5773         $_DEPEND_CFLAGS \
5774     $COMPILE_CXXFLAGS`
5775
5776 AC_SUBST(SYSTEM_MAKEDEPEND)
5777
5778 AC_SUBST(NSPR_CFLAGS)
5779 AC_SUBST(NSPR_LIBS)
5780 AC_SUBST(MOZ_NATIVE_NSPR)
5781
5782 AC_SUBST(CFLAGS)
5783 AC_SUBST(CXXFLAGS)
5784 AC_SUBST(CPPFLAGS)
5785 AC_SUBST(COMPILE_CFLAGS)
5786 AC_SUBST(COMPILE_CXXFLAGS)
5787 AC_SUBST(LDFLAGS)
5788 AC_SUBST(LIBS)
5789 AC_SUBST(CROSS_COMPILE)
5790
5791 AC_SUBST(HOST_CC)
5792 AC_SUBST(HOST_CXX)
5793 AC_SUBST(HOST_CFLAGS)
5794 AC_SUBST(HOST_CXXFLAGS)
5795 AC_SUBST(HOST_LDFLAGS)
5796 AC_SUBST(HOST_OPTIMIZE_FLAGS)
5797 AC_SUBST(HOST_AR)
5798 AC_SUBST(HOST_AR_FLAGS)
5799 AC_SUBST(HOST_LD)
5800 AC_SUBST(HOST_RANLIB)
5801 AC_SUBST(HOST_NSPR_MDCPUCFG)
5802 AC_SUBST(HOST_BIN_SUFFIX)
5803 AC_SUBST(HOST_OS_ARCH)
5804
5805 AC_SUBST(TARGET_CPU)
5806 AC_SUBST(TARGET_VENDOR)
5807 AC_SUBST(TARGET_OS)
5808 AC_SUBST(TARGET_NSPR_MDCPUCFG)
5809 AC_SUBST(TARGET_MD_ARCH)
5810 AC_SUBST(TARGET_XPCOM_ABI)
5811 AC_SUBST(OS_TARGET)
5812 AC_SUBST(OS_ARCH)
5813 AC_SUBST(OS_RELEASE)
5814 AC_SUBST(OS_TEST)
5815 AC_SUBST(CPU_ARCH)
5816 AC_SUBST(INTEL_ARCHITECTURE)
5817
5818 AC_SUBST(WRAP_MALLOC_CFLAGS)
5819 AC_SUBST(WRAP_MALLOC_LIB)
5820 AC_SUBST(MKSHLIB)
5821 AC_SUBST(MKCSHLIB)
5822 AC_SUBST(MKSHLIB_FORCE_ALL)
5823 AC_SUBST(MKSHLIB_UNFORCE_ALL)
5824 AC_SUBST(DSO_CFLAGS)
5825 AC_SUBST(DSO_PIC_CFLAGS)
5826 AC_SUBST(DSO_LDOPTS)
5827 AC_SUBST(LIB_PREFIX)
5828 AC_SUBST(DLL_PREFIX)
5829 AC_SUBST(DLL_SUFFIX)
5830 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
5831 AC_SUBST(LIB_SUFFIX)
5832 AC_SUBST(OBJ_SUFFIX)
5833 AC_SUBST(BIN_SUFFIX)
5834 AC_SUBST(ASM_SUFFIX)
5835 AC_SUBST(IMPORT_LIB_SUFFIX)
5836 AC_SUBST(USE_N32)
5837 AC_SUBST(CC_VERSION)
5838 AC_SUBST(CXX_VERSION)
5839 AC_SUBST(MSMANIFEST_TOOL)
5840
5841 if test "$USING_HCC"; then
5842    CC='${topsrcdir}/build/hcc'
5843    CC="$CC '$_OLDCC'"
5844    CXX='${topsrcdir}/build/hcpp'
5845    CXX="$CXX '$_OLDCXX'"
5846    AC_SUBST(CC)
5847    AC_SUBST(CXX)
5848 fi
5849
5850 AC_MSG_CHECKING([for posix_fallocate])
5851 AC_TRY_LINK([#define _XOPEN_SOURCE 600
5852   #include <fcntl.h>],
5853                  [posix_fallocate(0, 0, 0);],
5854                  [ac_cv___posix_fallocate=true],
5855                  [ac_cv___posix_fallocate=false])
5856
5857 if test "$ac_cv___posix_fallocate" = true ; then
5858   AC_DEFINE(HAVE_POSIX_FALLOCATE)
5859   AC_MSG_RESULT(yes)
5860 else
5861   AC_MSG_RESULT(no)
5862 fi
5863
5864 dnl Check for missing components
5865 if test "$COMPILE_ENVIRONMENT"; then
5866 if test "$MOZ_X11"; then
5867     dnl ====================================================
5868     dnl = Check if X headers exist
5869     dnl ====================================================
5870     _SAVE_CFLAGS=$CFLAGS
5871     CFLAGS="$CFLAGS $XCFLAGS"
5872     AC_TRY_COMPILE([
5873         #include <stdio.h>
5874         #include <stdlib.h>
5875         #include <X11/Xlib.h>
5876         #include <X11/Intrinsic.h>
5877     ],
5878     [
5879         Display *dpy = 0;
5880         if ((dpy = XOpenDisplay(NULL)) == NULL) {
5881             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
5882             exit(1);
5883         }
5884     ], [], 
5885     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
5886     CFLAGS="$_SAVE_CFLAGS"
5887
5888     if test ! -z "$MISSING_X"; then
5889         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
5890     fi
5891
5892 fi # MOZ_X11
5893 fi # COMPILE_ENVIRONMENT
5894
5895 dnl Set various defines and substitutions
5896 dnl ========================================================
5897
5898 if test "$OS_ARCH" = "BeOS"; then
5899   AC_DEFINE(XP_BEOS)
5900 elif test "$OS_ARCH" = "Darwin"; then
5901   AC_DEFINE(XP_MACOSX)
5902   AC_DEFINE(XP_UNIX)
5903   AC_DEFINE(UNIX_ASYNC_DNS)
5904 elif test "$OS_ARCH" = "OpenVMS"; then
5905   AC_DEFINE(XP_UNIX)
5906 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2" -a "$OS_ARCH" != "WINCE"; then
5907   AC_DEFINE(XP_UNIX)
5908   AC_DEFINE(UNIX_ASYNC_DNS)
5909 fi
5910
5911 AC_ARG_ENABLE(threadsafe,
5912               [  --enable-threadsafe     Enable support for multiple threads.],
5913               [AC_DEFINE(JS_THREADSAFE)],)
5914
5915 if test "$MOZ_DEBUG"; then
5916     AC_DEFINE(MOZ_REFLOW_PERF)
5917     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
5918 fi
5919
5920 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
5921     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
5922     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
5923     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
5924     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
5925     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
5926     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
5927     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
5928     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
5929 fi
5930
5931 dnl ========================================================
5932 dnl JavaScript shell
5933 dnl ========================================================
5934
5935 AC_HAVE_FUNCS(setlocale)
5936 AC_HAVE_FUNCS(localeconv)
5937
5938 dnl ========================================================
5939 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
5940 dnl ========================================================
5941 case "$host_os" in
5942 mingw*)
5943     WIN_TOP_SRC=`cd $srcdir; pwd -W`
5944     ;;
5945 cygwin*|msvc*|mks*)
5946     HOST_CC="\$(CYGWIN_WRAPPER) $HOST_CC"
5947     HOST_CXX="\$(CYGWIN_WRAPPER) $HOST_CXX"
5948     CC="\$(CYGWIN_WRAPPER) $CC"
5949     CXX="\$(CYGWIN_WRAPPER) $CXX"
5950     CPP="\$(CYGWIN_WRAPPER) $CPP"
5951     LD="\$(CYGWIN_WRAPPER) $LD"
5952     AS="\$(CYGWIN_WRAPPER) $AS"
5953     RC="\$(CYGWIN_WRAPPER) $RC"
5954     CYGDRIVE_MOUNT=`mount -p | awk '{ if (/^\//) { print $1; exit } }'`
5955     WIN_TOP_SRC=`cygpath -a -w $srcdir | sed -e 's|\\\\|/|g'`
5956     ;;
5957 esac
5958
5959 AC_SUBST(CYGDRIVE_MOUNT)
5960 AC_SUBST(WIN_TOP_SRC)
5961
5962 AC_SUBST(MOZILLA_VERSION)
5963
5964 AC_SUBST(ac_configure_args)
5965
5966 dnl Spit out some output
5967 dnl ========================================================
5968
5969 # Save the defines header file before autoconf removes it.
5970 # (Do not add AC_DEFINE calls after this line.)
5971   _CONFIG_TMP=confdefs-tmp.h
5972   _CONFIG_DEFS_H=js-confdefs.h
5973
5974   cat > $_CONFIG_TMP <<\EOF
5975 /* List of defines generated by configure. Included with preprocessor flag,
5976  * -include, to avoid long list of -D defines on the compile command-line.
5977  * Do not edit.
5978  */
5979
5980 #ifndef _JS_CONFDEFS_H_
5981 #define _JS_CONFDEFS_H_
5982 EOF
5983
5984 _EGREP_PATTERN='^#define ('
5985 if test -n "$_NON_GLOBAL_ACDEFINES"; then
5986     for f in $_NON_GLOBAL_ACDEFINES; do
5987         _EGREP_PATTERN="${_EGREP_PATTERN}$f|"
5988     done
5989 fi
5990 _EGREP_PATTERN="${_EGREP_PATTERN}dummy_never_defined)"
5991  
5992   sort confdefs.h | egrep -v "$_EGREP_PATTERN" >> $_CONFIG_TMP
5993
5994   cat >> $_CONFIG_TMP <<\EOF
5995
5996 #endif /* _JS_CONFDEFS_H_ */
5997
5998 EOF
5999
6000   # Only write js-confdefs.h when something changes (or it doesn't exist)
6001   if cmp -s $_CONFIG_TMP $_CONFIG_DEFS_H; then
6002     rm $_CONFIG_TMP
6003   else
6004     AC_MSG_RESULT("creating $_CONFIG_DEFS_H")
6005     mv -f $_CONFIG_TMP $_CONFIG_DEFS_H
6006
6007     echo ==== $_CONFIG_DEFS_H =================================
6008     cat $_CONFIG_DEFS_H
6009   fi
6010
6011 dnl Probably shouldn't call this manually but we always want the output of DEFS
6012 rm -f confdefs.h.save
6013 mv confdefs.h confdefs.h.save
6014 egrep -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
6015 AC_OUTPUT_MAKE_DEFS()
6016 MOZ_DEFINES=$DEFS
6017 AC_SUBST(MOZ_DEFINES)
6018 rm -f confdefs.h
6019 mv confdefs.h.save confdefs.h
6020
6021 MAKEFILES="
6022   Makefile
6023   shell/Makefile
6024   lirasm/Makefile
6025   jsapi-tests/Makefile
6026   tests/Makefile
6027   config/Makefile
6028   config/autoconf.mk
6029   config/mkdepend/Makefile
6030 "
6031
6032 if test -n "$JS_NATIVE_EDITLINE"; then
6033    MAKEFILES="$MAKEFILES
6034 editline/Makefile
6035 "
6036 fi
6037
6038 dnl 
6039 dnl Run a perl script to quickly create the makefiles.
6040 dnl If it succeeds, it outputs a shell command to set CONFIG_FILES
6041 dnl   for the files it cannot handle correctly. This way, config.status
6042 dnl   will handle these files.
6043 dnl If it fails, nothing is set and config.status will run as usual.
6044 dnl
6045 dnl This does not change the $MAKEFILES variable.
6046 dnl
6047 dnl OpenVMS gets a line overflow on the long eval command, so use a temp file.
6048 dnl
6049 if test -z "${AS_PERL}"; then
6050 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl > conftest.sh
6051 else
6052 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl -nowrap --cygwin-srcdir=$srcdir > conftest.sh
6053 fi
6054 . ./conftest.sh
6055 rm conftest.sh
6056
6057 echo $MAKEFILES > unallmakefiles
6058
6059 mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null
6060
6061 AC_OUTPUT($MAKEFILES)
6062
6063 dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world
6064 if cmp -s config/autoconf.mk config/autoconf.mk.orig; then
6065   echo "config/autoconf.mk is unchanged"
6066   mv -f config/autoconf.mk.orig config/autoconf.mk 2> /dev/null
6067 else
6068   rm -f config/autoconf.mk.orig 2> /dev/null
6069 fi
6070
6071 # Produce the js-config script at configure time; see the comments for
6072 # 'js-config' in Makefile.in.
6073 AC_MSG_RESULT(invoking make to create js-config script)
6074 $GMAKE js-config
6075
6076 # Build jsctypes if it's enabled.
6077 if test "$JS_HAS_CTYPES"; then
6078   # Run the libffi 'configure' script.
6079   ac_configure_args="--disable-shared --enable-static --disable-raw-api"
6080   if test "$MOZ_DEBUG"; then
6081     ac_configure_args="$ac_configure_args --enable-debug"
6082   fi
6083   if test "$DSO_PIC_CFLAGS"; then
6084     ac_configure_args="$ac_configure_args --with-pic"
6085   fi
6086   if test "$CROSS_COMPILE"; then
6087     case "$target" in
6088     *-mingw*)
6089       ac_configure_args="$ac_configure_args --build=$build --host=${target_cpu}-${target_os} HOST_CC=\"$HOST_CC\" CC=\"$CC\""
6090       ;;
6091     *-android*)
6092       CFLAGS="$ANDROID_CFLAGS"
6093       CPPFLAGS="$ANDROID_CPPFLAGS"
6094       LDFLAGS="$ANDROID_LDFLAGS"
6095
6096       export AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS CFLAGS LDFLAGS
6097
6098       ac_configure_args="$ac_configure_args --build=$build --host=${target_cpu}-${target_os} HOST_CC=\"$HOST_CC\""
6099       ;;
6100     *)
6101       ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\" CC=\"$CC\""
6102       ;;
6103     esac
6104   fi
6105   if test "$_MSC_VER"; then
6106     # Use a wrapper script for cl and ml that looks more like gcc.
6107     # autotools can't quite handle an MSVC build environment yet.
6108     ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
6109     case "${target_cpu}" in
6110     x86_64)
6111       # Need target since MSYS tools into mozilla-build may be 32bit
6112       ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/ctypes/libffi/msvcc.sh -m64\" --build=$build --host=$target"
6113       ;;
6114     *)
6115       ac_configure_args="$ac_configure_args CC=$_topsrcdir/ctypes/libffi/msvcc.sh"
6116       ;;
6117     esac
6118   fi
6119   if test "$SOLARIS_SUNPRO_CC"; then
6120     # Always use gcc for libffi on Solaris
6121     if test ! "$HAVE_64BIT_OS"; then
6122       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m32 LD= LDFLAGS="
6123     else
6124       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-m64 LD= LDFLAGS="
6125     fi
6126   fi
6127   if test "$AIX_IBM_XLC"; then
6128     # Always use gcc for libffi on IBM AIX5/AIX6
6129     if test ! "$HAVE_64BIT_OS"; then
6130       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix32"
6131     else
6132       ac_configure_args="$ac_configure_args CC=gcc CFLAGS=-maix64"
6133     fi
6134   fi
6135   if test "$OS_ARCH" = "OS2"; then
6136     ac_configure_args="$ac_configure_args CFLAGS=-Zomf AR=emxomfar"
6137   fi
6138   if test -n "$MOZ_THUMB2"; then
6139     ac_configure_args="$ac_configure_args --enable-thumb2"
6140   fi
6141   if test -n "$MOZ_ARM_ARCH"; then
6142     ac_configure_args="$ac_configure_args --with-cpu-arch=$MOZ_ARM_ARCH"
6143   fi
6144
6145   # Use a separate cache file for libffi, since it does things differently
6146   # from our configure.
6147   mkdir -p $_objdir/ctypes/libffi
6148   old_cache_file=$cache_file
6149   cache_file=$_objdir/ctypes/libffi/config.cache
6150   old_config_files=$CONFIG_FILES
6151   unset CONFIG_FILES
6152   AC_OUTPUT_SUBDIRS(ctypes/libffi)
6153   cache_file=$old_cache_file
6154   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
6155   CONFIG_FILES=$old_config_files
6156 fi
6157