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