Bug 1835466 - Update wpt metadata, a=testonly
[gecko.git] / nsprpub / configure.in
blob7d4446689a828d8759ca2f7b087b061f57e64d9f
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(build/autoconf)
12 AC_CANONICAL_TARGET
14 dnl ========================================================
15 dnl = Defaults
16 dnl ========================================================
17 MOD_MAJOR_VERSION=4
18 MOD_MINOR_VERSION=35
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.3 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         cygwin*)      OS_ARCH=WINNT ;;
825         darwin*)      OS_ARCH=Darwin ;;
826         riscos*)      OS_ARCH=RISCOS ;;
827     esac
828 else
829     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
830     OS_RELEASE=`uname -r`
831     OS_TEST=`uname -m`
834 if test "$OS_ARCH" = "AIX"; then
835     OS_RELEASE=`uname -v`.`uname -r`
838 if test "$OS_ARCH" = "FreeBSD"; then
839     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
842 if test "$OS_ARCH" = "Linux"; then
843     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
844     OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
847 #######################################################################
848 # Master "Core Components" macros for getting the OS target           #
849 #######################################################################
852 # Note: OS_TARGET should be specified on the command line for gmake.
853 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
854 # The difference between the Win95 target and the WinNT target is that
855 # the WinNT target uses Windows NT specific features not available
856 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
857 # at lesser performance (the Win95 target uses threads; the WinNT target
858 # uses fibers).
860 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
861 # cross-compilation.
865 # The following hack allows one to build on a WIN95 machine (as if
866 # s/he were cross-compiling on a WINNT host for a WIN95 target).
867 # It also accomodates for MKS's uname.exe.  If you never intend
868 # to do development on a WIN95 machine, you don't need this hack.
870 case "$OS_ARCH" in
871 Windows_95)
872     OS_ARCH=Windows_NT
873     OS_TARGET=WIN95
874     ;;
875 Windows_98)
876     OS_ARCH=Windows_NT
877     OS_TARGET=WIN95
878     ;;
879 CYGWIN_9*|CYGWIN_ME*)
880     OS_ARCH='CYGWIN_NT-4.0'
881     OS_TARGET=WIN95
882     ;;
883 OS_2)
884     OS_ARCH=OS2
885     OS_TARGET=OS2
886     ;;
887 esac
890 # On WIN32, we also define the variable CPU_ARCH.
893 case "$OS_ARCH" in
894 Windows_NT)
896 # If uname -s returns "Windows_NT", we assume that we are using
897 # the uname.exe in MKS toolkit.
899 # The -r option of MKS uname only returns the major version number.
900 # So we need to use its -v option to get the minor version number.
901 # Moreover, it doesn't have the -p option, so we need to use uname -m.
903     OS_ARCH=WINNT
904     OS_MINOR_RELEASE=`uname -v`
905     if test "$OS_MINOR_RELEASE" = "00"; then
906         OS_MINOR_RELEASE=0
907     fi
908     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
909     CPU_ARCH=`uname -m`
910     #
911     # MKS's uname -m returns "586" on a Pentium machine.
912     #
913     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
914         CPU_ARCH=x86
915     fi
916     ;;
917 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
919 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
920 # the uname.exe in the Cygwin tools.
921 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
922 # the uname.exe in the MSYS tools.
923 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
924 # the uname.exe in the MSYS2 tools.
926     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
927     OS_ARCH=WINNT
928     CPU_ARCH=`uname -m`
929     #
930     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
931     #
932     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
933         CPU_ARCH=x86
934     fi
935     ;;
936 esac
938 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
939     OS_TARGET=WIN95
940     if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
941         USE_DEBUG_RTL=1
942     fi
944 if test -z "$OS_TARGET"; then
945     OS_TARGET=$OS_ARCH
947 if test "$OS_TARGET" = "WIN95"; then
948     OS_RELEASE="4.0"
950 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
952 dnl ========================================================
953 dnl Enable high-memory support on OS/2 by default.
954 dnl ========================================================
955 AC_ARG_ENABLE(os2-high-mem,
956     [  --disable-os2-high-mem  Disable high-memory support on OS/2],
957     [ if test "$enableval" = "no"; then
958         MOZ_OS2_HIGH_MEMORY=
959       else
960         MOZ_OS2_HIGH_MEMORY=1
961       fi ])
963 dnl ========================================================
964 dnl = ARM toolchain tweaks
965 dnl ========================================================
967 dnl Defaults
968 MOZ_ALIGN=toolchain-default
970 case "$target" in
971 arm*-android*|arm*-linuxandroid*)
972     MOZ_THUMB=yes
973     MOZ_ARCH=armv7-a
974     MOZ_FPU=vfp
975     MOZ_FLOAT_ABI=softfp
976     MOZ_SOFT_FLOAT=yes
977     MOZ_ALIGN=no
978     ;;
979 arm*-*)
980     if test -n "$MOZ_PLATFORM_MAEMO"; then
981         MOZ_THUMB=no
982         MOZ_ARCH=armv7-a
983         MOZ_FLOAT_ABI=softfp
984     fi
985     if test "$MOZ_PLATFORM_MAEMO" = 6; then
986         MOZ_THUMB=yes
987     fi
988     ;;
989 esac
991 dnl Kept for compatibility with some buildbot mozconfig
992 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
994 AC_ARG_WITH(thumb,
995 [  --with-thumb[[=yes|no|toolchain-default]]]
996 [                          Use Thumb instruction set (-mthumb)],
997     if test -z "$GNU_CC"; then
998         AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
999     fi
1000     MOZ_THUMB=$withval)
1002 AC_ARG_WITH(thumb-interwork,
1003 [  --with-thumb-interwork[[=yes|no|toolchain-default]]
1004                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
1005     if test -z "$GNU_CC"; then
1006         AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
1007     fi
1008     MOZ_THUMB_INTERWORK=$withval)
1010 AC_ARG_WITH(arch,
1011 [  --with-arch=[[type|toolchain-default]]
1012                            Use specific CPU features (-march=type)],
1013     if test -z "$GNU_CC"; then
1014         AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
1015     fi
1016     MOZ_ARCH=$withval)
1018 AC_ARG_WITH(fpu,
1019 [  --with-fpu=[[type|toolchain-default]]
1020                            Use specific FPU type (-mfpu=type)],
1021     if test -z "$GNU_CC"; then
1022         AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
1023     fi
1024     MOZ_FPU=$withval)
1026 AC_ARG_WITH(float-abi,
1027 [  --with-float-abi=[[type|toolchain-default]]
1028                            Use specific arm float ABI (-mfloat-abi=type)],
1029     if test -z "$GNU_CC"; then
1030         AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
1031     fi
1032     MOZ_FLOAT_ABI=$withval)
1034 AC_ARG_WITH(soft-float,
1035 [  --with-soft-float[[=yes|no|toolchain-default]]
1036                            Use soft float library (-msoft-float)],
1037     if test -z "$GNU_CC"; then
1038         AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
1039     fi
1040     MOZ_SOFT_FLOAT=$withval)
1042 case "$MOZ_ARCH" in
1043 toolchain-default|"")
1044     arch_flag=""
1045     ;;
1047     arch_flag="-march=$MOZ_ARCH"
1048     ;;
1049 esac
1051 case "$MOZ_THUMB" in
1052 yes)
1053     MOZ_THUMB2=1
1054     thumb_flag="-mthumb"
1055     ;;
1057     MOZ_THUMB2=
1058     thumb_flag="-marm"
1059     ;;
1061     _SAVE_CFLAGS="$CFLAGS"
1062     CFLAGS="$arch_flag"
1063     AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1064         MOZ_THUMB2=1,
1065         MOZ_THUMB2=)
1066     CFLAGS="$_SAVE_CFLAGS"
1067     thumb_flag=""
1068     ;;
1069 esac
1071 case "$MOZ_THUMB_INTERWORK" in
1072 yes)
1073     thumb_interwork_flag="-mthumb-interwork"
1074     ;;
1076     thumb_interwork_flag="-mno-thumb-interwork"
1077     ;;
1078 *) # toolchain-default
1079     thumb_interwork_flag=""
1080     ;;
1081 esac
1083 case "$MOZ_FPU" in
1084 toolchain-default|"")
1085     fpu_flag=""
1086     ;;
1088     fpu_flag="-mfpu=$MOZ_FPU"
1089     ;;
1090 esac
1092 case "$MOZ_FLOAT_ABI" in
1093 toolchain-default|"")
1094     float_abi_flag=""
1095     ;;
1097     float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1098     ;;
1099 esac
1101 case "$MOZ_SOFT_FLOAT" in
1102 yes)
1103     soft_float_flag="-msoft-float"
1104     ;;
1106     soft_float_flag="-mno-soft-float"
1107     ;;
1108 *) # toolchain-default
1109     soft_float_flag=""
1110     ;;
1111 esac
1113 case "$MOZ_ALIGN" in
1114 toolchain-default|"")
1115     align_flag=""
1116     ;;
1118     align_flag="-mno-unaligned-access"
1119     ;;
1120 yes)
1121     align_flag="-munaligned-access"
1122     ;;
1124     align_flag=""
1125     ;;
1126 esac
1128 if test -n "$align_flag"; then
1129   _SAVE_CFLAGS="$CFLAGS"
1130   CFLAGS="$CFLAGS $align_flag"
1131   AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
1132   AC_TRY_COMPILE([],[],,align_flag="")
1133   CFLAGS="$_SAVE_CFLAGS"
1136 dnl Use echo to avoid accumulating space characters
1137 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
1138 if test -n "$all_flags"; then
1139     _SAVE_CFLAGS="$CFLAGS"
1140     CFLAGS="$all_flags"
1141     AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1142     AC_TRY_COMPILE([],[return 0;],
1143         AC_MSG_RESULT([yes]),
1144         AC_MSG_ERROR([no]))
1146     CFLAGS="$_SAVE_CFLAGS $all_flags"
1147     CXXFLAGS="$CXXFLAGS $all_flags"
1148     ASFLAGS="$ASFLAGS $all_flags"
1149     if test -n "$thumb_flag"; then
1150         LDFLAGS="$LDFLAGS $thumb_flag"
1151     fi
1154 dnl ========================================================
1155 dnl Override of system specific host options
1156 dnl ========================================================
1157 case "$host" in
1158 *-mingw*|*-msys*)
1159     NSINSTALL=nsinstall
1160     ;;
1161 *-cygwin*|*-mks*)
1162     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
1163     if test `echo "${PATH}" | grep -c \;` = 0; then
1164         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
1165     fi
1166     ;;
1167 *os2*)
1168     ;;
1170     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1171     ;;
1172 esac
1174 dnl ========================================================
1175 dnl Override of system specific target options
1176 dnl ========================================================
1177 case "$target" in
1179 *-aix*)
1180     AC_DEFINE(XP_UNIX)
1181     AC_DEFINE(AIX)
1182     AC_DEFINE(SYSV)
1183     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
1184     AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
1185     case "${target_os}" in
1186     aix3.2*)
1187         AC_DEFINE(AIX_RENAME_SELECT)
1188         AC_DEFINE(_PR_NO_LARGE_FILES)
1189         AIX_LINK_OPTS='-bnso -berok'
1190         PR_MD_ASFILES=os_AIX.s
1191         ;;
1192     aix4.1*)
1193         AC_DEFINE(AIX_TIMERS)
1194         AC_DEFINE(_PR_NO_LARGE_FILES)
1195         AC_DEFINE(AIX4_1)
1196         MKSHLIB=
1197         DSO_LDOPTS=
1198         AIX_LINK_OPTS='-bnso -berok'
1199         LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
1200         LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
1201         ;;
1202     aix4.2*)
1203         AC_DEFINE(AIX_TIMERS)
1204         AC_DEFINE(_PR_HAVE_OFF64_T)
1205         AIX_LINK_OPTS='-brtl -bnso -berok'
1206         ;;
1207     aix4.3*)
1208         AC_DEFINE(AIX_TIMERS)
1209         AC_DEFINE(_PR_HAVE_OFF64_T)
1210         AC_DEFINE(AIX4_3_PLUS)
1211         AC_DEFINE(HAVE_SOCKLEN_T)
1212         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1213         USE_IPV6=1
1214         AIX_LINK_OPTS='-brtl -bnso -berok'
1215         ;;
1216     *)
1217         AC_DEFINE(AIX_TIMERS)
1218         AC_DEFINE(_PR_HAVE_OFF64_T)
1219         AC_DEFINE(AIX4_3_PLUS)
1220         AC_DEFINE(HAVE_SOCKLEN_T)
1221         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1222         USE_IPV6=1
1223         AIX_LINK_OPTS='-brtl -bnso -berok'
1224         ;;
1225     esac
1226     CFLAGS="$CFLAGS -qro -qroconst"
1227     AIX_WRAP='$(DIST)/lib/aixwrap.o'
1228     AIX_TMP='./_aix_tmp.o'
1229     if test -n "$USE_64"; then
1230         MDCPUCFG_H=_aix64.cfg
1231         OBJECT_MODE=64
1232     else
1233         MDCPUCFG_H=_aix32.cfg
1234     fi
1235     PR_MD_CSRCS=aix.c
1236     RESOLVE_LINK_SYMBOLS=1
1237     ;;
1238         
1239 *-bsdi*)
1240     AC_DEFINE(XP_UNIX)
1241     AC_DEFINE(BSDI)
1242     AC_DEFINE(NEED_BSDREGEX)
1244     CFLAGS="$CFLAGS -Wall -Wno-format"
1245     CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
1247     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1248         CPU_ARCH=x86
1249     elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
1250         CPU_ARCH=sparc
1251     fi
1253     MDCPUCFG_H=_bsdi.cfg
1254     PR_MD_CSRCS=bsdi.c
1256     DSO_LDOPTS=-r
1258     case "$target_os" in
1259     bsdi1.1*)
1260         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1261         AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
1262         AC_DEFINE(_PR_NEED_H_ERRNO)
1263         MKSHLIB=
1264         DSO_CFLAGS=
1265         DSO_LDOPTS=
1266         ;;
1268     bsdi2.1*)
1269         AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
1270         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1271         AC_DEFINE(HAVE_DLL)
1272         AC_DEFINE(USE_DLFCN)
1273         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1274         PR_MD_ASFILES=os_BSD_OS_386_2.s
1275         ;;
1277     bsdi4.* | bsdi5.*)
1278         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1279         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1280         AC_DEFINE(HAVE_DLL)
1281         AC_DEFINE(USE_DLFCN)
1282         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1283         MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1284         DSO_CFLAGS=-fPIC
1285         DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
1286         STRIP="$STRIP -d"
1287         case "$target_os" in
1288         bsdi4.2* | bsdi4.3* | bsdi5.*)
1289             AC_DEFINE(_PR_HAVE_GETPROTO_R)
1290             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1291             ;;
1292         esac
1293         ;;
1294     *)
1295         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1296         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1297         AC_DEFINE(HAVE_DLL)
1298         AC_DEFINE(USE_DLFCN)
1299         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1300         ;;
1301     esac
1303     ;;
1305 *-darwin*)
1306     AC_DEFINE(XP_UNIX)
1307     AC_DEFINE(DARWIN)
1308     AC_DEFINE(HAVE_BSD_FLOCK)
1309     AC_DEFINE(HAVE_SOCKLEN_T)
1310     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1311     changequote(,)
1312     HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1313     changequote([,])
1314     if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
1315         AC_DEFINE(HAS_CONNECTX)
1316     fi
1317     AS='$(CC) -x assembler-with-cpp'
1318     CFLAGS="$CFLAGS -Wall -fno-common"
1319     case "${target_cpu}" in
1320         arm*)
1321             CPU_ARCH=arm
1322             ;;
1323         i*86*|x86_64)
1324             if test -n "$USE_64"; then
1325                 CPU_ARCH=x86_64
1326             else        
1327                 CPU_ARCH=i386
1328             fi
1329             ;;
1330         aarch64)
1331             CPU_ARCH=aarch64
1332             ;;
1333         *)
1334             CPU_ARCH=ppc
1335             ;;
1336     esac
1337     if test "`echo $CC | grep -c '\-arch '`" = "0"; then
1338         case "$CPU_ARCH" in
1339         aarch64)
1340             CC="$CC -arch arm64"
1341             ;;
1342         *)
1343             CC="$CC -arch $CPU_ARCH"
1344             ;;
1345         esac
1346     fi
1347     AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
1348     DSO_CFLAGS=-fPIC
1349     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1350     _OPTIMIZE_FLAGS=-O2
1351     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1352     STRIP="$STRIP -x -S"
1353     DLL_SUFFIX=dylib
1354     USE_PTHREADS=1
1355     MDCPUCFG_H=_darwin.cfg
1356     PR_MD_CSRCS=darwin.c
1357     PR_MD_ASFILES=os_Darwin.s
1359     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1360         dnl Use the specified value
1361         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1362     elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1363         dnl No value specified on the command line or in the environment,
1364         dnl use the lesser of the library's minimum or the architecture's
1365         dnl minimum.
1366         case "${target_cpu}" in
1367             powerpc*)
1368                 dnl Architecture minimum 10.3
1369                 export MACOSX_DEPLOYMENT_TARGET=10.3
1370                 ;;
1371             i*86*)
1372                 dnl Architecture minimum 10.4
1373                 export MACOSX_DEPLOYMENT_TARGET=10.4
1374                 ;;
1375         esac
1376     fi
1378     dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1379     dnl in use.  NEXT_ROOT will be set and exported if it's needed for
1380     dnl ld.
1382     if test "$MACOS_SDK_DIR"; then
1383         dnl Sync this section with the one in Mozilla's top level.
1385         if test ! -d "$MACOS_SDK_DIR"; then
1386             AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1387 specify a valid SDK.  SDKs are installed when the optional cross-development
1388 tools are selected during the Xcode/Developer Tools installation.])
1389         fi
1391         changequote(,)
1392         CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1393         GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1394         GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1395         changequote([,])
1396         GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1397         if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1398             SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1399             if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1400                 SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1401             fi
1403             SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1405             CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1407             dnl CPP needs to be set for AC_CHECK_HEADER.
1408             CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1410             changequote(,)
1411             HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1412             changequote([,])
1413             if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1414                 dnl The build host is running Tiger (10.4) or earlier.
1415                 dnl ld support for -syslibroot is compiler-agnostic, but
1416                 dnl only available on Tiger and later.  On Tiger and
1417                 dnl earlier build hosts, just rely on NEXT_ROOT, because
1418                 dnl it's not been shown to cause any problems.
1419                 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}"
1420             else
1421                 dnl The build host is running Leopard (10.5) or later.
1422                 dnl With NEXT_ROOT set, the linker will still not apply
1423                 dnl it when resolving dependencies.  This causes problems
1424                 dnl on Leopard, where an SDK depends on frameworks which
1425                 dnl were present in earlier OS releases (and the associated
1426                 dnl SDK) but not in Leopard.  -syslibroot does not have
1427                 dnl this problem, but it results in harmless warnings when
1428                 dnl NEXT_ROOT is set.  NEXT_ROOT needs to remain set even
1429                 dnl on Leopard because the compiler uses it too.
1430                 MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1431             fi
1433             LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1434             export NEXT_ROOT=$MACOS_SDK_DIR
1436             if test -n "$CROSS_COMPILE" ; then
1437                 dnl NEXT_ROOT will be in the environment, but it
1438                 dnl shouldn't be set for the build host.  HOST_CXX is
1439                 dnl presently unused.
1440                 HOST_CC="NEXT_ROOT= $HOST_CC"
1441                 HOST_CXX="NEXT_ROOT= $HOST_CXX"
1442             fi
1443         else
1444             dnl gcc >= 4.0 uses different paths than above, but knows
1445             dnl how to find them itself.
1446             CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1448             dnl CPP needs to be set for AC_CHECK_HEADER.
1449             CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1451             dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1452             dnl has an ld that supports -syslibroot.  Don't set
1453             dnl NEXT_ROOT because it will be ignored and cause
1454             dnl warnings when -syslibroot is specified.
1455             if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1456                 dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1457                 dnl based on the -isysroot it receives.
1458                 LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1459             else
1460                 dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1461                 dnl to be explicit.
1462                 LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1463             fi
1464         fi
1465     fi
1466     ;;
1468 *-freebsd*)
1469     if test -z "$USE_NSPR_THREADS"; then
1470         USE_PTHREADS=1
1471     fi
1472     AC_DEFINE(XP_UNIX)
1473     AC_DEFINE(FREEBSD)
1474     AC_DEFINE(HAVE_BSD_FLOCK)
1475     AC_DEFINE(HAVE_SOCKLEN_T)
1476     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1477     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1478     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1479     if test "$MOZ_OBJFORMAT" = "elf"; then
1480         DLL_SUFFIX=so
1481     else
1482         DLL_SUFFIX=so.1.0
1483     fi
1484     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1485     DSO_CFLAGS=-fPIC
1486     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1487     MDCPUCFG_H=_freebsd.cfg
1488     PR_MD_CSRCS=freebsd.c
1489     ;;
1491 *-hpux*)
1492     AC_DEFINE(XP_UNIX)
1493     AC_DEFINE(HPUX)
1494     AC_DEFINE(_HPUX_SOURCE)
1495     # HPUX report the POLLHUP event for a socket when the
1496     # shutdown(SHUT_WR) operation is called for the remote end, even though
1497     # the socket is still writeable. Use select(), instead of poll(), to
1498     # workaround this problem.
1499     AC_DEFINE(_PR_POLL_WITH_SELECT)
1500     AC_DEFINE(_USE_BIG_FDS)
1501     DSO_LDOPTS='-b +h $(notdir $@)'
1502     PR_MD_CSRCS=hpux.c
1503     if test "$OS_TEST" = "ia64"; then
1504         DLL_SUFFIX=so
1505         DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1506         CPU_ARCH_TAG=_$OS_TEST 
1507         if test -z "$USE_64"; then
1508             COMPILER_TAG=_32
1509         fi
1510         PR_MD_ASFILES=os_HPUX_ia64.s
1511     else
1512         AC_DEFINE(hppa)
1513         DLL_SUFFIX=sl
1514         PR_MD_ASFILES=os_HPUX.s
1515     fi
1516     if test -n "$USE_64"; then
1517         MDCPUCFG_H=_hpux64.cfg
1518     else
1519         MDCPUCFG_H=_hpux32.cfg
1520     fi
1521     if test -z "$GNU_CC"; then
1522         CC="$CC -Ae"
1523         CXX="$CXX -ext"
1524         DSO_CFLAGS=+Z
1525     else
1526         DSO_CFLAGS=-fPIC
1527         ASFLAGS="$ASFLAGS -x assembler-with-cpp"
1528     fi
1530     if test -n "$MOZILLA_CLIENT"; then
1531         DEFAULT_IMPL_STRATEGY=_EMU
1532     fi
1534     if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
1535         AC_DEFINE(_PR_NEED_H_ERRNO)
1536         AC_DEFINE(HPUX9)
1537         DEFAULT_IMPL_STRATEGY=_EMU
1538         USE_NSPR_THREADS=1
1539     fi
1541     if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1542         AC_DEFINE(_PR_NO_LARGE_FILES)
1543     fi
1545     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1546         AC_DEFINE(_PR_NEED_H_ERRNO)
1547     fi
1549     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1550         AC_DEFINE(HAVE_INT_LOCALTIME_R)
1551     fi
1553     if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1554         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1555     fi
1557     # HP-UX 11i v2 (B.11.23) or higher
1558     changequote(<<,>>)
1559     case "$OS_RELEASE" in
1560     [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1561         USE_IPV6=1
1562         ;;
1563     esac
1564     changequote([,])
1566     if test "$OS_RELEASE" = "B.10.01"; then
1567         AC_DEFINE(HPUX10)
1568         DEFAULT_IMPL_STRATEGY=_EMU
1569     fi
1571     if test "$OS_RELEASE" = "B.10.10"; then
1572         AC_DEFINE(HPUX10)
1573         AC_DEFINE(HPUX10_10)
1574         DEFAULT_IMPL_STRATEGY=_PTH
1575     fi
1577     if test "$OS_RELEASE" = "B.10.20"; then
1578         AC_DEFINE(HPUX10)
1579         AC_DEFINE(HPUX10_20)
1580         if test -z "$GNU_CC"; then
1581             CFLAGS="$CFLAGS +DAportable +DS1.1"
1582             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1583         fi
1584         DEFAULT_IMPL_STRATEGY=_PTH
1585     fi
1587     if test "$OS_RELEASE" = "B.10.30"; then
1588         AC_DEFINE(HPUX10)
1589         AC_DEFINE(HPUX10_30)
1590         if test -z "$GNU_CC"; then
1591             CFLAGS="$CFLAGS +DAportable +DS1.1"
1592             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1593         fi
1594         DEFAULT_IMPL_STRATEGY=_PTH
1595     fi
1597     if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1598         AC_DEFINE(HPUX10)
1599         AC_DEFINE(HPUX11)
1600         AC_DEFINE(_LARGEFILE64_SOURCE)
1601         AC_DEFINE(_PR_HAVE_OFF64_T)
1602         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1603         if test -z "$GNU_CC"; then
1604             if test -z "$USE_64"; then
1605                 if test "$OS_TEST" = "ia64"; then
1606                     CFLAGS="$CFLAGS +DD32"
1607                     CXXFLAGS="$CXXFLAGS +DD32"
1608                 else
1609                     CFLAGS="$CFLAGS +DAportable +DS2.0"
1610                     CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1611                 fi
1612             else
1613                 if test "$OS_TEST" = "ia64"; then
1614                     CFLAGS="$CFLAGS +DD64"
1615                     CXXFLAGS="$CXXFLAGS +DD64"
1616                 else
1617                     CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1618                     CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1619                 fi
1620             fi
1621         fi
1622         DEFAULT_IMPL_STRATEGY=_PTH
1623     fi
1625     if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1626         USE_NSPR_THREADS=1
1627         USE_PTHREADS=
1628         USE_USER_PTHREADS=
1629     elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1630         USE_PTHREADS=1
1631         if test "$USE_NSPR_THREADS"; then
1632             USE_PTHREADS=
1633         fi
1634         if test "$USE_USER_PTHREADS"; then
1635             USE_PTHREADS=
1636         fi
1637     fi
1638     ;;
1640 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
1641     if test -z "$USE_NSPR_THREADS"; then
1642         USE_PTHREADS=1
1643         IMPL_STRATEGY=_PTH
1644     fi
1645     AC_DEFINE(XP_UNIX)
1646     AC_DEFINE(_GNU_SOURCE)
1647     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1648     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1649     case "${target}" in
1650     *-android*|*-linuxandroid*)
1651         OS_TARGET=Android
1652         AC_DEFINE(LINUX)
1653         ;;
1654     *-linux*)
1655         AC_DEFINE(LINUX)
1656         ;;
1657     esac
1658     CFLAGS="$CFLAGS -Wall"
1659     CXXFLAGS="$CXXFLAGS -Wall"
1660     MDCPUCFG_H=_linux.cfg
1661     PR_MD_CSRCS=linux.c
1662     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1663     DSO_CFLAGS=-fPIC
1664     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1665     _OPTIMIZE_FLAGS=-O2
1666     _DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb, and that
1667                                    # combo is not yet good at debugging inlined
1668                                    # functions (even when using DWARF2 as the
1669                                    # debugging format)
1670     COMPILER_TAG=_glibc
1671     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1672         CPU_ARCH=x86
1673     else
1674         CPU_ARCH=$OS_TEST
1675     fi
1676     CPU_ARCH_TAG=_${CPU_ARCH}
1677     case "${target_cpu}" in
1678     alpha)
1679         AC_DEFINE(_ALPHA_)
1680         AC_DEFINE(__alpha)
1681         CFLAGS="$CFLAGS -mieee"
1682         CXXFLAGS="$CXXFLAGS -mieee"
1683         ;;
1684     i*86)
1685         AC_DEFINE(i386)
1686         PR_MD_ASFILES=os_Linux_x86.s
1687         ;;
1688     ia64)
1689         PR_MD_ASFILES=os_Linux_ia64.s
1690         ;;
1691     x86_64)
1692         if test -n "$USE_64"; then
1693             PR_MD_ASFILES=os_Linux_x86_64.s
1694         elif test -n "$USE_X32"; then
1695             PR_MD_ASFILES=os_Linux_x86_64.s
1696             CC="$CC -mx32"
1697             CXX="$CXX -mx32"
1698         else
1699             AC_DEFINE(i386)
1700             PR_MD_ASFILES=os_Linux_x86.s
1701             CC="$CC -m32"
1702             CXX="$CXX -m32"
1703         fi
1704         ;;
1705     ppc|powerpc)
1706         PR_MD_ASFILES=os_Linux_ppc.s
1707         ;;
1708     powerpc64)
1709         if test -n "$USE_64"; then
1710             CC="$CC -m64"
1711             CXX="$CXX -m64"
1712         else
1713             PR_MD_ASFILES=os_Linux_ppc.s
1714         fi
1715         ;;
1716     esac    
1717     ;;
1719 *-mingw*|*-msys*|*-cygwin*|*-mks*)
1720     AC_DEFINE(XP_PC)
1721     AC_DEFINE(WIN32)
1722     PR_MD_ARCH_DIR=windows
1723     RESOLVE_LINK_SYMBOLS=1
1725     if test -n "$GNU_CC"; then
1726         CC="$CC -mwindows"
1727         CXX="$CXX -mwindows"
1728         DLL_SUFFIX=dll
1729         MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1730         RC=$WINDRES
1731         # Use temp file for windres (bug 213281)
1732         RCFLAGS='-O coff --use-temp-file'
1733     else
1734         LD=link
1735         AR='lib -NOLOGO -OUT:"$@"'
1736         AR_FLAGS=
1737         RANLIB='echo not_ranlib'
1738         STRIP='echo not_strip'
1739         RC=rc.exe
1740         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1741         OBJ_SUFFIX=obj
1742         LIB_SUFFIX=lib
1743         DLL_SUFFIX=dll
1745         # Determine compiler version
1746         changequote(,)
1747         _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
1748         changequote([,])
1749         CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
1750         if test -z "$CC_VERSION"; then
1751             AC_MSG_ERROR([Could not determine MSC version.])
1752         fi
1754         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
1755         _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
1756         _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
1757         _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
1758         MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
1760         if test "$_CC_MAJOR_VERSION" -eq "14"; then
1761            dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
1762            dnl so be very specific here!
1763            dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
1764            if test $_CC_RELEASE -gt 50727; then
1765               _USE_DYNAMICBASE=1
1766            elif test $_CC_BUILD -ge 762; then
1767               _USE_DYNAMICBASE=1
1768            fi
1769            AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
1770            AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
1771         elif test $_CC_MAJOR_VERSION -ge 15; then
1772            _USE_DYNAMICBASE=1    
1773            AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
1774            AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
1775         fi
1777         if test -n "$_USE_DYNAMICBASE"; then
1778            DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
1779         fi
1781         # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
1782         # tape manipulation utility (or something else)
1783         if test "$MSC_VER" -ge "1400"; then
1784             changequote(,)
1785             _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
1786             changequote([,])
1788             MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
1789             if test -n "$MSMT_TOOL"; then
1790                 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
1791                 if test -z "$MSMANIFEST_TOOL_VERSION"; then
1792                     AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
1793                 fi
1794                 MT=mt
1795                 unset MSMT_TOOL
1796             else
1797                 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
1798             fi
1799         fi
1800         
1801         CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
1802         DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
1803         _DEBUG_FLAGS=-Zi
1804         _OPTIMIZE_FLAGS=-O2
1806         PROFILE_GEN_CFLAGS="-GL"
1807         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
1808         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
1809         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
1811         if test "$MSC_VER" -ge "1800"; then
1812             dnl Visual C++ 2013 requires -FS when parallel building with
1813             dnl make -jN. If not specified, compiler sometimes emits C1041
1814             dnl error.
1815             CFLAGS="$CFLAGS -FS"
1816             dnl -Gw can benefit when using linker optimization on PGO.
1817             dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1818             PROFILE_GEN_CFLAGS="$PROFILE_GEN_CFLAGS -Gw"
1819             PROFILE_USE_CFLAGS="$PROFILE_USE_CFLAGS -Gw"
1820         fi
1822         if test -z "$MOZ_OPTIMIZE"; then
1823             CFLAGS="$CFLAGS -Od"
1824         fi
1826         if test "$USE_DEBUG_RTL" = 1; then
1827             if test -n "$USE_STATIC_RTL"; then
1828                 CFLAGS="$CFLAGS -MTd"
1829             else
1830                 CFLAGS="$CFLAGS -MDd"
1831             fi
1832         else
1833             if test -n "$USE_STATIC_RTL"; then
1834                 CFLAGS="$CFLAGS -MT"
1835             else
1836                 CFLAGS="$CFLAGS -MD"
1837             fi
1838         fi
1840         if test -n "$MOZ_DEBUG"; then
1841             AC_DEFINE(_DEBUG)
1842         else
1843             DEFINES="$DEFINES -U_DEBUG"
1844         fi
1846         if test -n "$MOZ_DEBUG_SYMBOLS"; then
1847             if test -n "$MOZ_OPTIMIZE"; then
1848                 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
1849                 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
1850             else
1851                 DLLFLAGS="$DLLFLAGS -DEBUG"
1852                 LDFLAGS="$LDFLAGS -DEBUG"
1853             fi
1854         fi
1856         OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
1857         if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
1858             OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
1859         fi
1860         
1861         if test "$OS_TARGET" = "WINNT"; then
1862             CFLAGS="$CFLAGS -GT"
1863             LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1864             LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1865         else
1866             LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1867             LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1868         fi
1869     fi # GNU_CC
1871     if test -n "$USE_STATIC_TLS"; then
1872         AC_DEFINE(_PR_USE_STATIC_TLS)
1873     fi
1875     if test "$OS_TARGET" = "WINNT"; then
1876         AC_DEFINE(WINNT)
1877     else
1878         AC_DEFINE(WIN95)
1879         # undefine WINNT as some versions of mingw gcc define it by default
1880         DEFINES="$DEFINES -UWINNT"
1881         AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
1882     fi
1884     if test "$CPU_ARCH" = "x86"; then
1885         CPU_ARCH_TAG=
1886     else
1887         CPU_ARCH_TAG=$CPU_ARCH
1888     fi
1890     if test "$USE_DEBUG_RTL" = 1; then
1891         OBJDIR_SUFFIX=OBJD
1892     fi
1894     case "$OS_TARGET" in
1895     WINNT)
1896             MDCPUCFG_H=_winnt.cfg
1897             ;;
1898     WIN95)
1899             MDCPUCFG_H=_win95.cfg
1900             ;;
1901     *)
1902             AC_MSG_ERROR([Missing OS_TARGET for ${target}.  Use --enable-win32-target to set.])
1903         ;;
1904     esac
1906     case "$target_cpu" in
1907     i*86)
1908         if test -n "$USE_64"; then
1909             AC_DEFINE(_AMD64_)
1910         else            
1911             AC_DEFINE(_X86_)
1912             if test -z "$GNU_CC" -a "$MSC_VER" -ge "1700"; then
1913                 dnl Visual C++ 2012 defaults to -arch:SSE2. Use -arch:IA32
1914                 dnl to avoid requiring SSE2.
1915                 CFLAGS="$CFLAGS -arch:IA32"
1916             fi
1917         fi
1918         ;;
1919     x86_64)
1920             AC_DEFINE(_AMD64_)
1921             USE_64=1
1922             ;;
1923     aarch64)
1924             AC_DEFINE(_ARM64_)
1925             USE_64=1
1926             ;;
1927     ia64)
1928             AC_DEFINE(_IA64_)
1929             USE_64=1
1930             ;;
1931     *)
1932             AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1933             ;;
1934     esac
1935     ;;
1937 *-netbsd*)
1938     AC_DEFINE(XP_UNIX)
1939     AC_DEFINE(NETBSD)
1940     AC_DEFINE(HAVE_BSD_FLOCK)
1941     AC_DEFINE(HAVE_SOCKLEN_T)
1942     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1943     if test -z "$USE_NSPR_THREADS"; then
1944         USE_PTHREADS=1
1945     fi
1946     MDCPUCFG_H=_netbsd.cfg
1947     PR_MD_CSRCS=netbsd.c
1949     DSO_CFLAGS='-fPIC -DPIC'
1950     CFLAGS="$CFLAGS -ansi -Wall"
1951     CXXFLAGS="$CXXFLAGS -ansi -Wall"
1952     MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1954     if test -z "$OBJECT_FMT"; then
1955         if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
1956             OBJECT_FMT=a.out
1957             DLL_SUFFIX=so.1.0
1958             DSO_LDOPTS='-shared'
1959         else
1960             OBJECT_FMT=ELF
1961             DLL_SUFFIX=so
1962             DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
1963         fi
1964     fi
1966     if test "$LIBRUNPATH"; then
1967         DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
1968     fi
1969     ;;
1971 *-nto*)
1972     AC_DEFINE(XP_UNIX)
1973     AC_DEFINE(NTO)
1974     AC_DEFINE(_QNX_SOURCE)
1975     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1976     MDCPUCFG_H=_nto.cfg
1977     PR_MD_CSRCS=nto.c
1978     MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
1979     DSO_CFLAGS=-fPIC
1980     DSO_LDOPTS=-shared
1981     OS_LIBS="$OS_LIBS -lsocket"
1982     _OPTIMIZE_FLAGS="-O1"
1983     _DEBUG_FLAGS="-gstabs"
1984         ;;
1986 *-openbsd*)
1987     AC_DEFINE(XP_UNIX)
1988     AC_DEFINE(OPENBSD)
1989     AC_DEFINE(HAVE_BSD_FLOCK)
1990     AC_DEFINE(HAVE_SOCKLEN_T)
1991     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1992     CFLAGS="$CFLAGS -ansi -Wall"
1993     CXXFLAGS="$CXXFLAGS -ansi -Wall"
1994     DLL_SUFFIX=so.1.0
1995     DSO_CFLAGS=-fPIC
1996     MDCPUCFG_H=_openbsd.cfg
1997     PR_MD_CSRCS=openbsd.c
1998     OS_LIBS="-lc"
1999     if test -z "$USE_NSPR_THREADS"; then
2000         USE_PTHREADS=1
2001     fi
2002     DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
2003     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2004     ;;
2006 *-qnx*)
2007     AC_DEFINE(XP_UNIX)
2008     AC_DEFINE(QNX)
2009     AC_DEFINE(_PR_NEED_H_ERRNO)
2010     USE_NSPR_THREADS=1
2011     MDCPUCFG_H=_qnx.cfg
2012     PR_MD_CSRCS=qnx.c
2013     ;;
2015 *-riscos*)
2016     AC_DEFINE(XP_UNIX)
2017     AC_DEFINE(RISCOS)
2018     AC_DEFINE(_PR_NEED_H_ERRNO)
2019     USE_PTHREADS=1
2020     MDCPUCFG_H=_riscos.cfg
2021     PR_MD_CSRCS=riscos.c
2022     DSO_CFLAGS=-fPIC
2023     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
2024     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2025     ;;
2027 *-*-sco*)
2028     AC_DEFINE(XP_UNIX)
2029     AC_DEFINE(SCO)
2030     AC_DEFINE(sco)
2031     AC_DEFINE(SYSV)
2032     AC_DEFINE(_SVID3)
2033     AC_DEFINE(_PR_NEED_H_ERRNO)
2034     CC='cc -b elf -KPIC'
2035     CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
2036     USE_NSPR_THREADS=1
2037     CPU_ARCH=x86
2038     DSO_LDOPTS='-b elf -G'
2039     MDCPUCFG_H=_scoos.cfg
2040     PR_MD_SRCS=scoos.c
2041     ;;
2043 *-solaris*)
2044     if test -z "$USE_NSPR_THREADS"; then
2045         USE_PTHREADS=1
2046     fi
2047     AC_DEFINE(XP_UNIX)
2048     AC_DEFINE(SVR4)
2049     AC_DEFINE(SYSV)
2050     AC_DEFINE(__svr4)
2051     AC_DEFINE(__svr4__)
2052     AC_DEFINE(SOLARIS)
2053     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2054     CPU_ARCH=`uname -p`
2055     MDCPUCFG_H=_solaris.cfg
2056     PR_MD_CSRCS=solaris.c
2057     LD=/usr/ccs/bin/ld
2058     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2059     RESOLVE_LINK_SYMBOLS=1
2060     case "${OS_RELEASE}" in
2061     5.8|5.9)
2062         ;;
2063     *)
2064         # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
2065         USE_B_DIRECT=1
2066         ;;
2067     esac
2068     if test -n "$GNU_CC"; then
2069         DSO_CFLAGS=-fPIC
2070         if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
2071             GCC_USE_GNU_LD=1
2072         fi
2073         DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore' 
2074         if test -n "$USE_B_DIRECT"; then
2075             DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
2076         fi
2077     else
2078         DSO_CFLAGS=-KPIC
2079         DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
2080         if test -n "$USE_B_DIRECT"; then
2081             DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
2082         fi
2083     fi
2084     if test -n "$GNU_CC"; then
2085         CFLAGS="$CFLAGS -Wall"
2086         CXXFLAGS="$CXXFLAGS -Wall"
2087         if test -n "$USE_MDUPDATE"; then
2088             CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
2089             CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
2090         fi
2091         GCC_AS=`$CC -print-prog-name=as`
2092         if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
2093             GNU_AS=1
2094         fi
2095     else
2096         CFLAGS="$CFLAGS -xstrconst"
2097         CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
2098         if test -z "$MOZ_OPTIMIZE"; then
2099             CFLAGS="$CFLAGS -xs"
2100             CXXFLAGS="$CXXFLAGS -xs"
2101         fi
2102         _OPTIMIZE_FLAGS=-xO4
2103     fi
2104     if test -z "$GNU_AS"; then
2105         ASFLAGS="$ASFLAGS -Wa,-P"
2106     fi
2107     if test -n "$USE_64"; then
2108         if test -n "$GNU_CC"; then
2109             CC="$CC -m64"
2110             CXX="$CXX -m64"
2111         else
2112             if test "$OS_TEST" = "i86pc"; then
2113                 CC="$CC -xarch=amd64"
2114                 CXX="$CXX -xarch=amd64"
2115             else
2116                 CC="$CC -xarch=v9"
2117                 CXX="$CXX -xarch=v9"
2118             fi
2119         fi
2120     fi
2121     if test "$OS_TEST" = "i86pc"; then
2122         if test -z "$USE_64"; then
2123             AC_DEFINE(i386)
2124         fi
2125         CPU_ARCH_TAG=_$OS_TEST
2126         # The default debug format, DWARF (-g), is not supported by gcc
2127         # on i386-ANY-sysv4/solaris, but the stabs format is.  It is
2128         # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2129         # If your gcc uses GNU as, you do not need the -Wa,-s option.
2130         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2131             _DEBUG_FLAGS=-gstabs
2132             if test -z "$GNU_AS"; then
2133                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2134             fi
2135         fi
2136     fi
2137     case "${target_os}" in
2138     solaris2.3*)
2139         AC_DEFINE(_PR_NO_LARGE_FILES)
2140         ;;
2141     solaris2.4*)
2142         AC_DEFINE(_PR_NO_LARGE_FILES)
2143         ;;
2144     solaris2.5*)
2145         AC_DEFINE(SOLARIS2_5)    
2146         ;;
2147     *)
2148         AC_DEFINE(_PR_HAVE_OFF64_T)
2149         # The lfcompile64(5) man page on Solaris 2.6 says:
2150         #     For applications that do not wish to conform to the POSIX or
2151         #     X/Open  specifications,  the  64-bit transitional interfaces
2152         #     are available by default.  No compile-time flags need to  be
2153         #     set.
2154         # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2155         # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2156         if test -n "$GNU_CC"; then
2157             AC_DEFINE(_LARGEFILE64_SOURCE)
2158         fi
2159         ;;
2160     esac
2161     case "${target_os}" in
2162     solaris2.3*)
2163         ;;
2164     solaris2.4*)
2165         ;;
2166     solaris2.5*)
2167         ;;
2168     solaris2.6*)
2169         ;;
2170     solaris2.7*)
2171         ;;
2172     *)
2173         # Solaris 8 or higher has IPv6.
2174         AC_DEFINE(_PR_INET6)
2175         ;;
2176     esac
2177     if test "$CPU_ARCH" = "sparc"; then
2178         # 64-bit Solaris SPARC requires V9 architecture, so the following
2179         # is not needed.
2180         if test -z "$USE_64"; then
2181             ULTRASPARC_LIBRARY=nspr_flt
2182         fi
2183     fi
2184     # Purify requires that binaries linked against nspr also
2185     # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2186     _rev=`uname -r`
2187     _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2188     OS_LIBS="$OS_LIBS $_librt"
2189     ;;
2191 *-sco-sysv5*)
2192     AC_DEFINE(XP_UNIX)
2193     AC_DEFINE(UNIXWARE)
2194     AC_DEFINE(SVR4)
2195     AC_DEFINE(SYSV)
2196     USE_NSPR_THREADS=1
2197     if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
2198         AC_DEFINE(_PR_NO_LARGE_FILES)
2199         CC='$(NSDEPTH)/build/hcc cc'
2200         CXX='$(NSDEPTH)/build/hcpp CC'
2201         MDCPUCFG_H=_unixware.cfg
2202     else
2203         AC_DEFINE(_LARGEFILE64_SOURCE)
2204         AC_DEFINE(_PR_HAVE_OFF64_T)
2205         AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
2206         MDCPUCFG_H=_unixware7.cfg
2207     fi
2208     PR_MD_CSRCS=unixware.c
2209     DSO_LDOPTS=-G
2210     CPU_ARCH=x86
2211     ;;
2213 *-os2*)
2214     AC_DEFINE(XP_OS2)
2215     AC_DEFINE(XP_PC)
2216     AC_DEFINE(BSD_SELECT)
2217     AC_DEFINE(TCPV40HDRS)
2218     LIB_SUFFIX=lib
2219     DLL_SUFFIX=dll
2220     RC=rc.exe
2221     PR_MD_ARCH_DIR=os2
2222     PROG_SUFFIX=.exe
2223     NSINSTALL=nsinstall
2224     MDCPUCFG_H=_os2.cfg
2225     RESOLVE_LINK_SYMBOLS=1
2227     AC_DEFINE(OS2)
2228     AR=emxomfar
2229     AR_FLAGS='r $@'
2230     CFLAGS="$CFLAGS -Wall -Zomf"
2231     CXXFLAGS="$CFLAGS -Wall -Zomf"
2232     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2233     DSO_CFLAGS=
2234     DSO_LDOPTS='-Zomf -Zdll'
2235     LDFLAGS='-Zmap'
2236     _OPTIMIZE_FLAGS="-O2 -s"
2237     _DEBUG_FLAGS="-g -fno-inline"
2238     if test -n "$MOZ_OPTIMIZE"; then
2239       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2240     fi
2241     IMPLIB='emximp -o'
2242     FILTER='emxexp -o'
2243     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2244       LDFLAGS="$LDFLAGS -Zhigh-mem"
2245       AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2246     fi
2248     # GCC for OS/2 currently predefines these, but we don't want them
2249     DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
2250     ;;
2253     AC_DEFINE(XP_UNIX)
2254     ;;
2255    
2256 esac
2258 if test -z "$SKIP_LIBRARY_CHECKS"; then
2259 dnl ========================================================
2260 dnl Check for system libraries
2261 dnl ========================================================
2264 dnl We don't want anything to link with libdl even if it's present on OS X, 
2265 dnl since it's not used and not part of the default installation.
2266 dnl The same goes for BeOS.
2267 dnl OS/2 has dlfcn in libc.
2269 case $target in
2270 *-darwin*|*-os2*)
2271     ;;
2273     AC_CHECK_LIB(dl, dlopen,
2274         [AC_CHECK_HEADER(dlfcn.h,
2275             OS_LIBS="-ldl $OS_LIBS")])
2276     ;;
2277 esac
2280 dnl ========================================================
2281 dnl Check for system header files.
2282 dnl ========================================================
2284 dnl ========================================================
2285 dnl Check for typedefs and structs
2286 dnl ========================================================
2288 dnl ========================================================
2289 dnl Checks for library functions.
2290 dnl ========================================================
2291 AC_PROG_GCC_TRADITIONAL
2292 _SAVE_LIBS="$LIBS"
2293 LIBS="$LIBS $OS_LIBS"
2294 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
2295  secure_getenv __secure_getenv)
2296 LIBS="$_SAVE_LIBS"
2298 dnl ========================================================
2299 dnl Check options
2300 dnl ========================================================
2302 dnl ======================================================
2303 dnl = Enable compiling with ccache
2304 dnl ======================================================
2305 AC_ARG_WITH(ccache,
2306 [  --with-ccache[=path/to/ccache]
2307                           Enable compiling with ccache],
2308     CCACHE=$withval, CCACHE="no")
2310 if test "$CCACHE" != "no"; then
2311     if test -n "$CCACHE"; then
2312         if test "$CCACHE" = "yes"; then
2313             CCACHE=
2314         else
2315             if test ! -e "$CCACHE"; then
2316                 AC_MSG_ERROR([$CCACHE not found])
2317             fi
2318         fi
2319     fi
2320     AC_PATH_PROGS(CCACHE, $CCACHE ccache)
2321     if test -z "$CCACHE" -o "$CCACHE" = ":"; then
2322         AC_MSG_ERROR([ccache not found])
2323     elif test -x "$CCACHE"; then
2324         CC="$CCACHE $CC"
2325         CXX="$CCACHE $CXX"
2326     else
2327         AC_MSG_ERROR([$CCACHE is not executable])
2328     fi
2331 dnl ========================================================
2332 dnl =
2333 dnl = --enable-strip
2334 dnl = 
2335 dnl = Enable stripping of libs and executables
2336 dnl = 
2337 dnl ========================================================
2338 AC_ARG_ENABLE(strip,
2339     [  --enable-strip          Enable stripping of shared libs and programs],
2340     [ if test "$enableval" = "yes"; then
2341             ENABLE_STRIP=1
2342       fi ])
2344 dnl Check for hpux options
2345 case "${target_os}" in
2346 hpux*)
2347 if test -z "$GNU_CC"; then
2349     AC_CACHE_CHECK(for +Olit support,
2350         ac_cv_hpux_usable_olit_option,
2351         dnl since aCC doesn't throw an error on invalid options,
2352         dnl we have to test this the hard way
2353         [ac_cv_hpux_usable_olit_option=no
2354         rm -f conftest*
2355         echo 'int main() { return 0; }' | cat > conftest.c
2356         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2357         if test $? -eq 0; then
2358             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2359                 ac_cv_hpux_usable_olit_option=yes
2360             fi
2361         fi
2362         rm -f conftest*
2363         ])
2365     if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2366         CFLAGS="$CFLAGS +Olit=all"
2367         CXXFLAGS="$CXXFLAGS +Olit=all"
2368     else
2369         CFLAGS="$CFLAGS +ESlit"
2370         CXXFLAGS="$CXXFLAGS +ESlit"
2371     fi
2374 esac
2376 case "$target_os" in
2377 darwin*)
2378     _HAVE_PTHREADS=1
2379     ;;
2381     AC_CHECK_LIB(pthreads, pthread_create,
2382         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2383         AC_CHECK_LIB(pthread, pthread_create,
2384             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2385             AC_CHECK_LIB(c_r, pthread_create,
2386                 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2387                 AC_CHECK_LIB(c, pthread_create,
2388                     _HAVE_PTHREADS=1
2389                 )
2390             )
2391         )
2392     )
2393     ;;
2394 esac
2396 AC_ARG_WITH(pthreads,
2397     [  --with-pthreads         Use system pthreads library as thread subsystem],
2398     [ if test "$withval" = "yes"; then
2399             if test -n "$_HAVE_PTHREADS"; then
2400                     USE_PTHREADS=1 
2401                     USE_USER_PTHREADS=
2402                     USE_NSPR_THREADS=
2403             else
2404                     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2405             fi
2406           else
2407             USE_PTHREADS=
2408             _PTHREAD_LDFLAGS=
2409           fi],
2410         [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2411             USE_PTHREADS=1
2412             USE_USER_PTHREADS=
2413             USE_NSPR_THREADS=
2414           fi])
2416 AC_ARG_ENABLE(user-pthreads,
2417     [  --enable-user-pthreads  Build using userland pthreads],
2418     [ if test "$enableval" = "yes"; then
2419         if test -n "$_HAVE_PTHREADS"; then
2420                     USE_PTHREADS=
2421                     USE_USER_PTHREADS=1
2422                     USE_NSPR_THREADS=
2423             else
2424                     AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2425             fi
2426           fi])
2428 AC_ARG_ENABLE(nspr-threads,
2429     [  --enable-nspr-threads   Build using classic nspr threads],
2430     [ if test "$enableval" = "yes"; then
2431             USE_PTHREADS=
2432             USE_USER_PTHREADS=
2433             USE_NSPR_THREADS=1
2434           fi])
2436 fi # SKIP_LIBRARY_CHECKS
2438 AC_ARG_ENABLE(ipv6,
2439     [  --enable-ipv6           Compile ipv6 support],
2440     [ if test "$enableval" = "yes"; then
2441             USE_IPV6=1
2442       else
2443             USE_IPV6=
2444       fi])
2446 if test -n "$USE_PTHREADS"; then
2447    dnl See if -pthread is supported.
2448    rm -f conftest*
2449    ac_cv_have_dash_pthread=no
2450    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2451    echo 'int main() { return 0; }' | cat > conftest.c
2452    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2453    if test $? -eq 0; then
2454         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2455             ac_cv_have_dash_pthread=yes
2456                 case "$target_os" in
2457             freebsd*)
2458 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2459             ;;
2460             *)
2461             CFLAGS="$CFLAGS -pthread"
2462             CXXFLAGS="$CXXFLAGS -pthread"
2463             ;;
2464         esac
2465         fi
2466     fi
2467     rm -f conftest*
2468     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2470         dnl
2471         dnl See if -pthreads is supported.
2472         dnl
2473     ac_cv_have_dash_pthreads=no
2474     if test "$ac_cv_have_dash_pthread" = "no"; then
2475             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2476         echo 'int main() { return 0; }' | cat > conftest.c
2477             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2478         if test $? -eq 0; then
2479                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2480                             ac_cv_have_dash_pthreads=yes
2481                             CFLAGS="$CFLAGS -pthreads"
2482                             CXXFLAGS="$CXXFLAGS -pthreads"
2483                     fi
2484             fi
2485             rm -f conftest*
2486         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2487     fi
2489     case "$target" in
2490     *-solaris*)
2491         if test "$ac_cv_have_dash_pthreads" = "yes"; then
2492             _PTHREAD_LDFLAGS=
2493         fi
2494             ;;
2495     *-freebsd*)
2496             AC_DEFINE(_REENTRANT)
2497             AC_DEFINE(_THREAD_SAFE)
2498             dnl -pthread links in -lc_r, so don't specify it explicitly.
2499             if test "$ac_cv_have_dash_pthread" = "yes"; then
2500                 _PTHREAD_LDFLAGS="-pthread"
2501             else
2502                 _PTHREAD_LDFLAGS="-lc_r"
2503             fi
2504             ;;
2505     *-netbsd*)
2506             if test "$ac_cv_have_dash_pthread" = "yes"; then
2507                 _PTHREAD_LDFLAGS="-pthread"
2508             fi
2509             ;;
2510     *-bsdi*)
2511             AC_DEFINE(_THREAD_SAFE)
2512             dnl -pthread links in -lc_r, so don't specify it explicitly.
2513             if test "$ac_cv_have_dash_pthread" = "yes"; then
2514                 _PTHREAD_LDFLAGS=
2515             fi
2516             ;;
2517     *-openbsd*)
2518         if test "$ac_cv_have_dash_pthread" = "yes"; then
2519             _PTHREAD_LDFLAGS=-pthread
2520         fi
2521         ;;
2522     *-linux*|*-gnu*|*-k*bsd*-gnu)
2523         AC_DEFINE(_REENTRANT)
2524         ;;
2525     esac
2527 else 
2528     if test -n "$USE_USER_PTHREADS"; then
2529             USE_PTHREADS=
2530             USE_NSPR_THREADS=
2531     else
2532         _PTHREAD_LDFLAGS=
2533     fi
2535 dnl Special thread exceptions
2537 case "$target" in
2538 *-aix*)
2539     if test -n "$USE_NSPR_THREADS"; then
2540         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2541     fi
2542     case "$target_os" in
2543     aix4.1*)
2544         if test -z "$USE_PTHREADS"; then
2545             AC_DEFINE(AIX_RENAME_SELECT)
2546         fi
2547         ;;
2548     aix4.2*)
2549         if test -z "$USE_NSPR_THREADS"; then
2550             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2551         fi
2552         ;;
2553     aix4.3*)
2554         if test -z "$USE_NSPR_THREADS"; then
2555             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2556         fi
2557         if test -n "$USE_PTHREADS"; then
2558             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2559         fi
2560         ;;
2561     *)
2562         if test -z "$USE_NSPR_THREADS"; then
2563             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2564         fi
2565         if test -n "$USE_PTHREADS"; then
2566             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2567         fi
2568         ;;
2569     esac
2570     ;;
2571 *-bsdi*)
2572     if test -n "$USE_PTHREADS"; then
2573         AC_DEFINE(_PR_NEED_PTHREAD_INIT)
2574     fi
2575     ;;
2576 *-freebsd*)
2577     if test -n "$USE_NSPR_THREADS"; then
2578         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2579     fi
2580     ;;
2581 *-hpux*)
2582     if test -n "$USE_NSPR_THREADS"; then
2583         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2584     fi 
2585     if test "$USE_PTHREADS"; then
2586         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2587         AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2588     fi
2589     if test "$USE_USER_PTHREADS"; then
2590         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2591     fi
2592     ;;
2593 *-linux*|*-gnu*|*-k*bsd*-gnu)
2594     if test -n "$USE_NSPR_THREADS"; then
2595         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2596     fi
2597     ;;
2598 *-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*)
2599     dnl win32, os2 cannot use pthreads
2600     USE_PTHREADS=
2601     _PTHREAD_LDFLAGS=
2602     USE_USER_PTHREADS=
2603     ;;
2604 *-netbsd*|*-openbsd*)
2605     if test -n "$USE_NSPR_THREADS"; then
2606         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2607     fi
2608     ;;
2609 *-solaris*)
2610     if test -n "$USE_NSPR_THREADS"; then
2611         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2612     fi
2613     if test -n "$USE_PTHREADS"; then
2614         AC_DEFINE(_REENTRANT)
2615         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2616         if test "$OS_TEST" = "i86pc"; then
2617             if test -n "$USE_64"; then
2618                PR_MD_ASFILES=os_SunOS_x86_64.s
2619             else
2620                PR_MD_ASFILES=os_SunOS_x86.s
2621             fi
2622         else
2623             if test -n "$USE_64"; then
2624                 PR_MD_ASFILES=os_SunOS_sparcv9.s
2625             fi
2626         fi
2627     fi
2628     ;;
2629 *-nto*)
2630     if test -n "$USE_PTHREADS"; then
2631         AC_DEFINE(_PR_HAVE_GETHOST_R)
2632         AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2633     fi
2634     ;;
2635 esac
2637 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2639 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2640 dnl make sure that we use it.
2641 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2642     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2645 if test -n "$_SAVE_DEBUG_FLAGS"; then
2646     _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2649 if test -n "$MOZ_OPTIMIZE"; then
2650     CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2651     CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2654 if test -n "$MOZ_DEBUG_SYMBOLS"; then
2655     CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2656     CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2659 if test -n "$MOZ_OPTIMIZE"; then
2660     OBJDIR_TAG=_OPT
2661 else
2662     OBJDIR_TAG=_DBG
2665 if test -n "$USE_64"; then
2666     COMPILER_TAG=_64
2669 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2671 dnl ========================================================
2672 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2673 dnl ========================================================
2674 case "$target_os" in
2675 cygwin*|mks*)
2676     CC="\$(CYGWIN_WRAPPER) $CC"
2677     CXX="\$(CYGWIN_WRAPPER) $CXX"
2678     RC="\$(CYGWIN_WRAPPER) $RC"
2679     ;;
2680 esac
2682 dnl ========================================================
2683 dnl = Use malloc wrapper lib
2684 dnl ========================================================
2685 AC_ARG_ENABLE(wrap-malloc,
2686 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
2687 [     if test "$enableval" = "yes"; then
2688             _WRAP_MALLOC=1
2689       fi ])
2691 if test -n "$_WRAP_MALLOC"; then
2692     if test -n "$GNU_CC"; then
2693         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
2694         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
2695         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
2696         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
2697     else
2698         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
2699     fi
2702 dnl ========================================================
2703 dnl = Location of malloc wrapper lib
2704 dnl ========================================================
2705 AC_ARG_WITH(wrap-malloc,
2706 [  --with-wrap-malloc=SHAREDLIB  Location of malloc wrapper library],
2707     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
2709 dnl ========================================================
2710 dnl Substitution of found variables.
2711 dnl ========================================================
2712 AC_SUBST(SHELL_OVERRIDE)
2714 AC_SUBST(MOZILLA_CLIENT)
2715 AC_SUBST(CC)
2716 AC_SUBST(CXX)
2717 AC_SUBST(CFLAGS)
2718 AC_SUBST(CXXFLAGS)
2719 AC_SUBST(CPPFLAGS)
2720 AC_SUBST(HOST_CC)
2721 AC_SUBST(HOST_CFLAGS)
2722 AC_SUBST(LDFLAGS)
2723 AC_SUBST(HOST_LDFLAGS)
2724 AC_SUBST(GNU_CC)
2725 AC_SUBST(GCC_USE_GNU_LD)
2726 AC_SUBST(MSC_VER)
2727 AC_SUBST(CROSS_COMPILE)
2729 AC_SUBST(MOZ_OPTIMIZE)
2730 AC_SUBST(MOZ_DEBUG)
2731 AC_SUBST(MOZ_DEBUG_SYMBOLS)
2733 AC_SUBST(USE_CPLUS)
2734 AC_SUBST(USE_IPV6)
2735 AC_SUBST(USE_N32)
2736 AC_SUBST(USE_X32)
2737 AC_SUBST(USE_64)
2738 AC_SUBST(OBJECT_MODE)
2739 AC_SUBST(ENABLE_STRIP)
2741 AC_SUBST(USE_PTHREADS)
2742 AC_SUBST(USE_BTHREADS)
2743 AC_SUBST(USE_USER_PTHREADS)
2744 AC_SUBST(USE_NSPR_THREADS)
2746 AC_SUBST(LIBNSPR)
2747 AC_SUBST(LIBPLC)
2749 AC_SUBST(MOD_MAJOR_VERSION)
2750 AC_SUBST(MOD_MINOR_VERSION)
2751 AC_SUBST(MOD_PATCH_VERSION)
2752 AC_SUBST(NSPR_MODNAME)
2753 AC_SUBST(MDCPUCFG_H)
2754 AC_SUBST(PR_MD_CSRCS)
2755 AC_SUBST(PR_MD_ASFILES)
2756 AC_SUBST(PR_MD_ARCH_DIR)
2757 AC_SUBST(CPU_ARCH)
2759 AC_SUBST(OBJ_SUFFIX)
2760 AC_SUBST(LIB_SUFFIX)
2761 AC_SUBST(DLL_SUFFIX)
2762 AC_SUBST(ASM_SUFFIX)
2763 AC_SUBST(WRAP_LDFLAGS)
2764 AC_SUBST(MKSHLIB)
2765 AC_SUBST(DSO_CFLAGS)
2766 AC_SUBST(DSO_LDOPTS)
2768 AC_SUBST(OS_TARGET)
2769 AC_SUBST(OS_ARCH)
2770 AC_SUBST(OS_RELEASE)
2771 AC_SUBST(OS_TEST)
2772 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
2774 AC_SUBST(DEFINES)
2775 AC_SUBST(DEFS)
2776 AC_SUBST(AR)
2777 AC_SUBST(AR_FLAGS)
2778 AC_SUBST(AS)
2779 AC_SUBST(ASFLAGS)
2780 AC_SUBST(LD)
2781 AC_SUBST(RANLIB)
2782 AC_SUBST(PERL)
2783 AC_SUBST(STRIP)
2784 AC_SUBST(FILTER)
2785 AC_SUBST(IMPLIB)
2787 AC_SUBST(PROFILE_GEN_CFLAGS)
2788 AC_SUBST(PROFILE_GEN_LDFLAGS)
2789 AC_SUBST(PROFILE_USE_CFLAGS)
2790 AC_SUBST(PROFILE_USE_LDFLAGS)
2792 AC_SUBST(OS_LIBS)
2793 AC_SUBST(RESOLVE_LINK_SYMBOLS)
2794 AC_SUBST(AIX_LINK_OPTS)
2795 AC_SUBST(NOSUCHFILE)
2796 AC_SUBST(MOZ_OBJFORMAT)
2797 AC_SUBST(ULTRASPARC_LIBRARY)
2799 AC_SUBST(OBJDIR)
2800 AC_SUBST(OBJDIR_NAME)
2801 AC_SUBST(RELEASE_OBJDIR_NAME)
2802 AC_SUBST(NSINSTALL)
2803 AC_SUBST(OPTIMIZER)
2804 AC_SUBST(RC)
2805 AC_SUBST(RCFLAGS)
2806 AC_SUBST(DLLFLAGS)
2807 AC_SUBST(EXEFLAGS)
2808 AC_SUBST(OS_DLLFLAGS)
2809 AC_SUBST(CYGWIN_WRAPPER)
2810 AC_SUBST(VISIBILITY_FLAGS)
2811 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2812 AC_SUBST(MACOS_SDK_DIR)
2813 AC_SUBST(NEXT_ROOT)
2814 AC_SUBST(MT)
2816 dnl ========================================================
2817 dnl Generate output files.
2818 dnl ========================================================
2819 MAKEFILES="
2820     Makefile
2821     config/Makefile
2822     config/autoconf.mk
2823     config/nsprincl.mk
2824     config/nsprincl.sh
2825     config/nspr-config
2826     config/nspr.pc
2827     lib/Makefile
2828     lib/ds/Makefile
2829     lib/libc/Makefile
2830     lib/libc/include/Makefile
2831     lib/libc/src/Makefile
2832     lib/tests/Makefile
2833     pkg/Makefile
2834     pr/Makefile
2835     pr/include/Makefile
2836     pr/include/md/Makefile
2837     pr/include/obsolete/Makefile
2838     pr/include/private/Makefile
2839     pr/src/Makefile
2840     pr/src/io/Makefile
2841     pr/src/linking/Makefile
2842     pr/src/malloc/Makefile
2843     pr/src/md/Makefile
2844     pr/src/md/${PR_MD_ARCH_DIR}/Makefile
2845     pr/src/memory/Makefile
2846     pr/src/misc/Makefile
2847     pr/src/threads/Makefile
2848     pr/tests/Makefile
2849     pr/tests/dll/Makefile
2852 if test "$OS_TARGET" = "Linux"; then
2853     MAKEFILES="$MAKEFILES
2854         pkg/linux/Makefile
2855     "
2856 elif test "$OS_TARGET" = "SunOS"; then
2857     MAKEFILES="$MAKEFILES
2858         pkg/solaris/Makefile
2859         pkg/solaris/SUNWpr/Makefile
2860         pkg/solaris/SUNWprd/Makefile
2861     "
2864 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
2865     MAKEFILES="$MAKEFILES
2866         pr/src/threads/combined/Makefile
2867     "
2868 elif test -n "$USE_PTHREADS"; then
2869     MAKEFILES="$MAKEFILES
2870         pr/src/pthreads/Makefile
2871     "
2872 elif test -n "$USE_BTHREADS"; then
2873     MAKEFILES="$MAKEFILES
2874         pr/src/bthreads/Makefile
2875     "
2878 if test -n "$USE_CPLUS"; then
2879     MAKEFILES="$MAKEFILES
2880         pr/src/cplus/Makefile
2881         pr/src/cplus/tests/Makefile
2882     "
2885 echo $MAKEFILES > unallmakefiles
2887 AC_CONFIG_FILES([$MAKEFILES])
2888 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])
2889 AC_OUTPUT