Fix copyright notice.
[mozilla-central.git] / configure.in
blobfc6ed433076e74566b5f795be0cced8dbd551bde
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(config/config.mk)
67 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
68 AC_CANONICAL_SYSTEM
69 TARGET_CPU="${target_cpu}"
70 TARGET_VENDOR="${target_vendor}"
71 TARGET_OS="${target_os}"
74 MOZ_DEB_TIMESTAMP=`date +"%a, %d  %b %Y %T %z"   2>&1` 
75 AC_SUBST(MOZ_DEB_TIMESTAMP)
78 dnl ========================================================
79 dnl =
80 dnl = Don't change the following two lines.  Doing so breaks:
81 dnl =
82 dnl = CFLAGS="-foo" ./configure
83 dnl =
84 dnl ========================================================
85 CFLAGS="${CFLAGS=}"
86 CPPFLAGS="${CPPFLAGS=}"
87 CXXFLAGS="${CXXFLAGS=}"
88 LDFLAGS="${LDFLAGS=}"
89 HOST_CFLAGS="${HOST_CFLAGS=}"
90 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
91 HOST_LDFLAGS="${HOST_LDFLAGS=}"
93 dnl ========================================================
94 dnl = Preserve certain environment flags passed to configure
95 dnl = We want sub projects to receive the same flags
96 dnl = untainted by this configure script
97 dnl ========================================================
98 _SUBDIR_CC="$CC"
99 _SUBDIR_CXX="$CXX"
100 _SUBDIR_CFLAGS="$CFLAGS"
101 _SUBDIR_CPPFLAGS="$CPPFLAGS"
102 _SUBDIR_CXXFLAGS="$CXXFLAGS"
103 _SUBDIR_LDFLAGS="$LDFLAGS"
104 _SUBDIR_HOST_CC="$HOST_CC"
105 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
106 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
107 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
108 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
110 dnl Set the version number of the libs included with mozilla
111 dnl ========================================================
112 MOZJPEG=62
113 MOZPNG=10400
114 MOZZLIB=0x1230
115 NSPR_VERSION=4
116 NSS_VERSION=3
118 dnl Set the minimum version of toolkit libs used by mozilla
119 dnl ========================================================
120 GLIB_VERSION=1.2.0
121 LIBIDL_VERSION=0.6.3
122 PERL_VERSION=5.006
123 PYTHON_VERSION=2.4
124 CAIRO_VERSION=1.8.8
125 PANGO_VERSION=1.14.0
126 GTK2_VERSION=2.10.0
127 WINDRES_VERSION=2.14.90
128 W32API_VERSION=3.8
129 GNOMEVFS_VERSION=2.0
130 GNOMEUI_VERSION=2.2.0
131 GCONF_VERSION=1.2.1
132 GIO_VERSION=2.0
133 STARTUP_NOTIFICATION_VERSION=0.8
134 DBUS_VERSION=0.60
135 SQLITE_VERSION=3.6.22
136 LIBNOTIFY_VERSION=0.4
138 MSMANIFEST_TOOL=
140 dnl Set various checks
141 dnl ========================================================
142 MISSING_X=
143 AC_PROG_AWK
145 dnl Initialize the Pthread test variables early so they can be
146 dnl  overridden by each platform.
147 dnl ========================================================
148 USE_PTHREADS=
149 _PTHREAD_LDFLAGS=""
151 dnl Do not allow a separate objdir build if a srcdir build exists.
152 dnl ==============================================================
153 _topsrcdir=`cd \`dirname $0\`; pwd`
154 _objdir=`pwd`
156 if test "$_topsrcdir" != "$_objdir"
157 then
158   # Check for a couple representative files in the source tree
159   _conflict_files=
160   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
161     if test -f $file; then
162       _conflict_files="$_conflict_files $file"
163     fi
164   done
165   if test "$_conflict_files"; then
166     echo "***"
167     echo "*   Your source tree contains these files:"
168     for file in $_conflict_files; do
169       echo "*         $file"
170     done
171     cat 1>&2 <<-EOF
172         *   This indicates that you previously built in the source tree.
173         *   A source tree build can confuse the separate objdir build.
174         *
175         *   To clean up the source tree:
176         *     1. cd $_topsrcdir
177         *     2. gmake distclean
178         ***
179         EOF
180     exit 1
181     break
182   fi
184 MOZ_BUILD_ROOT=`pwd`
186 dnl Default to MSVC for win32 and gcc-4.2 for darwin
187 dnl ==============================================================
188 if test -z "$CROSS_COMPILE"; then
189 case "$target" in
190 *-cygwin*|*-mingw*|*-msvc*|*-mks*)
191     if test -z "$CC"; then CC=cl; fi
192     if test -z "$CXX"; then CXX=cl; fi
193     if test -z "$CPP"; then CPP="cl -E -nologo"; fi
194     if test -z "$CXXCPP"; then CXXCPP="cl -TP -E -nologo"; ac_cv_prog_CXXCPP="$CXXCPP"; fi
195     if test -z "$LD"; then LD=link; fi
196     if test -z "$AS"; then
197         case "${target_cpu}" in
198         i*86)
199             AS=ml;
200             ;;
201         x86_64)
202             AS=ml64;
203             ;;
204         esac
205     fi
206     if test -z "$MIDL"; then MIDL=midl; fi
207     ;;
208 *-darwin*)
209     if test -z "$CC"; then CC=gcc-4.2; fi
210     if test -z "$CXX"; then CXX=g++-4.2; fi
211     ;;
212 esac
215 COMPILE_ENVIRONMENT=1
216 MOZ_ARG_DISABLE_BOOL(compile-environment,
217 [  --disable-compile-environment
218                            Disable compiler/library checks.],
219     COMPILE_ENVIRONMENT= )
220 AC_SUBST(COMPILE_ENVIRONMENT)
222 MOZ_ARG_WITH_STRING(l10n-base,
223 [  --with-l10n-base=DIR     path to l10n repositories],
224     L10NBASEDIR=$withval)
225 if test ! -z "$L10NBASEDIR"; then
226     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
227         AC_MSG_ERROR([--with-l10n-base must specify a path])
228     elif test -d "$L10NBASEDIR"; then
229         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
230     else
231         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
232     fi
234 AC_SUBST(L10NBASEDIR)
236 dnl Check for Perl first -- needed for win32 SDK checks
237 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
238 if test -z "$PERL" || test "$PERL" = ":"; then
239     AC_MSG_ERROR([perl not found in \$PATH])
242 dnl ========================================================
243 dnl Checks for compilers.
244 dnl ========================================================
245 dnl Set CROSS_COMPILE in the environment when running configure
246 dnl to use the cross-compile setup for now
247 dnl ========================================================
249 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
250 AR_FLAGS='cr $@'
252 if test "$COMPILE_ENVIRONMENT"; then
254 dnl Do some special WinCE toolchain stuff
255 case "$target" in
256 *wince|*winmo)
258     MOZ_ARG_WITH_STRING(wince-sdk,
259     [  --with-wince-sdk=WINCE_SDK_DIR
260                         The path to the Windows CE SDK],
261     WINCE_SDK_DIR=$withval)
263     MOZ_ARG_WITH_STRING(ogles-sdk,
264     [  --with-ogles-sdk=OGLES_SDK_DIR
265                         The path to the OGLES SDK],
266     OGLES_SDK_DIR=$withval)
268     AC_DEFINE(WINCE)
269     
270     export WINCE=1
272     echo -----------------------------------------------------------------------------
273     echo Building Windows CE Shunt Library and Tool Chain
274     echo Using SDK in:
275     echo $WINCE_SDK_DIR
277     ac_exeext=.exe
279     _pwd=`pwd -W`
280     _topsrcdirwin=`cd \`dirname $0\`; pwd -W`
281     make OGLES_SDK_DIR="$OGLES_SDK_DIR" WINCE_SDK_DIR="$WINCE_SDK_DIR" \
282     TOPSRCDIR="$_topsrcdirwin" OBJDIR="$_pwd" target="$target" \
283     -C $srcdir/build/wince/tools
285     CC="$_pwd/dist/sdk/bin/$target-gcc.exe"
286     CXX="$_pwd/dist/sdk/bin/$target-gcc.exe"
287     CPP="$_pwd/dist/sdk/bin/$target-gcc.exe -E -nologo"
288     CXXCPP="$_pwd/dist/sdk/bin/$target-gcc.exe -TP -E -nologo"
289     LD="$_pwd/dist/sdk/bin/$target-link.exe"
290     AR="$_pwd/dist/sdk/bin/$target-lib.exe"
291     AS="$_pwd/dist/sdk/bin/$target-as.exe"
292     RC="$_pwd/dist/sdk/bin/$target-res.exe"
295     echo -----------------------------------------------------------------------------
297     ;;
298 esac
300 if test -n "$CROSS_COMPILE" && test "$target" != "$host"; then
301     echo "cross compiling from $host to $target"
302     cross_compiling=yes
304     _SAVE_CC="$CC"
305     _SAVE_CFLAGS="$CFLAGS"
306     _SAVE_LDFLAGS="$LDFLAGS"
308     AC_MSG_CHECKING([for host c compiler])
309     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
310     if test -z "$HOST_CC"; then
311         AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
312     fi
313     AC_MSG_RESULT([$HOST_CC])
314     AC_MSG_CHECKING([for host c++ compiler])
315     AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
316     if test -z "$HOST_CXX"; then
317         AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
318     fi
319     AC_MSG_RESULT([$HOST_CXX])
321     if test -z "$HOST_CFLAGS"; then
322         HOST_CFLAGS="$CFLAGS"
323     fi
324     if test -z "$HOST_CXXFLAGS"; then
325         HOST_CXXFLAGS="$CXXFLAGS"
326     fi
327     if test -z "$HOST_LDFLAGS"; then
328         HOST_LDFLAGS="$LDFLAGS"
329     fi
330     if test -z "$HOST_AR_FLAGS"; then
331         HOST_AR_FLAGS="$AR_FLAGS"
332     fi
333     AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
334     AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
335     CC="$HOST_CC"
336     CFLAGS="$HOST_CFLAGS"
337     LDFLAGS="$HOST_LDFLAGS"
339     AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
340     AC_TRY_COMPILE([], [return(0);], 
341         [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
342         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
344     CC="$HOST_CXX"
345     CFLAGS="$HOST_CXXFLAGS"
347     AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
348     AC_TRY_COMPILE([], [return(0);], 
349         [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
350         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
351     
352     CC=$_SAVE_CC
353     CFLAGS=$_SAVE_CFLAGS
354     LDFLAGS=$_SAVE_LDFLAGS
356     case "$build:$target" in
357       powerpc-apple-darwin8*:i?86-apple-darwin*)
358         dnl The Darwin cross compiler doesn't necessarily point itself at a
359         dnl root that has libraries for the proper architecture, it defaults
360         dnl to the system root.  The libraries in the system root on current
361         dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
362         dnl checks will fail.  Fake a working SDK in that case.
363         _SAVE_CFLAGS=$CFLAGS
364         _SAVE_CXXFLAGS=$CXXLAGS
365         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk $CFLAGS"
366         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk $CXXFLAGS"
367         ;;
368     esac
370     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
371     unset ac_cv_prog_CC
372     AC_PROG_CC
373     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
374     unset ac_cv_prog_CXX
375     AC_PROG_CXX
377     case "$build:$target" in
378       powerpc-apple-darwin8*:i?86-apple-darwin*)
379         dnl Revert the changes made above.  From this point on, the target
380         dnl compiler will never be used without applying the SDK to CFLAGS
381         dnl (see --with-macos-sdk below).
382         CFLAGS=$_SAVE_CFLAGS
383         CXXFLAGS=$_SAVE_CXXFLAGS
384         ;;
385     esac
387     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
388     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
389     MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
390     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
391     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
392     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
393     AC_DEFINE(CROSS_COMPILE)
394 else
395     AC_PROG_CC
396     AC_PROG_CXX
397     AC_PROG_RANLIB
398     MOZ_PATH_PROGS(AS, $AS as, $CC)
399     AC_CHECK_PROGS(AR, ar, :)
400     AC_CHECK_PROGS(LD, ld, :)
401     AC_CHECK_PROGS(STRIP, strip, :)
402     AC_CHECK_PROGS(WINDRES, windres, :)
403     if test -z "$HOST_CC"; then
404         HOST_CC='$(CC)'
405     fi
406     if test -z "$HOST_CFLAGS"; then
407         HOST_CFLAGS='$(CFLAGS)'
408     fi
409     if test -z "$HOST_CXX"; then
410         HOST_CXX='$(CXX)'
411     fi
412     if test -z "$HOST_CXXFLAGS"; then
413         HOST_CXXFLAGS='$(CXXFLAGS)'
414     fi
415     if test -z "$HOST_LDFLAGS"; then
416         HOST_LDFLAGS='$(LDFLAGS)'
417     fi
418     if test -z "$HOST_RANLIB"; then
419         HOST_RANLIB='$(RANLIB)'
420     fi
421     if test -z "$HOST_AR"; then
422         HOST_AR='$(AR)'
423     fi
424     if test -z "$HOST_AR_FLAGS"; then
425         HOST_AR_FLAGS='$(AR_FLAGS)'
426     fi
429 GNU_AS=
430 GNU_LD=
431 GNU_CC=
432 GNU_CXX=
433 CC_VERSION='N/A'
434 CXX_VERSION='N/A'
435 if test "$GCC" = "yes"; then
436     GNU_CC=1
437     CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
439 if test "$GXX" = "yes"; then
440     GNU_CXX=1
441     CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
443 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
444     GNU_AS=1
446 if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
447     GNU_LD=1
449 if test "$GNU_CC"; then
450     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
451         GCC_USE_GNU_LD=1
452     fi
455 INTEL_CC=
456 INTEL_CXX=
457 if test "$GCC" = yes; then
458    if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
459      INTEL_CC=1
460    fi
463 if test "$GXX" = yes; then
464    if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
465      INTEL_CXX=1
466    fi
469 dnl Special win32 checks
470 dnl ========================================================
471 case "$target" in
472 *-wince|*-winmo)
473     WINVER=500
474     WINSDK_TARGETVER=502
475     ;;
477     WINVER=502
478     dnl Target the Windows 7 SDK by default
479     WINSDK_TARGETVER=601
480     ;;
481 esac
484 MOZ_ARG_WITH_STRING(windows-version,
485 [  --with-windows-version=WINSDK_TARGETVER
486                           Highest Windows version to target using this SDK
487                               502: Windows Server 2003
488                               600: Windows Vista
489                               601: Windows 7],
490   WINSDK_TARGETVER=$withval)
492 case "$WINSDK_TARGETVER" in
493 502|600|601)
494     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
495     ;;
498     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER), must be 502, 600 or 601]);
499     ;;
501 esac
503 dnl Vista SDK specific api (deprecated)
504 MOZ_ARG_DISABLE_BOOL(vista-sdk-requirements,
505 [  --disable-vista-sdk-requirements
506                            Do not build Vista SDK specific code],
507    MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=1,
508    MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=$_PLATFORM_MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
509 if test -n "$COMPILE_ENVIRONMENT"; then
510 if test -n "$MOZ_DISABLE_VISTA_SDK_REQUIREMENTS"; then
511     AC_MSG_WARN([--disable-vista-sdk-requirements is deprecated, use --with-windows-version=502 instead])
512     MOZ_WINSDK_TARGETVER=05020000
515 if test "$MOZ_WINSDK_TARGETVER" -lt "06000000"; then
516     MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=1
517     AC_DEFINE(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
518     # We can't build parental controls either
519     MOZ_DISABLE_PARENTAL_CONTROLS=1
523 AC_SUBST(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
525 case "$target" in
526 *-cygwin*|*-mingw*|*-msvc*|*-mks*|*-wince|*-winmo)
527     if test "$GCC" != "yes"; then
528         # Check to see if we are really running in a msvc environemnt
529         _WIN32_MSVC=1
530         AC_CHECK_PROGS(MIDL, midl)
532         # Make sure compilers are valid
533         CFLAGS="$CFLAGS -TC -nologo"
534         CXXFLAGS="$CXXFLAGS -TP -nologo"
535         AC_LANG_SAVE
536         AC_LANG_C
537         AC_TRY_COMPILE([#include <stdio.h>],
538             [ printf("Hello World\n"); ],,
539             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
541         AC_LANG_CPLUSPLUS
542         AC_TRY_COMPILE([#include <new.h>],
543             [ unsigned *test = new unsigned(42); ],,
544             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
545         AC_LANG_RESTORE
546         
547         changequote(,)
548         _MSVC_VER_FILTER='s|.* ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
549         changequote([,])
550         
551         # Determine compiler version
552         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
553         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
554         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
555         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
556         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
557         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
559         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
560         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
562         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
563             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
564         fi
565         if test "$_CC_MAJOR_VERSION" = "13"; then
566             _CC_SUITE=7
567         elif test "$_CC_MAJOR_VERSION" = "14"; then
568             _CC_SUITE=8
569             CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
570             dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
571             dnl so be very specific here!
572             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
573             if test $_CC_RELEASE -gt 50727; then
574                _USE_DYNAMICBASE=1
575             elif test $_CC_BUILD -ge 762; then
576                _USE_DYNAMICBASE=1
577             fi
578             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
579             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
580         elif test "$_CC_MAJOR_VERSION" = "15"; then
581             _CC_SUITE=9
582             CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
583             LDFLAGS="$LDFLAGS -MANIFESTUAC:NO"
584             _USE_DYNAMICBASE=1
585             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
586             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
587         elif test "$_CC_MAJOR_VERSION" = "16"; then
588             _CC_SUITE=10
589             CXXFLAGS="$CXXFLAGS -Zc:wchar_t-"
590             LDFLAGS="$LDFLAGS -MANIFESTUAC:NO"
591             _USE_DYNAMICBASE=1
592             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
593             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
594         else
595             AC_MSG_ERROR([This version of the MSVC compiler, $CC_VERSION , is unsupported.])
596         fi
598         _MOZ_RTTI_FLAGS_ON='-GR'
599         _MOZ_RTTI_FLAGS_OFF='-GR-'
600         _MOZ_EXCEPTIONS_FLAGS_ON='-EHsc'
601         _MOZ_EXCEPTIONS_FLAGS_OFF=''
603         if test -n "$WIN32_REDIST_DIR"; then
604             WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
605         fi
606         
607         # bug #249782
608         # ensure that mt.exe is Microsoft (R) Manifest Tool and not magnetic tape manipulation utility (or something else)
609         if test "$_CC_SUITE" -ge "8"; then
610                 changequote(,)
611                 _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
612                 changequote([,])
614                 MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
615                 if test -n "$MSMT_TOOL"; then
616                         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
617                         if test -z "$MSMANIFEST_TOOL_VERSION"; then
618                                 AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
619                         fi
620                         MSMANIFEST_TOOL=1
621                         unset MSMT_TOOL
622                 else
623                         AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
624                 fi
625         fi
627         # Check linker version
628         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
629         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
630         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
631             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
632         fi
633         INCREMENTAL_LINKER=1
635         # Check midl version
636         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
637         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
638         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
639         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
640         # Add flags if necessary
641         AC_MSG_CHECKING([for midl flags])
642         case "$target" in
643         i*86-*)
644             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
645                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
646                 # MIDL version 7.00.0500 or later has no problem.
647                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
648                 AC_MSG_RESULT([need -env win32])
649             else
650                 AC_MSG_RESULT([none needed])
651             fi
652             ;;
653         x86_64-*)
654             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
655             ;;
656         *)
657             AC_MSG_RESULT([none needed])
658             ;;
659         esac
661         # Identify which version of the SDK we're building with
662         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
663         # from there
664         AC_CHECK_HEADERS([winsdkver.h])
665         if test "$ac_cv_header_winsdkver_h" = "yes"; then
666             # Get the highest _WIN32_WINNT and NTDDI versions supported
667             # Take the higher of the two
668             # This is done because the Windows 7 beta SDK reports its
669             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
670             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
671                            ac_cv_winsdk_maxver,
672                            [cat > conftest.h <<EOF
673 #include <winsdkver.h>
674 #include <sdkddkver.h>
676 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
677 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
678 #else
679 #define WINSDK_MAXVER NTDDI_MAXVER
680 #endif
682 WINSDK_MAXVER
684                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
685                             rm -f conftest.h
686                            ])
687             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
688         else
689             # The Vista SDK is the only one to have sdkddkver.h but not
690             # WinSDKVer.h
691             AC_CHECK_HEADERS([sdkddkver.h])
692             if test "$ac_cv_header_sdkddkver_h" = "yes"; then
693                 MOZ_WINSDK_MAXVER=0x06000000
694             else
695                 # Assume the Server 2003 Platform SDK
696                 MOZ_WINSDK_MAXVER=0x05020000
697             fi
698         fi
700         unset _MSVC_VER_FILTER
702     else
703         # Check w32api version
704         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
705         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
706         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
707         AC_TRY_COMPILE([#include <w32api.h>],
708             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
709                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
710                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
711                 #error "test failed."
712             #endif
713             , [ res=yes ], [ res=no ])
714         AC_MSG_RESULT([$res])
715         if test "$res" != "yes"; then
716             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
717         fi
718         # Check windres version
719         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
720         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
721         AC_MSG_RESULT([$_WINDRES_VERSION])
722         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
723         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
724         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
725         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
726         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
727         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
728         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
729                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
730                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
731                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
732                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
733                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
734         then
735             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
736         fi
738         # Server 2003 is the highest version supported
739         MOZ_WINSDK_MAXVER=0x05020000
740     fi # !GNU_CC
742     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
743     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
744     # Require OS features provided by IE 5.0
745     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0500)
747     # If the maximum version supported by this SDK is lower than the target
748     # version, error out
749     AC_MSG_CHECKING([for Windows SDK being recent enough])
750     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
751         AC_MSG_RESULT("yes")
752     else
753         AC_MSG_RESULT("no")
754         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. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
755     fi
757     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
758     # Definitions matching sdkddkver.h
759     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WS03, 0x05020000)
760     AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
761     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
762     ;;
763 esac
765 dnl Test breaks icc on OS/2 && MSVC
766 if test "$CC" != "icc" -a -z "$_WIN32_MSVC"; then
767     AC_PROG_CC_C_O
768     if grep "NO_MINUS_C_MINUS_O 1" ./confdefs.h >/dev/null; then
769         USING_HCC=1
770         _OLDCC=$CC
771         _OLDCXX=$CXX
772         CC="${srcdir}/build/hcc '$CC'"
773         CXX="${srcdir}/build/hcpp '$CXX'"
774     fi
777 AC_PROG_CPP
778 AC_PROG_CXXCPP
780 if test -n "$_WIN32_MSVC"; then
781     SKIP_PATH_CHECKS=1
782     SKIP_COMPILER_CHECKS=1
783     SKIP_LIBRARY_CHECKS=1
785     # Since we're skipping compiler and library checks, hard-code
786     # some facts here.
787     case "$target" in
788     *-wince|*-winmo)
789         ;;
790     *)
791         AC_DEFINE(HAVE_IO_H)
792         AC_DEFINE(HAVE_SETBUF)
793         AC_DEFINE(HAVE_ISATTY)
794         ;;
795     esac
798 fi # COMPILE_ENVIRONMENT
800 AC_SUBST(MIDL_FLAGS)
801 AC_SUBST(_MSC_VER)
803 AC_SUBST(GNU_AS)
804 AC_SUBST(GNU_LD)
805 AC_SUBST(GNU_CC)
806 AC_SUBST(GNU_CXX)
807 AC_SUBST(INTEL_CC)
808 AC_SUBST(INTEL_CXX)
810 dnl ========================================================
811 dnl Checks for programs.
812 dnl ========================================================
813 AC_PROG_INSTALL
814 AC_PROG_LN_S
816 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
817 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
818 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
819 _perl_res=$?
820 AC_MSG_RESULT([$_perl_version])
822 if test "$_perl_res" != 0; then
823     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
827 AC_MSG_CHECKING([for full perl installation])
828 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
829 _perl_res=$?
830 if test "$_perl_res" != 0; then
831     AC_MSG_RESULT([no])
832     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
833 else
834     AC_MSG_RESULT([yes])    
837 MOZ_PATH_PROGS(PYTHON, $PYTHON python2.5 python2.4 python)
838 if test -z "$PYTHON"; then
839     AC_MSG_ERROR([python was not found in \$PATH])
842 if test -z "$COMPILE_ENVIRONMENT"; then
843     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
845 AC_SUBST(NSINSTALL_BIN)
847 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
848 MOZ_PATH_PROG(WHOAMI, whoami, :)
849 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
850 MOZ_PATH_PROG(UNZIP, unzip, :)
851 MOZ_PATH_PROGS(ZIP, zip)
852 if test -z "$ZIP" || test "$ZIP" = ":"; then
853     AC_MSG_ERROR([zip not found in \$PATH])
855 MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
856 MOZ_PATH_PROG(XARGS, xargs)
857 if test -z "$XARGS" || test "$XARGS" = ":"; then
858     AC_MSG_ERROR([xargs not found in \$PATH .])
861 if test "$COMPILE_ENVIRONMENT"; then
863 dnl ========================================================
864 dnl = Mac OS X toolchain support
865 dnl ========================================================
867 case "$target_os" in
868 darwin*)
869     dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
870     dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
871     dnl the environment and includedir purposes (when using an SDK, below),
872     dnl but remember the full version number for the libdir (SDK).
873     changequote(,)
874     GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
875     GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
876     changequote([,])
877     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
878         dnl Bug 280479, but this keeps popping up in bug 292530 too because
879         dnl 4.0.0/4061 is the default compiler in Tiger.
880         changequote(,)
881         GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
882         changequote([,])
883         if test "$GCC_BUILD" = "4061" ; then
884             AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
885 This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
886 from building Mozilla. Upgrade to Xcode 2.1 or later.])
887         fi
888     fi
890     dnl xcodebuild needs GCC_VERSION defined in the environment, since it
891     dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
892     dnl /usr/bin/g(cc|++)-$GCC_VERSION.
893     MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
895     case "$PBBUILD" in
896       *xcodebuild*)
897         changequote(,)
898         XCODEBUILD_VERSION=`$PBBUILD -version 2>/dev/null | xargs | sed -e 's/.*DevToolsCore-\([0-9]*\).*/\1/'`
899         changequote([,])
900         if test -n "$XCODEBUILD_VERSION" && test "$XCODEBUILD_VERSION" -ge 620 ; then
901           HAS_XCODE_2_1=1;
902         fi
903       ;;
904     esac
906     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
907     dnl it has moved into /usr/bin.
908     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
909     ;;
910 esac
912 AC_SUBST(GCC_VERSION)
913 AC_SUBST(XCODEBUILD_VERSION)
914 AC_SUBST(HAS_XCODE_2_1)
916 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
917 dnl that a universal binary is being produced.
918 AC_SUBST(UNIVERSAL_BINARY)
920 dnl ========================================================
921 dnl Check for MacOS deployment target version
922 dnl ========================================================
924 MOZ_ARG_ENABLE_STRING(macos-target,
925                       [  --enable-macos-target=VER (default=10.5)
926                           Set the minimum MacOS version needed at runtime],
927                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
929 case "$target" in
930 *-darwin*)
931     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
932         dnl Use the specified value
933         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
934         AC_DEFINE_UNQUOTED(__ENVIRONMENT_MAC_OS_X_VERION_MIN_REQUIRED__,$_MACOSX_DEPLOYMENT_TARGET)
935     elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
936         dnl No value specified on the command line or in the environment,
937         dnl use architecture minimum.
938         export MACOSX_DEPLOYMENT_TARGET=10.5
939     fi
940     ;;
941 esac
943 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
945 dnl ========================================================
946 dnl = Mac OS X SDK support
947 dnl ========================================================
948 MACOS_SDK_DIR=
949 NEXT_ROOT=
950 MOZ_ARG_WITH_STRING(macos-sdk,
951 [  --with-macos-sdk=dir   Location of platform SDK to use (Mac OS X only)],
952     MACOS_SDK_DIR=$withval)
954 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
955 dnl NEXT_ROOT will be set and exported only if it's needed.
956 AC_SUBST(MACOS_SDK_DIR)
957 AC_SUBST(NEXT_ROOT)
959 if test "$MACOS_SDK_DIR"; then
960   dnl Sync this section with the ones in NSPR and NSS.
961   dnl Changes to the cross environment here need to be accounted for in
962   dnl the libIDL checks (below) and xpidl build.
964   if test ! -d "$MACOS_SDK_DIR"; then
965     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
966 specify a valid SDK.  SDKs are installed when the optional cross-development
967 tools are selected during the Xcode/Developer Tools installation.])
968   fi
970   GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
971   if test "$GCC_VERSION_MAJOR" -lt "4" ; then
972     AC_MSG_ERROR([You need to upgrade the compiler version to 4.x])
973   else
974     CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
975     CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
977     dnl CPP/CXXCPP needs to be set for AC_CHECK_HEADER.
978     CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
979     CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
981     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
982       dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
983       dnl that supports -syslibroot.  Don't set NEXT_ROOT because it will
984       dnl be ignored and cause warnings when -syslibroot is specified.
985       dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
986       dnl the -isysroot it receives, so this is only needed with 4.0.0.
987       LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
988     fi
989   fi
991   AC_LANG_SAVE
992   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
993   AC_LANG_CPLUSPLUS
994   AC_TRY_COMPILE([#include <new>
995                  int main() { return 0; }],
996    result=yes,
997    result=no)
998   AC_LANG_RESTORE
999   AC_MSG_RESULT($result)
1001   if test "$result" = "no" ; then
1002     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
1003   fi
1006 fi # COMPILE_ENVIRONMENT
1008 if test -n "$MAKE"; then
1009   if test `echo $MAKE | grep -c make.py` != 1; then
1010      NOT_PYMAKE=$MAKE
1011   fi
1014 case "$host_os" in
1015 cygwin*|mingw*|mks*|msvc*)
1016     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
1017     ;;
1019     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
1020     ;;
1021 esac
1022 if test "$GMAKE" = ":"; then
1023    AC_MSG_ERROR([GNU make not found])
1025 AC_SUBST(GMAKE)
1027 if test "$COMPILE_ENVIRONMENT"; then
1029 AC_PATH_XTRA
1031 XCFLAGS="$X_CFLAGS"
1033 fi # COMPILE_ENVIRONMENT
1035 dnl ========================================================
1036 dnl set the defaults first
1037 dnl ========================================================
1038 AS_BIN=$AS
1039 AR_LIST='$(AR) t'
1040 AR_EXTRACT='$(AR) x'
1041 AR_DELETE='$(AR) d'
1042 AS='$(CC)'
1043 AS_DASH_C_FLAG='-c'
1044 DLL_PREFIX=lib
1045 LIB_PREFIX=lib
1046 DLL_SUFFIX=.so
1047 OBJ_SUFFIX=o
1048 LIB_SUFFIX=a
1049 ASM_SUFFIX=s
1050 IMPORT_LIB_SUFFIX=
1051 TARGET_MD_ARCH=unix
1052 DIRENT_INO=d_ino
1053 CYGWIN_WRAPPER=
1054 WIN_TOP_SRC=
1055 MOZ_USER_DIR=".mozilla"
1057 MOZ_JPEG_CFLAGS=
1058 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/jpeg)'
1059 MOZ_ZLIB_CFLAGS=
1060 MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
1061 MOZ_BZ2_CFLAGS=
1062 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
1063 MOZ_PNG_CFLAGS=
1064 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/modules/libimg/png)'
1066 MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
1067 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
1068 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1069 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
1070 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
1071 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1072 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
1074 MOZ_FS_LAYOUT=unix
1076 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1078 USE_DEPENDENT_LIBS=1
1080 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1082 MOZ_ENABLE_POSTSCRIPT=1 
1084 if test -n "$CROSS_COMPILE"; then
1085     OS_TARGET="${target_os}"
1086     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1087     OS_RELEASE=
1088     case "${target_os}" in
1089         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1090         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1091         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1092         mingw*)       OS_ARCH=WINNT ;;
1093         wince*)       OS_ARCH=WINCE ;;
1094         winmo*)       OS_ARCH=WINCE ;;
1095         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1096     esac
1097 else
1098     OS_TARGET=`uname -s`
1099     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1100     OS_RELEASE=`uname -r`
1103 # Before this used `uname -m` when not cross compiling
1104 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1105 OS_TEST="${target_cpu}"
1107 _COMPILER_PREFIX=
1109 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1111 #######################################################################
1112 # Master "Core Components" macros for getting the OS target           #
1113 #######################################################################
1116 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1117 # cross-compilation.
1121 # Define and override various archtecture-specific variables, including
1122 # HOST_OS_ARCH
1123 # OS_ARCH
1124 # OS_TEST
1125 # OS_TARGET
1126 # OS_RELEASE
1127 # OS_MINOR_RELEASE
1130 case "$HOST_OS_ARCH" in
1131 cygwin*|mingw*|mks*|msvc*)
1132     HOST_OS_ARCH=WINNT
1133     ;;
1134 linux*)
1135     HOST_OS_ARCH=Linux
1136     ;;
1137 solaris*)
1138     HOST_OS_ARCH=SunOS
1139     SOLARIS_SUNPRO_CC=
1140     SOLARIS_SUNPRO_CXX=
1141     if test -z "$GNU_CC"; then
1142         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1143             SOLARIS_SUNPRO_CC=1
1144        fi
1145     fi
1147     if test -z "$GNU_CXX"; then
1148        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1149            SOLARIS_SUNPRO_CXX=1
1150        fi
1151     fi
1152     AC_SUBST(SOLARIS_SUNPRO_CC)
1153     AC_SUBST(SOLARIS_SUNPRO_CXX)
1154     ;;
1155 BSD_386)
1156     HOST_OS_ARCH=BSD
1157     ;;
1158 dgux)
1159     HOST_OS_ARCH=DGUX
1160     ;;
1161 IRIX64)
1162     HOST_OS_ARCH=IRIX
1163     ;;
1164 UNIX_SV)
1165     if "`cat /etc/bcheckrc | grep -c NCR 2>/dev/null`" != "0"; then
1166         HOST_OS_ARCH=NCR
1167     else
1168         HOST_OS_ARCH=UNIXWARE
1169     fi
1170     ;;
1171 ncr)
1172     HOST_OS_ARCH=NCR
1173     ;;
1174 UNIX_SYSTEM_V)
1175     HOST_OS_ARCH=NEC
1176     ;;
1177 OSF1)
1178     ;;
1179 *OpenVMS*)
1180     HOST_OS_ARCH=OpenVMS
1181     ;;
1182 OS_2)
1183     HOST_OS_ARCH=OS2
1184     ;;
1185 QNX)
1186     ;;
1187 SCO_SV)
1188     HOST_OS_ARCH=SCOOS
1189     ;;
1190 SINIX-N | SINIX-Y | SINIX-Z |ReliantUNIX-M)
1191     HOST_OS_ARCH=SINIX
1192     ;;
1193 UnixWare)
1194     HOST_OS_ARCH=UNIXWARE
1195     ;;
1196 esac
1198 case "$OS_ARCH" in
1199 WINNT)
1200     if test -z "$CROSS_COMPILE" ; then
1201         OS_TEST=`uname -p`
1202     fi
1203     ;;
1204 Windows_NT)
1206 # If uname -s returns "Windows_NT", we assume that we are using
1207 # the uname.exe in MKS toolkit.
1209 # The -r option of MKS uname only returns the major version number.
1210 # So we need to use its -v option to get the minor version number.
1211 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1213     OS_ARCH=WINNT
1214     OS_TARGET=WINNT
1215     OS_MINOR_RELEASE=`uname -v`
1216     if test "$OS_MINOR_RELEASE" = "00"; then
1217         OS_MINOR_RELEASE=0
1218     fi
1219     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1220     ;;
1221 CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*)
1223 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
1224 # the uname.exe in the Cygwin tools.
1225 # Prior to the Beta 20 release, Cygwin was called GNU-Win32.
1226 # If uname -s returns "CYGWIN32/NT", we assume that we are using
1227 # the uname.exe in the GNU-Win32 tools.
1228 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1229 # the uname.exe in the MSYS tools.
1231     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1232     OS_ARCH=WINNT
1233     OS_TARGET=WINNT
1234     ;;
1235 AIX)
1236     OS_RELEASE=`uname -v`.`uname -r`
1237     OS_TEST=${target_cpu}
1238     ;;
1239 BSD_386)
1240     OS_ARCH=BSD
1241     ;;
1242 dgux)
1243     OS_ARCH=DGUX
1244     ;;
1245 IRIX64)
1246     OS_ARCH=IRIX
1247     ;;
1248 UNIX_SV)
1249     if "`cat /etc/bcheckrc | grep -c NCR 2>/dev/null`" != "0"; then
1250         OS_ARCH=NCR
1251     else
1252         OS_ARCH=UNIXWARE
1253         OS_RELEASE=`uname -v`
1254     fi
1255     ;;
1256 ncr)
1257     OS_ARCH=NCR
1258     ;;
1259 UNIX_SYSTEM_V)
1260     OS_ARCH=NEC
1261     ;;
1262 OSF1)
1263     case `uname -v` in
1264     148)
1265         OS_RELEASE=V3.2C
1266         ;;
1267     564)
1268         OS_RELEASE=V4.0B
1269         ;;
1270     878)
1271         OS_RELEASE=V4.0D
1272         ;;
1273     esac
1274     ;;
1275 *OpenVMS*)
1276     OS_ARCH=OpenVMS
1277     OS_RELEASE=`uname -v`
1278     OS_TEST=`uname -p`
1279     ;;
1280 OS_2)
1281     OS_ARCH=OS2
1282     OS_TARGET=OS2
1283     OS_RELEASE=`uname -v`
1284     ;;
1285 QNX)
1286     if test "$OS_TARGET" != "NTO"; then
1287         changequote(,)
1288         OS_RELEASE=`uname -v | sed 's/^\([0-9]\)\([0-9]*\)$/\1.\2/'`
1289         changequote([,])
1290     fi
1291     OS_TEST=x86
1292     ;;
1293 SCO_SV)
1294     OS_ARCH=SCOOS
1295     OS_RELEASE=5.0
1296     ;;
1297 SINIX-N | SINIX-Y | SINIX-Z |ReliantUNIX-M)
1298     OS_ARCH=SINIX
1299     OS_TEST=`uname -p`
1300     ;;
1301 UnixWare)
1302     OS_ARCH=UNIXWARE
1303     OS_RELEASE=`uname -v`
1304     ;;
1305 WINCE)
1306     OS_ARCH=WINCE
1307     case "${target_os}" in
1308     *winmo)
1309         OS_TARGET=WINMO
1310         WINCE_WINDOWS_MOBILE=1
1311         AC_DEFINE(WINCE_WINDOWS_MOBILE)
1312         ;;
1313     *)
1314         OS_TARGET=WINCE
1315         ;;
1316     esac
1317     ;;
1318 Darwin)
1319     case "${target_cpu}" in
1320     powerpc*)
1321         OS_TEST=ppc
1322         ;;
1323     i*86*)
1324         OS_TEST=i386 
1325         ;;
1326     x86_64)
1327         OS_TEST=x86_64
1328         ;;
1329     *)
1330         if test -z "$CROSS_COMPILE" ; then
1331             OS_TEST=`uname -p`
1332         fi
1333         ;;
1334     esac
1335     ;;
1336 esac
1338 if test "$OS_ARCH" = "NCR"; then
1339     changequote(,)
1340     OS_RELEASE=`awk '{print $3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$/\2.\3/'`
1341     changequote([,])
1344 # Only set CPU_ARCH if we recognize the value of OS_TEST
1346 case "$OS_TEST" in
1347 *86 | i86pc)
1348     CPU_ARCH=x86
1349     ;;
1351 powerpc64 | ppc64)
1352     CPU_ARCH=ppc64
1353     ;;
1355 powerpc | ppc | rs6000)
1356     CPU_ARCH=ppc
1357     ;;
1359 Alpha | alpha | ALPHA)
1360     CPU_ARCH=Alpha
1361     ;;
1363 s390)
1364     CPU_ARCH=s390
1365     ;;
1367 s390x)
1368     CPU_ARCH=s390x
1369     ;;
1371 hppa* | parisc)
1372     CPU_ARCH=hppa
1373     ;;
1375 sun4u | sparc*)
1376     CPU_ARCH=sparc
1377     ;;
1379 x86_64 | ia64)
1380     CPU_ARCH="$OS_TEST"
1381     ;;
1383 arm)
1384     if test "$OS_TARGET" = "WINCE"; then
1385         CPU_ARCH="$OS_TEST"
1386     fi
1387     ;;
1388 esac
1390 if test -z "$OS_TARGET"; then
1391     OS_TARGET=$OS_ARCH
1393 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1395 dnl ========================================================
1396 dnl GNU specific defaults
1397 dnl ========================================================
1398 if test "$GNU_CC"; then
1399     # FIXME: Let us build with strict aliasing. bug 414641.
1400     CFLAGS="$CFLAGS -fno-strict-aliasing"
1401     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1402     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1403     DSO_LDOPTS='-shared'
1404     if test "$GCC_USE_GNU_LD"; then
1405         # Don't allow undefined symbols in libraries
1406         DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1407     fi
1408     WARNINGS_AS_ERRORS='-Werror'
1409     DSO_CFLAGS=''
1410     DSO_PIC_CFLAGS='-fPIC'
1411     ASFLAGS="$ASFLAGS -fPIC"
1412     _MOZ_RTTI_FLAGS_ON=${_COMPILER_PREFIX}-frtti
1413     _MOZ_RTTI_FLAGS_OFF=${_COMPILER_PREFIX}-fno-rtti
1414     _MOZ_EXCEPTIONS_FLAGS_ON='-fhandle-exceptions'
1415     _MOZ_EXCEPTIONS_FLAGS_OFF='-fno-handle-exceptions'
1417     # Turn on GNU specific features
1418     # -Wall - turn on all warnings
1419     # -pedantic - make compiler warn about non-ANSI stuff, and
1420     #             be a little bit stricter
1421     # Warnings slamm took out for now (these were giving more noise than help):
1422     # -Wbad-function-cast - warns when casting a function to a new return type
1423     # -Wshadow - removed because it generates more noise than help --pete
1424     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith"
1425     if test -z "$INTEL_CC"; then
1426        # Don't use -Wcast-align with ICC
1427        case "$CPU_ARCH" in
1428            # And don't use it on hppa, ia64, sparc, since it's noisy there
1429            hppa | ia64 | sparc)
1430            ;;
1431            *)
1432         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1433            ;;
1434        esac
1435     fi
1437     dnl Turn pedantic on but disable the warnings for long long
1438     _PEDANTIC=1
1440     if test -z "$INTEL_CC"; then
1441       _IGNORE_LONG_LONG_WARNINGS=1
1442       _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
1443     else
1444       _IGNORE_LONG_LONG_WARNINGS=
1445     fi
1448     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1449     _USE_CPP_INCLUDE_FLAG=1
1450 elif test "$SOLARIS_SUNPRO_CC"; then
1451     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1452     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1454     DSO_LDOPTS='-shared'
1455     if test "$GNU_LD"; then
1456         # Don't allow undefined symbols in libraries
1457         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1458     fi
1460     DSO_CFLAGS=''
1461     if test "$CPU_ARCH" = "sparc"; then
1462         # for Sun Studio on Solaris/SPARC
1463         DSO_PIC_CFLAGS='-xcode=pic32'
1464     else
1465         DSO_PIC_CFLAGS='-KPIC'
1466     fi
1467     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1468 else
1469     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1470     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1472     DSO_LDOPTS='-shared'
1473     if test "$GNU_LD"; then
1474         # Don't allow undefined symbols in libraries
1475         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1476     fi
1478     DSO_CFLAGS=''
1479     DSO_PIC_CFLAGS='-KPIC'
1480     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1483 if test "$GNU_CXX"; then
1484     # FIXME: Let us build with strict aliasing. bug 414641.
1485     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
1486     # Turn on GNU specific features
1487     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
1488     if test -z "$INTEL_CC"; then
1489        # Don't use -Wcast-align with ICC
1490        case "$CPU_ARCH" in
1491            # And don't use it on hppa, ia64, sparc, since it's noisy there
1492            hppa | ia64 | sparc)
1493            ;;
1494            *)
1495         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1496            ;;
1497        esac
1498     fi
1500     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1501     _USE_CPP_INCLUDE_FLAG=1
1503     AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
1504                    ac_has_wno_invalid_offsetof,
1505         [
1506             AC_LANG_SAVE
1507             AC_LANG_CPLUSPLUS
1508             _SAVE_CXXFLAGS="$CXXFLAGS"
1509             CXXFLAGS="$CXXFLAGS ${_COMPILER_PREFIX}-Wno-invalid-offsetof"
1510             AC_TRY_COMPILE([],
1511                            [return(0);],
1512                            ac_has_wno_invalid_offsetof="yes",
1513                            ac_has_wno_invalid_offsetof="no")
1514             CXXFLAGS="$_SAVE_CXXFLAGS"
1515             AC_LANG_RESTORE
1516         ])
1517     if test "$ac_has_wno_invalid_offsetof" = "yes"; then
1518         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-invalid-offsetof"
1519     fi
1521     AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
1522                    ac_has_wno_variadic_macros,
1523         [
1524             AC_LANG_SAVE
1525             AC_LANG_CPLUSPLUS
1526             _SAVE_CXXFLAGS="$CXXFLAGS"
1527             CXXFLAGS="$CXXFLAGS ${_COMPILER_PREFIX}-Wno-variadic-macros"
1528             AC_TRY_COMPILE([],
1529                            [return(0);],
1530                            ac_has_wno_variadic_macros="yes",
1531                            ac_has_wno_variadic_macros="no")
1532             CXXFLAGS="$_SAVE_CXXFLAGS"
1533             AC_LANG_RESTORE
1534         ])
1535     if test "$ac_has_wno_variadic_macros" = "yes"; then
1536         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-variadic-macros"
1537     fi
1539     AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
1540                    ac_has_werror_return_type,
1541         [
1542             AC_LANG_SAVE
1543             AC_LANG_CPLUSPLUS
1544             _SAVE_CXXFLAGS="$CXXFLAGS"
1545             CXXFLAGS="$CXXFLAGS -Werror=return-type"
1546             AC_TRY_COMPILE([],
1547                            [return(0);],
1548                            ac_has_werror_return_type="yes",
1549                            ac_has_werror_return_type="no")
1550             CXXFLAGS="$_SAVE_CXXFLAGS"
1551             AC_LANG_RESTORE
1552         ])
1553     if test "$ac_has_werror_return_type" = "yes"; then
1554         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
1555     fi
1557 else
1558     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1561 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1562 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1563 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1564 dnl normal behavior.
1565 dnl ========================================================
1566 MKSHLIB_FORCE_ALL=
1567 MKSHLIB_UNFORCE_ALL=
1569 if test "$COMPILE_ENVIRONMENT"; then
1570 if test "$GNU_CC"; then
1571   AC_MSG_CHECKING(whether ld has archive extraction flags)
1572   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1573    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1574     ac_cv_mkshlib_force_and_unforce="no"
1575     exec 3<&0 <<LOOP_INPUT
1576         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1577         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1578         force="-Wl,-all";              unforce="-Wl,-none"
1579 LOOP_INPUT
1580     while read line
1581     do
1582       eval $line
1583       LDFLAGS=$force
1584       LIBS=$unforce
1585       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1586     done
1587     exec 0<&3 3<&-
1588     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1589    ])
1590   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1591     AC_MSG_RESULT(no)
1592   else
1593     AC_MSG_RESULT(yes)
1594     eval $ac_cv_mkshlib_force_and_unforce
1595     MKSHLIB_FORCE_ALL=$force
1596     MKSHLIB_UNFORCE_ALL=$unforce
1597   fi
1598 fi # GNU_CC
1599 fi # COMPILE_ENVIRONMENT
1601 dnl =================================================================
1602 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1603 dnl which is bad when cross compiling.
1604 dnl =================================================================
1605 if test "$COMPILE_ENVIRONMENT"; then
1606 configure_static_assert_macros='
1607 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1608 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1609 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1612 dnl test that the macros actually work:
1613 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1614 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1615  [AC_LANG_SAVE
1616   AC_LANG_C
1617   ac_cv_static_assertion_macros_work="yes"
1618   AC_TRY_COMPILE([$configure_static_assert_macros],
1619                  [CONFIGURE_STATIC_ASSERT(1)],
1620                  ,
1621                  ac_cv_static_assertion_macros_work="no")
1622   AC_TRY_COMPILE([$configure_static_assert_macros],
1623                  [CONFIGURE_STATIC_ASSERT(0)],
1624                  ac_cv_static_assertion_macros_work="no",
1625                  )
1626   AC_LANG_CPLUSPLUS
1627   AC_TRY_COMPILE([$configure_static_assert_macros],
1628                  [CONFIGURE_STATIC_ASSERT(1)],
1629                  ,
1630                  ac_cv_static_assertion_macros_work="no")
1631   AC_TRY_COMPILE([$configure_static_assert_macros],
1632                  [CONFIGURE_STATIC_ASSERT(0)],
1633                  ac_cv_static_assertion_macros_work="no",
1634                  )
1635   AC_LANG_RESTORE
1636  ])
1637 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1638 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1639     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1641 fi # COMPILE_ENVIRONMENT
1643 dnl ========================================================
1644 dnl Checking for 64-bit OS
1645 dnl ========================================================
1646 if test "$COMPILE_ENVIRONMENT"; then
1647 AC_LANG_SAVE
1648 AC_LANG_C
1649 AC_MSG_CHECKING(for 64-bit OS)
1650 AC_TRY_COMPILE([$configure_static_assert_macros],
1651                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1652                result="yes", result="no")
1653 AC_MSG_RESULT("$result")
1654 if test "$result" = "yes"; then
1655     AC_DEFINE(HAVE_64BIT_OS)
1656     HAVE_64BIT_OS=1
1658 AC_SUBST(HAVE_64BIT_OS)
1659 AC_LANG_RESTORE
1660 fi # COMPILE_ENVIRONMENT
1662 dnl ========================================================
1663 dnl Enable high-memory support on OS/2 by default.
1664 dnl ========================================================
1665 MOZ_OS2_HIGH_MEMORY=1
1666 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1667 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1668     MOZ_OS2_HIGH_MEMORY=,
1669     MOZ_OS2_HIGH_MEMORY=1 )
1670 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1672 dnl ========================================================
1673 dnl System overrides of the defaults for host
1674 dnl ========================================================
1675 case "$host" in
1676 *-beos*)
1677     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE -DNO_X11"
1678     HOST_NSPR_MDCPUCFG='\"md/_beos.cfg\"'
1679     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1680     ;;
1682 *cygwin*|*mingw*|*mks*|*msvc*|*wince|*winmo)
1683     # we need Python 2.5 on Windows
1684     PYTHON_VERSION=2.5
1685     if test -n "$_WIN32_MSVC"; then
1686         HOST_AR=lib
1687         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1688         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1689         HOST_RANLIB='echo ranlib'
1690     else
1691         HOST_CFLAGS="$HOST_CFLAGS -mno-cygwin"
1692     fi
1693     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11"
1694     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1695     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1696     HOST_BIN_SUFFIX=.exe
1697     case "$host" in
1698     *mingw*)
1699     dnl MinGW/MSYS does not need CYGWIN_WRAPPER
1700         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1701         ;;
1702     *)
1703         CYGWIN_WRAPPER="${srcdir}/build/cygwin-wrapper"
1704         if test "`echo ${srcdir} | grep -c ^/ 2>/dev/null`" = 0; then
1705             _pwd=`pwd`
1706             CYGWIN_WRAPPER="${_pwd}/${srcdir}/build/cygwin-wrapper"
1707         fi
1708         if test "`${PERL} -v | grep -c cygwin  2>/dev/null`" = 0; then
1709             AS_PERL=1
1710             PERL="${CYGWIN_WRAPPER} $PERL"
1711         fi
1713         if test "`${PYTHON} -c 'import sys; print sys.platform;'`" != "cygwin"; then
1714             PYTHON="${CYGWIN_WRAPPER} $PYTHON"
1715         fi
1716         ;;
1717     esac
1719     case "${host_cpu}" in
1720     x86_64)
1721         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1722         ;;
1723     esac
1724     ;;
1726 *-darwin*)
1727     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1728     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1729     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1730     ;;
1732 *-linux*|*-kfreebsd*-gnu)
1733     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1734     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1735     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1736     ;;
1738 *os2*)
1739     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1740     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1741     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1742     HOST_BIN_SUFFIX=.exe
1743     MOZ_FIX_LINK_PATHS=
1744     ;;
1746 *-osf*)
1747     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1748     HOST_NSPR_MDCPUCFG='\"md/_osf1.cfg\"'
1749     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1750     ;;
1753     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1754     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1755     ;;
1756 esac
1758 dnl We require version 2.4 or newer of Python to build,
1759 dnl and 2.5 or newer on Windows.
1760 AC_MSG_CHECKING([for minimum required Python version >= $PYTHON_VERSION])
1761 changequote(,)
1762 $PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1])" $PYTHON_VERSION
1763 _python_res=$?
1764 changequote([,])
1765 if test "$_python_res" != 0; then
1766     AC_MSG_ERROR([Python $PYTHON_VERSION or higher is required.])
1768 AC_MSG_RESULT([yes])
1770 dnl Get mozilla version from central milestone file
1771 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1773 dnl Get version of various core apps from the version files.
1774 FIREFOX_VERSION=`cat $topsrcdir/browser/config/version.txt`
1776 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1777 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1779 dnl ========================================================
1780 dnl System overrides of the defaults for target
1781 dnl ========================================================
1783 case "$target" in
1784 *-aix*)
1785     AC_DEFINE(AIX)
1786     if test ! "$GNU_CC"; then
1787         if test ! "$HAVE_64BIT_OS"; then
1788             # Compiling with Visual Age C++ object model compat is the
1789             # default. To compile with object model ibm, add 
1790             # AIX_OBJMODEL=ibm to .mozconfig.
1791             if test "$AIX_OBJMODEL" = "ibm"; then
1792                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1793             else
1794                 AIX_OBJMODEL=compat
1795             fi
1796         else
1797             AIX_OBJMODEL=compat
1798         fi
1799         AC_SUBST(AIX_OBJMODEL)
1800         DSO_LDOPTS='-qmkshrobj=1'
1801         DSO_CFLAGS='-qflag=w:w'
1802         DSO_PIC_CFLAGS=
1803         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1804         AC_MSG_WARN([Clearing MOZ_FIX_LINK_PATHS till we can fix bug 332075.])
1805         MOZ_FIX_LINK_PATHS=
1806         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1807         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1808         if test "$COMPILE_ENVIRONMENT"; then
1809             AC_LANG_SAVE
1810             AC_LANG_CPLUSPLUS
1811             AC_MSG_CHECKING([for VisualAge C++ compiler version >= 6.0.0.3])
1812             AC_TRY_COMPILE([],
1813                 [#if (__IBMCPP__ < 600)
1814                  #error "Bad compiler"
1815                  #endif],
1816                 _BAD_COMPILER=,_BAD_COMPILER=1)
1817             if test -n "$_BAD_COMPILER"; then
1818                 AC_MSG_RESULT([no])    
1819                 AC_MSG_ERROR([VisualAge C++ version 6.0.0.3 or higher is required to build.])
1820             else
1821                 AC_MSG_RESULT([yes])    
1822             fi
1823             AC_LANG_RESTORE
1824             TARGET_COMPILER_ABI="ibmc"
1825             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1826             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1827         fi
1828     fi
1829     case "${target_os}" in
1830     aix4.1*)
1831         DLL_SUFFIX='_shr.a'
1832         ;;
1833     esac
1834     if test "$COMPILE_ENVIRONMENT"; then
1835         AC_CHECK_HEADERS(sys/inttypes.h)
1836     fi
1837     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1838     ;;
1840 *-beos*)
1841     no_x=yes
1842     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1843     _PLATFORM_DEFAULT_TOOLKIT="cairo-beos"
1844     DSO_LDOPTS='-nostart'
1845     TK_LIBS='-lbe -lroot'
1846     LIBS="$LIBS -lbe"
1847     if test "$COMPILE_ENVIRONMENT"; then
1848         AC_CHECK_LIB(bind,main,LIBS="$LIBS -lbind")
1849         AC_CHECK_LIB(zeta,main,LIBS="$LIBS -lzeta")
1850     fi
1851     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-multichar"
1852     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-multichar"
1853     _MOZ_USE_RTTI=1
1854     USE_DEPENDENT_LIBS=
1855     MOZ_USER_DIR="Mozilla"
1856     ;;
1858 *-bsdi*)
1859     dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
1860     _PEDANTIC=
1861     _IGNORE_LONG_LONG_WARNINGS=
1862     case $OS_RELEASE in
1863         4.*|5.*)
1864             STRIP="$STRIP -d"
1865             ;;
1866         *)
1867             DSO_CFLAGS=''
1868             DSO_LDOPTS='-r'
1869             _WARNINGS_CFLAGS="-Wall"
1870             _WARNINGS_CXXFLAGS="-Wall"
1871             # The test above doesn't work properly, at least on 3.1.
1872             MKSHLIB_FORCE_ALL=''
1873             MKSHLIB_UNFORCE_ALL=''
1874         ;;
1875     esac
1876     ;;
1878 *-darwin*) 
1879     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1880     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1881     MOZ_OPTIMIZE_FLAGS="-O3"
1882     _PEDANTIC=
1883     CFLAGS="$CFLAGS -fpascal-strings -fno-common"
1884     CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
1885     DLL_SUFFIX=".dylib"
1886     DSO_LDOPTS=''
1887     STRIP="$STRIP -x -S"
1888     _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1889     MOZ_ENABLE_POSTSCRIPT=
1890     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1891     # The ExceptionHandling framework is needed for Objective-C exception
1892     # logging code in nsObjCExceptions.h. Currently we only use that in debug
1893     # builds.
1894     MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
1896     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1897     dnl ===================================================================
1898     if test "x$enable_dtrace" = "xyes"; then
1899         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1900     else
1901         dnl check for the presence of the -dead_strip linker flag
1902         AC_MSG_CHECKING([for -dead_strip option to ld])
1903         _SAVE_LDFLAGS=$LDFLAGS
1904         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1905         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1906         if test -n "$_HAVE_DEAD_STRIP" ; then
1907             AC_MSG_RESULT([yes])
1908             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1909         else
1910             AC_MSG_RESULT([no])
1911         fi
1912         
1913         LDFLAGS=$_SAVE_LDFLAGS
1914     fi
1915     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
1916     ;;
1918 *-freebsd*)
1919     if test `test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` != "elf"; then
1920         DLL_SUFFIX=".so.1.0"
1921         DSO_LDOPTS="-shared"
1922     fi
1923     if test ! "$GNU_CC"; then
1924         DSO_LDOPTS="-Bshareable $DSO_LDOPTS"
1925     fi
1926 # Can't have force w/o an unforce.
1927 #    # Hack for FreeBSD 2.2
1928 #    if test -z "$MKSHLIB_FORCE_ALL"; then
1929 #       MKSHLIB_FORCE_ALL='-Wl,-Bforcearchive'
1930 #       MKSHLIB_UNFORCE_ALL=''
1931 #    fi
1932     ;; 
1934 *-hpux*)
1935     DLL_SUFFIX=".sl"
1936     if test ! "$GNU_CC"; then
1937         DSO_LDOPTS='-b -Wl,+s'
1938         DSO_CFLAGS=""
1939         DSO_PIC_CFLAGS="+Z"
1940         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
1941         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
1942         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1943     else
1944         DSO_LDOPTS='-b -E +s'
1945         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1946         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1947     fi
1948     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
1949     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1950     ;;
1952 *-irix5*)
1953     AC_DEFINE(IRIX)
1954     DSO_LDOPTS='-elf -shared'
1956     if test "$GNU_CC"; then
1957        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1958        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1959        MKSHLIB_FORCE_ALL='-Wl,-all'
1960        MKSHLIB_UNFORCE_ALL='-Wl,-none'
1961        CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
1962     else
1963        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1964        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1965        MKSHLIB_FORCE_ALL='-all'
1966        MKSHLIB_UNFORCE_ALL='-none'
1967     fi
1968     ;;
1970 *-irix6*)
1971     AC_DEFINE(IRIX)
1972     dnl the irix specific xptcinvoke code is written against the n32 ABI so we *must* 
1973     dnl compile and link using -n32
1974     USE_N32=1
1975     TARGET_COMPILER_ABI=n32
1976     DSO_LDOPTS='-elf -shared'
1977     MKSHLIB='$(CCC) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1978     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1979     _MOZ_EXCEPTIONS_FLAGS_OFF="-LANG:exceptions=OFF"
1980     _MOZ_EXCEPTIONS_FLAGS_ON="-LANG:exceptions=ON"
1981     if test "$GNU_CC"; then
1982        MKSHLIB_FORCE_ALL='-Wl,-all'
1983        MKSHLIB_UNFORCE_ALL='-Wl,-none'
1984        _WARNINGS_CFLAGS="-Wall"
1985        _WARNINGS_CXXFLAGS="-Wall"
1986        CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS"
1987     else
1988        MKSHLIB_FORCE_ALL='-all'
1989        MKSHLIB_UNFORCE_ALL='-none'
1990            AR_LIST="$AR t"
1991            AR_EXTRACT="$AR x"
1992            AR_DELETE="$AR d"
1993            AR='$(CXX) -ar'
1994            AR_FLAGS='-o $@'
1995        CFLAGS="$CFLAGS -woff 3262 -G 4"
1996        CXXFLAGS="$CXXFLAGS -woff 3262 -G 4"
1997        if test -n "$USE_N32"; then
1998            ASFLAGS="$ASFLAGS -n32"
1999            CFLAGS="$CFLAGS -n32"
2000            CXXFLAGS="$CXXFLAGS -n32"
2001            LDFLAGS="$LDFLAGS -n32"
2002        fi
2003        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2004        AC_MSG_WARN([Clearing MOZ_FIX_LINK_PATHS for OSF/1 as fix for bug 333545 (till the reference bug 332075 is fixed.])
2005        MOZ_FIX_LINK_PATHS=
2006     fi
2007     if test -z "$GNU_CXX"; then
2008       MIPSPRO_CXX=1
2009     fi
2010     ;;
2012 *-*linux*)
2013     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2014     # Similarly for GNU_CXX and INTEL_CXX.
2015     if test "$INTEL_CC" || test "$INTEL_CXX"; then
2016         # -Os has been broken on Intel's C/C++ compilers for quite a
2017         # while; Intel recommends against using it.
2018         MOZ_OPTIMIZE_FLAGS="-O2"
2019         MOZ_DEBUG_FLAGS="-g"
2020     elif test "$GNU_CC" || test "$GNU_CXX"; then
2021         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2022         case $GCC_VERSION in
2023         4.1.*|4.2.*)
2024             # -Os is broken on gcc 4.1.x and 4.2.x, we need to tweak it to get good results.
2025             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2026         esac
2027         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_SIZE_TWEAK"
2028         MOZ_DEBUG_FLAGS="-g"
2029     fi
2031     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2033     MOZ_MEMORY=1
2035     case "${target_cpu}" in
2036     alpha*)
2037         CFLAGS="$CFLAGS -mieee"
2038         CXXFLAGS="$CXXFLAGS -mieee"
2039     ;;
2040     i*86)
2041         USE_ELF_DYNSTR_GC=1
2042     ;;
2043     mips*)
2044         MOZ_DEBUG_FLAGS="-g" # We want inlining
2045     ;;
2046     esac
2047     ;;
2049 *-wince*|*-winmo*)
2050     TARGET_COMPILER_ABI=msvc
2051     _PLATFORM_DEFAULT_TOOLKIT=cairo-windows
2052     _PLATFORM_MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=1
2053     MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2054     MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2055     AR_LIST="$AR -list"
2056     AR_EXTRACT="$AR -extract"
2057     AR_DELETE="$AR d"
2058     AR_FLAGS='-OUT:"$@"'
2059     MOZ_MEMORY=1
2060     NSS_DISABLE_DBM=1
2061     MOZ_OGG=
2062     ac_configure_args="$ac_configure_args --enable-win32-target=WINCE"
2064     if test "$AS_BIN"; then
2065         AS="$AS_BIN"
2066     fi
2067     DSO_CFLAGS=
2068     DSO_PIC_CFLAGS=
2069     DLL_SUFFIX=.dll
2070     BIN_SUFFIX='.exe'
2071     if test -z "$RC"; then 
2072         RC=rc.exe  
2073     fi
2074     # certain versions of cygwin's makedepend barf on the 
2075     # #include <string> vs -I./dist/include/string issue so don't use it
2076     SYSTEM_MAKEDEPEND=
2078     HOST_CC=cl
2079     HOST_CXX=cl
2080     HOST_LD=link
2081     HOST_AR='lib -OUT:$@'
2082     HOST_RANLIB='echo ranlib'
2083     HOST_CFLAGS="$HOST_CFLAGS -D_X86_"
2084         
2085         
2086     WARNINGS_AS_ERRORS='-WX'
2087     MOZ_OPTIMIZE_FLAGS='-Ox'
2088     AR_FLAGS='-NOLOGO -OUT:"$@"'
2089     ASM_SUFFIX=asm
2090     CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2091     CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2092     DLL_PREFIX=
2093     DOXYGEN=:
2094     DSO_LDOPTS=-SUBSYSTEM:WINDOWSCE
2095     DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2096     GARBAGE=
2097     IMPORT_LIB_SUFFIX=lib
2098     dnl Need to force-link against mozalloc because it's used in the shunt
2099     LIBS="$LIBS \$(LIBXUL_DIST)/lib/mozalloc.lib"
2100     LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2101     LIB_PREFIX=
2102     LIB_SUFFIX=lib 
2103     MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
2104     MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
2105     MKSHLIB_FORCE_ALL=
2106     MKSHLIB_UNFORCE_ALL=
2107     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2108     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2109     MOZ_DEBUG_FLAGS='-Zi'
2110     MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2111     MOZ_FIX_LINK_PATHS=
2112     MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
2113     OBJ_SUFFIX=obj
2114     RANLIB='echo not_ranlib'
2115     STRIP='echo not_strip'
2116     TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
2117     UNZIP=unzip
2118     XARGS=xargs
2119     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2120     ZIP=zip
2121     LIBIDL_CFLAGS="-I$MOZ_TOOLS_DIR/include ${GLIB_CFLAGS}"
2122     LIBIDL_LIBS="$MOZ_TOOLS_DIR/lib/libidl-0.6_s.lib $MOZ_TOOLS_DIR/lib/glib-1.2_s.lib"
2123     STATIC_LIBIDL=1
2124     MOZ_TREE_FREETYPE=1
2126     AC_DEFINE(HAVE_SNPRINTF)
2127     AC_DEFINE(_WINDOWS)
2128     AC_DEFINE(WIN32)
2129     AC_DEFINE(XP_WIN)
2130     AC_DEFINE(XP_WIN32)
2131     AC_DEFINE(HW_THREADS)
2132     AC_DEFINE(STDC_HEADERS)
2133     AC_DEFINE(NEW_H, <new>)
2134     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2135     AC_DEFINE(HAVE_LOCALTIME_R)
2137     TARGET_MD_ARCH=win32
2138     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2139     BIN_SUFFIX='.exe'
2140     MOZ_ENABLE_POSTSCRIPT=
2141     MOZ_USER_DIR="Mozilla"
2143     MOZ_GFX_OPTIMIZE_MOBILE=1
2145     # Sanity check for WINCE_WINDOWS_MOBILE
2146     # XXX disabled until we can fix the mobile tinderbox
2147     ##if test "$WINCE_WINDOWS_MOBILE"; then
2148     ##   AC_CHECK_HEADER(tpcshell.h, [],
2149     ##        AC_MSG_ERROR([Can't find tpcshell.h in your SDK; are you sure you don't need --disable-windows-mobile-components?]))
2150     ##fi
2154 *-mingw*|*-cygwin*|*-msvc*|*-mks*)
2155     DSO_CFLAGS=
2156     DSO_PIC_CFLAGS=
2157     DLL_SUFFIX=.dll
2158     RC=rc.exe
2159     # certain versions of cygwin's makedepend barf on the 
2160     # #include <string> vs -I./dist/include/string issue so don't use it
2161     SYSTEM_MAKEDEPEND=
2162     if test -n "$GNU_CC"; then
2163         CC="$CC -mno-cygwin"
2164         CXX="$CXX -mno-cygwin"
2165         CPP="$CPP -mno-cygwin"
2166         CFLAGS="$CFLAGS -mms-bitfields"
2167         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2168         DSO_LDOPTS='-shared'
2169         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2170         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2171         RC='$(WINDRES)'
2172         # Use temp file for windres (bug 213281)
2173         RCFLAGS='-O coff --use-temp-file'
2174         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2175         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32"
2176         MOZ_JS_LIBS='-L$(LIBXUL_DIST)/lib -lmozjs'
2177         MOZ_FIX_LINK_PATHS=
2178         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2179         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2180         DLL_PREFIX=
2181         IMPORT_LIB_SUFFIX=dll.a
2182     else
2183         TARGET_COMPILER_ABI=msvc
2184         HOST_CC='$(CC)'
2185         HOST_CXX='$(CXX)'
2186         HOST_LD='$(LD)'
2187         if test "$AS_BIN"; then
2188             AS="$(basename "$AS_BIN")"
2189         fi
2190         AR='lib -NOLOGO -OUT:"$@"'
2191         AR_FLAGS=
2192         RANLIB='echo not_ranlib'
2193         STRIP='echo not_strip'
2194         XARGS=xargs
2195         ZIP=zip
2196         UNZIP=unzip
2197         DOXYGEN=:
2198         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
2199         ASM_SUFFIX=asm
2200         OBJ_SUFFIX=obj
2201         LIB_SUFFIX=lib
2202         DLL_PREFIX=
2203         LIB_PREFIX=
2204         IMPORT_LIB_SUFFIX=lib
2205         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2206         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2207         MKSHLIB_FORCE_ALL=
2208         MKSHLIB_UNFORCE_ALL=
2209         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2210         _USE_CPP_INCLUDE_FLAG=1
2211         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2212         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2213         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2214         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2215         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
2216         MOZ_DEBUG_FLAGS='-Zi'
2217         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2218         WARNINGS_AS_ERRORS='-WX'
2219         MOZ_OPTIMIZE_FLAGS='-O1'
2220         MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
2221         MOZ_FIX_LINK_PATHS=
2222         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2223         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2224         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2225         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2226         if test $_MSC_VER -ge 1400; then
2227             LDFLAGS="$LDFLAGS -NXCOMPAT"
2228             dnl For profile-guided optimization
2229             PROFILE_GEN_CFLAGS="-GL"
2230             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2231             dnl XXX: PGO builds can fail with warnings treated as errors,
2232             dnl specifically "no profile data available" appears to be
2233             dnl treated as an error sometimes. This might be a consequence
2234             dnl of using WARNINGS_AS_ERRORS in some modules, combined
2235             dnl with the linker doing most of the work in the whole-program
2236             dnl optimization/PGO case. I think it's probably a compiler bug,
2237             dnl but we work around it here.
2238             PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2239             dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2240             dnl Probably also a compiler bug, but what can you do?
2241             PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2242             if test -n "$_USE_DYNAMICBASE"; then
2243                LDFLAGS="$LDFLAGS -DYNAMICBASE"
2244             fi
2245         fi
2246     fi
2247     MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg32$(VERSION_NUMBER),$(DEPTH)/jpeg)'
2248     MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,png,$(DEPTH)/modules/libimg/png)'
2249     AC_DEFINE(HAVE_SNPRINTF)
2250     AC_DEFINE(_WINDOWS)
2251     AC_DEFINE(WIN32)
2252     AC_DEFINE(XP_WIN)
2253     AC_DEFINE(XP_WIN32)
2254     AC_DEFINE(HW_THREADS)
2255     AC_DEFINE(STDC_HEADERS)
2256     AC_DEFINE(NEW_H, <new>)
2257     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2258     TARGET_MD_ARCH=win32
2259     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2260     BIN_SUFFIX='.exe'
2261     MOZ_ENABLE_POSTSCRIPT=
2262     MOZ_USER_DIR="Mozilla"
2264     dnl Hardcode to win95 for now - cls
2265     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2267     dnl set NO_X11 defines here as the general check is skipped on win32
2268     no_x=yes
2269     AC_DEFINE(NO_X11)
2271     dnl MinGW/MSYS doesn't provide or need cygpath
2272     case "$host" in
2273     *-mingw*)
2274         CYGPATH_W=echo
2275         CYGPATH_S=cat
2276         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2277         ;;
2278     *-cygwin*|*-msvc*|*-mks*)
2279         CYGPATH_W="cygpath -a -w"
2280         CYGPATH_S="sed -e s|\\\\|/|g"
2281         MOZ_BUILD_ROOT=`$CYGPATH_W $MOZ_BUILD_ROOT | $CYGPATH_S`
2282         ;;
2283     esac
2284     case "$host" in
2285     *-mingw*|*-cygwin*|*-msvc*|*-mks*)
2287     if test -z "$MOZ_TOOLS"; then
2288         AC_MSG_ERROR([MOZ_TOOLS is not set])
2289     fi
2291     MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2292     if test "$?" != "0" || test -z "$MOZ_TOOLS_DIR"; then
2293         AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2294     fi
2295     MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2296     if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2297         AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2298     fi
2299     MOZ_TOOLS_DIR=`$CYGPATH_W $MOZ_TOOLS_DIR | $CYGPATH_S`
2301     if test -n "$GLIB_PREFIX"; then
2302         _GLIB_PREFIX_DIR=`cd $GLIB_PREFIX && pwd -W`
2303         if test "$?" = "0"; then
2304             if test `echo ${PATH}: | grep -ic "$_GLIB_PREFIX_DIR/bin:"` = 0; then
2305                 AC_MSG_ERROR([GLIB_PREFIX must be in your \$PATH.])
2306             fi
2307             _GLIB_PREFIX_DIR=`$CYGPATH_W $_GLIB_PREFIX_DIR | $CYGPATH_S`
2308         else
2309             AC_MSG_ERROR([GLIB_PREFIX is set but "${GLIB_PREFIX}" is not a directory.])
2310         fi
2311     else
2312         _GLIB_PREFIX_DIR=$MOZ_TOOLS_DIR
2313     fi
2314     if test ! -f "${_GLIB_PREFIX_DIR}/include/glib.h"; then
2315         AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/include/glib.h .])
2316     fi
2317     GLIB_CFLAGS="-I${_GLIB_PREFIX_DIR}/include"
2318     if test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"; then
2319         GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"
2320     elif test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"; then
2321         GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"
2322     else
2323         AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/lib/glib-1.2.lib or $_GLIB_PREFIX_DIR/lib/glib-1.2_s.lib])
2324     fi
2326     if test -n "$LIBIDL_PREFIX"; then
2327         _LIBIDL_PREFIX_DIR=`cd $LIBIDL_PREFIX && pwd -W`
2328         if test "$?" = "0"; then
2329             if test `echo ${PATH}: | grep -ic "$_LIBIDL_PREFIX_DIR/bin:"` = 0; then
2330                 AC_MSG_ERROR([LIBIDL_PREFIX must be in your \$PATH.])
2331             fi
2332             _LIBIDL_PREFIX_DIR=`$CYGPATH_W $_LIBIDL_PREFIX_DIR | $CYGPATH_S`
2333         else
2334             AC_MSG_ERROR([LIBIDL_PREFIX is set but "${LIBIDL_PREFIX}" is not a directory.])
2335         fi
2336     else
2337         _LIBIDL_PREFIX_DIR=$MOZ_TOOLS_DIR
2338     fi        
2339     if test ! -f "${_LIBIDL_PREFIX_DIR}/include/libIDL/IDL.h"; then
2340         AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/include/libIDL/IDL.h .])
2341     fi
2342     LIBIDL_CFLAGS="-I${_LIBIDL_PREFIX_DIR}/include ${GLIB_CFLAGS}"
2343     if test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"; then
2344         LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"
2345         STATIC_LIBIDL=1
2346     elif test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"; then
2347         LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"
2348     else
2349         AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/lib/libidl-0.6.lib or $_LIBIDL_PREFIX_DIR/lib/libidl-0.6_s.lib])
2350     fi
2351     LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
2352     ;;
2354     *) # else cross-compiling
2355         if test -n "$GLIB_PREFIX"; then
2356             GLIB_CFLAGS="-I${GLIB_PREFIX}/include"
2357             if test -f "${GLIB_PREFIX}/lib/glib-1.2_s.lib"; then
2358                 GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2_s.lib"
2359             elif test -f "${GLIB_PREFIX}/lib/glib-1.2.lib"; then
2360                 GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2.lib"
2361             else
2362                 AC_MSG_ERROR([Cannot find $GLIB_PREFIX/lib/glib-1.2.lib or $GLIB_PREFIX/lib/glib-1.2_s.lib])
2363             fi
2364         fi
2365         if test -n "$LIBIDL_PREFIX"; then
2366             LIBIDL_CFLAGS="-I${LIBIDL_PREFIX}/include ${GLIB_CFLAGS}"
2367             if test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"; then
2368                 LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"
2369                 STATIC_LIBIDL=1
2370             elif test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"; then
2371                 LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"
2372             else
2373                 AC_MSG_ERROR([Cannot find $LIBIDL_PREFIX/lib/libIDL-0.6.lib or $LIBIDL_PREFIX/lib/libIDL-0.6_s.lib])
2374             fi
2375         fi
2376         LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
2377         ;;
2378     esac 
2381     case "$host_os" in
2382     cygwin*|msvc*|mks*)
2383         AC_MSG_WARN([Using a cygwin build environment is unsupported. Configure cannot check for the presence of necessary headers. Please upgrade to MozillaBuild; see http://developer.mozilla.org/en/docs/Windows_Build_Prerequisites])
2384         ;;
2386     *)
2387         AC_CHECK_HEADERS(oleacc.idl)
2389         AC_LANG_SAVE
2390         AC_LANG_CPLUSPLUS
2391         AC_CHECK_HEADERS(atlbase.h)
2392         AC_LANG_RESTORE
2393         ;;
2394     esac
2396     case "$target" in
2397     i*86-*)
2398         if test "$HAVE_64BIT_OS"; then
2399             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2400         fi
2402         if test $_MSC_VER -ge 1400; then
2403             LDFLAGS="$LDFLAGS -SAFESEH"
2404         fi
2405         AC_CHECK_HEADERS(mmintrin.h)
2406         AC_DEFINE(_X86_)
2407         ;;
2408     alpha-*)
2409         AC_DEFINE(_ALPHA_)
2410         ;;
2411     mips-*)
2412         AC_DEFINE(_MIPS_)
2413         ;;
2414     x86_64-*)
2415         AC_DEFINE(_AMD64_)
2416         ;;
2417     *)
2418         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2419         ;;
2420     esac
2422     if test "$HAVE_64BIT_OS"; then
2423         AC_DEFINE(_WIN64)
2424     fi
2425     ;;
2427 *-netbsd*)
2428     DSO_CFLAGS=''
2429     CFLAGS="$CFLAGS -Dunix"
2430     CXXFLAGS="$CXXFLAGS -Dunix"
2431     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2432         DLL_SUFFIX=".so"
2433         DSO_PIC_CFLAGS='-fPIC -DPIC'
2434         DSO_LDOPTS='-shared'
2435         BIN_FLAGS='-Wl,--export-dynamic'
2436     else
2437         DSO_PIC_CFLAGS='-fPIC -DPIC'
2438         DLL_SUFFIX=".so.1.0"
2439         DSO_LDOPTS='-shared'
2440     fi
2441     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2442     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2443     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2444     if test "$LIBRUNPATH"; then
2445         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2446     fi
2447     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2448     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2449     ;;
2451 *-nto*) 
2452         AC_DEFINE(NTO)  
2453         AC_DEFINE(_QNX_SOURCE)
2454         AC_DEFINE(_i386)
2455         OS_TARGET=NTO
2456         WARNINGS_AS_ERRORS=''
2457         MOZ_OPTIMIZE_FLAGS="-O"
2458         MOZ_DEBUG_FLAGS="-gstabs"
2459         USE_PTHREADS=1
2460         _PEDANTIC=
2461         LIBS="$LIBS -lsocket -lstdc++"
2462         _DEFINES_CFLAGS='-Wp,-include -Wp,$(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT -D_POSIX_C_SOURCE=199506'
2463         _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -Wp,-include -Wp,$(DEPTH)/mozilla-config.h -D_POSIX_C_SOURCE=199506'
2464         if test "$with_x" != "yes"
2465         then
2466                 _PLATFORM_DEFAULT_TOOLKIT="photon"
2467             TK_CFLAGS='-I/usr/include/photon'
2468                 TK_LIBS='-lph'
2469         fi
2470         case "${target_cpu}" in
2471         ppc*)
2472         AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)        
2473         ;;
2474         esac
2475         case "${host_cpu}" in
2476         i*86)
2477         USE_ELF_DYNSTR_GC=1
2478         ;;
2479         esac
2480         ;;
2482 *-openbsd*)
2483     DLL_SUFFIX=".so.1.0"
2484     DSO_CFLAGS=''
2485     DSO_PIC_CFLAGS='-fPIC'
2486     DSO_LDOPTS='-shared -fPIC'
2487     if test "$LIBRUNPATH"; then
2488         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2489     fi
2490     ;;
2492 *-openvms*) 
2493     AC_DEFINE(NO_PW_GECOS)
2494     AC_DEFINE(NO_UDSOCK)
2495     AC_DEFINE(POLL_WITH_XCONNECTIONNUMBER)
2496     USE_PTHREADS=1
2497     MKSHLIB_FORCE_ALL='-all'
2498     MKSHLIB_UNFORCE_ALL='-none'
2499     AS='as'
2500     AS_DASH_C_FLAG='-Wc/names=as_is'
2501     AR_FLAGS='c $@'
2502     DSO_LDOPTS='-shared -auto_symvec'
2503     DSO_PIC_CFLAGS=
2504     MOZ_DEBUG_LDFLAGS='-g'
2505     COMPAQ_CXX=1
2506     CC_VERSION=`$CC -V 2>&1 | awk '/ C / { print $3 }'`
2507     CXX_VERSION=`$CXX -V 2>&1 | awk '/ C\+\+ / { print $3 }'`
2508     ;;
2511 *-os2*)
2512     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2513     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2514     AC_DEFINE(OS2)
2515     AC_DEFINE(XP_OS2)
2516     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2517     AC_DEFINE(TCPV40HDRS)
2518     DLL_PREFIX=
2519     LIB_PREFIX=
2520     LIB_SUFFIX=lib
2521     BIN_SUFFIX=".exe"
2522     DLL_SUFFIX=".dll"
2523     IMPORT_LIB_SUFFIX=lib
2524     DSO_PIC_CFLAGS=
2525     AR=emxomfar
2526     AR_FLAGS='r $@'
2527     CFLAGS="$CFLAGS -Zomf"
2528     CXXFLAGS="$CXXFLAGS -Zomf"
2529     DSO_LDOPTS='-Zdll'
2530     BIN_FLAGS='-Zlinker /ST:0x100000'
2531     IMPLIB='emximp -o'
2532     FILTER='emxexp -o'
2533     LDFLAGS='-Zmap'
2534     WARNINGS_AS_ERRORS='-Werror'
2535     MOZ_DEBUG_FLAGS="-g -fno-inline"
2536     MOZ_OPTIMIZE_FLAGS="-O2"
2537     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2538     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2539     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2540     TARGET_MD_ARCH=os2
2541     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2542     MOZ_ENABLE_POSTSCRIPT=
2543     RC=rc.exe
2544     RCFLAGS='-n'
2545     MOZ_USER_DIR="Mozilla"
2547     if test "$MOZTOOLS"; then
2548         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2549     else
2550         AC_MSG_ERROR([MOZTOOLS is not set])
2551     fi
2552     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2553         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2554         LDFLAGS="$LDFLAGS -Zhigh-mem"
2555         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2556         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2557     fi
2559     # GCC for OS/2 currently predefines these, but we don't want them
2560     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2561     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2563     AC_CACHE_CHECK(for __declspec(dllexport),
2564         ac_os2_declspec,
2565         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2566                         [return 0;],
2567                         ac_os2_declspec="yes",
2568                         ac_os2_declspec="no")])
2569     if test "$ac_os2_declspec" = "yes"; then
2570         FILTER='true'
2571         MOZ_OS2_USE_DECLSPEC='1'
2572     fi
2573     ;;
2575 alpha*-*-osf*)
2576     if test "$GNU_CC"; then
2577       MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
2578       MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$@ -o $@'
2580     else
2581         MOZ_DEBUG_FLAGS='-g'
2582         ASFLAGS='-I$(topsrcdir)/xpcom/reflect/xptcall/public -g'
2583         CFLAGS="$CFLAGS -ieee"
2584         CXXFLAGS="$CXXFLAGS "'-noexceptions -ieee  -ptr $(DIST)/cxx_repository'
2585         DSO_LDOPTS='-shared -msym -expect_unresolved \* -update_registry $(DIST)/so_locations'
2586         DSO_CFLAGS=
2587         DSO_PIC_CFLAGS=
2588         MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
2589         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -soname $@ -o $@'
2590         MKSHLIB_FORCE_ALL='-all'
2591         MKSHLIB_UNFORCE_ALL='-none'
2592         dnl Might fix the libxpcom.so breakage on this platform as well....
2593         AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2594         AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2595     fi
2596     if test -z "$GNU_CXX"; then
2597       COMPAQ_CXX=1
2598     fi
2599     AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2600     ;;
2602 *-qnx*) 
2603     DIRENT_INO=d_stat.st_ino
2604     dnl Solves the problems the QNX compiler has with nsCOMPtr.h.
2605     AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2606     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2607     dnl Explicit set STDC_HEADERS to workaround QNX 6.0's failing of std test
2608     AC_DEFINE(STDC_HEADERS)
2609     if test "$no_x" = "yes"; then
2610             _PLATFORM_DEFAULT_TOOLKIT='photon'
2611             TK_CFLAGS='-I/usr/nto/include/photon'
2612             TK_LIBS='-lphoton -lphrender'
2613     fi
2614     ;;
2616 *-sco*) 
2617     AC_DEFINE(NSCAP_DISABLE_TEST_DONTQUERY_CASES)
2618     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2619     CXXFLAGS="$CXXFLAGS -I/usr/include/CC"
2620     if test ! "$GNU_CC"; then
2621        DSO_LDOPTS='-G'
2622     fi
2623     ;;
2625 *-solaris*) 
2626     AC_DEFINE(SOLARIS)
2627     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2628     SYSTEM_MAKEDEPEND=
2629     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2630     # libraries one level up (e.g. libnspr4.so)
2631     LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..'"
2632     MOZ_MEMORY=1
2633     if test "$SOLARIS_SUNPRO_CC"; then
2634        LIBS="-lCrun -lCstd $LIBS"
2635        NS_USE_NATIVE=1
2636        MOZ_FIX_LINK_PATHS=
2637        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2638        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all"
2639        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic -norunpath"
2640        LDFLAGS="-xildoff -z lazyload -z combreloc $LDFLAGS"
2641        if test -z "$CROSS_COMPILE" && test -f /usr/lib/ld/map.noexstk; then
2642            _SAVE_LDFLAGS=$LDFLAGS
2643            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS" 
2644            AC_TRY_LINK([#include <stdio.h>],
2645                        [printf("Hello World\n");],
2646                        ,
2647                        [LDFLAGS=$_SAVE_LDFLAGS])
2648        fi
2649        WARNINGS_AS_ERRORS='-Werror'
2650        MOZ_OPTIMIZE_FLAGS="-xO4"
2651        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2652        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) -G -z muldefs -h $@ -o $@'
2653        MKSHLIB_FORCE_ALL='-z allextract'
2654        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2655        DSO_LDOPTS='-G -z muldefs'
2656        AR_LIST="$AR t"
2657        AR_EXTRACT="$AR x"
2658        AR_DELETE="$AR d"
2659        AR='$(CXX) -xar'
2660        AR_FLAGS='-o $@'
2661        AS='/usr/ccs/bin/as'
2662        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2663        AS_DASH_C_FLAG=''
2664        TARGET_COMPILER_ABI="sunc"
2665        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2666        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2667        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2668        AC_LANG_SAVE
2669        AC_LANG_CPLUSPLUS
2670        AC_TRY_COMPILE([],
2671            [#if (__SUNPRO_CC < 0x590)
2672            #error "Denied"
2673            #endif],
2674            _BAD_COMPILER=,_BAD_COMPILER=1)
2675         if test -n "$_BAD_COMPILER"; then
2676             _res="no"
2677             AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2678         else
2679             _res="yes"
2680         fi
2681         AC_MSG_RESULT([$_res])
2682         AC_LANG_RESTORE
2683     else
2684        ASFLAGS="$ASFLAGS -fPIC"
2685        DSO_LDOPTS='-G'
2686        _WARNINGS_CFLAGS=''
2687        _WARNINGS_CXXFLAGS=''
2688        if test "$OS_RELEASE" = "5.3"; then
2689           AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2690        fi
2691     fi
2692     if test "$OS_RELEASE" = "5.5.1"; then
2693        AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2694     fi
2695     ;;
2697 *-sunos*) 
2698     DSO_LDOPTS='-Bdynamic'
2699     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2700     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2701     AC_DEFINE(SUNOS4)
2702     AC_DEFINE(SPRINTF_RETURNS_STRING)
2703     case "$(target_os)" in
2704     sunos4.1*)
2705         DLL_SUFFIX='.so.1.0'
2706         ;;
2707     esac
2708     ;;
2710 *-sysv4.2uw7*) 
2711         NSPR_LIBS="-lnspr$NSPR_VERSION -lplc$NSPR_VERSION -lplds$NSPR_VERSION -L/usr/ccs/lib -lcrt"
2712     ;;
2714 *-os2*)
2715     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2716     ;;
2718 esac
2720 dnl Only one oddball right now (QNX), but this gives us flexibility
2721 dnl if any other platforms need to override this in the future.
2722 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2724 dnl ========================================================
2725 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2726 dnl by now will not have any way to link most binaries (tests
2727 dnl as well as viewer, apprunner, etc.), because some symbols
2728 dnl will be left out of the "composite" .so's by ld as unneeded.
2729 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2730 dnl they can link in the static libs that provide the missing
2731 dnl symbols.
2732 dnl ========================================================
2733 NO_LD_ARCHIVE_FLAGS=
2734 if test -z "$MKSHLIB_FORCE_ALL" || test -z "$MKSHLIB_UNFORCE_ALL"; then
2735     NO_LD_ARCHIVE_FLAGS=1
2737 case "$target" in
2738 *-os2*)
2739     NO_LD_ARCHIVE_FLAGS=
2740     ;;
2741 *-aix4.3*|*-aix5*)
2742     NO_LD_ARCHIVE_FLAGS=
2743     ;;
2744 *-openvms*)
2745     NO_LD_ARCHIVE_FLAGS=
2746     ;;
2747 *-msvc*|*-mks*|*-mingw*|*-cygwin*|*-wince|*-winmo)
2748     if test -z "$GNU_CC"; then
2749         NO_LD_ARCHIVE_FLAGS=
2750     fi
2751     ;;
2752 esac
2753 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2755 dnl ========================================================
2756 dnl = Flags to strip unused symbols from .so components
2757 dnl ========================================================
2758 case "$target" in
2759     *-linux*|*-kfreebsd*-gnu)
2760         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2761         ;;
2762     *-solaris*)
2763         if test -z "$GNU_CC"; then
2764          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2765         else
2766          if test -z "$GCC_USE_GNU_LD"; then
2767           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2768          else
2769           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2770          fi
2771         fi
2772         ;;
2773     *-nto*) 
2774         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2775         ;;
2776     *-darwin*)
2777         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2778         ;;
2779     *-cygwin*|*-mingw*|*-mks*|*-msvc|*-wince|*-winmo)
2780         if test -n "$GNU_CC"; then
2781            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2782         fi
2783         ;;
2784 esac
2786 if test -z "$COMPILE_ENVIRONMENT"; then
2787     SKIP_COMPILER_CHECKS=1
2788     SKIP_LIBRARY_CHECKS=1
2791 if test -z "$SKIP_COMPILER_CHECKS"; then
2792 dnl Checks for typedefs, structures, and compiler characteristics.
2793 dnl ========================================================
2794 AC_LANG_C
2795 AC_HEADER_STDC
2796 AC_C_CONST
2797 AC_TYPE_MODE_T
2798 AC_TYPE_OFF_T
2799 AC_TYPE_PID_T
2800 AC_TYPE_SIZE_T
2801 AC_MSG_CHECKING(for ssize_t)
2802 AC_CACHE_VAL(ac_cv_type_ssize_t,
2803  [AC_TRY_COMPILE([#include <stdio.h>
2804                   #include <sys/types.h>],
2805                  [ssize_t foo = 0;],
2806                  [ac_cv_type_ssize_t=true],
2807                  [ac_cv_type_ssize_t=false])])
2808 if test "$ac_cv_type_ssize_t" = true ; then
2809   AC_DEFINE(HAVE_SSIZE_T)
2810   AC_MSG_RESULT(yes)
2811 else
2812   AC_MSG_RESULT(no)
2814 AC_STRUCT_ST_BLKSIZE
2815 AC_MSG_CHECKING(for siginfo_t)
2816 AC_CACHE_VAL(ac_cv_siginfo_t,
2817  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2818                   #include <signal.h>],
2819                  [siginfo_t* info;],
2820                  [ac_cv_siginfo_t=true],
2821                  [ac_cv_siginfo_t=false])])
2822 if test "$ac_cv_siginfo_t" = true ; then
2823   AC_DEFINE(HAVE_SIGINFO_T)
2824   AC_MSG_RESULT(yes)
2825 else
2826   AC_MSG_RESULT(no)
2829 dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
2830 dnl ========================================================
2831 AC_MSG_CHECKING(for int16_t)
2832 AC_CACHE_VAL(ac_cv_int16_t,
2833  [AC_TRY_COMPILE([#include <stdio.h>
2834                   #include <sys/types.h>],
2835                  [int16_t foo = 0;],
2836                  [ac_cv_int16_t=true],
2837                  [ac_cv_int16_t=false])])
2838 if test "$ac_cv_int16_t" = true ; then
2839   AC_DEFINE(HAVE_INT16_T)
2840   AC_MSG_RESULT(yes)
2841 else
2842   AC_MSG_RESULT(no)
2844 AC_MSG_CHECKING(for int32_t)
2845 AC_CACHE_VAL(ac_cv_int32_t,
2846  [AC_TRY_COMPILE([#include <stdio.h>
2847                   #include <sys/types.h>],
2848                  [int32_t foo = 0;],
2849                  [ac_cv_int32_t=true],
2850                  [ac_cv_int32_t=false])])
2851 if test "$ac_cv_int32_t" = true ; then
2852   AC_DEFINE(HAVE_INT32_T)
2853   AC_MSG_RESULT(yes)
2854 else
2855   AC_MSG_RESULT(no)
2857 AC_MSG_CHECKING(for int64_t)
2858 AC_CACHE_VAL(ac_cv_int64_t,
2859  [AC_TRY_COMPILE([#include <stdio.h>
2860                   #include <sys/types.h>],
2861                  [int64_t foo = 0;],
2862                  [ac_cv_int64_t=true],
2863                  [ac_cv_int64_t=false])])
2864 if test "$ac_cv_int64_t" = true ; then
2865   AC_DEFINE(HAVE_INT64_T)
2866   AC_MSG_RESULT(yes)
2867 else
2868   AC_MSG_RESULT(no)
2870 AC_MSG_CHECKING(for int64)
2871 AC_CACHE_VAL(ac_cv_int64,
2872  [AC_TRY_COMPILE([#include <stdio.h>
2873                   #include <sys/types.h>],
2874                  [int64 foo = 0;],
2875                  [ac_cv_int64=true],
2876                  [ac_cv_int64=false])])
2877 if test "$ac_cv_int64" = true ; then
2878   AC_DEFINE(HAVE_INT64)
2879   AC_MSG_RESULT(yes)
2880 else
2881   AC_MSG_RESULT(no)
2883 AC_MSG_CHECKING(for uint)
2884 AC_CACHE_VAL(ac_cv_uint,
2885  [AC_TRY_COMPILE([#include <stdio.h>
2886                   #include <sys/types.h>],
2887                  [uint foo = 0;],
2888                  [ac_cv_uint=true],
2889                  [ac_cv_uint=false])])
2890 if test "$ac_cv_uint" = true ; then
2891   AC_DEFINE(HAVE_UINT)
2892   AC_MSG_RESULT(yes)
2893 else
2894   AC_MSG_RESULT(no)
2896 AC_MSG_CHECKING(for uint_t)
2897 AC_CACHE_VAL(ac_cv_uint_t,
2898  [AC_TRY_COMPILE([#include <stdio.h>
2899                   #include <sys/types.h>],
2900                  [uint_t foo = 0;],
2901                  [ac_cv_uint_t=true],
2902                  [ac_cv_uint_t=false])])
2903 if test "$ac_cv_uint_t" = true ; then
2904   AC_DEFINE(HAVE_UINT_T)
2905   AC_MSG_RESULT(yes)
2906 else
2907   AC_MSG_RESULT(no)
2909 AC_MSG_CHECKING(for uint16_t)
2910 AC_CACHE_VAL(ac_cv_uint16_t,
2911  [AC_TRY_COMPILE([#include <stdio.h>
2912                   #include <sys/types.h>],
2913                  [uint16_t foo = 0;],
2914                  [ac_cv_uint16_t=true],
2915                  [ac_cv_uint16_t=false])])
2916 if test "$ac_cv_uint16_t" = true ; then
2917   AC_DEFINE(HAVE_UINT16_T)
2918   AC_MSG_RESULT(yes)
2919 else
2920   AC_MSG_RESULT(no)
2923 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
2924 dnl are defined when compiling C++ but not C.  Since the result of this
2925 dnl test is used only in C++, do it in C++.
2926 AC_LANG_CPLUSPLUS
2928 AC_MSG_CHECKING(for uname.domainname)
2929 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
2930     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2931         [ struct utsname *res; char *domain; 
2932             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
2933         [ac_cv_have_uname_domainname_field=true],
2934         [ac_cv_have_uname_domainname_field=false])])
2936 if test "$ac_cv_have_uname_domainname_field" = "true"; then
2937     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
2938     AC_MSG_RESULT(yes)
2939 else
2940     AC_MSG_RESULT(no)
2943 AC_MSG_CHECKING(for uname.__domainname)
2944 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
2945     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2946         [ struct utsname *res; char *domain; 
2947             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
2948         [ac_cv_have_uname_us_domainname_field=true],
2949         [ac_cv_have_uname_us_domainname_field=false])])
2951 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
2952     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
2953     AC_MSG_RESULT(yes)
2954 else
2955     AC_MSG_RESULT(no)
2958 AC_LANG_CPLUSPLUS
2960 dnl Check for usable char16_t (2 bytes, unsigned)
2961 dnl (we might not need the unsignedness check anymore)
2962 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
2963     ac_cv_have_usable_char16_t,
2964     [AC_TRY_COMPILE([$configure_static_assert_macros],
2965                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
2966                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
2967                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
2968                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
2969                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
2970                     ac_cv_have_usable_char16_t="yes",
2971                     ac_cv_have_usable_char16_t="no")])
2972 if test "$ac_cv_have_usable_char16_t" = "yes"; then
2973     AC_DEFINE(HAVE_CPP_CHAR16_T)
2974     HAVE_CPP_CHAR16_T=1
2977 dnl Check for usable wchar_t (2 bytes, unsigned)
2978 dnl (we really don't need the unsignedness check anymore)
2979 dnl ========================================================
2981 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
2982     ac_cv_have_usable_wchar_v2,
2983     [AC_TRY_COMPILE([#include <stddef.h>
2984                      $configure_static_assert_macros],
2985                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2986                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2987                     ac_cv_have_usable_wchar_v2="yes",
2988                     ac_cv_have_usable_wchar_v2="no")])
2989 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
2990     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2991     HAVE_CPP_2BYTE_WCHAR_T=1
2992 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
2993 dnl This is really gcc-only
2994 dnl Do this test using CXX only since some versions of gcc
2995 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
2996 dnl only have short-wchar support for c++.
2997 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
2999     _SAVE_CXXFLAGS=$CXXFLAGS
3000     CXXFLAGS="$CXXFLAGS -fshort-wchar"
3002     AC_CACHE_CHECK(for compiler -fshort-wchar option, 
3003         ac_cv_have_usable_wchar_option_v2,
3004         [AC_TRY_LINK([#include <stddef.h>
3005                       $configure_static_assert_macros],
3006                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
3007                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
3008                      ac_cv_have_usable_wchar_option_v2="yes",
3009                      ac_cv_have_usable_wchar_option_v2="no")])
3011     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
3012         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
3013         HAVE_CPP_2BYTE_WCHAR_T=1
3014         WCHAR_CFLAGS="-fshort-wchar"
3015     else    
3016         CXXFLAGS=$_SAVE_CXXFLAGS
3017     fi
3020 AC_LANG_C
3022 dnl Check for .hidden assembler directive and visibility attribute.
3023 dnl Borrowed from glibc configure.in
3024 dnl ===============================================================
3025 if test "$GNU_CC"; then
3026   AC_CACHE_CHECK(for visibility(hidden) attribute,
3027                  ac_cv_visibility_hidden,
3028                  [cat > conftest.c <<EOF
3029                   int foo __attribute__ ((visibility ("hidden"))) = 1;
3031                   ac_cv_visibility_hidden=no
3032                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3033                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3034                       ac_cv_visibility_hidden=yes
3035                     fi
3036                   fi
3037                   rm -f conftest.[cs]
3038                  ])
3039   if test "$ac_cv_visibility_hidden" = "yes"; then
3040     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
3042     AC_CACHE_CHECK(for visibility(default) attribute,
3043                    ac_cv_visibility_default,
3044                    [cat > conftest.c <<EOF
3045                     int foo __attribute__ ((visibility ("default"))) = 1;
3047                     ac_cv_visibility_default=no
3048                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3049                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
3050                         ac_cv_visibility_default=yes
3051                       fi
3052                     fi
3053                     rm -f conftest.[cs]
3054                    ])
3055     if test "$ac_cv_visibility_default" = "yes"; then
3056       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
3058       AC_CACHE_CHECK(for visibility pragma support,
3059                      ac_cv_visibility_pragma,
3060                      [cat > conftest.c <<EOF
3061 #pragma GCC visibility push(hidden)
3062                       int foo_hidden = 1;
3063 #pragma GCC visibility push(default)
3064                       int foo_default = 1;
3066                       ac_cv_visibility_pragma=no
3067                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
3068                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
3069                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
3070                             ac_cv_visibility_pragma=yes
3071                           fi
3072                         fi
3073                       fi
3074                       rm -f conftest.[cs]
3075                     ])
3076       if test "$ac_cv_visibility_pragma" = "yes"; then
3077         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
3078                        ac_cv_have_visibility_class_bug,
3079                        [cat > conftest.c <<EOF
3080 #pragma GCC visibility push(hidden)
3081 struct __attribute__ ((visibility ("default"))) TestStruct {
3082   static void Init();
3084 __attribute__ ((visibility ("default"))) void TestFunc() {
3085   TestStruct::Init();
3088                        ac_cv_have_visibility_class_bug=no
3089                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3090                          ac_cv_have_visibility_class_bug=yes
3091                        else
3092                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
3093                            ac_cv_have_visibility_class_bug=yes
3094                          fi
3095                        fi
3096                        rm -rf conftest.{c,S}
3097                        ])
3099         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
3100                        ac_cv_have_visibility_builtin_bug,
3101                        [cat > conftest.c <<EOF
3102 #pragma GCC visibility push(hidden)
3103 #pragma GCC visibility push(default)
3104 #include <string.h>
3105 #pragma GCC visibility pop
3107 __attribute__ ((visibility ("default"))) void Func() {
3108   char c[[100]];
3109   memset(c, 0, sizeof(c));
3112                        ac_cv_have_visibility_builtin_bug=no
3113                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
3114                          ac_cv_have_visibility_builtin_bug=yes
3115                        else
3116                          if test `grep -c "@PLT" conftest.S` = 0; then
3117                            ac_cv_visibility_builtin_bug=yes
3118                          fi
3119                        fi
3120                        rm -f conftest.{c,S}
3121                        ])
3122         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
3123                 "$ac_cv_have_visibility_class_bug" = "no"; then
3124           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
3125           WRAP_SYSTEM_INCLUDES=1
3126         else
3127           VISIBILITY_FLAGS='-fvisibility=hidden'
3128         fi # have visibility pragma bug
3129       fi   # have visibility pragma
3130     fi     # have visibility(default) attribute
3131   fi       # have visibility(hidden) attribute
3132 fi         # GNU_CC
3134 # visibility hidden flag for Sun Studio on Solaris
3135 if test "$SOLARIS_SUNPRO_CC"; then
3136 VISIBILITY_FLAGS='-xldscope=hidden'
3137 fi         # Sun Studio on Solaris
3139 AC_SUBST(WRAP_SYSTEM_INCLUDES)
3140 AC_SUBST(VISIBILITY_FLAGS)
3142 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
3143 dnl ========================================================
3144 if test "$GNU_CC"; then
3145   CFLAGS_save="${CFLAGS}"
3146   CFLAGS="${CFLAGS} -Werror"
3147   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
3148                  ac_cv_force_align_arg_pointer,
3149                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
3150                                  [],
3151                                  ac_cv_force_align_arg_pointer="yes",
3152                                  ac_cv_force_align_arg_pointer="no")])
3153   CFLAGS="${CFLAGS_save}"
3154   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
3155     HAVE_GCC_ALIGN_ARG_POINTER=1
3156   else
3157     HAVE_GCC_ALIGN_ARG_POINTER=
3158   fi
3160 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
3162 dnl Checks for header files.
3163 dnl ========================================================
3164 AC_HEADER_DIRENT
3165 case "$target_os" in
3166 freebsd*)
3167 # for stuff like -lXshm
3168     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
3169     ;;
3170 esac
3171 AC_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h)
3172 AC_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h)
3173 AC_CHECK_HEADERS(gnu/libc-version.h nl_types.h)
3174 AC_CHECK_HEADERS(malloc.h)
3175 AC_CHECK_HEADERS(X11/XKBlib.h)
3176 AC_CHECK_HEADERS(io.h)
3178 dnl These are all the places some variant of statfs can be hiding.
3179 AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
3181 dnl Quota support
3182 AC_CHECK_HEADERS(sys/quota.h)
3184 dnl Try for MMX support
3185 dnl NB - later gcc versions require -mmmx for this header to be successfully
3186 dnl included (or another option which implies it, such as -march=pentium-mmx)
3187 AC_CHECK_HEADERS(mmintrin.h)
3189 dnl Check whether the compiler supports the new-style C++ standard
3190 dnl library headers (i.e. <new>) or needs the old "new.h"
3191 AC_LANG_CPLUSPLUS
3192 NEW_H=new.h
3193 AC_CHECK_HEADER(new, [NEW_H=new])
3194 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3195 AC_LANG_C
3197 AC_ARG_ENABLE(dtrace,
3198               [  --enable-dtrace         build with dtrace support if available (default=no)],
3199               [enable_dtrace="yes"],)
3200 if test "x$enable_dtrace" = "xyes"; then
3201   AC_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3202   if test -n "$HAVE_DTRACE"; then
3203       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3204   else
3205       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3206   fi
3208 AC_SUBST(HAVE_DTRACE)
3210 case $target in
3211 *-aix4.3*|*-aix5*)
3212         ;;
3214         AC_CHECK_HEADERS(sys/cdefs.h)
3215         ;;
3216 esac
3218 dnl Checks for libraries.
3219 dnl ========================================================
3220 case $target in
3221 *-hpux11.*)
3222         ;;
3224         AC_CHECK_LIB(c_r, gethostbyname_r)
3225         ;;
3226 esac
3228 dnl We don't want to link with libdl even if it's present on OS X, since
3229 dnl it's not used and not part of the default installation.
3230 dnl The same goes for BeOS. OS/2 has dlfcn in libc.
3231 dnl We don't want to link against libm or libpthread on Darwin since
3232 dnl they both are just symlinks to libSystem and explicitly linking
3233 dnl against libSystem causes issues when debugging (see bug 299601).
3234 case $target in
3235 *-darwin*)
3236     ;;
3237 *-beos*)
3238     ;;
3239 *-os2*)
3240     ;;
3242     AC_CHECK_LIB(m, atan)
3243     AC_CHECK_LIB(dl, dlopen,
3244     AC_CHECK_HEADER(dlfcn.h, 
3245         LIBS="-ldl $LIBS"
3246         AC_DEFINE(HAVE_LIBDL)))
3247     ;;
3248 esac
3250 _SAVE_CFLAGS="$CFLAGS"
3251 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3252 AC_CHECK_FUNCS(dladdr)
3253 CFLAGS="$_SAVE_CFLAGS"
3255 if test ! "$GNU_CXX"; then
3257     case $target in
3258     *-aix*)
3259         AC_CHECK_LIB(C_r, demangle)
3260         ;;
3261      *)
3262         AC_CHECK_LIB(C, demangle)
3263         ;;
3264      esac
3267 dnl OS/2 has socket in libc.
3268 case $target in
3269 *-os2*)
3270     ;;
3272     AC_CHECK_LIB(socket, socket)
3273 esac
3275 dnl ========================================================
3276 dnl Check whether we can compile code for Core Text
3277 dnl (available on Mac OS X 10.5 or later)
3278 dnl ========================================================
3279 case "$target" in
3280 *-darwin*)
3281   AC_MSG_CHECKING([for Core Text])
3282   AC_TRY_COMPILE([#include <ApplicationServices/ApplicationServices.h>],
3283                  [CTLineRef lineRef;],
3284                   ac_cv_have_core_text="yes",
3285                   ac_cv_have_core_text="no")
3286   AC_MSG_RESULT([$ac_cv_have_core_text])
3288   if test "$ac_cv_have_core_text" = "no"; then
3289     AC_MSG_ERROR([Core Text is required (available on Mac OS X 10.5 or later).])
3290   fi
3291   ;;
3292 esac
3294 XLDFLAGS="$X_LIBS"
3295 XLIBS="$X_EXTRA_LIBS"
3297 dnl ========================================================
3298 dnl Checks for X libraries.
3299 dnl Ordering is important.
3300 dnl Xt is dependent upon SM as of X11R6
3301 dnl ========================================================
3302 if test "$no_x" = "yes"; then
3303     AC_DEFINE(NO_X11)
3304 else
3305     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3306         XLIBS="-lX11 $XLIBS"
3307         _SAVE_LDFLAGS="$LDFLAGS"
3308         LDFLAGS="$XLDFLAGS $LDFLAGS"
3309         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3310                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3311         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3312                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3313      
3314         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3315         unset ac_cv_lib_Xt_XtFree
3316             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3317             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS) 
3318         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3319                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3320         ])
3322     # AIX needs the motif library linked before libXt to prevent
3323     # crashes in plugins linked against Motif - Bug #98892
3324     case "${target_os}" in
3325     aix*)
3326         XT_LIBS="-lXm $XT_LIBS"
3327         ;;
3328     esac
3330     dnl ========================================================
3331     dnl = Check for XShm
3332     dnl ========================================================
3333     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3334         $XLIBS $XEXT_LIBS)
3335     AC_CHECK_HEADER(X11/extensions/XShm.h)
3336     if test "$ac_cv_header_X11_extensions_XShm_h" = "yes" &&
3337         test -n "$_HAVE_XSHM_XEXT"; then
3338         AC_DEFINE(HAVE_XSHM)
3339     fi
3341     dnl ========================================================
3342     dnl = Check for XIE
3343     dnl ========================================================
3344     AC_CHECK_LIB(XIE, XieFloGeometry, [MOZ_XIE_LIBS="-lXIE"],,
3345         $XLIBS $XEXT_LIBS)
3346     AC_CHECK_HEADER(X11/extensions/XIElib.h)
3348     if test "$MOZ_XIE_LIBS"; then
3349         dnl ====================================================
3350         dnl = If XIE is present and is desired, turn it on
3351         dnl ====================================================
3352         case $target in
3353             *-hpux*)
3354                 ;;
3355             *)
3356                 HAVE_XIE=1
3357                 ;;
3358         esac
3359     fi
3361         LDFLAGS="$_SAVE_LDFLAGS"
3363     dnl ========================================================
3364     dnl = Check for freetype2 and its functionality
3365     dnl ========================================================
3366     AC_CHECK_FT2(6.1.0, [_HAVE_FREETYPE2=1], [_HAVE_FREETYPE2=])
3368     if test "$_HAVE_FREETYPE2"; then
3369         _SAVE_LIBS="$LIBS"
3370         _SAVE_CFLAGS="$CFLAGS"
3371         LIBS="$LIBS $FT2_LIBS"
3372         CFLAGS="$CFLAGS $FT2_CFLAGS"
3374         AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
3375             ac_cv_member_FT_Bitmap_Size_y_ppem,
3376             [AC_TRY_COMPILE([#include <ft2build.h>
3377                              #include FT_FREETYPE_H],
3378                             [FT_Bitmap_Size s;
3379                              if (sizeof s.y_ppem) return 0;
3380                              return 1],
3381                             ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
3382                             ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
3383         if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
3384             HAVE_FT_BITMAP_SIZE_Y_PPEM=1
3385         else
3386             HAVE_FT_BITMAP_SIZE_Y_PPEM=0
3387         fi
3388         AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
3389                            $HAVE_FT_BITMAP_SIZE_Y_PPEM,
3390                            [FT_Bitmap_Size structure includes y_ppem field])
3392         AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
3394         LIBS="$_SAVE_LIBS"
3395         CFLAGS="$_SAVE_CFLAGS"
3396     fi
3398 fi # $no_x
3400 AC_SUBST(XCFLAGS)
3401 AC_SUBST(XLDFLAGS)
3402 AC_SUBST(XLIBS)
3403 AC_SUBST(XEXT_LIBS)
3404 AC_SUBST(XT_LIBS)
3406 AC_MSG_CHECKING(for ARM SIMD support in compiler)
3407 AC_TRY_COMPILE([],
3408                [asm("uqadd8 r1, r1, r2");],
3409                result="yes", result="no")
3410 AC_MSG_RESULT("$result")
3411 if test "$result" = "yes"; then
3412     AC_DEFINE(HAVE_ARM_SIMD)
3413     HAVE_ARM_SIMD=1
3415 AC_SUBST(HAVE_ARM_SIMD)
3417 AC_MSG_CHECKING(for ARM NEON support in compiler)
3418 _SAVE_CFLAGS="$CFLAGS"
3419 if test "$GNU_CC"; then
3420   # gcc needs -mfpu=neon to recognize NEON instructions
3421   CFLAGS="$CFLAGS -mfpu=neon -mfloat-abi=softfp"
3423 AC_TRY_COMPILE([],
3424                [asm("vadd.i8 d0, d0, d0");],
3425                result="yes", result="no")
3426 AC_MSG_RESULT("$result")
3427 if test "$result" = "yes"; then
3428     AC_DEFINE(HAVE_ARM_NEON)
3429     HAVE_ARM_NEON=1
3431 CFLAGS="$_SAVE_CFLAGS"
3432 AC_SUBST(HAVE_ARM_NEON)
3434 dnl ========================================================
3435 dnl = pthread support
3436 dnl = Start by checking whether the system support pthreads
3437 dnl ========================================================
3438 case "$target_os" in
3439 darwin*)
3440     USE_PTHREADS=1
3441     ;;
3443     MOZ_CHECK_PTHREADS(pthreads,
3444         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3445         MOZ_CHECK_PTHREADS(pthread,
3446             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3447             MOZ_CHECK_PTHREADS(c_r,
3448                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3449                 MOZ_CHECK_PTHREADS(c,
3450                     USE_PTHREADS=1
3451                 )
3452             )
3453         )
3454     )
3455     ;;
3456 esac
3458 dnl ========================================================
3459 dnl Check the command line for --with-pthreads 
3460 dnl ========================================================
3461 MOZ_ARG_WITH_BOOL(pthreads,
3462 [  --with-pthreads         Force use of system pthread library with NSPR ],
3463 [ if test "$USE_PTHREADS"x = x; then
3464     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3465 fi],
3466     USE_PTHREADS=
3467     _PTHREAD_LDFLAGS=
3470 dnl ========================================================
3471 dnl Do the platform specific pthread hackery
3472 dnl ========================================================
3473 if test "$USE_PTHREADS"x != x
3474 then
3475         dnl
3476         dnl See if -pthread is supported.
3477         dnl
3478         rm -f conftest*
3479         ac_cv_have_dash_pthread=no
3480         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3481         echo 'int main() { return 0; }' | cat > conftest.c
3482         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3483         if test $? -eq 0; then
3484                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3485                         ac_cv_have_dash_pthread=yes
3486                 case "$target_os" in
3487                 freebsd*)
3488 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3489                 ;;
3490                 *)
3491                             CFLAGS="$CFLAGS -pthread"
3492                             CXXFLAGS="$CXXFLAGS -pthread"
3493                 ;;
3494                 esac
3495                 fi
3496         fi
3497         rm -f conftest*
3498     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3500         dnl
3501         dnl See if -pthreads is supported.
3502         dnl
3503     ac_cv_have_dash_pthreads=no
3504     if test "$ac_cv_have_dash_pthread" = "no"; then
3505             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3506         echo 'int main() { return 0; }' | cat > conftest.c
3507             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3508         if test $? -eq 0; then
3509                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3510                             ac_cv_have_dash_pthreads=yes
3511                             CFLAGS="$CFLAGS -pthreads"
3512                             CXXFLAGS="$CXXFLAGS -pthreads"
3513                     fi
3514             fi
3515             rm -f conftest*
3516         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3517     fi
3519         case "$target" in
3520             *-*-freebsd*)
3521                         AC_DEFINE(_REENTRANT)
3522                         AC_DEFINE(_THREAD_SAFE)
3523                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3524                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3525                                 _PTHREAD_LDFLAGS="-pthread"
3526                         else
3527                                 _PTHREAD_LDFLAGS="-lc_r"
3528                         fi
3529                         ;;
3531             *-*-openbsd*|*-*-bsdi*)
3532                         AC_DEFINE(_REENTRANT)
3533                         AC_DEFINE(_THREAD_SAFE)
3534                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3535                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3536                 _PTHREAD_LDFLAGS="-pthread"
3537                         fi
3538                         ;;
3540             *-*-linux*|*-*-kfreebsd*-gnu)
3541                         AC_DEFINE(_REENTRANT) 
3542                         ;;
3544             *-*-nto*) 
3545                         AC_DEFINE(_REENTRANT) 
3546                         ;;
3548             *-aix4.3*|*-aix5*)
3549                         AC_DEFINE(_REENTRANT) 
3550                         ;;
3552             *-hpux11.*)
3553                         AC_DEFINE(_REENTRANT) 
3554                         ;;
3556             alpha*-*-osf*)
3557                         AC_DEFINE(_REENTRANT)
3558                         ;;
3560             *-*-solaris*) 
3561                         AC_DEFINE(_REENTRANT)
3562                         if test "$SOLARIS_SUNPRO_CC"; then
3563                                 CFLAGS="$CFLAGS -mt" 
3564                                 CXXFLAGS="$CXXFLAGS -mt" 
3565                         fi
3566                         ;;
3567         esac
3568     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3571 dnl ========================================================
3572 dnl See if mmap sees writes
3573 dnl For cross compiling, just define it as no, which is a safe default
3574 dnl ========================================================
3575 AC_MSG_CHECKING(whether mmap() sees write()s)
3577 changequote(,)
3578 mmap_test_prog='
3579     #include <stdlib.h>
3580     #include <unistd.h>
3581     #include <sys/mman.h>
3582     #include <sys/types.h>
3583     #include <sys/stat.h>
3584     #include <fcntl.h>
3586     char fname[] = "conftest.file";
3587     char zbuff[1024]; /* Fractional page is probably worst case */
3589     int main() {
3590         char *map;
3591         int fd;
3592         int i;
3593         unlink(fname);
3594         fd = open(fname, O_RDWR | O_CREAT, 0660);
3595         if(fd<0) return 1;
3596         unlink(fname);
3597         write(fd, zbuff, sizeof(zbuff));
3598         lseek(fd, 0, SEEK_SET);
3599         map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0);
3600         if(map==(char*)-1) return 2;
3601         for(i=0; fname[i]; i++) {
3602             int rc = write(fd, &fname[i], 1);
3603             if(map[i]!=fname[i]) return 4;
3604         }
3605         return 0;
3606     }
3608 changequote([,])
3610 AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes")
3612 AC_MSG_RESULT("$result")
3614 if test "$result" = "no"; then
3615     AC_DEFINE(MMAP_MISSES_WRITES)
3619 dnl Checks for library functions.
3620 dnl ========================================================
3621 AC_PROG_GCC_TRADITIONAL
3622 AC_FUNC_MEMCMP
3623 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf statvfs memmove rint stat64 lstat64 truncate64 statvfs64 setbuf isatty)
3624 AC_CHECK_FUNCS(flockfile getpagesize)
3625 AC_CHECK_FUNCS(localtime_r strtok_r)
3627 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock, and -lrt
3628 _SAVE_LDFLAGS=$LDFLAGS
3629 LDFLAGS="$LDFLAGS -lrt"
3630 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC) and -lrt,
3631                ac_cv_have_clock_monotonic,
3632                [AC_TRY_LINK([#include <time.h>],
3633                             [ struct timespec ts;
3634                               clock_gettime(CLOCK_MONOTONIC, &ts); ],
3635                             ac_cv_have_clock_monotonic=yes,
3636                             ac_cv_have_clock_monotonic=no)])
3637 LDFLAGS=$_SAVE_LDFLAGS
3638 if test "$ac_cv_have_clock_monotonic" = "yes"; then
3639     HAVE_CLOCK_MONOTONIC=1
3640     REALTIME_LIBS=-lrt
3641     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3642     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3643     AC_SUBST(REALTIME_LIBS)
3646 dnl check for wcrtomb/mbrtowc
3647 dnl =======================================================================
3648 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3649 AC_LANG_SAVE
3650 AC_LANG_CPLUSPLUS
3651 AC_CACHE_CHECK(for wcrtomb,
3652     ac_cv_have_wcrtomb,
3653     [AC_TRY_LINK([#include <wchar.h>],
3654                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3655                  ac_cv_have_wcrtomb="yes",
3656                  ac_cv_have_wcrtomb="no")])
3657 if test "$ac_cv_have_wcrtomb" = "yes"; then
3658     AC_DEFINE(HAVE_WCRTOMB)
3660 AC_CACHE_CHECK(for mbrtowc,
3661     ac_cv_have_mbrtowc,
3662     [AC_TRY_LINK([#include <wchar.h>],
3663                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3664                  ac_cv_have_mbrtowc="yes",
3665                  ac_cv_have_mbrtowc="no")])
3666 if test "$ac_cv_have_mbrtowc" = "yes"; then
3667     AC_DEFINE(HAVE_MBRTOWC)
3669 AC_LANG_RESTORE
3672 AC_CACHE_CHECK(
3673     [for res_ninit()],
3674     ac_cv_func_res_ninit,
3675     [AC_TRY_LINK([
3676         #ifdef linux
3677         #define _BSD_SOURCE 1
3678         #endif
3679         #include <resolv.h>
3680         ],
3681         [int foo = res_ninit(&_res);],
3682         [ac_cv_func_res_ninit=yes],
3683         [ac_cv_func_res_ninit=no])
3684     ])
3686 if test "$ac_cv_func_res_ninit" = "yes"; then
3687     AC_DEFINE(HAVE_RES_NINIT)
3688 dnl must add the link line we do something as foolish as this... dougt
3689 dnl else
3690 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3691 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3694 AC_LANG_CPLUSPLUS
3695 AC_CACHE_CHECK(
3696     [for gnu_get_libc_version()],
3697     ac_cv_func_gnu_get_libc_version,
3698     [AC_TRY_LINK([
3699         #ifdef HAVE_GNU_LIBC_VERSION_H
3700         #include <gnu/libc-version.h>
3701         #endif
3702         ],
3703         [const char *glibc_version = gnu_get_libc_version();],
3704         [ac_cv_func_gnu_get_libc_version=yes],
3705         [ac_cv_func_gnu_get_libc_version=no] 
3706         )]
3707     )
3709 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3710     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3713 case $target_os in
3714     os2*|msvc*|mks*|cygwin*|mingw*|darwin*|wince*|winmo*|beos*)
3715         ;;
3716     *)
3717     
3718 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3719     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3720         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3721 _SAVE_LIBS=$LIBS
3722 LIBS="$LIBS $_ICONV_LIBS"
3723 AC_CACHE_CHECK(
3724     [for iconv()],
3725     ac_cv_func_iconv,
3726     [AC_TRY_LINK([
3727         #include <stdlib.h>
3728         #include <iconv.h>
3729         ],
3730         [
3731             iconv_t h = iconv_open("", "");
3732             iconv(h, NULL, NULL, NULL, NULL);
3733             iconv_close(h);
3734         ],
3735         [ac_cv_func_iconv=yes],
3736         [ac_cv_func_iconv=no] 
3737         )]
3738     )
3739 if test "$ac_cv_func_iconv" = "yes"; then
3740     AC_DEFINE(HAVE_ICONV)
3741     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3742     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3743     LIBICONV="$_ICONV_LIBS"
3744     AC_CACHE_CHECK(
3745         [for iconv() with const input],
3746         ac_cv_func_const_iconv,
3747         [AC_TRY_COMPILE([
3748             #include <stdlib.h>
3749             #include <iconv.h>
3750             ],
3751             [
3752                 const char *input = "testing";
3753                 iconv_t h = iconv_open("", "");
3754                 iconv(h, &input, NULL, NULL, NULL);
3755                 iconv_close(h);
3756             ],
3757             [ac_cv_func_const_iconv=yes],
3758             [ac_cv_func_const_iconv=no] 
3759             )]
3760         )
3761     if test "$ac_cv_func_const_iconv" = "yes"; then
3762         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3763     fi
3765 LIBS=$_SAVE_LIBS
3767     ;;
3768 esac
3770 AM_LANGINFO_CODESET
3772 AC_LANG_C
3774 dnl **********************
3775 dnl *** va_copy checks ***
3776 dnl **********************
3777 dnl we currently check for all three va_copy possibilities, so we get
3778 dnl all results in config.log for bug reports.
3779 AC_MSG_CHECKING(for an implementation of va_copy())
3780 AC_CACHE_VAL(ac_cv_va_copy,[
3781     AC_TRY_RUN([
3782         #include <stdarg.h>
3783         void f (int i, ...) {
3784             va_list args1, args2;
3785             va_start (args1, i);
3786             va_copy (args2, args1);
3787             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3788                 exit (1);
3789             va_end (args1); va_end (args2);
3790         }
3791         int main() { f (0, 42); return 0; }],
3792         ac_cv_va_copy=yes,
3793         ac_cv_va_copy=no,
3794         ac_cv_va_copy=no
3795     )
3797 AC_MSG_RESULT($ac_cv_va_copy)
3798 AC_MSG_CHECKING(for an implementation of __va_copy())
3799 AC_CACHE_VAL(ac_cv___va_copy,[
3800     AC_TRY_RUN([
3801         #include <stdarg.h>
3802         void f (int i, ...) {
3803             va_list args1, args2;
3804             va_start (args1, i);
3805             __va_copy (args2, args1);
3806             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3807                 exit (1);
3808             va_end (args1); va_end (args2);
3809         }
3810         int main() { f (0, 42); return 0; }],
3811         ac_cv___va_copy=yes,
3812         ac_cv___va_copy=no,
3813         ac_cv___va_copy=no
3814     )
3816 AC_MSG_RESULT($ac_cv___va_copy)
3817 AC_MSG_CHECKING(whether va_lists can be copied by value)
3818 AC_CACHE_VAL(ac_cv_va_val_copy,[
3819     AC_TRY_RUN([
3820         #include <stdarg.h>
3821         void f (int i, ...) {
3822             va_list args1, args2;
3823             va_start (args1, i);
3824             args2 = args1;
3825             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3826                 exit (1);
3827             va_end (args1); va_end (args2);
3828         }
3829         int main() { f (0, 42); return 0; }],
3830         ac_cv_va_val_copy=yes,
3831         ac_cv_va_val_copy=no,
3832         ac_cv_va_val_copy=yes
3833     )
3835 if test "x$ac_cv_va_copy" = "xyes"; then
3836     AC_DEFINE(VA_COPY, va_copy)
3837     AC_DEFINE(HAVE_VA_COPY)
3838 elif test "x$ac_cv___va_copy" = "xyes"; then
3839     AC_DEFINE(VA_COPY, __va_copy)
3840     AC_DEFINE(HAVE_VA_COPY)
3843 if test "x$ac_cv_va_val_copy" = "xno"; then
3844    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3846 AC_MSG_RESULT($ac_cv_va_val_copy)
3848 dnl Check for dll-challenged libc's.
3849 dnl This check is apparently only needed for Linux.
3850 case "$target" in
3851         *-linux*)
3852             dnl ===================================================================
3853             _curdir=`pwd`
3854             export _curdir
3855             rm -rf conftest* _conftest
3856             mkdir _conftest
3857             cat >> conftest.C <<\EOF
3858 #include <stdio.h>
3859 #include <link.h>
3860 #include <dlfcn.h>
3861 #ifdef _dl_loaded
3862 void __dump_link_map(void) {
3863   struct link_map *map = _dl_loaded;
3864   while (NULL != map) {printf("0x%08x %s\n", map->l_addr, map->l_name); map = map->l_next;}
3866 int main() {
3867   dlopen("./conftest1.so",RTLD_LAZY);
3868   dlopen("./../_conftest/conftest1.so",RTLD_LAZY);
3869   dlopen("CURDIR/_conftest/conftest1.so",RTLD_LAZY);
3870   dlopen("CURDIR/_conftest/../_conftest/conftest1.so",RTLD_LAZY);
3871   __dump_link_map();
3873 #else
3874 /* _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).*/
3875 int main() { printf("./conftest1.so\n"); }
3876 #endif
3879             $PERL -p -i -e "s/CURDIR/\$ENV{_curdir}/g;" conftest.C
3881             cat >> conftest1.C <<\EOF
3882 #include <stdio.h>
3883 void foo(void) {printf("foo in dll called\n");}
3885             ${CXX-g++} -fPIC -c -g conftest1.C
3886             ${CXX-g++} -shared -Wl,-h -Wl,conftest1.so -o conftest1.so conftest1.o
3887             ${CXX-g++} -g conftest.C -o conftest -ldl
3888             cp -f conftest1.so conftest _conftest
3889             cd _conftest
3890             if test `./conftest | grep conftest1.so | wc -l` -gt 1
3891             then
3892                 echo
3893                 echo "*** Your libc has a bug that can result in loading the same dynamic"
3894                 echo "*** library multiple times.  This bug is known to be fixed in glibc-2.0.7-32"
3895                 echo "*** or later.  However, if you choose not to upgrade, the only effect"
3896                 echo "*** will be excessive memory usage at runtime."
3897                 echo
3898             fi
3899             cd ${_curdir}
3900             rm -rf conftest* _conftest
3901             dnl ===================================================================
3902             ;;
3903 esac
3905 dnl ===================================================================
3906 dnl ========================================================
3907 dnl By default, turn rtti and exceptions off on g++/egcs
3908 dnl ========================================================
3909 if test "$GNU_CXX"; then
3911   AC_MSG_CHECKING(for C++ exceptions flag)
3913   dnl They changed -f[no-]handle-exceptions to -f[no-]exceptions in g++ 2.8
3914   AC_CACHE_VAL(ac_cv_cxx_exceptions_flags,
3915   [echo "int main() { return 0; }" | cat > conftest.C
3917   ${CXX-g++} ${CXXFLAGS} -c -fno-handle-exceptions conftest.C > conftest.out 2>&1
3919   if egrep "warning.*renamed" conftest.out >/dev/null; then
3920     ac_cv_cxx_exceptions_flags=${_COMPILER_PREFIX}-fno-exceptions
3921   else
3922     ac_cv_cxx_exceptions_flags=${_COMPILER_PREFIX}-fno-handle-exceptions
3923   fi
3925   rm -f conftest*])
3927   AC_MSG_RESULT($ac_cv_cxx_exceptions_flags)
3928   _MOZ_EXCEPTIONS_FLAGS_OFF=$ac_cv_cxx_exceptions_flags
3929   _MOZ_EXCEPTIONS_FLAGS_ON=`echo $ac_cv_cxx_exceptions_flags | sed 's|no-||'`
3932 dnl ========================================================
3933 dnl Put your C++ language/feature checks below
3934 dnl ========================================================
3935 AC_LANG_CPLUSPLUS
3937 HAVE_GCC3_ABI=
3938 if test "$GNU_CC"; then
3939   AC_CACHE_CHECK(for gcc 3.0 ABI,
3940       ac_cv_gcc_three_abi,
3941       [AC_TRY_COMPILE([],
3942                       [
3943 #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
3944   return 0;
3945 #else
3946 #error Not gcc3.
3947 #endif
3948                       ],
3949                       ac_cv_gcc_three_abi="yes",
3950                       ac_cv_gcc_three_abi="no")])
3951   if test "$ac_cv_gcc_three_abi" = "yes"; then
3952       TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-gcc3}"
3953       HAVE_GCC3_ABI=1
3954   else
3955       TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-gcc2}"
3956   fi
3958 AC_SUBST(HAVE_GCC3_ABI)
3961 AC_CACHE_CHECK(for C++ \"explicit\" keyword,
3962                ac_cv_cpp_explicit,
3963                [AC_TRY_COMPILE(class X {
3964                                public: explicit X(int i) : i_(i) {}
3965                                private: int i_;
3966                                };,
3967                                X x(3);,
3968                                ac_cv_cpp_explicit=yes,
3969                                ac_cv_cpp_explicit=no)])
3970 if test "$ac_cv_cpp_explicit" = yes ; then
3971    AC_DEFINE(HAVE_CPP_EXPLICIT)
3974 AC_CACHE_CHECK(for C++ \"typename\" keyword,
3975                ac_cv_cpp_typename,
3976                [AC_TRY_COMPILE(class param {
3977                                public:
3978                                    typedef unsigned long num_type;
3979                                };
3981                                template <class T> class tplt {
3982                                public:
3983                                    typedef typename T::num_type t_num_type;
3984                                    t_num_type foo(typename T::num_type num) {
3985                                        return num;
3986                                    }
3987                                };,
3988                                tplt<param> A;
3989                                A.foo(0);,
3990                                ac_cv_cpp_typename=yes,
3991                                ac_cv_cpp_typename=no)])
3992 if test "$ac_cv_cpp_typename" = yes ; then
3993    AC_DEFINE(HAVE_CPP_TYPENAME)
3996 dnl Check for support of modern template specialization syntax
3997 dnl Test code and requirement from scc@netscape.com.
3998 dnl Autoconf cut-and-paste job by waterson@netscape.com
3999 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
4000                ac_cv_cpp_modern_specialize_template_syntax,
4001                [AC_TRY_COMPILE(template <class T> struct X { int a; };
4002                                class Y {};
4003                                template <> struct X<Y> { double a; };,
4004                                X<int> int_x;
4005                                X<Y> y_x;,
4006                                ac_cv_cpp_modern_specialize_template_syntax=yes,
4007                                ac_cv_cpp_modern_specialize_template_syntax=no)])
4008 if test "$ac_cv_cpp_modern_specialize_template_syntax" = yes ; then
4009   AC_DEFINE(HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX)
4013 dnl Some compilers support only full specialization, and some don't.
4014 AC_CACHE_CHECK(whether partial template specialization works,
4015                ac_cv_cpp_partial_specialization,
4016                [AC_TRY_COMPILE(template <class T> class Foo {};
4017                                template <class T> class Foo<T*> {};,
4018                                return 0;,
4019                                ac_cv_cpp_partial_specialization=yes,
4020                                ac_cv_cpp_partial_specialization=no)])
4021 if test "$ac_cv_cpp_partial_specialization" = yes ; then
4022   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
4025 dnl Some compilers have limited support for operators with templates;
4026 dnl specifically, it is necessary to define derived operators when a base
4027 dnl class's operator declaration should suffice.
4028 AC_CACHE_CHECK(whether operators must be re-defined for templates derived from templates,
4029                ac_cv_need_derived_template_operators,
4030                [AC_TRY_COMPILE([template <class T> class Base { };
4031                                 template <class T>
4032                                 Base<T> operator+(const Base<T>& lhs, const Base<T>& rhs) { return lhs; }
4033                                 template <class T> class Derived : public Base<T> { };],
4034                                [Derived<char> a, b;
4035                                 Base<char> c = a + b;
4036                                 return 0;],
4037                                ac_cv_need_derived_template_operators=no,
4038                                ac_cv_need_derived_template_operators=yes)])
4039 if test "$ac_cv_need_derived_template_operators" = yes ; then
4040   AC_DEFINE(NEED_CPP_DERIVED_TEMPLATE_OPERATORS)
4044 dnl Some compilers have trouble detecting that a template class
4045 dnl that derives from another template is actually an instance
4046 dnl of the base class. This test checks for that.
4047 AC_CACHE_CHECK(whether we need to cast a derived template to pass as its base class,
4048                ac_cv_need_cpp_template_cast_to_base,
4049                [AC_TRY_COMPILE([template <class T> class Base { };
4050                                 template <class T> class Derived : public Base<T> { };
4051                                 template <class T> int foo(const Base<T>&) { return 0; }],
4052                                [Derived<char> bar; return foo(bar);],
4053                                ac_cv_need_cpp_template_cast_to_base=no,
4054                                ac_cv_need_cpp_template_cast_to_base=yes)])
4055 if test "$ac_cv_need_cpp_template_cast_to_base" = yes ; then
4056   AC_DEFINE(NEED_CPP_TEMPLATE_CAST_TO_BASE)
4059 dnl Some compilers have trouble resolving the ambiguity between two
4060 dnl functions whose arguments differ only by cv-qualifications.
4061 AC_CACHE_CHECK(whether the compiler can resolve const ambiguities for templates,
4062                ac_cv_can_resolve_const_ambiguity,
4063                [AC_TRY_COMPILE([
4064                                 template <class T> class ptrClass {
4065                                   public: T* ptr;
4066                                 };
4068                                 template <class T> T* a(ptrClass<T> *arg) {
4069                                   return arg->ptr;
4070                                 }
4072                                 template <class T>
4073                                 const T* a(const ptrClass<T> *arg) {
4074                                   return arg->ptr;
4075                                 }
4076                                ],
4077                                [ ptrClass<int> i;
4078                                  a(&i); ],
4079                                ac_cv_can_resolve_const_ambiguity=yes,
4080                                ac_cv_can_resolve_const_ambiguity=no)])
4081 if test "$ac_cv_can_resolve_const_ambiguity" = no ; then
4082   AC_DEFINE(CANT_RESOLVE_CPP_CONST_AMBIGUITY)
4086 dnl We don't do exceptions on unix.  The only reason this used to be here
4087 dnl is that mozilla/xpcom/tests/TestCOMPtr.cpp has a test which uses 
4088 dnl exceptions.  But, we turn exceptions off by default and this test breaks.
4089 dnl So im commenting this out until someone writes some artificial 
4090 dnl intelligence to detect not only if the compiler has exceptions, but if 
4091 dnl they are enabled as well.
4092 dnl 
4093 dnl AC_CACHE_CHECK(for C++ \"exceptions\",
4094 dnl                ac_cv_cpp_exceptions,
4095 dnl                [AC_TRY_COMPILE(class X { public: X() {} };
4096 dnl                                static void F() { throw X(); },
4097 dnl                                try { F(); } catch(X & e) { },
4098 dnl                                ac_cv_cpp_exceptions=yes,
4099 dnl                                ac_cv_cpp_exceptions=no)])
4100 dnl if test $ac_cv_cpp_exceptions = yes ; then
4101 dnl    AC_DEFINE(HAVE_CPP_EXCEPTIONS)
4102 dnl fi
4104 dnl Some compilers have marginal |using| support; for example, gcc-2.7.2.3
4105 dnl supports it well enough to allow us to use it to change access, but not
4106 dnl to resolve ambiguity. The next two tests determine how well the |using|
4107 dnl keyword is supported.
4109 dnl Check to see if we can change access with |using|.  Test both a
4110 dnl legal and an illegal example.
4111 AC_CACHE_CHECK(whether the C++ \"using\" keyword can change access,
4112                ac_cv_cpp_access_changing_using2,
4113                [AC_TRY_COMPILE(
4114                    class A { protected: int foo() { return 0; } };
4115                    class B : public A { public: using A::foo; };,
4116                    B b; return b.foo();,
4117                    [AC_TRY_COMPILE(
4118                        class A { public: int foo() { return 1; } };
4119                        class B : public A { private: using A::foo; };,
4120                        B b; return b.foo();,
4121                        ac_cv_cpp_access_changing_using2=no,
4122                        ac_cv_cpp_access_changing_using2=yes)],
4123                    ac_cv_cpp_access_changing_using2=no)])
4124 if test "$ac_cv_cpp_access_changing_using2" = yes ; then
4125    AC_DEFINE(HAVE_CPP_ACCESS_CHANGING_USING)
4128 dnl Check to see if we can resolve ambiguity with |using|.
4129 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
4130                ac_cv_cpp_ambiguity_resolving_using,
4131                [AC_TRY_COMPILE(class X { 
4132                                  public: int go(const X&) {return 3;}
4133                                          int jo(const X&) {return 3;}
4134                                };
4135                                class Y : public X {
4136                                  public:  int go(int) {return 2;}
4137                                           int jo(int) {return 2;}
4138                                           using X::jo;
4139                                  private: using X::go;
4140                                };,
4141                                X x; Y y; y.jo(x);,
4142                                ac_cv_cpp_ambiguity_resolving_using=yes,
4143                                ac_cv_cpp_ambiguity_resolving_using=no)])
4144 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
4145    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
4148 dnl Check to see if the |std| namespace is supported. If so, we'll want
4149 dnl to qualify any standard library calls with "std::" to ensure that
4150 dnl those functions can be resolved.
4151 AC_CACHE_CHECK(for \"std::\" namespace,
4152                ac_cv_cpp_namespace_std,
4153                [AC_TRY_COMPILE([#include <algorithm>],
4154                                [return std::min(0, 1);],
4155                                ac_cv_cpp_namespace_std=yes,
4156                                ac_cv_cpp_namespace_std=no)])
4157 if test "$ac_cv_cpp_namespace_std" = yes ; then
4158    AC_DEFINE(HAVE_CPP_NAMESPACE_STD)
4161 dnl Older compilers are overly ambitious with respect to using the standard
4162 dnl template library's |operator!=()| when |operator==()| is defined. In
4163 dnl which case, defining |operator!=()| in addition to |operator==()| causes
4164 dnl ambiguity at compile-time. This test checks for that case.
4165 AC_CACHE_CHECK(whether standard template operator!=() is ambiguous,
4166                ac_cv_cpp_unambiguous_std_notequal,
4167                [AC_TRY_COMPILE([#include <algorithm>
4168                                 struct T1 {};
4169                                 int operator==(const T1&, const T1&) { return 0; }
4170                                 int operator!=(const T1&, const T1&) { return 0; }],
4171                                [T1 a,b; return a != b;],
4172                                ac_cv_cpp_unambiguous_std_notequal=unambiguous,
4173                                ac_cv_cpp_unambiguous_std_notequal=ambiguous)])
4174 if test "$ac_cv_cpp_unambiguous_std_notequal" = unambiguous ; then
4175   AC_DEFINE(HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL)
4179 AC_CACHE_CHECK(for C++ reinterpret_cast,
4180                ac_cv_cpp_reinterpret_cast,
4181                [AC_TRY_COMPILE(struct X { int i; };
4182                                struct Y { int i; };,
4183                                X x; X*const z = &x;Y*y = reinterpret_cast<Y*>(z);,
4184                                ac_cv_cpp_reinterpret_cast=yes,
4185                                ac_cv_cpp_reinterpret_cast=no)])
4186 if test "$ac_cv_cpp_reinterpret_cast" = yes ; then
4187    AC_DEFINE(HAVE_CPP_NEW_CASTS)
4190 dnl See if a dynamic_cast to void* gives the most derived object.
4191 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
4192                ac_cv_cpp_dynamic_cast_void_ptr,
4193                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
4194                             class Y { int j; public: virtual ~Y() { } };
4195                             class Z : public X, public Y { int k; };
4197                             int main() {
4198                                  Z mdo;
4199                                  X *subx = (X*)&mdo;
4200                                  Y *suby = (Y*)&mdo;
4201                                  return !((((void*)&mdo != (void*)subx) &&
4202                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
4203                                           (((void*)&mdo != (void*)suby) &&
4204                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
4205                             }],
4206                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
4207                            ac_cv_cpp_dynamic_cast_void_ptr=no,
4208                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
4209 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
4210    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
4214 dnl note that this one is reversed - if the test fails, then
4215 dnl we require implementations of unused virtual methods. Which
4216 dnl really blows because it means we'll have useless vtable
4217 dnl bloat.
4218 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
4219                ac_cv_cpp_unused_required,
4220                [AC_TRY_LINK(class X {private: virtual void never_called();};,
4221                                X x;,
4222                                ac_cv_cpp_unused_required=no,
4223                                ac_cv_cpp_unused_required=yes)])
4224 if test "$ac_cv_cpp_unused_required" = yes ; then
4225    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
4229 dnl Some compilers have trouble comparing a constant reference to a templatized
4230 dnl class to zero, and require an explicit operator==() to be defined that takes
4231 dnl an int. This test separates the strong from the weak.
4233 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
4234                ac_cv_trouble_comparing_to_zero,
4235                [AC_TRY_COMPILE([#include <algorithm>
4236                                 template <class T> class Foo {};
4237                                 class T2;
4238                                 template <class T> int operator==(const T2*, const T&) { return 0; }
4239                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
4240                                [Foo<int> f; return (0 != f);],
4241                                ac_cv_trouble_comparing_to_zero=no,
4242                                ac_cv_trouble_comparing_to_zero=yes)])
4243 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
4244   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
4247 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
4248 _SAVE_LDFLAGS=$LDFLAGS
4249 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS"
4250 AC_CACHE_CHECK(for __thread keyword for TLS variables,
4251                ac_cv_thread_keyword,
4252                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
4253                             [return tlsIsMainThread;],
4254                             ac_cv_thread_keyword=yes,
4255                             ac_cv_thread_keyword=no)])
4256 LDFLAGS=$_SAVE_LDFLAGS
4257 if test "$ac_cv_thread_keyword" = yes; then
4258   AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
4261 dnl Check for the existence of various allocation headers/functions
4263 MALLOC_H=
4264 AC_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
4265 if test "$MALLOC_H" = ""; then
4266   AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
4267   if test "$MALLOC_H" = ""; then
4268     AC_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
4269   fi
4271 if test "$MALLOC_H" != ""; then
4272    AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
4275 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
4276 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
4278 dnl See if compiler supports some gcc-style attributes
4280 AC_CACHE_CHECK(for __attribute__((always_inline)),
4281                ac_cv_attribute_always_inline,
4282                [AC_TRY_COMPILE([],
4283                                [inline void f(void) __attribute__((always_inline));],
4284                                ac_cv_attribute_always_inline=yes,
4285                                ac_cv_attribute_always_inline=no)])
4287 AC_CACHE_CHECK(for __attribute__((malloc)),
4288                ac_cv_attribute_malloc,
4289                [AC_TRY_COMPILE([],
4290                                [void* f(int) __attribute__((malloc));],
4291                                ac_cv_attribute_malloc=yes,
4292                                ac_cv_attribute_malloc=no)])
4294 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
4295                ac_cv_attribute_warn_unused,
4296                [AC_TRY_COMPILE([],
4297                                [int f(void) __attribute__((warn_unused_result));],
4298                                ac_cv_attribute_warn_unused=yes,
4299                                ac_cv_attribute_warn_unused=no)])
4301 AC_CACHE_CHECK(for __attribute__((noreturn)),
4302                ac_cv_attribute_noreturn,
4303                [AC_TRY_COMPILE([],
4304                                [void f(void) __attribute__((noreturn));],
4305                                ac_cv_attribute_noreturn=yes,
4306                                ac_cv_attribute_noreturn=no)])
4308 dnl End of C++ language/feature checks
4309 AC_LANG_C
4311 dnl ========================================================
4312 dnl =  Internationalization checks
4313 dnl ========================================================
4315 dnl Internationalization and Locale support is different
4316 dnl on various UNIX platforms.  Checks for specific i18n
4317 dnl features go here.
4319 dnl check for LC_MESSAGES
4320 AC_CACHE_CHECK(for LC_MESSAGES,
4321                 ac_cv_i18n_lc_messages,
4322                 [AC_TRY_COMPILE([#include <locale.h>],
4323                                 [int category = LC_MESSAGES;],
4324                                 ac_cv_i18n_lc_messages=yes,
4325                                 ac_cv_i18n_lc_messages=no)])
4326 if test "$ac_cv_i18n_lc_messages" = yes; then
4327    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
4328 fi      
4330 fi # SKIP_COMPILER_CHECKS
4332 TARGET_XPCOM_ABI=
4333 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
4334     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
4337 dnl Mozilla specific options
4338 dnl ========================================================
4339 dnl The macros used for command line options
4340 dnl are defined in build/autoconf/altoptions.m4.
4342 dnl If the compiler supports these attributes, define them as
4343 dnl convenience macros.
4344 if test "$ac_cv_attribute_always_inline" = yes ; then
4345   AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
4346 else
4347   AC_DEFINE(NS_ALWAYS_INLINE,)
4350 if test "$ac_cv_attribute_malloc" = yes ; then
4351   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
4352 else
4353   AC_DEFINE(NS_ATTR_MALLOC,)
4356 if test "$ac_cv_attribute_warn_unused" = yes ; then
4357   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
4358 else
4359   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
4362 if test "$ac_cv_attribute_noreturn" = yes ; then
4363   AC_DEFINE(NS_NORETURN, [__attribute__((noreturn))])
4364 else
4365   AC_DEFINE(NS_NORETURN,)
4368 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
4369 dnl features that Windows actually does support.
4371 if test -n "$SKIP_COMPILER_CHECKS"; then
4372    dnl Windows has malloc.h
4373    AC_DEFINE(MALLOC_H, [<malloc.h>])
4374    AC_DEFINE(HAVE_FORCEINLINE)
4375 fi # SKIP_COMPILER_CHECKS
4377 dnl ========================================================
4378 dnl =
4379 dnl = Check for external package dependencies
4380 dnl =
4381 dnl ========================================================
4382 MOZ_ARG_HEADER(External Packages)
4384 MOZ_ENABLE_LIBXUL=1
4386 MOZ_ARG_WITH_STRING(libxul-sdk,
4387 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
4388   LIBXUL_SDK_DIR=$withval)
4390 if test "$LIBXUL_SDK_DIR" = "yes"; then
4391     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
4392 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
4393     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
4395     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
4396         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
4397     fi
4399     MOZ_ENABLE_LIBXUL=1
4401 AC_SUBST(LIBXUL_SDK)
4403 if test -n "$LIBXUL_SDK"; then
4404     LIBXUL_DIST="$LIBXUL_SDK"
4405 else
4406     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
4408 AC_SUBST(LIBXUL_DIST)
4410 SYSTEM_LIBXUL=
4412 MOZ_ARG_WITH_BOOL(system-libxul,
4413 [  --with-system-libxul   Use system installed libxul SDK],
4414     SYSTEM_LIBXUL=1)
4416 if test -n "$SYSTEM_LIBXUL" && test -z "$MOZ_ENABLE_LIBXUL"; then
4417     AC_MSG_ERROR([--with-system-libxul needs --with-libxul-sdk])
4420 dnl ========================================================
4421 dnl = If NSPR was not detected in the system, 
4422 dnl = use the one in the source tree (mozilla/nsprpub)
4423 dnl ========================================================
4424 MOZ_ARG_WITH_BOOL(system-nspr,
4425 [  --with-system-nspr      Use system installed NSPR],
4426     _USE_SYSTEM_NSPR=1 )
4428 if test -n "$_USE_SYSTEM_NSPR"; then
4429     AM_PATH_NSPR(4.8.0, [MOZ_NATIVE_NSPR=1], [MOZ_NATIVE_NSPR=])
4432 if test -n "$MOZ_NATIVE_NSPR"; then
4433     _SAVE_CFLAGS=$CFLAGS
4434     CFLAGS="$CFLAGS $NSPR_CFLAGS"
4435     AC_TRY_COMPILE([#include "prlog.h"],
4436                 [#ifndef PR_STATIC_ASSERT
4437                  #error PR_STATIC_ASSERT not defined
4438                  #endif],
4439                 [MOZ_NATIVE_NSPR=1],
4440                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
4441     CFLAGS=$_SAVE_CFLAGS
4442 else
4443     if test "$OS_ARCH" = "WINCE"; then
4444         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
4445         NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
4446     elif test "$OS_ARCH" = "WINNT"; then
4447         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
4448         if test -n "$GNU_CC"; then
4449             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
4450         else
4451             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
4452         fi
4453     else
4454         NSPR_CFLAGS='`$(LIBXUL_DIST)/bin/nspr-config --prefix='${LIBXUL_DIST}' --includedir='${LIBXUL_DIST}'/include/nspr --cflags`'
4455         NSPR_LIBS='`$(LIBXUL_DIST)/bin/nspr-config --prefix='${LIBXUL_DIST}' --libdir='${LIBXUL_DIST}'/lib --libs`'
4456     fi
4459 dnl ========================================================
4460 dnl = If NSS was not detected in the system, 
4461 dnl = use the one in the source tree (mozilla/security/nss)
4462 dnl ========================================================
4464 MOZ_ARG_WITH_BOOL(system-nss,
4465 [  --with-system-nss      Use system installed NSS],
4466     _USE_SYSTEM_NSS=1 )
4468 if test -n "$_USE_SYSTEM_NSS"; then
4469     AM_PATH_NSS(3.12.6, [MOZ_NATIVE_NSS=1], [MOZ_NATIVE_NSS=])
4472 if test -n "$MOZ_NATIVE_NSS"; then
4473    NSS_LIBS="$NSS_LIBS -lcrmf"
4474 else
4475    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
4476    NSS_DEP_LIBS="\
4477         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
4478         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)smime$NSS_VERSION\$(DLL_SUFFIX) \
4479         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)ssl$NSS_VERSION\$(DLL_SUFFIX) \
4480         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nss$NSS_VERSION\$(DLL_SUFFIX) \
4481         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nssutil$NSS_VERSION\$(DLL_SUFFIX)"
4483    if test -z "$GNU_CC" && test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "WINCE" -o "$OS_ARCH" = "OS2"; then
4484        NSS_LIBS="\
4485         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
4486         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
4487         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
4488         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
4489         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
4490    else
4491        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
4492    fi
4495 if test -z "$SKIP_LIBRARY_CHECKS"; then
4496 dnl system JPEG support
4497 dnl ========================================================
4498 MOZ_ARG_WITH_STRING(system-jpeg,
4499 [  --with-system-jpeg[=PFX]
4500                           Use system libjpeg [installed at prefix PFX]],
4501     JPEG_DIR=$withval)
4503 _SAVE_CFLAGS=$CFLAGS
4504 _SAVE_LDFLAGS=$LDFLAGS
4505 _SAVE_LIBS=$LIBS
4506 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
4507     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
4508     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
4510 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
4511     SYSTEM_JPEG=
4512 else
4513     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [SYSTEM_JPEG=1 JPEG_LIBS="-ljpeg $JPEG_LIBS"], SYSTEM_JPEG=, $JPEG_LIBS)
4516 if test "$SYSTEM_JPEG" = 1; then
4517     LIBS="$JPEG_LIBS $LIBS"
4518     AC_TRY_COMPILE([ #include <stdio.h>
4519                      #include <sys/types.h>
4520                      #include <jpeglib.h> ],
4521                    [ #if JPEG_LIB_VERSION < $MOZJPEG
4522                      #error "Insufficient JPEG library version ($MOZJPEG required)."
4523                      #endif ],
4524                    SYSTEM_JPEG=1,
4525                    [SYSTEM_JPEG= JPEG_CFLAGS= JPEG_LIBS=]) 
4526 fi 
4527 CFLAGS=$_SAVE_CFLAGS
4528 LDFLAGS=$_SAVE_LDFLAGS
4529 LIBS=$_SAVE_LIBS
4531 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$SYSTEM_JPEG" = 1; then
4532     JPEG_CFLAGS="-I${JPEG_DIR}/include"
4533     JPEG_LIBS="-L${JPEG_DIR}/lib ${JPEG_LIBS}"
4536 dnl system ZLIB support
4537 dnl ========================================================
4538 MOZ_ARG_WITH_STRING(system-zlib,
4539 [  --with-system-zlib[=PFX]
4540                           Use system libz [installed at prefix PFX]],
4541     ZLIB_DIR=$withval)
4543 _SAVE_CFLAGS=$CFLAGS
4544 _SAVE_LDFLAGS=$LDFLAGS
4545 _SAVE_LIBS=$LIBS
4546 if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
4547     CFLAGS="-I${ZLIB_DIR}/include $CFLAGS"
4548     LDFLAGS="-L${ZLIB_DIR}/lib $LDFLAGS"
4550 if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
4551     SYSTEM_ZLIB=
4552 else
4553     AC_CHECK_LIB(z, gzread, [SYSTEM_ZLIB=1 ZLIB_LIBS="-lz $ZLIB_LIBS"], 
4554         [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=], $ZLIB_LIBS)
4556 if test "$SYSTEM_ZLIB" = 1; then
4557     LIBS="$ZLIB_LIBS $LIBS"
4558     AC_TRY_COMPILE([ #include <stdio.h>
4559                      #include <string.h>
4560                      #include <zlib.h> ],
4561                    [ #if ZLIB_VERNUM < $MOZZLIB 
4562                      #error "Insufficient zlib version ($MOZZLIB required)."
4563                      #endif ],
4564                    SYSTEM_ZLIB=1,
4565                    [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=]) 
4567 CFLAGS=$_SAVE_CFLAGS
4568 LDFLAGS=$_SAVE_LDFLAGS
4569 LIBS=$_SAVE_LIBS
4571 if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
4572     ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
4573     ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
4576 dnl system BZIP2 Support
4577 dnl ========================================================
4578 MOZ_ARG_WITH_STRING(system-bz2,
4579 [  --with-system-bz2[=PFX]
4580                           Use system libbz2 [installed at prefix PFX]],
4581     BZ2_DIR=$withval)
4583 _SAVE_CFLAGS=$CFLAGS
4584 _SAVE_LDFLAGS=$LDFLAGS
4585 _SAVE_LIBS=$LIBS
4586 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4587     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4588     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4590 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4591     SYSTEM_BZ2=
4592 else
4593     AC_CHECK_LIB(bz2, BZ2_bzread, [SYSTEM_BZ2=1 BZ2_LIBS="-lbz2"],
4594         [SYSTEM_BZ2= BZ2_CFLAGS= BZ2_LIBS=], $BZ2_LIBS)
4596 CFLAGS=$_SAVE_CFLAGS
4597 LDFLAGS=$_SAVE_LDFLAGS
4598 LIBS=$_SAVE_LIBS
4600 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$SYSTEM_BZ2" = 1; then
4601     BZ2_CFLAGS="-I${BZ2_DIR}/include"
4602     BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
4605 dnl system PNG Support
4606 dnl ========================================================
4607 MOZ_ARG_WITH_STRING(system-png, 
4608 [  --with-system-png[=PFX]
4609                           Use system libpng [installed at prefix PFX]],
4610     PNG_DIR=$withval)
4612 _SAVE_CFLAGS=$CFLAGS
4613 _SAVE_LDFLAGS=$LDFLAGS
4614 _SAVE_LIBS=$LIBS
4615 CFLAGS="$ZLIB_CFLAGS $CFLAGS"
4616 LDFLAGS="$ZLIB_LIBS -lz $LDFLAGS"
4617 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4618     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4619     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4621 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4622     SYSTEM_PNG=
4623 else
4624     _SAVE_PNG_LIBS=$PNG_LIBS
4625     AC_CHECK_LIB(png, png_get_valid, [SYSTEM_PNG=1 PNG_LIBS="-lpng $PNG_LIBS"],
4626                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]), 
4627                  $PNG_LIBS)
4628     AC_CHECK_LIB(png, png_get_acTL, ,
4629                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]),
4630                  $_SAVE_PNG_LIBS)
4632 if test "$SYSTEM_PNG" = 1; then
4633     LIBS="$PNG_LIBS $LIBS"
4634     AC_TRY_COMPILE([ #include <stdio.h>
4635                      #include <sys/types.h>
4636                      #include <png.h> ],
4637                    [ #if PNG_LIBPNG_VER < $MOZPNG
4638                      #error "Insufficient libpng version ($MOZPNG required)."
4639                      #endif
4640                      #ifndef PNG_UINT_31_MAX
4641                      #error "Insufficient libpng version."
4642                      #endif ],
4643                    SYSTEM_PNG=1,
4644                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4646 CFLAGS=$_SAVE_CFLAGS
4647 LDFLAGS=$_SAVE_LDFLAGS
4648 LIBS=$_SAVE_LIBS
4650 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$SYSTEM_PNG" = 1; then
4651     PNG_CFLAGS="-I${PNG_DIR}/include"
4652     PNG_LIBS="-L${PNG_DIR}/lib ${PNG_LIBS}"
4655 fi # SKIP_LIBRARY_CHECKS
4657 dnl system HunSpell Support
4658 dnl ========================================================
4659 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4660 [  --enable-system-hunspell  Use system hunspell (located with pkgconfig)],
4661     SYSTEM_HUNSPELL=1 )
4663 if test -n "$SYSTEM_HUNSPELL"; then
4664     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4667 AC_SUBST(SYSTEM_HUNSPELL)
4669 dnl ========================================================
4670 dnl Java SDK support
4671 dnl ========================================================
4672 JAVA_INCLUDE_PATH=
4673 MOZ_ARG_WITH_STRING(java-include-path,
4674 [  --with-java-include-path=dir   Location of Java SDK headers],
4675     JAVA_INCLUDE_PATH=$withval)
4677 JAVA_BIN_PATH=
4678 MOZ_ARG_WITH_STRING(java-bin-path,
4679 [  --with-java-bin-path=dir   Location of Java binaries (java, javac, jar)],
4680     JAVA_BIN_PATH=$withval)
4682 dnl ========================================================
4683 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4684 dnl their usage and use them in spidermonkey.
4685 dnl ========================================================
4686 MOZ_ARG_WITH_BOOL(arm-kuser,
4687 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4688     USE_ARM_KUSER=1,
4689     USE_ARM_KUSER=)
4690 if test -n "$USE_ARM_KUSER"; then
4691    AC_DEFINE(USE_ARM_KUSER)
4694 dnl ========================================================
4695 dnl =
4696 dnl = Application
4697 dnl =
4698 dnl ========================================================
4700 MOZ_ARG_HEADER(Application)
4702 BUILD_STATIC_LIBS=
4703 ENABLE_TESTS=1
4704 MOZ_ACTIVEX_SCRIPTING_SUPPORT=
4705 MOZ_BRANDING_DIRECTORY=
4706 MOZ_OFFICIAL_BRANDING=
4707 MOZ_FEEDS=1
4708 MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp icon"
4709 MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
4710 MOZ_IPC=1
4711 MOZ_JAVAXPCOM=
4712 MOZ_JSDEBUGGER=1
4713 MOZ_JSLOADER=1
4714 MOZ_MATHML=1
4715 MOZ_MORK=1
4716 MOZ_MORKREADER=
4717 MOZ_AUTH_EXTENSION=1
4718 MOZ_NO_ACTIVEX_SUPPORT=1
4719 MOZ_NO_INSPECTOR_APIS=
4720 MOZ_NO_FAST_LOAD=
4721 MOZ_OGG=1
4722 MOZ_SYDNEYAUDIO=
4723 MOZ_WAVE=1
4724 MOZ_MEDIA=
4725 MOZ_PANGO=1
4726 MOZ_PERMISSIONS=1
4727 MOZ_PLACES=
4728 MOZ_PLAINTEXT_EDITOR_ONLY=
4729 MOZ_PLUGINS=1
4730 MOZ_PREF_EXTENSIONS=1
4731 MOZ_PROFILELOCKING=1
4732 MOZ_PSM=1
4733 MOZ_RDF=1
4734 MOZ_REFLOW_PERF=
4735 MOZ_SAFE_BROWSING=
4736 MOZ_FASTSTART=
4737 MOZ_HELP_VIEWER=
4738 MOZ_SPELLCHECK=1
4739 MOZ_SPLASHSCREEN=
4740 MOZ_STORAGE=1
4741 MOZ_SVG=1
4742 MOZ_TIMELINE=
4743 MOZ_TOOLKIT_SEARCH=1
4744 MOZ_UI_LOCALE=en-US
4745 MOZ_UNIVERSALCHARDET=1
4746 MOZ_URL_CLASSIFIER=
4747 MOZ_USE_NATIVE_UCONV=
4748 MOZ_VIEW_SOURCE=1
4749 MOZ_XPFE_COMPONENTS=1
4750 MOZ_XPINSTALL=1
4751 MOZ_XSLT_STANDALONE=
4752 MOZ_XTF=1
4753 MOZ_XUL=1
4754 MOZ_ZIPWRITER=1
4755 NS_PRINTING=1
4756 NECKO_WIFI=1
4757 NECKO_COOKIES=1
4758 NECKO_DISK_CACHE=1
4759 NECKO_PROTOCOLS_DEFAULT="about data file ftp gopher http res viewsource"
4760 NECKO_SMALL_BUFFERS=
4761 XPC_IDISPATCH_SUPPORT=
4764 case "$target_os" in
4765 darwin*|*wince*|*winmo*)
4766     ACCESSIBILITY=
4767     ;;
4769     ACCESSIBILITY=1
4770     ;;
4771 esac
4773 case "$target_os" in
4774     msvc*|mks*|cygwin*|mingw*)
4775         NS_ENABLE_TSF=1
4776         if test -z "$GNU_CC"; then 
4777             if test "$MOZ_WINSDK_TARGETVER" -lt "06000000"; then
4778                 NS_ENABLE_TSF=
4779             fi
4780             XPC_IDISPATCH_SUPPORT=1
4781             MOZ_NO_ACTIVEX_SUPPORT=
4782         fi
4783         if test -n "$NS_ENABLE_TSF"; then
4784             AC_DEFINE(NS_ENABLE_TSF)
4785         fi
4786         ;;
4787 esac
4789 MOZ_ARG_ENABLE_STRING(application,
4790 [  --enable-application=APP
4791                           Options include:
4792                             browser (Firefox)
4793                             xulrunner
4794                             content/xslt (Standalone Transformiix XSLT)
4795                             netwerk (Standalone Necko)
4796                             tools/update-packaging (AUS-related packaging tools)
4797                             standalone (use this for standalone
4798                               xpcom/xpconnect or to manually drive a build)],
4799 [ MOZ_BUILD_APP=$enableval ] )
4801 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4802 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4803   XULRUNNER_STUB_NAME=$withval)
4805 if test -z "$XULRUNNER_STUB_NAME"; then
4806   case "$target_os" in
4807   darwin*)
4808     XULRUNNER_STUB_NAME=xulrunner
4809     ;;
4810   *)
4811     XULRUNNER_STUB_NAME=xulrunner-stub
4812   esac
4814 AC_SUBST(XULRUNNER_STUB_NAME)
4816 if test -z "$MOZ_BUILD_APP"; then
4817   AC_MSG_ERROR([--enable-application=APP was not specified and is required.])
4818 else
4819   # We have a valid application only if it has a build.mk file in its top
4820   # directory.
4821   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4822     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4823   fi
4826 # Allow the application to influence configure with a confvars.sh script.
4828 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4829 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4830   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4831   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4832 else
4833   AC_MSG_RESULT([no])
4836 # Now is a good time to test for logic errors, define mismatches, etc.
4837 case "$MOZ_BUILD_APP" in
4838 xulrunner)
4839   if test "$LIBXUL_SDK"; then
4840     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4841   fi
4842   ;;
4843 esac
4845 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4846 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4847 # MOZ_BUILD_APP.
4848 case "$MOZ_BUILD_APP" in
4849 browser)
4850   AC_DEFINE(MOZ_PHOENIX)
4851   ;;
4853 xulrunner)
4854   AC_DEFINE(MOZ_XULRUNNER)
4855   ;;
4857 content/xslt)
4858   AC_DEFINE(TX_EXE)
4859   ;;
4861 standalone) 
4862   MOZ_APP_NAME=mozilla
4863   MOZ_APP_DISPLAYNAME=Mozilla
4864   MOZ_APP_VERSION=$MOZILLA_VERSION
4865   ;;
4867 esac
4869 AC_SUBST(MOZ_BUILD_APP)
4870 AC_SUBST(MOZ_PHOENIX)
4871 AC_SUBST(MOZ_XULRUNNER)
4873 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4875 dnl ========================================================
4876 dnl = 
4877 dnl = Toolkit Options
4878 dnl = 
4879 dnl ========================================================
4880 MOZ_ARG_HEADER(Toolkit Options)
4882     dnl ========================================================
4883     dnl = Select the default toolkit
4884     dnl ========================================================
4885         MOZ_ARG_ENABLE_STRING(default-toolkit,
4886         [  --enable-default-toolkit=TK
4887                           Select default toolkit
4888                           Platform specific defaults:
4889                             BeOS - cairo-beos
4890                             Mac OS X - cairo-cocoa
4891                             Neutrino/QNX - photon
4892                             OS/2 - cairo-os2
4893                             Win32/WinCE - cairo-windows
4894                             Gtk2 with DirectFB - cairo-gtk2-dfb
4895                             * - cairo-gtk2
4896                             * - cairo-qt],
4897     [ _DEFAULT_TOOLKIT=$enableval ],
4898     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4900     if test "$_DEFAULT_TOOLKIT" = "photon" \
4901         -o "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4902         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4903         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-dfb" \
4904         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4905         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4906         -o "$_DEFAULT_TOOLKIT" = "cairo-beos" \
4907         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4908         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa"
4909     then
4910         dnl nglayout only supports building with one toolkit,
4911         dnl so ignore everything after the first comma (",").
4912         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4913     else
4914         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4915     fi
4917 AC_DEFINE_UNQUOTED(MOZ_DEFAULT_TOOLKIT,"$MOZ_WIDGET_TOOLKIT")
4919 dnl ========================================================
4920 dnl = Enable the toolkit as needed                         =
4921 dnl ========================================================
4923 case "$MOZ_WIDGET_TOOLKIT" in
4924 photon)
4925         MOZ_ENABLE_PHOTON=1
4926         AC_DEFINE(MOZ_WIDGET_PHOTON)
4927     ;;
4929 cairo-windows)
4930     MOZ_WIDGET_TOOLKIT=windows
4931     MOZ_WEBGL=1
4932     case "${target}" in
4933     *-wince*)
4934         NS_PRINTING=
4935         ;;
4936     esac
4937     ;;
4939 cairo-gtk2|cairo-gtk2-x11)
4940     MOZ_WIDGET_TOOLKIT=gtk2
4941     MOZ_ENABLE_GTK2=1
4942     MOZ_ENABLE_XREMOTE=1
4943     MOZ_WEBGL=1
4944     MOZ_WEBGL_GLX=1
4946     AC_DEFINE(MOZ_X11)
4947     MOZ_X11=1
4948     USE_FC_FREETYPE=1
4950     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4951     TK_LIBS='$(MOZ_GTK2_LIBS)'
4952     AC_DEFINE(MOZ_WIDGET_GTK2)
4953     ;;
4955 cairo-gtk2-dfb)
4956     MOZ_WIDGET_TOOLKIT=gtk2
4957     MOZ_ENABLE_GTK2=1
4958     MOZ_WEBGL=
4960     AC_DEFINE(MOZ_DFB)
4961     MOZ_DFB=1
4963     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4964     TK_LIBS='$(MOZ_GTK2_LIBS)'
4965     AC_DEFINE(MOZ_WIDGET_GTK2)
4966     if test "$no_x" != "yes"; then
4967         AC_MSG_WARN([Disabling X when DirectFB is specified.])
4968         no_x=yes
4969     fi
4970     ;;
4972 cairo-qt)
4973     MOZ_WIDGET_TOOLKIT=qt
4974     MOZ_ENABLE_QT=1
4975     MOZ_ENABLE_XREMOTE=1
4976     USE_ELF_DYNSTR_GC=
4977     NS_PRINTING=
4979     AC_DEFINE(MOZ_X11)
4980     MOZ_X11=1
4981     USE_FC_FREETYPE=1
4983     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4984     TK_LIBS='$(MOZ_QT_LIBS)'
4985     AC_DEFINE(MOZ_WIDGET_QT)
4986     ;;
4988 cairo-beos)
4989     MOZ_WIDGET_TOOLKIT=beos
4990     USE_FC_FREETYPE=1
4991     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4992     TK_LIBS='$(MOZ_CAIRO_LIBS)'
4993     ;;
4995 cairo-os2)
4996     MOZ_WIDGET_TOOLKIT=os2
4997     USE_FC_FREETYPE=1
4998     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
4999     TK_LIBS='$(MOZ_CAIRO_LIBS)'
5000     ;;
5002 cairo-cocoa)
5003     MOZ_WIDGET_TOOLKIT=cocoa
5004     AC_DEFINE(MOZ_WIDGET_COCOA)
5005     MOZ_USER_DIR="Mozilla"
5006     AC_DEFINE(XP_MACOSX)
5007     TK_LIBS='-framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook'
5008     TK_CFLAGS="-DNO_X11"
5009     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
5010     CFLAGS="$CFLAGS $TK_CFLAGS"
5011     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
5012     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
5013     MOZ_FS_LAYOUT=bundle
5014     MOZ_WEBGL=1
5015     ;;
5016 esac
5018 if test "$MOZ_ENABLE_XREMOTE"; then
5019     AC_DEFINE(MOZ_ENABLE_XREMOTE)
5022 if test "$COMPILE_ENVIRONMENT"; then
5023   if test "$MOZ_ENABLE_GTK2"; then
5024     if test "$MOZ_X11"; then
5025       GDK_PACKAGES=gdk-x11-2.0
5026     elif test "$MOZ_DFB"; then
5027       PKG_CHECK_MODULES(MOZ_DFB, directfb >= 1.1.0)
5028       GDK_PACKAGES=directfb
5029     fi
5031     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
5032   fi
5034 fi # COMPILE_ENVIRONMENT
5036 AC_SUBST(MOZ_DEFAULT_TOOLKIT)
5037 AC_SUBST(MOZ_FS_LAYOUT)
5039 dnl ========================================================
5040 dnl = startup-notification support module
5041 dnl ========================================================
5043 if test "$MOZ_ENABLE_GTK2"
5044 then
5045     MOZ_ENABLE_STARTUP_NOTIFICATION=
5047     MOZ_ARG_ENABLE_BOOL(startup-notification,
5048     [  --enable-startup-notification       Enable startup-notification support (default: disabled) ],
5049         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
5050         MOZ_ENABLE_STARTUP_NOTIFICATION=)
5051     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
5052     then
5053         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
5054                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
5055         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
5056             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
5057             then
5058                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
5059             fi
5060             MOZ_ENABLE_STARTUP_NOTIFICATION=
5061         ])
5062     fi
5064     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
5065         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
5066     fi
5068     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
5070 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
5071 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
5072 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
5074 dnl ========================================================
5075 dnl = QT support
5076 dnl ========================================================
5077 if test "$MOZ_ENABLE_QT"
5078 then
5079     MOZ_ARG_WITH_STRING(qtdir,
5080     [  --with-qtdir=\$dir       Specify Qt directory ],
5081     [ QTDIR=$withval])
5083     if test -z "$QTDIR"; then
5084         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore)
5085         AC_CHECK_PROGS(HOST_MOC, moc, "")
5086     else
5087         MOZ_QT_LIBS="-L$QTDIR/qt/lib/ -lQtGui -lQtNetwork -lQtCore"
5089         MOZ_QT_CFLAGS="-DQT_SHARED"
5090         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/qt/include"
5091         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/qt/include/Qt"
5092         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/qt/include/QtGui"
5093         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/qt/include/QtCore"
5094         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/qt/include/QtNetwork"
5096         HOST_MOC="$QTDIR/qt/bin/moc"
5097     fi
5098     if test -z "$HOST_MOC"; then
5099         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
5100 incorrect])
5101     fi
5102     MOC=$HOST_MOC
5105 AC_SUBST(GTK_CONFIG)
5106 AC_SUBST(TK_CFLAGS)
5107 AC_SUBST(TK_LIBS)
5109 AC_SUBST(MOZ_ENABLE_GTK2)
5110 AC_SUBST(MOZ_ENABLE_PHOTON)
5111 AC_SUBST(MOZ_ENABLE_QT)
5112 AC_SUBST(MOZ_ENABLE_XREMOTE)
5113 AC_SUBST(MOZ_GTK2_CFLAGS)
5114 AC_SUBST(MOZ_GTK2_LIBS)
5115 AC_SUBST(MOZ_QT_CFLAGS)
5116 AC_SUBST(MOZ_QT_LIBS)
5118 AC_SUBST(MOC)
5120 AC_SUBST(MOZ_DFB)
5121 AC_SUBST(MOZ_X11)
5123 dnl ========================================================
5124 dnl =
5125 dnl = Components & Features
5126 dnl = 
5127 dnl ========================================================
5128 MOZ_ARG_HEADER(Components and Features)
5130 dnl ========================================================
5131 dnl = Localization
5132 dnl ========================================================
5133 MOZ_ARG_ENABLE_STRING(ui-locale,
5134 [  --enable-ui-locale=ab-CD
5135                           Select the user interface locale (default: en-US)],
5136     MOZ_UI_LOCALE=$enableval )
5137 AC_SUBST(MOZ_UI_LOCALE)
5139 dnl ========================================================
5140 dnl = Trademarked Branding 
5141 dnl ========================================================
5142 MOZ_ARG_ENABLE_BOOL(official-branding,
5143 [  --enable-official-branding Enable Official mozilla.org Branding
5144                           Do not distribute builds with
5145                           --enable-official-branding unless you have
5146                           permission to use trademarks per
5147                           http://www.mozilla.org/foundation/trademarks/ .],
5149   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
5150     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
5151   else
5152     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
5153     MOZ_OFFICIAL_BRANDING=1
5154   fi
5155 ], MOZ_OFFICIAL_BRANDING=)
5157 AC_SUBST(MOZ_OFFICIAL_BRANDING)
5158 if test -n "$MOZ_OFFICIAL_BRANDING"; then
5159   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
5162 MOZ_ARG_WITH_STRING(branding,
5163 [  --with-branding=dir    Use branding from the specified directory.],
5164     MOZ_BRANDING_DIRECTORY=$withval)
5166 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
5167 if test -z "$REAL_BRANDING_DIRECTORY"; then
5168   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
5171 if test -f "$topsrcdir/$REAL_BRANDING_DIRECTORY/configure.sh"; then
5172   . "$topsrcdir/$REAL_BRANDING_DIRECTORY/configure.sh"
5175 AC_SUBST(MOZ_BRANDING_DIRECTORY)
5177 dnl ========================================================
5178 dnl = Distribution ID
5179 dnl ========================================================
5180 MOZ_ARG_WITH_STRING(distribution-id,
5181 [  --with-distribution-id=ID  Set distribution-specific id (default=org.mozilla)],
5182 [ val=`echo $withval`
5183     MOZ_DISTRIBUTION_ID="$val"])
5185 if test -z "$MOZ_DISTRIBUTION_ID"; then
5186    MOZ_DISTRIBUTION_ID="org.mozilla"
5189 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
5190 AC_SUBST(MOZ_DISTRIBUTION_ID)
5193 dnl ========================================================
5194 dnl complex text support off by default
5195 dnl ========================================================
5196 MOZ_ARG_DISABLE_BOOL(pango,
5197 [  --disable-pango Disable usage of Pango ],
5198     MOZ_PANGO=,
5199     MOZ_PANGO=1)
5201 dnl ========================================================
5202 dnl = Pango
5203 dnl ========================================================
5204 if test "$MOZ_ENABLE_GTK2"
5205 then
5206     AC_SUBST(MOZ_PANGO)
5208     PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
5210     PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION)
5211     AC_SUBST(MOZ_PANGO_CFLAGS)
5212     AC_SUBST(MOZ_PANGO_LIBS)
5213     if test "$MOZ_PANGO"
5214     then
5215         AC_DEFINE(MOZ_PANGO)
5216     else
5217         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0 fontconfig)
5218         AC_SUBST(FT2_CFLAGS)
5219         AC_SUBST(FT2_LIBS)
5220     fi
5223 if test "$MOZ_ENABLE_QT"
5224 then
5225     if test "$MOZ_PANGO"
5226     then
5227         PKG_CHECK_MODULES(MOZ_PANGO, [pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION],
5228         [
5229             AC_SUBST(MOZ_PANGO_CFLAGS)
5230             AC_SUBST(MOZ_PANGO_LIBS)
5231             AC_DEFINE(MOZ_PANGO)
5232         ],
5233         [
5234             echo "Pango library not found, will use FT2 font engine"
5235             MOZ_PANGO=
5236         ])
5237     fi
5238     AC_SUBST(MOZ_PANGO)
5241 dnl ========================================================
5242 dnl = GnomeVFS, GIO and GConf support module
5243 dnl ========================================================
5245 if test "$MOZ_X11"
5246 then
5247     dnl build the gnomevfs extension by default only when the
5248     dnl GTK2 toolkit is in use.
5249     if test "$MOZ_ENABLE_GTK2"
5250     then
5251         MOZ_ENABLE_GNOMEVFS=1
5252         MOZ_ENABLE_GCONF=1
5253     fi
5255     dnl ========================================================
5256     dnl = GnomeVFS support module
5257     dnl ========================================================
5258     MOZ_ARG_DISABLE_BOOL(gnomevfs,
5259     [  --disable-gnomevfs      Disable GnomeVFS support ],
5260         MOZ_ENABLE_GNOMEVFS=,
5261         MOZ_ENABLE_GNOMEVFS=force)
5263     if test "$MOZ_ENABLE_GNOMEVFS"
5264     then
5265         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
5266             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
5267             MOZ_ENABLE_GNOMEVFS=1
5268             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
5269         ],[
5270             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
5271             then
5272                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
5273             fi
5274             MOZ_ENABLE_GNOMEVFS=
5275         ])
5276     else
5277         if test `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
5278             PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
5279               MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
5280             ])
5281         fi
5282     fi
5284     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
5285     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
5286     AC_SUBST(MOZ_GNOMEVFS_LIBS)
5288     dnl ========================================================
5289     dnl = GIO support module
5290     dnl ========================================================
5291     MOZ_ARG_ENABLE_BOOL(gio,
5292     [  --enable-gio            Enable GIO support (default: disabled)],
5293         MOZ_ENABLE_GIO=force,
5294         MOZ_ENABLE_GIO=)
5296     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK2"
5297     then
5298         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
5299             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
5300             MOZ_ENABLE_GIO=1
5301             AC_DEFINE(MOZ_ENABLE_GIO)
5302         ],[
5303             if test "$MOZ_ENABLE_GIO" = "force"
5304             then
5305                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
5306             fi
5307             MOZ_ENABLE_GIO=
5308         ])
5309     fi
5311     AC_SUBST(MOZ_ENABLE_GIO)
5312     AC_SUBST(MOZ_GIO_CFLAGS)
5313     AC_SUBST(MOZ_GIO_LIBS)
5314    
5315     dnl ========================================================
5316     dnl = GConf support module
5317     dnl ========================================================
5318     if test "$MOZ_ENABLE_GCONF"
5319     then
5320         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
5321             MOZ_GCONF_LIBS=`echo $MOZ_GCONF_LIBS | sed 's/-llinc\>//'`
5322             MOZ_ENABLE_GCONF=1
5323         ],[
5324             if test "$MOZ_ENABLE_GCONF" = "force"
5325             then
5326                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
5327             fi
5328             MOZ_ENABLE_GCONF=
5329         ])
5330     fi
5332     if test "$MOZ_ENABLE_GCONF"; then
5333         AC_DEFINE(MOZ_ENABLE_GCONF)
5334     fi
5336     AC_SUBST(MOZ_ENABLE_GCONF)
5337     AC_SUBST(MOZ_GCONF_CFLAGS)
5338     AC_SUBST(MOZ_GCONF_LIBS)
5341 dnl ========================================================
5342 dnl = libnotify support
5343 dnl ========================================================
5345 if test "$MOZ_ENABLE_GTK2"
5346 then
5347     MOZ_ENABLE_LIBNOTIFY=1
5349     MOZ_ARG_DISABLE_BOOL(libnotify,
5350     [  --disable-libnotify       Disable libnotify support ],
5351     MOZ_ENABLE_LIBNOTIFY=,
5352     MOZ_ENABLE_LIBNOTIFY=1)
5354     if test "$MOZ_ENABLE_LIBNOTIFY"
5355     then
5356         AC_DEFINE(MOZ_ENABLE_LIBNOTIFY)
5357     fi
5360 if test -z "$SKIP_LIBRARY_CHECKS"
5361 then
5362     if test "$MOZ_ENABLE_GTK2"
5363     then
5364         if test "$MOZ_ENABLE_LIBNOTIFY"
5365         then
5366             PKG_CHECK_MODULES(MOZ_LIBNOTIFY, libnotify >= $LIBNOTIFY_VERSION)
5367         fi
5368     fi
5370 AC_SUBST(MOZ_ENABLE_LIBNOTIFY)
5371 AC_SUBST(MOZ_LIBNOTIFY_CFLAGS)
5372 AC_SUBST(MOZ_LIBNOTIFY_LIBS)
5374 dnl ========================================================
5375 dnl = GNOME component (mozgnome)
5376 dnl ========================================================
5378 # The GNOME component is built if one of 
5379 # gnome-vfs, gio, gconf or libnotify is available.
5380 if test "$MOZ_ENABLE_GCONF" || \
5381    test "$MOZ_ENABLE_GNOMEVFS" || \
5382    test "$MOZ_ENABLE_GIO" || \
5383    test "$MOZ_ENABLE_LIBNOTIFY"; then
5384     MOZ_ENABLE_GNOME_COMPONENT=1
5385 else
5386     MOZ_ENABLE_GNOME_COMPONENT=
5388 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
5390 dnl ========================================================
5391 dnl = libgnomeui support module
5392 dnl ========================================================
5394 if test "$MOZ_ENABLE_GTK2"
5395 then
5396     MOZ_ENABLE_GNOMEUI=1
5398     MOZ_ARG_DISABLE_BOOL(gnomeui,
5399     [  --disable-gnomeui       Disable libgnomeui support (default: auto, optional at runtime) ],
5400         MOZ_ENABLE_GNOMEUI=,
5401         MOZ_ENABLE_GNOMEUI=force)
5403     if test "$MOZ_ENABLE_GNOMEUI"
5404     then
5405         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
5406         [
5407             MOZ_GNOMEUI_LIBS=`echo $MOZ_GNOMEUI_LIBS | sed 's/-llinc\>//'`
5408             MOZ_ENABLE_GNOMEUI=1
5409         ],[
5410             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5411             then
5412                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5413             fi
5414             MOZ_ENABLE_GNOMEUI=
5415         ])
5416     fi
5418     if test "$MOZ_ENABLE_GNOMEUI"; then
5419         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5420     fi
5423 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5424 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5425 AC_SUBST(MOZ_GNOMEUI_LIBS)
5427 dnl ========================================================
5428 dnl = dbus support
5429 dnl ========================================================
5431 if test "$MOZ_ENABLE_GTK2" || test "$MOZ_ENABLE_QT"
5432 then
5433     MOZ_ENABLE_DBUS=1
5435     MOZ_ARG_DISABLE_BOOL(dbus,
5436     [  --disable-dbus       Disable dbus support ],
5437         MOZ_ENABLE_DBUS=,
5438         MOZ_ENABLE_DBUS=1)
5440     if test "$MOZ_ENABLE_DBUS"
5441     then
5442         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5443         AC_DEFINE(MOZ_ENABLE_DBUS)
5444     fi
5446 AC_SUBST(MOZ_ENABLE_DBUS)
5447 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5448 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5450 dnl ========================================================
5451 dnl = Build Personal Security Manager
5452 dnl ========================================================
5453 MOZ_ARG_DISABLE_BOOL(crypto,
5454 [  --disable-crypto        Disable crypto support (Personal Security Manager)],
5455     MOZ_PSM=,
5456     MOZ_PSM=1 )
5458 dnl ========================================================
5459 dnl = JS Debugger XPCOM component (js/jsd)
5460 dnl ========================================================
5461 MOZ_ARG_DISABLE_BOOL(jsd,
5462 [  --disable-jsd           Disable JavaScript debug library],
5463     MOZ_JSDEBUGGER=,
5464     MOZ_JSDEBUGGER=1)
5467 dnl ========================================================
5468 dnl = Disable IPC support for tabs and plugins
5469 dnl ========================================================
5470 case "${target}" in
5471 *-apple-darwin*)
5472     MOZ_IPC=
5473     ;;
5474 *-wince*)
5475     MOZ_IPC=
5476     ;;
5477 esac
5479 MOZ_ARG_DISABLE_BOOL(ipc,
5480 [  --disable-ipc           Disable IPC supports for tabs and plugins],
5481     MOZ_IPC=,
5482     MOZ_IPC=1)
5484 if test -n "$MOZ_IPC"; then
5485     AC_DEFINE(MOZ_IPC)
5488 AC_SUBST(MOZ_IPC)
5490 dnl ========================================================
5491 dnl = Enable IPDL's "expensive" unit tests
5492 dnl ========================================================
5493 MOZ_IPDL_TESTS=
5495 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5496 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5497     MOZ_IPDL_TESTS=1,
5498     MOZ_IPDL_TESTS=)
5500 if test -z "$MOZ_IPC" -a -n "$MOZ_IPDL_TESTS"; then
5501     AC_MSG_ERROR([--enable-ipdl-tests requires --enable-ipc])
5504 if test -n "$MOZ_IPDL_TESTS"; then
5505     AC_DEFINE(MOZ_IPDL_TESTS)
5508 AC_SUBST(MOZ_IPDL_TESTS)
5510 dnl ========================================================
5511 dnl = Disable plugin support
5512 dnl ========================================================
5513 MOZ_ARG_DISABLE_BOOL(plugins,
5514 [  --disable-plugins       Disable plugins support],
5515     MOZ_PLUGINS=,
5516     MOZ_PLUGINS=1)
5518 dnl ========================================================
5519 dnl = Disable building dbm
5520 dnl ========================================================
5521 MOZ_ARG_DISABLE_BOOL(dbm,
5522 [  --disable-dbm       Disable building dbm],
5523     NSS_DISABLE_DBM=1,
5524     NSS_DISABLE_DBM=)
5526 dnl bi-directional support always on
5527 IBMBIDI=1
5528 AC_DEFINE(IBMBIDI)
5530 dnl ========================================================
5531 dnl view source support on by default
5532 dnl ========================================================
5533 if test "$MOZ_VIEW_SOURCE"; then
5534     AC_DEFINE(MOZ_VIEW_SOURCE)
5537 dnl ========================================================
5538 dnl accessibility support on by default on all platforms 
5539 dnl except OS X.
5540 dnl ========================================================
5541 MOZ_ARG_DISABLE_BOOL(accessibility,
5542 [  --disable-accessibility Disable accessibility support (off by default on OS X)],
5543     ACCESSIBILITY=,
5544     ACCESSIBILITY=1 )
5545 if test "$ACCESSIBILITY"; then
5546     AC_DEFINE(ACCESSIBILITY)
5549 if test -n "$ACCESSIBILITY" -a "$COMPILE_ENVIRONMENT" = "1"; then
5550 case "$target" in
5551 *-mingw*|*-cygwin*|*-msvc*|*-mks*)
5552     if test "$ac_cv_header_atlbase_h" = "no"; then
5553         AC_MSG_ERROR([System header atlbase.h is not available. See http://developer.mozilla.org/en/docs/atlbase.h for details on fixing this problem.])
5554     fi
5555     if test "$ac_cv_header_oleacc_idl" = "no"; then
5556         AC_MSG_ERROR([System header oleacc.idl is not available. See http://developer.mozilla.org/en/docs/oleacc.idl for details on fixing this problem.])
5557     fi
5558     ;;
5559 esac
5562 dnl ========================================================
5563 dnl xpfe/components on by default
5564 dnl ========================================================
5565 MOZ_ARG_DISABLE_BOOL(xpfe-components,
5566 [  --disable-xpfe-components
5567                           Disable xpfe components],
5568     MOZ_XPFE_COMPONENTS=,
5569     MOZ_XPFE_COMPONENTS=1 )
5571 dnl ========================================================
5572 dnl xpinstall support on by default
5573 dnl ========================================================
5574 MOZ_ARG_DISABLE_BOOL(xpinstall,
5575 [  --disable-xpinstall     Disable xpinstall support],
5576     MOZ_XPINSTALL=,
5577     MOZ_XPINSTALL=1 )
5578 if test "$MOZ_XPINSTALL"; then
5579     AC_DEFINE(MOZ_XPINSTALL)
5582 dnl ========================================================
5583 dnl xpcom js loader support on by default
5584 dnl ========================================================
5585 if test "$MOZ_JSLOADER"; then
5586     AC_DEFINE(MOZ_JSLOADER)
5589 dnl ========================================================
5590 dnl Disable printing
5591 dnl ========================================================
5592 MOZ_ARG_DISABLE_BOOL(printing,
5593 [  --disable-printing  Disable printing support],
5594     NS_PRINTING=,
5595     NS_PRINTING=1 )
5597 if test "$MOZ_WIDGET_TOOLKIT" = "qt"; then
5598     AC_MSG_WARN([Printing does not work with Qt at this time. Omitting printing support.])
5599     NS_PRINTING=
5602 if test "$NS_PRINTING"; then
5603     AC_DEFINE(NS_PRINTING)
5604     AC_DEFINE(NS_PRINT_PREVIEW)
5607 dnl ========================================================
5608 dnl use native unicode converters
5609 dnl ========================================================
5610 MOZ_ARG_ENABLE_BOOL(native-uconv,
5611 [  --enable-native-uconv   Enable iconv support],
5612     MOZ_USE_NATIVE_UCONV=1,
5613     MOZ_USE_NATIVE_UCONV= )
5614 if test "$MOZ_USE_NATIVE_UCONV"; then
5615     AC_DEFINE(MOZ_USE_NATIVE_UCONV)
5617 if test "$OS_ARCH" != "WINCE" -a "$OS_ARCH" != "WINNT" -a "$MOZ_USE_NATIVE_UCONV" -a "$ac_cv_func_iconv" != "yes"; then
5618     AC_MSG_ERROR([iconv() not found.  Cannot enable native uconv support.])
5622 dnl ========================================================
5623 dnl Libeditor can be build as plaintext-only,
5624 dnl or as a full html and text editing component.
5625 dnl We build both by default.
5626 dnl ========================================================
5627 MOZ_ARG_ENABLE_BOOL(plaintext-editor-only,
5628 [  --enable-plaintext-editor-only
5629                           Allow only plaintext editing],
5630     MOZ_PLAINTEXT_EDITOR_ONLY=1,
5631     MOZ_PLAINTEXT_EDITOR_ONLY= )
5632 dnl Note the #define is MOZILLA, not MOZ, for compat with the Mac build.
5633 AC_SUBST(MOZ_PLAINTEXT_EDITOR_ONLY)
5635 dnl ========================================================
5636 dnl = Disable Fast Load
5637 dnl ========================================================
5638 MOZ_ARG_DISABLE_BOOL(xpcom-fastload,
5639 [  --disable-xpcom-fastload           Disable XPCOM fastload support],
5640     MOZ_NO_FAST_LOAD=1,
5641     MOZ_NO_FAST_LOAD=)
5643 AC_SUBST(MOZ_NO_FAST_LOAD)
5645 if test -n "$MOZ_NO_FAST_LOAD"; then
5646     AC_DEFINE(MOZ_NO_FAST_LOAD)
5649 dnl ========================================================
5650 dnl = Disable Ogg Codecs
5651 dnl ========================================================
5652 MOZ_ARG_DISABLE_BOOL(ogg,
5653 [  --disable-ogg           Disable Ogg Codec support],
5654     MOZ_OGG=,
5655     MOZ_OGG=1)
5657 AC_SUBST(MOZ_OGG)
5659 if test -n "$MOZ_OGG"; then
5660     AC_DEFINE(MOZ_OGG)
5661     MOZ_SYDNEYAUDIO=1
5662     MOZ_MEDIA=1
5664     dnl Checks for __attribute__(aligned()) directive
5665     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5666         [ac_cv_c_attribute_aligned],
5667         [ac_cv_c_attribute_aligned=0
5668          CFLAGS_save="${CFLAGS}"
5669          CFLAGS="${CFLAGS} -Werror"
5670          for ac_cv_c_attr_align_try in 64 32 16 8; do
5671            echo "trying $ac_cv_c_attr_align_try"
5672            AC_TRY_COMPILE([],
5673                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5674                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5675            if test "$ac_cv_c_attribute_aligned" != 0; then
5676              break;
5677            fi
5678          done
5679            CFLAGS="${CFLAGS_save}"])
5680     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5681       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5682                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5683     fi
5686 dnl ========================================================
5687 dnl = Disable Wave decoder support
5688 dnl ========================================================
5689 MOZ_ARG_DISABLE_BOOL(wave,
5690 [  --disable-wave          Disable Wave decoder support],
5691     MOZ_WAVE=,
5692     MOZ_WAVE=1)
5694 AC_SUBST(MOZ_WAVE)
5696 if test -n "$MOZ_WAVE"; then
5697     AC_DEFINE(MOZ_WAVE)
5698     MOZ_SYDNEYAUDIO=1
5699     MOZ_MEDIA=1
5702 dnl ========================================================
5703 dnl = Handle dependent SYDNEYAUDIO and MEDIA defines
5704 dnl ========================================================
5706 AC_SUBST(MOZ_SYDNEYAUDIO)
5708 if test -n "$MOZ_SYDNEYAUDIO"; then
5709     AC_DEFINE(MOZ_SYDNEYAUDIO)
5712 AC_SUBST(MOZ_MEDIA)
5714 if test -n "$MOZ_MEDIA"; then
5715     AC_DEFINE(MOZ_MEDIA)
5718 dnl ========================================================
5719 dnl = Check alsa availability on Linux if using sydneyaudio
5720 dnl ========================================================
5722 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5723 if test -n "$MOZ_SYDNEYAUDIO"; then
5724    case "$target_os" in
5725 linux*)
5726       PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5727          [echo "$MOZ_ALSA_PKG_ERRORS"
5728           AC_MSG_ERROR([Need alsa for Ogg or Wave decoding on Linux.  Disable with --disable-ogg --disable-wave.])])
5729       ;;
5730    esac
5732 AC_SUBST(MOZ_ALSA_LIBS)
5734 dnl ========================================================
5735 dnl Splashscreen
5736 dnl ========================================================
5737 AC_ARG_ENABLE(splashscreen,
5738               [  --enable-splashscreen   display splashscreen while loading (default=no)],
5739               [enable_splash="yes"],[enable_splash=""])
5740 if test "x$enable_splash" = "xyes"; then
5741   MOZ_SPLASHSCREEN=1
5742   AC_DEFINE(MOZ_SPLASHSCREEN)
5744 AC_SUBST(MOZ_SPLASHSCREEN)
5746 dnl ========================================================
5747 dnl Permissions System
5748 dnl ========================================================
5749 MOZ_ARG_DISABLE_BOOL(permissions,
5750 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5751     MOZ_PERMISSIONS=,
5752     MOZ_PERMISSIONS=1
5755 dnl ========================================================
5756 dnl NegotiateAuth
5757 dnl ========================================================
5758 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5759 [  --disable-negotiateauth Disable GSS-API negotiation ],
5760     MOZ_AUTH_EXTENSION=,
5761     MOZ_AUTH_EXTENSION=1 )
5763 dnl ========================================================
5764 dnl XTF
5765 dnl ========================================================
5766 MOZ_ARG_DISABLE_BOOL(xtf,
5767 [  --disable-xtf           Disable XTF (pluggable xml tags) support],
5768     MOZ_XTF=,
5769     MOZ_XTF=1 )
5770 if test "$MOZ_XTF"; then
5771   AC_DEFINE(MOZ_XTF)
5774 dnl ========================================================
5775 dnl Pref extensions (autoconfig and system-pref)
5776 dnl ========================================================
5777 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5778 [  --disable-pref-extensions
5779                           Disable pref extensions such as autoconfig and
5780                           system-pref],
5781   MOZ_PREF_EXTENSIONS=,
5782   MOZ_PREF_EXTENSIONS=1 )
5784 dnl ========================================================
5785 dnl = Universalchardet
5786 dnl ========================================================
5787 MOZ_ARG_DISABLE_BOOL(universalchardet,
5788 [  --disable-universalchardet
5789                           Disable universal encoding detection],
5790   MOZ_UNIVERSALCHARDET=,
5791   MOZ_UNIVERSALCHARDET=1 )
5793 dnl ========================================================
5794 dnl JavaXPCOM
5795 dnl ========================================================
5796 case "${target}" in
5797 *-wince*)
5798     MOZ_JAVAXPCOM=
5799     ;;
5800 esac
5802 MOZ_ARG_ENABLE_BOOL(javaxpcom,
5803 [  --enable-javaxpcom
5804                           Enable Java-XPCOM bridge],
5805     MOZ_JAVAXPCOM=1,
5806     MOZ_JAVAXPCOM= )
5808 if test -n "${MOZ_JAVAXPCOM}"; then
5809   case "$host_os" in
5810     cygwin*|msvc*|mks*)
5811       if test -n "$JAVA_HOME"; then
5812         JAVA_HOME=`cygpath -u \`cygpath -m -s "$JAVA_HOME"\``
5813       fi
5814       ;;
5815     *mingw*)
5816       if test -n "$JAVA_HOME"; then
5817         JAVA_HOME=`cd "$JAVA_HOME" && pwd`
5818       fi
5819       ;;
5820   esac
5822   if test -n "${JAVA_INCLUDE_PATH}"; then
5823     dnl Make sure jni.h exists in the given include path.
5824     if test ! -f "$JAVA_INCLUDE_PATH/jni.h"; then
5825       AC_MSG_ERROR([jni.h was not found in given include path $JAVA_INCLUDE_PATH.])
5826     fi
5827   else
5828     case "$target_os" in
5829       darwin*)
5830         dnl Default to java system location
5831         JAVA_INCLUDE_PATH=/System/Library/Frameworks/JavaVM.framework/Headers
5832         ;;
5833       *)
5834         dnl Try $JAVA_HOME
5835         JAVA_INCLUDE_PATH="$JAVA_HOME/include"
5836         ;;
5837     esac
5838     if test ! -f "$JAVA_INCLUDE_PATH/jni.h"; then
5839       AC_MSG_ERROR([The header jni.h was not found.  Set \$JAVA_HOME to your java sdk directory, use --with-java-bin-path={java-bin-dir}, or reconfigure with --disable-javaxpcom.])
5840     fi
5841   fi
5843   if test -n "${JAVA_BIN_PATH}"; then
5844     dnl Look for javac and jar in the specified path.
5845     JAVA_PATH="$JAVA_BIN_PATH"
5846   else
5847     dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5848     JAVA_PATH="$JAVA_HOME/bin:$PATH"
5849   fi
5851   MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5852   MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5853   MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5854   if test -z "$JAVA" || test "$JAVA" = ":" || test -z "$JAVAC" || test "$JAVAC" = ":" || test -z "$JAR" || test "$JAR" = ":"; then
5855     AC_MSG_ERROR([The programs java, javac and jar were not found.  Set \$JAVA_HOME to your java sdk directory, use --with-java-bin-path={java-bin-dir}, or reconfigure with --disable-javaxpcom.])
5856   fi
5859 dnl ========================================================
5860 dnl = Breakpad crash reporting (on by default on supported platforms)
5861 dnl ========================================================
5863 if (test "$OS_ARCH" = "WINNT" -a -z "$GNU_CC" \
5864     || test "$OS_ARCH" = "Darwin" \
5865     || test "$OS_ARCH" = "Linux" -a "$CPU_ARCH" = "x86" \
5866     || test "$OS_ARCH" = "SunOS") \
5867    && test -z "$HAVE_64BIT_OS"; then
5868    MOZ_CRASHREPORTER=1
5871 MOZ_ARG_DISABLE_BOOL(crashreporter,
5872 [  --disable-crashreporter          Disable breakpad crash reporting],
5873     MOZ_CRASHREPORTER=,
5874     MOZ_CRASHREPORTER=1)
5876 if test -n "$MOZ_CRASHREPORTER"; then
5877    AC_DEFINE(MOZ_CRASHREPORTER)
5879   if (test "$OS_ARCH" = "Linux" || test "$OS_ARCH" = "SunOS") && \
5880     test -z "$SKIP_LIBRARY_CHECKS"; then
5881     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
5882     AC_SUBST(MOZ_GTHREAD_CFLAGS)
5883     AC_SUBST(MOZ_GTHREAD_LIBS)
5885     AC_CHECK_HEADERS([curl/curl.h], [], [AC_MSG_ERROR([Couldn't find curl/curl.h which is required for the crash reporter.  Use --disable-crashreporter to disable the crash reporter.])])
5886   fi
5889 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
5890 [  --with-crashreporter-enable-percent=NN  Enable sending crash reports by default on NN% of users. (default=100)],
5891 [ val=`echo $withval | sed 's/[^0-9]//g'`
5892     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
5894 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
5895    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
5897 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
5899 dnl ========================================================
5900 dnl = Enable compilation of specific extension modules
5901 dnl ========================================================
5903 MOZ_ARG_ENABLE_STRING(extensions,
5904 [  --enable-extensions     Enable extensions],
5905 [ for option in `echo $enableval | sed 's/,/ /g'`; do
5906     if test "$option" = "yes" || test "$option" = "all"; then
5907         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
5908     elif test "$option" = "no" || test "$option" = "none"; then
5909         MOZ_EXTENSIONS=""
5910     elif test "$option" = "default"; then
5911         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
5912     elif test `echo "$option" | grep -c \^-` != 0; then
5913         option=`echo $option | sed 's/^-//'`
5914         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
5915     else
5916         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
5917     fi
5918 done],
5919     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
5921 if test -z "$MOZ_ENABLE_GNOMEVFS" && test -z "$MOZ_GNOMEVFS_LIBS" && test `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
5922     # Suppress warning on non-X11 platforms
5923     if test -n "$MOZ_X11"; then
5924         AC_MSG_WARN([Cannot build gnomevfs without required libraries. Removing gnomevfs from MOZ_EXTENSIONS.])
5925     fi
5926     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
5929 dnl Do not build gnomevfs with libxul based apps
5930 if test -n "$LIBXUL_SDK_DIR" && test `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
5931     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
5934 if test -z "$MOZ_ENABLE_GIO" && test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
5935     # Suppress warning on non-X11 platforms
5936     if test -n "$MOZ_X11"; then
5937         AC_MSG_WARN([Cannot build gio without required libraries. Removing gio from MOZ_EXTENSIONS.])
5938     fi
5939     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
5942 dnl Do not build gio with libxul based apps
5943 if test -n "$LIBXUL_SDK_DIR" && test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
5944     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
5947 if test -z "$MOZ_JSDEBUGGER" && test `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
5948     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
5949     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
5952 dnl This might be temporary: build tridentprofile only on Windows
5953 if test `echo "$MOZ_EXTENSIONS" | grep -c tridentprofile` -ne 0 && test "$OS_ARCH" != "WINNT"; then
5954     AC_MSG_WARN([tridentprofile extension works only on Windows at this time. Removing tridentprofile from MOZ_EXTENSIONS.])
5955     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|tridentprofile||'`
5958 dnl cookie must be built before tridentprofile. put it at list's end.
5959 if test `echo "$MOZ_EXTENSIONS" | grep -c tridentprofile` -ne 0; then
5960   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|tridentprofile||'`
5961   MOZ_EXTENSIONS="$MOZ_EXTENSIONS tridentprofile"
5964 dnl xforms requires xtf and schema-validation
5965 if test -z "$MOZ_XTF" && test `echo "$MOZ_EXTENSIONS" | grep -c xforms` -ne 0; then
5966     AC_MSG_WARN([Cannot build XForms without XTF support.  Removing XForms from MOZ_EXTENSIONS.])
5967     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|xforms||g'`
5969 if test `echo "$MOZ_EXTENSIONS" | grep -c xforms` -ne 0 && test `echo "$MOZ_EXTENSIONS" | grep -c schema-validation` -eq 0; then
5970     AC_MSG_WARN([Cannot build XForms without schema validation.  Removing XForms from MOZ_EXTENSIONS.])
5971     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|xforms||g'`
5974 if test `echo "$MOZ_EXTENSIONS" | grep -c auth` -ne 0; then
5975     AC_MSG_WARN([auth is no longer an extension, use --disable-negotiateauth to disable.])
5976     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|auth||g'`
5979 if test `echo "$MOZ_EXTENSIONS" | grep -c 'cookie\|permissions'` -ne 0; then
5980     AC_MSG_WARN([cookie and permissions are no longer extensions, use --disable-permissions to disable.])
5981     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|cookie||g; s|permissions||g'`
5984 if test `echo "$MOZ_EXTENSIONS" | grep -c pref` -ne 0; then
5985     AC_MSG_WARN([pref is no longer an extension, use --disable-pref-extensions to disable.])
5986     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|pref||g'`
5989 if test `echo "$MOZ_EXTENSIONS" | grep -c universalchardet` -ne 0; then
5990     AC_MSG_WARN([universalchardet is no longer an extension, use --disable-universalchardet to disable.])
5991     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|universalchardet||g'`
5994 if test `echo "$MOZ_EXTENSIONS" | grep -c java` -ne 0; then
5995     AC_MSG_WARN([java is no longer an extension, use --enable-javaxpcom to enable.])
5996     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|java||g'`
5999 if test `echo "$MOZ_EXTENSIONS" | grep -c spellcheck` -ne 0; then
6000     AC_MSG_WARN([spellcheck is no longer an extension.])
6001     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|spellcheck||g'`
6004 dnl Remove dupes
6005 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6007 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6008 dnl when trying to build a non-existent extension.
6009 for extension in $MOZ_EXTENSIONS; do
6010     if test ! -d "${srcdir}/extensions/${extension}"; then
6011         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6012     fi
6013 done
6016 dnl ========================================================
6017 dnl Image decoders
6018 dnl ========================================================
6019 case "$MOZ_WIDGET_TOOLKIT" in
6020 beos|windows|os2|mac|cocoa)
6021     ;;
6023     if test -z "$MOZ_ENABLE_GTK2" && test -z "$MOZ_ENABLE_QT"; then
6024        MOZ_IMG_DECODERS_DEFAULT=`echo $MOZ_IMG_DECODERS_DEFAULT | sed -e 's|icon||'`
6025     fi
6026     ;;
6027 esac
6029 MOZ_ARG_ENABLE_STRING(image-decoders,
6030 [  --enable-image-decoders[={mod1,mod2,default,all,none}]
6031                           Enable specific image decoders],
6032 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6033     if test "$option" = "yes" || test "$option" = "all"; then
6034         MOZ_IMG_DECODERS="$MOZ_IMG_DECODERS $MOZ_IMG_DECODERS_DEFAULT"
6035     elif test "$option" = "no" || test "$option" = "none"; then
6036         MOZ_IMG_DECODERS=""
6037     elif test "$option" = "default"; then
6038         MOZ_IMG_DECODERS="$MOZ_IMG_DECODERS $MOZ_IMG_DECODERS_DEFAULT"
6039     elif test `echo "$option" | grep -c \^-` != 0; then
6040         option=`echo $option | sed 's/^-//'`
6041         MOZ_IMG_DECODERS=`echo "$MOZ_IMG_DECODERS" | sed "s/ ${option}//"`
6042     else
6043         MOZ_IMG_DECODERS="$MOZ_IMG_DECODERS $option"
6044     fi
6045 done],
6046     MOZ_IMG_DECODERS="$MOZ_IMG_DECODERS_DEFAULT")
6048 dnl Dupes are removed in the encoder section because it will also add decoders
6050 dnl ========================================================
6051 dnl Image encoders
6052 dnl ========================================================
6053 MOZ_ARG_ENABLE_STRING(image-encoders,
6054 [  --enable-image-encoders[={mod1,mod2,default,all,none}]
6055                           Enable specific image encoders],
6056 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6057     if test "$option" = "yes" || test "$option" = "all"; then
6058         addencoder="$MOZ_IMG_ENCODERS_DEFAULT"
6059     elif test "$option" = "no" || test "$option" = "none"; then
6060         MOZ_IMG_ENCODERS=""
6061         addencoder=""
6062     elif test "$option" = "default"; then
6063         addencoder="$MOZ_IMG_ENCODERS_DEFAULT"
6064     elif test `echo "$option" | grep -c \^-` != 0; then
6065         option=`echo $option | sed 's/^-//'`
6066         addencoder=`echo "$MOZ_IMG_ENCODERS" | sed "s/ ${option}//"`
6067     else
6068         addencoder="$option"
6069     fi
6070     MOZ_IMG_ENCODERS="$MOZ_IMG_ENCODERS $addencoder"
6071 done],
6072     MOZ_IMG_ENCODERS="$MOZ_IMG_ENCODERS_DEFAULT")
6074 dnl Remove dupes
6075 MOZ_IMG_DECODERS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_IMG_DECODERS}`
6076 MOZ_IMG_ENCODERS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_IMG_ENCODERS}`
6078 dnl ========================================================
6079 dnl MathML on by default
6080 dnl ========================================================
6081 MOZ_ARG_DISABLE_BOOL(mathml,
6082 [  --disable-mathml        Disable MathML support],
6083     MOZ_MATHML=,
6084     MOZ_MATHML=1 )
6085 if test "$MOZ_MATHML"; then
6086   AC_DEFINE(MOZ_MATHML)
6089 dnl ========================================================
6090 dnl SVG
6091 dnl ========================================================
6092 MOZ_ARG_DISABLE_BOOL(svg,
6093 [  --disable-svg            Disable SVG support],
6094     MOZ_SVG=,
6095     MOZ_SVG=1 )
6096 if test -n "$MOZ_SVG"; then
6097   AC_DEFINE(MOZ_SVG)
6100 dnl ========================================================
6101 dnl SMIL
6102 dnl ========================================================
6103 MOZ_SMIL=1
6104 MOZ_ARG_DISABLE_BOOL(smil,
6105 [  --disable-smil           Disable SMIL animation support],
6106     MOZ_SMIL=,
6107     MOZ_SMIL=1 )
6108 # Automatically disable SMIL if SVG is disabled
6109 if test -z "$MOZ_SVG"; then
6110   MOZ_SMIL=
6112 if test -n "$MOZ_SMIL"; then
6113   AC_DEFINE(MOZ_SMIL)
6116 dnl ========================================================
6117 dnl Build Freetype in the tree
6118 dnl ========================================================
6119 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6120 [  --enable-tree-freetype         Enable Tree FreeType],
6121     MOZ_TREE_FREETYPE=1,
6122     MOZ_TREE_FREETYPE= )
6123 if test -n "$MOZ_TREE_FREETYPE"; then
6124    AC_DEFINE(MOZ_TREE_FREETYPE)
6125    AC_SUBST(MOZ_TREE_FREETYPE)
6126    MOZ_ENABLE_CAIRO_FT=1       
6127    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6128    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6129    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6130    FT2_LIBS='$(LIBXUL_DIST)/lib/freetype2.lib'
6131    CAIRO_FT_LIBS='$(LIBXUL_DIST)/lib/freetype2.lib'
6132    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6133    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6134    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6135    AC_SUBST(CAIRO_FT_CFLAGS)
6139 dnl ========================================================
6140 dnl Installer
6141 dnl ========================================================
6142 case "$target_os" in
6143     aix*|solaris*|linux*|msvc*|mks*|cygwin*|mingw*|os2*|wince*|winmo*)
6144         MOZ_INSTALLER=1
6145         ;;
6146 esac
6148 MOZ_ARG_DISABLE_BOOL(installer,
6149 [  --disable-installer     Disable building of installer],
6150     MOZ_INSTALLER=,
6151     MOZ_INSTALLER=1 )
6152 if test -n "$MOZ_INSTALLER" -a "$OS_ARCH" = "WINNT"; then
6153     # Disable installer for Windows builds that use the new toolkit if NSIS
6154     # isn't in the path.
6155     MOZ_PATH_PROGS(MAKENSIS, makensis)
6156     if test -z "$MAKENSIS" || test "$MAKENSIS" = ":"; then
6157         AC_MSG_ERROR([To build the installer makensis is required in your path. To build without the installer reconfigure using --disable-installer.])
6158     fi
6159     # The Windows build for NSIS requires the iconv command line utility to
6160     # convert the charset of the locale files.
6161     MOZ_PATH_PROGS(HOST_ICONV, $HOST_ICONV "iconv", "")
6162     if test -z "$HOST_ICONV"; then
6163         AC_MSG_ERROR([To build the installer iconv is required in your path. To build without the installer reconfigure using --disable-installer.])
6164     fi
6167 # Automatically disable installer if xpinstall isn't built
6168 if test -z "$MOZ_XPINSTALL"; then
6169     MOZ_INSTALLER=
6171 AC_SUBST(MOZ_INSTALLER)
6173 AC_MSG_CHECKING([for tar archiver])
6174 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6175 if test -z "$TAR"; then
6176     AC_MSG_ERROR([no tar archiver found in \$PATH])
6178 AC_MSG_RESULT([$TAR])
6179 AC_SUBST(TAR)
6181 AC_MSG_CHECKING([for wget])
6182 AC_CHECK_PROGS(WGET, wget, "")
6183 AC_MSG_RESULT([$WGET])
6184 AC_SUBST(WGET)
6186 dnl ========================================================
6187 dnl Updater
6188 dnl ========================================================
6190 MOZ_ARG_DISABLE_BOOL(updater,
6191 [  --disable-updater       Disable building of updater],
6192     MOZ_UPDATER=,
6193     MOZ_UPDATER=1 )
6194 AC_SUBST(MOZ_UPDATER)
6196 # app update channel is 'default' when not supplied.
6197 MOZ_ARG_ENABLE_STRING([update-channel],
6198 [  --enable-update-channel=CHANNEL
6199                            Select application update channel (default=default)],
6200     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
6202 if test -z "$MOZ_UPDATE_CHANNEL"; then
6203     MOZ_UPDATE_CHANNEL=default
6205 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
6207 # tools/update-packaging is not checked out by default.
6208 MOZ_ARG_ENABLE_BOOL(update-packaging,
6209 [  --enable-update-packaging
6210                            Enable tools/update-packaging],
6211     MOZ_UPDATE_PACKAGING=1,
6212     MOZ_UPDATE_PACKAGING= )
6213 AC_SUBST(MOZ_UPDATE_PACKAGING)
6215 dnl ========================================================
6216 dnl ActiveX
6217 dnl ========================================================
6219 MOZ_ARG_DISABLE_BOOL(xpconnect-idispatch,
6220 [  --disable-xpconnect-idispatch
6221                           Disable building of xpconnect support for IDispatch
6222                           (win32 only)],
6223     XPC_IDISPATCH_SUPPORT=,
6224     XPC_IDISPATCH_SUPPORT=1)
6225 AC_SUBST(XPC_IDISPATCH_SUPPORT)
6227 MOZ_ARG_DISABLE_BOOL(activex,
6228 [  --disable-activex       Disable building of ActiveX control (win32 only)],
6229     MOZ_NO_ACTIVEX_SUPPORT=1,
6230     MOZ_NO_ACTIVEX_SUPPORT= )
6231 AC_SUBST(MOZ_NO_ACTIVEX_SUPPORT)
6233 MOZ_ARG_ENABLE_BOOL(activex-scripting,
6234 [  --enable-activex-scripting
6235                           Enable building of ActiveX scripting support (win32)],
6236     MOZ_ACTIVEX_SCRIPTING_SUPPORT=1,
6237     MOZ_ACTIVEX_SCRIPTING_SUPPORT=)
6238 AC_SUBST(MOZ_ACTIVEX_SCRIPTING_SUPPORT)
6240 if test -n "$MOZ_NO_ACTIVEX_SUPPORT" -a -n "$MOZ_ACTIVEX_SCRIPTING_SUPPORT";
6241 then
6242     AC_MSG_ERROR([Cannot enable ActiveX scripting support when ActiveX support is disabled.])
6245 if test "$COMPILE_ENVIRONMENT" = "1"; then
6246 if test -n "$XPC_IDISPATCH_SUPPORT" -o -n "$MOZ_ACTIVEX_SCRIPTING_SUPPORT" -o -z "$MOZ_NO_ACTIVEX_SUPPORT"; then
6247 case "$target" in
6248 *-mingw*|*-cygwin*|*-msvc*|*-mks*)
6249     if test "$ac_cv_header_atlbase_h" = "no"; then
6250         AC_MSG_ERROR([System header atlbase.h is not available. See http://developer.mozilla.org/en/docs/atlbase.h for details on fixing this problem.])
6251     fi
6252     ;;
6253 esac
6257 dnl ========================================================
6258 dnl leaky
6259 dnl ========================================================
6260 MOZ_ARG_ENABLE_BOOL(leaky,
6261 [  --enable-leaky          Build leaky memory tool],
6262     MOZ_LEAKY=1,
6263     MOZ_LEAKY=)
6266 dnl ========================================================
6267 dnl xpctools
6268 dnl ========================================================
6269 MOZ_ARG_ENABLE_BOOL(xpctools,
6270 [  --enable-xpctools       Build JS profiling tool],
6271     MOZ_XPCTOOLS=1,
6272     MOZ_XPCTOOLS= )
6275 dnl ========================================================
6276 dnl build the tests by default
6277 dnl ========================================================
6278 MOZ_ARG_DISABLE_BOOL(tests,
6279 [  --disable-tests         Do not build test libraries & programs],
6280     ENABLE_TESTS=,
6281     ENABLE_TESTS=1 )
6283 dnl ========================================================
6284 dnl parental controls (for Windows Vista)
6285 dnl ========================================================
6286 MOZ_ARG_DISABLE_BOOL(parental-controls,
6287 [  --disable-parental-controls
6288                            Do not build parental controls],
6289    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6290    MOZ_DISABLE_PARENTAL_CONTROLS=)
6291 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6292     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6295 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6297 dnl ========================================================
6298 dnl =
6299 dnl = Module specific options
6300 dnl =
6301 dnl ========================================================
6302 MOZ_ARG_HEADER(Individual module options)
6304 dnl ========================================================
6305 dnl = Enable places (new history/bookmarks)
6306 dnl ========================================================
6307 MOZ_ARG_ENABLE_BOOL(places,
6308 [  --enable-places        Enable 'places' bookmark/history implementation],
6309     MOZ_PLACES=1,
6310     MOZ_PLACES= )
6311 if test -n "$MOZ_PLACES"; then
6312     AC_DEFINE(MOZ_PLACES)
6313     if test -z "$MOZ_MAIL_NEWS"; then
6314       MOZ_MORK=
6315     fi
6316     MOZ_MORKREADER=1
6317 else
6318   if test "$MOZ_BUILD_APP" = "browser"; then
6319     AC_MSG_ERROR([Cannot build Firefox with --disable-places.])
6320   fi
6323 dnl ========================================================
6324 dnl = Disable feed handling components
6325 dnl ========================================================
6326 MOZ_ARG_DISABLE_BOOL(feeds,
6327 [  --disable-feeds        Disable feed handling and processing components],
6328     MOZ_FEEDS=,
6329     MOZ_FEEDS=1 )
6330 if test -n "$MOZ_FEEDS"; then
6331     AC_DEFINE(MOZ_FEEDS)
6332 else
6333     if test "$MOZ_BUILD_APP" = "browser"; then
6334         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6335     fi
6338 dnl ========================================================
6339 dnl = Enable mozStorage
6340 dnl ========================================================
6341 dnl Implicitly enabled by default if building calendar or places
6342 MOZ_ARG_ENABLE_BOOL(storage,
6343 [  --enable-storage        Enable mozStorage module and related components],
6344     MOZ_STORAGE=1,
6345     MOZ_STORAGE= )
6346 if test -n "$MOZ_STORAGE"; then
6347     AC_DEFINE(MOZ_STORAGE)
6350 dnl ========================================================
6351 dnl Check for sqlite
6352 dnl ========================================================
6354 MOZ_NATIVE_SQLITE=
6355 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6356 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6357 MOZ_NATIVE_SQLITE=1,
6358 MOZ_NATIVE_SQLITE= )
6360 if test -z "$MOZ_NATIVE_SQLITE"
6361 then
6362     SQLITE_CFLAGS=
6363     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6364 else
6365     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6366     dnl ===================================
6367     dnl === SQLITE_SECURE_DELETE checks ===
6368     dnl ===================================
6369     dnl check to see if the system sqlite package is compiled with
6370     dnl SQLITE_SECURE_DELETE enabled.
6371     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system sqlite)
6372     _SAVE_CFLAGS="$CFLAGS"
6373     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6374     _SAVE_LIBS="$LIBS"
6375     LIBS="$LIBS $SQLITE_LIBS"
6376     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6377         AC_TRY_RUN([
6378             #include "sqlite3.h"
6379             #include <stdio.h>
6380             #include <assert.h>
6382             int main(int argc, char **argv){
6383               sqlite3 *db;
6384               sqlite3_uint64 r;
6385               char *zFilename;
6386               FILE *in;
6387               int i;
6388               int rc;
6389               char *zBuf;
6390               const int bufSize = 1024*3;
6392               zBuf = malloc(bufSize*sizeof(char));
6393               assert( zBuf );
6394               rc = sqlite3_open(":memory:", &db);
6395               assert( rc==SQLITE_OK );
6396               sqlite3_close(db);
6397               sqlite3_randomness(sizeof(r), &r);
6398               zFilename = sqlite3_mprintf("test_db_%llu.sqlite", r);
6399               rc = sqlite3_open(zFilename, &db);
6400               assert( rc==SQLITE_OK );
6401               rc = sqlite3_exec(db, 
6402                 "BEGIN;"
6403                 "CREATE TABLE t1(x);"
6404                 "INSERT INTO t1 VALUES(zeroblob(1000)||'abcdefghijklmnopqrstuvwxyz');"
6405                 "COMMIT;"
6406                 "DELETE FROM t1;",
6407                 0, 0, 0
6408               );
6409               assert( rc==SQLITE_OK );
6410               sqlite3_close(db);
6411               in = fopen(zFilename, "r");
6412               assert( in!=0 );
6413               rc = fread(zBuf, 1, bufSize, in);
6414               assert( rc==bufSize );
6415               fclose(in);
6416               unlink(zFilename);
6417               free( zBuf );
6418               for(i=0; i<bufSize-11; i++){
6419                 if( *(zBuf+i)=='h' && memcmp(zBuf+i, "hijklmnopq", 10)==0 ){
6420                   return 1;
6421                 }
6422               }
6423               return 0;
6424             }],
6425             ac_cv_sqlite_secure_delete=yes,
6426             ac_cv_sqlite_secure_delete=no,
6427             ac_cv_sqlite_secure_delete=no
6428         )
6429     ])
6430     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6431     CFLAGS="$_SAVE_CFLAGS"
6432     LIBS="$_SAVE_LIBS"
6433     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6434         AC_MSG_ERROR([System Sqlite library is not compiled with SQLITE_SECURE_DELETE.])
6435     fi
6438 AC_SUBST(MOZ_NATIVE_SQLITE)
6440 dnl ========================================================
6441 dnl = Enable help viewer (off by default)
6442 dnl ========================================================
6443 MOZ_ARG_ENABLE_BOOL(help-viewer,
6444 [  --enable-help-viewer        Enable help viewer],
6445     MOZ_HELP_VIEWER=1,
6446     MOZ_HELP_VIEWER= )
6447 if test -n "$MOZ_HELP_VIEWER"; then
6448      AC_DEFINE(MOZ_HELP_VIEWER)
6450 AC_SUBST(MOZ_HELP_VIEWER)
6451 if test "$MOZ_BUILD_APP" = "browser" -a -n "$MOZ_HELP_VIEWER"; then
6452     AC_MSG_ERROR([Cannot build Firefox with --enable-help-viewer.])
6455 dnl ========================================================
6456 dnl = Enable safe browsing (anti-phishing)
6457 dnl ========================================================
6458 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6459 [  --enable-safe-browsing        Enable safe browsing (anti-phishing) implementation],
6460     MOZ_SAFE_BROWSING=1,
6461     MOZ_SAFE_BROWSING= )
6462 if test -n "$MOZ_SAFE_BROWSING"; then
6463     AC_DEFINE(MOZ_SAFE_BROWSING)
6465 AC_SUBST(MOZ_SAFE_BROWSING)
6467 dnl ========================================================
6468 dnl = Enable faststart component
6469 dnl ========================================================
6470 MOZ_ARG_ENABLE_BOOL(faststart,
6471 [  --enable-faststart            Enable the faststart component],
6472     MOZ_FASTSTART=1,
6473     MOZ_FASTSTART= )
6474 if test -n "$MOZ_FASTSTART"; then
6475     AC_DEFINE(MOZ_FASTSTART)
6477 AC_SUBST(MOZ_FASTSTART)
6479 dnl ========================================================
6480 dnl = Enable url-classifier
6481 dnl ========================================================
6482 dnl Implicitly enabled by default if building with safe-browsing
6483 if test -n "$MOZ_SAFE_BROWSING"; then
6484     MOZ_URL_CLASSIFIER=1
6486 MOZ_ARG_ENABLE_BOOL(url-classifier,
6487 [  --enable-url-classifier        Enable url classifier module],
6488     MOZ_URL_CLASSIFIER=1,
6489     MOZ_URL_CLASSIFIER= )
6490 if test -n "$MOZ_URL_CLASSIFIER"; then
6491     AC_DEFINE(MOZ_URL_CLASSIFIER)
6493 AC_SUBST(MOZ_URL_CLASSIFIER)
6495 dnl ========================================================
6496 dnl = Disable zipwriter
6497 dnl ========================================================
6498 MOZ_ARG_DISABLE_BOOL(zipwriter,
6499 [  --disable-zipwriter             Disable zipwriter component],
6500     MOZ_ZIPWRITER=,
6501     MOZ_ZIPWRITER=1 )
6502 AC_SUBST(MOZ_ZIPWRITER)
6504 dnl ========================================================
6505 dnl = Disable libconic
6506 dnl ========================================================
6507 MOZ_ENABLE_LIBCONIC=1
6508 MOZ_ARG_DISABLE_BOOL(libconic,
6509 [  --disable-libconic              Disable libconic],
6510     MOZ_ENABLE_LIBCONIC=,
6511     MOZ_ENABLE_LIBCONIC=1 )
6513 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6514     PKG_CHECK_MODULES(LIBCONIC, conic,
6515                       MOZ_ENABLE_LIBCONIC=1,
6516                       MOZ_ENABLE_LIBCONIC=)
6518 if test "$MOZ_ENABLE_LIBCONIC"; then
6519     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6522 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6523 AC_SUBST(LIBCONIC_CFLAGS)
6524 AC_SUBST(LIBCONIC_LIBS)
6526 dnl ========================================================
6527 dnl = Maemo checks
6528 dnl ========================================================
6530 MAEMO_SDK_TARGET_VER=-1
6532 MOZ_ARG_WITH_STRING(maemo-version,
6533 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6534                         Maemo SDK Version],
6535   MAEMO_SDK_TARGET_VER=$withval)
6537 case "$MAEMO_SDK_TARGET_VER" in
6539     MOZ_PLATFORM_MAEMO=5
6540     ;;
6543     MOZ_PLATFORM_MAEMO=6
6544     ;;
6547     dnl We aren't compiling for Maemo, move on.
6548     ;;
6550     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6551     ;;
6552 esac
6554 if test $MOZ_PLATFORM_MAEMO; then
6555    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6557    if test -z "$MOZ_ENABLE_DBUS"; then
6558        AC_MSG_ERROR([DBus is required when building for Maemo])
6559    fi
6560    
6561    MOZ_GFX_OPTIMIZE_MOBILE=1
6562    MOZ_WEBGL_GLX=
6564    if test $MOZ_PLATFORM_MAEMO = 5; then
6565       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6566       AC_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6567                        [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6568       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6569                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6571       AC_SUBST(XCOMPOSITE_LIBS)
6573       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6574       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6575       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6576       if test -z "$_LIB_FOUND"; then
6577          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6578       fi
6581       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6582       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6583       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6584       if test -z "$_LIB_FOUND"; then
6585          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6586       fi
6588       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6589       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6590       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6591       if test -z "$_LIB_FOUND"; then
6592          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6593       fi
6594    fi
6596    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6597    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6600 dnl ========================================================
6601 dnl = faststripe theme
6602 dnl ========================================================
6603 MOZ_ARG_ENABLE_BOOL(faststripe,
6604 [  --enable-faststripe  Use faststripe theme],
6605     MOZ_THEME_FASTSTRIPE=1,
6606     MOZ_THEME_FASTSTRIPE= )
6607 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6609 dnl ========================================================
6610 dnl =
6611 dnl = Feature options that require extra sources to be pulled
6612 dnl =
6613 dnl ========================================================
6614 dnl MOZ_ARG_HEADER(Features that require extra sources)
6616 dnl ========================================================
6617 dnl =
6618 dnl = Debugging Options
6619 dnl = 
6620 dnl ========================================================
6621 MOZ_ARG_HEADER(Debugging and Optimizations)
6623 dnl ========================================================
6624 dnl = Disable building with debug info.
6625 dnl = Debugging is OFF by default
6626 dnl ========================================================
6627 if test -z "$MOZ_DEBUG_FLAGS"
6628 then
6629     case "$target" in
6630     *-irix*)
6631         if test "$GNU_CC"; then
6632             GCC_VERSION=`$CC -v 2>&1 | awk '/version/ { print $3 }'`
6633             case "$GCC_VERSION" in
6634             2.95.*)
6635                 MOZ_DEBUG_FLAGS=""
6636                 ;;
6637             *)
6638                 MOZ_DEBUG_FLAGS="-g"
6639                 ;;
6640             esac
6641         else
6642             MOZ_DEBUG_FLAGS="-g"
6643         fi
6644         ;;
6645     *)
6646         MOZ_DEBUG_FLAGS="-g"
6647         ;;
6648     esac
6651 MOZ_ARG_ENABLE_STRING(debug,
6652 [  --enable-debug[=DBG]    Enable building with developer debug info
6653                            (using compiler flags DBG)],
6654 [ if test "$enableval" != "no"; then
6655     MOZ_DEBUG=1
6656     if test -n "$enableval" -a "$enableval" != "yes"; then
6657         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6658         _MOZ_DEBUG_FLAGS_SET=1
6659     fi
6660   else
6661     MOZ_DEBUG=
6662   fi ],
6663   MOZ_DEBUG=)
6665 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG"
6666  case "${target_os}" in
6667     beos*)
6668         MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${USER}"
6669         ;;
6670     msvc*|mks*|cygwin*|mingw*|os2*|wince*|winmo*)
6671         MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
6672         ;;
6673     *) 
6674         MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`$WHOAMI`"
6675         ;;
6676   esac
6677 MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DTRACING"
6679 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
6681 if test -n "$MOZ_DEBUG"; then
6682     AC_MSG_CHECKING([for valid debug flags])
6683     _SAVE_CFLAGS=$CFLAGS
6684     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
6685     AC_TRY_COMPILE([#include <stdio.h>], 
6686         [printf("Hello World\n");],
6687         _results=yes,
6688         _results=no)
6689     AC_MSG_RESULT([$_results])
6690     if test "$_results" = "no"; then
6691         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
6692     fi
6693     CFLAGS=$_SAVE_CFLAGS
6696 dnl ========================================================
6697 dnl enable mobile optimizations
6698 dnl ========================================================
6699 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6700 [  --enable-mobile-optimize   Enable mobile optimizations],
6701     MOZ_GFX_OPTIMIZE_MOBILE=1)
6703 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6705 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6706     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6709 dnl ========================================================
6710 dnl = Enable code optimization. ON by default.
6711 dnl ========================================================
6712 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6713         MOZ_OPTIMIZE_FLAGS="-O"
6716 MOZ_ARG_ENABLE_STRING(optimize,
6717 [  --disable-optimize      Disable compiler optimization
6718   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6719 [ if test "$enableval" != "no"; then
6720     MOZ_OPTIMIZE=1
6721     if test -n "$enableval" && test "$enableval" != "yes"; then
6722         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6723         MOZ_OPTIMIZE=2
6724     fi
6725 else
6726     MOZ_OPTIMIZE=
6727 fi ], MOZ_OPTIMIZE=1)
6729 if test "$COMPILE_ENVIRONMENT"; then
6730 if test -n "$MOZ_OPTIMIZE"; then
6731     AC_MSG_CHECKING([for valid optimization flags])
6732     _SAVE_CFLAGS=$CFLAGS
6733     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6734     AC_TRY_COMPILE([#include <stdio.h>], 
6735         [printf("Hello World\n");],
6736         _results=yes,
6737         _results=no)
6738     AC_MSG_RESULT([$_results])
6739     if test "$_results" = "no"; then
6740         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6741     fi
6742     CFLAGS=$_SAVE_CFLAGS
6744 fi # COMPILE_ENVIRONMENT
6746 AC_SUBST(MOZ_OPTIMIZE)
6747 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6748 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6749 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6751 dnl ========================================================
6752 dnl = (Deprecated) generation of debugger info for specific modules
6753 dnl ========================================================
6754 MOZ_ARG_ENABLE_STRING(debugger-info-modules,
6755 [  --enable-debugger-info-modules
6756                           Enable/disable debugger info for specific modules],
6757 [ if test "$enableval" != "no"; then
6758     AC_MSG_WARN([--enable-debugger-info-modules is deprecated, use --enable-debug-symbols instead])
6759     MOZ_DEBUG_SYMBOLS=1
6760   fi ])
6762 dnl ========================================================
6763 dnl = Enable generation of debug symbols
6764 dnl ========================================================
6765 MOZ_ARG_ENABLE_STRING(debug-symbols,
6766 [  --enable-debug-symbols[=DBG]    Enable debugging symbols
6767                                    (using compiler flags DBG)],
6768 [ if test "$enableval" != "no"; then
6769       MOZ_DEBUG_SYMBOLS=1
6770       if test -n "$enableval" -a "$enableval" != "yes"; then
6771           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
6772               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6773           else
6774               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
6775           fi
6776       fi
6777   fi ])
6779 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
6780     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
6781     export MOZ_DEBUG_SYMBOLS
6784 dnl ========================================================
6785 dnl Disable runtime logging checks
6786 dnl ========================================================
6787 MOZ_ARG_DISABLE_BOOL(logging,
6788 [  --disable-logging       Disable logging facilities],
6789     NS_DISABLE_LOGGING=1,
6790     NS_DISABLE_LOGGING= )
6791 if test "$NS_DISABLE_LOGGING"; then
6792     AC_DEFINE(NS_DISABLE_LOGGING)
6793 else
6794     AC_DEFINE(MOZ_LOGGING)
6797 dnl ========================================================
6798 dnl = dnl This will enable logging of addref, release, ctor, dtor.
6799 dnl ========================================================
6800 _ENABLE_LOGREFCNT=42
6801 MOZ_ARG_ENABLE_BOOL(logrefcnt,
6802 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
6803     _ENABLE_LOGREFCNT=1,
6804     _ENABLE_LOGREFCNT= )
6805 if test "$_ENABLE_LOGREFCNT" = "1"; then
6806     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
6807 elif test -z "$_ENABLE_LOGREFCNT"; then
6808     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
6811 dnl ========================================================
6812 dnl = Enable trace malloc
6813 dnl ========================================================
6814 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
6815 MOZ_ARG_ENABLE_BOOL(trace-malloc,
6816 [  --enable-trace-malloc   Enable malloc tracing],
6817     NS_TRACE_MALLOC=1,
6818     NS_TRACE_MALLOC= )
6819 if test "$NS_TRACE_MALLOC"; then
6820   # Please, Mr. Linker Man, don't take away our symbol names
6821   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
6822   USE_ELF_DYNSTR_GC=
6823   AC_DEFINE(NS_TRACE_MALLOC)
6825 AC_SUBST(NS_TRACE_MALLOC)
6827 dnl ========================================================
6828 dnl = Enable jemalloc
6829 dnl ========================================================
6830 MOZ_ARG_ENABLE_BOOL(jemalloc,
6831 [  --enable-jemalloc       Replace memory allocator with jemalloc],
6832     MOZ_MEMORY=1,
6833     MOZ_MEMORY=)
6835 if test "$NS_TRACE_MALLOC"; then
6836     MOZ_MEMORY=
6839 if test "$MOZ_MEMORY"; then
6841   dnl Don't try to run compiler tests on Windows  
6842   if test "$OS_ARCH" = "WINNT"; then
6843     if test -z "$HAVE_64BIT_OS"; then
6844       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
6845     else
6846       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
6847     fi
6848   else
6849     AC_CHECK_SIZEOF([int *], [4])
6850     case "${ac_cv_sizeof_int_p}" in
6851     4)
6852       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
6853       ;;
6854     8)
6855       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
6856       ;;
6857     *)
6858       AC_MSG_ERROR([Unexpected pointer size])
6859       ;;
6860     esac
6861   fi
6863   AC_DEFINE(MOZ_MEMORY)
6864   if test "x$MOZ_DEBUG" = "x1"; then
6865     AC_DEFINE(MOZ_MEMORY_DEBUG)
6866   fi
6867   dnl The generic feature tests that determine how to compute ncpus are long and
6868   dnl complicated.  Therefore, simply define special cpp variables for the
6869   dnl platforms we have special knowledge of.
6870   case "${target_os}" in
6871   darwin*)
6872     AC_DEFINE(MOZ_MEMORY_DARWIN)
6873     ;;
6874   *freebsd*)
6875     AC_DEFINE(MOZ_MEMORY_BSD)
6876     ;;
6877   *linux*)
6878     AC_DEFINE(MOZ_MEMORY_LINUX)
6879     ;;
6880   netbsd*)
6881     AC_DEFINE(MOZ_MEMORY_BSD)
6882     ;;
6883   solaris*)
6884     AC_DEFINE(MOZ_MEMORY_SOLARIS)
6885     ;;
6886   msvc*|mks*|cygwin*|mingw*)
6887     AC_DEFINE(MOZ_MEMORY_WINDOWS)
6888     dnl This is sort of awful. Will revisit if we add support for more versions
6889     if test "$CC_VERSION" != "14.00.50727.762" -a "$CC_VERSION" != "15.00.30729.01"; then
6890         AC_MSG_ERROR([Building jemalloc requires exactly Visual C++ 2005 SP1 or 2008 SP1 currently.])
6891     fi
6892     if test -z "$WIN32_CRT_SRC_DIR"; then
6893       if test -z "$VCINSTALLDIR" -o ! -d "$VCINSTALLDIR"; then
6894         AC_MSG_ERROR([When building jemalloc, set WIN32_CRT_SRC_DIR to the path to the Visual C++ CRT source (usually VCINSTALLDIR\crt\src, but VCINSTALLDIR is not set, so I can't autodetect it for you).])
6895       else
6896         WIN32_CRT_SRC_DIR="$VCINSTALLDIR\crt\src"
6897       fi
6898     fi
6899     dnl cpu check
6900     case "${target_cpu}" in
6901     i*86)
6902       _WIN32_CRT_CPU=intel
6903       ;;
6904     *)
6905       AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
6906       ;;
6907     esac
6909     if test ! -d "$WIN32_CRT_SRC_DIR"; then
6910       AC_MSG_ERROR([Invalid Win32 CRT source directory: ${WIN32_CRT_SRC_DIR}])
6911     fi
6912     WIN32_CRT_SRC_DIR=`cd "$WIN32_CRT_SRC_DIR" && pwd -W`
6913     _objdir_win=`pwd -W`
6914     WIN32_CUSTOM_CRT_DIR="$_objdir_win/memory/jemalloc/crtsrc/build/$_WIN32_CRT_CPU"
6915     MOZ_MEMORY_LDFLAGS="-MANIFEST:NO -LIBPATH:\"$WIN32_CUSTOM_CRT_DIR\" -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt19 -DEFAULTLIB:mozcpp19"
6916     dnl Also pass this to NSPR/NSS
6917     DLLFLAGS="$DLLFLAGS $MOZ_MEMORY_LDFLAGS"
6918     export DLLFLAGS
6919     ;;
6920   *wince)
6921     AC_DEFINE(MOZ_MEMORY_WINCE)
6922     AC_DEFINE(MOZ_MEMORY_WINDOWS)
6923     if test -z "$WINCE_WINDOWS_MOBILE"; then
6924       AC_DEFINE(MOZ_MEMORY_WINCE6)
6925     fi
6926     ;;
6927   *winmo)
6928     AC_DEFINE(MOZ_MEMORY_WINCE)
6929     AC_DEFINE(MOZ_MEMORY_WINDOWS)
6930     ;;
6931   *)
6932     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
6933     ;;
6934   esac
6936   if test "$OS_ARCH" != "Darwin"; then
6937     dnl NB: this must be kept in sync with jemalloc.h
6938     AC_DEFINE(HAVE_JEMALLOC_VALLOC)
6939     AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
6940     AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
6941   fi
6943 AC_SUBST(MOZ_MEMORY)
6944 AC_SUBST(MOZ_MEMORY_LDFLAGS)
6945 AC_SUBST(WIN32_CRT_SRC_DIR)
6946 dnl Need to set this for make because NSS doesn't have configure
6947 AC_SUBST(DLLFLAGS)
6949 dnl ========================================================
6950 dnl = Use malloc wrapper lib
6951 dnl ========================================================
6952 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
6953 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
6954     _WRAP_MALLOC=1,
6955     _WRAP_MALLOC= )
6957 if test -n "$_WRAP_MALLOC"; then
6958     if test "$GNU_CC"; then
6959     WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -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"
6960     MKSHLIB='$(CXX) $(DSO_LDOPTS) $(WRAP_MALLOC_CFLAGS) -o $@'
6961     fi
6964 dnl ========================================================
6965 dnl = Location of malloc wrapper lib
6966 dnl ========================================================
6967 MOZ_ARG_WITH_STRING(wrap-malloc,
6968 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
6969     WRAP_MALLOC_LIB=$withval)
6971 dnl ========================================================
6972 dnl = Use TraceVis
6973 dnl ========================================================
6974 MOZ_ARG_ENABLE_BOOL(tracevis,
6975 [  --enable-tracevis       Enable TraceVis tracing tool (default=no)],
6976     MOZ_TRACEVIS=1,
6977     MOZ_TRACEVIS= )
6978 if test -n "$MOZ_TRACEVIS"; then
6979     AC_DEFINE(MOZ_TRACEVIS)
6982 dnl ========================================================
6983 dnl = Use Valgrind
6984 dnl ========================================================
6985 MOZ_ARG_ENABLE_BOOL(valgrind,
6986 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
6987     MOZ_VALGRIND=1,
6988     MOZ_VALGRIND= )
6989 if test -n "$MOZ_VALGRIND"; then
6990     AC_CHECK_HEADER([valgrind/valgrind.h], [],
6991         AC_MSG_ERROR(
6992             [--enable-valgrind specified but Valgrind is not installed]))
6993     AC_DEFINE(MOZ_VALGRIND)
6996 dnl ========================================================
6997 dnl jprof
6998 dnl ========================================================
6999 MOZ_ARG_ENABLE_BOOL(jprof,
7000 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof)],
7001     MOZ_JPROF=1,
7002     MOZ_JPROF= )
7003 if test -n "$MOZ_JPROF"; then
7004     AC_DEFINE(MOZ_JPROF)
7007 dnl ========================================================
7008 dnl shark
7009 dnl ========================================================
7010 MOZ_ARG_ENABLE_BOOL(shark,
7011 [  --enable-shark          Enable shark remote profiling (needs CHUD framework)],
7012     MOZ_SHARK=1,
7013     MOZ_SHARK= )
7014 if test -n "$MOZ_SHARK"; then
7015     AC_DEFINE(MOZ_SHARK)
7018 dnl ========================================================
7019 dnl callgrind
7020 dnl ========================================================
7021 MOZ_ARG_ENABLE_BOOL(callgrind,
7022 [  --enable-callgrind      Enable callgrind profiling],
7023     MOZ_CALLGRIND=1,
7024     MOZ_CALLGRIND= )
7025 if test -n "$MOZ_CALLGRIND"; then
7026     AC_DEFINE(MOZ_CALLGRIND)
7029 dnl ========================================================
7030 dnl vtune
7031 dnl ========================================================
7032 MOZ_ARG_ENABLE_BOOL(vtune,
7033 [  --enable-vtune          Enable vtune profiling],
7034     MOZ_VTUNE=1,
7035     MOZ_VTUNE= )
7036 if test -n "$MOZ_VTUNE"; then
7037     AC_DEFINE(MOZ_VTUNE)
7040 dnl ========================================================
7041 dnl Zealous JavaScript GC
7042 dnl ========================================================
7043 MOZ_ARG_ENABLE_BOOL(gczeal,
7044 [  --enable-gczeal          Enable zealous JavaScript GCing],
7045     JS_GC_ZEAL=1,
7046     JS_GC_ZEAL= )
7047 if test -n "$JS_GC_ZEAL"; then
7048     AC_DEFINE(JS_GC_ZEAL)
7051 dnl ========================================================
7052 dnl = Enable static checking using gcc-dehydra
7053 dnl ========================================================
7055 MOZ_ARG_WITH_STRING(static-checking,
7056 [  --with-static-checking=path/to/gcc_dehydra.so
7057                             Enable static checking of code using GCC-dehydra],
7058     DEHYDRA_PATH=$withval,
7059     DEHYDRA_PATH= )
7061 if test -n "$DEHYDRA_PATH"; then
7062     if test ! -f "$DEHYDRA_PATH"; then
7063         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7064     fi
7065     AC_DEFINE(NS_STATIC_CHECKING)
7067 AC_SUBST(DEHYDRA_PATH)
7069 dnl ========================================================
7070 dnl = Enable stripping of libs & executables
7071 dnl ========================================================
7072 MOZ_ARG_ENABLE_BOOL(strip,
7073 [  --enable-strip          Enable stripping of libs & executables ],
7074     ENABLE_STRIP=1,
7075     ENABLE_STRIP= )
7077 dnl ========================================================
7078 dnl = Enable stripping of libs & executables when packaging
7079 dnl ========================================================
7080 MOZ_ARG_ENABLE_BOOL(install-strip,
7081 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7082     PKG_SKIP_STRIP= ,
7083     PKG_SKIP_STRIP=1)
7085 dnl ========================================================
7086 dnl = --enable-elf-dynstr-gc
7087 dnl ========================================================
7088 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7089 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7090     USE_ELF_DYNSTR_GC=1,
7091     USE_ELF_DYNSTR_GC= )
7093 dnl ========================================================
7094 dnl = 
7095 dnl = Profiling and Instrumenting
7096 dnl = 
7097 dnl ========================================================
7098 MOZ_ARG_HEADER(Profiling and Instrumenting)
7100 dnl ========================================================
7101 dnl = Enable timeline service, which provides lightweight
7102 dnl = instrumentation of mozilla for performance measurement.
7103 dnl = Timeline is off by default.
7104 dnl ========================================================
7105 MOZ_ARG_ENABLE_BOOL(timeline,
7106 [  --enable-timeline       Enable timeline services ],
7107     MOZ_TIMELINE=1,
7108     MOZ_TIMELINE= )
7109 if test -n "$MOZ_TIMELINE"; then
7110     AC_DEFINE(MOZ_TIMELINE)
7113 dnl ========================================================
7114 dnl Turn on reflow counting
7115 dnl ========================================================
7116 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7117 [  --enable-reflow-perf    Enable reflow performance tracing],
7118     MOZ_REFLOW_PERF=1,
7119     MOZ_REFLOW_PERF= )
7120 if test -n "$MOZ_REFLOW_PERF"; then
7121     AC_DEFINE(MOZ_REFLOW_PERF)
7124 dnl ========================================================
7125 dnl Enable code size metrics.
7126 dnl ========================================================
7127 MOZ_ARG_ENABLE_BOOL(codesighs,
7128 [  --enable-codesighs      Enable code size analysis tools],
7129     _ENABLE_CODESIGHS=1,
7130     _ENABLE_CODESIGHS= )
7131 if test -n "$_ENABLE_CODESIGHS"; then
7132     if test -d $srcdir/tools/codesighs; then 
7133         MOZ_MAPINFO=1
7134     else
7135         AC_MSG_ERROR([Codesighs directory $srcdir/tools/codesighs required.])
7136     fi
7139 MOZ_ARG_ENABLE_BOOL(insure,
7140 [  --enable-insure         Enable insure++ instrumentation (linux only)],
7141     _ENABLE_INSURE=1,
7142     _ENABLE_INSURE= )
7143 if test -n "$_ENABLE_INSURE"; then
7144     MOZ_INSURE="insure"
7145     MOZ_INSURIFYING=1
7146     MOZ_INSURE_DIRS="."
7147     MOZ_INSURE_EXCLUDE_DIRS="config"
7150 MOZ_ARG_WITH_STRING(insure-dirs,
7151 [  --with-insure-dirs=DIRS
7152                           Dirs to instrument with insure ],
7153     MOZ_INSURE_DIRS=$withval )
7155 MOZ_ARG_WITH_STRING(insure-exclude-dirs,
7156 [  --with-insure-exclude-dirs=DIRS
7157                           Dirs to not instrument with insure ],
7158     MOZ_INSURE_EXCLUDE_DIRS="config $withval" )
7160 dnl ========================================================
7161 dnl = Support for Quantify (Windows)
7162 dnl ========================================================
7163 MOZ_ARG_ENABLE_BOOL(quantify,
7164 [  --enable-quantify      Enable Quantify support (Windows only) ],
7165     MOZ_QUANTIFY=1,
7166     MOZ_QUANTIFY= )
7168 dnl ========================================================
7169 dnl = Support for demangling undefined symbols
7170 dnl ========================================================
7171 if test -z "$SKIP_LIBRARY_CHECKS"; then
7172     AC_LANG_SAVE
7173     AC_LANG_CPLUSPLUS
7174     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7175     AC_LANG_RESTORE
7178 # Demangle only for debug or trace-malloc builds
7179 MOZ_DEMANGLE_SYMBOLS=
7180 if test "$HAVE_DEMANGLE" -a "$HAVE_GCC3_ABI" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
7181     MOZ_DEMANGLE_SYMBOLS=1
7182     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7184 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7186 dnl ========================================================
7187 dnl = Support for gcc stack unwinding (from gcc 3.3)
7188 dnl ========================================================
7189 if test "$HAVE_GCC3_ABI" && test -z "$SKIP_LIBRARY_CHECKS"; then
7190     AC_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7193 dnl ========================================================
7194 dnl =
7195 dnl = Misc. Options
7196 dnl = 
7197 dnl ========================================================
7198 MOZ_ARG_HEADER(Misc. Options)
7200 dnl ========================================================
7201 dnl update xterm title
7202 dnl ========================================================
7203 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7204 [  --enable-xterm-updates  Update XTERM titles with current command.],
7205     MOZ_UPDATE_XTERM=1,
7206     MOZ_UPDATE_XTERM= )
7208 dnl =========================================================
7209 dnl = Chrome format
7210 dnl =========================================================
7211 MOZ_ARG_ENABLE_STRING([chrome-format],
7212 [  --enable-chrome-format=jar|flat|both|symlink
7213                           Select FORMAT of chrome files (default=jar)],
7214     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7216 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7217     MOZ_CHROME_FILE_FORMAT=jar
7220 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" && 
7221     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7222     test "$MOZ_CHROME_FILE_FORMAT" != "symlink" &&
7223     test "$MOZ_CHROME_FILE_FORMAT" != "both"; then
7224     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, or symlink])
7227 if test "$MOZ_CHROME_FILE_FORMAT" = "jar"; then
7228    AC_DEFINE(MOZ_CHROME_FILE_FORMAT_JAR)
7230 dnl ========================================================
7231 dnl = Define default location for MOZILLA_FIVE_HOME
7232 dnl ========================================================
7233 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7234 [  --with-default-mozilla-five-home
7235                           Set the default value for MOZILLA_FIVE_HOME],
7236 [ val=`echo $withval`
7237   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7239 dnl ========================================================
7240 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7241 dnl ========================================================
7242 MOZ_ARG_WITH_STRING(user-appdir,
7243 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7244 [ val=`echo $withval`
7245 if echo "$val" | grep "\/" >/dev/null; then
7246     AC_MSG_ERROR("Homedir must be single relative path.")
7247 else 
7248     MOZ_USER_DIR="$val"
7249 fi])
7251 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7253 dnl ========================================================
7254 dnl = Doxygen configuration
7255 dnl ========================================================
7256 dnl Use commas to specify multiple dirs to this arg
7257 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7258 MOZ_ARG_WITH_STRING(doc-input-dirs,
7259 [  --with-doc-input-dirs=DIRS
7260                           Header/idl dirs to create docs from],
7261 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7262 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7264 dnl Use commas to specify multiple dirs to this arg
7265 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7266 MOZ_ARG_WITH_STRING(doc-include-dirs,
7267 [  --with-doc-include-dirs=DIRS  
7268                           Include dirs to preprocess doc headers],
7269 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7270 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7272 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7273 MOZ_ARG_WITH_STRING(doc-output-dir,
7274 [  --with-doc-output-dir=DIR
7275                           Dir to generate docs into],
7276 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7277 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7279 if test -z "$SKIP_COMPILER_CHECKS"; then
7280 dnl ========================================================
7281 dnl =
7282 dnl = Compiler Options
7283 dnl = 
7284 dnl ========================================================
7285 MOZ_ARG_HEADER(Compiler Options)
7287 dnl ========================================================
7288 dnl Check for gcc -pipe support
7289 dnl ========================================================
7290 AC_MSG_CHECKING([for gcc -pipe support])
7291 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
7292     echo '#include <stdio.h>' > dummy-hello.c
7293     echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c
7294     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
7295     cat dummy-hello.s 2> /dev/null | ${AS_BIN} -o dummy-hello.S - 2>&5
7296     if test $? = 0; then
7297         _res_as_stdin="yes"
7298     else
7299         _res_as_stdin="no"
7300     fi
7301     if test "$_res_as_stdin" = "yes"; then
7302         _SAVE_CFLAGS=$CFLAGS
7303         CFLAGS="$CFLAGS -pipe"
7304         AC_TRY_COMPILE( [ #include <stdio.h> ],
7305             [printf("Hello World\n");],
7306             [_res_gcc_pipe="yes"],
7307             [_res_gcc_pipe="no"] )
7308         CFLAGS=$_SAVE_CFLAGS
7309     fi
7310     if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
7311         _res="yes";
7312         CFLAGS="$CFLAGS -pipe"
7313         CXXFLAGS="$CXXFLAGS -pipe"
7314     else
7315         _res="no"
7316     fi
7317     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
7318     AC_MSG_RESULT([$_res])
7319 else
7320     AC_MSG_RESULT([no])
7323 dnl pass -Wno-long-long to the compiler
7324 MOZ_ARG_ENABLE_BOOL(long-long-warning,
7325 [  --enable-long-long-warning 
7326                           Warn about use of non-ANSI long long type],
7327     _IGNORE_LONG_LONG_WARNINGS=,
7328     _IGNORE_LONG_LONG_WARNINGS=1)
7330 if test "$_IGNORE_LONG_LONG_WARNINGS"; then
7331      _SAVE_CFLAGS="$CFLAGS"
7332      CFLAGS="$CFLAGS ${_COMPILER_PREFIX}-Wno-long-long"
7333      AC_MSG_CHECKING([whether compiler supports -Wno-long-long])
7334      AC_TRY_COMPILE([], [return(0);], 
7335         [ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} ${_COMPILER_PREFIX}-Wno-long-long"
7336           _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-long-long"
7337           result="yes" ], result="no")
7338      AC_MSG_RESULT([$result])
7339      CFLAGS="$_SAVE_CFLAGS"
7342 dnl ========================================================
7343 dnl Profile guided optimization
7344 dnl ========================================================
7345 dnl Test for profiling options
7346 dnl Under gcc 3.3, use -fprofile-arcs/-fbranch-probabilities
7347 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7349 dnl Provide a switch to disable PGO even when called via profiledbuild.
7350 MOZ_ARG_DISABLE_BOOL(profile-guided-optimization,
7351 [  --disable-profile-guided-optimization
7352                            Don't build with PGO even if called via make profiledbuild],
7353 MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=1,
7354 MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=)
7356 AC_SUBST(MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE)
7358 _SAVE_CFLAGS="$CFLAGS"
7359 CFLAGS="$CFLAGS -fprofile-generate"
7361 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7362 AC_TRY_COMPILE([], [return 0;],
7363                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7364                  result="yes" ], result="no")
7365 AC_MSG_RESULT([$result])
7367 if test $result = "yes"; then
7368   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7369   PROFILE_USE_CFLAGS="-fprofile-use"
7370   PROFILE_USE_LDFLAGS="-fprofile-use"
7371 else
7372   CFLAGS="$_SAVE_CFLAGS -fprofile-arcs"
7373   AC_MSG_CHECKING([whether C compiler supports -fprofile-arcs])
7374   AC_TRY_COMPILE([], [return 0;],
7375                  [ PROFILE_GEN_CFLAGS="-fprofile-arcs"
7376                    result="yes" ], result="no")
7377   AC_MSG_RESULT([$result])
7378   if test $result = "yes"; then
7379     PROFILE_USE_CFLAGS="-fbranch-probabilities"
7380   fi
7381   # don't really care, this is an old GCC
7382   PROFILE_GEN_LDFLAGS=
7383   PROFILE_USE_LDFLAGS=
7386 CFLAGS="$_SAVE_CFLAGS"
7388 if test -n "$INTEL_CC"; then
7389   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7390   PROFILE_GEN_LDFLAGS=
7391   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7392   PROFILE_USE_LDFLAGS=
7395 dnl Sun Studio on Solaris
7396 if test "$SOLARIS_SUNPRO_CC"; then
7397   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7398   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7399   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7400   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7403 AC_SUBST(PROFILE_GEN_CFLAGS)
7404 AC_SUBST(PROFILE_GEN_LDFLAGS)
7405 AC_SUBST(PROFILE_USE_CFLAGS)
7406 AC_SUBST(PROFILE_USE_LDFLAGS)
7408 AC_LANG_CPLUSPLUS
7410 dnl ========================================================
7411 dnl Test for -pedantic bustage
7412 dnl ========================================================
7413 MOZ_ARG_DISABLE_BOOL(pedantic,
7414 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],
7415 _PEDANTIC= )
7416 if test "$_PEDANTIC"; then
7417     _SAVE_CXXFLAGS=$CXXFLAGS
7418     CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic"
7419     AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
7420     AC_TRY_COMPILE([$configure_static_assert_macros],
7421                    [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
7422                    result="no", result="yes" )
7423     AC_MSG_RESULT([$result])
7424     CXXFLAGS="$_SAVE_CXXFLAGS"
7426     case "$result" in
7427     no)
7428         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} ${_COMPILER_PREFIX}-pedantic"
7429         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic"
7430         ;;
7431     yes)
7432         AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic.  Reconfigure using --disable-pedantic. ])
7433         ;;
7434     esac
7437 dnl ========================================================
7438 dnl Test for correct temporary object destruction order
7439 dnl ========================================================
7440 dnl We want to make sure the compiler follows the C++ spec here as 
7441 dnl xpcom and the string classes depend on it (bug 235381).
7442 AC_MSG_CHECKING([for correct temporary object destruction order])
7443 AC_TRY_RUN([ class A {
7444              public:  A(int& x) : mValue(x) {}
7445                       ~A() { mValue--; }
7446                       operator char**() { return 0; }
7447              private:  int& mValue;
7448              };
7449              void func(char **arg) {}
7450              int m=2;
7451              void test() {
7452                   func(A(m));
7453                   if (m==1) m = 0;
7454              }
7455              int main() {
7456                  test();
7457                  return(m);
7458              }
7459              ],
7460      result="yes", result="no", result="maybe")
7461 AC_MSG_RESULT([$result])
7463 if test "$result" = "no"; then
7464     AC_MSG_ERROR([Your compiler does not follow the C++ specification for temporary object destruction order.])
7467 dnl ========================================================
7468 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7469 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7470 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7471 dnl ========================================================
7472 _SAVE_CXXFLAGS=$CXXFLAGS
7473 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7474 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7475     ac_nscap_nonconst_opeq_bug,
7476     [AC_TRY_COMPILE([
7477                       template <class T>
7478                       class Pointer
7479                         {
7480                         public:
7481                           T* myPtr;
7482                         };
7483                       
7484                       template <class T, class U>
7485                       int operator==(const Pointer<T>& rhs, U* lhs)
7486                         {
7487                           return rhs.myPtr == lhs;
7488                         }
7489                       
7490                       template <class T, class U>
7491                       int operator==(const Pointer<T>& rhs, const U* lhs)
7492                         {
7493                           return rhs.myPtr == lhs;
7494                         }
7495                     ],
7496                     [
7497                       Pointer<int> foo;
7498                       const int* bar;
7499                       return foo == bar;
7500                     ],
7501                     ac_nscap_nonconst_opeq_bug="no",
7502                     ac_nscap_nonconst_opeq_bug="yes")])
7503 CXXFLAGS="$_SAVE_CXXFLAGS"
7505 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7506     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7508 fi # SKIP_COMPILER_CHECKS
7510 dnl ========================================================
7511 dnl C++ rtti
7512 dnl Should be smarter and check that the compiler does indeed have rtti
7513 dnl ========================================================
7515 MOZ_ARG_ENABLE_BOOL(cpp-rtti,
7516 [  --enable-cpp-rtti       Enable C++ RTTI ],
7517 [ _MOZ_USE_RTTI=1 ],
7518 [ _MOZ_USE_RTTI= ])
7520 if test "$_MOZ_USE_RTTI"; then
7521    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_ON
7522 else
7523    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_OFF
7526 AC_SUBST(_MOZ_RTTI_FLAGS_ON)
7528 dnl ========================================================
7529 dnl C++ exceptions (g++/egcs only - for now)
7530 dnl Should be smarter and check that the compiler does indeed have exceptions
7531 dnl ========================================================
7532 MOZ_ARG_ENABLE_BOOL(cpp-exceptions,
7533 [  --enable-cpp-exceptions Enable C++ exceptions ],
7534 [ _MOZ_CPP_EXCEPTIONS=1 ],
7535 [ _MOZ_CPP_EXCEPTIONS= ])
7537 if test "$_MOZ_CPP_EXCEPTIONS"; then
7538     _MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_ON
7539 else
7540     _MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_OFF
7543 AC_SUBST(_MOZ_EXCEPTIONS_FLAGS_ON)
7545 # Irix & OSF native compilers do not like exception declarations 
7546 # when exceptions are disabled
7547 if test -n "$MIPSPRO_CXX" -o -n "$COMPAQ_CXX" -o -n "$VACPP"; then
7548     AC_DEFINE(CPP_THROW_NEW, [])
7549 else
7550     AC_DEFINE(CPP_THROW_NEW, [throw()])
7552 AC_LANG_C
7554 dnl ========================================================
7555 dnl =
7556 dnl = Build depencency options
7557 dnl =
7558 dnl ========================================================
7559 MOZ_ARG_HEADER(Build dependencies)
7561 dnl ========================================================
7562 dnl = Do not auto generate dependency info
7563 dnl ========================================================
7564 MOZ_AUTO_DEPS=1
7565 MOZ_ARG_DISABLE_BOOL(auto-deps,
7566 [  --disable-auto-deps     Do not automatically generate dependency info],
7567     MOZ_AUTO_DEPS=,
7568     MOZ_AUTO_DEPS=1)
7570 if test -n "$MOZ_AUTO_DEPS"; then
7571 dnl ========================================================
7572 dnl = Use mkdepend instead of $CC -MD for dependency generation
7573 dnl ========================================================
7574 _cpp_md_flag=
7575 MOZ_ARG_DISABLE_BOOL(md,
7576 [  --disable-md            Do not use compiler-based dependencies ],
7577   [_cpp_md_flag=],
7578   [_cpp_md_flag=1],
7579   [dnl Default is to turn on -MD if using GNU-compatible compilers
7580    if test "$GNU_CC" -a "$GNU_CXX" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "WINCE"; then
7581      _cpp_md_flag=1
7582    fi
7583   dnl Default is to use -xM if using Sun Studio on Solaris
7584    if test "$SOLARIS_SUNPRO_CC"; then
7585      _cpp_md_flag=1
7586    fi])
7587 if test "$_cpp_md_flag"; then
7588   COMPILER_DEPEND=1
7589   if test "$OS_ARCH" = "OpenVMS"; then
7590     _DEPEND_CFLAGS='$(subst =, ,$(filter-out %/.pp,-MM=-MD=-MF=$(MDDEPDIR)/$(basename $(@F)).pp))'
7591   else
7592     _DEPEND_CFLAGS='$(filter-out %/.pp,-Wp,-MD,$(MDDEPDIR)/$(basename $(@F)).pp)'
7593   fi
7594   dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7595   if test "$SOLARIS_SUNPRO_CC"; then
7596     _DEPEND_CFLAGS=
7597   fi
7598 else
7599   COMPILER_DEPEND=
7600   dnl Don't override this for MSVC
7601   if test -z "$_WIN32_MSVC"; then
7602     _USE_CPP_INCLUDE_FLAG=
7603     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7604     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7605   fi
7607 fi # MOZ_AUTO_DEPS
7608 MDDEPDIR='.deps'
7609 AC_SUBST(MOZ_AUTO_DEPS)
7610 AC_SUBST(COMPILER_DEPEND)
7611 AC_SUBST(MDDEPDIR)
7614 dnl ========================================================
7615 dnl =
7616 dnl = Static Build Options
7617 dnl =
7618 dnl ========================================================
7619 MOZ_ARG_HEADER(Static build options)
7621 MOZ_ARG_ENABLE_BOOL(static,
7622 [  --enable-static         Enable building of internal static libs],
7623     BUILD_STATIC_LIBS=1,
7624     BUILD_STATIC_LIBS=)
7626 MOZ_ARG_ENABLE_BOOL(libxul,
7627 [  --enable-libxul         Enable building of libxul],
7628     MOZ_ENABLE_LIBXUL=1,
7629     MOZ_ENABLE_LIBXUL=)
7631 if test -n "$MOZ_STATIC_BUILD_UNSUPPORTED" -a -n "$BUILD_STATIC_LIBS"; then
7632         AC_MSG_ERROR([--enable-static is not supported for building $MOZ_APP_NAME. You probably want --enable-libxul.])
7635 if test -n "$MOZ_ENABLE_LIBXUL" -a -n "$BUILD_STATIC_LIBS"; then
7636         AC_MSG_ERROR([--enable-libxul is not compatible with --enable-static])
7639 if test -n "$MOZ_IPC" -a -z "$MOZ_ENABLE_LIBXUL"; then
7640     AC_MSG_ERROR([--enable-ipc requires --enable-libxul])
7643 AC_SUBST(LIBXUL_LIBS)
7645 if test -n "$MOZ_ENABLE_LIBXUL"; then
7646     XPCOM_LIBS="$LIBXUL_LIBS"
7647     AC_DEFINE(MOZ_ENABLE_LIBXUL)
7648 else
7649     if test -n "$BUILD_STATIC_LIBS"; then
7650         AC_DEFINE(MOZ_STATIC_BUILD)
7651     fi
7652     XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS"
7655 dnl ========================================================
7656 dnl =
7657 dnl = Standalone module options
7658 dnl = 
7659 dnl ========================================================
7660 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7662 dnl Check for GLib and libIDL.
7663 dnl ========================================================
7664 case "$target_os" in
7665 msvc*|mks*|cygwin*|mingw*|wince*|winmo*)
7666     SKIP_IDL_CHECK="yes"
7667     ;;
7669     SKIP_IDL_CHECK="no"
7670     ;;
7671 esac
7673 if test -z "$COMPILE_ENVIRONMENT"; then
7674     SKIP_IDL_CHECK="yes"
7677 dnl = Allow users to disable libIDL checking for standalone modules
7678 MOZ_ARG_WITHOUT_BOOL(libIDL,
7679 [  --without-libIDL        Skip check for libIDL (standalone modules only)],
7680         SKIP_IDL_CHECK="yes")
7682 if test "$SKIP_IDL_CHECK" = "no"
7683 then
7684     _LIBIDL_FOUND=
7685     if test "$MACOS_SDK_DIR"; then 
7686       dnl xpidl, and therefore libIDL, is only needed on the build host.
7687       dnl Don't build it against the SDK, as that causes problems.
7688       _MACSAVE_CFLAGS="$CFLAGS"
7689       _MACSAVE_LIBS="$LIBS"
7690       _MACSAVE_LDFLAGS="$LDFLAGS"
7691       _MACSAVE_NEXT_ROOT="$NEXT_ROOT"
7692       changequote(,)
7693       CFLAGS=`echo $CFLAGS|sed -E -e "s%((-I|-isystem )${MACOS_SDK_DIR}/usr/(include|lib/gcc)[^ ]*)|-F${MACOS_SDK_DIR}(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*|-isysroot ${MACOS_SDK_DIR}%%g"`
7694       LIBS=`echo $LIBS|sed -e "s?-L${MACOS_SDK_DIR}/usr/lib[^ ]*??g"`
7695       LDFLAGS=`echo $LDFLAGS|sed -e "s?-Wl,-syslibroot,${MACOS_SDK_DIR}??g"`
7696       changequote([,])
7697       unset NEXT_ROOT
7698     fi
7700     if test "$MOZ_ENABLE_GTK2"; then
7701         PKG_CHECK_MODULES(LIBIDL, libIDL-2.0 >= 0.8.0 glib-2.0 gobject-2.0, _LIBIDL_FOUND=1,_LIBIDL_FOUND=)
7702     fi
7703     dnl if no gtk/libIDL1 or gtk2/libIDL2 combination was found, fall back
7704     dnl to either libIDL1 or libIDL2.
7705     if test -z "$_LIBIDL_FOUND"; then
7706         AM_PATH_LIBIDL($LIBIDL_VERSION,_LIBIDL_FOUND=1)
7707         if test -z "$_LIBIDL_FOUND"; then
7708             PKG_CHECK_MODULES(LIBIDL, libIDL-2.0 >= 0.8.0,_LIBIDL_FOUND=1)
7709         fi
7710     fi
7711     dnl
7712     dnl If we don't have a libIDL config program & not cross-compiling, 
7713     dnl     look for orbit-config instead.
7714     dnl
7715     if test -z "$_LIBIDL_FOUND" && test -z "$CROSS_COMPILE"; then
7716         MOZ_PATH_PROGS(ORBIT_CONFIG, $ORBIT_CONFIG orbit-config)
7717         if test -n "$ORBIT_CONFIG"; then
7718             AC_MSG_CHECKING([for ORBit libIDL usability])
7719                 _ORBIT_CFLAGS=`${ORBIT_CONFIG} client --cflags`
7720             _ORBIT_LIBS=`${ORBIT_CONFIG} client --libs`
7721             _ORBIT_INC_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-I/); } }' -- ${_ORBIT_CFLAGS}`
7722             _ORBIT_LIB_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-L/); } }' -- ${_ORBIT_LIBS}`
7723             LIBIDL_CFLAGS="$_ORBIT_INC_PATH"
7724             LIBIDL_LIBS="$_ORBIT_LIB_PATH -lIDL -lglib"
7725             LIBIDL_CONFIG=
7726             _SAVE_CFLAGS="$CFLAGS"
7727             _SAVE_LIBS="$LIBS"
7728             CFLAGS="$LIBIDL_CFLAGS $CFLAGS"
7729             LIBS="$LIBIDL_LIBS $LIBS"
7730             AC_TRY_RUN([
7731 #include <stdlib.h>
7732 #include <libIDL/IDL.h>
7733 int main() {
7734   char *s;
7735   s=strdup(IDL_get_libver_string());
7736   if(s==NULL) {
7737     exit(1);
7738   }
7739   exit(0);
7741             ], [_LIBIDL_FOUND=1
7742                 result="yes"],
7743                [LIBIDL_CFLAGS=
7744                 LIBIDL_LIBS=
7745                 result="no"],
7746                [_LIBIDL_FOUND=1
7747                 result="maybe"] )
7748             AC_MSG_RESULT($result)
7749             CFLAGS="$_SAVE_CFLAGS"
7750             LIBS="$_SAVE_LIBS"
7751         fi
7752     fi
7753     if test -z "$_LIBIDL_FOUND"; then
7754         AC_MSG_ERROR([libIDL not found.
7755         libIDL $LIBIDL_VERSION or higher is required.])
7756     fi
7757     if test "$MACOS_SDK_DIR"; then
7758       CFLAGS="$_MACSAVE_CFLAGS"
7759       LIBS="$_MACSAVE_LIBS"
7760       LDFLAGS="$_MACSAVE_LDFLAGS"
7761       if test -n "$_MACSAVE_NEXT_ROOT" ; then
7762         export NEXT_ROOT="$_MACSAVE_NEXT_ROOT"
7763       fi
7764     fi
7767 if test -n "$CROSS_COMPILE"; then
7768      if test -z "$HOST_LIBIDL_CONFIG"; then
7769         HOST_LIBIDL_CONFIG="$LIBIDL_CONFIG"
7770     fi
7771     if test -n "$HOST_LIBIDL_CONFIG" && test "$HOST_LIBIDL_CONFIG" != "no"; then
7772         HOST_LIBIDL_CFLAGS=`${HOST_LIBIDL_CONFIG} --cflags`
7773         HOST_LIBIDL_LIBS=`${HOST_LIBIDL_CONFIG} --libs`
7774     else
7775         HOST_LIBIDL_CFLAGS="$LIBIDL_CFLAGS"
7776         HOST_LIBIDL_LIBS="$LIBIDL_LIBS"
7777     fi
7780 if test -z "$SKIP_PATH_CHECKS"; then
7781 if test -z "${GLIB_CFLAGS}" || test -z "${GLIB_LIBS}" ; then
7782     if test "$MOZ_ENABLE_GTK2" || test "$USE_ELF_DYNSTR_GC" ; then
7783         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
7784     else
7785         AM_PATH_GLIB(${GLIB_VERSION})
7786     fi
7790 if test -z "${GLIB_GMODULE_LIBS}" -a -n "${GLIB_CONFIG}"; then
7791     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
7794 AC_SUBST(LIBIDL_CFLAGS)
7795 AC_SUBST(LIBIDL_LIBS)
7796 AC_SUBST(STATIC_LIBIDL)
7797 AC_SUBST(GLIB_CFLAGS)
7798 AC_SUBST(GLIB_LIBS)
7799 AC_SUBST(GLIB_GMODULE_LIBS)
7800 AC_SUBST(HOST_LIBIDL_CONFIG)
7801 AC_SUBST(HOST_LIBIDL_CFLAGS)
7802 AC_SUBST(HOST_LIBIDL_LIBS)
7804 dnl ========================================================
7805 dnl Check for cairo
7806 dnl ========================================================
7807 MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
7809 MOZ_TREE_CAIRO=1
7810 MOZ_ARG_ENABLE_BOOL(system-cairo,
7811 [ --enable-system-cairo Use system cairo (located with pkgconfig)],
7812 MOZ_TREE_CAIRO=,
7813 MOZ_TREE_CAIRO=1 )
7815 # Check for headers defining standard int types.
7816 AC_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
7818 if test "$MOZ_TREE_CAIRO"; then
7819     AC_DEFINE(MOZ_TREE_CAIRO)
7821     # For now we assume that we will have a uint64_t available through
7822     # one of the above headers or mozstdint.h.
7823     AC_DEFINE(HAVE_UINT64_T)
7825     # Define macros for cairo-features.h
7826     if test "$MOZ_X11"; then
7827         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
7828         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
7829         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
7830         PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
7831         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
7832         MOZ_ENABLE_CAIRO_FT=1
7833         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
7834     fi
7835     if test "$MOZ_WIDGET_TOOLKIT" = "qt"; then
7836         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
7837     fi
7838     if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
7839         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
7840         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
7841         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
7842     fi
7843     if test "$MOZ_WIDGET_TOOLKIT" = "windows"; then
7844         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
7845         if test -z "$WINCE"; then
7846             WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
7847             if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
7848                 WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
7849                 WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
7850                 MOZ_ENABLE_D2D_SURFACE=1
7851                 MOZ_ENABLE_DWRITE_FONT=1
7852             else
7853                 WIN32_DWRITE_FONT_FEATURE=
7854                 WIN32_D2D_SURFACE_FEATURE=
7855             fi
7856         else
7857             WIN32_FONT_FEATURE=
7858             WIN32_DWRITE_FONT_FEATURE=
7859             WIN32_D2D_SURFACE_FEATURE=
7860         fi
7862         AC_TRY_COMPILE([#include <ddraw.h>], [int foo = DDLOCK_WAITNOTBUSY;], HAS_DDRAW=1, HAS_DDRAW=)
7863         if test -z "$HAS_DDRAW"; then
7864             AC_MSG_WARN([DirectDraw ddraw.h header not found or it's missing DDLOCK_WAITNOTBUSY, disabling DirectDraw surface.  If you have an older SDK (such as the CE5 SDK), try copying in ddraw.lib and ddraw.h from the WM6 SDK.])
7865             DDRAW_SURFACE_FEATURE=
7866         else
7867             DDRAW_SURFACE_FEATURE="#define CAIRO_HAS_DDRAW_SURFACE 1"
7868         fi
7870         if test -z "$OGLES_SDK_DIR"; then
7871             OGLES_SURFACE_FEATURE=
7872         else
7873             AC_TRY_COMPILE([
7874               #include <EGL/egl.h>
7875               #include <EGL/eglext.h>
7876               #include <GLES2/gl2.h>
7877               #include <GLES2/gl2ext.h>
7878             ], [ EGLDisplay _cairo_ddraw_egl_dpy = EGL_NO_DISPLAY;], HAS_OGLES=1, HAS_OGLES=)
7879             if test -z "$HAS_OGLES"; then
7880               AC_MSG_WARN([OpenGL ES2 headers not found, disabling OpenGL acceleration surfaces.])
7881               OGLES_SURFACE_FEATURE=
7882             else
7883               OGLES_SURFACE_FEATURE="#define CAIRO_DDRAW_USE_GL 1"
7884             fi
7885         fi
7887         PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
7888     fi
7889     if test "$MOZ_WIDGET_TOOLKIT" = "os2"; then
7890         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
7891         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
7892         PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
7893         MOZ_ENABLE_CAIRO_FT=1
7894         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
7895         CAIRO_FT_LIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
7896     fi
7897     if test "$MOZ_WIDGET_TOOLKIT" = "beos"; then
7898         PKG_CHECK_MODULES(CAIRO_FT, fontconfig freetype2)
7899         BEOS_SURFACE_FEATURE="#define CAIRO_HAS_BEOS_SURFACE 1"
7900         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
7901         MOZ_ENABLE_CAIRO_FT=1
7902     fi
7903     if test "$USE_FC_FREETYPE"; then
7904         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
7905     fi
7906     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
7907     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
7908     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
7909     AC_SUBST(CAIRO_FT_CFLAGS)
7910     AC_SUBST(HAS_OGLES)
7912     if test "$MOZ_DEBUG"; then
7913       SANITY_CHECKING_FEATURE="#define CAIRO_DO_SANITY_CHECKING 1"
7914     else
7915       SANITY_CHECKING_FEATURE="#undef CAIRO_DO_SANITY_CHECKING"
7916     fi
7918     PNG_FUNCTIONS_FEATURE="#define CAIRO_HAS_PNG_FUNCTIONS 1"
7920     AC_SUBST(PS_SURFACE_FEATURE)
7921     AC_SUBST(PDF_SURFACE_FEATURE)
7922     AC_SUBST(SVG_SURFACE_FEATURE)
7923     AC_SUBST(XLIB_SURFACE_FEATURE)
7924     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
7925     AC_SUBST(QUARTZ_SURFACE_FEATURE)
7926     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
7927     AC_SUBST(XCB_SURFACE_FEATURE)
7928     AC_SUBST(WIN32_SURFACE_FEATURE)
7929     AC_SUBST(DDRAW_SURFACE_FEATURE)
7930     AC_SUBST(OGLES_SURFACE_FEATURE)    
7931     AC_SUBST(OS2_SURFACE_FEATURE)
7932     AC_SUBST(BEOS_SURFACE_FEATURE)
7933     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
7934     AC_SUBST(FT_FONT_FEATURE)
7935     AC_SUBST(FC_FONT_FEATURE)
7936     AC_SUBST(WIN32_FONT_FEATURE)
7937     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
7938     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
7939     AC_SUBST(QUARTZ_FONT_FEATURE)
7940     AC_SUBST(PNG_FUNCTIONS_FEATURE)
7941     AC_SUBST(QT_SURFACE_FEATURE)
7943     if test "$_WIN32_MSVC"; then
7944         MOZ_CAIRO_LIBS='$(DEPTH)/gfx/cairo/cairo/src/mozcairo.lib $(DEPTH)/gfx/cairo/libpixman/src/mozlibpixman.lib'
7945     else
7946         MOZ_CAIRO_LIBS='$(DEPTH)/gfx/cairo/cairo/src/$(LIB_PREFIX)mozcairo.$(LIB_SUFFIX) $(DEPTH)/gfx/cairo/libpixman/src/$(LIB_PREFIX)mozlibpixman.$(LIB_SUFFIX)'" $CAIRO_FT_LIBS"
7948         if test "$MOZ_X11"; then
7949             MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS -lXrender -lfreetype -lfontconfig"
7950         fi
7951     fi
7953     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
7954     mv -f $CAIRO_FEATURES_H "$CAIRO_FEATURES_H".orig 2> /dev/null
7956 else
7957    PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION pixman-1 freetype2 fontconfig)
7958    MOZ_CAIRO_CFLAGS=$CAIRO_CFLAGS
7959    MOZ_CAIRO_LIBS=$CAIRO_LIBS
7960    if test "$MOZ_X11"; then
7961         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
7962         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
7963         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
7964    fi
7967 AC_SUBST(MOZ_TREE_CAIRO)
7968 AC_SUBST(MOZ_CAIRO_CFLAGS)
7969 AC_SUBST(MOZ_CAIRO_LIBS)
7971 dnl qcms
7972 dnl ========================================================
7974 QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
7975 AC_SUBST(QCMS_LIBS)
7977 dnl ========================================================
7978 dnl disable xul
7979 dnl ========================================================
7980 MOZ_ARG_DISABLE_BOOL(xul,
7981 [  --disable-xul           Disable XUL],
7982     MOZ_XUL= )
7983 if test "$MOZ_XUL"; then
7984   AC_DEFINE(MOZ_XUL)
7985 else
7986   dnl remove extensions that require XUL
7987   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
7990 AC_SUBST(MOZ_XUL)
7992 dnl ========================================================
7993 dnl disable profile locking
7994 dnl   do no use this in applications that can have more than
7995 dnl   one process accessing the profile directory.
7996 dnl ========================================================
7997 MOZ_ARG_DISABLE_BOOL(profilelocking,
7998 [  --disable-profilelocking           Disable profile locking],
7999     MOZ_PROFILELOCKING=,
8000     MOZ_PROFILELOCKING=1 )
8001 if test "$MOZ_PROFILELOCKING"; then
8002   AC_DEFINE(MOZ_PROFILELOCKING)
8005 dnl ========================================================
8006 dnl disable rdf services
8007 dnl ========================================================
8008 MOZ_ARG_DISABLE_BOOL(rdf,
8009 [  --disable-rdf           Disable RDF],
8010     MOZ_RDF= )
8011 if test "$MOZ_RDF"; then
8012   AC_DEFINE(MOZ_RDF)
8015 AC_SUBST(MOZ_RDF)
8017 dnl ========================================================
8018 dnl necko configuration options
8019 dnl ========================================================
8022 dnl option to disable various necko protocols
8024 MOZ_ARG_ENABLE_STRING(necko-protocols,
8025 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8026                           Enable/disable specific protocol handlers],
8027 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8028     if test "$option" = "yes" || test "$option" = "all"; then
8029         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8030     elif test "$option" = "no" || test "$option" = "none"; then
8031         NECKO_PROTOCOLS=""
8032     elif test "$option" = "default"; then
8033         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8034     elif test `echo "$option" | grep -c \^-` != 0; then
8035         option=`echo $option | sed 's/^-//'`
8036         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8037     else
8038         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8039     fi
8040 done],
8041     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8042 dnl Remove dupes
8043 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8044 AC_SUBST(NECKO_PROTOCOLS)
8045 for p in $NECKO_PROTOCOLS; do
8046     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8047 done
8050 dnl option to disable necko's disk cache
8052 MOZ_ARG_DISABLE_BOOL(necko-disk-cache,
8053 [  --disable-necko-disk-cache
8054                           Disable necko disk cache],
8055     NECKO_DISK_CACHE=,
8056     NECKO_DISK_CACHE=1)
8057 AC_SUBST(NECKO_DISK_CACHE)
8058 if test "$NECKO_DISK_CACHE"; then
8059     AC_DEFINE(NECKO_DISK_CACHE)
8063 dnl option to disable necko's wifi scanner
8065 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8066 [  --disable-necko-wifi   Disable necko wifi scanner],
8067     NECKO_WIFI=,
8068     NECKO_WIFI=1
8071 if test "$OS_ARCH" = "OS2"; then
8072   dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
8073   NECKO_WIFI=
8075 if test "$NECKO_WIFI" -a \
8076         "$OS_ARCH" != "Linux" -a \
8077         "$OS_ARCH" != "Darwin" -a \
8078         "$OS_ARCH" != "SunOS" -a \
8079         "$OS_ARCH" != "WINNT" -a \
8080         "$OS_ARCH" != "WINCE"; then
8081   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
8084 if test -z "$SKIP_LIBRARY_CHECKS" -a "$NECKO_WIFI" -a "$OS_ARCH" = "Linux"
8085 then
8086   AC_CHECK_HEADER([iwlib.h])
8087   if test "$ac_cv_header_iwlib_h" != "yes"; then
8088     AC_MSG_ERROR([Can't find header iwlib.h for Necko WiFi scanning (might be in package libiw-dev (Ubuntu) or wireless-tools-devel (Fedora)); use --disable-necko-wifi to disable])
8089   fi
8092 if test "$NECKO_WIFI"; then
8093   AC_DEFINE(NECKO_WIFI)
8095 AC_SUBST(NECKO_WIFI)
8098 dnl option to minimize size of necko's i/o buffers
8100 MOZ_ARG_ENABLE_BOOL(necko-small-buffers,
8101 [  --enable-necko-small-buffers
8102                           Minimize size of necko's i/o buffers],
8103     NECKO_SMALL_BUFFERS=1,
8104     NECKO_SMALL_BUFFERS=)
8105 AC_SUBST(NECKO_SMALL_BUFFERS)
8106 if test "$NECKO_SMALL_BUFFERS"; then
8107     AC_DEFINE(NECKO_SMALL_BUFFERS)
8108 fi 
8111 dnl option to disable cookies
8113 MOZ_ARG_DISABLE_BOOL(cookies,
8114 [  --disable-cookies       Disable cookie support],
8115     NECKO_COOKIES=,
8116     NECKO_COOKIES=1)
8117 AC_SUBST(NECKO_COOKIES)
8118 if test "$NECKO_COOKIES"; then
8119     AC_DEFINE(NECKO_COOKIES)
8123 dnl Build jsctypes on the platforms we can.
8125 AC_SUBST(BUILD_CTYPES)
8126 if test "$OS_ARCH" != "WINCE" -o `echo $OS_TEST | grep -ic arm` != 1; then
8127   BUILD_CTYPES=1
8128   AC_DEFINE(BUILD_CTYPES)
8131 dnl NECKO_ configuration options are not global
8132 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_"
8134 dnl Only build Mork if it's required
8135 AC_SUBST(MOZ_MORK)
8136 if test "$MOZ_MORK"; then
8137   AC_DEFINE(MOZ_MORK)
8140 dnl Build the lightweight Mork reader if required
8141 AC_SUBST(MOZ_MORKREADER)
8142 if test "$MOZ_MORKREADER"; then
8143   AC_DEFINE(MOZ_MORKREADER)
8146 dnl ========================================================
8147 if test "$MOZ_DEBUG" || test "$NS_TRACE_MALLOC"; then
8148     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8151 dnl ========================================================
8152 dnl =
8153 dnl = Maintainer debug option (no --enable equivalent)
8154 dnl =
8155 dnl ========================================================
8157 AC_SUBST(AR)
8158 AC_SUBST(AR_FLAGS)
8159 AC_SUBST(AR_LIST)
8160 AC_SUBST(AR_EXTRACT)
8161 AC_SUBST(AR_DELETE)
8162 AC_SUBST(AS)
8163 AC_SUBST(ASFLAGS)
8164 AC_SUBST(AS_DASH_C_FLAG)
8165 AC_SUBST(LD)
8166 AC_SUBST(RC)
8167 AC_SUBST(RCFLAGS)
8168 AC_SUBST(WINDRES)
8169 AC_SUBST(IMPLIB)
8170 AC_SUBST(FILTER)
8171 AC_SUBST(BIN_FLAGS)
8172 AC_SUBST(NS_USE_NATIVE)
8173 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8174 AC_SUBST(MOZ_UPDATE_XTERM)
8175 AC_SUBST(MINIMO)
8176 AC_SUBST(MOZ_PLATFORM_MAEMO)
8177 AC_SUBST(MOZ_AUTH_EXTENSION)
8178 AC_SUBST(MOZ_MATHML)
8179 AC_SUBST(MOZ_PERMISSIONS)
8180 AC_SUBST(MOZ_XTF)
8181 AC_SUBST(MOZ_NO_INSPECTOR_APIS)
8182 AC_SUBST(MOZ_PREF_EXTENSIONS)
8183 AC_SUBST(MOZ_SVG)
8184 AC_SUBST(MOZ_SMIL)
8185 AC_SUBST(MOZ_XSLT_STANDALONE)
8186 AC_SUBST(MOZ_JS_LIBS)
8187 AC_SUBST(MOZ_PSM)
8188 AC_SUBST(MOZ_DEBUG)
8189 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8190 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8191 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8192 AC_SUBST(MOZ_DEBUG_FLAGS)
8193 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8194 AC_SUBST(WARNINGS_AS_ERRORS)
8195 AC_SUBST(MOZ_EXTENSIONS)
8196 AC_SUBST(MOZ_IMG_DECODERS)
8197 AC_SUBST(MOZ_IMG_ENCODERS)
8198 AC_SUBST(MOZ_JSDEBUGGER)
8199 AC_SUBST(MOZ_PLUGINS)
8200 AC_SUBST(MOZ_LOG_REFCNT)
8201 AC_SUBST(MOZ_LEAKY)
8202 AC_SUBST(MOZ_JPROF)
8203 AC_SUBST(MOZ_SHARK)
8204 AC_SUBST(MOZ_CALLGRIND)
8205 AC_SUBST(MOZ_VTUNE)
8206 AC_SUBST(MOZ_XPCTOOLS)
8207 AC_SUBST(MOZ_JSLOADER)
8208 AC_SUBST(MOZ_USE_NATIVE_UCONV)
8209 AC_SUBST(MOZ_INSURE)
8210 AC_SUBST(MOZ_INSURE_DIRS)
8211 AC_SUBST(MOZ_INSURE_EXCLUDE_DIRS)
8212 AC_SUBST(MOZ_QUANTIFY)
8213 AC_SUBST(MOZ_INSURIFYING)
8214 AC_SUBST(LIBICONV)
8215 AC_SUBST(MOZ_PLACES)
8216 AC_SUBST(MOZ_PLACES_BOOKMARKS)
8217 AC_SUBST(MOZ_STORAGE)
8218 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8219 AC_SUBST(MOZ_FEEDS)
8220 AC_SUBST(NS_PRINTING)
8221 AC_SUBST(MOZ_WEBGL)
8223 AC_SUBST(MOZ_JAVAXPCOM)
8224 AC_SUBST(JAVA_INCLUDE_PATH)
8225 AC_SUBST(JAVA)
8226 AC_SUBST(JAVAC)
8227 AC_SUBST(JAR)
8229 AC_SUBST(MOZ_PROFILELOCKING)
8231 AC_SUBST(HAVE_XIE)
8232 AC_SUBST(MOZ_XIE_LIBS)
8233 AC_SUBST(MOZ_ENABLE_POSTSCRIPT)
8235 AC_SUBST(BUILD_STATIC_LIBS)
8236 AC_SUBST(MOZ_ENABLE_LIBXUL)
8237 AC_SUBST(ENABLE_TESTS)
8238 AC_SUBST(IBMBIDI)
8239 AC_SUBST(MOZ_UNIVERSALCHARDET)
8240 AC_SUBST(ACCESSIBILITY)
8241 AC_SUBST(MOZ_XPINSTALL)
8242 AC_SUBST(MOZ_VIEW_SOURCE)
8243 AC_SUBST(MOZ_SPELLCHECK)
8244 AC_SUBST(MOZ_XPFE_COMPONENTS)
8245 AC_SUBST(MOZ_USER_DIR)
8246 AC_SUBST(MOZ_CRASHREPORTER)
8248 AC_SUBST(ENABLE_STRIP)
8249 AC_SUBST(PKG_SKIP_STRIP)
8250 AC_SUBST(USE_ELF_DYNSTR_GC)
8251 AC_SUBST(INCREMENTAL_LINKER)
8252 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8253 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8255 AC_SUBST(MOZ_FIX_LINK_PATHS)
8256 AC_SUBST(XPCOM_LIBS)
8257 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8258 AC_SUBST(XPCOM_GLUE_LDOPTS)
8259 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8261 AC_SUBST(USE_DEPENDENT_LIBS)
8263 AC_SUBST(MOZ_BUILD_ROOT)
8264 AC_SUBST(MOZ_OS2_TOOLS)
8265 AC_SUBST(MOZ_OS2_USE_DECLSPEC)
8267 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8268 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8269 AC_SUBST(MOZ_TIMELINE)
8270 AC_SUBST(OGLES_SDK_DIR)
8272 AC_SUBST(MOZ_APP_NAME)
8273 AC_SUBST(MOZ_APP_DISPLAYNAME)
8274 AC_SUBST(MOZ_APP_VERSION)
8275 AC_SUBST(MOZ_APP_UA_EXTRA)
8276 AC_SUBST(FIREFOX_VERSION)
8278 AC_SUBST(MOZ_PKG_SPECIAL)
8280 AC_SUBST(MOZILLA_OFFICIAL)
8282 dnl win32 options
8283 AC_SUBST(MOZ_MAPINFO)
8284 AC_SUBST(MOZ_BROWSE_INFO)
8285 AC_SUBST(MOZ_TOOLS_DIR)
8286 AC_SUBST(CYGWIN_WRAPPER)
8287 AC_SUBST(AS_PERL)
8288 AC_SUBST(WIN32_REDIST_DIR)
8289 AC_SUBST(PYTHON)
8291 AC_SUBST(WINCE)
8292 AC_SUBST(WINCE_SDK_DIR)
8293 AC_SUBST(WINCE_WINDOWS_MOBILE)
8295 dnl Echo the CFLAGS to remove extra whitespace.
8296 CFLAGS=`echo \
8297         $_WARNINGS_CFLAGS \
8298         $CFLAGS`
8300 CXXFLAGS=`echo \
8301         $_MOZ_RTTI_FLAGS \
8302         $_MOZ_EXCEPTIONS_FLAGS \
8303         $_WARNINGS_CXXFLAGS \
8304         $CXXFLAGS`
8306 COMPILE_CFLAGS=`echo \
8307     $_DEFINES_CFLAGS \
8308         $_DEPEND_CFLAGS \
8309     $COMPILE_CFLAGS`
8311 COMPILE_CXXFLAGS=`echo \
8312     $_DEFINES_CXXFLAGS \
8313         $_DEPEND_CFLAGS \
8314     $COMPILE_CXXFLAGS`
8316 AC_SUBST(SYSTEM_MAKEDEPEND)
8317 AC_SUBST(SYSTEM_LIBXUL)
8318 AC_SUBST(SYSTEM_JPEG)
8319 AC_SUBST(SYSTEM_PNG)
8320 AC_SUBST(SYSTEM_ZLIB)
8321 AC_SUBST(SYSTEM_BZ2)
8323 AC_SUBST(JPEG_CFLAGS)
8324 AC_SUBST(JPEG_LIBS)
8325 AC_SUBST(ZLIB_CFLAGS)
8326 AC_SUBST(ZLIB_LIBS)
8327 AC_SUBST(BZ2_CFLAGS)
8328 AC_SUBST(BZ2_LIBS)
8329 AC_SUBST(PNG_CFLAGS)
8330 AC_SUBST(PNG_LIBS)
8332 AC_SUBST(MOZ_JPEG_CFLAGS)
8333 AC_SUBST(MOZ_JPEG_LIBS)
8334 AC_SUBST(MOZ_ZLIB_CFLAGS)
8335 AC_SUBST(MOZ_ZLIB_LIBS)
8336 AC_SUBST(MOZ_BZ2_CFLAGS)
8337 AC_SUBST(MOZ_BZ2_LIBS)
8338 AC_SUBST(MOZ_PNG_CFLAGS)
8339 AC_SUBST(MOZ_PNG_LIBS)
8341 AC_SUBST(NSPR_CFLAGS)
8342 AC_SUBST(NSPR_LIBS)
8343 AC_SUBST(MOZ_NATIVE_NSPR)
8345 AC_SUBST(NSS_CFLAGS)
8346 AC_SUBST(NSS_LIBS)
8347 AC_SUBST(NSS_DEP_LIBS)
8348 AC_SUBST(MOZ_NATIVE_NSS)
8349 AC_SUBST(NSS_DISABLE_DBM)
8351 AC_SUBST(CFLAGS)
8352 AC_SUBST(CXXFLAGS)
8353 AC_SUBST(CPPFLAGS)
8354 AC_SUBST(COMPILE_CFLAGS)
8355 AC_SUBST(COMPILE_CXXFLAGS)
8356 AC_SUBST(LDFLAGS)
8357 AC_SUBST(LIBS)
8358 AC_SUBST(CROSS_COMPILE)
8359 AC_SUBST(WCHAR_CFLAGS)
8361 AC_SUBST(HOST_CC)
8362 AC_SUBST(HOST_CXX)
8363 AC_SUBST(HOST_CFLAGS)
8364 AC_SUBST(HOST_CXXFLAGS)
8365 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8366 AC_SUBST(HOST_AR)
8367 AC_SUBST(HOST_AR_FLAGS)
8368 AC_SUBST(HOST_LD)
8369 AC_SUBST(HOST_RANLIB)
8370 AC_SUBST(HOST_NSPR_MDCPUCFG)
8371 AC_SUBST(HOST_BIN_SUFFIX)
8372 AC_SUBST(HOST_OS_ARCH)
8374 AC_SUBST(TARGET_CPU)
8375 AC_SUBST(TARGET_VENDOR)
8376 AC_SUBST(TARGET_OS)
8377 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8378 AC_SUBST(TARGET_MD_ARCH)
8379 AC_SUBST(TARGET_XPCOM_ABI)
8380 AC_SUBST(OS_TARGET)
8381 AC_SUBST(OS_ARCH)
8382 AC_SUBST(OS_RELEASE)
8383 AC_SUBST(OS_TEST)
8385 AC_SUBST(MOZ_DISABLE_JAR_PACKAGING)
8386 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8388 AC_SUBST(WRAP_MALLOC_CFLAGS)
8389 AC_SUBST(WRAP_MALLOC_LIB)
8390 AC_SUBST(MKSHLIB)
8391 AC_SUBST(MKCSHLIB)
8392 AC_SUBST(MKSHLIB_FORCE_ALL)
8393 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8394 AC_SUBST(DSO_CFLAGS)
8395 AC_SUBST(DSO_PIC_CFLAGS)
8396 AC_SUBST(DSO_LDOPTS)
8397 AC_SUBST(LIB_PREFIX)
8398 AC_SUBST(DLL_PREFIX)
8399 AC_SUBST(DLL_SUFFIX)
8400 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8401 AC_SUBST(LIB_SUFFIX)
8402 AC_SUBST(OBJ_SUFFIX)
8403 AC_SUBST(BIN_SUFFIX)
8404 AC_SUBST(ASM_SUFFIX)
8405 AC_SUBST(IMPORT_LIB_SUFFIX)
8406 AC_SUBST(USE_N32)
8407 AC_SUBST(CC_VERSION)
8408 AC_SUBST(CXX_VERSION)
8409 AC_SUBST(MSMANIFEST_TOOL)
8410 AC_SUBST(NS_ENABLE_TSF)
8411 AC_SUBST(MOZ_NSS_PATCH)
8413 if test "$USING_HCC"; then
8414    CC='${topsrcdir}/build/hcc'
8415    CC="$CC '$_OLDCC'"
8416    CXX='${topsrcdir}/build/hcpp'
8417    CXX="$CXX '$_OLDCXX'"
8418    AC_SUBST(CC)
8419    AC_SUBST(CXX)
8422 dnl Check for missing components
8423 if test "$COMPILE_ENVIRONMENT"; then
8424 if test "$MOZ_X11"; then
8425     dnl ====================================================
8426     dnl = Check if X headers exist
8427     dnl ====================================================
8428     _SAVE_CFLAGS=$CFLAGS
8429     CFLAGS="$CFLAGS $XCFLAGS"
8430     AC_TRY_COMPILE([
8431         #include <stdio.h>
8432         #include <stdlib.h>
8433         #include <X11/Xlib.h>
8434         #include <X11/Intrinsic.h>
8435     ],
8436     [
8437         Display *dpy = 0;
8438         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8439             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8440             exit(1);
8441         }
8442     ], [], 
8443     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8444     CFLAGS="$_SAVE_CFLAGS"
8446     if test ! -z "$MISSING_X"; then
8447         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8448     fi
8450 fi # MOZ_X11
8452 dnl Check for headers, etc. needed by WebGL.
8453 if test -n "$MOZ_WEBGL_GLX"; then
8454     AC_CHECK_HEADER(GL/glx.h)
8455     if test "$ac_cv_header_GL_glx_h" != "yes"; then
8456         AC_MSG_ERROR([Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa (SuSE))])
8457     fi
8458 fi # MOZ_WEBGL_GLX
8459 fi # COMPILE_ENVIRONMENT
8461 if test "$USE_FC_FREETYPE"; then
8462     if test "$COMPILE_ENVIRONMENT"; then
8463         _SAVE_CPPFLAGS="$CPPFLAGS"
8464         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8465         AC_CHECK_HEADERS(fontconfig/fcfreetype.h, , 
8466             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)])
8467         CPPFLAGS="$_SAVE_CPPFLAGS"
8468     else
8469         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8470     fi
8473 dnl Set various defines and substitutions
8474 dnl ========================================================
8476 if test "$OS_ARCH" = "BeOS"; then
8477   AC_DEFINE(XP_BEOS)
8478 elif test "$OS_ARCH" = "Darwin"; then
8479   AC_DEFINE(XP_UNIX)
8480   AC_DEFINE(UNIX_ASYNC_DNS)
8481 elif test "$OS_ARCH" = "OpenVMS"; then
8482   AC_DEFINE(XP_UNIX)
8483 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2" -a "$OS_ARCH" != "WINCE"; then
8484   AC_DEFINE(XP_UNIX)
8485   AC_DEFINE(UNIX_ASYNC_DNS)
8488 if test "$MOZ_DEBUG"; then
8489     AC_DEFINE(MOZ_REFLOW_PERF)
8490     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8493 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
8494     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8495     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8496     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8497     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8498     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8499     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8500     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8501     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8504 dnl ========================================================
8505 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
8506 dnl ========================================================
8507 case "$host_os" in
8508 mingw*)
8509     WIN_TOP_SRC=`cd $srcdir; pwd -W`
8510     ;;
8511 cygwin*|msvc*|mks*)
8512     HOST_CC="\$(CYGWIN_WRAPPER) $HOST_CC"
8513     HOST_CXX="\$(CYGWIN_WRAPPER) $HOST_CXX"
8514     CC="\$(CYGWIN_WRAPPER) $CC"
8515     CXX="\$(CYGWIN_WRAPPER) $CXX"
8516     CPP="\$(CYGWIN_WRAPPER) $CPP"
8517     LD="\$(CYGWIN_WRAPPER) $LD"
8518     AS="\$(CYGWIN_WRAPPER) $AS"
8519     RC="\$(CYGWIN_WRAPPER) $RC"
8520     MIDL="\$(CYGWIN_WRAPPER) $MIDL"
8521     CYGDRIVE_MOUNT=`mount -p | awk '{ if (/^\//) { print $1; exit } }'`
8522     WIN_TOP_SRC=`cygpath -a -w $srcdir | sed -e 's|\\\\|/|g'`
8523     ;;
8524 esac
8526 AC_SUBST(CYGDRIVE_MOUNT)
8527 AC_SUBST(WIN_TOP_SRC)
8529 AC_SUBST(MOZILLA_VERSION)
8531 AC_SUBST(ac_configure_args)
8533 dnl Spit out some output
8534 dnl ========================================================
8536 dnl The following defines are used by xpcom
8537 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8538 CPP_THROW_NEW
8539 HAVE_CPP_2BYTE_WCHAR_T
8540 HAVE_CPP_ACCESS_CHANGING_USING
8541 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8542 HAVE_CPP_BOOL
8543 HAVE_CPP_CHAR16_T
8544 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8545 HAVE_CPP_EXPLICIT
8546 HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
8547 HAVE_CPP_NAMESPACE_STD
8548 HAVE_CPP_NEW_CASTS
8549 HAVE_CPP_PARTIAL_SPECIALIZATION
8550 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8551 HAVE_CPP_TYPENAME
8552 HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
8553 HAVE_STATVFS
8554 NEED_CPP_UNUSED_IMPLEMENTATIONS
8555 NEW_H
8556 HAVE_GETPAGESIZE
8557 HAVE_ICONV
8558 HAVE_ICONV_WITH_CONST_INPUT
8559 HAVE_MBRTOWC
8560 HAVE_SYS_MOUNT_H
8561 HAVE_SYS_VFS_H
8562 HAVE_WCRTOMB
8565 AC_CONFIG_HEADER(
8566 netwerk/necko-config.h
8567 xpcom/xpcom-config.h
8568 xpcom/xpcom-private.h
8571 # Save the defines header file before autoconf removes it.
8572 # (Do not add AC_DEFINE calls after this line.)
8573   _CONFIG_TMP=confdefs-tmp.h
8574   _CONFIG_DEFS_H=mozilla-config.h
8576   cat > $_CONFIG_TMP <<\EOF
8577 /* List of defines generated by configure. Included with preprocessor flag,
8578  * -include, to avoid long list of -D defines on the compile command-line.
8579  * Do not edit.
8580  */
8582 #ifndef _MOZILLA_CONFIG_H_
8583 #define _MOZILLA_CONFIG_H_
8586 _EGREP_PATTERN='^#define ('
8587 if test -n "$_NON_GLOBAL_ACDEFINES"; then
8588     for f in $_NON_GLOBAL_ACDEFINES; do
8589         _EGREP_PATTERN="${_EGREP_PATTERN}$f|"
8590     done
8592 _EGREP_PATTERN="${_EGREP_PATTERN}dummy_never_defined)"
8594   sort confdefs.h | egrep -v "$_EGREP_PATTERN" >> $_CONFIG_TMP
8596   cat >> $_CONFIG_TMP <<\EOF
8598 #endif /* _MOZILLA_CONFIG_H_ */
8602   # Only write mozilla-config.h when something changes (or it doesn't exist)
8603   if cmp -s $_CONFIG_TMP $_CONFIG_DEFS_H; then
8604     rm $_CONFIG_TMP
8605   else
8606     AC_MSG_RESULT("creating $_CONFIG_DEFS_H")
8607     mv -f $_CONFIG_TMP $_CONFIG_DEFS_H
8609     echo ==== $_CONFIG_DEFS_H =================================
8610     cat $_CONFIG_DEFS_H
8611   fi
8613 dnl Probably shouldn't call this manually but we always want the output of DEFS
8614 rm -f confdefs.h.save
8615 mv confdefs.h confdefs.h.save
8616 egrep -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
8617 AC_OUTPUT_MAKE_DEFS()
8618 MOZ_DEFINES=$DEFS
8619 AC_SUBST(MOZ_DEFINES)
8620 rm -f confdefs.h
8621 mv confdefs.h.save confdefs.h
8623 dnl Load the list of Makefiles to generate.
8624 dnl   To add new Makefiles, edit allmakefiles.sh.
8625 dnl   allmakefiles.sh sets the variable, MAKEFILES.
8626 . ${srcdir}/allmakefiles.sh
8627 dnl 
8628 dnl Run a perl script to quickly create the makefiles.
8629 dnl If it succeeds, it outputs a shell command to set CONFIG_FILES
8630 dnl   for the files it cannot handle correctly. This way, config.status
8631 dnl   will handle these files.
8632 dnl If it fails, nothing is set and config.status will run as usual.
8634 dnl This does not change the $MAKEFILES variable.
8636 dnl OpenVMS gets a line overflow on the long eval command, so use a temp file.
8638 if test -z "${AS_PERL}"; then
8639 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl > conftest.sh
8640 else
8641 echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl -nowrap --cygwin-srcdir=$srcdir > conftest.sh
8643 . ./conftest.sh
8644 rm conftest.sh
8646 echo $MAKEFILES > unallmakefiles
8648 mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null
8650 AC_OUTPUT($MAKEFILES)
8652 dnl Prevent the regeneration of cairo-features.h forcing rebuilds of gfx stuff
8653 if test "$CAIRO_FEATURES_H"; then
8654   if cmp -s $CAIRO_FEATURES_H "$CAIRO_FEATURES_H".orig; then
8655     echo "$CAIRO_FEATURES_H is unchanged"
8656     mv -f "$CAIRO_FEATURES_H".orig "$CAIRO_FEATURES_H" 2> /dev/null
8657   else
8658     rm -f "$CAIRO_FEATURES_H".orig 2> /dev/null
8659   fi
8662 dnl ========================================================
8663 dnl = Setup a nice relatively clean build environment for
8664 dnl = sub-configures.
8665 dnl ========================================================
8666 CC="$_SUBDIR_CC" 
8667 CXX="$_SUBDIR_CXX" 
8668 CFLAGS="$_SUBDIR_CFLAGS" 
8669 CPPFLAGS="$_SUBDIR_CPPFLAGS"
8670 CXXFLAGS="$_SUBDIR_CXXFLAGS"
8671 LDFLAGS="$_SUBDIR_LDFLAGS"
8672 HOST_CC="$_SUBDIR_HOST_CC" 
8673 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
8674 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
8677 unset MAKEFILES
8678 unset CONFIG_FILES
8680 # No need to run subconfigures when building with LIBXUL_SDK_DIR
8681 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
8683 if test -z "$MOZ_NATIVE_NSPR"; then
8684     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
8685     if test -z "$MOZ_DEBUG"; then
8686         ac_configure_args="$ac_configure_args --disable-debug"
8687     fi
8688     if test "$MOZ_OPTIMIZE" = "1"; then
8689         ac_configure_args="$ac_configure_args --enable-optimize"
8690     fi
8691     if test "$OS_ARCH" = "WINNT" && test "$NS_TRACE_MALLOC"; then
8692        ac_configure_args="$ac_configure_args --enable-debug --disable-optimize"
8693     fi
8694     if test -n "$HAVE_64BIT_OS"; then
8695         ac_configure_args="$ac_configure_args --enable-64bit"
8696     fi
8697     if test -n "$USE_ARM_KUSER"; then
8698         ac_configure_args="$ac_configure_args --with-arm-kuser"
8699     fi
8700     AC_OUTPUT_SUBDIRS(nsprpub)
8701     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
8704 if test -z "$MOZ_NATIVE_NSPR"; then
8705     # Hack to deal with the fact that we use NSPR_CFLAGS everywhere
8706     AC_MSG_WARN([Recreating autoconf.mk with updated nspr-config output])
8707     if test "$OS_ARCH" != "WINNT" && test "$OS_ARCH" != "WINCE"; then
8708        NSPR_LIBS=`./nsprpub/config/nspr-config --prefix=$LIBXUL_DIST --exec-prefix=$MOZ_BUILD_ROOT/dist --libdir=$LIBXUL_DIST/lib --libs`
8709        $PERL -pi.bak -e "s '^NSPR_LIBS\\s*=.*'NSPR_LIBS = $NSPR_LIBS'" config/autoconf.mk
8710        NSPR_CFLAGS=`./nsprpub/config/nspr-config --prefix=$LIBXUL_DIST --exec-prefix=$MOZ_BUILD_ROOT/dist --includedir=$LIBXUL_DIST/include/nspr --cflags`
8711        $PERL -pi.bak -e "s '^NSPR_CFLAGS\\s*=.*'NSPR_CFLAGS = $NSPR_CFLAGS'" config/autoconf.mk
8712     fi
8713     rm -f config/autoconf.mk.bak
8716 # Run the SpiderMonkey 'configure' script.
8717 dist=$MOZ_BUILD_ROOT/dist
8718 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
8719 ac_configure_args="$ac_configure_args --enable-threadsafe"
8720 if test -z "$MOZ_NATIVE_NSPR"; then
8721     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
8722     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
8724 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
8725 ac_configure_args="$ac_configure_args --includedir=$dist/include"
8726 ac_configure_args="$ac_configure_args --bindir=$dist/bin"
8727 ac_configure_args="$ac_configure_args --libdir=$dist/lib"
8728 ac_configure_args="$ac_configure_args --with-sync-build-files=$_topsrcdir"
8729 if test "$MOZ_MEMORY"; then
8730    ac_configure_args="$ac_configure_args --enable-jemalloc"
8731    if test -n "$MOZ_MEMORY_LDFLAGS"; then
8732      export MOZ_MEMORY_LDFLAGS
8733    fi
8735 AC_OUTPUT_SUBDIRS(js/src)
8736 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
8738 # Build jsctypes on the platforms we can.
8739 if test "$BUILD_CTYPES"; then
8740   # Run the libffi 'configure' script.
8741   ac_configure_args="--disable-shared --enable-static --disable-raw-api"
8742   if test "$MOZ_DEBUG"; then
8743     ac_configure_args="$ac_configure_args --enable-debug"
8744   fi
8745   if test "$DSO_PIC_CFLAGS"; then
8746     ac_configure_args="$ac_configure_args --with-pic"
8747   fi
8748   if test "$CROSS_COMPILE"; then
8749     case "$target" in
8750     *-mingw*)
8751       ac_configure_args="$ac_configure_args --build=$build --host=${target_cpu}-${target_os} HOST_CC=\"$HOST_CC\" CC=\"$CC\""
8752       ;;
8753     *)
8754       ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\" CC=\"$CC\""
8755       ;;
8756     esac
8757   fi
8758   if test "$_MSC_VER"; then
8759     # Use a wrapper script for cl and ml that looks more like gcc.
8760     # autotools can't quite handle an MSVC build environment yet.
8761     ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
8762     case "${target_cpu}" in
8763     x86_64)
8764       # Need target since MSYS tools into mozilla-build may be 32bit
8765       ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/js/ctypes/libffi/msvcc.sh -m64\" --build=$build --host=$target"
8766       ;;
8767     *)
8768       ac_configure_args="$ac_configure_args CC=$_topsrcdir/js/ctypes/libffi/msvcc.sh"
8769       ;;
8770     esac
8771   fi
8772   if test "$SOLARIS_SUNPRO_CC"; then
8773     # Always use gcc for libffi on Solaris
8774     ac_configure_args="$ac_configure_args CC=gcc"
8775   fi
8777   # Use a separate cache file for libffi, since it does things differently
8778   # from our configure.
8779   old_cache_file=$cache_file
8780   cache_file=js/ctypes/libffi/config.cache
8781   AC_OUTPUT_SUBDIRS(js/ctypes/libffi)
8782   cache_file=$old_cache_file
8783   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
8786 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
8788 dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world
8789 dnl Needs to be at the end to respect possible changes from NSPR configure
8790 if cmp -s config/autoconf.mk config/autoconf.mk.orig; then
8791   echo "config/autoconf.mk is unchanged"
8792   mv -f config/autoconf.mk.orig config/autoconf.mk 2> /dev/null
8793 else
8794   rm -f config/autoconf.mk.orig 2> /dev/null