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