Bug 1557368 [wpt PR 16856] - Update error type test for attachInternals(), a=testonly
[gecko.git] / nsprpub / configure.in
blob9ff70f3589ad996f65af456dec7c3af98b2da317
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl 
3 dnl This Source Code Form is subject to the terms of the Mozilla Public
4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 AC_PREREQ(2.61)
8 AC_INIT
9 AC_CONFIG_SRCDIR([pr/include/nspr.h])
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
12 AC_CANONICAL_TARGET
14 dnl ========================================================
15 dnl = Defaults
16 dnl ========================================================
17 MOD_MAJOR_VERSION=4
18 MOD_MINOR_VERSION=21
19 MOD_PATCH_VERSION=0
20 NSPR_MODNAME=nspr20
21 _HAVE_PTHREADS=
22 USE_PTHREADS=
23 USE_USER_PTHREADS=
24 USE_NSPR_THREADS=
25 USE_N32=
26 USE_X32=
27 USE_64=
28 USE_CPLUS=
29 USE_IPV6=
30 USE_MDUPDATE=
31 _MACOSX_DEPLOYMENT_TARGET=
32 _OPTIMIZE_FLAGS=-O
33 _DEBUG_FLAGS=-g
34 MOZ_DEBUG=1
35 MOZ_OPTIMIZE=
36 OBJDIR='$(OBJDIR_NAME)'
37 OBJDIR_NAME=.
38 OBJDIR_SUFFIX=OBJ
39 NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
40 NOSUCHFILE=/no-such-file
41 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
42 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
43 CYGWIN_WRAPPER=
44 MACOS_SDK_DIR=
45 NEXT_ROOT=
46 MT=
47 MOZ_OS2_HIGH_MEMORY=1
48 PROFILE_GEN_CFLAGS=
49 PROFILE_GEN_LDFLAGS=
50 PROFILE_USE_CFLAGS=
51 PROFILE_USE_LDFLAGS=
53 dnl Link in libraries necessary to resolve all symbols for shared libs
54 RESOLVE_LINK_SYMBOLS=
56 dnl ========================================================
57 dnl =
58 dnl = Dont change the following lines.  Doing so breaks:
59 dnl =
60 dnl = CFLAGS="-foo" ./configure
61 dnl =
62 dnl ========================================================
63 CFLAGS="${CFLAGS=}"
64 CXXFLAGS="${CXXFLAGS=}"
65 LDFLAGS="${LDFLAGS=}"
66 DLLFLAGS="${DLLFLAGS=}"
67 HOST_CFLAGS="${HOST_CFLAGS=}"
68 HOST_LDFLAGS="${HOST_LDFLAGS=}"
70 case "$target" in
71 *-cygwin*|*-mingw*|*-msys*)
72     # Check to see if we are really running in a msvc environemnt
73     _WIN32_MSVC=
74     AC_CHECK_PROGS(CC, cl)
75     cat > conftest.c <<EOF
76 #ifdef _MSC_VER
77 COMPILER IS MSVC
78 #endif
79 EOF
80     read dummy <<EOF
81 $($CC -E conftest.c 2>/dev/null | grep COMPILER)
82 EOF
83     if test -n "$dummy"; then
84         _WIN32_MSVC=1
85         CXX=$CC
86     fi
87     rm -f conftest.c
88     ;;
89 *-mks*)
90     _WIN32_MSVC=1
91     ;;
92 esac
94 if test -n "$_WIN32_MSVC"; then
95     SKIP_PATH_CHECKS=1
96     SKIP_COMPILER_CHECKS=1
97     SKIP_LIBRARY_CHECKS=1
100 dnl ========================================================
101 dnl = Android uses a very custom (hacky) toolchain; we need to do this
102 dnl = here, so that the compiler checks can succeed
103 dnl ========================================================
105 AC_ARG_WITH(android-ndk,
106 [  --with-android-ndk=DIR
107                           location where the Android NDK can be found],
108     android_ndk=$withval)
110 AC_ARG_WITH(android-toolchain,
111 [  --with-android-toolchain=DIR
112                           location of the Android toolchain],
113     android_toolchain=$withval)
115 dnl The default android_version is different for each target cpu.
116 case "$target_cpu" in
117 arm)
118     android_version=5
119     ;;
120 i?86|mipsel)
121     android_version=9
122     ;;
123 esac
125 AC_ARG_WITH(android-version,
126 [  --with-android-version=VER
127                           Android platform version, default 5 for arm, 9 for x86/mips],
128     android_version=$withval)
130 AC_ARG_WITH(android-platform,
131 [  --with-android-platform=DIR
132                           location of platform dir],
133     android_platform=$withval)
135 case "$target" in
136 arm-linux*-android*|*-linuxandroid*)
137     android_tool_prefix="arm-linux-androideabi"
138     ;;
139 i?86-*android*)
140     android_tool_prefix="i686-linux-android"
141     ;;
142 mipsel-*android*)
143     android_tool_prefix="mipsel-linux-android"
144     ;;
146     android_tool_prefix="$target_os"
147     ;;
148 esac
150 case "$target" in
151 *-android*|*-linuxandroid*)
152     if test -z "$android_ndk" ; then
153        AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
154     fi
156     if test -z "$android_toolchain" ; then
157         AC_MSG_CHECKING([for android toolchain directory])
159         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
161         case "$target_cpu" in
162         arm)
163             target_name=arm-linux-androideabi-4.4.3
164             ;;
165         i?86)
166             target_name=x86-4.4.3
167             ;;
168         mipsel)
169             target_name=mipsel-linux-android-4.4.3
170             ;;
171         esac
172         android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
174         if test -d "$android_toolchain" ; then
175             AC_MSG_RESULT([$android_toolchain])
176         else
177             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
178         fi
179     fi
181     if test -z "$android_platform" ; then
182         AC_MSG_CHECKING([for android platform directory])
184         case "$target_cpu" in
185         arm)
186             target_name=arm
187             ;;
188         i?86)
189             target_name=x86
190             ;;
191         mipsel)
192             target_name=mips
193             ;;
194         esac
196         android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
198         if test -d "$android_platform" ; then
199             AC_MSG_RESULT([$android_platform])
200         else
201             AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
202         fi
203     fi
205     dnl Old NDK support. If minimum requirement is changed to NDK r8b,
206     dnl please remove this.
207     case "$target_cpu" in
208     i?86)
209         if ! test -e "$android_toolchain"/bin/"$android_tool_prefix"-gcc; then
210             dnl Old NDK toolchain name
211             android_tool_prefix="i686-android-linux"
212         fi
213         ;;
214     esac
216     dnl set up compilers
217     AS="$android_toolchain"/bin/"$android_tool_prefix"-as
218     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
219     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
220     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
221     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
222     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
223     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
224     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
226     CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
227     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
228     CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
229     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
231     AC_DEFINE(ANDROID)
232     ;;
233 esac
235 dnl ========================================================
236 dnl =
237 dnl = Check options that may affect the compiler
238 dnl =
239 dnl ========================================================
240 dist_prefix='${MOD_DEPTH}/dist'
241 dist_bindir='${dist_prefix}/bin'
242 dist_includedir='${dist_prefix}/include/nspr'
243 dist_libdir='${dist_prefix}/lib'
244 dnl If the --includedir option was not specified, add '/nspr' to autoconf's
245 dnl default value of includedir.
246 if test "${includedir}" = '${prefix}/include'; then
247     includedir='${prefix}/include/nspr'
250 AC_ARG_WITH(dist-prefix,
251     [  --with-dist-prefix=DIST_PREFIX
252                           place build files in DIST_PREFIX [dist]],
253     dist_prefix=$withval)
255 AC_ARG_WITH(dist-bindir,
256     [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
257     dist_bindir=$withval)
259 AC_ARG_WITH(dist-includedir,
260     [  --with-dist-includedir=DIR
261                           build include files in DIR [DIST_PREFIX/include/nspr]],
262     dist_includedir=$withval)
264 AC_ARG_WITH(dist-libdir,
265     [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
266     dist_libdir=$withval)
268 AC_SUBST(dist_prefix)
269 AC_SUBST(dist_bindir)
270 AC_SUBST(dist_includedir)
271 AC_SUBST(dist_libdir)
273 dnl Check if NSPR is being compiled for Mozilla
274 dnl Let --with-arg override environment setting
276 AC_ARG_WITH(mozilla,
277     [  --with-mozilla          Compile NSPR with Mozilla support],
278     [   if test "$withval" = "yes"; then
279             AC_DEFINE(MOZILLA_CLIENT)
280             MOZILLA_CLIENT=1
281             else
282                 MOZILLA_CLIENT=
283             fi],
284     [   if test -n "$MOZILLA_CLIENT"; then
285                 AC_DEFINE(MOZILLA_CLIENT)
286             fi])
288 AC_ARG_ENABLE(optimize,
289     [  --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
290     [ if test "$enableval" != "no"; then
291           MOZ_OPTIMIZE=1
292           if test -n "$enableval" -a "$enableval" != "yes"; then
293             _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
294             _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
295           fi
296       else
297           MOZ_OPTIMIZE=
298       fi ])
300 AC_ARG_ENABLE(debug,
301     [  --enable-debug[=DBG]    Enable debugging (using compiler flags DBG)],
302     [ if test "$enableval" != "no"; then
303           MOZ_DEBUG=1
304           MOZ_DEBUG_SYMBOLS=1
305           if test -n "$enableval" -a "$enableval" != "yes"; then
306               _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
307               _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
308           fi
309       else
310           MOZ_DEBUG=
311       fi ],
312       MOZ_DEBUG_SYMBOLS=1)
314 AC_ARG_ENABLE(debug-symbols,
315     [  --enable-debug-symbols[=DBG]    Enable debugging symbols
316                                        (using compiler flags DBG)],
317     [ if test "$enableval" != "no"; then
318           MOZ_DEBUG_SYMBOLS=1
319           if test -n "$enableval" -a "$enableval" != "yes"; then
320               if test -z "$_SAVE_DEBUG_FLAGS"; then
321                   _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
322                   _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
323               else
324                   AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
325               fi
326           fi
327       else
328           MOZ_DEBUG_SYMBOLS=
329       fi ])
331 AC_ARG_ENABLE(win32-target,
332     [  --enable-win32-target=\$t
333                           Specify win32 flavor. (WIN95 or WINNT)],
334     OS_TARGET=`echo $enableval | tr a-z A-Z`)
336 AC_ARG_ENABLE(symbian-target,
337     [  --enable-symbian-target=\$t
338                           Specify symbian flavor. (WINSCW or GCCE)],
339     OS_TARGET=`echo $enableval | tr a-z A-Z`)
341 AC_ARG_ENABLE(debug-rtl,
342     [  --enable-debug-rtl      Use the MSVC debug runtime library],
343     [ if test "$enableval" = "yes"; then
344             USE_DEBUG_RTL=1
345       else
346             USE_DEBUG_RTL=0
347       fi ])
349 AC_ARG_ENABLE(static-rtl,
350     [  --enable-static-rtl     Use the MSVC static runtime library],
351     [ if test "$enableval" = "yes"; then
352             USE_STATIC_RTL=1
353       fi ])
355 AC_ARG_ENABLE(n32,
356     [  --enable-n32            Enable n32 ABI support (IRIX only)],
357     [ if test "$enableval" = "yes"; then
358         USE_N32=1
359       else if test "$enableval" = "no"; then
360         USE_N32=
361       fi
362     fi ])
364 AC_ARG_ENABLE(x32,
365     [  --enable-x32            Enable x32 ABI support (x86_64 only)],
366     [ if test "$enableval" = "yes"; then
367         USE_X32=1
368       else if test "$enableval" = "no"; then
369         USE_X32=
370       fi
371     fi ])
373 AC_ARG_ENABLE(64bit,
374     [  --enable-64bit          Enable 64-bit support (on certain platforms)],
375     [ if test "$enableval" = "yes"; then
376             USE_64=1
377       fi ])
379 AC_ARG_ENABLE(mdupdate,
380     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
381     [ if test "$enableval" = "yes"; then
382             USE_MDUPDATE=1
383       fi ])
385 AC_ARG_ENABLE(cplus,
386     [  --enable-cplus          Enable some c++ api routines],
387     [ if test "$enableval" = "yes"; then
388             USE_CPLUS=1
389       fi]) 
391 AC_ARG_WITH(arm-kuser,
392     [  --with-arm-kuser        Use kuser helpers (Linux/ARM only)
393                           (Requires kernel 2.6.13 or later)],
394     [ if test "$withval" = "yes"; then
395             AC_DEFINE(_PR_ARM_KUSER)
396       fi ])
398 dnl ========================================================
399 dnl = Mac OS X SDK support
400 dnl ========================================================
401 AC_ARG_WITH(macos-sdk,
402     [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
403     MACOS_SDK_DIR=$withval)
405 AC_ARG_ENABLE(macos-target,
406              [  --enable-macos-target=VER
407                           Set the minimum MacOS version needed at runtime
408                           [10.2 for ppc, 10.4 for x86]],
409              [_MACOSX_DEPLOYMENT_TARGET=$enableval])
411 dnl ========================================================
412 dnl =
413 dnl = Set the threading model
414 dnl =
415 dnl ========================================================
416 case "$target" in
418 *-aix*)
419     case "${target_os}" in
420     aix3.2*)
421         USE_NSPR_THREADS=1
422         ;;
423     *)
424         USE_PTHREADS=1
425         ;;
426     esac
427     ;;
429 esac
431 dnl ========================================================
432 dnl =
433 dnl = Set the default C compiler
434 dnl =
435 dnl ========================================================
436 if test -z "$CC"; then
437     case "$target" in
439     *-aix*)
440         if test -z "$USE_NSPR_THREADS"; then
441             CC=xlc_r
442         else
443             CC=xlc
444         fi
445     ;;
447     *-hpux*)
448         CC=cc
449     ;;
451     *-irix*)
452         CC=cc
453     ;;
455     *-osf*)
456         CC=cc
457     ;;
459     *-solaris*)
460         CC=cc
461     ;;
463     esac
466 dnl ========================================================
467 dnl =
468 dnl = Set the default C++ compiler
469 dnl =
470 dnl ========================================================
471 if test -z "$CXX"; then
472     case "$target" in
474     *-aix*)
475         if test -z "$USE_NSPR_THREADS"; then
476             CXX=xlC_r
477         else
478             CXX=xlC
479         fi
480     ;;
482     *-hpux*)
483         case "${target_os}" in
484         hpux10.30)
485             CXX=aCC
486             ;;
487         hpux11.*)
488             CXX=aCC
489             ;;
490         *)
491             CXX=CC
492             ;;
493         esac
494     ;;
496     *-irix*)
497         CXX=CC
498     ;;
500     *-osf*)
501         CXX=cxx
502     ;;
504     *-solaris*)
505         CXX=CC
506     ;;
508     esac
511 if test -z "$SKIP_PATH_CHECKS"; then
512     AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
515 if test -n "$MOZ_DEBUG"; then
516     AC_DEFINE(DEBUG)
517     DEFINES="$DEFINES -UNDEBUG"
519     case "${target_os}" in
520     beos*)
521         DEFINES="$DEFINES -DDEBUG_${USER}"
522         ;;
523     mks*|cygwin*|mingw*|msys*|os2*)
524         DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
525         ;;
526     *)
527         DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
528         ;;
529     esac
530 else
531     AC_DEFINE(NDEBUG)
532     DEFINES="$DEFINES -UDEBUG"
535 if test -z "$SKIP_COMPILER_CHECKS"; then
536 dnl ========================================================
537 dnl Checks for compilers.
538 dnl ========================================================
539 if test "$target" != "$host"; then
540     echo "cross compiling from $host to $target"
541     cross_compiling=yes
543     case "$build:$target" in
544       powerpc-apple-darwin8*:i?86-apple-darwin*)
545         dnl The Darwin cross compiler doesn't necessarily point itself at a
546         dnl root that has libraries for the proper architecture, it defaults
547         dnl to the system root.  The libraries in the system root on current
548         dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
549         dnl checks will fail.  Fake a working SDK in that case.
550         _SAVE_CFLAGS=$CFLAGS
551         _SAVE_CXXFLAGS=$CXXFLAGS
552         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
553         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
554         ;;
555     esac
557     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
558     unset ac_cv_prog_CC
559     dnl Now exit the conditional block to invoke AC_PROG_CC.
562 dnl In the latest versions of autoconf, AC_PROG_CC is a one-shot macro,
563 dnl declared with AC_DEFUN_ONCE. So it must not be expanded inside a
564 dnl conditional block. Invoke AC_PROG_CC outside any conditional block
565 dnl and before invoking AC_TRY_COMPILE (which requires AC_PROG_CC).
566 AC_PROG_CC
568 dnl Reenter the conditional blocks after invoking AC_PROG_CC.
569 if test "$target" != "$host"; then
570     if test -n "$USE_CPLUS"; then
571         AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
572         unset ac_cv_prog_CXX
573         AC_PROG_CXX
574     fi
576     case "$build:$target" in
577       powerpc-apple-darwin8*:i?86-apple-darwin*|*:arm*-apple-darwin*)
578         dnl Revert the changes made above.  From this point on, the target
579         dnl compiler will never be used without applying the SDK to CFLAGS
580         dnl (see --with-macos-sdk below).
581         CFLAGS=$_SAVE_CFLAGS
582         CXXFLAGS=$_SAVE_CXXFLAGS
583         ;;
584     esac
586     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
587     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
588     AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
589     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
590     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
591     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
593     _SAVE_CC="$CC"
594     _SAVE_CFLAGS="$CFLAGS"
595     _SAVE_LDFLAGS="$LDFLAGS"
597     AC_MSG_CHECKING([for $host compiler])
598     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
599     if test -z "$HOST_CC"; then
600         AC_MSG_ERROR([no acceptable cc found in \$PATH])
601     fi
602     AC_MSG_RESULT([$HOST_CC])
604     CC="$HOST_CC"
605     CFLAGS="$HOST_CFLAGS"
606     LDFLAGS="$HOST_LDFLAGS"
608     AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
609     AC_TRY_COMPILE([], [return 0;],
610         [AC_MSG_RESULT([yes])],
611         [AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.])] )
613     CC=$_SAVE_CC
614     CFLAGS=$_SAVE_CFLAGS
615     LDFLAGS=$_SAVE_LDFLAGS
616 else
617     if test -n "$USE_CPLUS"; then
618         if test "$CC" = "cl" -a -z "$CXX"; then
619             CXX=$CC
620         else
621             AC_PROG_CXX
622         fi
623     fi
624     AC_PROG_RANLIB
625     AC_PATH_PROGS(AS, as, $CC)
626     AC_PATH_PROGS(AR, ar, echo not_ar)
627     AC_PATH_PROGS(LD, ld link, echo not_ld)
628     AC_PATH_PROGS(STRIP, strip, echo not_strip)
629     AC_PATH_PROGS(WINDRES, windres, echo not_windres)
630     if test -z "$HOST_CC"; then
631         HOST_CC="$CC"
632     fi
633     if test -z "$HOST_CFLAGS"; then
634         HOST_CFLAGS="$CFLAGS"
635     fi
638 AC_PROG_CPP
640 if test "$GCC" = "yes"; then
641     GNU_CC=1
643 if test "$GXX" = "yes"; then
644     GNU_CXX=1
646 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
647     GNU_AS=1
649 rm -f a.out
651 case "$build:$target" in
652     i?86-apple-darwin*:powerpc-apple-darwin*)
653         dnl cross_compiling will have erroneously been set to "no" in this
654         dnl case, because the x86 build host is able to run ppc code in a
655         dnl translated environment, making a cross compiler appear native.
656         cross_compiling=yes
657         ;;
658 esac
660 if test "$cross_compiling"  = "yes"; then
661     CROSS_COMPILE=1
662 else
663     CROSS_COMPILE=
666 dnl ========================================================
667 dnl Check for gcc -pipe support
668 dnl ========================================================
669 AC_MSG_CHECKING([for gcc -pipe support])
670 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
671     echo '#include <stdio.h>' > dummy-hello.c
672     echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
673     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
674     cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
675     if test $? = 0; then
676         _res_as_stdin="yes"
677     else
678         _res_as_stdin="no"
679     fi
680     if test "$_res_as_stdin" = "yes"; then
681         _SAVE_CFLAGS=$CFLAGS
682         CFLAGS="$CFLAGS -pipe"
683         AC_TRY_COMPILE( [ #include <stdio.h> ],
684             [printf("Hello World\n");],
685             [_res_gcc_pipe="yes"],
686             [_res_gcc_pipe="no"] )
687         CFLAGS=$_SAVE_CFLAGS
688     fi
689     if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
690         _res="yes";
691         CFLAGS="$CFLAGS -pipe"
692         CXXFLAGS="$CXXFLAGS -pipe"
693     else
694         _res="no"
695     fi
696     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
697     AC_MSG_RESULT([$_res])
698 else
699     AC_MSG_RESULT([no])
702 dnl ========================================================
703 dnl Check for pragma diagnostic
704 dnl ========================================================
706 AC_MSG_CHECKING([for pragma diagnostic])
707 if test "$GNU_CC" = "1"; then
708     cat >dummy-hello.c <<EOF
709 #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
710 #pragma GCC diagnostic push
711 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
712 #endif
713 int main() {
714     char *dummy = "";
715     return 0;
718     ${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
719     if test $? != 0; then
720         ${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
721         if test $? = 0; then
722             CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
723             _res=yes
724         else
725             _res=no
726         fi
727     else
728         _res=no
729     fi
730     rm -f dummy-hello.c dummy-hello.s
731     AC_MSG_RESULT([$_res])
732 else
733     AC_MSG_RESULT([no])
736 dnl ========================================================
737 dnl Profile guided optimization
738 dnl ========================================================
739 dnl Test for profiling options
740 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
742 _SAVE_CFLAGS="$CFLAGS"
743 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
745 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
746 AC_TRY_COMPILE([], [return 0;],
747                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
748                  result="yes" ], result="no")
749 AC_MSG_RESULT([$result])
751 if test $result = "yes"; then
752    PROFILE_GEN_LDFLAGS="-fprofile-generate"
753    PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
754    PROFILE_USE_LDFLAGS="-fprofile-use"
757 CFLAGS="$_SAVE_CFLAGS"
759 dnl ===============================================================
760 dnl Check for .hidden assembler directive and visibility attribute.
761 dnl Borrowed from glibc configure.in
762 dnl ===============================================================
763 if test "$GNU_CC"; then
764     AC_CACHE_CHECK(for visibility(hidden) attribute,
765         ac_cv_visibility_hidden,
766         [cat > conftest.c <<EOF
767         int foo __attribute__ ((visibility ("hidden"))) = 1;
769         ac_cv_visibility_hidden=no
770         if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
771             if grep '\.hidden.*foo' conftest.s >/dev/null; then
772                 ac_cv_visibility_hidden=yes
773             fi
774         fi
775         rm -f conftest.[cs]
776         ])
777     if test "$ac_cv_visibility_hidden" = "yes"; then
778         AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
779         AC_CACHE_CHECK(for visibility pragma support,
780             ac_cv_visibility_pragma,
781             [cat > conftest.c <<EOF
782 #pragma GCC visibility push(hidden)
783             int foo_hidden = 1;
784 #pragma GCC visibility push(default)
785             int foo_default = 1;
787             ac_cv_visibility_pragma=no
788             if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
789                 if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
790                     if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
791                         ac_cv_visibility_pragma=yes
792                     fi
793                 fi
794             fi
795             rm -f conftest.[cs]
796             ])
797         if test "$ac_cv_visibility_pragma" = "yes"; then
798             AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
799             # To work around a build problem on Linux x86-64 (Bugzilla bug
800             # 293438), we use the -fvisibility=hidden flag.  This flag is less
801             # optimal than #pragma GCC visibility push(hidden) because the flag
802             # assumes that symbols defined outside the current source file have
803             # the default visibility.  This has the advantage that we don't need
804             # to wrap system header files, but has the disadvantage that calls
805             # to hidden symbols defined in other source files cannot be
806             # optimized by the compiler.  The -fvisibility=hidden flag does
807             # hide and export symbols correctly.
808             #VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
809             #WRAP_SYSTEM_INCLUDES=1
810             VISIBILITY_FLAGS="-fvisibility=hidden"
811             WRAP_SYSTEM_INCLUDES=
812         fi
813     fi
814 fi # GNU_CC
816 fi # SKIP_COMPILER_CHECKS
818 dnl ========================================================
819 dnl Checks for programs.
820 dnl ========================================================
821 if test -z "$SKIP_PATH_CHECKS"; then
822     AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
823 elif test -z "$PERL"; then
824     PERL=perl
827 dnl ========================================================
828 dnl Default platform specific options
829 dnl ========================================================
830 OBJ_SUFFIX=o
831 LIB_SUFFIX=a
832 DLL_SUFFIX=so
833 ASM_SUFFIX=s
834 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
835 PR_MD_ASFILES=
836 PR_MD_CSRCS=
837 PR_MD_ARCH_DIR=unix
838 AR_FLAGS='cr $@'
839 AS='$(CC)'
840 ASFLAGS='$(CFLAGS)'
842 if test -n "$CROSS_COMPILE"; then
843     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
844     OS_RELEASE=
845     OS_TEST="${target_cpu}"
846     case "${target_os}" in
847         linux*)       OS_ARCH=Linux ;;
848         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
849         mingw*)       OS_ARCH=WINNT CPU_ARCH=x86 ;;
850         darwin*)      OS_ARCH=Darwin ;;
851         riscos*)      OS_ARCH=RISCOS ;;
852     esac
853 else
854     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
855     OS_RELEASE=`uname -r`
856     OS_TEST=`uname -m`
859 if test "$OS_ARCH" = "IRIX64"; then
860     OS_ARCH=IRIX
863 if test "$OS_ARCH" = "AIX"; then
864     OS_RELEASE=`uname -v`.`uname -r`
867 if test "$OS_ARCH" = "FreeBSD"; then
868     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
871 if test "$OS_ARCH" = "Linux"; then
872     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
873     OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
876 #######################################################################
877 # Master "Core Components" macros for getting the OS target           #
878 #######################################################################
881 # Note: OS_TARGET should be specified on the command line for gmake.
882 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
883 # The difference between the Win95 target and the WinNT target is that
884 # the WinNT target uses Windows NT specific features not available
885 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
886 # at lesser performance (the Win95 target uses threads; the WinNT target
887 # uses fibers).
889 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
890 # cross-compilation.
894 # The following hack allows one to build on a WIN95 machine (as if
895 # s/he were cross-compiling on a WINNT host for a WIN95 target).
896 # It also accomodates for MKS's uname.exe.  If you never intend
897 # to do development on a WIN95 machine, you don't need this hack.
899 case "$OS_ARCH" in
900 Windows_95)
901     OS_ARCH=Windows_NT
902     OS_TARGET=WIN95
903     ;;
904 Windows_98)
905     OS_ARCH=Windows_NT
906     OS_TARGET=WIN95
907     ;;
908 CYGWIN_9*|CYGWIN_ME*)
909     OS_ARCH='CYGWIN_NT-4.0'
910     OS_TARGET=WIN95
911     ;;
912 OS_2)
913     OS_ARCH=OS2
914     OS_TARGET=OS2
915     ;;
916 esac
919 # On WIN32, we also define the variable CPU_ARCH.
922 case "$OS_ARCH" in
923 Windows_NT)
925 # If uname -s returns "Windows_NT", we assume that we are using
926 # the uname.exe in MKS toolkit.
928 # The -r option of MKS uname only returns the major version number.
929 # So we need to use its -v option to get the minor version number.
930 # Moreover, it doesn't have the -p option, so we need to use uname -m.
932     OS_ARCH=WINNT
933     OS_MINOR_RELEASE=`uname -v`
934     if test "$OS_MINOR_RELEASE" = "00"; then
935         OS_MINOR_RELEASE=0
936     fi
937     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
938     CPU_ARCH=`uname -m`
939     #
940     # MKS's uname -m returns "586" on a Pentium machine.
941     #
942     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
943         CPU_ARCH=x86
944     fi
945     ;;
946 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
948 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
949 # the uname.exe in the Cygwin tools.
950 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
951 # the uname.exe in the MSYS tools.
952 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
953 # the uname.exe in the MSYS2 tools.
955     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
956     OS_ARCH=WINNT
957     CPU_ARCH=`uname -m`
958     #
959     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
960     #
961     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
962         CPU_ARCH=x86
963     fi
964     ;;
965 esac
967 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
968     OS_TARGET=WIN95
969     if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
970         USE_DEBUG_RTL=1
971     fi
973 if test -z "$OS_TARGET"; then
974     OS_TARGET=$OS_ARCH
976 if test "$OS_TARGET" = "WIN95"; then
977     OS_RELEASE="4.0"
979 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
981 dnl ========================================================
982 dnl Enable high-memory support on OS/2 by default.
983 dnl ========================================================
984 AC_ARG_ENABLE(os2-high-mem,
985     [  --disable-os2-high-mem  Disable high-memory support on OS/2],
986     [ if test "$enableval" = "no"; then
987         MOZ_OS2_HIGH_MEMORY=
988       else
989         MOZ_OS2_HIGH_MEMORY=1
990       fi ])
992 dnl ========================================================
993 dnl = ARM toolchain tweaks
994 dnl ========================================================
996 dnl Defaults
997 MOZ_ALIGN=toolchain-default
999 case "$target" in
1000 arm*-android*|arm*-linuxandroid*)
1001     MOZ_THUMB=yes
1002     MOZ_ARCH=armv7-a
1003     MOZ_FPU=vfp
1004     MOZ_FLOAT_ABI=softfp
1005     MOZ_SOFT_FLOAT=yes
1006     MOZ_ALIGN=no
1007     ;;
1008 arm*-*)
1009     if test -n "$MOZ_PLATFORM_MAEMO"; then
1010         MOZ_THUMB=no
1011         MOZ_ARCH=armv7-a
1012         MOZ_FLOAT_ABI=softfp
1013     fi
1014     if test "$MOZ_PLATFORM_MAEMO" = 6; then
1015         MOZ_THUMB=yes
1016     fi
1017     ;;
1018 esac
1020 dnl Kept for compatibility with some buildbot mozconfig
1021 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
1023 AC_ARG_WITH(thumb,
1024 [  --with-thumb[[=yes|no|toolchain-default]]]
1025 [                          Use Thumb instruction set (-mthumb)],
1026     if test -z "$GNU_CC"; then
1027         AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
1028     fi
1029     MOZ_THUMB=$withval)
1031 AC_ARG_WITH(thumb-interwork,
1032 [  --with-thumb-interwork[[=yes|no|toolchain-default]]
1033                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
1034     if test -z "$GNU_CC"; then
1035         AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
1036     fi
1037     MOZ_THUMB_INTERWORK=$withval)
1039 AC_ARG_WITH(arch,
1040 [  --with-arch=[[type|toolchain-default]]
1041                            Use specific CPU features (-march=type)],
1042     if test -z "$GNU_CC"; then
1043         AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
1044     fi
1045     MOZ_ARCH=$withval)
1047 AC_ARG_WITH(fpu,
1048 [  --with-fpu=[[type|toolchain-default]]
1049                            Use specific FPU type (-mfpu=type)],
1050     if test -z "$GNU_CC"; then
1051         AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
1052     fi
1053     MOZ_FPU=$withval)
1055 AC_ARG_WITH(float-abi,
1056 [  --with-float-abi=[[type|toolchain-default]]
1057                            Use specific arm float ABI (-mfloat-abi=type)],
1058     if test -z "$GNU_CC"; then
1059         AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
1060     fi
1061     MOZ_FLOAT_ABI=$withval)
1063 AC_ARG_WITH(soft-float,
1064 [  --with-soft-float[[=yes|no|toolchain-default]]
1065                            Use soft float library (-msoft-float)],
1066     if test -z "$GNU_CC"; then
1067         AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
1068     fi
1069     MOZ_SOFT_FLOAT=$withval)
1071 case "$MOZ_ARCH" in
1072 toolchain-default|"")
1073     arch_flag=""
1074     ;;
1076     arch_flag="-march=$MOZ_ARCH"
1077     ;;
1078 esac
1080 case "$MOZ_THUMB" in
1081 yes)
1082     MOZ_THUMB2=1
1083     thumb_flag="-mthumb"
1084     ;;
1086     MOZ_THUMB2=
1087     thumb_flag="-marm"
1088     ;;
1090     _SAVE_CFLAGS="$CFLAGS"
1091     CFLAGS="$arch_flag"
1092     AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1093         MOZ_THUMB2=1,
1094         MOZ_THUMB2=)
1095     CFLAGS="$_SAVE_CFLAGS"
1096     thumb_flag=""
1097     ;;
1098 esac
1100 case "$MOZ_THUMB_INTERWORK" in
1101 yes)
1102     thumb_interwork_flag="-mthumb-interwork"
1103     ;;
1105     thumb_interwork_flag="-mno-thumb-interwork"
1106     ;;
1107 *) # toolchain-default
1108     thumb_interwork_flag=""
1109     ;;
1110 esac
1112 case "$MOZ_FPU" in
1113 toolchain-default|"")
1114     fpu_flag=""
1115     ;;
1117     fpu_flag="-mfpu=$MOZ_FPU"
1118     ;;
1119 esac
1121 case "$MOZ_FLOAT_ABI" in
1122 toolchain-default|"")
1123     float_abi_flag=""
1124     ;;
1126     float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1127     ;;
1128 esac
1130 case "$MOZ_SOFT_FLOAT" in
1131 yes)
1132     soft_float_flag="-msoft-float"
1133     ;;
1135     soft_float_flag="-mno-soft-float"
1136     ;;
1137 *) # toolchain-default
1138     soft_float_flag=""
1139     ;;
1140 esac
1142 case "$MOZ_ALIGN" in
1143 toolchain-default|"")
1144     align_flag=""
1145     ;;
1147     align_flag="-mno-unaligned-access"
1148     ;;
1149 yes)
1150     align_flag="-munaligned-access"
1151     ;;
1153     align_flag=""
1154     ;;
1155 esac
1157 if test -n "$align_flag"; then
1158   _SAVE_CFLAGS="$CFLAGS"
1159   CFLAGS="$CFLAGS $align_flag"
1160   AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
1161   AC_TRY_COMPILE([],[],,align_flag="")
1162   CFLAGS="$_SAVE_CFLAGS"
1165 dnl Use echo to avoid accumulating space characters
1166 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
1167 if test -n "$all_flags"; then
1168     _SAVE_CFLAGS="$CFLAGS"
1169     CFLAGS="$all_flags"
1170     AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1171     AC_TRY_COMPILE([],[return 0;],
1172         AC_MSG_RESULT([yes]),
1173         AC_MSG_ERROR([no]))
1175     CFLAGS="$_SAVE_CFLAGS $all_flags"
1176     CXXFLAGS="$CXXFLAGS $all_flags"
1177     ASFLAGS="$ASFLAGS $all_flags"
1178     if test -n "$thumb_flag"; then
1179         LDFLAGS="$LDFLAGS $thumb_flag"
1180     fi
1183 dnl ========================================================
1184 dnl Override of system specific host options
1185 dnl ========================================================
1186 case "$host" in
1187 *-mingw*|*-msys*)
1188     NSINSTALL=nsinstall
1189     ;;
1190 *-cygwin*|*-mks*)
1191     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
1192     if test `echo "${PATH}" | grep -c \;` = 0; then
1193         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
1194     fi
1195     ;;
1196 *-beos*)
1197     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
1198     ;;
1199 *os2*)
1200     ;;
1202     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1203     ;;
1204 esac
1206 dnl ========================================================
1207 dnl Override of system specific target options
1208 dnl ========================================================
1209 case "$target" in
1211 *-aix*)
1212     AC_DEFINE(XP_UNIX)
1213     AC_DEFINE(AIX)
1214     AC_DEFINE(SYSV)
1215     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
1216     AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
1217     case "${target_os}" in
1218     aix3.2*)
1219         AC_DEFINE(AIX_RENAME_SELECT)
1220         AC_DEFINE(_PR_NO_LARGE_FILES)
1221         AIX_LINK_OPTS='-bnso -berok'
1222         PR_MD_ASFILES=os_AIX.s
1223         ;;
1224     aix4.1*)
1225         AC_DEFINE(AIX_TIMERS)
1226         AC_DEFINE(_PR_NO_LARGE_FILES)
1227         AC_DEFINE(AIX4_1)
1228         MKSHLIB=
1229         DSO_LDOPTS=
1230         AIX_LINK_OPTS='-bnso -berok'
1231         LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
1232         LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
1233         ;;
1234     aix4.2*)
1235         AC_DEFINE(AIX_TIMERS)
1236         AC_DEFINE(_PR_HAVE_OFF64_T)
1237         AIX_LINK_OPTS='-brtl -bnso -berok'
1238         ;;
1239     aix4.3*)
1240         AC_DEFINE(AIX_TIMERS)
1241         AC_DEFINE(_PR_HAVE_OFF64_T)
1242         AC_DEFINE(AIX4_3_PLUS)
1243         AC_DEFINE(HAVE_SOCKLEN_T)
1244         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1245         USE_IPV6=1
1246         AIX_LINK_OPTS='-brtl -bnso -berok'
1247         ;;
1248     *)
1249         AC_DEFINE(AIX_TIMERS)
1250         AC_DEFINE(_PR_HAVE_OFF64_T)
1251         AC_DEFINE(AIX4_3_PLUS)
1252         AC_DEFINE(HAVE_SOCKLEN_T)
1253         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1254         USE_IPV6=1
1255         AIX_LINK_OPTS='-brtl -bnso -berok'
1256         ;;
1257     esac
1258     CFLAGS="$CFLAGS -qro -qroconst"
1259     AIX_WRAP='$(DIST)/lib/aixwrap.o'
1260     AIX_TMP='./_aix_tmp.o'
1261     if test -n "$USE_64"; then
1262         MDCPUCFG_H=_aix64.cfg
1263         OBJECT_MODE=64
1264     else
1265         MDCPUCFG_H=_aix32.cfg
1266     fi
1267     PR_MD_CSRCS=aix.c
1268     RESOLVE_LINK_SYMBOLS=1
1269     ;;
1270         
1271 *-beos*)
1272     AC_DEFINE(XP_BEOS)
1273     AC_DEFINE(BeOS)
1274     AC_DEFINE(BEOS)
1275     AC_DEFINE(_POSIX_SOURCE)
1276     DSO_LDOPTS=-nostart
1277     MDCPUCFG_H=_beos.cfg
1278     USE_BTHREADS=1
1279     PR_MD_ARCH_DIR=beos
1280     RESOLVE_LINK_SYMBOLS=1
1281     case "${target_cpu}" in
1282     i*86)
1283         _OPTIMIZE_FLAGS=-O2
1284         _DEBUG_FLAGS='-gdwarf-2 -O0'
1285         MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
1286         AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"])
1287         ;;
1288     powerpc)
1289         CC=mwcc
1290         CCC=mwcc
1291         LD=mwld
1292         DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o'
1293         _OPTIMIZE_FLAGS=-O2    
1294         _DEBUG_FLAGS='-g -O0'
1295         ;;
1296     esac
1297     ;;
1299 *-bsdi*)
1300     AC_DEFINE(XP_UNIX)
1301     AC_DEFINE(BSDI)
1302     AC_DEFINE(NEED_BSDREGEX)
1304     CFLAGS="$CFLAGS -Wall -Wno-format"
1305     CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
1307     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1308         CPU_ARCH=x86
1309     elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
1310         CPU_ARCH=sparc
1311     fi
1313     MDCPUCFG_H=_bsdi.cfg
1314     PR_MD_CSRCS=bsdi.c
1316     DSO_LDOPTS=-r
1318     case "$target_os" in
1319     bsdi1.1*)
1320         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1321         AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
1322         AC_DEFINE(_PR_NEED_H_ERRNO)
1323         MKSHLIB=
1324         DSO_CFLAGS=
1325         DSO_LDOPTS=
1326         ;;
1328     bsdi2.1*)
1329         AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
1330         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1331         AC_DEFINE(HAVE_DLL)
1332         AC_DEFINE(USE_DLFCN)
1333         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1334         PR_MD_ASFILES=os_BSD_OS_386_2.s
1335         ;;
1337     bsdi4.* | bsdi5.*)
1338         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1339         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1340         AC_DEFINE(HAVE_DLL)
1341         AC_DEFINE(USE_DLFCN)
1342         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1343         MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1344         DSO_CFLAGS=-fPIC
1345         DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
1346         STRIP="$STRIP -d"
1347         case "$target_os" in
1348         bsdi4.2* | bsdi4.3* | bsdi5.*)
1349             AC_DEFINE(_PR_HAVE_GETPROTO_R)
1350             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1351             ;;
1352         esac
1353         ;;
1354     *)
1355         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1356         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1357         AC_DEFINE(HAVE_DLL)
1358         AC_DEFINE(USE_DLFCN)
1359         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1360         ;;
1361     esac
1363     ;;
1365 *-darwin*)
1366     AC_DEFINE(XP_UNIX)
1367     AC_DEFINE(DARWIN)
1368     AC_DEFINE(HAVE_BSD_FLOCK)
1369     AC_DEFINE(HAVE_SOCKLEN_T)
1370     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1371     changequote(,)
1372     HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1373     changequote([,])
1374     if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
1375         AC_DEFINE(HAS_CONNECTX)
1376     fi
1377     AS='$(CC) -x assembler-with-cpp'
1378     CFLAGS="$CFLAGS -Wall -fno-common"
1379     case "${target_cpu}" in
1380         arm*)
1381             CPU_ARCH=arm
1382             ;;
1383         i*86*|x86_64)
1384             if test -n "$USE_64"; then
1385                 CPU_ARCH=x86_64
1386             else        
1387                 CPU_ARCH=i386
1388             fi
1389             ;;
1390         *)
1391             CPU_ARCH=ppc
1392             ;;
1393     esac
1394     if test "`echo $CC | grep -c '\-arch '`" = "0"; then
1395         CC="$CC -arch $CPU_ARCH"
1396     fi
1397     AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
1398     DSO_CFLAGS=-fPIC
1399     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1400     _OPTIMIZE_FLAGS=-O2
1401     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1402     STRIP="$STRIP -x -S"
1403     DLL_SUFFIX=dylib
1404     USE_PTHREADS=1
1405     MDCPUCFG_H=_darwin.cfg
1406     PR_MD_CSRCS=darwin.c
1407     PR_MD_ASFILES=os_Darwin.s
1409     # Add Mac OS X support for loading CFM & CFBundle plugins
1410     if test -f "${MACOS_SDK_DIR}/System/Library/Frameworks/Carbon.framework/Carbon"; then
1411         AC_DEFINE(XP_MACOSX)
1412         OS_TARGET=MacOSX
1414         if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1415             dnl Use the specified value
1416             export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1417         elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1418             dnl No value specified on the command line or in the environment,
1419             dnl use the lesser of the library's minimum or the architecture's
1420             dnl minimum.
1421             case "${target_cpu}" in
1422                 powerpc*)
1423                     dnl Architecture minimum 10.2
1424                     export MACOSX_DEPLOYMENT_TARGET=10.2
1425                     ;;
1426                 i*86*)
1427                     dnl Architecture minimum 10.4
1428                     export MACOSX_DEPLOYMENT_TARGET=10.4
1429                     ;;
1430             esac
1431         fi
1433         dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1434         dnl in use.  NEXT_ROOT will be set and exported if it's needed for
1435         dnl ld.
1437         if test "$MACOS_SDK_DIR"; then
1438             dnl Sync this section with the one in Mozilla's top level.
1440             if test ! -d "$MACOS_SDK_DIR"; then
1441                 AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1442 specify a valid SDK.  SDKs are installed when the optional cross-development
1443 tools are selected during the Xcode/Developer Tools installation.])
1444             fi
1446             changequote(,)
1447             CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1448             GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1449             GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1450             changequote([,])
1451             GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1452             if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1453                 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1454                 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1455                     SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1456                 fi
1458                 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1460                 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1462                 dnl CPP needs to be set for AC_CHECK_HEADER.
1463                 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1465                 changequote(,)
1466                 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1467                 changequote([,])
1468                 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1469                     dnl The build host is running Tiger (10.4) or earlier.
1470                     dnl ld support for -syslibroot is compiler-agnostic, but
1471                     dnl only available on Tiger and later.  On Tiger and
1472                     dnl earlier build hosts, just rely on NEXT_ROOT, because
1473                     dnl it's not been shown to cause any problems.
1474                     MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}"
1475                 else
1476                     dnl The build host is running Leopard (10.5) or later.
1477                     dnl With NEXT_ROOT set, the linker will still not apply
1478                     dnl it when resolving dependencies.  This causes problems
1479                     dnl on Leopard, where an SDK depends on frameworks which
1480                     dnl were present in earlier OS releases (and the associated
1481                     dnl SDK) but not in Leopard.  -syslibroot does not have
1482                     dnl this problem, but it results in harmless warnings when
1483                     dnl NEXT_ROOT is set.  NEXT_ROOT needs to remain set even
1484                     dnl on Leopard because the compiler uses it too.
1485                     MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1486                 fi
1488                 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1489                 export NEXT_ROOT=$MACOS_SDK_DIR
1491                 if test -n "$CROSS_COMPILE" ; then
1492                     dnl NEXT_ROOT will be in the environment, but it
1493                     dnl shouldn't be set for the build host.  HOST_CXX is
1494                     dnl presently unused.
1495                     HOST_CC="NEXT_ROOT= $HOST_CC"
1496                     HOST_CXX="NEXT_ROOT= $HOST_CXX"
1497                 fi
1498             else
1499                 dnl gcc >= 4.0 uses different paths than above, but knows
1500                 dnl how to find them itself.
1501                 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1503                 dnl CPP needs to be set for AC_CHECK_HEADER.
1504                 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1506                 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1507                 dnl has an ld that supports -syslibroot.  Don't set
1508                 dnl NEXT_ROOT because it will be ignored and cause
1509                 dnl warnings when -syslibroot is specified.
1510                 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1511                     dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1512                     dnl based on the -isysroot it receives.
1513                     LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1514                 else
1515                     dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1516                     dnl to be explicit.
1517                     LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1518                 fi
1519             fi
1520         fi
1521     fi
1522     ;;
1524 *-dgux*)
1525     AC_DEFINE(XP_UNIX)
1526     AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
1527     AC_DEFINE(SVR4)
1528     AC_DEFINE(SYSV)
1529     AC_DEFINE(DGUX)
1530     AC_DEFINE(_DGUX_SOURCE)
1531     AC_DEFINE(_POSIX4A_DRAFT6_SOURCE)
1532     DSO_LDOPTS=-G
1533     _OPTIMIZE_FLAGS=-O2
1534     _DEBUG_FLAGS=
1535     MDCPUCFG_H=_dgux.cfg
1536     PR_MD_CSRCS=dgux.c
1537     ;;
1539 *-freebsd*)
1540     if test -z "$USE_NSPR_THREADS"; then
1541         USE_PTHREADS=1
1542     fi
1543     AC_DEFINE(XP_UNIX)
1544     AC_DEFINE(FREEBSD)
1545     AC_DEFINE(HAVE_BSD_FLOCK)
1546     AC_DEFINE(HAVE_SOCKLEN_T)
1547     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1548     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1549     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1550     if test "$MOZ_OBJFORMAT" = "elf"; then
1551         DLL_SUFFIX=so
1552     else
1553         DLL_SUFFIX=so.1.0
1554     fi
1555     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1556     DSO_CFLAGS=-fPIC
1557     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1558     MDCPUCFG_H=_freebsd.cfg
1559     PR_MD_CSRCS=freebsd.c
1560     ;;
1562 *-hpux*)
1563     AC_DEFINE(XP_UNIX)
1564     AC_DEFINE(HPUX)
1565     AC_DEFINE(_HPUX_SOURCE)
1566     # OSF1 and HPUX report the POLLHUP event for a socket when the
1567     # shutdown(SHUT_WR) operation is called for the remote end, even though
1568     # the socket is still writeable. Use select(), instead of poll(), to
1569     # workaround this problem.
1570     AC_DEFINE(_PR_POLL_WITH_SELECT)
1571     AC_DEFINE(_USE_BIG_FDS)
1572     DSO_LDOPTS='-b +h $(notdir $@)'
1573     PR_MD_CSRCS=hpux.c
1574     if test "$OS_TEST" = "ia64"; then
1575         DLL_SUFFIX=so
1576         DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1577         CPU_ARCH_TAG=_$OS_TEST 
1578         if test -z "$USE_64"; then
1579             COMPILER_TAG=_32
1580         fi
1581         PR_MD_ASFILES=os_HPUX_ia64.s
1582     else
1583         AC_DEFINE(hppa)
1584         DLL_SUFFIX=sl
1585         PR_MD_ASFILES=os_HPUX.s
1586     fi
1587     if test -n "$USE_64"; then
1588         MDCPUCFG_H=_hpux64.cfg
1589     else
1590         MDCPUCFG_H=_hpux32.cfg
1591     fi
1592     if test -z "$GNU_CC"; then
1593         CC="$CC -Ae"
1594         CXX="$CXX -ext"
1595         DSO_CFLAGS=+Z
1596     else
1597         DSO_CFLAGS=-fPIC
1598         ASFLAGS="$ASFLAGS -x assembler-with-cpp"
1599     fi
1601     if test -n "$MOZILLA_CLIENT"; then
1602         DEFAULT_IMPL_STRATEGY=_EMU
1603     fi
1605     if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
1606         AC_DEFINE(_PR_NEED_H_ERRNO)
1607         AC_DEFINE(HPUX9)
1608         DEFAULT_IMPL_STRATEGY=_EMU
1609         USE_NSPR_THREADS=1
1610     fi
1612     if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1613         AC_DEFINE(_PR_NO_LARGE_FILES)
1614     fi
1616     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1617         AC_DEFINE(_PR_NEED_H_ERRNO)
1618     fi
1620     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1621         AC_DEFINE(HAVE_INT_LOCALTIME_R)
1622     fi
1624     if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1625         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1626     fi
1628     # HP-UX 11i v2 (B.11.23) or higher
1629     changequote(<<,>>)
1630     case "$OS_RELEASE" in
1631     [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1632         USE_IPV6=1
1633         ;;
1634     esac
1635     changequote([,])
1637     if test "$OS_RELEASE" = "B.10.01"; then
1638         AC_DEFINE(HPUX10)
1639         DEFAULT_IMPL_STRATEGY=_EMU
1640     fi
1642     if test "$OS_RELEASE" = "B.10.10"; then
1643         AC_DEFINE(HPUX10)
1644         AC_DEFINE(HPUX10_10)
1645         DEFAULT_IMPL_STRATEGY=_PTH
1646     fi
1648     if test "$OS_RELEASE" = "B.10.20"; then
1649         AC_DEFINE(HPUX10)
1650         AC_DEFINE(HPUX10_20)
1651         if test -z "$GNU_CC"; then
1652             CFLAGS="$CFLAGS +DAportable +DS1.1"
1653             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1654         fi
1655         DEFAULT_IMPL_STRATEGY=_PTH
1656     fi
1658     if test "$OS_RELEASE" = "B.10.30"; then
1659         AC_DEFINE(HPUX10)
1660         AC_DEFINE(HPUX10_30)
1661         if test -z "$GNU_CC"; then
1662             CFLAGS="$CFLAGS +DAportable +DS1.1"
1663             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1664         fi
1665         DEFAULT_IMPL_STRATEGY=_PTH
1666     fi
1668     if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1669         AC_DEFINE(HPUX10)
1670         AC_DEFINE(HPUX11)
1671         AC_DEFINE(_LARGEFILE64_SOURCE)
1672         AC_DEFINE(_PR_HAVE_OFF64_T)
1673         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1674         if test -z "$GNU_CC"; then
1675             if test -z "$USE_64"; then
1676                 if test "$OS_TEST" = "ia64"; then
1677                     CFLAGS="$CFLAGS +DD32"
1678                     CXXFLAGS="$CXXFLAGS +DD32"
1679                 else
1680                     CFLAGS="$CFLAGS +DAportable +DS2.0"
1681                     CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1682                 fi
1683             else
1684                 if test "$OS_TEST" = "ia64"; then
1685                     CFLAGS="$CFLAGS +DD64"
1686                     CXXFLAGS="$CXXFLAGS +DD64"
1687                 else
1688                     CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1689                     CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1690                 fi
1691             fi
1692         fi
1693         DEFAULT_IMPL_STRATEGY=_PTH
1694     fi
1696     if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1697         USE_NSPR_THREADS=1
1698         USE_PTHREADS=
1699         USE_USER_PTHREADS=
1700     elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1701         USE_PTHREADS=1
1702         if test "$USE_NSPR_THREADS"; then
1703             USE_PTHREADS=
1704         fi
1705         if test "$USE_USER_PTHREADS"; then
1706             USE_PTHREADS=
1707         fi
1708     fi
1709     ;;
1711 *-irix*)
1712     AC_DEFINE(XP_UNIX)
1713     AC_DEFINE(IRIX)
1714     AC_DEFINE(SVR4)
1715     AC_DEFINE(_SGI_MP_SOURCE)
1716     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1717     PR_MD_CSRCS=irix.c
1718     PR_MD_ASFILES=os_Irix.s
1719     MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
1720     STRIP="$STRIP -f"
1721     RESOLVE_LINK_SYMBOLS=1
1722     if test -n "$USE_64"; then
1723         MDCPUCFG_H=_irix64.cfg
1724     else
1725         MDCPUCFG_H=_irix32.cfg
1726     fi
1727     case "${target_os}" in
1728     irix6*)
1729         AC_DEFINE(IRIX6)
1730         USE_PTHREADS=1
1731         USE_N32=1
1732         COMPILER_TAG=_n32
1733         IMPL_STRATEGY=_PTH
1734         ;;
1735     irix5*)
1736         AC_DEFINE(IRIX5)
1737         USE_NSPR_THREADS=1
1738         ;;
1739     *)
1740         USE_PTHREADS=1
1741         USE_N32=1
1742         ;;
1743     esac
1744     if test "$GNU_CC"; then
1745         dnl
1746         dnl If we are using gcc with native binutils, we need to
1747         dnl suppress the
1748         dnl #lineno "filename" num num
1749         dnl lines, which confuse IRIX native as.  Add -Wp,-P to the
1750         dnl gcc command line, which passes -P to the preprocessor.
1751         dnl
1752             AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
1753             CFLAGS="$CFLAGS -Wall -Wno-format"
1754             _OPTIMIZE_FLAGS="-O6"
1755     else
1756             if test -n "$USE_N32"; then
1757                 AS='as -D_ASM $(INCLUDES) -n32'
1758             else
1759                 AS='as -D_ASM $(INCLUDES)'
1760             fi
1761             CFLAGS="$CFLAGS -fullwarn -xansi"
1762             if test "$USE_N32"; then
1763                 _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000"
1764             else
1765                 _OPTIMIZE_FLAGS="-O -Olimit 4000"
1766             fi
1767             if test "$USE_MDUPDATE"; then
1768                 CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
1769             fi
1770             case "${target}" in
1771             *-irix6.*)
1772                 CFLAGS="$CFLAGS -multigot"
1773                 DSO_LDOPTS="-no_unresolved"
1774                 if test "$USE_N32"; then
1775                         CFLAGS="$CFLAGS -n32 -woff 1209"
1776                         DSO_LDOPTS="$DSO_LDOPTS -n32"
1777                 else
1778                         if test "$USE_64"; then
1779                             CFLAGS="$CFLAGS -64"
1780                         else
1781                             CFLAGS="$CFLAGS -32"
1782                         fi
1783                 fi
1784                 ;;
1785             *)
1786                 CFLAGS="$CFLAGS -xgot"
1787                 ;;
1788             esac
1789     fi
1790     if test "${target_os}" = "irix5.3"; then
1791             AC_DEFINE(IRIX5_3)
1792     fi
1793     case "${target_os}" in
1794         irix6.5)
1795             if test -z "$GNU_CC"; then
1796                     CFLAGS="$CFLAGS -mips3"
1797             fi
1798             AC_DEFINE(_PR_HAVE_GETPROTO_R)
1799             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1800             AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
1801             ;;
1802         irix5*)
1803             ;;
1804         *)
1805             AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
1806             ;;
1807         esac
1808     ;;
1810 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
1811     if test -z "$USE_NSPR_THREADS"; then
1812         USE_PTHREADS=1
1813         IMPL_STRATEGY=_PTH
1814     fi
1815     AC_DEFINE(XP_UNIX)
1816     AC_DEFINE(_GNU_SOURCE)
1817     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1818     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1819     case "${target}" in
1820     *-android*|*-linuxandroid*)
1821         OS_TARGET=Android
1822         AC_DEFINE(LINUX)
1823         ;;
1824     *-linux*)
1825         AC_DEFINE(LINUX)
1826         ;;
1827     esac
1828     CFLAGS="$CFLAGS -Wall"
1829     CXXFLAGS="$CXXFLAGS -Wall"
1830     MDCPUCFG_H=_linux.cfg
1831     PR_MD_CSRCS=linux.c
1832     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1833     DSO_CFLAGS=-fPIC
1834     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1835     _OPTIMIZE_FLAGS=-O2
1836     _DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb, and that
1837                                    # combo is not yet good at debugging inlined
1838                                    # functions (even when using DWARF2 as the
1839                                    # debugging format)
1840     COMPILER_TAG=_glibc
1841     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1842         CPU_ARCH=x86
1843     else
1844         CPU_ARCH=$OS_TEST
1845     fi
1846     CPU_ARCH_TAG=_${CPU_ARCH}
1847     case "${target_cpu}" in
1848     alpha)
1849         AC_DEFINE(_ALPHA_)
1850         AC_DEFINE(__alpha)
1851         CFLAGS="$CFLAGS -mieee"
1852         CXXFLAGS="$CXXFLAGS -mieee"
1853         ;;
1854     i*86)
1855         AC_DEFINE(i386)
1856         PR_MD_ASFILES=os_Linux_x86.s
1857         ;;
1858     ia64)
1859         PR_MD_ASFILES=os_Linux_ia64.s
1860         ;;
1861     x86_64)
1862         if test -n "$USE_64"; then
1863             PR_MD_ASFILES=os_Linux_x86_64.s
1864         elif test -n "$USE_X32"; then
1865             PR_MD_ASFILES=os_Linux_x86_64.s
1866             CC="$CC -mx32"
1867             CXX="$CXX -mx32"
1868         else
1869             AC_DEFINE(i386)
1870             PR_MD_ASFILES=os_Linux_x86.s
1871             CC="$CC -m32"
1872             CXX="$CXX -m32"
1873         fi
1874         ;;
1875     ppc|powerpc)
1876         PR_MD_ASFILES=os_Linux_ppc.s
1877         ;;
1878     powerpc64)
1879         if test -n "$USE_64"; then
1880             CC="$CC -m64"
1881             CXX="$CXX -m64"
1882         else
1883             PR_MD_ASFILES=os_Linux_ppc.s
1884         fi
1885         ;;
1886     esac    
1887     ;;
1889 *-mingw*|*-msys*|*-cygwin*|*-mks*)
1890     AC_DEFINE(XP_PC)
1891     AC_DEFINE(WIN32)
1892     PR_MD_ARCH_DIR=windows
1893     RESOLVE_LINK_SYMBOLS=1
1895     if test -n "$GNU_CC"; then
1896         CC="$CC -mwindows"
1897         CXX="$CXX -mwindows"
1898         DLL_SUFFIX=dll
1899         MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1900         RC=$WINDRES
1901         # Use temp file for windres (bug 213281)
1902         RCFLAGS='-O coff --use-temp-file'
1903     else
1904         LD=link
1905         AR='lib -NOLOGO -OUT:"$@"'
1906         AR_FLAGS=
1907         RANLIB='echo not_ranlib'
1908         STRIP='echo not_strip'
1909         RC=rc.exe
1910         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1911         OBJ_SUFFIX=obj
1912         LIB_SUFFIX=lib
1913         DLL_SUFFIX=dll
1915         # Determine compiler version
1916         changequote(,)
1917         _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
1918         changequote([,])
1919         CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
1920         if test -z "$CC_VERSION"; then
1921             AC_MSG_ERROR([Could not determine MSC version.])
1922         fi
1924         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
1925         _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
1926         _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
1927         _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
1928         MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
1930         if test "$_CC_MAJOR_VERSION" -eq "14"; then
1931            dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
1932            dnl so be very specific here!
1933            dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
1934            if test $_CC_RELEASE -gt 50727; then
1935               _USE_DYNAMICBASE=1
1936            elif test $_CC_BUILD -ge 762; then
1937               _USE_DYNAMICBASE=1
1938            fi
1939            AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
1940            AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
1941         elif test $_CC_MAJOR_VERSION -ge 15; then
1942            _USE_DYNAMICBASE=1    
1943            AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
1944            AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
1945         fi
1947         if test -n "$_USE_DYNAMICBASE"; then
1948            DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
1949         fi
1951         # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
1952         # tape manipulation utility (or something else)
1953         if test "$MSC_VER" -ge "1400"; then
1954             changequote(,)
1955             _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
1956             changequote([,])
1958             MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
1959             if test -n "$MSMT_TOOL"; then
1960                 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
1961                 if test -z "$MSMANIFEST_TOOL_VERSION"; then
1962                     AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
1963                 fi
1964                 MT=mt
1965                 unset MSMT_TOOL
1966             else
1967                 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
1968             fi
1969         fi
1970         
1971         CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
1972         DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
1973         _DEBUG_FLAGS=-Zi
1974         _OPTIMIZE_FLAGS=-O2
1976         PROFILE_GEN_CFLAGS="-GL"
1977         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
1978         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
1979         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
1981         if test "$MSC_VER" -ge "1800"; then
1982             dnl Visual C++ 2013 requires -FS when parallel building with
1983             dnl make -jN. If not specified, compiler sometimes emits C1041
1984             dnl error.
1985             CFLAGS="$CFLAGS -FS"
1986             dnl -Gw can benefit when using linker optimization on PGO.
1987             dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1988             PROFILE_GEN_CFLAGS="$PROFILE_GEN_CFLAGS -Gw"
1989             PROFILE_USE_CFLAGS="$PROFILE_USE_CFLAGS -Gw"
1990         fi
1992         if test -z "$MOZ_OPTIMIZE"; then
1993             CFLAGS="$CFLAGS -Od"
1994         fi
1996         if test "$USE_DEBUG_RTL" = 1; then
1997             if test -n "$USE_STATIC_RTL"; then
1998                 CFLAGS="$CFLAGS -MTd"
1999             else
2000                 CFLAGS="$CFLAGS -MDd"
2001             fi
2002         else
2003             if test -n "$USE_STATIC_RTL"; then
2004                 CFLAGS="$CFLAGS -MT"
2005             else
2006                 CFLAGS="$CFLAGS -MD"
2007             fi
2008         fi
2010         if test -n "$MOZ_DEBUG"; then
2011             AC_DEFINE(_DEBUG)
2012         else
2013             DEFINES="$DEFINES -U_DEBUG"
2014         fi
2016         if test -n "$MOZ_DEBUG_SYMBOLS"; then
2017             if test -n "$MOZ_OPTIMIZE"; then
2018                 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
2019                 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
2020             else
2021                 DLLFLAGS="$DLLFLAGS -DEBUG"
2022                 LDFLAGS="$LDFLAGS -DEBUG"
2023             fi
2024         fi
2026         OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
2027         if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
2028             OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
2029         fi
2030         
2031         if test "$OS_TARGET" = "WINNT"; then
2032             CFLAGS="$CFLAGS -GT"
2033             LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
2034             LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
2035         else
2036             LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
2037             LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
2038         fi
2039     fi # GNU_CC
2041     if test -n "$USE_STATIC_TLS"; then
2042         AC_DEFINE(_PR_USE_STATIC_TLS)
2043     fi
2045     if test "$OS_TARGET" = "WINNT"; then
2046         AC_DEFINE(WINNT)
2047     else
2048         AC_DEFINE(WIN95)
2049         # undefine WINNT as some versions of mingw gcc define it by default
2050         DEFINES="$DEFINES -UWINNT"
2051         AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
2052     fi
2054     if test "$CPU_ARCH" = "x86"; then
2055         CPU_ARCH_TAG=
2056     else
2057         CPU_ARCH_TAG=$CPU_ARCH
2058     fi
2060     if test "$USE_DEBUG_RTL" = 1; then
2061         OBJDIR_SUFFIX=OBJD
2062     fi
2064     case "$OS_TARGET" in
2065     WINNT)
2066             MDCPUCFG_H=_winnt.cfg
2067             ;;
2068     WIN95)
2069             MDCPUCFG_H=_win95.cfg
2070             ;;
2071     *)
2072             AC_MSG_ERROR([Missing OS_TARGET for ${target}.  Use --enable-win32-target to set.])
2073         ;;
2074     esac
2076     case "$target_cpu" in
2077     i*86)
2078         if test -n "$USE_64"; then
2079             AC_DEFINE(_AMD64_)
2080         else            
2081             AC_DEFINE(_X86_)
2082             if test -z "$GNU_CC" -a "$MSC_VER" -ge "1700"; then
2083                 dnl Visual C++ 2012 defaults to -arch:SSE2. Use -arch:IA32
2084                 dnl to avoid requiring SSE2.
2085                 CFLAGS="$CFLAGS -arch:IA32"
2086             fi
2087         fi
2088         ;;
2089     x86_64)
2090             AC_DEFINE(_AMD64_)
2091             USE_64=1
2092             ;;
2093     aarch64)
2094             AC_DEFINE(_ARM64_)
2095             USE_64=1
2096             ;;
2097     ia64)
2098             AC_DEFINE(_IA64_)
2099             USE_64=1
2100             ;;
2101     *)
2102             AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2103             ;;
2104     esac
2105     ;;
2107 *-netbsd*)
2108     AC_DEFINE(XP_UNIX)
2109     AC_DEFINE(NETBSD)
2110     AC_DEFINE(HAVE_BSD_FLOCK)
2111     AC_DEFINE(HAVE_SOCKLEN_T)
2112     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2113     if test -z "$USE_NSPR_THREADS"; then
2114         USE_PTHREADS=1
2115     fi
2116     MDCPUCFG_H=_netbsd.cfg
2117     PR_MD_CSRCS=netbsd.c
2119     DSO_CFLAGS='-fPIC -DPIC'
2120     CFLAGS="$CFLAGS -ansi -Wall"
2121     CXXFLAGS="$CXXFLAGS -ansi -Wall"
2122     MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
2124     if test -z "$OBJECT_FMT"; then
2125         if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
2126             OBJECT_FMT=a.out
2127             DLL_SUFFIX=so.1.0
2128             DSO_LDOPTS='-shared'
2129         else
2130             OBJECT_FMT=ELF
2131             DLL_SUFFIX=so
2132             DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
2133         fi
2134     fi
2136     if test "$LIBRUNPATH"; then
2137         DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
2138     fi
2139     ;;
2141 *-nto*)
2142     AC_DEFINE(XP_UNIX)
2143     AC_DEFINE(NTO)
2144     AC_DEFINE(_QNX_SOURCE)
2145     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2146     MDCPUCFG_H=_nto.cfg
2147     PR_MD_CSRCS=nto.c
2148     MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
2149     DSO_CFLAGS=-fPIC
2150     DSO_LDOPTS=-shared
2151     OS_LIBS="$OS_LIBS -lsocket"
2152     _OPTIMIZE_FLAGS="-O1"
2153     _DEBUG_FLAGS="-gstabs"
2154         ;;
2156 *-openbsd*)
2157     AC_DEFINE(XP_UNIX)
2158     AC_DEFINE(OPENBSD)
2159     AC_DEFINE(HAVE_BSD_FLOCK)
2160     AC_DEFINE(HAVE_SOCKLEN_T)
2161     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2162     CFLAGS="$CFLAGS -ansi -Wall"
2163     CXXFLAGS="$CXXFLAGS -ansi -Wall"
2164     DLL_SUFFIX=so.1.0
2165     DSO_CFLAGS=-fPIC
2166     MDCPUCFG_H=_openbsd.cfg
2167     PR_MD_CSRCS=openbsd.c
2168     OS_LIBS="-lc"
2169     if test -z "$USE_NSPR_THREADS"; then
2170         USE_PTHREADS=1
2171     fi
2172     DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
2173     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2174     ;;
2176 *-osf*)
2177     SHELL_OVERRIDE="SHELL               = /usr/bin/ksh"
2178     AC_DEFINE(XP_UNIX)
2179     AC_DEFINE(OSF1)
2180     AC_DEFINE(_REENTRANT)
2181     # OSF1 and HPUX report the POLLHUP event for a socket when the
2182     # shutdown(SHUT_WR) operation is called for the remote end, even though
2183     # the socket is still writeable. Use select(), instead of poll(), to
2184     # workaround this problem.
2185     AC_DEFINE(_PR_POLL_WITH_SELECT)
2187     if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then
2188         USE_NSPR_THREADS=1
2189     fi
2191     if test -z "$GNU_CC"; then
2192         CC="$CC -std1 -ieee_with_inexact"
2193         if test "$OS_RELEASE" != "V2.0"; then
2194             CC="$CC -readonly_strings"
2195         fi
2196         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
2197         AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H))
2198     else
2199         CFLAGS="$CFLAGS -mieee"
2200         CXXFLAGS="$CXXFLAGS -mieee"
2201     fi
2203     if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
2204         AC_DEFINE(HAVE_INT_LOCALTIME_R)
2205     else
2206         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2207         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2208     fi
2209     if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then
2210         AC_DEFINE(OSF1V4_MAP_PRIVATE_BUG)
2211     fi
2212     DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)'
2213     MDCPUCFG_H=_osf1.cfg
2214     PR_MD_CSRCS=osf1.c
2215     ;;
2217 *-qnx*)
2218     AC_DEFINE(XP_UNIX)
2219     AC_DEFINE(QNX)
2220     AC_DEFINE(_PR_NEED_H_ERRNO)
2221     USE_NSPR_THREADS=1
2222     MDCPUCFG_H=_qnx.cfg
2223     PR_MD_CSRCS=qnx.c
2224     ;;
2226 *-riscos*)
2227     AC_DEFINE(XP_UNIX)
2228     AC_DEFINE(RISCOS)
2229     AC_DEFINE(_PR_NEED_H_ERRNO)
2230     USE_PTHREADS=1
2231     MDCPUCFG_H=_riscos.cfg
2232     PR_MD_CSRCS=riscos.c
2233     DSO_CFLAGS=-fPIC
2234     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
2235     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2236     ;;
2238 *-*-sco*)
2239     AC_DEFINE(XP_UNIX)
2240     AC_DEFINE(SCO)
2241     AC_DEFINE(sco)
2242     AC_DEFINE(SYSV)
2243     AC_DEFINE(_SVID3)
2244     AC_DEFINE(_PR_NEED_H_ERRNO)
2245     CC='cc -b elf -KPIC'
2246     CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
2247     USE_NSPR_THREADS=1
2248     CPU_ARCH=x86
2249     DSO_LDOPTS='-b elf -G'
2250     MDCPUCFG_H=_scoos.cfg
2251     PR_MD_SRCS=scoos.c
2252     ;;
2254 *-solaris*)
2255     if test -z "$USE_NSPR_THREADS"; then
2256         USE_PTHREADS=1
2257     fi
2258     AC_DEFINE(XP_UNIX)
2259     AC_DEFINE(SVR4)
2260     AC_DEFINE(SYSV)
2261     AC_DEFINE(__svr4)
2262     AC_DEFINE(__svr4__)
2263     AC_DEFINE(SOLARIS)
2264     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2265     CPU_ARCH=`uname -p`
2266     MDCPUCFG_H=_solaris.cfg
2267     PR_MD_CSRCS=solaris.c
2268     LD=/usr/ccs/bin/ld
2269     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2270     RESOLVE_LINK_SYMBOLS=1
2271     case "${OS_RELEASE}" in
2272     5.8|5.9)
2273         ;;
2274     *)
2275         # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
2276         USE_B_DIRECT=1
2277         ;;
2278     esac
2279     if test -n "$GNU_CC"; then
2280         DSO_CFLAGS=-fPIC
2281         if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
2282             GCC_USE_GNU_LD=1
2283         fi
2284         DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore' 
2285         if test -n "$USE_B_DIRECT"; then
2286             DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
2287         fi
2288     else
2289         DSO_CFLAGS=-KPIC
2290         DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
2291         if test -n "$USE_B_DIRECT"; then
2292             DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
2293         fi
2294     fi
2295     if test -n "$GNU_CC"; then
2296         CFLAGS="$CFLAGS -Wall"
2297         CXXFLAGS="$CXXFLAGS -Wall"
2298         if test -n "$USE_MDUPDATE"; then
2299             CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
2300             CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
2301         fi
2302         GCC_AS=`$CC -print-prog-name=as`
2303         if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
2304             GNU_AS=1
2305         fi
2306     else
2307         CFLAGS="$CFLAGS -xstrconst"
2308         CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
2309         if test -z "$MOZ_OPTIMIZE"; then
2310             CFLAGS="$CFLAGS -xs"
2311             CXXFLAGS="$CXXFLAGS -xs"
2312         fi
2313         _OPTIMIZE_FLAGS=-xO4
2314     fi
2315     if test -z "$GNU_AS"; then
2316         ASFLAGS="$ASFLAGS -Wa,-P"
2317     fi
2318     if test -n "$USE_64"; then
2319         if test -n "$GNU_CC"; then
2320             CC="$CC -m64"
2321             CXX="$CXX -m64"
2322         else
2323             if test "$OS_TEST" = "i86pc"; then
2324                 CC="$CC -xarch=amd64"
2325                 CXX="$CXX -xarch=amd64"
2326             else
2327                 CC="$CC -xarch=v9"
2328                 CXX="$CXX -xarch=v9"
2329             fi
2330         fi
2331     fi
2332     if test "$OS_TEST" = "i86pc"; then
2333         if test -z "$USE_64"; then
2334             AC_DEFINE(i386)
2335         fi
2336         CPU_ARCH_TAG=_$OS_TEST
2337         # The default debug format, DWARF (-g), is not supported by gcc
2338         # on i386-ANY-sysv4/solaris, but the stabs format is.  It is
2339         # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2340         # If your gcc uses GNU as, you do not need the -Wa,-s option.
2341         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2342             _DEBUG_FLAGS=-gstabs
2343             if test -z "$GNU_AS"; then
2344                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2345             fi
2346         fi
2347     fi
2348     case "${target_os}" in
2349     solaris2.3*)
2350         AC_DEFINE(_PR_NO_LARGE_FILES)
2351         ;;
2352     solaris2.4*)
2353         AC_DEFINE(_PR_NO_LARGE_FILES)
2354         ;;
2355     solaris2.5*)
2356         AC_DEFINE(SOLARIS2_5)    
2357         ;;
2358     *)
2359         AC_DEFINE(_PR_HAVE_OFF64_T)
2360         # The lfcompile64(5) man page on Solaris 2.6 says:
2361         #     For applications that do not wish to conform to the POSIX or
2362         #     X/Open  specifications,  the  64-bit transitional interfaces
2363         #     are available by default.  No compile-time flags need to  be
2364         #     set.
2365         # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2366         # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2367         if test -n "$GNU_CC"; then
2368             AC_DEFINE(_LARGEFILE64_SOURCE)
2369         fi
2370         ;;
2371     esac
2372     case "${target_os}" in
2373     solaris2.3*)
2374         ;;
2375     solaris2.4*)
2376         ;;
2377     solaris2.5*)
2378         ;;
2379     solaris2.6*)
2380         ;;
2381     solaris2.7*)
2382         ;;
2383     *)
2384         # Solaris 8 or higher has IPv6.
2385         AC_DEFINE(_PR_INET6)
2386         ;;
2387     esac
2388     if test "$CPU_ARCH" = "sparc"; then
2389         # 64-bit Solaris SPARC requires V9 architecture, so the following
2390         # is not needed.
2391         if test -z "$USE_64"; then
2392             ULTRASPARC_LIBRARY=nspr_flt
2393         fi
2394     fi
2395     # Purify requires that binaries linked against nspr also
2396     # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2397     _rev=`uname -r`
2398     _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2399     OS_LIBS="$OS_LIBS $_librt"
2400     ;;
2402 *-sco-sysv5*)
2403     AC_DEFINE(XP_UNIX)
2404     AC_DEFINE(UNIXWARE)
2405     AC_DEFINE(SVR4)
2406     AC_DEFINE(SYSV)
2407     USE_NSPR_THREADS=1
2408     if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
2409         AC_DEFINE(_PR_NO_LARGE_FILES)
2410         CC='$(NSDEPTH)/build/hcc cc'
2411         CXX='$(NSDEPTH)/build/hcpp CC'
2412         MDCPUCFG_H=_unixware.cfg
2413     else
2414         AC_DEFINE(_LARGEFILE64_SOURCE)
2415         AC_DEFINE(_PR_HAVE_OFF64_T)
2416         AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
2417         MDCPUCFG_H=_unixware7.cfg
2418     fi
2419     PR_MD_CSRCS=unixware.c
2420     DSO_LDOPTS=-G
2421     CPU_ARCH=x86
2422     ;;
2424 *-symbian*)
2425     AC_ARG_WITH(symbian-sdk,
2426     [  --with-symbian-sdk=SYMBIAN_SDK_DIR
2427                           The path to the Symbian SDK],
2428     SYMBIAN_SDK_DIR=$withval)
2430     echo -----------------------------------------------------------------------------
2431     echo Building with Symbian SDK in: $SYMBIAN_SDK_DIR
2432     echo -----------------------------------------------------------------------------
2434     AC_DEFINE(XP_UNIX)
2435     AC_DEFINE(SYMBIAN)
2436     AC_DEFINE(__arm__)
2437     AC_DEFINE(__SYMBIAN32__)
2438     AC_DEFINE(_UNICODE)
2439     AC_DEFINE(NDEBUG)
2440     AC_DEFINE(__SUPPORT_CPP_EXCEPTIONS__)
2441     AC_DEFINE(MOZ_STDERR_TO_STDOUT)
2442     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2443     AC_DEFINE(HAVE_SOCKLEN_T)
2444     USE_PTHREADS=1
2445     LIB_SUFFIX=lib
2446     DLL_SUFFIX=dll
2447     MKSHLIB=
2448     DSO_LDOPTS=
2449     DSO_CFLAGS=
2450     VISIBILITY_FLAGS=
2451     MDCPUCFG_H=_symbian.cfg
2452     PR_MD_CSRCS=symbian.c
2453     NSINSTALL=nsinstall
2454     RANLIB='echo no ranlib '
2455     CPU_ARCH=ARM
2456     OS_ARCH=SYMBIAN
2457     OS_EXE_CFLAGS="$OS_EXE_CFLAGS -D__EXE__"
2458     CFLAGS="$CFLAGS -MD -nostdinc"
2459     SYMBIAN_SYS_INCLUDE="-I$SYMBIAN_SDK_DIR/Epoc32/include/variant -I$SYMBIAN_SDK_DIR/Epoc32/include -I$SYMBIAN_SDK_DIR/Epoc32/include/stdapis"
2460     echo -------------------------------------------------------
2461     echo SYMBIAN_SYS_INCLUDE is: $SYMBIAN_SYS_INCLUDE
2462     echo -------------------------------------------------------
2463     case "$OS_TARGET" in
2464     WINSCW)
2465         CC=mwccsym2.exe
2466         CXX=mwccsym2.exe
2467         LD=mwldsym2.exe
2468         AR=mwldsym2.exe
2469         WINSCW_LD_DIR="\$(SYMBIAN_SDK_DIR)/EPOC32/RELEASE/WINSCW/UDEB"
2470         CFLAGS="$CFLAGS -O0 -inline off -wchar_t off -align 4 -warnings on -w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostderr -gccdep -cwd source -i- -I\$(VPATH)"
2471         SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include Symbian_OS_v9.2.hrh"
2472         AR_FLAGS="-library -msgstyle gcc -stdlib -subsystem windows -noimplib -o \$@"
2473         AC_DEFINE(_DEBUG)
2474         AC_DEFINE(__CW32__)
2475         AC_DEFINE(__WINS__)
2476         AC_DEFINE(__WINSCW__)
2477         DEFINES="$DEFINES -U_WIN32"
2478             ;;
2479     GCCE)
2480         CFLAGS="$CFLAGS -Wall -Wno-unknown-pragmas -fexceptions -march=armv5t -mapcs -pipe -x c -msoft-float"
2481         CXXFLAGS="$CXXFLAGS $CFLAGS -Wno-ctor-dtor-privacy"
2482         SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include $SYMBIAN_SDK_DIR/EPOC32/INCLUDE/GCCE/GCCE.h"
2483         AC_DEFINE(__GCCE__)
2484         AC_DEFINE(__EABI__)
2485         DEFINES="$DEFINES -D__PRODUCT_INCLUDE__=$SYMBIAN_SDK_DIR/Epoc32/include/variant/Symbian_OS_v9.2.hrh"
2486             ;;
2487     *)
2488             AC_MSG_ERROR([Missing OS_TARGET for ${target}. Set --enable-symbian-target to with 'WINSCW' or 'GCCE'.])
2489         ;;
2490     esac
2491     CFLAGS="$CFLAGS ${SYMBIAN_SYS_INCLUDE}"
2492     ;;
2494 *-os2*)
2495     AC_DEFINE(XP_OS2)
2496     AC_DEFINE(XP_PC)
2497     AC_DEFINE(BSD_SELECT)
2498     AC_DEFINE(TCPV40HDRS)
2499     LIB_SUFFIX=lib
2500     DLL_SUFFIX=dll
2501     RC=rc.exe
2502     PR_MD_ARCH_DIR=os2
2503     PROG_SUFFIX=.exe
2504     NSINSTALL=nsinstall
2505     MDCPUCFG_H=_os2.cfg
2506     RESOLVE_LINK_SYMBOLS=1
2508     AC_DEFINE(OS2)
2509     AR=emxomfar
2510     AR_FLAGS='r $@'
2511     CFLAGS="$CFLAGS -Wall -Zomf"
2512     CXXFLAGS="$CFLAGS -Wall -Zomf"
2513     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2514     DSO_CFLAGS=
2515     DSO_LDOPTS='-Zomf -Zdll'
2516     LDFLAGS='-Zmap'
2517     _OPTIMIZE_FLAGS="-O2 -s"
2518     _DEBUG_FLAGS="-g -fno-inline"
2519     if test -n "$MOZ_OPTIMIZE"; then
2520       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2521     fi
2522     IMPLIB='emximp -o'
2523     FILTER='emxexp -o'
2524     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2525       LDFLAGS="$LDFLAGS -Zhigh-mem"
2526       AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2527     fi
2529     # GCC for OS/2 currently predefines these, but we don't want them
2530     DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
2531     ;;
2534     AC_DEFINE(XP_UNIX)
2535     ;;
2536    
2537 esac
2539 if test -z "$SKIP_LIBRARY_CHECKS"; then
2540 dnl ========================================================
2541 dnl Check for system libraries
2542 dnl ========================================================
2545 dnl We don't want anything to link with libdl even if it's present on OS X, 
2546 dnl since it's not used and not part of the default installation.
2547 dnl The same goes for BeOS.
2548 dnl OS/2 has dlfcn in libc.
2550 case $target in
2551 *-darwin*|*-beos*|*-os2*)
2552     ;;
2554     AC_CHECK_LIB(dl, dlopen,
2555         [AC_CHECK_HEADER(dlfcn.h,
2556             OS_LIBS="-ldl $OS_LIBS")])
2557     ;;
2558 esac
2561 dnl ========================================================
2562 dnl Check for system header files.
2563 dnl ========================================================
2565 dnl ========================================================
2566 dnl Check for typedefs and structs
2567 dnl ========================================================
2569 dnl ========================================================
2570 dnl Checks for library functions.
2571 dnl ========================================================
2572 AC_PROG_GCC_TRADITIONAL
2573 _SAVE_LIBS="$LIBS"
2574 LIBS="$LIBS $OS_LIBS"
2575 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
2576  secure_getenv __secure_getenv)
2577 LIBS="$_SAVE_LIBS"
2579 dnl ========================================================
2580 dnl Check options
2581 dnl ========================================================
2583 dnl ======================================================
2584 dnl = Enable compiling with ccache
2585 dnl ======================================================
2586 AC_ARG_WITH(ccache,
2587 [  --with-ccache[=path/to/ccache]
2588                           Enable compiling with ccache],
2589     CCACHE=$withval, CCACHE="no")
2591 if test "$CCACHE" != "no"; then
2592     if test -n "$CCACHE"; then
2593         if test "$CCACHE" = "yes"; then
2594             CCACHE=
2595         else
2596             if test ! -e "$CCACHE"; then
2597                 AC_MSG_ERROR([$CCACHE not found])
2598             fi
2599         fi
2600     fi
2601     AC_PATH_PROGS(CCACHE, $CCACHE ccache)
2602     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
2603         AC_MSG_ERROR([ccache not found])
2604     elif test -x "$CCACHE"; then
2605         CC="$CCACHE $CC"
2606         CXX="$CCACHE $CXX"
2607     else
2608         AC_MSG_ERROR([$CCACHE is not executable])
2609     fi
2612 dnl ========================================================
2613 dnl =
2614 dnl = --enable-strip
2615 dnl = 
2616 dnl = Enable stripping of libs and executables
2617 dnl = 
2618 dnl ========================================================
2619 AC_ARG_ENABLE(strip,
2620     [  --enable-strip          Enable stripping of shared libs and programs],
2621     [ if test "$enableval" = "yes"; then
2622             ENABLE_STRIP=1
2623       fi ])
2625 dnl Check for hpux options
2626 case "${target_os}" in
2627 hpux*)
2628 if test -z "$GNU_CC"; then
2630     AC_CACHE_CHECK(for +Olit support,
2631         ac_cv_hpux_usable_olit_option,
2632         dnl since aCC doesn't throw an error on invalid options,
2633         dnl we have to test this the hard way
2634         [ac_cv_hpux_usable_olit_option=no
2635         rm -f conftest*
2636         echo 'int main() { return 0; }' | cat > conftest.c
2637         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2638         if test $? -eq 0; then
2639             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2640                 ac_cv_hpux_usable_olit_option=yes
2641             fi
2642         fi
2643         rm -f conftest*
2644         ])
2646     if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2647         CFLAGS="$CFLAGS +Olit=all"
2648         CXXFLAGS="$CXXFLAGS +Olit=all"
2649     else
2650         CFLAGS="$CFLAGS +ESlit"
2651         CXXFLAGS="$CXXFLAGS +ESlit"
2652     fi
2655 esac
2657 case "$target_os" in
2658 darwin*)
2659     _HAVE_PTHREADS=1
2660     ;;
2662     AC_CHECK_LIB(pthreads, pthread_create,
2663         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2664         AC_CHECK_LIB(pthread, pthread_create,
2665             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2666             AC_CHECK_LIB(c_r, pthread_create,
2667                 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2668                 AC_CHECK_LIB(c, pthread_create,
2669                     _HAVE_PTHREADS=1
2670                 )
2671             )
2672         )
2673     )
2674     ;;
2675 esac
2677 AC_ARG_WITH(pthreads,
2678     [  --with-pthreads         Use system pthreads library as thread subsystem],
2679     [ if test "$withval" = "yes"; then
2680             if test -n "$_HAVE_PTHREADS"; then
2681                     USE_PTHREADS=1 
2682                     USE_USER_PTHREADS=
2683                     USE_NSPR_THREADS=
2684             else
2685                     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2686             fi
2687           else
2688             USE_PTHREADS=
2689             _PTHREAD_LDFLAGS=
2690           fi],
2691         [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2692             USE_PTHREADS=1
2693             USE_USER_PTHREADS=
2694             USE_NSPR_THREADS=
2695           fi])
2697 AC_ARG_ENABLE(user-pthreads,
2698     [  --enable-user-pthreads  Build using userland pthreads],
2699     [ if test "$enableval" = "yes"; then
2700         if test -n "$_HAVE_PTHREADS"; then
2701                     USE_PTHREADS=
2702                     USE_USER_PTHREADS=1
2703                     USE_NSPR_THREADS=
2704             else
2705                     AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2706             fi
2707           fi])
2709 AC_ARG_ENABLE(nspr-threads,
2710     [  --enable-nspr-threads   Build using classic nspr threads],
2711     [ if test "$enableval" = "yes"; then
2712             USE_PTHREADS=
2713             USE_USER_PTHREADS=
2714             USE_NSPR_THREADS=1
2715           fi])
2717 case "$target" in
2718 *-beos*)
2719     AC_ARG_WITH(bthreads,
2720     [  --with-bthreads         Use system bthreads library as thread subsystem
2721                           (BeOS only)],
2722     [   if test "$withval" = "yes"; then
2723             USE_BTHREADS=1
2724                 USE_USER_PTHREADS=
2725                 USE_PTHREADS=
2726             fi])
2727     ;;
2728 esac
2730 fi # SKIP_LIBRARY_CHECKS
2732 AC_ARG_ENABLE(ipv6,
2733     [  --enable-ipv6           Compile ipv6 support],
2734     [ if test "$enableval" = "yes"; then
2735             USE_IPV6=1
2736       else
2737             USE_IPV6=
2738       fi])
2740 if test -n "$USE_PTHREADS"; then
2741    dnl See if -pthread is supported.
2742    rm -f conftest*
2743    ac_cv_have_dash_pthread=no
2744    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2745    echo 'int main() { return 0; }' | cat > conftest.c
2746    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2747    if test $? -eq 0; then
2748         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2749             ac_cv_have_dash_pthread=yes
2750                 case "$target_os" in
2751             freebsd*)
2752 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2753             ;;
2754             *)
2755             CFLAGS="$CFLAGS -pthread"
2756             CXXFLAGS="$CXXFLAGS -pthread"
2757             ;;
2758         esac
2759         fi
2760     fi
2761     rm -f conftest*
2762     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2764         dnl
2765         dnl See if -pthreads is supported.
2766         dnl
2767     ac_cv_have_dash_pthreads=no
2768     if test "$ac_cv_have_dash_pthread" = "no"; then
2769             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2770         echo 'int main() { return 0; }' | cat > conftest.c
2771             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2772         if test $? -eq 0; then
2773                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2774                             ac_cv_have_dash_pthreads=yes
2775                             CFLAGS="$CFLAGS -pthreads"
2776                             CXXFLAGS="$CXXFLAGS -pthreads"
2777                     fi
2778             fi
2779             rm -f conftest*
2780         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2781     fi
2783     case "$target" in
2784     *-solaris*)
2785         if test "$ac_cv_have_dash_pthreads" = "yes"; then
2786             _PTHREAD_LDFLAGS=
2787         fi
2788             ;;
2789     *-freebsd*)
2790             AC_DEFINE(_REENTRANT)
2791             AC_DEFINE(_THREAD_SAFE)
2792             dnl -pthread links in -lc_r, so don't specify it explicitly.
2793             if test "$ac_cv_have_dash_pthread" = "yes"; then
2794                 _PTHREAD_LDFLAGS="-pthread"
2795             else
2796                 _PTHREAD_LDFLAGS="-lc_r"
2797             fi
2798             ;;
2799     *-netbsd*)
2800             if test "$ac_cv_have_dash_pthread" = "yes"; then
2801                 _PTHREAD_LDFLAGS="-pthread"
2802             fi
2803             ;;
2804     *-bsdi*)
2805             AC_DEFINE(_THREAD_SAFE)
2806             dnl -pthread links in -lc_r, so don't specify it explicitly.
2807             if test "$ac_cv_have_dash_pthread" = "yes"; then
2808                 _PTHREAD_LDFLAGS=
2809             fi
2810             ;;
2811     *-openbsd*)
2812         if test "$ac_cv_have_dash_pthread" = "yes"; then
2813             _PTHREAD_LDFLAGS=-pthread
2814         fi
2815         ;;
2816     *-linux*|*-gnu*|*-k*bsd*-gnu)
2817         AC_DEFINE(_REENTRANT)
2818         ;;
2819     esac
2821 else 
2822     if test -n "$USE_USER_PTHREADS"; then
2823             USE_PTHREADS=
2824             USE_NSPR_THREADS=
2825     else
2826         _PTHREAD_LDFLAGS=
2827     fi
2829 dnl Special thread exceptions
2831 case "$target" in
2832 *-aix*)
2833     if test -n "$USE_NSPR_THREADS"; then
2834         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2835     fi
2836     case "$target_os" in
2837     aix4.1*)
2838         if test -z "$USE_PTHREADS"; then
2839             AC_DEFINE(AIX_RENAME_SELECT)
2840         fi
2841         ;;
2842     aix4.2*)
2843         if test -z "$USE_NSPR_THREADS"; then
2844             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2845         fi
2846         ;;
2847     aix4.3*)
2848         if test -z "$USE_NSPR_THREADS"; then
2849             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2850         fi
2851         if test -n "$USE_PTHREADS"; then
2852             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2853         fi
2854         ;;
2855     *)
2856         if test -z "$USE_NSPR_THREADS"; then
2857             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2858         fi
2859         if test -n "$USE_PTHREADS"; then
2860             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2861         fi
2862         ;;
2863     esac
2864     ;;
2865 *-bsdi*)
2866     if test -n "$USE_PTHREADS"; then
2867         AC_DEFINE(_PR_NEED_PTHREAD_INIT)
2868     fi
2869     ;;
2870 *-freebsd*)
2871     if test -n "$USE_NSPR_THREADS"; then
2872         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2873     fi
2874     ;;
2875 *-hpux*)
2876     if test -n "$USE_NSPR_THREADS"; then
2877         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2878     fi 
2879     if test "$USE_PTHREADS"; then
2880         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2881         AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2882     fi
2883     if test "$USE_USER_PTHREADS"; then
2884         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2885     fi
2886     ;;
2887 *-irix*)
2888     if test "${target_os}" = "irix6.5"; then
2889         if test -n "$USE_PTHREADS"; then
2890             AC_DEFINE(_PR_HAVE_GETHOST_R)
2891             AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2892         fi
2893     fi
2894     ;;
2895 *-linux*|*-gnu*|*-k*bsd*-gnu)
2896     if test -n "$USE_NSPR_THREADS"; then
2897         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2898     fi
2899     ;;
2900 *-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*|*-beos*)
2901     dnl win32, os2 & beos cannot use pthreads
2902     USE_PTHREADS=
2903     _PTHREAD_LDFLAGS=
2904     USE_USER_PTHREADS=
2905     ;;
2906 *-netbsd*|*-openbsd*)
2907     if test -n "$USE_NSPR_THREADS"; then
2908         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2909     fi
2910     ;;
2911 *-osf*)
2912     if test -n "$USE_NSPR_THREADS"; then
2913         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2914     fi
2915     if test -n "$USE_PTHREADS"; then
2916         if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
2917             :
2918         else
2919             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2920         fi
2921     fi
2922     ;;
2923 *-solaris*)
2924     if test -n "$USE_NSPR_THREADS"; then
2925         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2926     fi
2927     if test -n "$USE_PTHREADS"; then
2928         AC_DEFINE(_REENTRANT)
2929         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2930         if test "$OS_TEST" = "i86pc"; then
2931             if test -n "$USE_64"; then
2932                PR_MD_ASFILES=os_SunOS_x86_64.s
2933             else
2934                PR_MD_ASFILES=os_SunOS_x86.s
2935             fi
2936         else
2937             if test -n "$USE_64"; then
2938                 PR_MD_ASFILES=os_SunOS_sparcv9.s
2939             fi
2940         fi
2941     fi
2942     ;;
2943 *-nto*)
2944     if test -n "$USE_PTHREADS"; then
2945         AC_DEFINE(_PR_HAVE_GETHOST_R)
2946         AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2947     fi
2948     ;;
2949 esac
2951 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2953 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2954 dnl make sure that we use it.
2955 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2956     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2959 if test -n "$_SAVE_DEBUG_FLAGS"; then
2960     _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2963 if test -n "$MOZ_OPTIMIZE"; then
2964     CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2965     CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2968 if test -n "$MOZ_DEBUG_SYMBOLS"; then
2969     CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2970     CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2973 if test -n "$MOZ_OPTIMIZE"; then
2974     OBJDIR_TAG=_OPT
2975 else
2976     OBJDIR_TAG=_DBG
2979 if test -n "$USE_64"; then
2980     COMPILER_TAG=_64
2983 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2985 dnl ========================================================
2986 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2987 dnl ========================================================
2988 case "$target_os" in
2989 cygwin*|mks*)
2990     CC="\$(CYGWIN_WRAPPER) $CC"
2991     CXX="\$(CYGWIN_WRAPPER) $CXX"
2992     RC="\$(CYGWIN_WRAPPER) $RC"
2993     ;;
2994 esac
2996 dnl ========================================================
2997 dnl = Use malloc wrapper lib
2998 dnl ========================================================
2999 AC_ARG_ENABLE(wrap-malloc,
3000 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
3001 [     if test "$enableval" = "yes"; then
3002             _WRAP_MALLOC=1
3003       fi ])
3005 if test -n "$_WRAP_MALLOC"; then
3006     if test -n "$GNU_CC"; then
3007         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
3008         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
3009         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
3010         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
3011     else
3012         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
3013     fi
3016 dnl ========================================================
3017 dnl = Location of malloc wrapper lib
3018 dnl ========================================================
3019 AC_ARG_WITH(wrap-malloc,
3020 [  --with-wrap-malloc=SHAREDLIB  Location of malloc wrapper library],
3021     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
3023 dnl ========================================================
3024 dnl Substitution of found variables.
3025 dnl ========================================================
3026 AC_SUBST(SHELL_OVERRIDE)
3028 AC_SUBST(MOZILLA_CLIENT)
3029 AC_SUBST(CC)
3030 AC_SUBST(CXX)
3031 AC_SUBST(CFLAGS)
3032 AC_SUBST(CXXFLAGS)
3033 AC_SUBST(CPPFLAGS)
3034 AC_SUBST(HOST_CC)
3035 AC_SUBST(HOST_CFLAGS)
3036 AC_SUBST(LDFLAGS)
3037 AC_SUBST(HOST_LDFLAGS)
3038 AC_SUBST(GNU_CC)
3039 AC_SUBST(GCC_USE_GNU_LD)
3040 AC_SUBST(MSC_VER)
3041 AC_SUBST(CROSS_COMPILE)
3043 AC_SUBST(MOZ_OPTIMIZE)
3044 AC_SUBST(MOZ_DEBUG)
3045 AC_SUBST(MOZ_DEBUG_SYMBOLS)
3047 AC_SUBST(USE_CPLUS)
3048 AC_SUBST(USE_IPV6)
3049 AC_SUBST(USE_N32)
3050 AC_SUBST(USE_X32)
3051 AC_SUBST(USE_64)
3052 AC_SUBST(OBJECT_MODE)
3053 AC_SUBST(ENABLE_STRIP)
3055 AC_SUBST(USE_PTHREADS)
3056 AC_SUBST(USE_BTHREADS)
3057 AC_SUBST(USE_USER_PTHREADS)
3058 AC_SUBST(USE_NSPR_THREADS)
3060 AC_SUBST(LIBNSPR)
3061 AC_SUBST(LIBPLC)
3063 AC_SUBST(MOD_MAJOR_VERSION)
3064 AC_SUBST(MOD_MINOR_VERSION)
3065 AC_SUBST(MOD_PATCH_VERSION)
3066 AC_SUBST(NSPR_MODNAME)
3067 AC_SUBST(MDCPUCFG_H)
3068 AC_SUBST(PR_MD_CSRCS)
3069 AC_SUBST(PR_MD_ASFILES)
3070 AC_SUBST(PR_MD_ARCH_DIR)
3071 AC_SUBST(CPU_ARCH)
3073 AC_SUBST(OBJ_SUFFIX)
3074 AC_SUBST(LIB_SUFFIX)
3075 AC_SUBST(DLL_SUFFIX)
3076 AC_SUBST(ASM_SUFFIX)
3077 AC_SUBST(WRAP_LDFLAGS)
3078 AC_SUBST(MKSHLIB)
3079 AC_SUBST(DSO_CFLAGS)
3080 AC_SUBST(DSO_LDOPTS)
3082 AC_SUBST(OS_TARGET)
3083 AC_SUBST(OS_ARCH)
3084 AC_SUBST(OS_RELEASE)
3085 AC_SUBST(OS_TEST)
3086 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
3088 AC_SUBST(DEFINES)
3089 AC_SUBST(DEFS)
3090 AC_SUBST(AR)
3091 AC_SUBST(AR_FLAGS)
3092 AC_SUBST(AS)
3093 AC_SUBST(ASFLAGS)
3094 AC_SUBST(LD)
3095 AC_SUBST(RANLIB)
3096 AC_SUBST(PERL)
3097 AC_SUBST(STRIP)
3098 AC_SUBST(FILTER)
3099 AC_SUBST(IMPLIB)
3101 AC_SUBST(PROFILE_GEN_CFLAGS)
3102 AC_SUBST(PROFILE_GEN_LDFLAGS)
3103 AC_SUBST(PROFILE_USE_CFLAGS)
3104 AC_SUBST(PROFILE_USE_LDFLAGS)
3106 AC_SUBST(OS_LIBS)
3107 AC_SUBST(RESOLVE_LINK_SYMBOLS)
3108 AC_SUBST(AIX_LINK_OPTS)
3109 AC_SUBST(NOSUCHFILE)
3110 AC_SUBST(MOZ_OBJFORMAT)
3111 AC_SUBST(ULTRASPARC_LIBRARY)
3113 AC_SUBST(OBJDIR)
3114 AC_SUBST(OBJDIR_NAME)
3115 AC_SUBST(RELEASE_OBJDIR_NAME)
3116 AC_SUBST(NSINSTALL)
3117 AC_SUBST(OPTIMIZER)
3118 AC_SUBST(RC)
3119 AC_SUBST(RCFLAGS)
3120 AC_SUBST(DLLFLAGS)
3121 AC_SUBST(EXEFLAGS)
3122 AC_SUBST(OS_DLLFLAGS)
3123 AC_SUBST(CYGWIN_WRAPPER)
3124 AC_SUBST(VISIBILITY_FLAGS)
3125 AC_SUBST(WRAP_SYSTEM_INCLUDES)
3126 AC_SUBST(MACOS_SDK_DIR)
3127 AC_SUBST(SYMBIAN_SDK_DIR)
3128 AC_SUBST(NEXT_ROOT)
3129 AC_SUBST(MT)
3131 dnl ========================================================
3132 dnl Generate output files.
3133 dnl ========================================================
3134 MAKEFILES="
3135     Makefile
3136     config/Makefile
3137     config/autoconf.mk
3138     config/nsprincl.mk
3139     config/nsprincl.sh
3140     config/nspr-config
3141     config/nspr.pc
3142     lib/Makefile
3143     lib/ds/Makefile
3144     lib/libc/Makefile
3145     lib/libc/include/Makefile
3146     lib/libc/src/Makefile
3147     lib/tests/Makefile
3148     pkg/Makefile
3149     pr/Makefile
3150     pr/include/Makefile
3151     pr/include/md/Makefile
3152     pr/include/obsolete/Makefile
3153     pr/include/private/Makefile
3154     pr/src/Makefile
3155     pr/src/io/Makefile
3156     pr/src/linking/Makefile
3157     pr/src/malloc/Makefile
3158     pr/src/md/Makefile
3159     pr/src/md/${PR_MD_ARCH_DIR}/Makefile
3160     pr/src/memory/Makefile
3161     pr/src/misc/Makefile
3162     pr/src/threads/Makefile
3163     pr/tests/Makefile
3164     pr/tests/dll/Makefile
3167 if test "$OS_TARGET" = "Linux"; then
3168     MAKEFILES="$MAKEFILES
3169         pkg/linux/Makefile
3170     "
3171 elif test "$OS_TARGET" = "SunOS"; then
3172     MAKEFILES="$MAKEFILES
3173         pkg/solaris/Makefile
3174         pkg/solaris/SUNWpr/Makefile
3175         pkg/solaris/SUNWprd/Makefile
3176     "
3179 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
3180     MAKEFILES="$MAKEFILES
3181         pr/src/threads/combined/Makefile
3182     "
3183 elif test -n "$USE_PTHREADS"; then
3184     MAKEFILES="$MAKEFILES
3185         pr/src/pthreads/Makefile
3186     "
3187 elif test -n "$USE_BTHREADS"; then
3188     MAKEFILES="$MAKEFILES
3189         pr/src/bthreads/Makefile
3190     "
3193 if test -n "$USE_CPLUS"; then
3194     MAKEFILES="$MAKEFILES
3195         pr/src/cplus/Makefile
3196         pr/src/cplus/tests/Makefile
3197     "
3200 echo $MAKEFILES > unallmakefiles
3202 AC_CONFIG_FILES([$MAKEFILES])
3203 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])
3204 AC_OUTPUT