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