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(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.3 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 cygwin*) OS_ARCH=WINNT ;;
825 darwin*) OS_ARCH=Darwin ;;
826 riscos*) OS_ARCH=RISCOS ;;
829 OS_ARCH=`uname -s | sed -e 's|/|_|g'`
830 OS_RELEASE=`uname -r`
834 if test "$OS_ARCH" = "AIX"; then
835 OS_RELEASE=`uname -v`.`uname -r`
838 if test "$OS_ARCH" = "FreeBSD"; then
839 OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
842 if test "$OS_ARCH" = "Linux"; then
843 OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
844 OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
847 #######################################################################
848 # Master "Core Components" macros for getting the OS target #
849 #######################################################################
852 # Note: OS_TARGET should be specified on the command line for gmake.
853 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
854 # The difference between the Win95 target and the WinNT target is that
855 # the WinNT target uses Windows NT specific features not available
856 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
857 # at lesser performance (the Win95 target uses threads; the WinNT target
860 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
865 # The following hack allows one to build on a WIN95 machine (as if
866 # s/he were cross-compiling on a WINNT host for a WIN95 target).
867 # It also accomodates for MKS's uname.exe. If you never intend
868 # to do development on a WIN95 machine, you don't need this hack.
879 CYGWIN_9*|CYGWIN_ME*)
880 OS_ARCH='CYGWIN_NT-4.0'
890 # On WIN32, we also define the variable CPU_ARCH.
896 # If uname -s returns "Windows_NT", we assume that we are using
897 # the uname.exe in MKS toolkit.
899 # The -r option of MKS uname only returns the major version number.
900 # So we need to use its -v option to get the minor version number.
901 # Moreover, it doesn't have the -p option, so we need to use uname -m.
904 OS_MINOR_RELEASE=`uname -v`
905 if test "$OS_MINOR_RELEASE" = "00"; then
908 OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
911 # MKS's uname -m returns "586" on a Pentium machine.
913 if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
917 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
919 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
920 # the uname.exe in the Cygwin tools.
921 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
922 # the uname.exe in the MSYS tools.
923 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
924 # the uname.exe in the MSYS2 tools.
926 OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
930 # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
932 if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
938 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
940 if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
944 if test -z "$OS_TARGET"; then
947 if test "$OS_TARGET" = "WIN95"; then
950 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
952 dnl ========================================================
953 dnl Enable high-memory support on OS/2 by default.
954 dnl ========================================================
955 AC_ARG_ENABLE(os2-high-mem,
956 [ --disable-os2-high-mem Disable high-memory support on OS/2],
957 [ if test "$enableval" = "no"; then
960 MOZ_OS2_HIGH_MEMORY=1
963 dnl ========================================================
964 dnl = ARM toolchain tweaks
965 dnl ========================================================
968 MOZ_ALIGN=toolchain-default
971 arm*-android*|arm*-linuxandroid*)
980 if test -n "$MOZ_PLATFORM_MAEMO"; then
985 if test "$MOZ_PLATFORM_MAEMO" = 6; then
991 dnl Kept for compatibility with some buildbot mozconfig
992 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
995 [ --with-thumb[[=yes|no|toolchain-default]]]
996 [ Use Thumb instruction set (-mthumb)],
997 if test -z "$GNU_CC"; then
998 AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
1002 AC_ARG_WITH(thumb-interwork,
1003 [ --with-thumb-interwork[[=yes|no|toolchain-default]]
1004 Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
1005 if test -z "$GNU_CC"; then
1006 AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
1008 MOZ_THUMB_INTERWORK=$withval)
1011 [ --with-arch=[[type|toolchain-default]]
1012 Use specific CPU features (-march=type)],
1013 if test -z "$GNU_CC"; then
1014 AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
1019 [ --with-fpu=[[type|toolchain-default]]
1020 Use specific FPU type (-mfpu=type)],
1021 if test -z "$GNU_CC"; then
1022 AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
1026 AC_ARG_WITH(float-abi,
1027 [ --with-float-abi=[[type|toolchain-default]]
1028 Use specific arm float ABI (-mfloat-abi=type)],
1029 if test -z "$GNU_CC"; then
1030 AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
1032 MOZ_FLOAT_ABI=$withval)
1034 AC_ARG_WITH(soft-float,
1035 [ --with-soft-float[[=yes|no|toolchain-default]]
1036 Use soft float library (-msoft-float)],
1037 if test -z "$GNU_CC"; then
1038 AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
1040 MOZ_SOFT_FLOAT=$withval)
1043 toolchain-default|"")
1047 arch_flag="-march=$MOZ_ARCH"
1051 case "$MOZ_THUMB" in
1054 thumb_flag="-mthumb"
1061 _SAVE_CFLAGS="$CFLAGS"
1063 AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1066 CFLAGS="$_SAVE_CFLAGS"
1071 case "$MOZ_THUMB_INTERWORK" in
1073 thumb_interwork_flag="-mthumb-interwork"
1076 thumb_interwork_flag="-mno-thumb-interwork"
1078 *) # toolchain-default
1079 thumb_interwork_flag=""
1084 toolchain-default|"")
1088 fpu_flag="-mfpu=$MOZ_FPU"
1092 case "$MOZ_FLOAT_ABI" in
1093 toolchain-default|"")
1097 float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1101 case "$MOZ_SOFT_FLOAT" in
1103 soft_float_flag="-msoft-float"
1106 soft_float_flag="-mno-soft-float"
1108 *) # toolchain-default
1113 case "$MOZ_ALIGN" in
1114 toolchain-default|"")
1118 align_flag="-mno-unaligned-access"
1121 align_flag="-munaligned-access"
1128 if test -n "$align_flag"; then
1129 _SAVE_CFLAGS="$CFLAGS"
1130 CFLAGS="$CFLAGS $align_flag"
1131 AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
1132 AC_TRY_COMPILE([],[],,align_flag="")
1133 CFLAGS="$_SAVE_CFLAGS"
1136 dnl Use echo to avoid accumulating space characters
1137 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
1138 if test -n "$all_flags"; then
1139 _SAVE_CFLAGS="$CFLAGS"
1141 AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1142 AC_TRY_COMPILE([],[return 0;],
1143 AC_MSG_RESULT([yes]),
1146 CFLAGS="$_SAVE_CFLAGS $all_flags"
1147 CXXFLAGS="$CXXFLAGS $all_flags"
1148 ASFLAGS="$ASFLAGS $all_flags"
1149 if test -n "$thumb_flag"; then
1150 LDFLAGS="$LDFLAGS $thumb_flag"
1154 dnl ========================================================
1155 dnl Override of system specific host options
1156 dnl ========================================================
1162 NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
1163 if test `echo "${PATH}" | grep -c \;` = 0; then
1164 CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
1170 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1174 dnl ========================================================
1175 dnl Override of system specific target options
1176 dnl ========================================================
1183 DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
1184 AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
1185 case "${target_os}" in
1187 AC_DEFINE(AIX_RENAME_SELECT)
1188 AC_DEFINE(_PR_NO_LARGE_FILES)
1189 AIX_LINK_OPTS='-bnso -berok'
1190 PR_MD_ASFILES=os_AIX.s
1193 AC_DEFINE(AIX_TIMERS)
1194 AC_DEFINE(_PR_NO_LARGE_FILES)
1198 AIX_LINK_OPTS='-bnso -berok'
1199 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
1200 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
1203 AC_DEFINE(AIX_TIMERS)
1204 AC_DEFINE(_PR_HAVE_OFF64_T)
1205 AIX_LINK_OPTS='-brtl -bnso -berok'
1208 AC_DEFINE(AIX_TIMERS)
1209 AC_DEFINE(_PR_HAVE_OFF64_T)
1210 AC_DEFINE(AIX4_3_PLUS)
1211 AC_DEFINE(HAVE_SOCKLEN_T)
1212 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1214 AIX_LINK_OPTS='-brtl -bnso -berok'
1217 AC_DEFINE(AIX_TIMERS)
1218 AC_DEFINE(_PR_HAVE_OFF64_T)
1219 AC_DEFINE(AIX4_3_PLUS)
1220 AC_DEFINE(HAVE_SOCKLEN_T)
1221 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1223 AIX_LINK_OPTS='-brtl -bnso -berok'
1226 CFLAGS="$CFLAGS -qro -qroconst"
1227 AIX_WRAP='$(DIST)/lib/aixwrap.o'
1228 AIX_TMP='./_aix_tmp.o'
1229 if test -n "$USE_64"; then
1230 MDCPUCFG_H=_aix64.cfg
1233 MDCPUCFG_H=_aix32.cfg
1236 RESOLVE_LINK_SYMBOLS=1
1242 AC_DEFINE(NEED_BSDREGEX)
1244 CFLAGS="$CFLAGS -Wall -Wno-format"
1245 CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
1247 if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1249 elif echo "$OS_TEST" | grep -c sparc >/dev/null; then
1253 MDCPUCFG_H=_bsdi.cfg
1258 case "$target_os" in
1260 AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1261 AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
1262 AC_DEFINE(_PR_NEED_H_ERRNO)
1269 AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
1270 AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
1272 AC_DEFINE(USE_DLFCN)
1273 AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1274 PR_MD_ASFILES=os_BSD_OS_386_2.s
1278 AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1279 AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1281 AC_DEFINE(USE_DLFCN)
1282 AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1283 MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1285 DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
1287 case "$target_os" in
1288 bsdi4.2* | bsdi4.3* | bsdi5.*)
1289 AC_DEFINE(_PR_HAVE_GETPROTO_R)
1290 AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1295 AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
1296 AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
1298 AC_DEFINE(USE_DLFCN)
1299 AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
1308 AC_DEFINE(HAVE_BSD_FLOCK)
1309 AC_DEFINE(HAVE_SOCKLEN_T)
1310 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1312 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1314 if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
1315 AC_DEFINE(HAS_CONNECTX)
1317 AS='$(CC) -x assembler-with-cpp'
1318 CFLAGS="$CFLAGS -Wall -fno-common"
1319 case "${target_cpu}" in
1324 if test -n "$USE_64"; then
1337 if test "`echo $CC | grep -c '\-arch '`" = "0"; then
1340 CC="$CC -arch arm64"
1343 CC="$CC -arch $CPU_ARCH"
1347 AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
1349 DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1351 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1352 STRIP="$STRIP -x -S"
1355 MDCPUCFG_H=_darwin.cfg
1356 PR_MD_CSRCS=darwin.c
1357 PR_MD_ASFILES=os_Darwin.s
1359 if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1360 dnl Use the specified value
1361 export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1362 elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1363 dnl No value specified on the command line or in the environment,
1364 dnl use the lesser of the library's minimum or the architecture's
1366 case "${target_cpu}" in
1368 dnl Architecture minimum 10.3
1369 export MACOSX_DEPLOYMENT_TARGET=10.3
1372 dnl Architecture minimum 10.4
1373 export MACOSX_DEPLOYMENT_TARGET=10.4
1378 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1379 dnl in use. NEXT_ROOT will be set and exported if it's needed for
1382 if test "$MACOS_SDK_DIR"; then
1383 dnl Sync this section with the one in Mozilla's top level.
1385 if test ! -d "$MACOS_SDK_DIR"; then
1386 AC_MSG_ERROR([SDK not found. When using --with-macos-sdk, you must
1387 specify a valid SDK. SDKs are installed when the optional cross-development
1388 tools are selected during the Xcode/Developer Tools installation.])
1392 CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1393 GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1394 GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1396 GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1397 if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1398 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1399 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1400 SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1403 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1405 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1407 dnl CPP needs to be set for AC_CHECK_HEADER.
1408 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1411 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1413 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1414 dnl The build host is running Tiger (10.4) or earlier.
1415 dnl ld support for -syslibroot is compiler-agnostic, but
1416 dnl only available on Tiger and later. On Tiger and
1417 dnl earlier build hosts, just rely on NEXT_ROOT, because
1418 dnl it's not been shown to cause any problems.
1419 MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}"
1421 dnl The build host is running Leopard (10.5) or later.
1422 dnl With NEXT_ROOT set, the linker will still not apply
1423 dnl it when resolving dependencies. This causes problems
1424 dnl on Leopard, where an SDK depends on frameworks which
1425 dnl were present in earlier OS releases (and the associated
1426 dnl SDK) but not in Leopard. -syslibroot does not have
1427 dnl this problem, but it results in harmless warnings when
1428 dnl NEXT_ROOT is set. NEXT_ROOT needs to remain set even
1429 dnl on Leopard because the compiler uses it too.
1430 MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1433 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1434 export NEXT_ROOT=$MACOS_SDK_DIR
1436 if test -n "$CROSS_COMPILE" ; then
1437 dnl NEXT_ROOT will be in the environment, but it
1438 dnl shouldn't be set for the build host. HOST_CXX is
1439 dnl presently unused.
1440 HOST_CC="NEXT_ROOT= $HOST_CC"
1441 HOST_CXX="NEXT_ROOT= $HOST_CXX"
1444 dnl gcc >= 4.0 uses different paths than above, but knows
1445 dnl how to find them itself.
1446 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1448 dnl CPP needs to be set for AC_CHECK_HEADER.
1449 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1451 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1452 dnl has an ld that supports -syslibroot. Don't set
1453 dnl NEXT_ROOT because it will be ignored and cause
1454 dnl warnings when -syslibroot is specified.
1455 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1456 dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1457 dnl based on the -isysroot it receives.
1458 LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1460 dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1462 LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1469 if test -z "$USE_NSPR_THREADS"; then
1474 AC_DEFINE(HAVE_BSD_FLOCK)
1475 AC_DEFINE(HAVE_SOCKLEN_T)
1476 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1477 CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1478 MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1479 if test "$MOZ_OBJFORMAT" = "elf"; then
1484 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1486 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1487 MDCPUCFG_H=_freebsd.cfg
1488 PR_MD_CSRCS=freebsd.c
1494 AC_DEFINE(_HPUX_SOURCE)
1495 # HPUX report the POLLHUP event for a socket when the
1496 # shutdown(SHUT_WR) operation is called for the remote end, even though
1497 # the socket is still writeable. Use select(), instead of poll(), to
1498 # workaround this problem.
1499 AC_DEFINE(_PR_POLL_WITH_SELECT)
1500 AC_DEFINE(_USE_BIG_FDS)
1501 DSO_LDOPTS='-b +h $(notdir $@)'
1503 if test "$OS_TEST" = "ia64"; then
1505 DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1506 CPU_ARCH_TAG=_$OS_TEST
1507 if test -z "$USE_64"; then
1510 PR_MD_ASFILES=os_HPUX_ia64.s
1514 PR_MD_ASFILES=os_HPUX.s
1516 if test -n "$USE_64"; then
1517 MDCPUCFG_H=_hpux64.cfg
1519 MDCPUCFG_H=_hpux32.cfg
1521 if test -z "$GNU_CC"; then
1527 ASFLAGS="$ASFLAGS -x assembler-with-cpp"
1530 if test -n "$MOZILLA_CLIENT"; then
1531 DEFAULT_IMPL_STRATEGY=_EMU
1534 if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
1535 AC_DEFINE(_PR_NEED_H_ERRNO)
1537 DEFAULT_IMPL_STRATEGY=_EMU
1541 if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1542 AC_DEFINE(_PR_NO_LARGE_FILES)
1545 if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1546 AC_DEFINE(_PR_NEED_H_ERRNO)
1549 if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1550 AC_DEFINE(HAVE_INT_LOCALTIME_R)
1553 if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1554 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1557 # HP-UX 11i v2 (B.11.23) or higher
1559 case "$OS_RELEASE" in
1560 [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1566 if test "$OS_RELEASE" = "B.10.01"; then
1568 DEFAULT_IMPL_STRATEGY=_EMU
1571 if test "$OS_RELEASE" = "B.10.10"; then
1573 AC_DEFINE(HPUX10_10)
1574 DEFAULT_IMPL_STRATEGY=_PTH
1577 if test "$OS_RELEASE" = "B.10.20"; then
1579 AC_DEFINE(HPUX10_20)
1580 if test -z "$GNU_CC"; then
1581 CFLAGS="$CFLAGS +DAportable +DS1.1"
1582 CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1584 DEFAULT_IMPL_STRATEGY=_PTH
1587 if test "$OS_RELEASE" = "B.10.30"; then
1589 AC_DEFINE(HPUX10_30)
1590 if test -z "$GNU_CC"; then
1591 CFLAGS="$CFLAGS +DAportable +DS1.1"
1592 CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1594 DEFAULT_IMPL_STRATEGY=_PTH
1597 if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1600 AC_DEFINE(_LARGEFILE64_SOURCE)
1601 AC_DEFINE(_PR_HAVE_OFF64_T)
1602 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1603 if test -z "$GNU_CC"; then
1604 if test -z "$USE_64"; then
1605 if test "$OS_TEST" = "ia64"; then
1606 CFLAGS="$CFLAGS +DD32"
1607 CXXFLAGS="$CXXFLAGS +DD32"
1609 CFLAGS="$CFLAGS +DAportable +DS2.0"
1610 CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1613 if test "$OS_TEST" = "ia64"; then
1614 CFLAGS="$CFLAGS +DD64"
1615 CXXFLAGS="$CXXFLAGS +DD64"
1617 CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1618 CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1622 DEFAULT_IMPL_STRATEGY=_PTH
1625 if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1629 elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1631 if test "$USE_NSPR_THREADS"; then
1634 if test "$USE_USER_PTHREADS"; then
1640 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
1641 if test -z "$USE_NSPR_THREADS"; then
1646 AC_DEFINE(_GNU_SOURCE)
1647 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1648 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1650 *-android*|*-linuxandroid*)
1658 CFLAGS="$CFLAGS -Wall"
1659 CXXFLAGS="$CXXFLAGS -Wall"
1660 MDCPUCFG_H=_linux.cfg
1662 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1664 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1666 _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that
1667 # combo is not yet good at debugging inlined
1668 # functions (even when using DWARF2 as the
1671 if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1676 CPU_ARCH_TAG=_${CPU_ARCH}
1677 case "${target_cpu}" in
1681 CFLAGS="$CFLAGS -mieee"
1682 CXXFLAGS="$CXXFLAGS -mieee"
1686 PR_MD_ASFILES=os_Linux_x86.s
1689 PR_MD_ASFILES=os_Linux_ia64.s
1692 if test -n "$USE_64"; then
1693 PR_MD_ASFILES=os_Linux_x86_64.s
1694 elif test -n "$USE_X32"; then
1695 PR_MD_ASFILES=os_Linux_x86_64.s
1700 PR_MD_ASFILES=os_Linux_x86.s
1706 PR_MD_ASFILES=os_Linux_ppc.s
1709 if test -n "$USE_64"; then
1713 PR_MD_ASFILES=os_Linux_ppc.s
1719 *-mingw*|*-msys*|*-cygwin*|*-mks*)
1722 PR_MD_ARCH_DIR=windows
1723 RESOLVE_LINK_SYMBOLS=1
1725 if test -n "$GNU_CC"; then
1727 CXX="$CXX -mwindows"
1729 MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1731 # Use temp file for windres (bug 213281)
1732 RCFLAGS='-O coff --use-temp-file'
1735 AR='lib -NOLOGO -OUT:"$@"'
1737 RANLIB='echo not_ranlib'
1738 STRIP='echo not_strip'
1740 GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1745 # Determine compiler version
1747 _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
1749 CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
1750 if test -z "$CC_VERSION"; then
1751 AC_MSG_ERROR([Could not determine MSC version.])
1754 _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
1755 _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
1756 _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
1757 _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
1758 MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
1760 if test "$_CC_MAJOR_VERSION" -eq "14"; then
1761 dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
1762 dnl so be very specific here!
1763 dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
1764 if test $_CC_RELEASE -gt 50727; then
1766 elif test $_CC_BUILD -ge 762; then
1769 AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
1770 AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
1771 elif test $_CC_MAJOR_VERSION -ge 15; then
1773 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
1774 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
1777 if test -n "$_USE_DYNAMICBASE"; then
1778 DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
1781 # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
1782 # tape manipulation utility (or something else)
1783 if test "$MSC_VER" -ge "1400"; then
1785 _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
1788 MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
1789 if test -n "$MSMT_TOOL"; then
1790 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
1791 if test -z "$MSMANIFEST_TOOL_VERSION"; then
1792 AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
1797 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
1801 CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
1802 DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
1806 PROFILE_GEN_CFLAGS="-GL"
1807 PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
1808 PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
1809 PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
1811 if test "$MSC_VER" -ge "1800"; then
1812 dnl Visual C++ 2013 requires -FS when parallel building with
1813 dnl make -jN. If not specified, compiler sometimes emits C1041
1815 CFLAGS="$CFLAGS -FS"
1816 dnl -Gw can benefit when using linker optimization on PGO.
1817 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1818 PROFILE_GEN_CFLAGS="$PROFILE_GEN_CFLAGS -Gw"
1819 PROFILE_USE_CFLAGS="$PROFILE_USE_CFLAGS -Gw"
1822 if test -z "$MOZ_OPTIMIZE"; then
1823 CFLAGS="$CFLAGS -Od"
1826 if test "$USE_DEBUG_RTL" = 1; then
1827 if test -n "$USE_STATIC_RTL"; then
1828 CFLAGS="$CFLAGS -MTd"
1830 CFLAGS="$CFLAGS -MDd"
1833 if test -n "$USE_STATIC_RTL"; then
1834 CFLAGS="$CFLAGS -MT"
1836 CFLAGS="$CFLAGS -MD"
1840 if test -n "$MOZ_DEBUG"; then
1843 DEFINES="$DEFINES -U_DEBUG"
1846 if test -n "$MOZ_DEBUG_SYMBOLS"; then
1847 if test -n "$MOZ_OPTIMIZE"; then
1848 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
1849 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
1851 DLLFLAGS="$DLLFLAGS -DEBUG"
1852 LDFLAGS="$LDFLAGS -DEBUG"
1856 OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
1857 if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
1858 OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
1861 if test "$OS_TARGET" = "WINNT"; then
1862 CFLAGS="$CFLAGS -GT"
1863 LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1864 LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1866 LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1867 LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1871 if test -n "$USE_STATIC_TLS"; then
1872 AC_DEFINE(_PR_USE_STATIC_TLS)
1875 if test "$OS_TARGET" = "WINNT"; then
1879 # undefine WINNT as some versions of mingw gcc define it by default
1880 DEFINES="$DEFINES -UWINNT"
1881 AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
1884 if test "$CPU_ARCH" = "x86"; then
1887 CPU_ARCH_TAG=$CPU_ARCH
1890 if test "$USE_DEBUG_RTL" = 1; then
1894 case "$OS_TARGET" in
1896 MDCPUCFG_H=_winnt.cfg
1899 MDCPUCFG_H=_win95.cfg
1902 AC_MSG_ERROR([Missing OS_TARGET for ${target}. Use --enable-win32-target to set.])
1906 case "$target_cpu" in
1908 if test -n "$USE_64"; then
1912 if test -z "$GNU_CC" -a "$MSC_VER" -ge "1700"; then
1913 dnl Visual C++ 2012 defaults to -arch:SSE2. Use -arch:IA32
1914 dnl to avoid requiring SSE2.
1915 CFLAGS="$CFLAGS -arch:IA32"
1932 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1940 AC_DEFINE(HAVE_BSD_FLOCK)
1941 AC_DEFINE(HAVE_SOCKLEN_T)
1942 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1943 if test -z "$USE_NSPR_THREADS"; then
1946 MDCPUCFG_H=_netbsd.cfg
1947 PR_MD_CSRCS=netbsd.c
1949 DSO_CFLAGS='-fPIC -DPIC'
1950 CFLAGS="$CFLAGS -ansi -Wall"
1951 CXXFLAGS="$CXXFLAGS -ansi -Wall"
1952 MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1954 if test -z "$OBJECT_FMT"; then
1955 if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
1958 DSO_LDOPTS='-shared'
1962 DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
1966 if test "$LIBRUNPATH"; then
1967 DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
1974 AC_DEFINE(_QNX_SOURCE)
1975 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1978 MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
1981 OS_LIBS="$OS_LIBS -lsocket"
1982 _OPTIMIZE_FLAGS="-O1"
1983 _DEBUG_FLAGS="-gstabs"
1989 AC_DEFINE(HAVE_BSD_FLOCK)
1990 AC_DEFINE(HAVE_SOCKLEN_T)
1991 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1992 CFLAGS="$CFLAGS -ansi -Wall"
1993 CXXFLAGS="$CXXFLAGS -ansi -Wall"
1996 MDCPUCFG_H=_openbsd.cfg
1997 PR_MD_CSRCS=openbsd.c
1999 if test -z "$USE_NSPR_THREADS"; then
2002 DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
2003 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2009 AC_DEFINE(_PR_NEED_H_ERRNO)
2018 AC_DEFINE(_PR_NEED_H_ERRNO)
2020 MDCPUCFG_H=_riscos.cfg
2021 PR_MD_CSRCS=riscos.c
2023 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
2024 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2033 AC_DEFINE(_PR_NEED_H_ERRNO)
2034 CC='cc -b elf -KPIC'
2035 CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
2038 DSO_LDOPTS='-b elf -G'
2039 MDCPUCFG_H=_scoos.cfg
2044 if test -z "$USE_NSPR_THREADS"; then
2053 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
2055 MDCPUCFG_H=_solaris.cfg
2056 PR_MD_CSRCS=solaris.c
2058 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2059 RESOLVE_LINK_SYMBOLS=1
2060 case "${OS_RELEASE}" in
2064 # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
2068 if test -n "$GNU_CC"; then
2070 if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
2073 DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore'
2074 if test -n "$USE_B_DIRECT"; then
2075 DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
2079 DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
2080 if test -n "$USE_B_DIRECT"; then
2081 DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
2084 if test -n "$GNU_CC"; then
2085 CFLAGS="$CFLAGS -Wall"
2086 CXXFLAGS="$CXXFLAGS -Wall"
2087 if test -n "$USE_MDUPDATE"; then
2088 CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
2089 CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
2091 GCC_AS=`$CC -print-prog-name=as`
2092 if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
2096 CFLAGS="$CFLAGS -xstrconst"
2097 CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
2098 if test -z "$MOZ_OPTIMIZE"; then
2099 CFLAGS="$CFLAGS -xs"
2100 CXXFLAGS="$CXXFLAGS -xs"
2102 _OPTIMIZE_FLAGS=-xO4
2104 if test -z "$GNU_AS"; then
2105 ASFLAGS="$ASFLAGS -Wa,-P"
2107 if test -n "$USE_64"; then
2108 if test -n "$GNU_CC"; then
2112 if test "$OS_TEST" = "i86pc"; then
2113 CC="$CC -xarch=amd64"
2114 CXX="$CXX -xarch=amd64"
2117 CXX="$CXX -xarch=v9"
2121 if test "$OS_TEST" = "i86pc"; then
2122 if test -z "$USE_64"; then
2125 CPU_ARCH_TAG=_$OS_TEST
2126 # The default debug format, DWARF (-g), is not supported by gcc
2127 # on i386-ANY-sysv4/solaris, but the stabs format is. It is
2128 # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2129 # If your gcc uses GNU as, you do not need the -Wa,-s option.
2130 if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2131 _DEBUG_FLAGS=-gstabs
2132 if test -z "$GNU_AS"; then
2133 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2137 case "${target_os}" in
2139 AC_DEFINE(_PR_NO_LARGE_FILES)
2142 AC_DEFINE(_PR_NO_LARGE_FILES)
2145 AC_DEFINE(SOLARIS2_5)
2148 AC_DEFINE(_PR_HAVE_OFF64_T)
2149 # The lfcompile64(5) man page on Solaris 2.6 says:
2150 # For applications that do not wish to conform to the POSIX or
2151 # X/Open specifications, the 64-bit transitional interfaces
2152 # are available by default. No compile-time flags need to be
2154 # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2155 # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2156 if test -n "$GNU_CC"; then
2157 AC_DEFINE(_LARGEFILE64_SOURCE)
2161 case "${target_os}" in
2173 # Solaris 8 or higher has IPv6.
2174 AC_DEFINE(_PR_INET6)
2177 if test "$CPU_ARCH" = "sparc"; then
2178 # 64-bit Solaris SPARC requires V9 architecture, so the following
2180 if test -z "$USE_64"; then
2181 ULTRASPARC_LIBRARY=nspr_flt
2184 # Purify requires that binaries linked against nspr also
2185 # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2187 _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2188 OS_LIBS="$OS_LIBS $_librt"
2197 if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
2198 AC_DEFINE(_PR_NO_LARGE_FILES)
2199 CC='$(NSDEPTH)/build/hcc cc'
2200 CXX='$(NSDEPTH)/build/hcpp CC'
2201 MDCPUCFG_H=_unixware.cfg
2203 AC_DEFINE(_LARGEFILE64_SOURCE)
2204 AC_DEFINE(_PR_HAVE_OFF64_T)
2205 AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
2206 MDCPUCFG_H=_unixware7.cfg
2208 PR_MD_CSRCS=unixware.c
2216 AC_DEFINE(BSD_SELECT)
2217 AC_DEFINE(TCPV40HDRS)
2225 RESOLVE_LINK_SYMBOLS=1
2230 CFLAGS="$CFLAGS -Wall -Zomf"
2231 CXXFLAGS="$CFLAGS -Wall -Zomf"
2232 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2234 DSO_LDOPTS='-Zomf -Zdll'
2236 _OPTIMIZE_FLAGS="-O2 -s"
2237 _DEBUG_FLAGS="-g -fno-inline"
2238 if test -n "$MOZ_OPTIMIZE"; then
2239 DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2243 if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2244 LDFLAGS="$LDFLAGS -Zhigh-mem"
2245 AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2248 # GCC for OS/2 currently predefines these, but we don't want them
2249 DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
2258 if test -z "$SKIP_LIBRARY_CHECKS"; then
2259 dnl ========================================================
2260 dnl Check for system libraries
2261 dnl ========================================================
2264 dnl We don't want anything to link with libdl even if it's present on OS X,
2265 dnl since it's not used and not part of the default installation.
2266 dnl The same goes for BeOS.
2267 dnl OS/2 has dlfcn in libc.
2273 AC_CHECK_LIB(dl, dlopen,
2274 [AC_CHECK_HEADER(dlfcn.h,
2275 OS_LIBS="-ldl $OS_LIBS")])
2280 dnl ========================================================
2281 dnl Check for system header files.
2282 dnl ========================================================
2284 dnl ========================================================
2285 dnl Check for typedefs and structs
2286 dnl ========================================================
2288 dnl ========================================================
2289 dnl Checks for library functions.
2290 dnl ========================================================
2291 AC_PROG_GCC_TRADITIONAL
2293 LIBS="$LIBS $OS_LIBS"
2294 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
2295 secure_getenv __secure_getenv)
2298 dnl ========================================================
2300 dnl ========================================================
2302 dnl ======================================================
2303 dnl = Enable compiling with ccache
2304 dnl ======================================================
2306 [ --with-ccache[=path/to/ccache]
2307 Enable compiling with ccache],
2308 CCACHE=$withval, CCACHE="no")
2310 if test "$CCACHE" != "no"; then
2311 if test -n "$CCACHE"; then
2312 if test "$CCACHE" = "yes"; then
2315 if test ! -e "$CCACHE"; then
2316 AC_MSG_ERROR([$CCACHE not found])
2320 AC_PATH_PROGS(CCACHE, $CCACHE ccache)
2321 if test -z "$CCACHE" -o "$CCACHE" = ":"; then
2322 AC_MSG_ERROR([ccache not found])
2323 elif test -x "$CCACHE"; then
2327 AC_MSG_ERROR([$CCACHE is not executable])
2331 dnl ========================================================
2333 dnl = --enable-strip
2335 dnl = Enable stripping of libs and executables
2337 dnl ========================================================
2338 AC_ARG_ENABLE(strip,
2339 [ --enable-strip Enable stripping of shared libs and programs],
2340 [ if test "$enableval" = "yes"; then
2344 dnl Check for hpux options
2345 case "${target_os}" in
2347 if test -z "$GNU_CC"; then
2349 AC_CACHE_CHECK(for +Olit support,
2350 ac_cv_hpux_usable_olit_option,
2351 dnl since aCC doesn't throw an error on invalid options,
2352 dnl we have to test this the hard way
2353 [ac_cv_hpux_usable_olit_option=no
2355 echo 'int main() { return 0; }' | cat > conftest.c
2356 ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2357 if test $? -eq 0; then
2358 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2359 ac_cv_hpux_usable_olit_option=yes
2365 if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2366 CFLAGS="$CFLAGS +Olit=all"
2367 CXXFLAGS="$CXXFLAGS +Olit=all"
2369 CFLAGS="$CFLAGS +ESlit"
2370 CXXFLAGS="$CXXFLAGS +ESlit"
2376 case "$target_os" in
2381 AC_CHECK_LIB(pthreads, pthread_create,
2382 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2383 AC_CHECK_LIB(pthread, pthread_create,
2384 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2385 AC_CHECK_LIB(c_r, pthread_create,
2386 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2387 AC_CHECK_LIB(c, pthread_create,
2396 AC_ARG_WITH(pthreads,
2397 [ --with-pthreads Use system pthreads library as thread subsystem],
2398 [ if test "$withval" = "yes"; then
2399 if test -n "$_HAVE_PTHREADS"; then
2404 AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2410 [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2416 AC_ARG_ENABLE(user-pthreads,
2417 [ --enable-user-pthreads Build using userland pthreads],
2418 [ if test "$enableval" = "yes"; then
2419 if test -n "$_HAVE_PTHREADS"; then
2424 AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2428 AC_ARG_ENABLE(nspr-threads,
2429 [ --enable-nspr-threads Build using classic nspr threads],
2430 [ if test "$enableval" = "yes"; then
2436 fi # SKIP_LIBRARY_CHECKS
2439 [ --enable-ipv6 Compile ipv6 support],
2440 [ if test "$enableval" = "yes"; then
2446 if test -n "$USE_PTHREADS"; then
2447 dnl See if -pthread is supported.
2449 ac_cv_have_dash_pthread=no
2450 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2451 echo 'int main() { return 0; }' | cat > conftest.c
2452 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2453 if test $? -eq 0; then
2454 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2455 ac_cv_have_dash_pthread=yes
2456 case "$target_os" in
2458 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2461 CFLAGS="$CFLAGS -pthread"
2462 CXXFLAGS="$CXXFLAGS -pthread"
2468 AC_MSG_RESULT($ac_cv_have_dash_pthread)
2471 dnl See if -pthreads is supported.
2473 ac_cv_have_dash_pthreads=no
2474 if test "$ac_cv_have_dash_pthread" = "no"; then
2475 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2476 echo 'int main() { return 0; }' | cat > conftest.c
2477 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2478 if test $? -eq 0; then
2479 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2480 ac_cv_have_dash_pthreads=yes
2481 CFLAGS="$CFLAGS -pthreads"
2482 CXXFLAGS="$CXXFLAGS -pthreads"
2486 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2491 if test "$ac_cv_have_dash_pthreads" = "yes"; then
2496 AC_DEFINE(_REENTRANT)
2497 AC_DEFINE(_THREAD_SAFE)
2498 dnl -pthread links in -lc_r, so don't specify it explicitly.
2499 if test "$ac_cv_have_dash_pthread" = "yes"; then
2500 _PTHREAD_LDFLAGS="-pthread"
2502 _PTHREAD_LDFLAGS="-lc_r"
2506 if test "$ac_cv_have_dash_pthread" = "yes"; then
2507 _PTHREAD_LDFLAGS="-pthread"
2511 AC_DEFINE(_THREAD_SAFE)
2512 dnl -pthread links in -lc_r, so don't specify it explicitly.
2513 if test "$ac_cv_have_dash_pthread" = "yes"; then
2518 if test "$ac_cv_have_dash_pthread" = "yes"; then
2519 _PTHREAD_LDFLAGS=-pthread
2522 *-linux*|*-gnu*|*-k*bsd*-gnu)
2523 AC_DEFINE(_REENTRANT)
2528 if test -n "$USE_USER_PTHREADS"; then
2535 dnl Special thread exceptions
2539 if test -n "$USE_NSPR_THREADS"; then
2540 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2542 case "$target_os" in
2544 if test -z "$USE_PTHREADS"; then
2545 AC_DEFINE(AIX_RENAME_SELECT)
2549 if test -z "$USE_NSPR_THREADS"; then
2550 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2554 if test -z "$USE_NSPR_THREADS"; then
2555 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2557 if test -n "$USE_PTHREADS"; then
2558 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2562 if test -z "$USE_NSPR_THREADS"; then
2563 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2565 if test -n "$USE_PTHREADS"; then
2566 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2572 if test -n "$USE_PTHREADS"; then
2573 AC_DEFINE(_PR_NEED_PTHREAD_INIT)
2577 if test -n "$USE_NSPR_THREADS"; then
2578 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2582 if test -n "$USE_NSPR_THREADS"; then
2583 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2585 if test "$USE_PTHREADS"; then
2586 AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2587 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2589 if test "$USE_USER_PTHREADS"; then
2590 AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2593 *-linux*|*-gnu*|*-k*bsd*-gnu)
2594 if test -n "$USE_NSPR_THREADS"; then
2595 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2598 *-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*)
2599 dnl win32, os2 cannot use pthreads
2604 *-netbsd*|*-openbsd*)
2605 if test -n "$USE_NSPR_THREADS"; then
2606 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2610 if test -n "$USE_NSPR_THREADS"; then
2611 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2613 if test -n "$USE_PTHREADS"; then
2614 AC_DEFINE(_REENTRANT)
2615 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2616 if test "$OS_TEST" = "i86pc"; then
2617 if test -n "$USE_64"; then
2618 PR_MD_ASFILES=os_SunOS_x86_64.s
2620 PR_MD_ASFILES=os_SunOS_x86.s
2623 if test -n "$USE_64"; then
2624 PR_MD_ASFILES=os_SunOS_sparcv9.s
2630 if test -n "$USE_PTHREADS"; then
2631 AC_DEFINE(_PR_HAVE_GETHOST_R)
2632 AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2637 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2639 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2640 dnl make sure that we use it.
2641 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2642 _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2645 if test -n "$_SAVE_DEBUG_FLAGS"; then
2646 _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2649 if test -n "$MOZ_OPTIMIZE"; then
2650 CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2651 CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2654 if test -n "$MOZ_DEBUG_SYMBOLS"; then
2655 CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2656 CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2659 if test -n "$MOZ_OPTIMIZE"; then
2665 if test -n "$USE_64"; then
2669 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2671 dnl ========================================================
2672 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2673 dnl ========================================================
2674 case "$target_os" in
2676 CC="\$(CYGWIN_WRAPPER) $CC"
2677 CXX="\$(CYGWIN_WRAPPER) $CXX"
2678 RC="\$(CYGWIN_WRAPPER) $RC"
2682 dnl ========================================================
2683 dnl = Use malloc wrapper lib
2684 dnl ========================================================
2685 AC_ARG_ENABLE(wrap-malloc,
2686 [ --enable-wrap-malloc Wrap malloc calls (gnu linker only)],
2687 [ if test "$enableval" = "yes"; then
2691 if test -n "$_WRAP_MALLOC"; then
2692 if test -n "$GNU_CC"; then
2693 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
2694 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
2695 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
2696 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
2698 AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
2702 dnl ========================================================
2703 dnl = Location of malloc wrapper lib
2704 dnl ========================================================
2705 AC_ARG_WITH(wrap-malloc,
2706 [ --with-wrap-malloc=SHAREDLIB Location of malloc wrapper library],
2707 WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
2709 dnl ========================================================
2710 dnl Substitution of found variables.
2711 dnl ========================================================
2712 AC_SUBST(SHELL_OVERRIDE)
2714 AC_SUBST(MOZILLA_CLIENT)
2721 AC_SUBST(HOST_CFLAGS)
2723 AC_SUBST(HOST_LDFLAGS)
2725 AC_SUBST(GCC_USE_GNU_LD)
2727 AC_SUBST(CROSS_COMPILE)
2729 AC_SUBST(MOZ_OPTIMIZE)
2731 AC_SUBST(MOZ_DEBUG_SYMBOLS)
2738 AC_SUBST(OBJECT_MODE)
2739 AC_SUBST(ENABLE_STRIP)
2741 AC_SUBST(USE_PTHREADS)
2742 AC_SUBST(USE_BTHREADS)
2743 AC_SUBST(USE_USER_PTHREADS)
2744 AC_SUBST(USE_NSPR_THREADS)
2749 AC_SUBST(MOD_MAJOR_VERSION)
2750 AC_SUBST(MOD_MINOR_VERSION)
2751 AC_SUBST(MOD_PATCH_VERSION)
2752 AC_SUBST(NSPR_MODNAME)
2753 AC_SUBST(MDCPUCFG_H)
2754 AC_SUBST(PR_MD_CSRCS)
2755 AC_SUBST(PR_MD_ASFILES)
2756 AC_SUBST(PR_MD_ARCH_DIR)
2759 AC_SUBST(OBJ_SUFFIX)
2760 AC_SUBST(LIB_SUFFIX)
2761 AC_SUBST(DLL_SUFFIX)
2762 AC_SUBST(ASM_SUFFIX)
2763 AC_SUBST(WRAP_LDFLAGS)
2765 AC_SUBST(DSO_CFLAGS)
2766 AC_SUBST(DSO_LDOPTS)
2770 AC_SUBST(OS_RELEASE)
2772 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
2787 AC_SUBST(PROFILE_GEN_CFLAGS)
2788 AC_SUBST(PROFILE_GEN_LDFLAGS)
2789 AC_SUBST(PROFILE_USE_CFLAGS)
2790 AC_SUBST(PROFILE_USE_LDFLAGS)
2793 AC_SUBST(RESOLVE_LINK_SYMBOLS)
2794 AC_SUBST(AIX_LINK_OPTS)
2795 AC_SUBST(NOSUCHFILE)
2796 AC_SUBST(MOZ_OBJFORMAT)
2797 AC_SUBST(ULTRASPARC_LIBRARY)
2800 AC_SUBST(OBJDIR_NAME)
2801 AC_SUBST(RELEASE_OBJDIR_NAME)
2808 AC_SUBST(OS_DLLFLAGS)
2809 AC_SUBST(CYGWIN_WRAPPER)
2810 AC_SUBST(VISIBILITY_FLAGS)
2811 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2812 AC_SUBST(MACOS_SDK_DIR)
2816 dnl ========================================================
2817 dnl Generate output files.
2818 dnl ========================================================
2830 lib/libc/include/Makefile
2831 lib/libc/src/Makefile
2836 pr/include/md/Makefile
2837 pr/include/obsolete/Makefile
2838 pr/include/private/Makefile
2841 pr/src/linking/Makefile
2842 pr/src/malloc/Makefile
2844 pr/src/md/${PR_MD_ARCH_DIR}/Makefile
2845 pr/src/memory/Makefile
2846 pr/src/misc/Makefile
2847 pr/src/threads/Makefile
2849 pr/tests/dll/Makefile
2852 if test "$OS_TARGET" = "Linux"; then
2853 MAKEFILES="$MAKEFILES
2856 elif test "$OS_TARGET" = "SunOS"; then
2857 MAKEFILES="$MAKEFILES
2858 pkg/solaris/Makefile
2859 pkg/solaris/SUNWpr/Makefile
2860 pkg/solaris/SUNWprd/Makefile
2864 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
2865 MAKEFILES="$MAKEFILES
2866 pr/src/threads/combined/Makefile
2868 elif test -n "$USE_PTHREADS"; then
2869 MAKEFILES="$MAKEFILES
2870 pr/src/pthreads/Makefile
2872 elif test -n "$USE_BTHREADS"; then
2873 MAKEFILES="$MAKEFILES
2874 pr/src/bthreads/Makefile
2878 if test -n "$USE_CPLUS"; then
2879 MAKEFILES="$MAKEFILES
2880 pr/src/cplus/Makefile
2881 pr/src/cplus/tests/Makefile
2885 echo $MAKEFILES > unallmakefiles
2887 AC_CONFIG_FILES([$MAKEFILES])
2888 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])