Bug 1569017 [wpt PR 18089] - [ElementTiming] Set startTime, a=testonly
[gecko.git] / nsprpub / configure.in
blob189f58d5f8da280e745f4b2967e9d783c5465955
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl 
3 dnl This Source Code Form is subject to the terms of the Mozilla Public
4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 AC_PREREQ(2.61)
8 AC_INIT
9 AC_CONFIG_SRCDIR([pr/include/nspr.h])
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
12 AC_CANONICAL_TARGET
14 dnl ========================================================
15 dnl = Defaults
16 dnl ========================================================
17 MOD_MAJOR_VERSION=4
18 MOD_MINOR_VERSION=22
19 MOD_PATCH_VERSION=0
20 NSPR_MODNAME=nspr20
21 _HAVE_PTHREADS=
22 USE_PTHREADS=
23 USE_USER_PTHREADS=
24 USE_NSPR_THREADS=
25 USE_N32=
26 USE_X32=
27 USE_64=
28 USE_CPLUS=
29 USE_IPV6=
30 USE_MDUPDATE=
31 _MACOSX_DEPLOYMENT_TARGET=
32 _OPTIMIZE_FLAGS=-O
33 _DEBUG_FLAGS=-g
34 MOZ_DEBUG=1
35 MOZ_OPTIMIZE=
36 OBJDIR='$(OBJDIR_NAME)'
37 OBJDIR_NAME=.
38 OBJDIR_SUFFIX=OBJ
39 NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
40 NOSUCHFILE=/no-such-file
41 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
42 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
43 CYGWIN_WRAPPER=
44 MACOS_SDK_DIR=
45 NEXT_ROOT=
46 MT=
47 MOZ_OS2_HIGH_MEMORY=1
48 PROFILE_GEN_CFLAGS=
49 PROFILE_GEN_LDFLAGS=
50 PROFILE_USE_CFLAGS=
51 PROFILE_USE_LDFLAGS=
53 dnl Link in libraries necessary to resolve all symbols for shared libs
54 RESOLVE_LINK_SYMBOLS=
56 dnl ========================================================
57 dnl =
58 dnl = Dont change the following lines.  Doing so breaks:
59 dnl =
60 dnl = CFLAGS="-foo" ./configure
61 dnl =
62 dnl ========================================================
63 CFLAGS="${CFLAGS=}"
64 CXXFLAGS="${CXXFLAGS=}"
65 LDFLAGS="${LDFLAGS=}"
66 DLLFLAGS="${DLLFLAGS=}"
67 HOST_CFLAGS="${HOST_CFLAGS=}"
68 HOST_LDFLAGS="${HOST_LDFLAGS=}"
70 case "$target" in
71 *-cygwin*|*-mingw*|*-msys*)
72     # Check to see if we are really running in a msvc environemnt
73     _WIN32_MSVC=
74     AC_CHECK_PROGS(CC, cl)
75     cat > conftest.c <<EOF
76 #ifdef _MSC_VER
77 COMPILER IS MSVC
78 #endif
79 EOF
80     read dummy <<EOF
81 $($CC -E conftest.c 2>/dev/null | grep COMPILER)
82 EOF
83     if test -n "$dummy"; then
84         _WIN32_MSVC=1
85         CXX=$CC
86     fi
87     rm -f conftest.c
88     ;;
89 *-mks*)
90     _WIN32_MSVC=1
91     ;;
92 esac
94 if test -n "$_WIN32_MSVC"; then
95     SKIP_PATH_CHECKS=1
96     SKIP_COMPILER_CHECKS=1
97     SKIP_LIBRARY_CHECKS=1
100 dnl ========================================================
101 dnl = Android uses a very custom (hacky) toolchain; we need to do this
102 dnl = here, so that the compiler checks can succeed
103 dnl ========================================================
105 AC_ARG_WITH(android-ndk,
106 [  --with-android-ndk=DIR
107                           location where the Android NDK can be found],
108     android_ndk=$withval)
110 AC_ARG_WITH(android-toolchain,
111 [  --with-android-toolchain=DIR
112                           location of the Android toolchain],
113     android_toolchain=$withval)
115 dnl The default android_version is different for each target cpu.
116 case "$target_cpu" in
117 arm)
118     android_version=5
119     ;;
120 i?86|mipsel)
121     android_version=9
122     ;;
123 esac
125 AC_ARG_WITH(android-version,
126 [  --with-android-version=VER
127                           Android platform version, default 5 for arm, 9 for x86/mips],
128     android_version=$withval)
130 AC_ARG_WITH(android-platform,
131 [  --with-android-platform=DIR
132                           location of platform dir],
133     android_platform=$withval)
135 case "$target" in
136 x86_64-linux*-android*)
137     android_tool_prefix="x86_64-linux-android"
138     ;;
139 aarch64-linux*-android*)
140     android_tool_prefix="aarch64-linux-android"
141     ;;
142 arm-linux*-android*|*-linuxandroid*)
143     android_tool_prefix="arm-linux-androideabi"
144     ;;
145 i?86-*android*)
146     android_tool_prefix="i686-linux-android"
147     ;;
148 mipsel-*android*)
149     android_tool_prefix="mipsel-linux-android"
150     ;;
152     android_tool_prefix="$target_os"
153     ;;
154 esac
156 case "$target" in
157 *-android*|*-linuxandroid*)
158     if test -z "$android_ndk" ; then
159        AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
160     fi
162     if test -z "$android_toolchain" ; then
163         AC_MSG_CHECKING([for android toolchain directory])
165         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
167         case "$target_cpu" in
168         arm)
169             target_name=arm-linux-androideabi-4.4.3
170             ;;
171         i?86)
172             target_name=x86-4.4.3
173             ;;
174         mipsel)
175             target_name=mipsel-linux-android-4.4.3
176             ;;
177         esac
178         android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
180         if test -d "$android_toolchain" ; then
181             AC_MSG_RESULT([$android_toolchain])
182         else
183             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
184         fi
185     fi
187     if test -z "$android_platform" ; then
188         AC_MSG_CHECKING([for android platform directory])
190         case "$target_cpu" in
191         arm)
192             target_name=arm
193             ;;
194         i?86)
195             target_name=x86
196             ;;
197         mipsel)
198             target_name=mips
199             ;;
200         esac
202         android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
204         if test -d "$android_platform" ; then
205             AC_MSG_RESULT([$android_platform])
206         else
207             AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
208         fi
209     fi
211     dnl Old NDK support. If minimum requirement is changed to NDK r8b,
212     dnl please remove this.
213     case "$target_cpu" in
214     i?86)
215         if ! test -e "$android_toolchain"/bin/"$android_tool_prefix"-gcc; then
216             dnl Old NDK toolchain name
217             android_tool_prefix="i686-android-linux"
218         fi
219         ;;
220     esac
222     dnl set up compilers
223     AS="$android_toolchain"/bin/"$android_tool_prefix"-as
224     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
225     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
226     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
227     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
228     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
229     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
230     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
232     CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
233     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
234     CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
235     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
237     AC_DEFINE(ANDROID)
238     ;;
239 esac
241 dnl ========================================================
242 dnl =
243 dnl = Check options that may affect the compiler
244 dnl =
245 dnl ========================================================
246 dist_prefix='${MOD_DEPTH}/dist'
247 dist_bindir='${dist_prefix}/bin'
248 dist_includedir='${dist_prefix}/include/nspr'
249 dist_libdir='${dist_prefix}/lib'
250 dnl If the --includedir option was not specified, add '/nspr' to autoconf's
251 dnl default value of includedir.
252 if test "${includedir}" = '${prefix}/include'; then
253     includedir='${prefix}/include/nspr'
256 AC_ARG_WITH(dist-prefix,
257     [  --with-dist-prefix=DIST_PREFIX
258                           place build files in DIST_PREFIX [dist]],
259     dist_prefix=$withval)
261 AC_ARG_WITH(dist-bindir,
262     [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
263     dist_bindir=$withval)
265 AC_ARG_WITH(dist-includedir,
266     [  --with-dist-includedir=DIR
267                           build include files in DIR [DIST_PREFIX/include/nspr]],
268     dist_includedir=$withval)
270 AC_ARG_WITH(dist-libdir,
271     [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
272     dist_libdir=$withval)
274 AC_SUBST(dist_prefix)
275 AC_SUBST(dist_bindir)
276 AC_SUBST(dist_includedir)
277 AC_SUBST(dist_libdir)
279 dnl Check if NSPR is being compiled for Mozilla
280 dnl Let --with-arg override environment setting
282 AC_ARG_WITH(mozilla,
283     [  --with-mozilla          Compile NSPR with Mozilla support],
284     [   if test "$withval" = "yes"; then
285             AC_DEFINE(MOZILLA_CLIENT)
286             MOZILLA_CLIENT=1
287             else
288                 MOZILLA_CLIENT=
289             fi],
290     [   if test -n "$MOZILLA_CLIENT"; then
291                 AC_DEFINE(MOZILLA_CLIENT)
292             fi])
294 AC_ARG_ENABLE(optimize,
295     [  --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
296     [ if test "$enableval" != "no"; then
297           MOZ_OPTIMIZE=1
298           if test -n "$enableval" -a "$enableval" != "yes"; then
299             _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
300             _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
301           fi
302       else
303           MOZ_OPTIMIZE=
304       fi ])
306 AC_ARG_ENABLE(debug,
307     [  --enable-debug[=DBG]    Enable debugging (using compiler flags DBG)],
308     [ if test "$enableval" != "no"; then
309           MOZ_DEBUG=1
310           MOZ_DEBUG_SYMBOLS=1
311           if test -n "$enableval" -a "$enableval" != "yes"; then
312               _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
313               _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
314           fi
315       else
316           MOZ_DEBUG=
317       fi ],
318       MOZ_DEBUG_SYMBOLS=1)
320 AC_ARG_ENABLE(debug-symbols,
321     [  --enable-debug-symbols[=DBG]    Enable debugging symbols
322                                        (using compiler flags DBG)],
323     [ if test "$enableval" != "no"; then
324           MOZ_DEBUG_SYMBOLS=1
325           if test -n "$enableval" -a "$enableval" != "yes"; then
326               if test -z "$_SAVE_DEBUG_FLAGS"; then
327                   _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
328                   _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
329               else
330                   AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
331               fi
332           fi
333       else
334           MOZ_DEBUG_SYMBOLS=
335       fi ])
337 AC_ARG_ENABLE(win32-target,
338     [  --enable-win32-target=\$t
339                           Specify win32 flavor. (WIN95 or WINNT)],
340     OS_TARGET=`echo $enableval | tr a-z A-Z`)
343 AC_ARG_ENABLE(debug-rtl,
344     [  --enable-debug-rtl      Use the MSVC debug runtime library],
345     [ if test "$enableval" = "yes"; then
346             USE_DEBUG_RTL=1
347       else
348             USE_DEBUG_RTL=0
349       fi ])
351 AC_ARG_ENABLE(static-rtl,
352     [  --enable-static-rtl     Use the MSVC static runtime library],
353     [ if test "$enableval" = "yes"; then
354             USE_STATIC_RTL=1
355       fi ])
357 AC_ARG_ENABLE(x32,
358     [  --enable-x32            Enable x32 ABI support (x86_64 only)],
359     [ if test "$enableval" = "yes"; then
360         USE_X32=1
361       else if test "$enableval" = "no"; then
362         USE_X32=
363       fi
364     fi ])
366 AC_ARG_ENABLE(64bit,
367     [  --enable-64bit          Enable 64-bit support (on certain platforms)],
368     [ if test "$enableval" = "yes"; then
369             USE_64=1
370       fi ])
372 AC_ARG_ENABLE(mdupdate,
373     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
374     [ if test "$enableval" = "yes"; then
375             USE_MDUPDATE=1
376       fi ])
378 AC_ARG_ENABLE(cplus,
379     [  --enable-cplus          Enable some c++ api routines],
380     [ if test "$enableval" = "yes"; then
381             USE_CPLUS=1
382       fi]) 
384 AC_ARG_WITH(arm-kuser,
385     [  --with-arm-kuser        Use kuser helpers (Linux/ARM only)
386                           (Requires kernel 2.6.13 or later)],
387     [ if test "$withval" = "yes"; then
388             AC_DEFINE(_PR_ARM_KUSER)
389       fi ])
391 dnl ========================================================
392 dnl = Mac OS X SDK support
393 dnl ========================================================
394 AC_ARG_WITH(macos-sdk,
395     [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
396     MACOS_SDK_DIR=$withval)
398 AC_ARG_ENABLE(macos-target,
399              [  --enable-macos-target=VER
400                           Set the minimum MacOS version needed at runtime
401                           [10.2 for ppc, 10.4 for x86]],
402              [_MACOSX_DEPLOYMENT_TARGET=$enableval])
404 dnl ========================================================
405 dnl =
406 dnl = Set the threading model
407 dnl =
408 dnl ========================================================
409 case "$target" in
411 *-aix*)
412     case "${target_os}" in
413     aix3.2*)
414         USE_NSPR_THREADS=1
415         ;;
416     *)
417         USE_PTHREADS=1
418         ;;
419     esac
420     ;;
422 esac
424 dnl ========================================================
425 dnl =
426 dnl = Set the default C compiler
427 dnl =
428 dnl ========================================================
429 if test -z "$CC"; then
430     case "$target" in
432     *-aix*)
433         if test -z "$USE_NSPR_THREADS"; then
434             CC=xlc_r
435         else
436             CC=xlc
437         fi
438     ;;
440     *-hpux*)
441         CC=cc
442     ;;
444     *-solaris*)
445         CC=cc
446     ;;
448     esac
451 dnl ========================================================
452 dnl =
453 dnl = Set the default C++ compiler
454 dnl =
455 dnl ========================================================
456 if test -z "$CXX"; then
457     case "$target" in
459     *-aix*)
460         if test -z "$USE_NSPR_THREADS"; then
461             CXX=xlC_r
462         else
463             CXX=xlC
464         fi
465     ;;
467     *-hpux*)
468         case "${target_os}" in
469         hpux10.30)
470             CXX=aCC
471             ;;
472         hpux11.*)
473             CXX=aCC
474             ;;
475         *)
476             CXX=CC
477             ;;
478         esac
479     ;;
481     *-solaris*)
482         CXX=CC
483     ;;
485     esac
488 if test -z "$SKIP_PATH_CHECKS"; then
489     AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
492 if test -n "$MOZ_DEBUG"; then
493     AC_DEFINE(DEBUG)
494     DEFINES="$DEFINES -UNDEBUG"
496     case "${target_os}" in
497     mks*|cygwin*|mingw*|msys*|os2*)
498         DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
499         ;;
500     *)
501         DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
502         ;;
503     esac
504 else
505     AC_DEFINE(NDEBUG)
506     DEFINES="$DEFINES -UDEBUG"
509 if test -z "$SKIP_COMPILER_CHECKS"; then
510 dnl ========================================================
511 dnl Checks for compilers.
512 dnl ========================================================
513 if test "$target" != "$host"; then
514     echo "cross compiling from $host to $target"
515     cross_compiling=yes
517     case "$build:$target" in
518       powerpc-apple-darwin8*:i?86-apple-darwin*)
519         dnl The Darwin cross compiler doesn't necessarily point itself at a
520         dnl root that has libraries for the proper architecture, it defaults
521         dnl to the system root.  The libraries in the system root on current
522         dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
523         dnl checks will fail.  Fake a working SDK in that case.
524         _SAVE_CFLAGS=$CFLAGS
525         _SAVE_CXXFLAGS=$CXXFLAGS
526         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
527         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
528         ;;
529     esac
531     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
532     unset ac_cv_prog_CC
533     dnl Now exit the conditional block to invoke AC_PROG_CC.
536 dnl In the latest versions of autoconf, AC_PROG_CC is a one-shot macro,
537 dnl declared with AC_DEFUN_ONCE. So it must not be expanded inside a
538 dnl conditional block. Invoke AC_PROG_CC outside any conditional block
539 dnl and before invoking AC_TRY_COMPILE (which requires AC_PROG_CC).
540 AC_PROG_CC
542 dnl Reenter the conditional blocks after invoking AC_PROG_CC.
543 if test "$target" != "$host"; then
544     if test -n "$USE_CPLUS"; then
545         AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
546         unset ac_cv_prog_CXX
547         AC_PROG_CXX
548     fi
550     case "$build:$target" in
551       powerpc-apple-darwin8*:i?86-apple-darwin*|*:arm*-apple-darwin*)
552         dnl Revert the changes made above.  From this point on, the target
553         dnl compiler will never be used without applying the SDK to CFLAGS
554         dnl (see --with-macos-sdk below).
555         CFLAGS=$_SAVE_CFLAGS
556         CXXFLAGS=$_SAVE_CXXFLAGS
557         ;;
558     esac
560     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
561     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
562     AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
563     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
564     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
565     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
567     _SAVE_CC="$CC"
568     _SAVE_CFLAGS="$CFLAGS"
569     _SAVE_LDFLAGS="$LDFLAGS"
571     AC_MSG_CHECKING([for $host compiler])
572     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
573     if test -z "$HOST_CC"; then
574         AC_MSG_ERROR([no acceptable cc found in \$PATH])
575     fi
576     AC_MSG_RESULT([$HOST_CC])
578     CC="$HOST_CC"
579     CFLAGS="$HOST_CFLAGS"
580     LDFLAGS="$HOST_LDFLAGS"
582     AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
583     AC_TRY_COMPILE([], [return 0;],
584         [AC_MSG_RESULT([yes])],
585         [AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.])] )
587     CC=$_SAVE_CC
588     CFLAGS=$_SAVE_CFLAGS
589     LDFLAGS=$_SAVE_LDFLAGS
590 else
591     if test -n "$USE_CPLUS"; then
592         if test "$CC" = "cl" -a -z "$CXX"; then
593             CXX=$CC
594         else
595             AC_PROG_CXX
596         fi
597     fi
598     AC_PROG_RANLIB
599     AC_PATH_PROGS(AS, as, $CC)
600     AC_PATH_PROGS(AR, ar, echo not_ar)
601     AC_PATH_PROGS(LD, ld link, echo not_ld)
602     AC_PATH_PROGS(STRIP, strip, echo not_strip)
603     AC_PATH_PROGS(WINDRES, windres, echo not_windres)
604     if test -z "$HOST_CC"; then
605         HOST_CC="$CC"
606     fi
607     if test -z "$HOST_CFLAGS"; then
608         HOST_CFLAGS="$CFLAGS"
609     fi
612 AC_PROG_CPP
614 if test "$GCC" = "yes"; then
615     GNU_CC=1
617 if test "$GXX" = "yes"; then
618     GNU_CXX=1
620 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
621     GNU_AS=1
623 rm -f a.out
625 case "$build:$target" in
626     i?86-apple-darwin*:powerpc-apple-darwin*)
627         dnl cross_compiling will have erroneously been set to "no" in this
628         dnl case, because the x86 build host is able to run ppc code in a
629         dnl translated environment, making a cross compiler appear native.
630         cross_compiling=yes
631         ;;
632 esac
634 if test "$cross_compiling"  = "yes"; then
635     CROSS_COMPILE=1
636 else
637     CROSS_COMPILE=
640 dnl ========================================================
641 dnl Check for gcc -pipe support
642 dnl ========================================================
643 AC_MSG_CHECKING([for gcc -pipe support])
644 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
645     echo '#include <stdio.h>' > dummy-hello.c
646     echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
647     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
648     cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
649     if test $? = 0; then
650         _res_as_stdin="yes"
651     else
652         _res_as_stdin="no"
653     fi
654     if test "$_res_as_stdin" = "yes"; then
655         _SAVE_CFLAGS=$CFLAGS
656         CFLAGS="$CFLAGS -pipe"
657         AC_TRY_COMPILE( [ #include <stdio.h> ],
658             [printf("Hello World\n");],
659             [_res_gcc_pipe="yes"],
660             [_res_gcc_pipe="no"] )
661         CFLAGS=$_SAVE_CFLAGS
662     fi
663     if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
664         _res="yes";
665         CFLAGS="$CFLAGS -pipe"
666         CXXFLAGS="$CXXFLAGS -pipe"
667     else
668         _res="no"
669     fi
670     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
671     AC_MSG_RESULT([$_res])
672 else
673     AC_MSG_RESULT([no])
676 dnl ========================================================
677 dnl Check for pragma diagnostic
678 dnl ========================================================
680 AC_MSG_CHECKING([for pragma diagnostic])
681 if test "$GNU_CC" = "1"; then
682     cat >dummy-hello.c <<EOF
683 #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
684 #pragma GCC diagnostic push
685 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
686 #endif
687 int main() {
688     char *dummy = "";
689     return 0;
692     ${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
693     if test $? != 0; then
694         ${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
695         if test $? = 0; then
696             CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
697             _res=yes
698         else
699             _res=no
700         fi
701     else
702         _res=no
703     fi
704     rm -f dummy-hello.c dummy-hello.s
705     AC_MSG_RESULT([$_res])
706 else
707     AC_MSG_RESULT([no])
710 dnl ========================================================
711 dnl Profile guided optimization
712 dnl ========================================================
713 dnl Test for profiling options
714 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
716 _SAVE_CFLAGS="$CFLAGS"
717 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
719 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
720 AC_TRY_COMPILE([], [return 0;],
721                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
722                  result="yes" ], result="no")
723 AC_MSG_RESULT([$result])
725 if test $result = "yes"; then
726    PROFILE_GEN_LDFLAGS="-fprofile-generate"
727    PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
728    PROFILE_USE_LDFLAGS="-fprofile-use"
731 CFLAGS="$_SAVE_CFLAGS"
733 dnl ===============================================================
734 dnl Check for .hidden assembler directive and visibility attribute.
735 dnl Borrowed from glibc configure.in
736 dnl ===============================================================
737 if test "$GNU_CC"; then
738     AC_CACHE_CHECK(for visibility(hidden) attribute,
739         ac_cv_visibility_hidden,
740         [cat > conftest.c <<EOF
741         int foo __attribute__ ((visibility ("hidden"))) = 1;
743         ac_cv_visibility_hidden=no
744         if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
745             if grep '\.hidden.*foo' conftest.s >/dev/null; then
746                 ac_cv_visibility_hidden=yes
747             fi
748         fi
749         rm -f conftest.[cs]
750         ])
751     if test "$ac_cv_visibility_hidden" = "yes"; then
752         AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
753         AC_CACHE_CHECK(for visibility pragma support,
754             ac_cv_visibility_pragma,
755             [cat > conftest.c <<EOF
756 #pragma GCC visibility push(hidden)
757             int foo_hidden = 1;
758 #pragma GCC visibility push(default)
759             int foo_default = 1;
761             ac_cv_visibility_pragma=no
762             if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
763                 if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
764                     if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
765                         ac_cv_visibility_pragma=yes
766                     fi
767                 fi
768             fi
769             rm -f conftest.[cs]
770             ])
771         if test "$ac_cv_visibility_pragma" = "yes"; then
772             AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
773             # To work around a build problem on Linux x86-64 (Bugzilla bug
774             # 293438), we use the -fvisibility=hidden flag.  This flag is less
775             # optimal than #pragma GCC visibility push(hidden) because the flag
776             # assumes that symbols defined outside the current source file have
777             # the default visibility.  This has the advantage that we don't need
778             # to wrap system header files, but has the disadvantage that calls
779             # to hidden symbols defined in other source files cannot be
780             # optimized by the compiler.  The -fvisibility=hidden flag does
781             # hide and export symbols correctly.
782             #VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
783             #WRAP_SYSTEM_INCLUDES=1
784             VISIBILITY_FLAGS="-fvisibility=hidden"
785             WRAP_SYSTEM_INCLUDES=
786         fi
787     fi
788 fi # GNU_CC
790 fi # SKIP_COMPILER_CHECKS
792 dnl ========================================================
793 dnl Checks for programs.
794 dnl ========================================================
795 if test -z "$SKIP_PATH_CHECKS"; then
796     AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
797 elif test -z "$PERL"; then
798     PERL=perl
801 dnl ========================================================
802 dnl Default platform specific options
803 dnl ========================================================
804 OBJ_SUFFIX=o
805 LIB_SUFFIX=a
806 DLL_SUFFIX=so
807 ASM_SUFFIX=s
808 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
809 PR_MD_ASFILES=
810 PR_MD_CSRCS=
811 PR_MD_ARCH_DIR=unix
812 AR_FLAGS='cr $@'
813 AS='$(CC)'
814 ASFLAGS='$(CFLAGS)'
816 if test -n "$CROSS_COMPILE"; then
817     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
818     OS_RELEASE=
819     OS_TEST="${target_cpu}"
820     case "${target_os}" in
821         linux*)       OS_ARCH=Linux ;;
822         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
823         mingw*)       OS_ARCH=WINNT CPU_ARCH=x86 ;;
824         darwin*)      OS_ARCH=Darwin ;;
825         riscos*)      OS_ARCH=RISCOS ;;
826     esac
827 else
828     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
829     OS_RELEASE=`uname -r`
830     OS_TEST=`uname -m`
833 if test "$OS_ARCH" = "AIX"; then
834     OS_RELEASE=`uname -v`.`uname -r`
837 if test "$OS_ARCH" = "FreeBSD"; then
838     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
841 if test "$OS_ARCH" = "Linux"; then
842     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
843     OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
846 #######################################################################
847 # Master "Core Components" macros for getting the OS target           #
848 #######################################################################
851 # Note: OS_TARGET should be specified on the command line for gmake.
852 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
853 # The difference between the Win95 target and the WinNT target is that
854 # the WinNT target uses Windows NT specific features not available
855 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
856 # at lesser performance (the Win95 target uses threads; the WinNT target
857 # uses fibers).
859 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
860 # cross-compilation.
864 # The following hack allows one to build on a WIN95 machine (as if
865 # s/he were cross-compiling on a WINNT host for a WIN95 target).
866 # It also accomodates for MKS's uname.exe.  If you never intend
867 # to do development on a WIN95 machine, you don't need this hack.
869 case "$OS_ARCH" in
870 Windows_95)
871     OS_ARCH=Windows_NT
872     OS_TARGET=WIN95
873     ;;
874 Windows_98)
875     OS_ARCH=Windows_NT
876     OS_TARGET=WIN95
877     ;;
878 CYGWIN_9*|CYGWIN_ME*)
879     OS_ARCH='CYGWIN_NT-4.0'
880     OS_TARGET=WIN95
881     ;;
882 OS_2)
883     OS_ARCH=OS2
884     OS_TARGET=OS2
885     ;;
886 esac
889 # On WIN32, we also define the variable CPU_ARCH.
892 case "$OS_ARCH" in
893 Windows_NT)
895 # If uname -s returns "Windows_NT", we assume that we are using
896 # the uname.exe in MKS toolkit.
898 # The -r option of MKS uname only returns the major version number.
899 # So we need to use its -v option to get the minor version number.
900 # Moreover, it doesn't have the -p option, so we need to use uname -m.
902     OS_ARCH=WINNT
903     OS_MINOR_RELEASE=`uname -v`
904     if test "$OS_MINOR_RELEASE" = "00"; then
905         OS_MINOR_RELEASE=0
906     fi
907     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
908     CPU_ARCH=`uname -m`
909     #
910     # MKS's uname -m returns "586" on a Pentium machine.
911     #
912     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
913         CPU_ARCH=x86
914     fi
915     ;;
916 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
918 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
919 # the uname.exe in the Cygwin tools.
920 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
921 # the uname.exe in the MSYS tools.
922 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
923 # the uname.exe in the MSYS2 tools.
925     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
926     OS_ARCH=WINNT
927     CPU_ARCH=`uname -m`
928     #
929     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
930     #
931     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
932         CPU_ARCH=x86
933     fi
934     ;;
935 esac
937 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
938     OS_TARGET=WIN95
939     if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
940         USE_DEBUG_RTL=1
941     fi
943 if test -z "$OS_TARGET"; then
944     OS_TARGET=$OS_ARCH
946 if test "$OS_TARGET" = "WIN95"; then
947     OS_RELEASE="4.0"
949 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
951 dnl ========================================================
952 dnl Enable high-memory support on OS/2 by default.
953 dnl ========================================================
954 AC_ARG_ENABLE(os2-high-mem,
955     [  --disable-os2-high-mem  Disable high-memory support on OS/2],
956     [ if test "$enableval" = "no"; then
957         MOZ_OS2_HIGH_MEMORY=
958       else
959         MOZ_OS2_HIGH_MEMORY=1
960       fi ])
962 dnl ========================================================
963 dnl = ARM toolchain tweaks
964 dnl ========================================================
966 dnl Defaults
967 MOZ_ALIGN=toolchain-default
969 case "$target" in
970 arm*-android*|arm*-linuxandroid*)
971     MOZ_THUMB=yes
972     MOZ_ARCH=armv7-a
973     MOZ_FPU=vfp
974     MOZ_FLOAT_ABI=softfp
975     MOZ_SOFT_FLOAT=yes
976     MOZ_ALIGN=no
977     ;;
978 arm*-*)
979     if test -n "$MOZ_PLATFORM_MAEMO"; then
980         MOZ_THUMB=no
981         MOZ_ARCH=armv7-a
982         MOZ_FLOAT_ABI=softfp
983     fi
984     if test "$MOZ_PLATFORM_MAEMO" = 6; then
985         MOZ_THUMB=yes
986     fi
987     ;;
988 esac
990 dnl Kept for compatibility with some buildbot mozconfig
991 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
993 AC_ARG_WITH(thumb,
994 [  --with-thumb[[=yes|no|toolchain-default]]]
995 [                          Use Thumb instruction set (-mthumb)],
996     if test -z "$GNU_CC"; then
997         AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
998     fi
999     MOZ_THUMB=$withval)
1001 AC_ARG_WITH(thumb-interwork,
1002 [  --with-thumb-interwork[[=yes|no|toolchain-default]]
1003                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
1004     if test -z "$GNU_CC"; then
1005         AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
1006     fi
1007     MOZ_THUMB_INTERWORK=$withval)
1009 AC_ARG_WITH(arch,
1010 [  --with-arch=[[type|toolchain-default]]
1011                            Use specific CPU features (-march=type)],
1012     if test -z "$GNU_CC"; then
1013         AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
1014     fi
1015     MOZ_ARCH=$withval)
1017 AC_ARG_WITH(fpu,
1018 [  --with-fpu=[[type|toolchain-default]]
1019                            Use specific FPU type (-mfpu=type)],
1020     if test -z "$GNU_CC"; then
1021         AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
1022     fi
1023     MOZ_FPU=$withval)
1025 AC_ARG_WITH(float-abi,
1026 [  --with-float-abi=[[type|toolchain-default]]
1027                            Use specific arm float ABI (-mfloat-abi=type)],
1028     if test -z "$GNU_CC"; then
1029         AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
1030     fi
1031     MOZ_FLOAT_ABI=$withval)
1033 AC_ARG_WITH(soft-float,
1034 [  --with-soft-float[[=yes|no|toolchain-default]]
1035                            Use soft float library (-msoft-float)],
1036     if test -z "$GNU_CC"; then
1037         AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
1038     fi
1039     MOZ_SOFT_FLOAT=$withval)
1041 case "$MOZ_ARCH" in
1042 toolchain-default|"")
1043     arch_flag=""
1044     ;;
1046     arch_flag="-march=$MOZ_ARCH"
1047     ;;
1048 esac
1050 case "$MOZ_THUMB" in
1051 yes)
1052     MOZ_THUMB2=1
1053     thumb_flag="-mthumb"
1054     ;;
1056     MOZ_THUMB2=
1057     thumb_flag="-marm"
1058     ;;
1060     _SAVE_CFLAGS="$CFLAGS"
1061     CFLAGS="$arch_flag"
1062     AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1063         MOZ_THUMB2=1,
1064         MOZ_THUMB2=)
1065     CFLAGS="$_SAVE_CFLAGS"
1066     thumb_flag=""
1067     ;;
1068 esac
1070 case "$MOZ_THUMB_INTERWORK" in
1071 yes)
1072     thumb_interwork_flag="-mthumb-interwork"
1073     ;;
1075     thumb_interwork_flag="-mno-thumb-interwork"
1076     ;;
1077 *) # toolchain-default
1078     thumb_interwork_flag=""
1079     ;;
1080 esac
1082 case "$MOZ_FPU" in
1083 toolchain-default|"")
1084     fpu_flag=""
1085     ;;
1087     fpu_flag="-mfpu=$MOZ_FPU"
1088     ;;
1089 esac
1091 case "$MOZ_FLOAT_ABI" in
1092 toolchain-default|"")
1093     float_abi_flag=""
1094     ;;
1096     float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1097     ;;
1098 esac
1100 case "$MOZ_SOFT_FLOAT" in
1101 yes)
1102     soft_float_flag="-msoft-float"
1103     ;;
1105     soft_float_flag="-mno-soft-float"
1106     ;;
1107 *) # toolchain-default
1108     soft_float_flag=""
1109     ;;
1110 esac
1112 case "$MOZ_ALIGN" in
1113 toolchain-default|"")
1114     align_flag=""
1115     ;;
1117     align_flag="-mno-unaligned-access"
1118     ;;
1119 yes)
1120     align_flag="-munaligned-access"
1121     ;;
1123     align_flag=""
1124     ;;
1125 esac
1127 if test -n "$align_flag"; then
1128   _SAVE_CFLAGS="$CFLAGS"
1129   CFLAGS="$CFLAGS $align_flag"
1130   AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
1131   AC_TRY_COMPILE([],[],,align_flag="")
1132   CFLAGS="$_SAVE_CFLAGS"
1135 dnl Use echo to avoid accumulating space characters
1136 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
1137 if test -n "$all_flags"; then
1138     _SAVE_CFLAGS="$CFLAGS"
1139     CFLAGS="$all_flags"
1140     AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1141     AC_TRY_COMPILE([],[return 0;],
1142         AC_MSG_RESULT([yes]),
1143         AC_MSG_ERROR([no]))
1145     CFLAGS="$_SAVE_CFLAGS $all_flags"
1146     CXXFLAGS="$CXXFLAGS $all_flags"
1147     ASFLAGS="$ASFLAGS $all_flags"
1148     if test -n "$thumb_flag"; then
1149         LDFLAGS="$LDFLAGS $thumb_flag"
1150     fi
1153 dnl ========================================================
1154 dnl Override of system specific host options
1155 dnl ========================================================
1156 case "$host" in
1157 *-mingw*|*-msys*)
1158     NSINSTALL=nsinstall
1159     ;;
1160 *-cygwin*|*-mks*)
1161     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
1162     if test `echo "${PATH}" | grep -c \;` = 0; then
1163         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
1164     fi
1165     ;;
1166 *os2*)
1167     ;;
1169     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1170     ;;
1171 esac
1173 dnl ========================================================
1174 dnl Override of system specific target options
1175 dnl ========================================================
1176 case "$target" in
1178 *-aix*)
1179     AC_DEFINE(XP_UNIX)
1180     AC_DEFINE(AIX)
1181     AC_DEFINE(SYSV)
1182     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
1183     AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
1184     case "${target_os}" in
1185     aix3.2*)
1186         AC_DEFINE(AIX_RENAME_SELECT)
1187         AC_DEFINE(_PR_NO_LARGE_FILES)
1188         AIX_LINK_OPTS='-bnso -berok'
1189         PR_MD_ASFILES=os_AIX.s
1190         ;;
1191     aix4.1*)
1192         AC_DEFINE(AIX_TIMERS)
1193         AC_DEFINE(_PR_NO_LARGE_FILES)
1194         AC_DEFINE(AIX4_1)
1195         MKSHLIB=
1196         DSO_LDOPTS=
1197         AIX_LINK_OPTS='-bnso -berok'
1198         LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
1199         LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
1200         ;;
1201     aix4.2*)
1202         AC_DEFINE(AIX_TIMERS)
1203         AC_DEFINE(_PR_HAVE_OFF64_T)
1204         AIX_LINK_OPTS='-brtl -bnso -berok'
1205         ;;
1206     aix4.3*)
1207         AC_DEFINE(AIX_TIMERS)
1208         AC_DEFINE(_PR_HAVE_OFF64_T)
1209         AC_DEFINE(AIX4_3_PLUS)
1210         AC_DEFINE(HAVE_SOCKLEN_T)
1211         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1212         USE_IPV6=1
1213         AIX_LINK_OPTS='-brtl -bnso -berok'
1214         ;;
1215     *)
1216         AC_DEFINE(AIX_TIMERS)
1217         AC_DEFINE(_PR_HAVE_OFF64_T)
1218         AC_DEFINE(AIX4_3_PLUS)
1219         AC_DEFINE(HAVE_SOCKLEN_T)
1220         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1221         USE_IPV6=1
1222         AIX_LINK_OPTS='-brtl -bnso -berok'
1223         ;;
1224     esac
1225     CFLAGS="$CFLAGS -qro -qroconst"
1226     AIX_WRAP='$(DIST)/lib/aixwrap.o'
1227     AIX_TMP='./_aix_tmp.o'
1228     if test -n "$USE_64"; then
1229         MDCPUCFG_H=_aix64.cfg
1230         OBJECT_MODE=64
1231     else
1232         MDCPUCFG_H=_aix32.cfg
1233     fi
1234     PR_MD_CSRCS=aix.c
1235     RESOLVE_LINK_SYMBOLS=1
1236     ;;
1237         
1238 *-bsdi*)
1239     AC_DEFINE(XP_UNIX)
1240     AC_DEFINE(BSDI)
1241     AC_DEFINE(NEED_BSDREGEX)
1243     CFLAGS="$CFLAGS -Wall -Wno-format"
1244     CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
1246     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1247         CPU_ARCH=x86
1248     elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
1249         CPU_ARCH=sparc
1250     fi
1252     MDCPUCFG_H=_bsdi.cfg
1253     PR_MD_CSRCS=bsdi.c
1255     DSO_LDOPTS=-r
1257     case "$target_os" in
1258     bsdi1.1*)
1259         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1260         AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
1261         AC_DEFINE(_PR_NEED_H_ERRNO)
1262         MKSHLIB=
1263         DSO_CFLAGS=
1264         DSO_LDOPTS=
1265         ;;
1267     bsdi2.1*)
1268         AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
1269         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1270         AC_DEFINE(HAVE_DLL)
1271         AC_DEFINE(USE_DLFCN)
1272         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1273         PR_MD_ASFILES=os_BSD_OS_386_2.s
1274         ;;
1276     bsdi4.* | bsdi5.*)
1277         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1278         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1279         AC_DEFINE(HAVE_DLL)
1280         AC_DEFINE(USE_DLFCN)
1281         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1282         MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1283         DSO_CFLAGS=-fPIC
1284         DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
1285         STRIP="$STRIP -d"
1286         case "$target_os" in
1287         bsdi4.2* | bsdi4.3* | bsdi5.*)
1288             AC_DEFINE(_PR_HAVE_GETPROTO_R)
1289             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1290             ;;
1291         esac
1292         ;;
1293     *)
1294         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1295         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1296         AC_DEFINE(HAVE_DLL)
1297         AC_DEFINE(USE_DLFCN)
1298         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1299         ;;
1300     esac
1302     ;;
1304 *-darwin*)
1305     AC_DEFINE(XP_UNIX)
1306     AC_DEFINE(DARWIN)
1307     AC_DEFINE(HAVE_BSD_FLOCK)
1308     AC_DEFINE(HAVE_SOCKLEN_T)
1309     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1310     changequote(,)
1311     HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1312     changequote([,])
1313     if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
1314         AC_DEFINE(HAS_CONNECTX)
1315     fi
1316     AS='$(CC) -x assembler-with-cpp'
1317     CFLAGS="$CFLAGS -Wall -fno-common"
1318     case "${target_cpu}" in
1319         arm*)
1320             CPU_ARCH=arm
1321             ;;
1322         i*86*|x86_64)
1323             if test -n "$USE_64"; then
1324                 CPU_ARCH=x86_64
1325             else        
1326                 CPU_ARCH=i386
1327             fi
1328             ;;
1329         *)
1330             CPU_ARCH=ppc
1331             ;;
1332     esac
1333     if test "`echo $CC | grep -c '\-arch '`" = "0"; then
1334         CC="$CC -arch $CPU_ARCH"
1335     fi
1336     AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
1337     DSO_CFLAGS=-fPIC
1338     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1339     _OPTIMIZE_FLAGS=-O2
1340     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1341     STRIP="$STRIP -x -S"
1342     DLL_SUFFIX=dylib
1343     USE_PTHREADS=1
1344     MDCPUCFG_H=_darwin.cfg
1345     PR_MD_CSRCS=darwin.c
1346     PR_MD_ASFILES=os_Darwin.s
1348     # Add Mac OS X support for loading CFM & CFBundle plugins
1349     if test -f "${MACOS_SDK_DIR}/System/Library/Frameworks/Carbon.framework/Carbon"; then
1350         AC_DEFINE(XP_MACOSX)
1351         OS_TARGET=MacOSX
1353         if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1354             dnl Use the specified value
1355             export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1356         elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1357             dnl No value specified on the command line or in the environment,
1358             dnl use the lesser of the library's minimum or the architecture's
1359             dnl minimum.
1360             case "${target_cpu}" in
1361                 powerpc*)
1362                     dnl Architecture minimum 10.2
1363                     export MACOSX_DEPLOYMENT_TARGET=10.2
1364                     ;;
1365                 i*86*)
1366                     dnl Architecture minimum 10.4
1367                     export MACOSX_DEPLOYMENT_TARGET=10.4
1368                     ;;
1369             esac
1370         fi
1372         dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1373         dnl in use.  NEXT_ROOT will be set and exported if it's needed for
1374         dnl ld.
1376         if test "$MACOS_SDK_DIR"; then
1377             dnl Sync this section with the one in Mozilla's top level.
1379             if test ! -d "$MACOS_SDK_DIR"; then
1380                 AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1381 specify a valid SDK.  SDKs are installed when the optional cross-development
1382 tools are selected during the Xcode/Developer Tools installation.])
1383             fi
1385             changequote(,)
1386             CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1387             GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1388             GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1389             changequote([,])
1390             GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1391             if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1392                 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1393                 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1394                     SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1395                 fi
1397                 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1399                 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1401                 dnl CPP needs to be set for AC_CHECK_HEADER.
1402                 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1404                 changequote(,)
1405                 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1406                 changequote([,])
1407                 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1408                     dnl The build host is running Tiger (10.4) or earlier.
1409                     dnl ld support for -syslibroot is compiler-agnostic, but
1410                     dnl only available on Tiger and later.  On Tiger and
1411                     dnl earlier build hosts, just rely on NEXT_ROOT, because
1412                     dnl it's not been shown to cause any problems.
1413                     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}"
1414                 else
1415                     dnl The build host is running Leopard (10.5) or later.
1416                     dnl With NEXT_ROOT set, the linker will still not apply
1417                     dnl it when resolving dependencies.  This causes problems
1418                     dnl on Leopard, where an SDK depends on frameworks which
1419                     dnl were present in earlier OS releases (and the associated
1420                     dnl SDK) but not in Leopard.  -syslibroot does not have
1421                     dnl this problem, but it results in harmless warnings when
1422                     dnl NEXT_ROOT is set.  NEXT_ROOT needs to remain set even
1423                     dnl on Leopard because the compiler uses it too.
1424                     MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1425                 fi
1427                 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1428                 export NEXT_ROOT=$MACOS_SDK_DIR
1430                 if test -n "$CROSS_COMPILE" ; then
1431                     dnl NEXT_ROOT will be in the environment, but it
1432                     dnl shouldn't be set for the build host.  HOST_CXX is
1433                     dnl presently unused.
1434                     HOST_CC="NEXT_ROOT= $HOST_CC"
1435                     HOST_CXX="NEXT_ROOT= $HOST_CXX"
1436                 fi
1437             else
1438                 dnl gcc >= 4.0 uses different paths than above, but knows
1439                 dnl how to find them itself.
1440                 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1442                 dnl CPP needs to be set for AC_CHECK_HEADER.
1443                 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1445                 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1446                 dnl has an ld that supports -syslibroot.  Don't set
1447                 dnl NEXT_ROOT because it will be ignored and cause
1448                 dnl warnings when -syslibroot is specified.
1449                 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1450                     dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1451                     dnl based on the -isysroot it receives.
1452                     LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1453                 else
1454                     dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1455                     dnl to be explicit.
1456                     LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1457                 fi
1458             fi
1459         fi
1460     fi
1461     ;;
1463 *-freebsd*)
1464     if test -z "$USE_NSPR_THREADS"; then
1465         USE_PTHREADS=1
1466     fi
1467     AC_DEFINE(XP_UNIX)
1468     AC_DEFINE(FREEBSD)
1469     AC_DEFINE(HAVE_BSD_FLOCK)
1470     AC_DEFINE(HAVE_SOCKLEN_T)
1471     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1472     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1473     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1474     if test "$MOZ_OBJFORMAT" = "elf"; then
1475         DLL_SUFFIX=so
1476     else
1477         DLL_SUFFIX=so.1.0
1478     fi
1479     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1480     DSO_CFLAGS=-fPIC
1481     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1482     MDCPUCFG_H=_freebsd.cfg
1483     PR_MD_CSRCS=freebsd.c
1484     ;;
1486 *-hpux*)
1487     AC_DEFINE(XP_UNIX)
1488     AC_DEFINE(HPUX)
1489     AC_DEFINE(_HPUX_SOURCE)
1490     # HPUX report the POLLHUP event for a socket when the
1491     # shutdown(SHUT_WR) operation is called for the remote end, even though
1492     # the socket is still writeable. Use select(), instead of poll(), to
1493     # workaround this problem.
1494     AC_DEFINE(_PR_POLL_WITH_SELECT)
1495     AC_DEFINE(_USE_BIG_FDS)
1496     DSO_LDOPTS='-b +h $(notdir $@)'
1497     PR_MD_CSRCS=hpux.c
1498     if test "$OS_TEST" = "ia64"; then
1499         DLL_SUFFIX=so
1500         DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1501         CPU_ARCH_TAG=_$OS_TEST 
1502         if test -z "$USE_64"; then
1503             COMPILER_TAG=_32
1504         fi
1505         PR_MD_ASFILES=os_HPUX_ia64.s
1506     else
1507         AC_DEFINE(hppa)
1508         DLL_SUFFIX=sl
1509         PR_MD_ASFILES=os_HPUX.s
1510     fi
1511     if test -n "$USE_64"; then
1512         MDCPUCFG_H=_hpux64.cfg
1513     else
1514         MDCPUCFG_H=_hpux32.cfg
1515     fi
1516     if test -z "$GNU_CC"; then
1517         CC="$CC -Ae"
1518         CXX="$CXX -ext"
1519         DSO_CFLAGS=+Z
1520     else
1521         DSO_CFLAGS=-fPIC
1522         ASFLAGS="$ASFLAGS -x assembler-with-cpp"
1523     fi
1525     if test -n "$MOZILLA_CLIENT"; then
1526         DEFAULT_IMPL_STRATEGY=_EMU
1527     fi
1529     if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
1530         AC_DEFINE(_PR_NEED_H_ERRNO)
1531         AC_DEFINE(HPUX9)
1532         DEFAULT_IMPL_STRATEGY=_EMU
1533         USE_NSPR_THREADS=1
1534     fi
1536     if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1537         AC_DEFINE(_PR_NO_LARGE_FILES)
1538     fi
1540     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1541         AC_DEFINE(_PR_NEED_H_ERRNO)
1542     fi
1544     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1545         AC_DEFINE(HAVE_INT_LOCALTIME_R)
1546     fi
1548     if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1549         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1550     fi
1552     # HP-UX 11i v2 (B.11.23) or higher
1553     changequote(<<,>>)
1554     case "$OS_RELEASE" in
1555     [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1556         USE_IPV6=1
1557         ;;
1558     esac
1559     changequote([,])
1561     if test "$OS_RELEASE" = "B.10.01"; then
1562         AC_DEFINE(HPUX10)
1563         DEFAULT_IMPL_STRATEGY=_EMU
1564     fi
1566     if test "$OS_RELEASE" = "B.10.10"; then
1567         AC_DEFINE(HPUX10)
1568         AC_DEFINE(HPUX10_10)
1569         DEFAULT_IMPL_STRATEGY=_PTH
1570     fi
1572     if test "$OS_RELEASE" = "B.10.20"; then
1573         AC_DEFINE(HPUX10)
1574         AC_DEFINE(HPUX10_20)
1575         if test -z "$GNU_CC"; then
1576             CFLAGS="$CFLAGS +DAportable +DS1.1"
1577             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1578         fi
1579         DEFAULT_IMPL_STRATEGY=_PTH
1580     fi
1582     if test "$OS_RELEASE" = "B.10.30"; then
1583         AC_DEFINE(HPUX10)
1584         AC_DEFINE(HPUX10_30)
1585         if test -z "$GNU_CC"; then
1586             CFLAGS="$CFLAGS +DAportable +DS1.1"
1587             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1588         fi
1589         DEFAULT_IMPL_STRATEGY=_PTH
1590     fi
1592     if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1593         AC_DEFINE(HPUX10)
1594         AC_DEFINE(HPUX11)
1595         AC_DEFINE(_LARGEFILE64_SOURCE)
1596         AC_DEFINE(_PR_HAVE_OFF64_T)
1597         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1598         if test -z "$GNU_CC"; then
1599             if test -z "$USE_64"; then
1600                 if test "$OS_TEST" = "ia64"; then
1601                     CFLAGS="$CFLAGS +DD32"
1602                     CXXFLAGS="$CXXFLAGS +DD32"
1603                 else
1604                     CFLAGS="$CFLAGS +DAportable +DS2.0"
1605                     CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1606                 fi
1607             else
1608                 if test "$OS_TEST" = "ia64"; then
1609                     CFLAGS="$CFLAGS +DD64"
1610                     CXXFLAGS="$CXXFLAGS +DD64"
1611                 else
1612                     CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1613                     CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1614                 fi
1615             fi
1616         fi
1617         DEFAULT_IMPL_STRATEGY=_PTH
1618     fi
1620     if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1621         USE_NSPR_THREADS=1
1622         USE_PTHREADS=
1623         USE_USER_PTHREADS=
1624     elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1625         USE_PTHREADS=1
1626         if test "$USE_NSPR_THREADS"; then
1627             USE_PTHREADS=
1628         fi
1629         if test "$USE_USER_PTHREADS"; then
1630             USE_PTHREADS=
1631         fi
1632     fi
1633     ;;
1635 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
1636     if test -z "$USE_NSPR_THREADS"; then
1637         USE_PTHREADS=1
1638         IMPL_STRATEGY=_PTH
1639     fi
1640     AC_DEFINE(XP_UNIX)
1641     AC_DEFINE(_GNU_SOURCE)
1642     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1643     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1644     case "${target}" in
1645     *-android*|*-linuxandroid*)
1646         OS_TARGET=Android
1647         AC_DEFINE(LINUX)
1648         ;;
1649     *-linux*)
1650         AC_DEFINE(LINUX)
1651         ;;
1652     esac
1653     CFLAGS="$CFLAGS -Wall"
1654     CXXFLAGS="$CXXFLAGS -Wall"
1655     MDCPUCFG_H=_linux.cfg
1656     PR_MD_CSRCS=linux.c
1657     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1658     DSO_CFLAGS=-fPIC
1659     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1660     _OPTIMIZE_FLAGS=-O2
1661     _DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb, and that
1662                                    # combo is not yet good at debugging inlined
1663                                    # functions (even when using DWARF2 as the
1664                                    # debugging format)
1665     COMPILER_TAG=_glibc
1666     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1667         CPU_ARCH=x86
1668     else
1669         CPU_ARCH=$OS_TEST
1670     fi
1671     CPU_ARCH_TAG=_${CPU_ARCH}
1672     case "${target_cpu}" in
1673     alpha)
1674         AC_DEFINE(_ALPHA_)
1675         AC_DEFINE(__alpha)
1676         CFLAGS="$CFLAGS -mieee"
1677         CXXFLAGS="$CXXFLAGS -mieee"
1678         ;;
1679     i*86)
1680         AC_DEFINE(i386)
1681         PR_MD_ASFILES=os_Linux_x86.s
1682         ;;
1683     ia64)
1684         PR_MD_ASFILES=os_Linux_ia64.s
1685         ;;
1686     x86_64)
1687         if test -n "$USE_64"; then
1688             PR_MD_ASFILES=os_Linux_x86_64.s
1689         elif test -n "$USE_X32"; then
1690             PR_MD_ASFILES=os_Linux_x86_64.s
1691             CC="$CC -mx32"
1692             CXX="$CXX -mx32"
1693         else
1694             AC_DEFINE(i386)
1695             PR_MD_ASFILES=os_Linux_x86.s
1696             CC="$CC -m32"
1697             CXX="$CXX -m32"
1698         fi
1699         ;;
1700     ppc|powerpc)
1701         PR_MD_ASFILES=os_Linux_ppc.s
1702         ;;
1703     powerpc64)
1704         if test -n "$USE_64"; then
1705             CC="$CC -m64"
1706             CXX="$CXX -m64"
1707         else
1708             PR_MD_ASFILES=os_Linux_ppc.s
1709         fi
1710         ;;
1711     esac    
1712     ;;
1714 *-mingw*|*-msys*|*-cygwin*|*-mks*)
1715     AC_DEFINE(XP_PC)
1716     AC_DEFINE(WIN32)
1717     PR_MD_ARCH_DIR=windows
1718     RESOLVE_LINK_SYMBOLS=1
1720     if test -n "$GNU_CC"; then
1721         CC="$CC -mwindows"
1722         CXX="$CXX -mwindows"
1723         DLL_SUFFIX=dll
1724         MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1725         RC=$WINDRES
1726         # Use temp file for windres (bug 213281)
1727         RCFLAGS='-O coff --use-temp-file'
1728     else
1729         LD=link
1730         AR='lib -NOLOGO -OUT:"$@"'
1731         AR_FLAGS=
1732         RANLIB='echo not_ranlib'
1733         STRIP='echo not_strip'
1734         RC=rc.exe
1735         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1736         OBJ_SUFFIX=obj
1737         LIB_SUFFIX=lib
1738         DLL_SUFFIX=dll
1740         # Determine compiler version
1741         changequote(,)
1742         _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
1743         changequote([,])
1744         CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
1745         if test -z "$CC_VERSION"; then
1746             AC_MSG_ERROR([Could not determine MSC version.])
1747         fi
1749         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
1750         _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
1751         _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
1752         _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
1753         MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
1755         if test "$_CC_MAJOR_VERSION" -eq "14"; then
1756            dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
1757            dnl so be very specific here!
1758            dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
1759            if test $_CC_RELEASE -gt 50727; then
1760               _USE_DYNAMICBASE=1
1761            elif test $_CC_BUILD -ge 762; then
1762               _USE_DYNAMICBASE=1
1763            fi
1764            AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
1765            AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
1766         elif test $_CC_MAJOR_VERSION -ge 15; then
1767            _USE_DYNAMICBASE=1    
1768            AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
1769            AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
1770         fi
1772         if test -n "$_USE_DYNAMICBASE"; then
1773            DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
1774         fi
1776         # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
1777         # tape manipulation utility (or something else)
1778         if test "$MSC_VER" -ge "1400"; then
1779             changequote(,)
1780             _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
1781             changequote([,])
1783             MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
1784             if test -n "$MSMT_TOOL"; then
1785                 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
1786                 if test -z "$MSMANIFEST_TOOL_VERSION"; then
1787                     AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
1788                 fi
1789                 MT=mt
1790                 unset MSMT_TOOL
1791             else
1792                 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
1793             fi
1794         fi
1795         
1796         CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
1797         DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
1798         _DEBUG_FLAGS=-Zi
1799         _OPTIMIZE_FLAGS=-O2
1801         PROFILE_GEN_CFLAGS="-GL"
1802         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
1803         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
1804         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
1806         if test "$MSC_VER" -ge "1800"; then
1807             dnl Visual C++ 2013 requires -FS when parallel building with
1808             dnl make -jN. If not specified, compiler sometimes emits C1041
1809             dnl error.
1810             CFLAGS="$CFLAGS -FS"
1811             dnl -Gw can benefit when using linker optimization on PGO.
1812             dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1813             PROFILE_GEN_CFLAGS="$PROFILE_GEN_CFLAGS -Gw"
1814             PROFILE_USE_CFLAGS="$PROFILE_USE_CFLAGS -Gw"
1815         fi
1817         if test -z "$MOZ_OPTIMIZE"; then
1818             CFLAGS="$CFLAGS -Od"
1819         fi
1821         if test "$USE_DEBUG_RTL" = 1; then
1822             if test -n "$USE_STATIC_RTL"; then
1823                 CFLAGS="$CFLAGS -MTd"
1824             else
1825                 CFLAGS="$CFLAGS -MDd"
1826             fi
1827         else
1828             if test -n "$USE_STATIC_RTL"; then
1829                 CFLAGS="$CFLAGS -MT"
1830             else
1831                 CFLAGS="$CFLAGS -MD"
1832             fi
1833         fi
1835         if test -n "$MOZ_DEBUG"; then
1836             AC_DEFINE(_DEBUG)
1837         else
1838             DEFINES="$DEFINES -U_DEBUG"
1839         fi
1841         if test -n "$MOZ_DEBUG_SYMBOLS"; then
1842             if test -n "$MOZ_OPTIMIZE"; then
1843                 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
1844                 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
1845             else
1846                 DLLFLAGS="$DLLFLAGS -DEBUG"
1847                 LDFLAGS="$LDFLAGS -DEBUG"
1848             fi
1849         fi
1851         OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
1852         if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
1853             OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
1854         fi
1855         
1856         if test "$OS_TARGET" = "WINNT"; then
1857             CFLAGS="$CFLAGS -GT"
1858             LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1859             LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1860         else
1861             LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1862             LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1863         fi
1864     fi # GNU_CC
1866     if test -n "$USE_STATIC_TLS"; then
1867         AC_DEFINE(_PR_USE_STATIC_TLS)
1868     fi
1870     if test "$OS_TARGET" = "WINNT"; then
1871         AC_DEFINE(WINNT)
1872     else
1873         AC_DEFINE(WIN95)
1874         # undefine WINNT as some versions of mingw gcc define it by default
1875         DEFINES="$DEFINES -UWINNT"
1876         AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
1877     fi
1879     if test "$CPU_ARCH" = "x86"; then
1880         CPU_ARCH_TAG=
1881     else
1882         CPU_ARCH_TAG=$CPU_ARCH
1883     fi
1885     if test "$USE_DEBUG_RTL" = 1; then
1886         OBJDIR_SUFFIX=OBJD
1887     fi
1889     case "$OS_TARGET" in
1890     WINNT)
1891             MDCPUCFG_H=_winnt.cfg
1892             ;;
1893     WIN95)
1894             MDCPUCFG_H=_win95.cfg
1895             ;;
1896     *)
1897             AC_MSG_ERROR([Missing OS_TARGET for ${target}.  Use --enable-win32-target to set.])
1898         ;;
1899     esac
1901     case "$target_cpu" in
1902     i*86)
1903         if test -n "$USE_64"; then
1904             AC_DEFINE(_AMD64_)
1905         else            
1906             AC_DEFINE(_X86_)
1907             if test -z "$GNU_CC" -a "$MSC_VER" -ge "1700"; then
1908                 dnl Visual C++ 2012 defaults to -arch:SSE2. Use -arch:IA32
1909                 dnl to avoid requiring SSE2.
1910                 CFLAGS="$CFLAGS -arch:IA32"
1911             fi
1912         fi
1913         ;;
1914     x86_64)
1915             AC_DEFINE(_AMD64_)
1916             USE_64=1
1917             ;;
1918     aarch64)
1919             AC_DEFINE(_ARM64_)
1920             USE_64=1
1921             ;;
1922     ia64)
1923             AC_DEFINE(_IA64_)
1924             USE_64=1
1925             ;;
1926     *)
1927             AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1928             ;;
1929     esac
1930     ;;
1932 *-netbsd*)
1933     AC_DEFINE(XP_UNIX)
1934     AC_DEFINE(NETBSD)
1935     AC_DEFINE(HAVE_BSD_FLOCK)
1936     AC_DEFINE(HAVE_SOCKLEN_T)
1937     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1938     if test -z "$USE_NSPR_THREADS"; then
1939         USE_PTHREADS=1
1940     fi
1941     MDCPUCFG_H=_netbsd.cfg
1942     PR_MD_CSRCS=netbsd.c
1944     DSO_CFLAGS='-fPIC -DPIC'
1945     CFLAGS="$CFLAGS -ansi -Wall"
1946     CXXFLAGS="$CXXFLAGS -ansi -Wall"
1947     MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1949     if test -z "$OBJECT_FMT"; then
1950         if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
1951             OBJECT_FMT=a.out
1952             DLL_SUFFIX=so.1.0
1953             DSO_LDOPTS='-shared'
1954         else
1955             OBJECT_FMT=ELF
1956             DLL_SUFFIX=so
1957             DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
1958         fi
1959     fi
1961     if test "$LIBRUNPATH"; then
1962         DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
1963     fi
1964     ;;
1966 *-nto*)
1967     AC_DEFINE(XP_UNIX)
1968     AC_DEFINE(NTO)
1969     AC_DEFINE(_QNX_SOURCE)
1970     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1971     MDCPUCFG_H=_nto.cfg
1972     PR_MD_CSRCS=nto.c
1973     MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
1974     DSO_CFLAGS=-fPIC
1975     DSO_LDOPTS=-shared
1976     OS_LIBS="$OS_LIBS -lsocket"
1977     _OPTIMIZE_FLAGS="-O1"
1978     _DEBUG_FLAGS="-gstabs"
1979         ;;
1981 *-openbsd*)
1982     AC_DEFINE(XP_UNIX)
1983     AC_DEFINE(OPENBSD)
1984     AC_DEFINE(HAVE_BSD_FLOCK)
1985     AC_DEFINE(HAVE_SOCKLEN_T)
1986     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1987     CFLAGS="$CFLAGS -ansi -Wall"
1988     CXXFLAGS="$CXXFLAGS -ansi -Wall"
1989     DLL_SUFFIX=so.1.0
1990     DSO_CFLAGS=-fPIC
1991     MDCPUCFG_H=_openbsd.cfg
1992     PR_MD_CSRCS=openbsd.c
1993     OS_LIBS="-lc"
1994     if test -z "$USE_NSPR_THREADS"; then
1995         USE_PTHREADS=1
1996     fi
1997     DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
1998     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1999     ;;
2001 *-qnx*)
2002     AC_DEFINE(XP_UNIX)
2003     AC_DEFINE(QNX)
2004     AC_DEFINE(_PR_NEED_H_ERRNO)
2005     USE_NSPR_THREADS=1
2006     MDCPUCFG_H=_qnx.cfg
2007     PR_MD_CSRCS=qnx.c
2008     ;;
2010 *-riscos*)
2011     AC_DEFINE(XP_UNIX)
2012     AC_DEFINE(RISCOS)
2013     AC_DEFINE(_PR_NEED_H_ERRNO)
2014     USE_PTHREADS=1
2015     MDCPUCFG_H=_riscos.cfg
2016     PR_MD_CSRCS=riscos.c
2017     DSO_CFLAGS=-fPIC
2018     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
2019     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2020     ;;
2022 *-*-sco*)
2023     AC_DEFINE(XP_UNIX)
2024     AC_DEFINE(SCO)
2025     AC_DEFINE(sco)
2026     AC_DEFINE(SYSV)
2027     AC_DEFINE(_SVID3)
2028     AC_DEFINE(_PR_NEED_H_ERRNO)
2029     CC='cc -b elf -KPIC'
2030     CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
2031     USE_NSPR_THREADS=1
2032     CPU_ARCH=x86
2033     DSO_LDOPTS='-b elf -G'
2034     MDCPUCFG_H=_scoos.cfg
2035     PR_MD_SRCS=scoos.c
2036     ;;
2038 *-solaris*)
2039     if test -z "$USE_NSPR_THREADS"; then
2040         USE_PTHREADS=1
2041     fi
2042     AC_DEFINE(XP_UNIX)
2043     AC_DEFINE(SVR4)
2044     AC_DEFINE(SYSV)
2045     AC_DEFINE(__svr4)
2046     AC_DEFINE(__svr4__)
2047     AC_DEFINE(SOLARIS)
2048     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2049     CPU_ARCH=`uname -p`
2050     MDCPUCFG_H=_solaris.cfg
2051     PR_MD_CSRCS=solaris.c
2052     LD=/usr/ccs/bin/ld
2053     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2054     RESOLVE_LINK_SYMBOLS=1
2055     case "${OS_RELEASE}" in
2056     5.8|5.9)
2057         ;;
2058     *)
2059         # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
2060         USE_B_DIRECT=1
2061         ;;
2062     esac
2063     if test -n "$GNU_CC"; then
2064         DSO_CFLAGS=-fPIC
2065         if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
2066             GCC_USE_GNU_LD=1
2067         fi
2068         DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore' 
2069         if test -n "$USE_B_DIRECT"; then
2070             DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
2071         fi
2072     else
2073         DSO_CFLAGS=-KPIC
2074         DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
2075         if test -n "$USE_B_DIRECT"; then
2076             DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
2077         fi
2078     fi
2079     if test -n "$GNU_CC"; then
2080         CFLAGS="$CFLAGS -Wall"
2081         CXXFLAGS="$CXXFLAGS -Wall"
2082         if test -n "$USE_MDUPDATE"; then
2083             CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
2084             CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
2085         fi
2086         GCC_AS=`$CC -print-prog-name=as`
2087         if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
2088             GNU_AS=1
2089         fi
2090     else
2091         CFLAGS="$CFLAGS -xstrconst"
2092         CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
2093         if test -z "$MOZ_OPTIMIZE"; then
2094             CFLAGS="$CFLAGS -xs"
2095             CXXFLAGS="$CXXFLAGS -xs"
2096         fi
2097         _OPTIMIZE_FLAGS=-xO4
2098     fi
2099     if test -z "$GNU_AS"; then
2100         ASFLAGS="$ASFLAGS -Wa,-P"
2101     fi
2102     if test -n "$USE_64"; then
2103         if test -n "$GNU_CC"; then
2104             CC="$CC -m64"
2105             CXX="$CXX -m64"
2106         else
2107             if test "$OS_TEST" = "i86pc"; then
2108                 CC="$CC -xarch=amd64"
2109                 CXX="$CXX -xarch=amd64"
2110             else
2111                 CC="$CC -xarch=v9"
2112                 CXX="$CXX -xarch=v9"
2113             fi
2114         fi
2115     fi
2116     if test "$OS_TEST" = "i86pc"; then
2117         if test -z "$USE_64"; then
2118             AC_DEFINE(i386)
2119         fi
2120         CPU_ARCH_TAG=_$OS_TEST
2121         # The default debug format, DWARF (-g), is not supported by gcc
2122         # on i386-ANY-sysv4/solaris, but the stabs format is.  It is
2123         # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2124         # If your gcc uses GNU as, you do not need the -Wa,-s option.
2125         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2126             _DEBUG_FLAGS=-gstabs
2127             if test -z "$GNU_AS"; then
2128                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2129             fi
2130         fi
2131     fi
2132     case "${target_os}" in
2133     solaris2.3*)
2134         AC_DEFINE(_PR_NO_LARGE_FILES)
2135         ;;
2136     solaris2.4*)
2137         AC_DEFINE(_PR_NO_LARGE_FILES)
2138         ;;
2139     solaris2.5*)
2140         AC_DEFINE(SOLARIS2_5)    
2141         ;;
2142     *)
2143         AC_DEFINE(_PR_HAVE_OFF64_T)
2144         # The lfcompile64(5) man page on Solaris 2.6 says:
2145         #     For applications that do not wish to conform to the POSIX or
2146         #     X/Open  specifications,  the  64-bit transitional interfaces
2147         #     are available by default.  No compile-time flags need to  be
2148         #     set.
2149         # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2150         # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2151         if test -n "$GNU_CC"; then
2152             AC_DEFINE(_LARGEFILE64_SOURCE)
2153         fi
2154         ;;
2155     esac
2156     case "${target_os}" in
2157     solaris2.3*)
2158         ;;
2159     solaris2.4*)
2160         ;;
2161     solaris2.5*)
2162         ;;
2163     solaris2.6*)
2164         ;;
2165     solaris2.7*)
2166         ;;
2167     *)
2168         # Solaris 8 or higher has IPv6.
2169         AC_DEFINE(_PR_INET6)
2170         ;;
2171     esac
2172     if test "$CPU_ARCH" = "sparc"; then
2173         # 64-bit Solaris SPARC requires V9 architecture, so the following
2174         # is not needed.
2175         if test -z "$USE_64"; then
2176             ULTRASPARC_LIBRARY=nspr_flt
2177         fi
2178     fi
2179     # Purify requires that binaries linked against nspr also
2180     # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2181     _rev=`uname -r`
2182     _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2183     OS_LIBS="$OS_LIBS $_librt"
2184     ;;
2186 *-sco-sysv5*)
2187     AC_DEFINE(XP_UNIX)
2188     AC_DEFINE(UNIXWARE)
2189     AC_DEFINE(SVR4)
2190     AC_DEFINE(SYSV)
2191     USE_NSPR_THREADS=1
2192     if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
2193         AC_DEFINE(_PR_NO_LARGE_FILES)
2194         CC='$(NSDEPTH)/build/hcc cc'
2195         CXX='$(NSDEPTH)/build/hcpp CC'
2196         MDCPUCFG_H=_unixware.cfg
2197     else
2198         AC_DEFINE(_LARGEFILE64_SOURCE)
2199         AC_DEFINE(_PR_HAVE_OFF64_T)
2200         AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
2201         MDCPUCFG_H=_unixware7.cfg
2202     fi
2203     PR_MD_CSRCS=unixware.c
2204     DSO_LDOPTS=-G
2205     CPU_ARCH=x86
2206     ;;
2208 *-os2*)
2209     AC_DEFINE(XP_OS2)
2210     AC_DEFINE(XP_PC)
2211     AC_DEFINE(BSD_SELECT)
2212     AC_DEFINE(TCPV40HDRS)
2213     LIB_SUFFIX=lib
2214     DLL_SUFFIX=dll
2215     RC=rc.exe
2216     PR_MD_ARCH_DIR=os2
2217     PROG_SUFFIX=.exe
2218     NSINSTALL=nsinstall
2219     MDCPUCFG_H=_os2.cfg
2220     RESOLVE_LINK_SYMBOLS=1
2222     AC_DEFINE(OS2)
2223     AR=emxomfar
2224     AR_FLAGS='r $@'
2225     CFLAGS="$CFLAGS -Wall -Zomf"
2226     CXXFLAGS="$CFLAGS -Wall -Zomf"
2227     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2228     DSO_CFLAGS=
2229     DSO_LDOPTS='-Zomf -Zdll'
2230     LDFLAGS='-Zmap'
2231     _OPTIMIZE_FLAGS="-O2 -s"
2232     _DEBUG_FLAGS="-g -fno-inline"
2233     if test -n "$MOZ_OPTIMIZE"; then
2234       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2235     fi
2236     IMPLIB='emximp -o'
2237     FILTER='emxexp -o'
2238     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2239       LDFLAGS="$LDFLAGS -Zhigh-mem"
2240       AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2241     fi
2243     # GCC for OS/2 currently predefines these, but we don't want them
2244     DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
2245     ;;
2248     AC_DEFINE(XP_UNIX)
2249     ;;
2250    
2251 esac
2253 if test -z "$SKIP_LIBRARY_CHECKS"; then
2254 dnl ========================================================
2255 dnl Check for system libraries
2256 dnl ========================================================
2259 dnl We don't want anything to link with libdl even if it's present on OS X, 
2260 dnl since it's not used and not part of the default installation.
2261 dnl The same goes for BeOS.
2262 dnl OS/2 has dlfcn in libc.
2264 case $target in
2265 *-darwin*|*-os2*)
2266     ;;
2268     AC_CHECK_LIB(dl, dlopen,
2269         [AC_CHECK_HEADER(dlfcn.h,
2270             OS_LIBS="-ldl $OS_LIBS")])
2271     ;;
2272 esac
2275 dnl ========================================================
2276 dnl Check for system header files.
2277 dnl ========================================================
2279 dnl ========================================================
2280 dnl Check for typedefs and structs
2281 dnl ========================================================
2283 dnl ========================================================
2284 dnl Checks for library functions.
2285 dnl ========================================================
2286 AC_PROG_GCC_TRADITIONAL
2287 _SAVE_LIBS="$LIBS"
2288 LIBS="$LIBS $OS_LIBS"
2289 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
2290  secure_getenv __secure_getenv)
2291 LIBS="$_SAVE_LIBS"
2293 dnl ========================================================
2294 dnl Check options
2295 dnl ========================================================
2297 dnl ======================================================
2298 dnl = Enable compiling with ccache
2299 dnl ======================================================
2300 AC_ARG_WITH(ccache,
2301 [  --with-ccache[=path/to/ccache]
2302                           Enable compiling with ccache],
2303     CCACHE=$withval, CCACHE="no")
2305 if test "$CCACHE" != "no"; then
2306     if test -n "$CCACHE"; then
2307         if test "$CCACHE" = "yes"; then
2308             CCACHE=
2309         else
2310             if test ! -e "$CCACHE"; then
2311                 AC_MSG_ERROR([$CCACHE not found])
2312             fi
2313         fi
2314     fi
2315     AC_PATH_PROGS(CCACHE, $CCACHE ccache)
2316     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
2317         AC_MSG_ERROR([ccache not found])
2318     elif test -x "$CCACHE"; then
2319         CC="$CCACHE $CC"
2320         CXX="$CCACHE $CXX"
2321     else
2322         AC_MSG_ERROR([$CCACHE is not executable])
2323     fi
2326 dnl ========================================================
2327 dnl =
2328 dnl = --enable-strip
2329 dnl = 
2330 dnl = Enable stripping of libs and executables
2331 dnl = 
2332 dnl ========================================================
2333 AC_ARG_ENABLE(strip,
2334     [  --enable-strip          Enable stripping of shared libs and programs],
2335     [ if test "$enableval" = "yes"; then
2336             ENABLE_STRIP=1
2337       fi ])
2339 dnl Check for hpux options
2340 case "${target_os}" in
2341 hpux*)
2342 if test -z "$GNU_CC"; then
2344     AC_CACHE_CHECK(for +Olit support,
2345         ac_cv_hpux_usable_olit_option,
2346         dnl since aCC doesn't throw an error on invalid options,
2347         dnl we have to test this the hard way
2348         [ac_cv_hpux_usable_olit_option=no
2349         rm -f conftest*
2350         echo 'int main() { return 0; }' | cat > conftest.c
2351         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2352         if test $? -eq 0; then
2353             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2354                 ac_cv_hpux_usable_olit_option=yes
2355             fi
2356         fi
2357         rm -f conftest*
2358         ])
2360     if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2361         CFLAGS="$CFLAGS +Olit=all"
2362         CXXFLAGS="$CXXFLAGS +Olit=all"
2363     else
2364         CFLAGS="$CFLAGS +ESlit"
2365         CXXFLAGS="$CXXFLAGS +ESlit"
2366     fi
2369 esac
2371 case "$target_os" in
2372 darwin*)
2373     _HAVE_PTHREADS=1
2374     ;;
2376     AC_CHECK_LIB(pthreads, pthread_create,
2377         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2378         AC_CHECK_LIB(pthread, pthread_create,
2379             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2380             AC_CHECK_LIB(c_r, pthread_create,
2381                 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2382                 AC_CHECK_LIB(c, pthread_create,
2383                     _HAVE_PTHREADS=1
2384                 )
2385             )
2386         )
2387     )
2388     ;;
2389 esac
2391 AC_ARG_WITH(pthreads,
2392     [  --with-pthreads         Use system pthreads library as thread subsystem],
2393     [ if test "$withval" = "yes"; then
2394             if test -n "$_HAVE_PTHREADS"; then
2395                     USE_PTHREADS=1 
2396                     USE_USER_PTHREADS=
2397                     USE_NSPR_THREADS=
2398             else
2399                     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2400             fi
2401           else
2402             USE_PTHREADS=
2403             _PTHREAD_LDFLAGS=
2404           fi],
2405         [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2406             USE_PTHREADS=1
2407             USE_USER_PTHREADS=
2408             USE_NSPR_THREADS=
2409           fi])
2411 AC_ARG_ENABLE(user-pthreads,
2412     [  --enable-user-pthreads  Build using userland pthreads],
2413     [ if test "$enableval" = "yes"; then
2414         if test -n "$_HAVE_PTHREADS"; then
2415                     USE_PTHREADS=
2416                     USE_USER_PTHREADS=1
2417                     USE_NSPR_THREADS=
2418             else
2419                     AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2420             fi
2421           fi])
2423 AC_ARG_ENABLE(nspr-threads,
2424     [  --enable-nspr-threads   Build using classic nspr threads],
2425     [ if test "$enableval" = "yes"; then
2426             USE_PTHREADS=
2427             USE_USER_PTHREADS=
2428             USE_NSPR_THREADS=1
2429           fi])
2431 fi # SKIP_LIBRARY_CHECKS
2433 AC_ARG_ENABLE(ipv6,
2434     [  --enable-ipv6           Compile ipv6 support],
2435     [ if test "$enableval" = "yes"; then
2436             USE_IPV6=1
2437       else
2438             USE_IPV6=
2439       fi])
2441 if test -n "$USE_PTHREADS"; then
2442    dnl See if -pthread is supported.
2443    rm -f conftest*
2444    ac_cv_have_dash_pthread=no
2445    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2446    echo 'int main() { return 0; }' | cat > conftest.c
2447    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2448    if test $? -eq 0; then
2449         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2450             ac_cv_have_dash_pthread=yes
2451                 case "$target_os" in
2452             freebsd*)
2453 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2454             ;;
2455             *)
2456             CFLAGS="$CFLAGS -pthread"
2457             CXXFLAGS="$CXXFLAGS -pthread"
2458             ;;
2459         esac
2460         fi
2461     fi
2462     rm -f conftest*
2463     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2465         dnl
2466         dnl See if -pthreads is supported.
2467         dnl
2468     ac_cv_have_dash_pthreads=no
2469     if test "$ac_cv_have_dash_pthread" = "no"; then
2470             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2471         echo 'int main() { return 0; }' | cat > conftest.c
2472             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2473         if test $? -eq 0; then
2474                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2475                             ac_cv_have_dash_pthreads=yes
2476                             CFLAGS="$CFLAGS -pthreads"
2477                             CXXFLAGS="$CXXFLAGS -pthreads"
2478                     fi
2479             fi
2480             rm -f conftest*
2481         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2482     fi
2484     case "$target" in
2485     *-solaris*)
2486         if test "$ac_cv_have_dash_pthreads" = "yes"; then
2487             _PTHREAD_LDFLAGS=
2488         fi
2489             ;;
2490     *-freebsd*)
2491             AC_DEFINE(_REENTRANT)
2492             AC_DEFINE(_THREAD_SAFE)
2493             dnl -pthread links in -lc_r, so don't specify it explicitly.
2494             if test "$ac_cv_have_dash_pthread" = "yes"; then
2495                 _PTHREAD_LDFLAGS="-pthread"
2496             else
2497                 _PTHREAD_LDFLAGS="-lc_r"
2498             fi
2499             ;;
2500     *-netbsd*)
2501             if test "$ac_cv_have_dash_pthread" = "yes"; then
2502                 _PTHREAD_LDFLAGS="-pthread"
2503             fi
2504             ;;
2505     *-bsdi*)
2506             AC_DEFINE(_THREAD_SAFE)
2507             dnl -pthread links in -lc_r, so don't specify it explicitly.
2508             if test "$ac_cv_have_dash_pthread" = "yes"; then
2509                 _PTHREAD_LDFLAGS=
2510             fi
2511             ;;
2512     *-openbsd*)
2513         if test "$ac_cv_have_dash_pthread" = "yes"; then
2514             _PTHREAD_LDFLAGS=-pthread
2515         fi
2516         ;;
2517     *-linux*|*-gnu*|*-k*bsd*-gnu)
2518         AC_DEFINE(_REENTRANT)
2519         ;;
2520     esac
2522 else 
2523     if test -n "$USE_USER_PTHREADS"; then
2524             USE_PTHREADS=
2525             USE_NSPR_THREADS=
2526     else
2527         _PTHREAD_LDFLAGS=
2528     fi
2530 dnl Special thread exceptions
2532 case "$target" in
2533 *-aix*)
2534     if test -n "$USE_NSPR_THREADS"; then
2535         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2536     fi
2537     case "$target_os" in
2538     aix4.1*)
2539         if test -z "$USE_PTHREADS"; then
2540             AC_DEFINE(AIX_RENAME_SELECT)
2541         fi
2542         ;;
2543     aix4.2*)
2544         if test -z "$USE_NSPR_THREADS"; then
2545             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2546         fi
2547         ;;
2548     aix4.3*)
2549         if test -z "$USE_NSPR_THREADS"; then
2550             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2551         fi
2552         if test -n "$USE_PTHREADS"; then
2553             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2554         fi
2555         ;;
2556     *)
2557         if test -z "$USE_NSPR_THREADS"; then
2558             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2559         fi
2560         if test -n "$USE_PTHREADS"; then
2561             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2562         fi
2563         ;;
2564     esac
2565     ;;
2566 *-bsdi*)
2567     if test -n "$USE_PTHREADS"; then
2568         AC_DEFINE(_PR_NEED_PTHREAD_INIT)
2569     fi
2570     ;;
2571 *-freebsd*)
2572     if test -n "$USE_NSPR_THREADS"; then
2573         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2574     fi
2575     ;;
2576 *-hpux*)
2577     if test -n "$USE_NSPR_THREADS"; then
2578         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2579     fi 
2580     if test "$USE_PTHREADS"; then
2581         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2582         AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2583     fi
2584     if test "$USE_USER_PTHREADS"; then
2585         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2586     fi
2587     ;;
2588 *-linux*|*-gnu*|*-k*bsd*-gnu)
2589     if test -n "$USE_NSPR_THREADS"; then
2590         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2591     fi
2592     ;;
2593 *-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*)
2594     dnl win32, os2 cannot use pthreads
2595     USE_PTHREADS=
2596     _PTHREAD_LDFLAGS=
2597     USE_USER_PTHREADS=
2598     ;;
2599 *-netbsd*|*-openbsd*)
2600     if test -n "$USE_NSPR_THREADS"; then
2601         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2602     fi
2603     ;;
2604 *-solaris*)
2605     if test -n "$USE_NSPR_THREADS"; then
2606         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2607     fi
2608     if test -n "$USE_PTHREADS"; then
2609         AC_DEFINE(_REENTRANT)
2610         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2611         if test "$OS_TEST" = "i86pc"; then
2612             if test -n "$USE_64"; then
2613                PR_MD_ASFILES=os_SunOS_x86_64.s
2614             else
2615                PR_MD_ASFILES=os_SunOS_x86.s
2616             fi
2617         else
2618             if test -n "$USE_64"; then
2619                 PR_MD_ASFILES=os_SunOS_sparcv9.s
2620             fi
2621         fi
2622     fi
2623     ;;
2624 *-nto*)
2625     if test -n "$USE_PTHREADS"; then
2626         AC_DEFINE(_PR_HAVE_GETHOST_R)
2627         AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2628     fi
2629     ;;
2630 esac
2632 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2634 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2635 dnl make sure that we use it.
2636 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2637     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2640 if test -n "$_SAVE_DEBUG_FLAGS"; then
2641     _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2644 if test -n "$MOZ_OPTIMIZE"; then
2645     CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2646     CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2649 if test -n "$MOZ_DEBUG_SYMBOLS"; then
2650     CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2651     CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2654 if test -n "$MOZ_OPTIMIZE"; then
2655     OBJDIR_TAG=_OPT
2656 else
2657     OBJDIR_TAG=_DBG
2660 if test -n "$USE_64"; then
2661     COMPILER_TAG=_64
2664 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2666 dnl ========================================================
2667 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2668 dnl ========================================================
2669 case "$target_os" in
2670 cygwin*|mks*)
2671     CC="\$(CYGWIN_WRAPPER) $CC"
2672     CXX="\$(CYGWIN_WRAPPER) $CXX"
2673     RC="\$(CYGWIN_WRAPPER) $RC"
2674     ;;
2675 esac
2677 dnl ========================================================
2678 dnl = Use malloc wrapper lib
2679 dnl ========================================================
2680 AC_ARG_ENABLE(wrap-malloc,
2681 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
2682 [     if test "$enableval" = "yes"; then
2683             _WRAP_MALLOC=1
2684       fi ])
2686 if test -n "$_WRAP_MALLOC"; then
2687     if test -n "$GNU_CC"; then
2688         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
2689         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
2690         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
2691         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
2692     else
2693         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
2694     fi
2697 dnl ========================================================
2698 dnl = Location of malloc wrapper lib
2699 dnl ========================================================
2700 AC_ARG_WITH(wrap-malloc,
2701 [  --with-wrap-malloc=SHAREDLIB  Location of malloc wrapper library],
2702     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
2704 dnl ========================================================
2705 dnl Substitution of found variables.
2706 dnl ========================================================
2707 AC_SUBST(SHELL_OVERRIDE)
2709 AC_SUBST(MOZILLA_CLIENT)
2710 AC_SUBST(CC)
2711 AC_SUBST(CXX)
2712 AC_SUBST(CFLAGS)
2713 AC_SUBST(CXXFLAGS)
2714 AC_SUBST(CPPFLAGS)
2715 AC_SUBST(HOST_CC)
2716 AC_SUBST(HOST_CFLAGS)
2717 AC_SUBST(LDFLAGS)
2718 AC_SUBST(HOST_LDFLAGS)
2719 AC_SUBST(GNU_CC)
2720 AC_SUBST(GCC_USE_GNU_LD)
2721 AC_SUBST(MSC_VER)
2722 AC_SUBST(CROSS_COMPILE)
2724 AC_SUBST(MOZ_OPTIMIZE)
2725 AC_SUBST(MOZ_DEBUG)
2726 AC_SUBST(MOZ_DEBUG_SYMBOLS)
2728 AC_SUBST(USE_CPLUS)
2729 AC_SUBST(USE_IPV6)
2730 AC_SUBST(USE_N32)
2731 AC_SUBST(USE_X32)
2732 AC_SUBST(USE_64)
2733 AC_SUBST(OBJECT_MODE)
2734 AC_SUBST(ENABLE_STRIP)
2736 AC_SUBST(USE_PTHREADS)
2737 AC_SUBST(USE_BTHREADS)
2738 AC_SUBST(USE_USER_PTHREADS)
2739 AC_SUBST(USE_NSPR_THREADS)
2741 AC_SUBST(LIBNSPR)
2742 AC_SUBST(LIBPLC)
2744 AC_SUBST(MOD_MAJOR_VERSION)
2745 AC_SUBST(MOD_MINOR_VERSION)
2746 AC_SUBST(MOD_PATCH_VERSION)
2747 AC_SUBST(NSPR_MODNAME)
2748 AC_SUBST(MDCPUCFG_H)
2749 AC_SUBST(PR_MD_CSRCS)
2750 AC_SUBST(PR_MD_ASFILES)
2751 AC_SUBST(PR_MD_ARCH_DIR)
2752 AC_SUBST(CPU_ARCH)
2754 AC_SUBST(OBJ_SUFFIX)
2755 AC_SUBST(LIB_SUFFIX)
2756 AC_SUBST(DLL_SUFFIX)
2757 AC_SUBST(ASM_SUFFIX)
2758 AC_SUBST(WRAP_LDFLAGS)
2759 AC_SUBST(MKSHLIB)
2760 AC_SUBST(DSO_CFLAGS)
2761 AC_SUBST(DSO_LDOPTS)
2763 AC_SUBST(OS_TARGET)
2764 AC_SUBST(OS_ARCH)
2765 AC_SUBST(OS_RELEASE)
2766 AC_SUBST(OS_TEST)
2767 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
2769 AC_SUBST(DEFINES)
2770 AC_SUBST(DEFS)
2771 AC_SUBST(AR)
2772 AC_SUBST(AR_FLAGS)
2773 AC_SUBST(AS)
2774 AC_SUBST(ASFLAGS)
2775 AC_SUBST(LD)
2776 AC_SUBST(RANLIB)
2777 AC_SUBST(PERL)
2778 AC_SUBST(STRIP)
2779 AC_SUBST(FILTER)
2780 AC_SUBST(IMPLIB)
2782 AC_SUBST(PROFILE_GEN_CFLAGS)
2783 AC_SUBST(PROFILE_GEN_LDFLAGS)
2784 AC_SUBST(PROFILE_USE_CFLAGS)
2785 AC_SUBST(PROFILE_USE_LDFLAGS)
2787 AC_SUBST(OS_LIBS)
2788 AC_SUBST(RESOLVE_LINK_SYMBOLS)
2789 AC_SUBST(AIX_LINK_OPTS)
2790 AC_SUBST(NOSUCHFILE)
2791 AC_SUBST(MOZ_OBJFORMAT)
2792 AC_SUBST(ULTRASPARC_LIBRARY)
2794 AC_SUBST(OBJDIR)
2795 AC_SUBST(OBJDIR_NAME)
2796 AC_SUBST(RELEASE_OBJDIR_NAME)
2797 AC_SUBST(NSINSTALL)
2798 AC_SUBST(OPTIMIZER)
2799 AC_SUBST(RC)
2800 AC_SUBST(RCFLAGS)
2801 AC_SUBST(DLLFLAGS)
2802 AC_SUBST(EXEFLAGS)
2803 AC_SUBST(OS_DLLFLAGS)
2804 AC_SUBST(CYGWIN_WRAPPER)
2805 AC_SUBST(VISIBILITY_FLAGS)
2806 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2807 AC_SUBST(MACOS_SDK_DIR)
2808 AC_SUBST(NEXT_ROOT)
2809 AC_SUBST(MT)
2811 dnl ========================================================
2812 dnl Generate output files.
2813 dnl ========================================================
2814 MAKEFILES="
2815     Makefile
2816     config/Makefile
2817     config/autoconf.mk
2818     config/nsprincl.mk
2819     config/nsprincl.sh
2820     config/nspr-config
2821     config/nspr.pc
2822     lib/Makefile
2823     lib/ds/Makefile
2824     lib/libc/Makefile
2825     lib/libc/include/Makefile
2826     lib/libc/src/Makefile
2827     lib/tests/Makefile
2828     pkg/Makefile
2829     pr/Makefile
2830     pr/include/Makefile
2831     pr/include/md/Makefile
2832     pr/include/obsolete/Makefile
2833     pr/include/private/Makefile
2834     pr/src/Makefile
2835     pr/src/io/Makefile
2836     pr/src/linking/Makefile
2837     pr/src/malloc/Makefile
2838     pr/src/md/Makefile
2839     pr/src/md/${PR_MD_ARCH_DIR}/Makefile
2840     pr/src/memory/Makefile
2841     pr/src/misc/Makefile
2842     pr/src/threads/Makefile
2843     pr/tests/Makefile
2844     pr/tests/dll/Makefile
2847 if test "$OS_TARGET" = "Linux"; then
2848     MAKEFILES="$MAKEFILES
2849         pkg/linux/Makefile
2850     "
2851 elif test "$OS_TARGET" = "SunOS"; then
2852     MAKEFILES="$MAKEFILES
2853         pkg/solaris/Makefile
2854         pkg/solaris/SUNWpr/Makefile
2855         pkg/solaris/SUNWprd/Makefile
2856     "
2859 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
2860     MAKEFILES="$MAKEFILES
2861         pr/src/threads/combined/Makefile
2862     "
2863 elif test -n "$USE_PTHREADS"; then
2864     MAKEFILES="$MAKEFILES
2865         pr/src/pthreads/Makefile
2866     "
2867 elif test -n "$USE_BTHREADS"; then
2868     MAKEFILES="$MAKEFILES
2869         pr/src/bthreads/Makefile
2870     "
2873 if test -n "$USE_CPLUS"; then
2874     MAKEFILES="$MAKEFILES
2875         pr/src/cplus/Makefile
2876         pr/src/cplus/tests/Makefile
2877     "
2880 echo $MAKEFILES > unallmakefiles
2882 AC_CONFIG_FILES([$MAKEFILES])
2883 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])
2884 AC_OUTPUT