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