Bug 1452182 [wpt PR 9921] - [css-grid] Minimum width items should include margins...
[gecko.git] / nsprpub / configure.in
blobea0ae7f8ea582bdb7509eeec7f82bbc06c05c5b2
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=19
19 MOD_PATCH_VERSION=0
20 NSPR_MODNAME=nspr20
21 _HAVE_PTHREADS=
22 USE_PTHREADS=
23 USE_USER_PTHREADS=
24 USE_NSPR_THREADS=
25 USE_N32=
26 USE_X32=
27 USE_64=
28 USE_CPLUS=
29 USE_IPV6=
30 USE_MDUPDATE=
31 _MACOSX_DEPLOYMENT_TARGET=
32 _OPTIMIZE_FLAGS=-O
33 _DEBUG_FLAGS=-g
34 MOZ_DEBUG=1
35 MOZ_OPTIMIZE=
36 OBJDIR='$(OBJDIR_NAME)'
37 OBJDIR_NAME=.
38 OBJDIR_SUFFIX=OBJ
39 NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
40 NOSUCHFILE=/no-such-file
41 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
42 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
43 CYGWIN_WRAPPER=
44 MACOS_SDK_DIR=
45 NEXT_ROOT=
46 MT=
47 MOZ_OS2_HIGH_MEMORY=1
48 PROFILE_GEN_CFLAGS=
49 PROFILE_GEN_LDFLAGS=
50 PROFILE_USE_CFLAGS=
51 PROFILE_USE_LDFLAGS=
53 dnl Link in libraries necessary to resolve all symbols for shared libs
54 RESOLVE_LINK_SYMBOLS=
56 dnl ========================================================
57 dnl =
58 dnl = Dont change the following lines.  Doing so breaks:
59 dnl =
60 dnl = CFLAGS="-foo" ./configure
61 dnl =
62 dnl ========================================================
63 CFLAGS="${CFLAGS=}"
64 CXXFLAGS="${CXXFLAGS=}"
65 LDFLAGS="${LDFLAGS=}"
66 DLLFLAGS="${DLLFLAGS=}"
67 HOST_CFLAGS="${HOST_CFLAGS=}"
68 HOST_LDFLAGS="${HOST_LDFLAGS=}"
70 case "$target" in
71 *-cygwin*|*-mingw*|*-msys*)
72     # Check to see if we are really running in a msvc environemnt
73     _WIN32_MSVC=
74     AC_CHECK_PROGS(CC, cl)
75     cat > conftest.c <<EOF
76 #ifdef _MSC_VER
77 COMPILER IS MSVC
78 #endif
79 EOF
80     read dummy <<EOF
81 $($CC -E conftest.c 2>/dev/null | grep COMPILER)
82 EOF
83     if test -n "$dummy"; then
84         _WIN32_MSVC=1
85         CXX=$CC
86     fi
87     rm -f conftest.c
88     ;;
89 *-mks*)
90     _WIN32_MSVC=1
91     ;;
92 esac
94 if test -n "$_WIN32_MSVC"; then
95     SKIP_PATH_CHECKS=1
96     SKIP_COMPILER_CHECKS=1
97     SKIP_LIBRARY_CHECKS=1
100 dnl ========================================================
101 dnl = Android uses a very custom (hacky) toolchain; we need to do this
102 dnl = here, so that the compiler checks can succeed
103 dnl ========================================================
105 AC_ARG_WITH(android-ndk,
106 [  --with-android-ndk=DIR
107                           location where the Android NDK can be found],
108     android_ndk=$withval)
110 AC_ARG_WITH(android-toolchain,
111 [  --with-android-toolchain=DIR
112                           location of the Android toolchain],
113     android_toolchain=$withval)
115 dnl The default android_version is different for each target cpu.
116 case "$target_cpu" in
117 arm)
118     android_version=5
119     ;;
120 i?86|mipsel)
121     android_version=9
122     ;;
123 esac
125 AC_ARG_WITH(android-version,
126 [  --with-android-version=VER
127                           Android platform version, default 5 for arm, 9 for x86/mips],
128     android_version=$withval)
130 AC_ARG_WITH(android-platform,
131 [  --with-android-platform=DIR
132                           location of platform dir],
133     android_platform=$withval)
135 case "$target" in
136 arm-linux*-android*|*-linuxandroid*)
137     android_tool_prefix="arm-linux-androideabi"
138     ;;
139 i?86-*android*)
140     android_tool_prefix="i686-linux-android"
141     ;;
142 mipsel-*android*)
143     android_tool_prefix="mipsel-linux-android"
144     ;;
146     android_tool_prefix="$target_os"
147     ;;
148 esac
150 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     AC_DEFINE(ANDROID)
164 else
165 case "$target" in
166 *-android*|*-linuxandroid*)
167     if test -z "$android_ndk" ; then
168        AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
169     fi
171     if test -z "$android_toolchain" ; then
172         AC_MSG_CHECKING([for android toolchain directory])
174         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
176         case "$target_cpu" in
177         arm)
178             target_name=arm-linux-androideabi-4.4.3
179             ;;
180         i?86)
181             target_name=x86-4.4.3
182             ;;
183         mipsel)
184             target_name=mipsel-linux-android-4.4.3
185             ;;
186         esac
187         android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
189         if test -d "$android_toolchain" ; then
190             AC_MSG_RESULT([$android_toolchain])
191         else
192             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
193         fi
194     fi
196     if test -z "$android_platform" ; then
197         AC_MSG_CHECKING([for android platform directory])
199         case "$target_cpu" in
200         arm)
201             target_name=arm
202             ;;
203         i?86)
204             target_name=x86
205             ;;
206         mipsel)
207             target_name=mips
208             ;;
209         esac
211         android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
213         if test -d "$android_platform" ; then
214             AC_MSG_RESULT([$android_platform])
215         else
216             AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
217         fi
218     fi
220     dnl Old NDK support. If minimum requirement is changed to NDK r8b,
221     dnl please remove this.
222     case "$target_cpu" in
223     i?86)
224         if ! test -e "$android_toolchain"/bin/"$android_tool_prefix"-gcc; then
225             dnl Old NDK toolchain name
226             android_tool_prefix="i686-android-linux"
227         fi
228         ;;
229     esac
231     dnl set up compilers
232     AS="$android_toolchain"/bin/"$android_tool_prefix"-as
233     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
234     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
235     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
236     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
237     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
238     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
239     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
241     CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
242     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
243     CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
244     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
246     AC_DEFINE(ANDROID)
247     ;;
248 esac
251 dnl ========================================================
252 dnl =
253 dnl = Check options that may affect the compiler
254 dnl =
255 dnl ========================================================
256 dist_prefix='${MOD_DEPTH}/dist'
257 dist_bindir='${dist_prefix}/bin'
258 dist_includedir='${dist_prefix}/include/nspr'
259 dist_libdir='${dist_prefix}/lib'
260 dnl If the --includedir option was not specified, add '/nspr' to autoconf's
261 dnl default value of includedir.
262 if test "${includedir}" = '${prefix}/include'; then
263     includedir='${prefix}/include/nspr'
266 AC_ARG_WITH(dist-prefix,
267     [  --with-dist-prefix=DIST_PREFIX
268                           place build files in DIST_PREFIX [dist]],
269     dist_prefix=$withval)
271 AC_ARG_WITH(dist-bindir,
272     [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
273     dist_bindir=$withval)
275 AC_ARG_WITH(dist-includedir,
276     [  --with-dist-includedir=DIR
277                           build include files in DIR [DIST_PREFIX/include/nspr]],
278     dist_includedir=$withval)
280 AC_ARG_WITH(dist-libdir,
281     [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
282     dist_libdir=$withval)
284 AC_SUBST(dist_prefix)
285 AC_SUBST(dist_bindir)
286 AC_SUBST(dist_includedir)
287 AC_SUBST(dist_libdir)
289 dnl Check if NSPR is being compiled for Mozilla
290 dnl Let --with-arg override environment setting
292 AC_ARG_WITH(mozilla,
293     [  --with-mozilla          Compile NSPR with Mozilla support],
294     [   if test "$withval" = "yes"; then
295             AC_DEFINE(MOZILLA_CLIENT)
296             MOZILLA_CLIENT=1
297             else
298                 MOZILLA_CLIENT=
299             fi],
300     [   if test -n "$MOZILLA_CLIENT"; then
301                 AC_DEFINE(MOZILLA_CLIENT)
302             fi])
304 AC_ARG_ENABLE(optimize,
305     [  --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
306     [ if test "$enableval" != "no"; then
307           MOZ_OPTIMIZE=1
308           if test -n "$enableval" -a "$enableval" != "yes"; then
309             _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
310             _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
311           fi
312       else
313           MOZ_OPTIMIZE=
314       fi ])
316 AC_ARG_ENABLE(debug,
317     [  --enable-debug[=DBG]    Enable debugging (using compiler flags DBG)],
318     [ if test "$enableval" != "no"; then
319           MOZ_DEBUG=1
320           MOZ_DEBUG_SYMBOLS=1
321           if test -n "$enableval" -a "$enableval" != "yes"; then
322               _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
323               _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
324           fi
325       else
326           MOZ_DEBUG=
327       fi ],
328       MOZ_DEBUG_SYMBOLS=1)
330 AC_ARG_ENABLE(debug-symbols,
331     [  --enable-debug-symbols[=DBG]    Enable debugging symbols
332                                        (using compiler flags DBG)],
333     [ if test "$enableval" != "no"; then
334           MOZ_DEBUG_SYMBOLS=1
335           if test -n "$enableval" -a "$enableval" != "yes"; then
336               if test -z "$_SAVE_DEBUG_FLAGS"; then
337                   _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
338                   _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
339               else
340                   AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
341               fi
342           fi
343       else
344           MOZ_DEBUG_SYMBOLS=
345       fi ])
347 AC_ARG_ENABLE(win32-target,
348     [  --enable-win32-target=\$t
349                           Specify win32 flavor. (WIN95 or WINNT)],
350     OS_TARGET=`echo $enableval | tr a-z A-Z`)
352 AC_ARG_ENABLE(symbian-target,
353     [  --enable-symbian-target=\$t
354                           Specify symbian flavor. (WINSCW or GCCE)],
355     OS_TARGET=`echo $enableval | tr a-z A-Z`)
357 AC_ARG_ENABLE(debug-rtl,
358     [  --enable-debug-rtl      Use the MSVC debug runtime library],
359     [ if test "$enableval" = "yes"; then
360             USE_DEBUG_RTL=1
361       else
362             USE_DEBUG_RTL=0
363       fi ])
365 AC_ARG_ENABLE(static-rtl,
366     [  --enable-static-rtl     Use the MSVC static runtime library],
367     [ if test "$enableval" = "yes"; then
368             USE_STATIC_RTL=1
369       fi ])
371 AC_ARG_ENABLE(n32,
372     [  --enable-n32            Enable n32 ABI support (IRIX only)],
373     [ if test "$enableval" = "yes"; then
374         USE_N32=1
375       else if test "$enableval" = "no"; then
376         USE_N32=
377       fi
378     fi ])
380 AC_ARG_ENABLE(x32,
381     [  --enable-x32            Enable x32 ABI support (x86_64 only)],
382     [ if test "$enableval" = "yes"; then
383         USE_X32=1
384       else if test "$enableval" = "no"; then
385         USE_X32=
386       fi
387     fi ])
389 AC_ARG_ENABLE(64bit,
390     [  --enable-64bit          Enable 64-bit support (on certain platforms)],
391     [ if test "$enableval" = "yes"; then
392             USE_64=1
393       fi ])
395 AC_ARG_ENABLE(mdupdate,
396     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
397     [ if test "$enableval" = "yes"; then
398             USE_MDUPDATE=1
399       fi ])
401 AC_ARG_ENABLE(cplus,
402     [  --enable-cplus          Enable some c++ api routines],
403     [ if test "$enableval" = "yes"; then
404             USE_CPLUS=1
405       fi]) 
407 AC_ARG_WITH(arm-kuser,
408     [  --with-arm-kuser        Use kuser helpers (Linux/ARM only)
409                           (Requires kernel 2.6.13 or later)],
410     [ if test "$withval" = "yes"; then
411             AC_DEFINE(_PR_ARM_KUSER)
412       fi ])
414 dnl ========================================================
415 dnl = Mac OS X SDK support
416 dnl ========================================================
417 AC_ARG_WITH(macos-sdk,
418     [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
419     MACOS_SDK_DIR=$withval)
421 AC_ARG_ENABLE(macos-target,
422              [  --enable-macos-target=VER
423                           Set the minimum MacOS version needed at runtime
424                           [10.2 for ppc, 10.4 for x86]],
425              [_MACOSX_DEPLOYMENT_TARGET=$enableval])
427 dnl ========================================================
428 dnl =
429 dnl = Set the threading model
430 dnl =
431 dnl ========================================================
432 case "$target" in
434 *-aix*)
435     case "${target_os}" in
436     aix3.2*)
437         USE_NSPR_THREADS=1
438         ;;
439     *)
440         USE_PTHREADS=1
441         ;;
442     esac
443     ;;
445 esac
447 dnl ========================================================
448 dnl =
449 dnl = Set the default C compiler
450 dnl =
451 dnl ========================================================
452 if test -z "$CC"; then
453     case "$target" in
455     *-aix*)
456         if test -z "$USE_NSPR_THREADS"; then
457             CC=xlc_r
458         else
459             CC=xlc
460         fi
461     ;;
463     *-hpux*)
464         CC=cc
465     ;;
467     *-irix*)
468         CC=cc
469     ;;
471     *-osf*)
472         CC=cc
473     ;;
475     *-solaris*)
476         CC=cc
477     ;;
479     esac
482 dnl ========================================================
483 dnl =
484 dnl = Set the default C++ compiler
485 dnl =
486 dnl ========================================================
487 if test -z "$CXX"; then
488     case "$target" in
490     *-aix*)
491         if test -z "$USE_NSPR_THREADS"; then
492             CXX=xlC_r
493         else
494             CXX=xlC
495         fi
496     ;;
498     *-hpux*)
499         case "${target_os}" in
500         hpux10.30)
501             CXX=aCC
502             ;;
503         hpux11.*)
504             CXX=aCC
505             ;;
506         *)
507             CXX=CC
508             ;;
509         esac
510     ;;
512     *-irix*)
513         CXX=CC
514     ;;
516     *-osf*)
517         CXX=cxx
518     ;;
520     *-solaris*)
521         CXX=CC
522     ;;
524     esac
527 if test -z "$SKIP_PATH_CHECKS"; then
528     AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
531 if test -n "$MOZ_DEBUG"; then
532     AC_DEFINE(DEBUG)
533     DEFINES="$DEFINES -UNDEBUG"
535     case "${target_os}" in
536     beos*)
537         DEFINES="$DEFINES -DDEBUG_${USER}"
538         ;;
539     mks*|cygwin*|mingw*|msys*|os2*)
540         DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
541         ;;
542     *)
543         DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
544         ;;
545     esac
546 else
547     AC_DEFINE(NDEBUG)
548     DEFINES="$DEFINES -UDEBUG"
551 if test -z "$SKIP_COMPILER_CHECKS"; then
552 dnl ========================================================
553 dnl Checks for compilers.
554 dnl ========================================================
555 if test "$target" != "$host"; then
556     echo "cross compiling from $host to $target"
557     cross_compiling=yes
559     case "$build:$target" in
560       powerpc-apple-darwin8*:i?86-apple-darwin*)
561         dnl The Darwin cross compiler doesn't necessarily point itself at a
562         dnl root that has libraries for the proper architecture, it defaults
563         dnl to the system root.  The libraries in the system root on current
564         dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
565         dnl checks will fail.  Fake a working SDK in that case.
566         _SAVE_CFLAGS=$CFLAGS
567         _SAVE_CXXFLAGS=$CXXFLAGS
568         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
569         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
570         ;;
571     esac
573     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
574     unset ac_cv_prog_CC
575     dnl Now exit the conditional block to invoke AC_PROG_CC.
578 dnl In the latest versions of autoconf, AC_PROG_CC is a one-shot macro,
579 dnl declared with AC_DEFUN_ONCE. So it must not be expanded inside a
580 dnl conditional block. Invoke AC_PROG_CC outside any conditional block
581 dnl and before invoking AC_TRY_COMPILE (which requires AC_PROG_CC).
582 AC_PROG_CC
584 dnl Reenter the conditional blocks after invoking AC_PROG_CC.
585 if test "$target" != "$host"; then
586     if test -n "$USE_CPLUS"; then
587         AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
588         unset ac_cv_prog_CXX
589         AC_PROG_CXX
590     fi
592     case "$build:$target" in
593       powerpc-apple-darwin8*:i?86-apple-darwin*|*:arm*-apple-darwin*)
594         dnl Revert the changes made above.  From this point on, the target
595         dnl compiler will never be used without applying the SDK to CFLAGS
596         dnl (see --with-macos-sdk below).
597         CFLAGS=$_SAVE_CFLAGS
598         CXXFLAGS=$_SAVE_CXXFLAGS
599         ;;
600     esac
602     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
603     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
604     AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
605     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
606     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
607     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
609     _SAVE_CC="$CC"
610     _SAVE_CFLAGS="$CFLAGS"
611     _SAVE_LDFLAGS="$LDFLAGS"
613     AC_MSG_CHECKING([for $host compiler])
614     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
615     if test -z "$HOST_CC"; then
616         AC_MSG_ERROR([no acceptable cc found in \$PATH])
617     fi
618     AC_MSG_RESULT([$HOST_CC])
620     CC="$HOST_CC"
621     CFLAGS="$HOST_CFLAGS"
622     LDFLAGS="$HOST_LDFLAGS"
624     AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
625     AC_TRY_COMPILE([], [return 0;],
626         [AC_MSG_RESULT([yes])],
627         [AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.])] )
629     CC=$_SAVE_CC
630     CFLAGS=$_SAVE_CFLAGS
631     LDFLAGS=$_SAVE_LDFLAGS
632 else
633     if test -n "$USE_CPLUS"; then
634         if test "$CC" = "cl" -a -z "$CXX"; then
635             CXX=$CC
636         else
637             AC_PROG_CXX
638         fi
639     fi
640     AC_PROG_RANLIB
641     AC_PATH_PROGS(AS, as, $CC)
642     AC_PATH_PROGS(AR, ar, echo not_ar)
643     AC_PATH_PROGS(LD, ld link, echo not_ld)
644     AC_PATH_PROGS(STRIP, strip, echo not_strip)
645     AC_PATH_PROGS(WINDRES, windres, echo not_windres)
646     if test -z "$HOST_CC"; then
647         HOST_CC="$CC"
648     fi
649     if test -z "$HOST_CFLAGS"; then
650         HOST_CFLAGS="$CFLAGS"
651     fi
654 AC_PROG_CPP
656 if test "$GCC" = "yes"; then
657     GNU_CC=1
659 if test "$GXX" = "yes"; then
660     GNU_CXX=1
662 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
663     GNU_AS=1
665 rm -f a.out
667 case "$build:$target" in
668     i?86-apple-darwin*:powerpc-apple-darwin*)
669         dnl cross_compiling will have erroneously been set to "no" in this
670         dnl case, because the x86 build host is able to run ppc code in a
671         dnl translated environment, making a cross compiler appear native.
672         cross_compiling=yes
673         ;;
674 esac
676 if test "$cross_compiling"  = "yes"; then
677     CROSS_COMPILE=1
678 else
679     CROSS_COMPILE=
682 dnl ========================================================
683 dnl Check for gcc -pipe support
684 dnl ========================================================
685 AC_MSG_CHECKING([for gcc -pipe support])
686 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
687     echo '#include <stdio.h>' > dummy-hello.c
688     echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
689     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
690     cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
691     if test $? = 0; then
692         _res_as_stdin="yes"
693     else
694         _res_as_stdin="no"
695     fi
696     if test "$_res_as_stdin" = "yes"; then
697         _SAVE_CFLAGS=$CFLAGS
698         CFLAGS="$CFLAGS -pipe"
699         AC_TRY_COMPILE( [ #include <stdio.h> ],
700             [printf("Hello World\n");],
701             [_res_gcc_pipe="yes"],
702             [_res_gcc_pipe="no"] )
703         CFLAGS=$_SAVE_CFLAGS
704     fi
705     if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
706         _res="yes";
707         CFLAGS="$CFLAGS -pipe"
708         CXXFLAGS="$CXXFLAGS -pipe"
709     else
710         _res="no"
711     fi
712     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
713     AC_MSG_RESULT([$_res])
714 else
715     AC_MSG_RESULT([no])
718 dnl ========================================================
719 dnl Check for pragma diagnostic
720 dnl ========================================================
722 AC_MSG_CHECKING([for pragma diagnostic])
723 if test "$GNU_CC" = "1"; then
724     cat >dummy-hello.c <<EOF
725 #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
726 #pragma GCC diagnostic push
727 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
728 #endif
729 int main() {
730     char *dummy = "";
731     return 0;
734     ${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
735     if test $? != 0; then
736         ${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
737         if test $? = 0; then
738             CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
739             _res=yes
740         else
741             _res=no
742         fi
743     else
744         _res=no
745     fi
746     rm -f dummy-hello.c dummy-hello.s
747     AC_MSG_RESULT([$_res])
748 else
749     AC_MSG_RESULT([no])
752 dnl ========================================================
753 dnl Profile guided optimization
754 dnl ========================================================
755 dnl Test for profiling options
756 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
758 _SAVE_CFLAGS="$CFLAGS"
759 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
761 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
762 AC_TRY_COMPILE([], [return 0;],
763                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
764                  result="yes" ], result="no")
765 AC_MSG_RESULT([$result])
767 if test $result = "yes"; then
768    PROFILE_GEN_LDFLAGS="-fprofile-generate"
769    PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
770    PROFILE_USE_LDFLAGS="-fprofile-use"
773 CFLAGS="$_SAVE_CFLAGS"
775 dnl ===============================================================
776 dnl Check for .hidden assembler directive and visibility attribute.
777 dnl Borrowed from glibc configure.in
778 dnl ===============================================================
779 if test "$GNU_CC"; then
780     AC_CACHE_CHECK(for visibility(hidden) attribute,
781         ac_cv_visibility_hidden,
782         [cat > conftest.c <<EOF
783         int foo __attribute__ ((visibility ("hidden"))) = 1;
785         ac_cv_visibility_hidden=no
786         if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
787             if grep '\.hidden.*foo' conftest.s >/dev/null; then
788                 ac_cv_visibility_hidden=yes
789             fi
790         fi
791         rm -f conftest.[cs]
792         ])
793     if test "$ac_cv_visibility_hidden" = "yes"; then
794         AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
795         AC_CACHE_CHECK(for visibility pragma support,
796             ac_cv_visibility_pragma,
797             [cat > conftest.c <<EOF
798 #pragma GCC visibility push(hidden)
799             int foo_hidden = 1;
800 #pragma GCC visibility push(default)
801             int foo_default = 1;
803             ac_cv_visibility_pragma=no
804             if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
805                 if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
806                     if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
807                         ac_cv_visibility_pragma=yes
808                     fi
809                 fi
810             fi
811             rm -f conftest.[cs]
812             ])
813         if test "$ac_cv_visibility_pragma" = "yes"; then
814             AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
815             # To work around a build problem on Linux x86-64 (Bugzilla bug
816             # 293438), we use the -fvisibility=hidden flag.  This flag is less
817             # optimal than #pragma GCC visibility push(hidden) because the flag
818             # assumes that symbols defined outside the current source file have
819             # the default visibility.  This has the advantage that we don't need
820             # to wrap system header files, but has the disadvantage that calls
821             # to hidden symbols defined in other source files cannot be
822             # optimized by the compiler.  The -fvisibility=hidden flag does
823             # hide and export symbols correctly.
824             #VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
825             #WRAP_SYSTEM_INCLUDES=1
826             VISIBILITY_FLAGS="-fvisibility=hidden"
827             WRAP_SYSTEM_INCLUDES=
828         fi
829     fi
830 fi # GNU_CC
832 fi # SKIP_COMPILER_CHECKS
834 dnl ========================================================
835 dnl Checks for programs.
836 dnl ========================================================
837 if test -z "$SKIP_PATH_CHECKS"; then
838     AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
839 elif test -z "$PERL"; then
840     PERL=perl
843 dnl ========================================================
844 dnl Default platform specific options
845 dnl ========================================================
846 OBJ_SUFFIX=o
847 LIB_SUFFIX=a
848 DLL_SUFFIX=so
849 ASM_SUFFIX=s
850 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
851 PR_MD_ASFILES=
852 PR_MD_CSRCS=
853 PR_MD_ARCH_DIR=unix
854 AR_FLAGS='cr $@'
855 AS='$(CC)'
856 ASFLAGS='$(CFLAGS)'
858 if test -n "$CROSS_COMPILE"; then
859     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
860     OS_RELEASE=
861     OS_TEST="${target_cpu}"
862     case "${target_os}" in
863         linux*)       OS_ARCH=Linux ;;
864         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
865         mingw*)       OS_ARCH=WINNT CPU_ARCH=x86 ;;
866         darwin*)      OS_ARCH=Darwin ;;
867         riscos*)      OS_ARCH=RISCOS ;;
868     esac
869 else
870     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
871     OS_RELEASE=`uname -r`
872     OS_TEST=`uname -m`
875 if test "$OS_ARCH" = "IRIX64"; then
876     OS_ARCH=IRIX
879 if test "$OS_ARCH" = "AIX"; then
880     OS_RELEASE=`uname -v`.`uname -r`
883 if test "$OS_ARCH" = "FreeBSD"; then
884     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
887 if test "$OS_ARCH" = "Linux"; then
888     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
889     OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
892 #######################################################################
893 # Master "Core Components" macros for getting the OS target           #
894 #######################################################################
897 # Note: OS_TARGET should be specified on the command line for gmake.
898 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
899 # The difference between the Win95 target and the WinNT target is that
900 # the WinNT target uses Windows NT specific features not available
901 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
902 # at lesser performance (the Win95 target uses threads; the WinNT target
903 # uses fibers).
905 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
906 # cross-compilation.
910 # The following hack allows one to build on a WIN95 machine (as if
911 # s/he were cross-compiling on a WINNT host for a WIN95 target).
912 # It also accomodates for MKS's uname.exe.  If you never intend
913 # to do development on a WIN95 machine, you don't need this hack.
915 case "$OS_ARCH" in
916 Windows_95)
917     OS_ARCH=Windows_NT
918     OS_TARGET=WIN95
919     ;;
920 Windows_98)
921     OS_ARCH=Windows_NT
922     OS_TARGET=WIN95
923     ;;
924 CYGWIN_9*|CYGWIN_ME*)
925     OS_ARCH='CYGWIN_NT-4.0'
926     OS_TARGET=WIN95
927     ;;
928 OS_2)
929     OS_ARCH=OS2
930     OS_TARGET=OS2
931     ;;
932 esac
935 # On WIN32, we also define the variable CPU_ARCH.
938 case "$OS_ARCH" in
939 Windows_NT)
941 # If uname -s returns "Windows_NT", we assume that we are using
942 # the uname.exe in MKS toolkit.
944 # The -r option of MKS uname only returns the major version number.
945 # So we need to use its -v option to get the minor version number.
946 # Moreover, it doesn't have the -p option, so we need to use uname -m.
948     OS_ARCH=WINNT
949     OS_MINOR_RELEASE=`uname -v`
950     if test "$OS_MINOR_RELEASE" = "00"; then
951         OS_MINOR_RELEASE=0
952     fi
953     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
954     CPU_ARCH=`uname -m`
955     #
956     # MKS's uname -m returns "586" on a Pentium machine.
957     #
958     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
959         CPU_ARCH=x86
960     fi
961     ;;
962 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
964 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
965 # the uname.exe in the Cygwin tools.
966 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
967 # the uname.exe in the MSYS tools.
968 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
969 # the uname.exe in the MSYS2 tools.
971     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
972     OS_ARCH=WINNT
973     CPU_ARCH=`uname -m`
974     #
975     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
976     #
977     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
978         CPU_ARCH=x86
979     fi
980     ;;
981 esac
983 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
984     OS_TARGET=WIN95
985     if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
986         USE_DEBUG_RTL=1
987     fi
989 if test -z "$OS_TARGET"; then
990     OS_TARGET=$OS_ARCH
992 if test "$OS_TARGET" = "WIN95"; then
993     OS_RELEASE="4.0"
995 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
997 dnl ========================================================
998 dnl Enable high-memory support on OS/2 by default.
999 dnl ========================================================
1000 AC_ARG_ENABLE(os2-high-mem,
1001     [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1002     [ if test "$enableval" = "no"; then
1003         MOZ_OS2_HIGH_MEMORY=
1004       else
1005         MOZ_OS2_HIGH_MEMORY=1
1006       fi ])
1008 dnl ========================================================
1009 dnl = ARM toolchain tweaks
1010 dnl ========================================================
1012 dnl Defaults
1013 MOZ_ALIGN=toolchain-default
1015 case "$target" in
1016 arm*-android*|arm*-linuxandroid*)
1017     MOZ_THUMB=yes
1018     MOZ_ARCH=armv7-a
1019     MOZ_FPU=vfp
1020     MOZ_FLOAT_ABI=softfp
1021     MOZ_SOFT_FLOAT=yes
1022     MOZ_ALIGN=no
1023     ;;
1024 arm*-*)
1025     if test -n "$MOZ_PLATFORM_MAEMO"; then
1026         MOZ_THUMB=no
1027         MOZ_ARCH=armv7-a
1028         MOZ_FLOAT_ABI=softfp
1029     fi
1030     if test "$MOZ_PLATFORM_MAEMO" = 6; then
1031         MOZ_THUMB=yes
1032     fi
1033     ;;
1034 esac
1036 dnl Kept for compatibility with some buildbot mozconfig
1037 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
1039 AC_ARG_WITH(thumb,
1040 [  --with-thumb[[=yes|no|toolchain-default]]]
1041 [                          Use Thumb instruction set (-mthumb)],
1042     if test -z "$GNU_CC"; then
1043         AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
1044     fi
1045     MOZ_THUMB=$withval)
1047 AC_ARG_WITH(thumb-interwork,
1048 [  --with-thumb-interwork[[=yes|no|toolchain-default]]
1049                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
1050     if test -z "$GNU_CC"; then
1051         AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
1052     fi
1053     MOZ_THUMB_INTERWORK=$withval)
1055 AC_ARG_WITH(arch,
1056 [  --with-arch=[[type|toolchain-default]]
1057                            Use specific CPU features (-march=type)],
1058     if test -z "$GNU_CC"; then
1059         AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
1060     fi
1061     MOZ_ARCH=$withval)
1063 AC_ARG_WITH(fpu,
1064 [  --with-fpu=[[type|toolchain-default]]
1065                            Use specific FPU type (-mfpu=type)],
1066     if test -z "$GNU_CC"; then
1067         AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
1068     fi
1069     MOZ_FPU=$withval)
1071 AC_ARG_WITH(float-abi,
1072 [  --with-float-abi=[[type|toolchain-default]]
1073                            Use specific arm float ABI (-mfloat-abi=type)],
1074     if test -z "$GNU_CC"; then
1075         AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
1076     fi
1077     MOZ_FLOAT_ABI=$withval)
1079 AC_ARG_WITH(soft-float,
1080 [  --with-soft-float[[=yes|no|toolchain-default]]
1081                            Use soft float library (-msoft-float)],
1082     if test -z "$GNU_CC"; then
1083         AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
1084     fi
1085     MOZ_SOFT_FLOAT=$withval)
1087 case "$MOZ_ARCH" in
1088 toolchain-default|"")
1089     arch_flag=""
1090     ;;
1092     arch_flag="-march=$MOZ_ARCH"
1093     ;;
1094 esac
1096 case "$MOZ_THUMB" in
1097 yes)
1098     MOZ_THUMB2=1
1099     thumb_flag="-mthumb"
1100     ;;
1102     MOZ_THUMB2=
1103     thumb_flag="-marm"
1104     ;;
1106     _SAVE_CFLAGS="$CFLAGS"
1107     CFLAGS="$arch_flag"
1108     AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1109         MOZ_THUMB2=1,
1110         MOZ_THUMB2=)
1111     CFLAGS="$_SAVE_CFLAGS"
1112     thumb_flag=""
1113     ;;
1114 esac
1116 case "$MOZ_THUMB_INTERWORK" in
1117 yes)
1118     thumb_interwork_flag="-mthumb-interwork"
1119     ;;
1121     thumb_interwork_flag="-mno-thumb-interwork"
1122     ;;
1123 *) # toolchain-default
1124     thumb_interwork_flag=""
1125     ;;
1126 esac
1128 case "$MOZ_FPU" in
1129 toolchain-default|"")
1130     fpu_flag=""
1131     ;;
1133     fpu_flag="-mfpu=$MOZ_FPU"
1134     ;;
1135 esac
1137 case "$MOZ_FLOAT_ABI" in
1138 toolchain-default|"")
1139     float_abi_flag=""
1140     ;;
1142     float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1143     ;;
1144 esac
1146 case "$MOZ_SOFT_FLOAT" in
1147 yes)
1148     soft_float_flag="-msoft-float"
1149     ;;
1151     soft_float_flag="-mno-soft-float"
1152     ;;
1153 *) # toolchain-default
1154     soft_float_flag=""
1155     ;;
1156 esac
1158 case "$MOZ_ALIGN" in
1159 toolchain-default|"")
1160     align_flag=""
1161     ;;
1163     align_flag="-mno-unaligned-access"
1164     ;;
1165 yes)
1166     align_flag="-munaligned-access"
1167     ;;
1169     align_flag=""
1170     ;;
1171 esac
1173 if test -n "$align_flag"; then
1174   _SAVE_CFLAGS="$CFLAGS"
1175   CFLAGS="$CFLAGS $align_flag"
1176   AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
1177   AC_TRY_COMPILE([],[],,align_flag="")
1178   CFLAGS="$_SAVE_CFLAGS"
1181 dnl Use echo to avoid accumulating space characters
1182 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
1183 if test -n "$all_flags"; then
1184     _SAVE_CFLAGS="$CFLAGS"
1185     CFLAGS="$all_flags"
1186     AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1187     AC_TRY_COMPILE([],[return 0;],
1188         AC_MSG_RESULT([yes]),
1189         AC_MSG_ERROR([no]))
1191     CFLAGS="$_SAVE_CFLAGS $all_flags"
1192     CXXFLAGS="$CXXFLAGS $all_flags"
1193     ASFLAGS="$ASFLAGS $all_flags"
1194     if test -n "$thumb_flag"; then
1195         LDFLAGS="$LDFLAGS $thumb_flag"
1196     fi
1199 dnl ========================================================
1200 dnl Override of system specific host options
1201 dnl ========================================================
1202 case "$host" in
1203 *-mingw*|*-msys*)
1204     NSINSTALL=nsinstall
1205     ;;
1206 *-cygwin*|*-mks*)
1207     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
1208     if test `echo "${PATH}" | grep -c \;` = 0; then
1209         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
1210     fi
1211     ;;
1212 *-beos*)
1213     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
1214     ;;
1215 *os2*)
1216     ;;
1218     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1219     ;;
1220 esac
1222 dnl ========================================================
1223 dnl Override of system specific target options
1224 dnl ========================================================
1225 case "$target" in
1227 *-aix*)
1228     AC_DEFINE(XP_UNIX)
1229     AC_DEFINE(AIX)
1230     AC_DEFINE(SYSV)
1231     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
1232     AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
1233     case "${target_os}" in
1234     aix3.2*)
1235         AC_DEFINE(AIX_RENAME_SELECT)
1236         AC_DEFINE(_PR_NO_LARGE_FILES)
1237         AIX_LINK_OPTS='-bnso -berok'
1238         PR_MD_ASFILES=os_AIX.s
1239         ;;
1240     aix4.1*)
1241         AC_DEFINE(AIX_TIMERS)
1242         AC_DEFINE(_PR_NO_LARGE_FILES)
1243         AC_DEFINE(AIX4_1)
1244         MKSHLIB=
1245         DSO_LDOPTS=
1246         AIX_LINK_OPTS='-bnso -berok'
1247         LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
1248         LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
1249         ;;
1250     aix4.2*)
1251         AC_DEFINE(AIX_TIMERS)
1252         AC_DEFINE(_PR_HAVE_OFF64_T)
1253         AIX_LINK_OPTS='-brtl -bnso -berok'
1254         ;;
1255     aix4.3*)
1256         AC_DEFINE(AIX_TIMERS)
1257         AC_DEFINE(_PR_HAVE_OFF64_T)
1258         AC_DEFINE(AIX4_3_PLUS)
1259         AC_DEFINE(HAVE_SOCKLEN_T)
1260         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1261         USE_IPV6=1
1262         AIX_LINK_OPTS='-brtl -bnso -berok'
1263         ;;
1264     *)
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     esac
1274     CFLAGS="$CFLAGS -qro -qroconst"
1275     AIX_WRAP='$(DIST)/lib/aixwrap.o'
1276     AIX_TMP='./_aix_tmp.o'
1277     if test -n "$USE_64"; then
1278         MDCPUCFG_H=_aix64.cfg
1279         OBJECT_MODE=64
1280     else
1281         MDCPUCFG_H=_aix32.cfg
1282     fi
1283     PR_MD_CSRCS=aix.c
1284     RESOLVE_LINK_SYMBOLS=1
1285     ;;
1286         
1287 *-beos*)
1288     AC_DEFINE(XP_BEOS)
1289     AC_DEFINE(BeOS)
1290     AC_DEFINE(BEOS)
1291     AC_DEFINE(_POSIX_SOURCE)
1292     DSO_LDOPTS=-nostart
1293     MDCPUCFG_H=_beos.cfg
1294     USE_BTHREADS=1
1295     PR_MD_ARCH_DIR=beos
1296     RESOLVE_LINK_SYMBOLS=1
1297     case "${target_cpu}" in
1298     i*86)
1299         _OPTIMIZE_FLAGS=-O2
1300         _DEBUG_FLAGS='-gdwarf-2 -O0'
1301         MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
1302         AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"])
1303         ;;
1304     powerpc)
1305         CC=mwcc
1306         CCC=mwcc
1307         LD=mwld
1308         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'
1309         _OPTIMIZE_FLAGS=-O2    
1310         _DEBUG_FLAGS='-g -O0'
1311         ;;
1312     esac
1313     ;;
1315 *-bsdi*)
1316     AC_DEFINE(XP_UNIX)
1317     AC_DEFINE(BSDI)
1318     AC_DEFINE(NEED_BSDREGEX)
1320     CFLAGS="$CFLAGS -Wall -Wno-format"
1321     CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
1323     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1324         CPU_ARCH=x86
1325     elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
1326         CPU_ARCH=sparc
1327     fi
1329     MDCPUCFG_H=_bsdi.cfg
1330     PR_MD_CSRCS=bsdi.c
1332     DSO_LDOPTS=-r
1334     case "$target_os" in
1335     bsdi1.1*)
1336         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1337         AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
1338         AC_DEFINE(_PR_NEED_H_ERRNO)
1339         MKSHLIB=
1340         DSO_CFLAGS=
1341         DSO_LDOPTS=
1342         ;;
1344     bsdi2.1*)
1345         AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
1346         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1347         AC_DEFINE(HAVE_DLL)
1348         AC_DEFINE(USE_DLFCN)
1349         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1350         PR_MD_ASFILES=os_BSD_OS_386_2.s
1351         ;;
1353     bsdi4.* | bsdi5.*)
1354         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1355         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1356         AC_DEFINE(HAVE_DLL)
1357         AC_DEFINE(USE_DLFCN)
1358         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1359         MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1360         DSO_CFLAGS=-fPIC
1361         DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
1362         STRIP="$STRIP -d"
1363         case "$target_os" in
1364         bsdi4.2* | bsdi4.3* | bsdi5.*)
1365             AC_DEFINE(_PR_HAVE_GETPROTO_R)
1366             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1367             ;;
1368         esac
1369         ;;
1370     *)
1371         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1372         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1373         AC_DEFINE(HAVE_DLL)
1374         AC_DEFINE(USE_DLFCN)
1375         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1376         ;;
1377     esac
1379     ;;
1381 *-darwin*)
1382     AC_DEFINE(XP_UNIX)
1383     AC_DEFINE(DARWIN)
1384     AC_DEFINE(HAVE_BSD_FLOCK)
1385     AC_DEFINE(HAVE_SOCKLEN_T)
1386     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1387     changequote(,)
1388     HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1389     changequote([,])
1390     if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
1391         AC_DEFINE(HAS_CONNECTX)
1392     fi
1393     AS='$(CC) -x assembler-with-cpp'
1394     CFLAGS="$CFLAGS -Wall -fno-common"
1395     case "${target_cpu}" in
1396         arm*)
1397             CPU_ARCH=arm
1398             ;;
1399         i*86*|x86_64)
1400             if test -n "$USE_64"; then
1401                 CPU_ARCH=x86_64
1402             else        
1403                 CPU_ARCH=i386
1404             fi
1405             ;;
1406         *)
1407             CPU_ARCH=ppc
1408             ;;
1409     esac
1410     if test "`echo $CC | grep -c '\-arch '`" = "0"; then
1411         CC="$CC -arch $CPU_ARCH"
1412     fi
1413     AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
1414     DSO_CFLAGS=-fPIC
1415     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1416     _OPTIMIZE_FLAGS=-O2
1417     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1418     STRIP="$STRIP -x -S"
1419     DLL_SUFFIX=dylib
1420     USE_PTHREADS=1
1421     MDCPUCFG_H=_darwin.cfg
1422     PR_MD_CSRCS=darwin.c
1423     PR_MD_ASFILES=os_Darwin.s
1425     # Add Mac OS X support for loading CFM & CFBundle plugins
1426     if test -f "${MACOS_SDK_DIR}/System/Library/Frameworks/Carbon.framework/Carbon"; then
1427         AC_DEFINE(XP_MACOSX)
1428         OS_TARGET=MacOSX
1430         if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1431             dnl Use the specified value
1432             export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1433         elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1434             dnl No value specified on the command line or in the environment,
1435             dnl use the lesser of the library's minimum or the architecture's
1436             dnl minimum.
1437             case "${target_cpu}" in
1438                 powerpc*)
1439                     dnl Architecture minimum 10.2
1440                     export MACOSX_DEPLOYMENT_TARGET=10.2
1441                     ;;
1442                 i*86*)
1443                     dnl Architecture minimum 10.4
1444                     export MACOSX_DEPLOYMENT_TARGET=10.4
1445                     ;;
1446             esac
1447         fi
1449         dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1450         dnl in use.  NEXT_ROOT will be set and exported if it's needed for
1451         dnl ld.
1453         if test "$MACOS_SDK_DIR"; then
1454             dnl Sync this section with the one in Mozilla's top level.
1456             if test ! -d "$MACOS_SDK_DIR"; then
1457                 AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1458 specify a valid SDK.  SDKs are installed when the optional cross-development
1459 tools are selected during the Xcode/Developer Tools installation.])
1460             fi
1462             changequote(,)
1463             CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1464             GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1465             GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1466             changequote([,])
1467             GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1468             if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1469                 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1470                 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1471                     SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1472                 fi
1474                 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1476                 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1478                 dnl CPP needs to be set for AC_CHECK_HEADER.
1479                 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1481                 changequote(,)
1482                 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1483                 changequote([,])
1484                 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1485                     dnl The build host is running Tiger (10.4) or earlier.
1486                     dnl ld support for -syslibroot is compiler-agnostic, but
1487                     dnl only available on Tiger and later.  On Tiger and
1488                     dnl earlier build hosts, just rely on NEXT_ROOT, because
1489                     dnl it's not been shown to cause any problems.
1490                     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}"
1491                 else
1492                     dnl The build host is running Leopard (10.5) or later.
1493                     dnl With NEXT_ROOT set, the linker will still not apply
1494                     dnl it when resolving dependencies.  This causes problems
1495                     dnl on Leopard, where an SDK depends on frameworks which
1496                     dnl were present in earlier OS releases (and the associated
1497                     dnl SDK) but not in Leopard.  -syslibroot does not have
1498                     dnl this problem, but it results in harmless warnings when
1499                     dnl NEXT_ROOT is set.  NEXT_ROOT needs to remain set even
1500                     dnl on Leopard because the compiler uses it too.
1501                     MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1502                 fi
1504                 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1505                 export NEXT_ROOT=$MACOS_SDK_DIR
1507                 if test -n "$CROSS_COMPILE" ; then
1508                     dnl NEXT_ROOT will be in the environment, but it
1509                     dnl shouldn't be set for the build host.  HOST_CXX is
1510                     dnl presently unused.
1511                     HOST_CC="NEXT_ROOT= $HOST_CC"
1512                     HOST_CXX="NEXT_ROOT= $HOST_CXX"
1513                 fi
1514             else
1515                 dnl gcc >= 4.0 uses different paths than above, but knows
1516                 dnl how to find them itself.
1517                 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1519                 dnl CPP needs to be set for AC_CHECK_HEADER.
1520                 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1522                 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1523                 dnl has an ld that supports -syslibroot.  Don't set
1524                 dnl NEXT_ROOT because it will be ignored and cause
1525                 dnl warnings when -syslibroot is specified.
1526                 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1527                     dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1528                     dnl based on the -isysroot it receives.
1529                     LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1530                 else
1531                     dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1532                     dnl to be explicit.
1533                     LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1534                 fi
1535             fi
1536         fi
1537     fi
1538     ;;
1540 *-dgux*)
1541     AC_DEFINE(XP_UNIX)
1542     AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
1543     AC_DEFINE(SVR4)
1544     AC_DEFINE(SYSV)
1545     AC_DEFINE(DGUX)
1546     AC_DEFINE(_DGUX_SOURCE)
1547     AC_DEFINE(_POSIX4A_DRAFT6_SOURCE)
1548     DSO_LDOPTS=-G
1549     _OPTIMIZE_FLAGS=-O2
1550     _DEBUG_FLAGS=
1551     MDCPUCFG_H=_dgux.cfg
1552     PR_MD_CSRCS=dgux.c
1553     ;;
1555 *-freebsd*)
1556     if test -z "$USE_NSPR_THREADS"; then
1557         USE_PTHREADS=1
1558     fi
1559     AC_DEFINE(XP_UNIX)
1560     AC_DEFINE(FREEBSD)
1561     AC_DEFINE(HAVE_BSD_FLOCK)
1562     AC_DEFINE(HAVE_SOCKLEN_T)
1563     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1564     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1565     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1566     if test "$MOZ_OBJFORMAT" = "elf"; then
1567         DLL_SUFFIX=so
1568     else
1569         DLL_SUFFIX=so.1.0
1570     fi
1571     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1572     DSO_CFLAGS=-fPIC
1573     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1574     MDCPUCFG_H=_freebsd.cfg
1575     PR_MD_CSRCS=freebsd.c
1576     ;;
1578 *-hpux*)
1579     AC_DEFINE(XP_UNIX)
1580     AC_DEFINE(HPUX)
1581     AC_DEFINE(_HPUX_SOURCE)
1582     # OSF1 and HPUX report the POLLHUP event for a socket when the
1583     # shutdown(SHUT_WR) operation is called for the remote end, even though
1584     # the socket is still writeable. Use select(), instead of poll(), to
1585     # workaround this problem.
1586     AC_DEFINE(_PR_POLL_WITH_SELECT)
1587     AC_DEFINE(_USE_BIG_FDS)
1588     DSO_LDOPTS='-b +h $(notdir $@)'
1589     PR_MD_CSRCS=hpux.c
1590     if test "$OS_TEST" = "ia64"; then
1591         DLL_SUFFIX=so
1592         DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1593         CPU_ARCH_TAG=_$OS_TEST 
1594         if test -z "$USE_64"; then
1595             COMPILER_TAG=_32
1596         fi
1597         PR_MD_ASFILES=os_HPUX_ia64.s
1598     else
1599         AC_DEFINE(hppa)
1600         DLL_SUFFIX=sl
1601         PR_MD_ASFILES=os_HPUX.s
1602     fi
1603     if test -n "$USE_64"; then
1604         MDCPUCFG_H=_hpux64.cfg
1605     else
1606         MDCPUCFG_H=_hpux32.cfg
1607     fi
1608     if test -z "$GNU_CC"; then
1609         CC="$CC -Ae"
1610         CXX="$CXX -ext"
1611         DSO_CFLAGS=+Z
1612     else
1613         DSO_CFLAGS=-fPIC
1614         ASFLAGS="$ASFLAGS -x assembler-with-cpp"
1615     fi
1617     if test -n "$MOZILLA_CLIENT"; then
1618         DEFAULT_IMPL_STRATEGY=_EMU
1619     fi
1621     if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
1622         AC_DEFINE(_PR_NEED_H_ERRNO)
1623         AC_DEFINE(HPUX9)
1624         DEFAULT_IMPL_STRATEGY=_EMU
1625         USE_NSPR_THREADS=1
1626     fi
1628     if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1629         AC_DEFINE(_PR_NO_LARGE_FILES)
1630     fi
1632     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1633         AC_DEFINE(_PR_NEED_H_ERRNO)
1634     fi
1636     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1637         AC_DEFINE(HAVE_INT_LOCALTIME_R)
1638     fi
1640     if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1641         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1642     fi
1644     # HP-UX 11i v2 (B.11.23) or higher
1645     changequote(<<,>>)
1646     case "$OS_RELEASE" in
1647     [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1648         USE_IPV6=1
1649         ;;
1650     esac
1651     changequote([,])
1653     if test "$OS_RELEASE" = "B.10.01"; then
1654         AC_DEFINE(HPUX10)
1655         DEFAULT_IMPL_STRATEGY=_EMU
1656     fi
1658     if test "$OS_RELEASE" = "B.10.10"; then
1659         AC_DEFINE(HPUX10)
1660         AC_DEFINE(HPUX10_10)
1661         DEFAULT_IMPL_STRATEGY=_PTH
1662     fi
1664     if test "$OS_RELEASE" = "B.10.20"; then
1665         AC_DEFINE(HPUX10)
1666         AC_DEFINE(HPUX10_20)
1667         if test -z "$GNU_CC"; then
1668             CFLAGS="$CFLAGS +DAportable +DS1.1"
1669             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1670         fi
1671         DEFAULT_IMPL_STRATEGY=_PTH
1672     fi
1674     if test "$OS_RELEASE" = "B.10.30"; then
1675         AC_DEFINE(HPUX10)
1676         AC_DEFINE(HPUX10_30)
1677         if test -z "$GNU_CC"; then
1678             CFLAGS="$CFLAGS +DAportable +DS1.1"
1679             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1680         fi
1681         DEFAULT_IMPL_STRATEGY=_PTH
1682     fi
1684     if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1685         AC_DEFINE(HPUX10)
1686         AC_DEFINE(HPUX11)
1687         AC_DEFINE(_LARGEFILE64_SOURCE)
1688         AC_DEFINE(_PR_HAVE_OFF64_T)
1689         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1690         if test -z "$GNU_CC"; then
1691             if test -z "$USE_64"; then
1692                 if test "$OS_TEST" = "ia64"; then
1693                     CFLAGS="$CFLAGS +DD32"
1694                     CXXFLAGS="$CXXFLAGS +DD32"
1695                 else
1696                     CFLAGS="$CFLAGS +DAportable +DS2.0"
1697                     CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1698                 fi
1699             else
1700                 if test "$OS_TEST" = "ia64"; then
1701                     CFLAGS="$CFLAGS +DD64"
1702                     CXXFLAGS="$CXXFLAGS +DD64"
1703                 else
1704                     CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1705                     CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1706                 fi
1707             fi
1708         fi
1709         DEFAULT_IMPL_STRATEGY=_PTH
1710     fi
1712     if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1713         USE_NSPR_THREADS=1
1714         USE_PTHREADS=
1715         USE_USER_PTHREADS=
1716     elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1717         USE_PTHREADS=1
1718         if test "$USE_NSPR_THREADS"; then
1719             USE_PTHREADS=
1720         fi
1721         if test "$USE_USER_PTHREADS"; then
1722             USE_PTHREADS=
1723         fi
1724     fi
1725     ;;
1727 *-irix*)
1728     AC_DEFINE(XP_UNIX)
1729     AC_DEFINE(IRIX)
1730     AC_DEFINE(SVR4)
1731     AC_DEFINE(_SGI_MP_SOURCE)
1732     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1733     PR_MD_CSRCS=irix.c
1734     PR_MD_ASFILES=os_Irix.s
1735     MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
1736     STRIP="$STRIP -f"
1737     RESOLVE_LINK_SYMBOLS=1
1738     if test -n "$USE_64"; then
1739         MDCPUCFG_H=_irix64.cfg
1740     else
1741         MDCPUCFG_H=_irix32.cfg
1742     fi
1743     case "${target_os}" in
1744     irix6*)
1745         AC_DEFINE(IRIX6)
1746         USE_PTHREADS=1
1747         USE_N32=1
1748         COMPILER_TAG=_n32
1749         IMPL_STRATEGY=_PTH
1750         ;;
1751     irix5*)
1752         AC_DEFINE(IRIX5)
1753         USE_NSPR_THREADS=1
1754         ;;
1755     *)
1756         USE_PTHREADS=1
1757         USE_N32=1
1758         ;;
1759     esac
1760     if test "$GNU_CC"; then
1761         dnl
1762         dnl If we are using gcc with native binutils, we need to
1763         dnl suppress the
1764         dnl #lineno "filename" num num
1765         dnl lines, which confuse IRIX native as.  Add -Wp,-P to the
1766         dnl gcc command line, which passes -P to the preprocessor.
1767         dnl
1768             AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
1769             CFLAGS="$CFLAGS -Wall -Wno-format"
1770             _OPTIMIZE_FLAGS="-O6"
1771     else
1772             if test -n "$USE_N32"; then
1773                 AS='as -D_ASM $(INCLUDES) -n32'
1774             else
1775                 AS='as -D_ASM $(INCLUDES)'
1776             fi
1777             CFLAGS="$CFLAGS -fullwarn -xansi"
1778             if test "$USE_N32"; then
1779                 _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000"
1780             else
1781                 _OPTIMIZE_FLAGS="-O -Olimit 4000"
1782             fi
1783             if test "$USE_MDUPDATE"; then
1784                 CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
1785             fi
1786             case "${target}" in
1787             *-irix6.*)
1788                 CFLAGS="$CFLAGS -multigot"
1789                 DSO_LDOPTS="-no_unresolved"
1790                 if test "$USE_N32"; then
1791                         CFLAGS="$CFLAGS -n32 -woff 1209"
1792                         DSO_LDOPTS="$DSO_LDOPTS -n32"
1793                 else
1794                         if test "$USE_64"; then
1795                             CFLAGS="$CFLAGS -64"
1796                         else
1797                             CFLAGS="$CFLAGS -32"
1798                         fi
1799                 fi
1800                 ;;
1801             *)
1802                 CFLAGS="$CFLAGS -xgot"
1803                 ;;
1804             esac
1805     fi
1806     if test "${target_os}" = "irix5.3"; then
1807             AC_DEFINE(IRIX5_3)
1808     fi
1809     case "${target_os}" in
1810         irix6.5)
1811             if test -z "$GNU_CC"; then
1812                     CFLAGS="$CFLAGS -mips3"
1813             fi
1814             AC_DEFINE(_PR_HAVE_GETPROTO_R)
1815             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1816             AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
1817             ;;
1818         irix5*)
1819             ;;
1820         *)
1821             AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
1822             ;;
1823         esac
1824     ;;
1826 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
1827     if test -z "$USE_NSPR_THREADS"; then
1828         USE_PTHREADS=1
1829         IMPL_STRATEGY=_PTH
1830     fi
1831     AC_DEFINE(XP_UNIX)
1832     AC_DEFINE(_GNU_SOURCE)
1833     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1834     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
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     esac    
1903     ;;
1905 *-mingw*|*-msys*|*-cygwin*|*-mks*)
1906     AC_DEFINE(XP_PC)
1907     AC_DEFINE(WIN32)
1908     PR_MD_ARCH_DIR=windows
1909     RESOLVE_LINK_SYMBOLS=1
1911     if test -n "$GNU_CC"; then
1912         CC="$CC -mwindows"
1913         CXX="$CXX -mwindows"
1914         DLL_SUFFIX=dll
1915         MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1916         RC=$WINDRES
1917         # Use temp file for windres (bug 213281)
1918         RCFLAGS='-O coff --use-temp-file'
1919     else
1920         LD=link
1921         AR='lib -NOLOGO -OUT:"$@"'
1922         AR_FLAGS=
1923         RANLIB='echo not_ranlib'
1924         STRIP='echo not_strip'
1925         RC=rc.exe
1926         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1927         OBJ_SUFFIX=obj
1928         LIB_SUFFIX=lib
1929         DLL_SUFFIX=dll
1931         # Determine compiler version
1932         changequote(,)
1933         _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
1934         changequote([,])
1935         CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
1936         if test -z "$CC_VERSION"; then
1937             AC_MSG_ERROR([Could not determine MSC version.])
1938         fi
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     AC_DEFINE(HAVE_SOCKLEN_T)
2124     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2125     if test -z "$USE_NSPR_THREADS"; then
2126         USE_PTHREADS=1
2127     fi
2128     MDCPUCFG_H=_netbsd.cfg
2129     PR_MD_CSRCS=netbsd.c
2131     DSO_CFLAGS='-fPIC -DPIC'
2132     CFLAGS="$CFLAGS -ansi -Wall"
2133     CXXFLAGS="$CXXFLAGS -ansi -Wall"
2134     MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
2136     if test -z "$OBJECT_FMT"; then
2137         if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
2138             OBJECT_FMT=a.out
2139             DLL_SUFFIX=so.1.0
2140             DSO_LDOPTS='-shared'
2141         else
2142             OBJECT_FMT=ELF
2143             DLL_SUFFIX=so
2144             DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
2145         fi
2146     fi
2148     if test "$LIBRUNPATH"; then
2149         DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
2150     fi
2151     ;;
2153 *-nto*)
2154     AC_DEFINE(XP_UNIX)
2155     AC_DEFINE(NTO)
2156     AC_DEFINE(_QNX_SOURCE)
2157     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2158     MDCPUCFG_H=_nto.cfg
2159     PR_MD_CSRCS=nto.c
2160     MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
2161     DSO_CFLAGS=-fPIC
2162     DSO_LDOPTS=-shared
2163     OS_LIBS="$OS_LIBS -lsocket"
2164     _OPTIMIZE_FLAGS="-O1"
2165     _DEBUG_FLAGS="-gstabs"
2166         ;;
2168 *-openbsd*)
2169     AC_DEFINE(XP_UNIX)
2170     AC_DEFINE(OPENBSD)
2171     AC_DEFINE(HAVE_BSD_FLOCK)
2172     AC_DEFINE(HAVE_SOCKLEN_T)
2173     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2174     CFLAGS="$CFLAGS -ansi -Wall"
2175     CXXFLAGS="$CXXFLAGS -ansi -Wall"
2176     DLL_SUFFIX=so.1.0
2177     DSO_CFLAGS=-fPIC
2178     MDCPUCFG_H=_openbsd.cfg
2179     PR_MD_CSRCS=openbsd.c
2180     OS_LIBS="-lc"
2181     if test -z "$USE_NSPR_THREADS"; then
2182         USE_PTHREADS=1
2183     fi
2184     DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
2185     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2186     ;;
2188 *-osf*)
2189     SHELL_OVERRIDE="SHELL               = /usr/bin/ksh"
2190     AC_DEFINE(XP_UNIX)
2191     AC_DEFINE(OSF1)
2192     AC_DEFINE(_REENTRANT)
2193     # OSF1 and HPUX report the POLLHUP event for a socket when the
2194     # shutdown(SHUT_WR) operation is called for the remote end, even though
2195     # the socket is still writeable. Use select(), instead of poll(), to
2196     # workaround this problem.
2197     AC_DEFINE(_PR_POLL_WITH_SELECT)
2199     if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then
2200         USE_NSPR_THREADS=1
2201     fi
2203     if test -z "$GNU_CC"; then
2204         CC="$CC -std1 -ieee_with_inexact"
2205         if test "$OS_RELEASE" != "V2.0"; then
2206             CC="$CC -readonly_strings"
2207         fi
2208         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
2209         AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H))
2210     else
2211         CFLAGS="$CFLAGS -mieee"
2212         CXXFLAGS="$CXXFLAGS -mieee"
2213     fi
2215     if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
2216         AC_DEFINE(HAVE_INT_LOCALTIME_R)
2217     else
2218         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2219         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2220     fi
2221     if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then
2222         AC_DEFINE(OSF1V4_MAP_PRIVATE_BUG)
2223     fi
2224     DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)'
2225     MDCPUCFG_H=_osf1.cfg
2226     PR_MD_CSRCS=osf1.c
2227     ;;
2229 *-qnx*)
2230     AC_DEFINE(XP_UNIX)
2231     AC_DEFINE(QNX)
2232     AC_DEFINE(_PR_NEED_H_ERRNO)
2233     USE_NSPR_THREADS=1
2234     MDCPUCFG_H=_qnx.cfg
2235     PR_MD_CSRCS=qnx.c
2236     ;;
2238 *-riscos*)
2239     AC_DEFINE(XP_UNIX)
2240     AC_DEFINE(RISCOS)
2241     AC_DEFINE(_PR_NEED_H_ERRNO)
2242     USE_PTHREADS=1
2243     MDCPUCFG_H=_riscos.cfg
2244     PR_MD_CSRCS=riscos.c
2245     DSO_CFLAGS=-fPIC
2246     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
2247     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2248     ;;
2250 *-*-sco*)
2251     AC_DEFINE(XP_UNIX)
2252     AC_DEFINE(SCO)
2253     AC_DEFINE(sco)
2254     AC_DEFINE(SYSV)
2255     AC_DEFINE(_SVID3)
2256     AC_DEFINE(_PR_NEED_H_ERRNO)
2257     CC='cc -b elf -KPIC'
2258     CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
2259     USE_NSPR_THREADS=1
2260     CPU_ARCH=x86
2261     DSO_LDOPTS='-b elf -G'
2262     MDCPUCFG_H=_scoos.cfg
2263     PR_MD_SRCS=scoos.c
2264     ;;
2266 *-solaris*)
2267     if test -z "$USE_NSPR_THREADS"; then
2268         USE_PTHREADS=1
2269     fi
2270     AC_DEFINE(XP_UNIX)
2271     AC_DEFINE(SVR4)
2272     AC_DEFINE(SYSV)
2273     AC_DEFINE(__svr4)
2274     AC_DEFINE(__svr4__)
2275     AC_DEFINE(SOLARIS)
2276     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2277     CPU_ARCH=`uname -p`
2278     MDCPUCFG_H=_solaris.cfg
2279     PR_MD_CSRCS=solaris.c
2280     LD=/usr/ccs/bin/ld
2281     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2282     RESOLVE_LINK_SYMBOLS=1
2283     case "${OS_RELEASE}" in
2284     5.8|5.9)
2285         ;;
2286     *)
2287         # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
2288         USE_B_DIRECT=1
2289         ;;
2290     esac
2291     if test -n "$GNU_CC"; then
2292         DSO_CFLAGS=-fPIC
2293         if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
2294             GCC_USE_GNU_LD=1
2295         fi
2296         DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore' 
2297         if test -n "$USE_B_DIRECT"; then
2298             DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
2299         fi
2300     else
2301         DSO_CFLAGS=-KPIC
2302         DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
2303         if test -n "$USE_B_DIRECT"; then
2304             DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
2305         fi
2306     fi
2307     if test -n "$GNU_CC"; then
2308         CFLAGS="$CFLAGS -Wall"
2309         CXXFLAGS="$CXXFLAGS -Wall"
2310         if test -n "$USE_MDUPDATE"; then
2311             CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
2312             CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
2313         fi
2314         GCC_AS=`$CC -print-prog-name=as`
2315         if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
2316             GNU_AS=1
2317         fi
2318     else
2319         CFLAGS="$CFLAGS -xstrconst"
2320         CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
2321         if test -z "$MOZ_OPTIMIZE"; then
2322             CFLAGS="$CFLAGS -xs"
2323             CXXFLAGS="$CXXFLAGS -xs"
2324         fi
2325         _OPTIMIZE_FLAGS=-xO4
2326     fi
2327     if test -z "$GNU_AS"; then
2328         ASFLAGS="$ASFLAGS -Wa,-P"
2329     fi
2330     if test -n "$USE_64"; then
2331         if test -n "$GNU_CC"; then
2332             CC="$CC -m64"
2333             CXX="$CXX -m64"
2334         else
2335             if test "$OS_TEST" = "i86pc"; then
2336                 CC="$CC -xarch=amd64"
2337                 CXX="$CXX -xarch=amd64"
2338             else
2339                 CC="$CC -xarch=v9"
2340                 CXX="$CXX -xarch=v9"
2341             fi
2342         fi
2343     fi
2344     if test "$OS_TEST" = "i86pc"; then
2345         if test -z "$USE_64"; then
2346             AC_DEFINE(i386)
2347         fi
2348         CPU_ARCH_TAG=_$OS_TEST
2349         # The default debug format, DWARF (-g), is not supported by gcc
2350         # on i386-ANY-sysv4/solaris, but the stabs format is.  It is
2351         # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2352         # If your gcc uses GNU as, you do not need the -Wa,-s option.
2353         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2354             _DEBUG_FLAGS=-gstabs
2355             if test -z "$GNU_AS"; then
2356                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2357             fi
2358         fi
2359     fi
2360     case "${target_os}" in
2361     solaris2.3*)
2362         AC_DEFINE(_PR_NO_LARGE_FILES)
2363         ;;
2364     solaris2.4*)
2365         AC_DEFINE(_PR_NO_LARGE_FILES)
2366         ;;
2367     solaris2.5*)
2368         AC_DEFINE(SOLARIS2_5)    
2369         ;;
2370     *)
2371         AC_DEFINE(_PR_HAVE_OFF64_T)
2372         # The lfcompile64(5) man page on Solaris 2.6 says:
2373         #     For applications that do not wish to conform to the POSIX or
2374         #     X/Open  specifications,  the  64-bit transitional interfaces
2375         #     are available by default.  No compile-time flags need to  be
2376         #     set.
2377         # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2378         # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2379         if test -n "$GNU_CC"; then
2380             AC_DEFINE(_LARGEFILE64_SOURCE)
2381         fi
2382         ;;
2383     esac
2384     case "${target_os}" in
2385     solaris2.3*)
2386         ;;
2387     solaris2.4*)
2388         ;;
2389     solaris2.5*)
2390         ;;
2391     solaris2.6*)
2392         ;;
2393     solaris2.7*)
2394         ;;
2395     *)
2396         # Solaris 8 or higher has IPv6.
2397         AC_DEFINE(_PR_INET6)
2398         ;;
2399     esac
2400     if test "$CPU_ARCH" = "sparc"; then
2401         # 64-bit Solaris SPARC requires V9 architecture, so the following
2402         # is not needed.
2403         if test -z "$USE_64"; then
2404             ULTRASPARC_LIBRARY=nspr_flt
2405         fi
2406     fi
2407     # Purify requires that binaries linked against nspr also
2408     # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2409     _rev=`uname -r`
2410     _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2411     OS_LIBS="$OS_LIBS $_librt"
2412     ;;
2414 *-sco-sysv5*)
2415     AC_DEFINE(XP_UNIX)
2416     AC_DEFINE(UNIXWARE)
2417     AC_DEFINE(SVR4)
2418     AC_DEFINE(SYSV)
2419     USE_NSPR_THREADS=1
2420     if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
2421         AC_DEFINE(_PR_NO_LARGE_FILES)
2422         CC='$(NSDEPTH)/build/hcc cc'
2423         CXX='$(NSDEPTH)/build/hcpp CC'
2424         MDCPUCFG_H=_unixware.cfg
2425     else
2426         AC_DEFINE(_LARGEFILE64_SOURCE)
2427         AC_DEFINE(_PR_HAVE_OFF64_T)
2428         AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
2429         MDCPUCFG_H=_unixware7.cfg
2430     fi
2431     PR_MD_CSRCS=unixware.c
2432     DSO_LDOPTS=-G
2433     CPU_ARCH=x86
2434     ;;
2436 *-symbian*)
2437     AC_ARG_WITH(symbian-sdk,
2438     [  --with-symbian-sdk=SYMBIAN_SDK_DIR
2439                           The path to the Symbian SDK],
2440     SYMBIAN_SDK_DIR=$withval)
2442     echo -----------------------------------------------------------------------------
2443     echo Building with Symbian SDK in: $SYMBIAN_SDK_DIR
2444     echo -----------------------------------------------------------------------------
2446     AC_DEFINE(XP_UNIX)
2447     AC_DEFINE(SYMBIAN)
2448     AC_DEFINE(__arm__)
2449     AC_DEFINE(__SYMBIAN32__)
2450     AC_DEFINE(_UNICODE)
2451     AC_DEFINE(NDEBUG)
2452     AC_DEFINE(__SUPPORT_CPP_EXCEPTIONS__)
2453     AC_DEFINE(MOZ_STDERR_TO_STDOUT)
2454     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2455     AC_DEFINE(HAVE_SOCKLEN_T)
2456     USE_PTHREADS=1
2457     LIB_SUFFIX=lib
2458     DLL_SUFFIX=dll
2459     MKSHLIB=
2460     DSO_LDOPTS=
2461     DSO_CFLAGS=
2462     VISIBILITY_FLAGS=
2463     MDCPUCFG_H=_symbian.cfg
2464     PR_MD_CSRCS=symbian.c
2465     NSINSTALL=nsinstall
2466     RANLIB='echo no ranlib '
2467     CPU_ARCH=ARM
2468     OS_ARCH=SYMBIAN
2469     OS_EXE_CFLAGS="$OS_EXE_CFLAGS -D__EXE__"
2470     CFLAGS="$CFLAGS -MD -nostdinc"
2471     SYMBIAN_SYS_INCLUDE="-I$SYMBIAN_SDK_DIR/Epoc32/include/variant -I$SYMBIAN_SDK_DIR/Epoc32/include -I$SYMBIAN_SDK_DIR/Epoc32/include/stdapis"
2472     echo -------------------------------------------------------
2473     echo SYMBIAN_SYS_INCLUDE is: $SYMBIAN_SYS_INCLUDE
2474     echo -------------------------------------------------------
2475     case "$OS_TARGET" in
2476     WINSCW)
2477         CC=mwccsym2.exe
2478         CXX=mwccsym2.exe
2479         LD=mwldsym2.exe
2480         AR=mwldsym2.exe
2481         WINSCW_LD_DIR="\$(SYMBIAN_SDK_DIR)/EPOC32/RELEASE/WINSCW/UDEB"
2482         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)"
2483         SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include Symbian_OS_v9.2.hrh"
2484         AR_FLAGS="-library -msgstyle gcc -stdlib -subsystem windows -noimplib -o \$@"
2485         AC_DEFINE(_DEBUG)
2486         AC_DEFINE(__CW32__)
2487         AC_DEFINE(__WINS__)
2488         AC_DEFINE(__WINSCW__)
2489         DEFINES="$DEFINES -U_WIN32"
2490             ;;
2491     GCCE)
2492         CFLAGS="$CFLAGS -Wall -Wno-unknown-pragmas -fexceptions -march=armv5t -mapcs -pipe -x c -msoft-float"
2493         CXXFLAGS="$CXXFLAGS $CFLAGS -Wno-ctor-dtor-privacy"
2494         SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include $SYMBIAN_SDK_DIR/EPOC32/INCLUDE/GCCE/GCCE.h"
2495         AC_DEFINE(__GCCE__)
2496         AC_DEFINE(__EABI__)
2497         DEFINES="$DEFINES -D__PRODUCT_INCLUDE__=$SYMBIAN_SDK_DIR/Epoc32/include/variant/Symbian_OS_v9.2.hrh"
2498             ;;
2499     *)
2500             AC_MSG_ERROR([Missing OS_TARGET for ${target}. Set --enable-symbian-target to with 'WINSCW' or 'GCCE'.])
2501         ;;
2502     esac
2503     CFLAGS="$CFLAGS ${SYMBIAN_SYS_INCLUDE}"
2504     ;;
2506 *-os2*)
2507     AC_DEFINE(XP_OS2)
2508     AC_DEFINE(XP_PC)
2509     AC_DEFINE(BSD_SELECT)
2510     AC_DEFINE(TCPV40HDRS)
2511     LIB_SUFFIX=lib
2512     DLL_SUFFIX=dll
2513     RC=rc.exe
2514     PR_MD_ARCH_DIR=os2
2515     PROG_SUFFIX=.exe
2516     NSINSTALL=nsinstall
2517     MDCPUCFG_H=_os2.cfg
2518     RESOLVE_LINK_SYMBOLS=1
2520     AC_DEFINE(OS2)
2521     AR=emxomfar
2522     AR_FLAGS='r $@'
2523     CFLAGS="$CFLAGS -Wall -Zomf"
2524     CXXFLAGS="$CFLAGS -Wall -Zomf"
2525     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2526     DSO_CFLAGS=
2527     DSO_LDOPTS='-Zomf -Zdll'
2528     LDFLAGS='-Zmap'
2529     _OPTIMIZE_FLAGS="-O2 -s"
2530     _DEBUG_FLAGS="-g -fno-inline"
2531     if test -n "$MOZ_OPTIMIZE"; then
2532       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2533     fi
2534     IMPLIB='emximp -o'
2535     FILTER='emxexp -o'
2536     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2537       LDFLAGS="$LDFLAGS -Zhigh-mem"
2538       AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2539     fi
2541     # GCC for OS/2 currently predefines these, but we don't want them
2542     DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
2543     ;;
2546     AC_DEFINE(XP_UNIX)
2547     ;;
2548    
2549 esac
2551 if test -z "$SKIP_LIBRARY_CHECKS"; then
2552 dnl ========================================================
2553 dnl Check for system libraries
2554 dnl ========================================================
2557 dnl We don't want anything to link with libdl even if it's present on OS X, 
2558 dnl since it's not used and not part of the default installation.
2559 dnl The same goes for BeOS.
2560 dnl OS/2 has dlfcn in libc.
2562 case $target in
2563 *-darwin*|*-beos*|*-os2*)
2564     ;;
2566     AC_CHECK_LIB(dl, dlopen,
2567         [AC_CHECK_HEADER(dlfcn.h,
2568             OS_LIBS="-ldl $OS_LIBS")])
2569     ;;
2570 esac
2573 dnl ========================================================
2574 dnl Check for system header files.
2575 dnl ========================================================
2577 dnl ========================================================
2578 dnl Check for typedefs and structs
2579 dnl ========================================================
2581 dnl ========================================================
2582 dnl Checks for library functions.
2583 dnl ========================================================
2584 AC_PROG_GCC_TRADITIONAL
2585 _SAVE_LIBS="$LIBS"
2586 LIBS="$LIBS $OS_LIBS"
2587 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
2588  secure_getenv __secure_getenv)
2589 LIBS="$_SAVE_LIBS"
2591 dnl ========================================================
2592 dnl Check options
2593 dnl ========================================================
2595 dnl ======================================================
2596 dnl = Enable compiling with ccache
2597 dnl ======================================================
2598 AC_ARG_WITH(ccache,
2599 [  --with-ccache[=path/to/ccache]
2600                           Enable compiling with ccache],
2601     CCACHE=$withval, CCACHE="no")
2603 if test "$CCACHE" != "no"; then
2604     if test -n "$CCACHE"; then
2605         if test "$CCACHE" = "yes"; then
2606             CCACHE=
2607         else
2608             if test ! -e "$CCACHE"; then
2609                 AC_MSG_ERROR([$CCACHE not found])
2610             fi
2611         fi
2612     fi
2613     AC_PATH_PROGS(CCACHE, $CCACHE ccache)
2614     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
2615         AC_MSG_ERROR([ccache not found])
2616     elif test -x "$CCACHE"; then
2617         CC="$CCACHE $CC"
2618         CXX="$CCACHE $CXX"
2619     else
2620         AC_MSG_ERROR([$CCACHE is not executable])
2621     fi
2624 dnl ========================================================
2625 dnl =
2626 dnl = --enable-strip
2627 dnl = 
2628 dnl = Enable stripping of libs and executables
2629 dnl = 
2630 dnl ========================================================
2631 AC_ARG_ENABLE(strip,
2632     [  --enable-strip          Enable stripping of shared libs and programs],
2633     [ if test "$enableval" = "yes"; then
2634             ENABLE_STRIP=1
2635       fi ])
2637 dnl Check for hpux options
2638 case "${target_os}" in
2639 hpux*)
2640 if test -z "$GNU_CC"; then
2642     AC_CACHE_CHECK(for +Olit support,
2643         ac_cv_hpux_usable_olit_option,
2644         dnl since aCC doesn't throw an error on invalid options,
2645         dnl we have to test this the hard way
2646         [ac_cv_hpux_usable_olit_option=no
2647         rm -f conftest*
2648         echo 'int main() { return 0; }' | cat > conftest.c
2649         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2650         if test $? -eq 0; then
2651             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2652                 ac_cv_hpux_usable_olit_option=yes
2653             fi
2654         fi
2655         rm -f conftest*
2656         ])
2658     if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2659         CFLAGS="$CFLAGS +Olit=all"
2660         CXXFLAGS="$CXXFLAGS +Olit=all"
2661     else
2662         CFLAGS="$CFLAGS +ESlit"
2663         CXXFLAGS="$CXXFLAGS +ESlit"
2664     fi
2667 esac
2669 case "$target_os" in
2670 darwin*)
2671     _HAVE_PTHREADS=1
2672     ;;
2674     AC_CHECK_LIB(pthreads, pthread_create,
2675         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2676         AC_CHECK_LIB(pthread, pthread_create,
2677             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2678             AC_CHECK_LIB(c_r, pthread_create,
2679                 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2680                 AC_CHECK_LIB(c, pthread_create,
2681                     _HAVE_PTHREADS=1
2682                 )
2683             )
2684         )
2685     )
2686     ;;
2687 esac
2689 AC_ARG_WITH(pthreads,
2690     [  --with-pthreads         Use system pthreads library as thread subsystem],
2691     [ if test "$withval" = "yes"; then
2692             if test -n "$_HAVE_PTHREADS"; then
2693                     USE_PTHREADS=1 
2694                     USE_USER_PTHREADS=
2695                     USE_NSPR_THREADS=
2696             else
2697                     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2698             fi
2699           else
2700             USE_PTHREADS=
2701             _PTHREAD_LDFLAGS=
2702           fi],
2703         [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2704             USE_PTHREADS=1
2705             USE_USER_PTHREADS=
2706             USE_NSPR_THREADS=
2707           fi])
2709 AC_ARG_ENABLE(user-pthreads,
2710     [  --enable-user-pthreads  Build using userland pthreads],
2711     [ if test "$enableval" = "yes"; then
2712         if test -n "$_HAVE_PTHREADS"; then
2713                     USE_PTHREADS=
2714                     USE_USER_PTHREADS=1
2715                     USE_NSPR_THREADS=
2716             else
2717                     AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2718             fi
2719           fi])
2721 AC_ARG_ENABLE(nspr-threads,
2722     [  --enable-nspr-threads   Build using classic nspr threads],
2723     [ if test "$enableval" = "yes"; then
2724             USE_PTHREADS=
2725             USE_USER_PTHREADS=
2726             USE_NSPR_THREADS=1
2727           fi])
2729 case "$target" in
2730 *-beos*)
2731     AC_ARG_WITH(bthreads,
2732     [  --with-bthreads         Use system bthreads library as thread subsystem
2733                           (BeOS only)],
2734     [   if test "$withval" = "yes"; then
2735             USE_BTHREADS=1
2736                 USE_USER_PTHREADS=
2737                 USE_PTHREADS=
2738             fi])
2739     ;;
2740 esac
2742 fi # SKIP_LIBRARY_CHECKS
2744 AC_ARG_ENABLE(ipv6,
2745     [  --enable-ipv6           Compile ipv6 support],
2746     [ if test "$enableval" = "yes"; then
2747             USE_IPV6=1
2748       else
2749             USE_IPV6=
2750       fi])
2752 if test -n "$USE_PTHREADS"; then
2753    dnl See if -pthread is supported.
2754    rm -f conftest*
2755    ac_cv_have_dash_pthread=no
2756    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2757    echo 'int main() { return 0; }' | cat > conftest.c
2758    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2759    if test $? -eq 0; then
2760         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2761             ac_cv_have_dash_pthread=yes
2762                 case "$target_os" in
2763             freebsd*)
2764 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2765             ;;
2766             *)
2767             CFLAGS="$CFLAGS -pthread"
2768             CXXFLAGS="$CXXFLAGS -pthread"
2769             ;;
2770         esac
2771         fi
2772     fi
2773     rm -f conftest*
2774     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2776         dnl
2777         dnl See if -pthreads is supported.
2778         dnl
2779     ac_cv_have_dash_pthreads=no
2780     if test "$ac_cv_have_dash_pthread" = "no"; then
2781             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2782         echo 'int main() { return 0; }' | cat > conftest.c
2783             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2784         if test $? -eq 0; then
2785                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2786                             ac_cv_have_dash_pthreads=yes
2787                             CFLAGS="$CFLAGS -pthreads"
2788                             CXXFLAGS="$CXXFLAGS -pthreads"
2789                     fi
2790             fi
2791             rm -f conftest*
2792         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2793     fi
2795     case "$target" in
2796     *-solaris*)
2797         if test "$ac_cv_have_dash_pthreads" = "yes"; then
2798             _PTHREAD_LDFLAGS=
2799         fi
2800             ;;
2801     *-freebsd*)
2802             AC_DEFINE(_REENTRANT)
2803             AC_DEFINE(_THREAD_SAFE)
2804             dnl -pthread links in -lc_r, so don't specify it explicitly.
2805             if test "$ac_cv_have_dash_pthread" = "yes"; then
2806                 _PTHREAD_LDFLAGS="-pthread"
2807             else
2808                 _PTHREAD_LDFLAGS="-lc_r"
2809             fi
2810             ;;
2811     *-netbsd*)
2812             if test "$ac_cv_have_dash_pthread" = "yes"; then
2813                 _PTHREAD_LDFLAGS="-pthread"
2814             fi
2815             ;;
2816     *-bsdi*)
2817             AC_DEFINE(_THREAD_SAFE)
2818             dnl -pthread links in -lc_r, so don't specify it explicitly.
2819             if test "$ac_cv_have_dash_pthread" = "yes"; then
2820                 _PTHREAD_LDFLAGS=
2821             fi
2822             ;;
2823     *-openbsd*)
2824         if test "$ac_cv_have_dash_pthread" = "yes"; then
2825             _PTHREAD_LDFLAGS=-pthread
2826         fi
2827         ;;
2828     *-linux*|*-gnu*|*-k*bsd*-gnu)
2829         AC_DEFINE(_REENTRANT)
2830         ;;
2831     esac
2833 else 
2834     if test -n "$USE_USER_PTHREADS"; then
2835             USE_PTHREADS=
2836             USE_NSPR_THREADS=
2837     else
2838         _PTHREAD_LDFLAGS=
2839     fi
2841 dnl Special thread exceptions
2843 case "$target" in
2844 *-aix*)
2845     if test -n "$USE_NSPR_THREADS"; then
2846         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2847     fi
2848     case "$target_os" in
2849     aix4.1*)
2850         if test -z "$USE_PTHREADS"; then
2851             AC_DEFINE(AIX_RENAME_SELECT)
2852         fi
2853         ;;
2854     aix4.2*)
2855         if test -z "$USE_NSPR_THREADS"; then
2856             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2857         fi
2858         ;;
2859     aix4.3*)
2860         if test -z "$USE_NSPR_THREADS"; then
2861             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2862         fi
2863         if test -n "$USE_PTHREADS"; then
2864             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2865         fi
2866         ;;
2867     *)
2868         if test -z "$USE_NSPR_THREADS"; then
2869             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2870         fi
2871         if test -n "$USE_PTHREADS"; then
2872             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2873         fi
2874         ;;
2875     esac
2876     ;;
2877 *-bsdi*)
2878     if test -n "$USE_PTHREADS"; then
2879         AC_DEFINE(_PR_NEED_PTHREAD_INIT)
2880     fi
2881     ;;
2882 *-freebsd*)
2883     if test -n "$USE_NSPR_THREADS"; then
2884         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2885     fi
2886     ;;
2887 *-hpux*)
2888     if test -n "$USE_NSPR_THREADS"; then
2889         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2890     fi 
2891     if test "$USE_PTHREADS"; then
2892         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2893         AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2894     fi
2895     if test "$USE_USER_PTHREADS"; then
2896         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2897     fi
2898     ;;
2899 *-irix*)
2900     if test "${target_os}" = "irix6.5"; then
2901         if test -n "$USE_PTHREADS"; then
2902             AC_DEFINE(_PR_HAVE_GETHOST_R)
2903             AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2904         fi
2905     fi
2906     ;;
2907 *-linux*|*-gnu*|*-k*bsd*-gnu)
2908     if test -n "$USE_NSPR_THREADS"; then
2909         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2910     fi
2911     ;;
2912 *-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*|*-beos*)
2913     dnl win32, os2 & beos cannot use pthreads
2914     USE_PTHREADS=
2915     _PTHREAD_LDFLAGS=
2916     USE_USER_PTHREADS=
2917     ;;
2918 *-netbsd*|*-openbsd*)
2919     if test -n "$USE_NSPR_THREADS"; then
2920         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2921     fi
2922     ;;
2923 *-osf*)
2924     if test -n "$USE_NSPR_THREADS"; then
2925         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2926     fi
2927     if test -n "$USE_PTHREADS"; then
2928         if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
2929             :
2930         else
2931             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2932         fi
2933     fi
2934     ;;
2935 *-solaris*)
2936     if test -n "$USE_NSPR_THREADS"; then
2937         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2938     fi
2939     if test -n "$USE_PTHREADS"; then
2940         AC_DEFINE(_REENTRANT)
2941         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2942         if test "$OS_TEST" = "i86pc"; then
2943             if test -n "$USE_64"; then
2944                PR_MD_ASFILES=os_SunOS_x86_64.s
2945             else
2946                PR_MD_ASFILES=os_SunOS_x86.s
2947             fi
2948         else
2949             if test -n "$USE_64"; then
2950                 PR_MD_ASFILES=os_SunOS_sparcv9.s
2951             fi
2952         fi
2953     fi
2954     ;;
2955 *-nto*)
2956     if test -n "$USE_PTHREADS"; then
2957         AC_DEFINE(_PR_HAVE_GETHOST_R)
2958         AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2959     fi
2960     ;;
2961 esac
2963 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2965 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2966 dnl make sure that we use it.
2967 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2968     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2971 if test -n "$_SAVE_DEBUG_FLAGS"; then
2972     _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2975 if test -n "$MOZ_OPTIMIZE"; then
2976     CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2977     CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2980 if test -n "$MOZ_DEBUG_SYMBOLS"; then
2981     CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2982     CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2985 if test -n "$MOZ_OPTIMIZE"; then
2986     OBJDIR_TAG=_OPT
2987 else
2988     OBJDIR_TAG=_DBG
2991 if test -n "$USE_64"; then
2992     COMPILER_TAG=_64
2995 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2997 dnl ========================================================
2998 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2999 dnl ========================================================
3000 case "$target_os" in
3001 cygwin*|mks*)
3002     CC="\$(CYGWIN_WRAPPER) $CC"
3003     CXX="\$(CYGWIN_WRAPPER) $CXX"
3004     RC="\$(CYGWIN_WRAPPER) $RC"
3005     ;;
3006 esac
3008 dnl ========================================================
3009 dnl = Use malloc wrapper lib
3010 dnl ========================================================
3011 AC_ARG_ENABLE(wrap-malloc,
3012 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
3013 [     if test "$enableval" = "yes"; then
3014             _WRAP_MALLOC=1
3015       fi ])
3017 if test -n "$_WRAP_MALLOC"; then
3018     if test -n "$GNU_CC"; then
3019         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
3020         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
3021         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
3022         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
3023     else
3024         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
3025     fi
3028 dnl ========================================================
3029 dnl = Location of malloc wrapper lib
3030 dnl ========================================================
3031 AC_ARG_WITH(wrap-malloc,
3032 [  --with-wrap-malloc=SHAREDLIB  Location of malloc wrapper library],
3033     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
3035 dnl ========================================================
3036 dnl Substitution of found variables.
3037 dnl ========================================================
3038 AC_SUBST(SHELL_OVERRIDE)
3040 AC_SUBST(MOZILLA_CLIENT)
3041 AC_SUBST(CC)
3042 AC_SUBST(CXX)
3043 AC_SUBST(CFLAGS)
3044 AC_SUBST(CXXFLAGS)
3045 AC_SUBST(CPPFLAGS)
3046 AC_SUBST(HOST_CC)
3047 AC_SUBST(HOST_CFLAGS)
3048 AC_SUBST(LDFLAGS)
3049 AC_SUBST(HOST_LDFLAGS)
3050 AC_SUBST(GNU_CC)
3051 AC_SUBST(GCC_USE_GNU_LD)
3052 AC_SUBST(MSC_VER)
3053 AC_SUBST(CROSS_COMPILE)
3055 AC_SUBST(MOZ_OPTIMIZE)
3056 AC_SUBST(MOZ_DEBUG)
3057 AC_SUBST(MOZ_DEBUG_SYMBOLS)
3059 AC_SUBST(USE_CPLUS)
3060 AC_SUBST(USE_IPV6)
3061 AC_SUBST(USE_N32)
3062 AC_SUBST(USE_X32)
3063 AC_SUBST(USE_64)
3064 AC_SUBST(OBJECT_MODE)
3065 AC_SUBST(ENABLE_STRIP)
3067 AC_SUBST(USE_PTHREADS)
3068 AC_SUBST(USE_BTHREADS)
3069 AC_SUBST(USE_USER_PTHREADS)
3070 AC_SUBST(USE_NSPR_THREADS)
3072 AC_SUBST(LIBNSPR)
3073 AC_SUBST(LIBPLC)
3075 AC_SUBST(MOD_MAJOR_VERSION)
3076 AC_SUBST(MOD_MINOR_VERSION)
3077 AC_SUBST(MOD_PATCH_VERSION)
3078 AC_SUBST(NSPR_MODNAME)
3079 AC_SUBST(MDCPUCFG_H)
3080 AC_SUBST(PR_MD_CSRCS)
3081 AC_SUBST(PR_MD_ASFILES)
3082 AC_SUBST(PR_MD_ARCH_DIR)
3083 AC_SUBST(CPU_ARCH)
3085 AC_SUBST(OBJ_SUFFIX)
3086 AC_SUBST(LIB_SUFFIX)
3087 AC_SUBST(DLL_SUFFIX)
3088 AC_SUBST(ASM_SUFFIX)
3089 AC_SUBST(WRAP_LDFLAGS)
3090 AC_SUBST(MKSHLIB)
3091 AC_SUBST(DSO_CFLAGS)
3092 AC_SUBST(DSO_LDOPTS)
3094 AC_SUBST(OS_TARGET)
3095 AC_SUBST(OS_ARCH)
3096 AC_SUBST(OS_RELEASE)
3097 AC_SUBST(OS_TEST)
3098 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
3100 AC_SUBST(DEFINES)
3101 AC_SUBST(DEFS)
3102 AC_SUBST(AR)
3103 AC_SUBST(AR_FLAGS)
3104 AC_SUBST(AS)
3105 AC_SUBST(ASFLAGS)
3106 AC_SUBST(LD)
3107 AC_SUBST(RANLIB)
3108 AC_SUBST(PERL)
3109 AC_SUBST(STRIP)
3110 AC_SUBST(FILTER)
3111 AC_SUBST(IMPLIB)
3113 AC_SUBST(PROFILE_GEN_CFLAGS)
3114 AC_SUBST(PROFILE_GEN_LDFLAGS)
3115 AC_SUBST(PROFILE_USE_CFLAGS)
3116 AC_SUBST(PROFILE_USE_LDFLAGS)
3118 AC_SUBST(OS_LIBS)
3119 AC_SUBST(RESOLVE_LINK_SYMBOLS)
3120 AC_SUBST(AIX_LINK_OPTS)
3121 AC_SUBST(NOSUCHFILE)
3122 AC_SUBST(MOZ_OBJFORMAT)
3123 AC_SUBST(ULTRASPARC_LIBRARY)
3125 AC_SUBST(OBJDIR)
3126 AC_SUBST(OBJDIR_NAME)
3127 AC_SUBST(RELEASE_OBJDIR_NAME)
3128 AC_SUBST(NSINSTALL)
3129 AC_SUBST(OPTIMIZER)
3130 AC_SUBST(RC)
3131 AC_SUBST(RCFLAGS)
3132 AC_SUBST(DLLFLAGS)
3133 AC_SUBST(EXEFLAGS)
3134 AC_SUBST(OS_DLLFLAGS)
3135 AC_SUBST(CYGWIN_WRAPPER)
3136 AC_SUBST(VISIBILITY_FLAGS)
3137 AC_SUBST(WRAP_SYSTEM_INCLUDES)
3138 AC_SUBST(MACOS_SDK_DIR)
3139 AC_SUBST(SYMBIAN_SDK_DIR)
3140 AC_SUBST(NEXT_ROOT)
3141 AC_SUBST(MT)
3143 dnl ========================================================
3144 dnl Generate output files.
3145 dnl ========================================================
3146 MAKEFILES="
3147     Makefile
3148     config/Makefile
3149     config/autoconf.mk
3150     config/nsprincl.mk
3151     config/nsprincl.sh
3152     config/nspr-config
3153     config/nspr.pc
3154     lib/Makefile
3155     lib/ds/Makefile
3156     lib/libc/Makefile
3157     lib/libc/include/Makefile
3158     lib/libc/src/Makefile
3159     lib/tests/Makefile
3160     pkg/Makefile
3161     pr/Makefile
3162     pr/include/Makefile
3163     pr/include/md/Makefile
3164     pr/include/obsolete/Makefile
3165     pr/include/private/Makefile
3166     pr/src/Makefile
3167     pr/src/io/Makefile
3168     pr/src/linking/Makefile
3169     pr/src/malloc/Makefile
3170     pr/src/md/Makefile
3171     pr/src/md/${PR_MD_ARCH_DIR}/Makefile
3172     pr/src/memory/Makefile
3173     pr/src/misc/Makefile
3174     pr/src/threads/Makefile
3175     pr/tests/Makefile
3176     pr/tests/dll/Makefile
3179 if test "$OS_TARGET" = "Linux"; then
3180     MAKEFILES="$MAKEFILES
3181         pkg/linux/Makefile
3182     "
3183 elif test "$OS_TARGET" = "SunOS"; then
3184     MAKEFILES="$MAKEFILES
3185         pkg/solaris/Makefile
3186         pkg/solaris/SUNWpr/Makefile
3187         pkg/solaris/SUNWprd/Makefile
3188     "
3191 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
3192     MAKEFILES="$MAKEFILES
3193         pr/src/threads/combined/Makefile
3194     "
3195 elif test -n "$USE_PTHREADS"; then
3196     MAKEFILES="$MAKEFILES
3197         pr/src/pthreads/Makefile
3198     "
3199 elif test -n "$USE_BTHREADS"; then
3200     MAKEFILES="$MAKEFILES
3201         pr/src/bthreads/Makefile
3202     "
3205 if test -n "$USE_CPLUS"; then
3206     MAKEFILES="$MAKEFILES
3207         pr/src/cplus/Makefile
3208         pr/src/cplus/tests/Makefile
3209     "
3212 echo $MAKEFILES > unallmakefiles
3214 AC_CONFIG_FILES([$MAKEFILES])
3215 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])
3216 AC_OUTPUT