1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
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/.
9 AC_CONFIG_SRCDIR([pr/include/nspr.h])
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
14 dnl ========================================================
16 dnl ========================================================
31 _MACOSX_DEPLOYMENT_TARGET=
36 OBJDIR='$(OBJDIR_NAME)'
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)'
53 dnl Link in libraries necessary to resolve all symbols for shared libs
56 dnl ========================================================
58 dnl = Dont change the following lines. Doing so breaks:
60 dnl = CFLAGS="-foo" ./configure
62 dnl ========================================================
64 CXXFLAGS="${CXXFLAGS=}"
66 DLLFLAGS="${DLLFLAGS=}"
67 HOST_CFLAGS="${HOST_CFLAGS=}"
68 HOST_LDFLAGS="${HOST_LDFLAGS=}"
71 *-cygwin*|*-mingw*|*-msys*)
72 # Check to see if we are really running in a msvc environemnt
74 AC_CHECK_PROGS(CC, cl)
75 cat > conftest.c <<EOF
81 $($CC -E conftest.c 2>/dev/null | grep COMPILER)
83 if test -n "$dummy"; then
94 if test -n "$_WIN32_MSVC"; then
96 SKIP_COMPILER_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
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)
136 x86_64-linux*-android*)
137 android_tool_prefix="x86_64-linux-android"
139 aarch64-linux*-android*)
140 android_tool_prefix="aarch64-linux-android"
142 arm-linux*-android*|*-linuxandroid*)
143 android_tool_prefix="arm-linux-androideabi"
146 android_tool_prefix="i686-linux-android"
149 android_tool_prefix="mipsel-linux-android"
152 android_tool_prefix="$target_os"
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.])
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
169 target_name=arm-linux-androideabi-4.4.3
172 target_name=x86-4.4.3
175 target_name=mipsel-linux-android-4.4.3
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])
183 AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
187 if test -z "$android_platform" ; then
188 AC_MSG_CHECKING([for android platform directory])
190 case "$target_cpu" in
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])
207 AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
211 dnl Old NDK support. If minimum requirement is changed to NDK r8b,
212 dnl please remove this.
213 case "$target_cpu" in
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"
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"
241 dnl ========================================================
243 dnl = Check options that may affect the compiler
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
283 [ --with-mozilla Compile NSPR with Mozilla support],
284 [ if test "$withval" = "yes"; then
285 AC_DEFINE(MOZILLA_CLIENT)
290 [ if test -n "$MOZILLA_CLIENT"; then
291 AC_DEFINE(MOZILLA_CLIENT)
294 AC_ARG_ENABLE(optimize,
295 [ --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
296 [ if test "$enableval" != "no"; then
298 if test -n "$enableval" -a "$enableval" != "yes"; then
299 _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
300 _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
307 [ --enable-debug[=DBG] Enable debugging (using compiler flags DBG)],
308 [ if test "$enableval" != "no"; then
311 if test -n "$enableval" -a "$enableval" != "yes"; then
312 _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
313 _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
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
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
330 AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
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
351 AC_ARG_ENABLE(static-rtl,
352 [ --enable-static-rtl Use the MSVC static runtime library],
353 [ if test "$enableval" = "yes"; then
358 [ --enable-x32 Enable x32 ABI support (x86_64 only)],
359 [ if test "$enableval" = "yes"; then
361 else if test "$enableval" = "no"; then
367 [ --enable-64bit Enable 64-bit support (on certain platforms)],
368 [ if test "$enableval" = "yes"; then
372 AC_ARG_ENABLE(mdupdate,
373 [ --enable-mdupdate Enable use of certain compilers' mdupdate feature],
374 [ if test "$enableval" = "yes"; then
379 [ --enable-cplus Enable some c++ api routines],
380 [ if test "$enableval" = "yes"; then
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)
391 dnl ========================================================
392 dnl = Mac OS X SDK support
393 dnl ========================================================
394 AC_ARG_WITH(macos-sdk,
395 [ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)],
396 MACOS_SDK_DIR=$withval)
398 AC_ARG_ENABLE(macos-target,
399 [ --enable-macos-target=VER
400 Set the minimum MacOS version needed at runtime
401 [10.2 for ppc, 10.4 for x86]],
402 [_MACOSX_DEPLOYMENT_TARGET=$enableval])
404 dnl ========================================================
406 dnl = Set the threading model
408 dnl ========================================================
412 case "${target_os}" in
424 dnl ========================================================
426 dnl = Set the default C compiler
428 dnl ========================================================
429 if test -z "$CC"; then
433 if test -z "$USE_NSPR_THREADS"; then
451 dnl ========================================================
453 dnl = Set the default C++ compiler
455 dnl ========================================================
456 if test -z "$CXX"; then
460 if test -z "$USE_NSPR_THREADS"; then
468 case "${target_os}" in
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
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'`"
501 DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
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"
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.
525 _SAVE_CXXFLAGS=$CXXFLAGS
526 CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
527 CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
531 AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
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).
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)
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).
556 CXXFLAGS=$_SAVE_CXXFLAGS
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)
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])
576 AC_MSG_RESULT([$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.])] )
589 LDFLAGS=$_SAVE_LDFLAGS
591 if test -n "$USE_CPLUS"; then
592 if test "$CC" = "cl" -a -z "$CXX"; then
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
607 if test -z "$HOST_CFLAGS"; then
608 HOST_CFLAGS="$CFLAGS"
614 if test "$GCC" = "yes"; then
617 if test "$GXX" = "yes"; then
620 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
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.
634 if test "$cross_compiling" = "yes"; then
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
654 if test "$_res_as_stdin" = "yes"; then
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"] )
663 if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
665 CFLAGS="$CFLAGS -pipe"
666 CXXFLAGS="$CXXFLAGS -pipe"
670 rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
671 AC_MSG_RESULT([$_res])
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"
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
696 CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
704 rm -f dummy-hello.c dummy-hello.s
705 AC_MSG_RESULT([$_res])
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
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)
758 #pragma GCC visibility push(default)
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
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=
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
801 dnl ========================================================
802 dnl Default platform specific options
803 dnl ========================================================
808 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
816 if test -n "$CROSS_COMPILE"; then
817 OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
819 OS_TEST="${target_cpu}"
820 case "${target_os}" in
821 linux*) OS_ARCH=Linux ;;
822 solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;;
823 mingw*) OS_ARCH=WINNT CPU_ARCH=x86 ;;
824 darwin*) OS_ARCH=Darwin ;;
825 riscos*) OS_ARCH=RISCOS ;;
828 OS_ARCH=`uname -s | sed -e 's|/|_|g'`
829 OS_RELEASE=`uname -r`
833 if test "$OS_ARCH" = "AIX"; then
834 OS_RELEASE=`uname -v`.`uname -r`
837 if test "$OS_ARCH" = "FreeBSD"; then
838 OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
841 if test "$OS_ARCH" = "Linux"; then
842 OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
843 OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
846 #######################################################################
847 # Master "Core Components" macros for getting the OS target #
848 #######################################################################
851 # Note: OS_TARGET should be specified on the command line for gmake.
852 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
853 # The difference between the Win95 target and the WinNT target is that
854 # the WinNT target uses Windows NT specific features not available
855 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
856 # at lesser performance (the Win95 target uses threads; the WinNT target
859 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
864 # The following hack allows one to build on a WIN95 machine (as if
865 # s/he were cross-compiling on a WINNT host for a WIN95 target).
866 # It also accomodates for MKS's uname.exe. If you never intend
867 # to do development on a WIN95 machine, you don't need this hack.
878 CYGWIN_9*|CYGWIN_ME*)
879 OS_ARCH='CYGWIN_NT-4.0'
889 # On WIN32, we also define the variable CPU_ARCH.
895 # If uname -s returns "Windows_NT", we assume that we are using
896 # the uname.exe in MKS toolkit.
898 # The -r option of MKS uname only returns the major version number.
899 # So we need to use its -v option to get the minor version number.
900 # Moreover, it doesn't have the -p option, so we need to use uname -m.
903 OS_MINOR_RELEASE=`uname -v`
904 if test "$OS_MINOR_RELEASE" = "00"; then
907 OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
910 # MKS's uname -m returns "586" on a Pentium machine.
912 if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
916 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
918 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
919 # the uname.exe in the Cygwin tools.
920 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
921 # the uname.exe in the MSYS tools.
922 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
923 # the uname.exe in the MSYS2 tools.
925 OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
929 # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
931 if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
937 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
939 if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
943 if test -z "$OS_TARGET"; then
946 if test "$OS_TARGET" = "WIN95"; then
949 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
951 dnl ========================================================
952 dnl Enable high-memory support on OS/2 by default.
953 dnl ========================================================
954 AC_ARG_ENABLE(os2-high-mem,
955 [ --disable-os2-high-mem Disable high-memory support on OS/2],
956 [ if test "$enableval" = "no"; then
959 MOZ_OS2_HIGH_MEMORY=1
962 dnl ========================================================
963 dnl = ARM toolchain tweaks
964 dnl ========================================================
967 MOZ_ALIGN=toolchain-default
970 arm*-android*|arm*-linuxandroid*)
979 if test -n "$MOZ_PLATFORM_MAEMO"; then
984 if test "$MOZ_PLATFORM_MAEMO" = 6; then
990 dnl Kept for compatibility with some buildbot mozconfig
991 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
994 [ --with-thumb[[=yes|no|toolchain-default]]]
995 [ Use Thumb instruction set (-mthumb)],
996 if test -z "$GNU_CC"; then
997 AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
1001 AC_ARG_WITH(thumb-interwork,
1002 [ --with-thumb-interwork[[=yes|no|toolchain-default]]
1003 Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
1004 if test -z "$GNU_CC"; then
1005 AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
1007 MOZ_THUMB_INTERWORK=$withval)
1010 [ --with-arch=[[type|toolchain-default]]
1011 Use specific CPU features (-march=type)],
1012 if test -z "$GNU_CC"; then
1013 AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
1018 [ --with-fpu=[[type|toolchain-default]]
1019 Use specific FPU type (-mfpu=type)],
1020 if test -z "$GNU_CC"; then
1021 AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
1025 AC_ARG_WITH(float-abi,
1026 [ --with-float-abi=[[type|toolchain-default]]
1027 Use specific arm float ABI (-mfloat-abi=type)],
1028 if test -z "$GNU_CC"; then
1029 AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
1031 MOZ_FLOAT_ABI=$withval)
1033 AC_ARG_WITH(soft-float,
1034 [ --with-soft-float[[=yes|no|toolchain-default]]
1035 Use soft float library (-msoft-float)],
1036 if test -z "$GNU_CC"; then
1037 AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
1039 MOZ_SOFT_FLOAT=$withval)
1042 toolchain-default|"")
1046 arch_flag="-march=$MOZ_ARCH"
1050 case "$MOZ_THUMB" in
1053 thumb_flag="-mthumb"
1060 _SAVE_CFLAGS="$CFLAGS"
1062 AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1065 CFLAGS="$_SAVE_CFLAGS"
1070 case "$MOZ_THUMB_INTERWORK" in
1072 thumb_interwork_flag="-mthumb-interwork"
1075 thumb_interwork_flag="-mno-thumb-interwork"
1077 *) # toolchain-default
1078 thumb_interwork_flag=""
1083 toolchain-default|"")
1087 fpu_flag="-mfpu=$MOZ_FPU"
1091 case "$MOZ_FLOAT_ABI" in
1092 toolchain-default|"")
1096 float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1100 case "$MOZ_SOFT_FLOAT" in
1102 soft_float_flag="-msoft-float"
1105 soft_float_flag="-mno-soft-float"
1107 *) # toolchain-default
1112 case "$MOZ_ALIGN" in
1113 toolchain-default|"")
1117 align_flag="-mno-unaligned-access"
1120 align_flag="-munaligned-access"
1127 if test -n "$align_flag"; then
1128 _SAVE_CFLAGS="$CFLAGS"
1129 CFLAGS="$CFLAGS $align_flag"
1130 AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
1131 AC_TRY_COMPILE([],[],,align_flag="")
1132 CFLAGS="$_SAVE_CFLAGS"
1135 dnl Use echo to avoid accumulating space characters
1136 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
1137 if test -n "$all_flags"; then
1138 _SAVE_CFLAGS="$CFLAGS"
1140 AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1141 AC_TRY_COMPILE([],[return 0;],
1142 AC_MSG_RESULT([yes]),
1145 CFLAGS="$_SAVE_CFLAGS $all_flags"
1146 CXXFLAGS="$CXXFLAGS $all_flags"
1147 ASFLAGS="$ASFLAGS $all_flags"
1148 if test -n "$thumb_flag"; then
1149 LDFLAGS="$LDFLAGS $thumb_flag"
1153 dnl ========================================================
1154 dnl Override of system specific host options
1155 dnl ========================================================
1161 NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
1162 if test `echo "${PATH}" | grep -c \;` = 0; then
1163 CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
1169 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1173 dnl ========================================================
1174 dnl Override of system specific target options
1175 dnl ========================================================
1182 DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
1183 AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
1184 case "${target_os}" in
1186 AC_DEFINE(AIX_RENAME_SELECT)
1187 AC_DEFINE(_PR_NO_LARGE_FILES)
1188 AIX_LINK_OPTS='-bnso -berok'
1189 PR_MD_ASFILES=os_AIX.s
1192 AC_DEFINE(AIX_TIMERS)
1193 AC_DEFINE(_PR_NO_LARGE_FILES)
1197 AIX_LINK_OPTS='-bnso -berok'
1198 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
1199 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
1202 AC_DEFINE(AIX_TIMERS)
1203 AC_DEFINE(_PR_HAVE_OFF64_T)
1204 AIX_LINK_OPTS='-brtl -bnso -berok'
1207 AC_DEFINE(AIX_TIMERS)
1208 AC_DEFINE(_PR_HAVE_OFF64_T)
1209 AC_DEFINE(AIX4_3_PLUS)
1210 AC_DEFINE(HAVE_SOCKLEN_T)
1211 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1213 AIX_LINK_OPTS='-brtl -bnso -berok'
1216 AC_DEFINE(AIX_TIMERS)
1217 AC_DEFINE(_PR_HAVE_OFF64_T)
1218 AC_DEFINE(AIX4_3_PLUS)
1219 AC_DEFINE(HAVE_SOCKLEN_T)
1220 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1222 AIX_LINK_OPTS='-brtl -bnso -berok'
1225 CFLAGS="$CFLAGS -qro -qroconst"
1226 AIX_WRAP='$(DIST)/lib/aixwrap.o'
1227 AIX_TMP='./_aix_tmp.o'
1228 if test -n "$USE_64"; then
1229 MDCPUCFG_H=_aix64.cfg
1232 MDCPUCFG_H=_aix32.cfg
1235 RESOLVE_LINK_SYMBOLS=1
1241 AC_DEFINE(NEED_BSDREGEX)
1243 CFLAGS="$CFLAGS -Wall -Wno-format"
1244 CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
1246 if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1248 elif echo "$OS_TEST" | grep -c sparc >/dev/null; then
1252 MDCPUCFG_H=_bsdi.cfg
1257 case "$target_os" in
1259 AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1260 AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
1261 AC_DEFINE(_PR_NEED_H_ERRNO)
1268 AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
1269 AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1271 AC_DEFINE(USE_DLFCN)
1272 AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1273 PR_MD_ASFILES=os_BSD_OS_386_2.s
1277 AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1278 AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1280 AC_DEFINE(USE_DLFCN)
1281 AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1282 MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1284 DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
1286 case "$target_os" in
1287 bsdi4.2* | bsdi4.3* | bsdi5.*)
1288 AC_DEFINE(_PR_HAVE_GETPROTO_R)
1289 AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1294 AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1295 AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1297 AC_DEFINE(USE_DLFCN)
1298 AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1307 AC_DEFINE(HAVE_BSD_FLOCK)
1308 AC_DEFINE(HAVE_SOCKLEN_T)
1309 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1311 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1313 if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
1314 AC_DEFINE(HAS_CONNECTX)
1316 AS='$(CC) -x assembler-with-cpp'
1317 CFLAGS="$CFLAGS -Wall -fno-common"
1318 case "${target_cpu}" in
1323 if test -n "$USE_64"; then
1333 if test "`echo $CC | grep -c '\-arch '`" = "0"; then
1334 CC="$CC -arch $CPU_ARCH"
1336 AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
1338 DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1340 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1341 STRIP="$STRIP -x -S"
1344 MDCPUCFG_H=_darwin.cfg
1345 PR_MD_CSRCS=darwin.c
1346 PR_MD_ASFILES=os_Darwin.s
1348 # Add Mac OS X support for loading CFM & CFBundle plugins
1349 if test -f "${MACOS_SDK_DIR}/System/Library/Frameworks/Carbon.framework/Carbon"; then
1350 AC_DEFINE(XP_MACOSX)
1353 if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1354 dnl Use the specified value
1355 export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1356 elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1357 dnl No value specified on the command line or in the environment,
1358 dnl use the lesser of the library's minimum or the architecture's
1360 case "${target_cpu}" in
1362 dnl Architecture minimum 10.2
1363 export MACOSX_DEPLOYMENT_TARGET=10.2
1366 dnl Architecture minimum 10.4
1367 export MACOSX_DEPLOYMENT_TARGET=10.4
1372 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1373 dnl in use. NEXT_ROOT will be set and exported if it's needed for
1376 if test "$MACOS_SDK_DIR"; then
1377 dnl Sync this section with the one in Mozilla's top level.
1379 if test ! -d "$MACOS_SDK_DIR"; then
1380 AC_MSG_ERROR([SDK not found. When using --with-macos-sdk, you must
1381 specify a valid SDK. SDKs are installed when the optional cross-development
1382 tools are selected during the Xcode/Developer Tools installation.])
1386 CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1387 GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1388 GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1390 GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1391 if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1392 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1393 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1394 SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1397 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1399 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1401 dnl CPP needs to be set for AC_CHECK_HEADER.
1402 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1405 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1407 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1408 dnl The build host is running Tiger (10.4) or earlier.
1409 dnl ld support for -syslibroot is compiler-agnostic, but
1410 dnl only available on Tiger and later. On Tiger and
1411 dnl earlier build hosts, just rely on NEXT_ROOT, because
1412 dnl it's not been shown to cause any problems.
1413 MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}"
1415 dnl The build host is running Leopard (10.5) or later.
1416 dnl With NEXT_ROOT set, the linker will still not apply
1417 dnl it when resolving dependencies. This causes problems
1418 dnl on Leopard, where an SDK depends on frameworks which
1419 dnl were present in earlier OS releases (and the associated
1420 dnl SDK) but not in Leopard. -syslibroot does not have
1421 dnl this problem, but it results in harmless warnings when
1422 dnl NEXT_ROOT is set. NEXT_ROOT needs to remain set even
1423 dnl on Leopard because the compiler uses it too.
1424 MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1427 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1428 export NEXT_ROOT=$MACOS_SDK_DIR
1430 if test -n "$CROSS_COMPILE" ; then
1431 dnl NEXT_ROOT will be in the environment, but it
1432 dnl shouldn't be set for the build host. HOST_CXX is
1433 dnl presently unused.
1434 HOST_CC="NEXT_ROOT= $HOST_CC"
1435 HOST_CXX="NEXT_ROOT= $HOST_CXX"
1438 dnl gcc >= 4.0 uses different paths than above, but knows
1439 dnl how to find them itself.
1440 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1442 dnl CPP needs to be set for AC_CHECK_HEADER.
1443 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1445 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1446 dnl has an ld that supports -syslibroot. Don't set
1447 dnl NEXT_ROOT because it will be ignored and cause
1448 dnl warnings when -syslibroot is specified.
1449 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1450 dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1451 dnl based on the -isysroot it receives.
1452 LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1454 dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1456 LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1464 if test -z "$USE_NSPR_THREADS"; then
1469 AC_DEFINE(HAVE_BSD_FLOCK)
1470 AC_DEFINE(HAVE_SOCKLEN_T)
1471 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1472 CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1473 MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1474 if test "$MOZ_OBJFORMAT" = "elf"; then
1479 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1481 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1482 MDCPUCFG_H=_freebsd.cfg
1483 PR_MD_CSRCS=freebsd.c
1489 AC_DEFINE(_HPUX_SOURCE)
1490 # HPUX report the POLLHUP event for a socket when the
1491 # shutdown(SHUT_WR) operation is called for the remote end, even though
1492 # the socket is still writeable. Use select(), instead of poll(), to
1493 # workaround this problem.
1494 AC_DEFINE(_PR_POLL_WITH_SELECT)
1495 AC_DEFINE(_USE_BIG_FDS)
1496 DSO_LDOPTS='-b +h $(notdir $@)'
1498 if test "$OS_TEST" = "ia64"; then
1500 DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1501 CPU_ARCH_TAG=_$OS_TEST
1502 if test -z "$USE_64"; then
1505 PR_MD_ASFILES=os_HPUX_ia64.s
1509 PR_MD_ASFILES=os_HPUX.s
1511 if test -n "$USE_64"; then
1512 MDCPUCFG_H=_hpux64.cfg
1514 MDCPUCFG_H=_hpux32.cfg
1516 if test -z "$GNU_CC"; then
1522 ASFLAGS="$ASFLAGS -x assembler-with-cpp"
1525 if test -n "$MOZILLA_CLIENT"; then
1526 DEFAULT_IMPL_STRATEGY=_EMU
1529 if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
1530 AC_DEFINE(_PR_NEED_H_ERRNO)
1532 DEFAULT_IMPL_STRATEGY=_EMU
1536 if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1537 AC_DEFINE(_PR_NO_LARGE_FILES)
1540 if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1541 AC_DEFINE(_PR_NEED_H_ERRNO)
1544 if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1545 AC_DEFINE(HAVE_INT_LOCALTIME_R)
1548 if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1549 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1552 # HP-UX 11i v2 (B.11.23) or higher
1554 case "$OS_RELEASE" in
1555 [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1561 if test "$OS_RELEASE" = "B.10.01"; then
1563 DEFAULT_IMPL_STRATEGY=_EMU
1566 if test "$OS_RELEASE" = "B.10.10"; then
1568 AC_DEFINE(HPUX10_10)
1569 DEFAULT_IMPL_STRATEGY=_PTH
1572 if test "$OS_RELEASE" = "B.10.20"; then
1574 AC_DEFINE(HPUX10_20)
1575 if test -z "$GNU_CC"; then
1576 CFLAGS="$CFLAGS +DAportable +DS1.1"
1577 CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1579 DEFAULT_IMPL_STRATEGY=_PTH
1582 if test "$OS_RELEASE" = "B.10.30"; then
1584 AC_DEFINE(HPUX10_30)
1585 if test -z "$GNU_CC"; then
1586 CFLAGS="$CFLAGS +DAportable +DS1.1"
1587 CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1589 DEFAULT_IMPL_STRATEGY=_PTH
1592 if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1595 AC_DEFINE(_LARGEFILE64_SOURCE)
1596 AC_DEFINE(_PR_HAVE_OFF64_T)
1597 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1598 if test -z "$GNU_CC"; then
1599 if test -z "$USE_64"; then
1600 if test "$OS_TEST" = "ia64"; then
1601 CFLAGS="$CFLAGS +DD32"
1602 CXXFLAGS="$CXXFLAGS +DD32"
1604 CFLAGS="$CFLAGS +DAportable +DS2.0"
1605 CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1608 if test "$OS_TEST" = "ia64"; then
1609 CFLAGS="$CFLAGS +DD64"
1610 CXXFLAGS="$CXXFLAGS +DD64"
1612 CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1613 CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1617 DEFAULT_IMPL_STRATEGY=_PTH
1620 if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1624 elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1626 if test "$USE_NSPR_THREADS"; then
1629 if test "$USE_USER_PTHREADS"; then
1635 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
1636 if test -z "$USE_NSPR_THREADS"; then
1641 AC_DEFINE(_GNU_SOURCE)
1642 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1643 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1645 *-android*|*-linuxandroid*)
1653 CFLAGS="$CFLAGS -Wall"
1654 CXXFLAGS="$CXXFLAGS -Wall"
1655 MDCPUCFG_H=_linux.cfg
1657 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1659 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1661 _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that
1662 # combo is not yet good at debugging inlined
1663 # functions (even when using DWARF2 as the
1666 if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1671 CPU_ARCH_TAG=_${CPU_ARCH}
1672 case "${target_cpu}" in
1676 CFLAGS="$CFLAGS -mieee"
1677 CXXFLAGS="$CXXFLAGS -mieee"
1681 PR_MD_ASFILES=os_Linux_x86.s
1684 PR_MD_ASFILES=os_Linux_ia64.s
1687 if test -n "$USE_64"; then
1688 PR_MD_ASFILES=os_Linux_x86_64.s
1689 elif test -n "$USE_X32"; then
1690 PR_MD_ASFILES=os_Linux_x86_64.s
1695 PR_MD_ASFILES=os_Linux_x86.s
1701 PR_MD_ASFILES=os_Linux_ppc.s
1704 if test -n "$USE_64"; then
1708 PR_MD_ASFILES=os_Linux_ppc.s
1714 *-mingw*|*-msys*|*-cygwin*|*-mks*)
1717 PR_MD_ARCH_DIR=windows
1718 RESOLVE_LINK_SYMBOLS=1
1720 if test -n "$GNU_CC"; then
1722 CXX="$CXX -mwindows"
1724 MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1726 # Use temp file for windres (bug 213281)
1727 RCFLAGS='-O coff --use-temp-file'
1730 AR='lib -NOLOGO -OUT:"$@"'
1732 RANLIB='echo not_ranlib'
1733 STRIP='echo not_strip'
1735 GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1740 # Determine compiler version
1742 _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
1744 CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
1745 if test -z "$CC_VERSION"; then
1746 AC_MSG_ERROR([Could not determine MSC version.])
1749 _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
1750 _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
1751 _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
1752 _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
1753 MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
1755 if test "$_CC_MAJOR_VERSION" -eq "14"; then
1756 dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
1757 dnl so be very specific here!
1758 dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
1759 if test $_CC_RELEASE -gt 50727; then
1761 elif test $_CC_BUILD -ge 762; then
1764 AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
1765 AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
1766 elif test $_CC_MAJOR_VERSION -ge 15; then
1768 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
1769 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
1772 if test -n "$_USE_DYNAMICBASE"; then
1773 DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
1776 # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
1777 # tape manipulation utility (or something else)
1778 if test "$MSC_VER" -ge "1400"; then
1780 _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
1783 MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
1784 if test -n "$MSMT_TOOL"; then
1785 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
1786 if test -z "$MSMANIFEST_TOOL_VERSION"; then
1787 AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
1792 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
1796 CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
1797 DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
1801 PROFILE_GEN_CFLAGS="-GL"
1802 PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
1803 PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
1804 PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
1806 if test "$MSC_VER" -ge "1800"; then
1807 dnl Visual C++ 2013 requires -FS when parallel building with
1808 dnl make -jN. If not specified, compiler sometimes emits C1041
1810 CFLAGS="$CFLAGS -FS"
1811 dnl -Gw can benefit when using linker optimization on PGO.
1812 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1813 PROFILE_GEN_CFLAGS="$PROFILE_GEN_CFLAGS -Gw"
1814 PROFILE_USE_CFLAGS="$PROFILE_USE_CFLAGS -Gw"
1817 if test -z "$MOZ_OPTIMIZE"; then
1818 CFLAGS="$CFLAGS -Od"
1821 if test "$USE_DEBUG_RTL" = 1; then
1822 if test -n "$USE_STATIC_RTL"; then
1823 CFLAGS="$CFLAGS -MTd"
1825 CFLAGS="$CFLAGS -MDd"
1828 if test -n "$USE_STATIC_RTL"; then
1829 CFLAGS="$CFLAGS -MT"
1831 CFLAGS="$CFLAGS -MD"
1835 if test -n "$MOZ_DEBUG"; then
1838 DEFINES="$DEFINES -U_DEBUG"
1841 if test -n "$MOZ_DEBUG_SYMBOLS"; then
1842 if test -n "$MOZ_OPTIMIZE"; then
1843 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
1844 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
1846 DLLFLAGS="$DLLFLAGS -DEBUG"
1847 LDFLAGS="$LDFLAGS -DEBUG"
1851 OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
1852 if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
1853 OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
1856 if test "$OS_TARGET" = "WINNT"; then
1857 CFLAGS="$CFLAGS -GT"
1858 LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1859 LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1861 LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1862 LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1866 if test -n "$USE_STATIC_TLS"; then
1867 AC_DEFINE(_PR_USE_STATIC_TLS)
1870 if test "$OS_TARGET" = "WINNT"; then
1874 # undefine WINNT as some versions of mingw gcc define it by default
1875 DEFINES="$DEFINES -UWINNT"
1876 AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
1879 if test "$CPU_ARCH" = "x86"; then
1882 CPU_ARCH_TAG=$CPU_ARCH
1885 if test "$USE_DEBUG_RTL" = 1; then
1889 case "$OS_TARGET" in
1891 MDCPUCFG_H=_winnt.cfg
1894 MDCPUCFG_H=_win95.cfg
1897 AC_MSG_ERROR([Missing OS_TARGET for ${target}. Use --enable-win32-target to set.])
1901 case "$target_cpu" in
1903 if test -n "$USE_64"; then
1907 if test -z "$GNU_CC" -a "$MSC_VER" -ge "1700"; then
1908 dnl Visual C++ 2012 defaults to -arch:SSE2. Use -arch:IA32
1909 dnl to avoid requiring SSE2.
1910 CFLAGS="$CFLAGS -arch:IA32"
1927 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1935 AC_DEFINE(HAVE_BSD_FLOCK)
1936 AC_DEFINE(HAVE_SOCKLEN_T)
1937 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1938 if test -z "$USE_NSPR_THREADS"; then
1941 MDCPUCFG_H=_netbsd.cfg
1942 PR_MD_CSRCS=netbsd.c
1944 DSO_CFLAGS='-fPIC -DPIC'
1945 CFLAGS="$CFLAGS -ansi -Wall"
1946 CXXFLAGS="$CXXFLAGS -ansi -Wall"
1947 MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1949 if test -z "$OBJECT_FMT"; then
1950 if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
1953 DSO_LDOPTS='-shared'
1957 DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
1961 if test "$LIBRUNPATH"; then
1962 DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
1969 AC_DEFINE(_QNX_SOURCE)
1970 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1973 MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
1976 OS_LIBS="$OS_LIBS -lsocket"
1977 _OPTIMIZE_FLAGS="-O1"
1978 _DEBUG_FLAGS="-gstabs"
1984 AC_DEFINE(HAVE_BSD_FLOCK)
1985 AC_DEFINE(HAVE_SOCKLEN_T)
1986 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1987 CFLAGS="$CFLAGS -ansi -Wall"
1988 CXXFLAGS="$CXXFLAGS -ansi -Wall"
1991 MDCPUCFG_H=_openbsd.cfg
1992 PR_MD_CSRCS=openbsd.c
1994 if test -z "$USE_NSPR_THREADS"; then
1997 DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
1998 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2004 AC_DEFINE(_PR_NEED_H_ERRNO)
2013 AC_DEFINE(_PR_NEED_H_ERRNO)
2015 MDCPUCFG_H=_riscos.cfg
2016 PR_MD_CSRCS=riscos.c
2018 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
2019 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2028 AC_DEFINE(_PR_NEED_H_ERRNO)
2029 CC='cc -b elf -KPIC'
2030 CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
2033 DSO_LDOPTS='-b elf -G'
2034 MDCPUCFG_H=_scoos.cfg
2039 if test -z "$USE_NSPR_THREADS"; then
2048 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2050 MDCPUCFG_H=_solaris.cfg
2051 PR_MD_CSRCS=solaris.c
2053 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2054 RESOLVE_LINK_SYMBOLS=1
2055 case "${OS_RELEASE}" in
2059 # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
2063 if test -n "$GNU_CC"; then
2065 if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
2068 DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore'
2069 if test -n "$USE_B_DIRECT"; then
2070 DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
2074 DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
2075 if test -n "$USE_B_DIRECT"; then
2076 DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
2079 if test -n "$GNU_CC"; then
2080 CFLAGS="$CFLAGS -Wall"
2081 CXXFLAGS="$CXXFLAGS -Wall"
2082 if test -n "$USE_MDUPDATE"; then
2083 CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
2084 CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
2086 GCC_AS=`$CC -print-prog-name=as`
2087 if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
2091 CFLAGS="$CFLAGS -xstrconst"
2092 CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
2093 if test -z "$MOZ_OPTIMIZE"; then
2094 CFLAGS="$CFLAGS -xs"
2095 CXXFLAGS="$CXXFLAGS -xs"
2097 _OPTIMIZE_FLAGS=-xO4
2099 if test -z "$GNU_AS"; then
2100 ASFLAGS="$ASFLAGS -Wa,-P"
2102 if test -n "$USE_64"; then
2103 if test -n "$GNU_CC"; then
2107 if test "$OS_TEST" = "i86pc"; then
2108 CC="$CC -xarch=amd64"
2109 CXX="$CXX -xarch=amd64"
2112 CXX="$CXX -xarch=v9"
2116 if test "$OS_TEST" = "i86pc"; then
2117 if test -z "$USE_64"; then
2120 CPU_ARCH_TAG=_$OS_TEST
2121 # The default debug format, DWARF (-g), is not supported by gcc
2122 # on i386-ANY-sysv4/solaris, but the stabs format is. It is
2123 # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2124 # If your gcc uses GNU as, you do not need the -Wa,-s option.
2125 if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2126 _DEBUG_FLAGS=-gstabs
2127 if test -z "$GNU_AS"; then
2128 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2132 case "${target_os}" in
2134 AC_DEFINE(_PR_NO_LARGE_FILES)
2137 AC_DEFINE(_PR_NO_LARGE_FILES)
2140 AC_DEFINE(SOLARIS2_5)
2143 AC_DEFINE(_PR_HAVE_OFF64_T)
2144 # The lfcompile64(5) man page on Solaris 2.6 says:
2145 # For applications that do not wish to conform to the POSIX or
2146 # X/Open specifications, the 64-bit transitional interfaces
2147 # are available by default. No compile-time flags need to be
2149 # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2150 # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2151 if test -n "$GNU_CC"; then
2152 AC_DEFINE(_LARGEFILE64_SOURCE)
2156 case "${target_os}" in
2168 # Solaris 8 or higher has IPv6.
2169 AC_DEFINE(_PR_INET6)
2172 if test "$CPU_ARCH" = "sparc"; then
2173 # 64-bit Solaris SPARC requires V9 architecture, so the following
2175 if test -z "$USE_64"; then
2176 ULTRASPARC_LIBRARY=nspr_flt
2179 # Purify requires that binaries linked against nspr also
2180 # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2182 _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2183 OS_LIBS="$OS_LIBS $_librt"
2192 if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
2193 AC_DEFINE(_PR_NO_LARGE_FILES)
2194 CC='$(NSDEPTH)/build/hcc cc'
2195 CXX='$(NSDEPTH)/build/hcpp CC'
2196 MDCPUCFG_H=_unixware.cfg
2198 AC_DEFINE(_LARGEFILE64_SOURCE)
2199 AC_DEFINE(_PR_HAVE_OFF64_T)
2200 AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
2201 MDCPUCFG_H=_unixware7.cfg
2203 PR_MD_CSRCS=unixware.c
2211 AC_DEFINE(BSD_SELECT)
2212 AC_DEFINE(TCPV40HDRS)
2220 RESOLVE_LINK_SYMBOLS=1
2225 CFLAGS="$CFLAGS -Wall -Zomf"
2226 CXXFLAGS="$CFLAGS -Wall -Zomf"
2227 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2229 DSO_LDOPTS='-Zomf -Zdll'
2231 _OPTIMIZE_FLAGS="-O2 -s"
2232 _DEBUG_FLAGS="-g -fno-inline"
2233 if test -n "$MOZ_OPTIMIZE"; then
2234 DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2238 if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2239 LDFLAGS="$LDFLAGS -Zhigh-mem"
2240 AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2243 # GCC for OS/2 currently predefines these, but we don't want them
2244 DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
2253 if test -z "$SKIP_LIBRARY_CHECKS"; then
2254 dnl ========================================================
2255 dnl Check for system libraries
2256 dnl ========================================================
2259 dnl We don't want anything to link with libdl even if it's present on OS X,
2260 dnl since it's not used and not part of the default installation.
2261 dnl The same goes for BeOS.
2262 dnl OS/2 has dlfcn in libc.
2268 AC_CHECK_LIB(dl, dlopen,
2269 [AC_CHECK_HEADER(dlfcn.h,
2270 OS_LIBS="-ldl $OS_LIBS")])
2275 dnl ========================================================
2276 dnl Check for system header files.
2277 dnl ========================================================
2279 dnl ========================================================
2280 dnl Check for typedefs and structs
2281 dnl ========================================================
2283 dnl ========================================================
2284 dnl Checks for library functions.
2285 dnl ========================================================
2286 AC_PROG_GCC_TRADITIONAL
2288 LIBS="$LIBS $OS_LIBS"
2289 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
2290 secure_getenv __secure_getenv)
2293 dnl ========================================================
2295 dnl ========================================================
2297 dnl ======================================================
2298 dnl = Enable compiling with ccache
2299 dnl ======================================================
2301 [ --with-ccache[=path/to/ccache]
2302 Enable compiling with ccache],
2303 CCACHE=$withval, CCACHE="no")
2305 if test "$CCACHE" != "no"; then
2306 if test -n "$CCACHE"; then
2307 if test "$CCACHE" = "yes"; then
2310 if test ! -e "$CCACHE"; then
2311 AC_MSG_ERROR([$CCACHE not found])
2315 AC_PATH_PROGS(CCACHE, $CCACHE ccache)
2316 if test -z "$CCACHE" -o "$CCACHE" = ":"; then
2317 AC_MSG_ERROR([ccache not found])
2318 elif test -x "$CCACHE"; then
2322 AC_MSG_ERROR([$CCACHE is not executable])
2326 dnl ========================================================
2328 dnl = --enable-strip
2330 dnl = Enable stripping of libs and executables
2332 dnl ========================================================
2333 AC_ARG_ENABLE(strip,
2334 [ --enable-strip Enable stripping of shared libs and programs],
2335 [ if test "$enableval" = "yes"; then
2339 dnl Check for hpux options
2340 case "${target_os}" in
2342 if test -z "$GNU_CC"; then
2344 AC_CACHE_CHECK(for +Olit support,
2345 ac_cv_hpux_usable_olit_option,
2346 dnl since aCC doesn't throw an error on invalid options,
2347 dnl we have to test this the hard way
2348 [ac_cv_hpux_usable_olit_option=no
2350 echo 'int main() { return 0; }' | cat > conftest.c
2351 ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2352 if test $? -eq 0; then
2353 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2354 ac_cv_hpux_usable_olit_option=yes
2360 if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2361 CFLAGS="$CFLAGS +Olit=all"
2362 CXXFLAGS="$CXXFLAGS +Olit=all"
2364 CFLAGS="$CFLAGS +ESlit"
2365 CXXFLAGS="$CXXFLAGS +ESlit"
2371 case "$target_os" in
2376 AC_CHECK_LIB(pthreads, pthread_create,
2377 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2378 AC_CHECK_LIB(pthread, pthread_create,
2379 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2380 AC_CHECK_LIB(c_r, pthread_create,
2381 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2382 AC_CHECK_LIB(c, pthread_create,
2391 AC_ARG_WITH(pthreads,
2392 [ --with-pthreads Use system pthreads library as thread subsystem],
2393 [ if test "$withval" = "yes"; then
2394 if test -n "$_HAVE_PTHREADS"; then
2399 AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2405 [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2411 AC_ARG_ENABLE(user-pthreads,
2412 [ --enable-user-pthreads Build using userland pthreads],
2413 [ if test "$enableval" = "yes"; then
2414 if test -n "$_HAVE_PTHREADS"; then
2419 AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2423 AC_ARG_ENABLE(nspr-threads,
2424 [ --enable-nspr-threads Build using classic nspr threads],
2425 [ if test "$enableval" = "yes"; then
2431 fi # SKIP_LIBRARY_CHECKS
2434 [ --enable-ipv6 Compile ipv6 support],
2435 [ if test "$enableval" = "yes"; then
2441 if test -n "$USE_PTHREADS"; then
2442 dnl See if -pthread is supported.
2444 ac_cv_have_dash_pthread=no
2445 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2446 echo 'int main() { return 0; }' | cat > conftest.c
2447 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2448 if test $? -eq 0; then
2449 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2450 ac_cv_have_dash_pthread=yes
2451 case "$target_os" in
2453 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2456 CFLAGS="$CFLAGS -pthread"
2457 CXXFLAGS="$CXXFLAGS -pthread"
2463 AC_MSG_RESULT($ac_cv_have_dash_pthread)
2466 dnl See if -pthreads is supported.
2468 ac_cv_have_dash_pthreads=no
2469 if test "$ac_cv_have_dash_pthread" = "no"; then
2470 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2471 echo 'int main() { return 0; }' | cat > conftest.c
2472 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2473 if test $? -eq 0; then
2474 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2475 ac_cv_have_dash_pthreads=yes
2476 CFLAGS="$CFLAGS -pthreads"
2477 CXXFLAGS="$CXXFLAGS -pthreads"
2481 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2486 if test "$ac_cv_have_dash_pthreads" = "yes"; then
2491 AC_DEFINE(_REENTRANT)
2492 AC_DEFINE(_THREAD_SAFE)
2493 dnl -pthread links in -lc_r, so don't specify it explicitly.
2494 if test "$ac_cv_have_dash_pthread" = "yes"; then
2495 _PTHREAD_LDFLAGS="-pthread"
2497 _PTHREAD_LDFLAGS="-lc_r"
2501 if test "$ac_cv_have_dash_pthread" = "yes"; then
2502 _PTHREAD_LDFLAGS="-pthread"
2506 AC_DEFINE(_THREAD_SAFE)
2507 dnl -pthread links in -lc_r, so don't specify it explicitly.
2508 if test "$ac_cv_have_dash_pthread" = "yes"; then
2513 if test "$ac_cv_have_dash_pthread" = "yes"; then
2514 _PTHREAD_LDFLAGS=-pthread
2517 *-linux*|*-gnu*|*-k*bsd*-gnu)
2518 AC_DEFINE(_REENTRANT)
2523 if test -n "$USE_USER_PTHREADS"; then
2530 dnl Special thread exceptions
2534 if test -n "$USE_NSPR_THREADS"; then
2535 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2537 case "$target_os" in
2539 if test -z "$USE_PTHREADS"; then
2540 AC_DEFINE(AIX_RENAME_SELECT)
2544 if test -z "$USE_NSPR_THREADS"; then
2545 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2549 if test -z "$USE_NSPR_THREADS"; then
2550 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2552 if test -n "$USE_PTHREADS"; then
2553 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2557 if test -z "$USE_NSPR_THREADS"; then
2558 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2560 if test -n "$USE_PTHREADS"; then
2561 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2567 if test -n "$USE_PTHREADS"; then
2568 AC_DEFINE(_PR_NEED_PTHREAD_INIT)
2572 if test -n "$USE_NSPR_THREADS"; then
2573 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2577 if test -n "$USE_NSPR_THREADS"; then
2578 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2580 if test "$USE_PTHREADS"; then
2581 AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2582 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2584 if test "$USE_USER_PTHREADS"; then
2585 AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2588 *-linux*|*-gnu*|*-k*bsd*-gnu)
2589 if test -n "$USE_NSPR_THREADS"; then
2590 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2593 *-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*)
2594 dnl win32, os2 cannot use pthreads
2599 *-netbsd*|*-openbsd*)
2600 if test -n "$USE_NSPR_THREADS"; then
2601 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2605 if test -n "$USE_NSPR_THREADS"; then
2606 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2608 if test -n "$USE_PTHREADS"; then
2609 AC_DEFINE(_REENTRANT)
2610 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2611 if test "$OS_TEST" = "i86pc"; then
2612 if test -n "$USE_64"; then
2613 PR_MD_ASFILES=os_SunOS_x86_64.s
2615 PR_MD_ASFILES=os_SunOS_x86.s
2618 if test -n "$USE_64"; then
2619 PR_MD_ASFILES=os_SunOS_sparcv9.s
2625 if test -n "$USE_PTHREADS"; then
2626 AC_DEFINE(_PR_HAVE_GETHOST_R)
2627 AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2632 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2634 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2635 dnl make sure that we use it.
2636 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2637 _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2640 if test -n "$_SAVE_DEBUG_FLAGS"; then
2641 _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2644 if test -n "$MOZ_OPTIMIZE"; then
2645 CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2646 CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2649 if test -n "$MOZ_DEBUG_SYMBOLS"; then
2650 CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2651 CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2654 if test -n "$MOZ_OPTIMIZE"; then
2660 if test -n "$USE_64"; then
2664 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2666 dnl ========================================================
2667 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2668 dnl ========================================================
2669 case "$target_os" in
2671 CC="\$(CYGWIN_WRAPPER) $CC"
2672 CXX="\$(CYGWIN_WRAPPER) $CXX"
2673 RC="\$(CYGWIN_WRAPPER) $RC"
2677 dnl ========================================================
2678 dnl = Use malloc wrapper lib
2679 dnl ========================================================
2680 AC_ARG_ENABLE(wrap-malloc,
2681 [ --enable-wrap-malloc Wrap malloc calls (gnu linker only)],
2682 [ if test "$enableval" = "yes"; then
2686 if test -n "$_WRAP_MALLOC"; then
2687 if test -n "$GNU_CC"; then
2688 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
2689 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
2690 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
2691 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
2693 AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
2697 dnl ========================================================
2698 dnl = Location of malloc wrapper lib
2699 dnl ========================================================
2700 AC_ARG_WITH(wrap-malloc,
2701 [ --with-wrap-malloc=SHAREDLIB Location of malloc wrapper library],
2702 WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
2704 dnl ========================================================
2705 dnl Substitution of found variables.
2706 dnl ========================================================
2707 AC_SUBST(SHELL_OVERRIDE)
2709 AC_SUBST(MOZILLA_CLIENT)
2716 AC_SUBST(HOST_CFLAGS)
2718 AC_SUBST(HOST_LDFLAGS)
2720 AC_SUBST(GCC_USE_GNU_LD)
2722 AC_SUBST(CROSS_COMPILE)
2724 AC_SUBST(MOZ_OPTIMIZE)
2726 AC_SUBST(MOZ_DEBUG_SYMBOLS)
2733 AC_SUBST(OBJECT_MODE)
2734 AC_SUBST(ENABLE_STRIP)
2736 AC_SUBST(USE_PTHREADS)
2737 AC_SUBST(USE_BTHREADS)
2738 AC_SUBST(USE_USER_PTHREADS)
2739 AC_SUBST(USE_NSPR_THREADS)
2744 AC_SUBST(MOD_MAJOR_VERSION)
2745 AC_SUBST(MOD_MINOR_VERSION)
2746 AC_SUBST(MOD_PATCH_VERSION)
2747 AC_SUBST(NSPR_MODNAME)
2748 AC_SUBST(MDCPUCFG_H)
2749 AC_SUBST(PR_MD_CSRCS)
2750 AC_SUBST(PR_MD_ASFILES)
2751 AC_SUBST(PR_MD_ARCH_DIR)
2754 AC_SUBST(OBJ_SUFFIX)
2755 AC_SUBST(LIB_SUFFIX)
2756 AC_SUBST(DLL_SUFFIX)
2757 AC_SUBST(ASM_SUFFIX)
2758 AC_SUBST(WRAP_LDFLAGS)
2760 AC_SUBST(DSO_CFLAGS)
2761 AC_SUBST(DSO_LDOPTS)
2765 AC_SUBST(OS_RELEASE)
2767 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
2782 AC_SUBST(PROFILE_GEN_CFLAGS)
2783 AC_SUBST(PROFILE_GEN_LDFLAGS)
2784 AC_SUBST(PROFILE_USE_CFLAGS)
2785 AC_SUBST(PROFILE_USE_LDFLAGS)
2788 AC_SUBST(RESOLVE_LINK_SYMBOLS)
2789 AC_SUBST(AIX_LINK_OPTS)
2790 AC_SUBST(NOSUCHFILE)
2791 AC_SUBST(MOZ_OBJFORMAT)
2792 AC_SUBST(ULTRASPARC_LIBRARY)
2795 AC_SUBST(OBJDIR_NAME)
2796 AC_SUBST(RELEASE_OBJDIR_NAME)
2803 AC_SUBST(OS_DLLFLAGS)
2804 AC_SUBST(CYGWIN_WRAPPER)
2805 AC_SUBST(VISIBILITY_FLAGS)
2806 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2807 AC_SUBST(MACOS_SDK_DIR)
2811 dnl ========================================================
2812 dnl Generate output files.
2813 dnl ========================================================
2825 lib/libc/include/Makefile
2826 lib/libc/src/Makefile
2831 pr/include/md/Makefile
2832 pr/include/obsolete/Makefile
2833 pr/include/private/Makefile
2836 pr/src/linking/Makefile
2837 pr/src/malloc/Makefile
2839 pr/src/md/${PR_MD_ARCH_DIR}/Makefile
2840 pr/src/memory/Makefile
2841 pr/src/misc/Makefile
2842 pr/src/threads/Makefile
2844 pr/tests/dll/Makefile
2847 if test "$OS_TARGET" = "Linux"; then
2848 MAKEFILES="$MAKEFILES
2851 elif test "$OS_TARGET" = "SunOS"; then
2852 MAKEFILES="$MAKEFILES
2853 pkg/solaris/Makefile
2854 pkg/solaris/SUNWpr/Makefile
2855 pkg/solaris/SUNWprd/Makefile
2859 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
2860 MAKEFILES="$MAKEFILES
2861 pr/src/threads/combined/Makefile
2863 elif test -n "$USE_PTHREADS"; then
2864 MAKEFILES="$MAKEFILES
2865 pr/src/pthreads/Makefile
2867 elif test -n "$USE_BTHREADS"; then
2868 MAKEFILES="$MAKEFILES
2869 pr/src/bthreads/Makefile
2873 if test -n "$USE_CPLUS"; then
2874 MAKEFILES="$MAKEFILES
2875 pr/src/cplus/Makefile
2876 pr/src/cplus/tests/Makefile
2880 echo $MAKEFILES > unallmakefiles
2882 AC_CONFIG_FILES([$MAKEFILES])
2883 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])