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)'
52 dnl Link in libraries necessary to resolve all symbols for shared libs
55 dnl ========================================================
57 dnl = Dont change the following lines. Doing so breaks:
59 dnl = CFLAGS="-foo" ./configure
61 dnl ========================================================
63 CXXFLAGS="${CXXFLAGS=}"
65 DLLFLAGS="${DLLFLAGS=}"
66 HOST_CFLAGS="${HOST_CFLAGS=}"
67 HOST_LDFLAGS="${HOST_LDFLAGS=}"
70 *-cygwin*|*-mingw*|*-msys*)
71 # Check to see if we are really running in a msvc environemnt
73 AC_CHECK_PROGS(CC, cl)
74 cat > conftest.c <<EOF
80 $($CC -E conftest.c 2>/dev/null | grep COMPILER)
82 if test -n "$dummy"; then
93 if test -n "$_WIN32_MSVC"; then
95 SKIP_COMPILER_CHECKS=1
99 dnl ========================================================
100 dnl = Android uses a very custom (hacky) toolchain; we need to do this
101 dnl = here, so that the compiler checks can succeed
102 dnl ========================================================
104 AC_ARG_WITH(android-ndk,
105 [ --with-android-ndk=DIR
106 location where the Android NDK can be found],
107 android_ndk=$withval)
109 AC_ARG_WITH(android-toolchain,
110 [ --with-android-toolchain=DIR
111 location of the Android toolchain],
112 android_toolchain=$withval)
114 dnl The default android_version is different for each target cpu.
115 case "$target_cpu" in
124 AC_ARG_WITH(android-version,
125 [ --with-android-version=VER
126 Android platform version, default 5 for arm, 9 for x86/mips],
127 android_version=$withval)
129 AC_ARG_WITH(android-platform,
130 [ --with-android-platform=DIR
131 location of platform dir],
132 android_platform=$withval)
135 x86_64-linux*-android*)
136 android_tool_prefix="x86_64-linux-android"
138 aarch64-linux*-android*)
139 android_tool_prefix="aarch64-linux-android"
141 arm-linux*-android*|*-linuxandroid*)
142 android_tool_prefix="arm-linux-androideabi"
145 android_tool_prefix="i686-linux-android"
148 android_tool_prefix="mipsel-linux-android"
151 android_tool_prefix="$target_os"
156 *-android*|*-linuxandroid*)
157 if test -z "$android_ndk" ; then
158 AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
161 if test -z "$android_toolchain" ; then
162 AC_MSG_CHECKING([for android toolchain directory])
164 kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
166 case "$target_cpu" in
168 target_name=arm-linux-androideabi-4.4.3
171 target_name=x86-4.4.3
174 target_name=mipsel-linux-android-4.4.3
177 android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
179 if test -d "$android_toolchain" ; then
180 AC_MSG_RESULT([$android_toolchain])
182 AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
186 if test -z "$android_platform" ; then
187 AC_MSG_CHECKING([for android platform directory])
189 case "$target_cpu" in
201 android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
203 if test -d "$android_platform" ; then
204 AC_MSG_RESULT([$android_platform])
206 AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
210 dnl Old NDK support. If minimum requirement is changed to NDK r8b,
211 dnl please remove this.
212 case "$target_cpu" in
214 if ! test -e "$android_toolchain"/bin/"$android_tool_prefix"-gcc; then
215 dnl Old NDK toolchain name
216 android_tool_prefix="i686-android-linux"
222 AS="$android_toolchain"/bin/"$android_tool_prefix"-as
223 CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
224 CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
225 CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
226 LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
227 AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
228 RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
229 STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
231 CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
232 CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
233 CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
234 LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
240 dnl ========================================================
242 dnl = Check options that may affect the compiler
244 dnl ========================================================
245 dist_prefix='${MOD_DEPTH}/dist'
246 dist_bindir='${dist_prefix}/bin'
247 dist_includedir='${dist_prefix}/include/nspr'
248 dist_libdir='${dist_prefix}/lib'
249 dnl If the --includedir option was not specified, add '/nspr' to autoconf's
250 dnl default value of includedir.
251 if test "${includedir}" = '${prefix}/include'; then
252 includedir='${prefix}/include/nspr'
255 AC_ARG_WITH(dist-prefix,
256 [ --with-dist-prefix=DIST_PREFIX
257 place build files in DIST_PREFIX [dist]],
258 dist_prefix=$withval)
260 AC_ARG_WITH(dist-bindir,
261 [ --with-dist-bindir=DIR build execuatables in DIR [DIST_PREFIX/bin]],
262 dist_bindir=$withval)
264 AC_ARG_WITH(dist-includedir,
265 [ --with-dist-includedir=DIR
266 build include files in DIR [DIST_PREFIX/include/nspr]],
267 dist_includedir=$withval)
269 AC_ARG_WITH(dist-libdir,
270 [ --with-dist-libdir=DIR build library files in DIR [DIST_PREFIX/lib]],
271 dist_libdir=$withval)
273 AC_SUBST(dist_prefix)
274 AC_SUBST(dist_bindir)
275 AC_SUBST(dist_includedir)
276 AC_SUBST(dist_libdir)
278 dnl Check if NSPR is being compiled for Mozilla
279 dnl Let --with-arg override environment setting
282 [ --with-mozilla Compile NSPR with Mozilla support],
283 [ if test "$withval" = "yes"; then
284 AC_DEFINE(MOZILLA_CLIENT)
289 [ if test -n "$MOZILLA_CLIENT"; then
290 AC_DEFINE(MOZILLA_CLIENT)
293 AC_ARG_ENABLE(optimize,
294 [ --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
295 [ if test "$enableval" != "no"; then
297 if test -n "$enableval" -a "$enableval" != "yes"; then
298 _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
299 _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
306 [ --enable-debug[=DBG] Enable debugging (using compiler flags DBG)],
307 [ if test "$enableval" != "no"; then
310 if test -n "$enableval" -a "$enableval" != "yes"; then
311 _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
312 _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
319 AC_ARG_ENABLE(debug-symbols,
320 [ --enable-debug-symbols[=DBG] Enable debugging symbols
321 (using compiler flags DBG)],
322 [ if test "$enableval" != "no"; then
324 if test -n "$enableval" -a "$enableval" != "yes"; then
325 if test -z "$_SAVE_DEBUG_FLAGS"; then
326 _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
327 _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
329 AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
336 AC_ARG_ENABLE(win32-target,
337 [ --enable-win32-target=\$t
338 Specify win32 flavor. (WIN95 or WINNT)],
339 OS_TARGET=`echo $enableval | tr a-z A-Z`)
342 AC_ARG_ENABLE(debug-rtl,
343 [ --enable-debug-rtl Use the MSVC debug runtime library],
344 [ if test "$enableval" = "yes"; then
350 AC_ARG_ENABLE(static-rtl,
351 [ --enable-static-rtl Use the MSVC static runtime library],
352 [ if test "$enableval" = "yes"; then
357 [ --enable-x32 Enable x32 ABI support (x86_64 only)],
358 [ if test "$enableval" = "yes"; then
360 else if test "$enableval" = "no"; then
366 [ --enable-64bit Enable 64-bit support (on certain platforms)],
367 [ if test "$enableval" = "yes"; then
371 AC_ARG_ENABLE(mdupdate,
372 [ --enable-mdupdate Enable use of certain compilers' mdupdate feature],
373 [ if test "$enableval" = "yes"; then
378 [ --enable-cplus Enable some c++ api routines],
379 [ if test "$enableval" = "yes"; then
383 AC_ARG_WITH(arm-kuser,
384 [ --with-arm-kuser Use kuser helpers (Linux/ARM only)
385 (Requires kernel 2.6.13 or later)],
386 [ if test "$withval" = "yes"; then
387 AC_DEFINE(_PR_ARM_KUSER)
390 dnl ========================================================
391 dnl = Mac OS X SDK support
392 dnl ========================================================
393 AC_ARG_WITH(macos-sdk,
394 [ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)],
395 MACOS_SDK_DIR=$withval)
397 AC_ARG_ENABLE(macos-target,
398 [ --enable-macos-target=VER
399 Set the minimum MacOS version needed at runtime
400 [10.3 for ppc, 10.4 for x86]],
401 [_MACOSX_DEPLOYMENT_TARGET=$enableval])
403 dnl ========================================================
405 dnl = Set the threading model
407 dnl ========================================================
415 dnl ========================================================
417 dnl = Set the default C compiler
419 dnl ========================================================
420 if test -z "$CC"; then
424 if test -z "$USE_NSPR_THREADS"; then
442 dnl ========================================================
444 dnl = Set the default C++ compiler
446 dnl ========================================================
447 if test -z "$CXX"; then
451 if test -z "$USE_NSPR_THREADS"; then
459 case "${target_os}" in
479 if test -z "$SKIP_PATH_CHECKS"; then
480 AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
483 if test -n "$MOZ_DEBUG"; then
485 DEFINES="$DEFINES -UNDEBUG"
487 case "${target_os}" in
488 mks*|cygwin*|mingw*|msys*)
489 DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
492 DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
497 DEFINES="$DEFINES -UDEBUG"
500 if test -z "$SKIP_COMPILER_CHECKS"; then
501 dnl ========================================================
502 dnl Checks for compilers.
503 dnl ========================================================
504 if test "$target" != "$host"; then
505 echo "cross compiling from $host to $target"
508 case "$build:$target" in
509 powerpc-apple-darwin8*:i?86-apple-darwin*)
510 dnl The Darwin cross compiler doesn't necessarily point itself at a
511 dnl root that has libraries for the proper architecture, it defaults
512 dnl to the system root. The libraries in the system root on current
513 dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
514 dnl checks will fail. Fake a working SDK in that case.
516 _SAVE_CXXFLAGS=$CXXFLAGS
517 CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
518 CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
522 AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
524 dnl Now exit the conditional block to invoke AC_PROG_CC.
527 dnl In the latest versions of autoconf, AC_PROG_CC is a one-shot macro,
528 dnl declared with AC_DEFUN_ONCE. So it must not be expanded inside a
529 dnl conditional block. Invoke AC_PROG_CC outside any conditional block
530 dnl and before invoking AC_TRY_COMPILE (which requires AC_PROG_CC).
533 dnl Reenter the conditional blocks after invoking AC_PROG_CC.
534 if test "$target" != "$host"; then
535 if test -n "$USE_CPLUS"; then
536 AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
541 case "$build:$target" in
542 powerpc-apple-darwin8*:i?86-apple-darwin*|*:arm*-apple-darwin*)
543 dnl Revert the changes made above. From this point on, the target
544 dnl compiler will never be used without applying the SDK to CFLAGS
545 dnl (see --with-macos-sdk below).
547 CXXFLAGS=$_SAVE_CXXFLAGS
551 AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
552 AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
553 AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
554 AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
555 AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
556 AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
559 _SAVE_CFLAGS="$CFLAGS"
560 _SAVE_LDFLAGS="$LDFLAGS"
562 AC_MSG_CHECKING([for $host compiler])
563 AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
564 if test -z "$HOST_CC"; then
565 AC_MSG_ERROR([no acceptable cc found in \$PATH])
567 AC_MSG_RESULT([$HOST_CC])
570 CFLAGS="$HOST_CFLAGS"
571 LDFLAGS="$HOST_LDFLAGS"
573 AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
574 AC_TRY_COMPILE([], [return 0;],
575 [AC_MSG_RESULT([yes])],
576 [AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.])] )
580 LDFLAGS=$_SAVE_LDFLAGS
582 if test -n "$USE_CPLUS"; then
583 if test "$CC" = "cl" -a -z "$CXX"; then
590 AC_PATH_PROGS(AS, as, $CC)
591 AC_PATH_PROGS(AR, ar, echo not_ar)
592 AC_PATH_PROGS(LD, ld link, echo not_ld)
593 AC_PATH_PROGS(STRIP, strip, echo not_strip)
594 AC_PATH_PROGS(WINDRES, windres, echo not_windres)
595 if test -z "$HOST_CC"; then
598 if test -z "$HOST_CFLAGS"; then
599 HOST_CFLAGS="$CFLAGS"
605 if test "$GCC" = "yes"; then
608 if test "$GXX" = "yes"; then
611 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
616 case "$build:$target" in
617 i?86-apple-darwin*:powerpc-apple-darwin*)
618 dnl cross_compiling will have erroneously been set to "no" in this
619 dnl case, because the x86 build host is able to run ppc code in a
620 dnl translated environment, making a cross compiler appear native.
625 if test "$cross_compiling" = "yes"; then
631 dnl ========================================================
632 dnl Check for gcc -pipe support
633 dnl ========================================================
634 AC_MSG_CHECKING([for gcc -pipe support])
635 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
636 echo '#include <stdio.h>' > dummy-hello.c
637 echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
638 ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
639 cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
645 if test "$_res_as_stdin" = "yes"; then
647 CFLAGS="$CFLAGS -pipe"
648 AC_TRY_COMPILE( [ #include <stdio.h> ],
649 [printf("Hello World\n");],
650 [_res_gcc_pipe="yes"],
651 [_res_gcc_pipe="no"] )
654 if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
656 CFLAGS="$CFLAGS -pipe"
657 CXXFLAGS="$CXXFLAGS -pipe"
661 rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
662 AC_MSG_RESULT([$_res])
667 dnl ========================================================
668 dnl Check for pragma diagnostic
669 dnl ========================================================
671 AC_MSG_CHECKING([for pragma diagnostic])
672 if test "$GNU_CC" = "1"; then
673 cat >dummy-hello.c <<EOF
674 #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
675 #pragma GCC diagnostic push
676 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
683 ${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
684 if test $? != 0; then
685 ${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
687 CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
695 rm -f dummy-hello.c dummy-hello.s
696 AC_MSG_RESULT([$_res])
701 dnl ========================================================
702 dnl Profile guided optimization
703 dnl ========================================================
704 dnl Test for profiling options
705 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
707 _SAVE_CFLAGS="$CFLAGS"
708 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
710 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
711 AC_TRY_COMPILE([], [return 0;],
712 [ PROFILE_GEN_CFLAGS="-fprofile-generate"
713 result="yes" ], result="no")
714 AC_MSG_RESULT([$result])
716 if test $result = "yes"; then
717 PROFILE_GEN_LDFLAGS="-fprofile-generate"
718 PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
719 PROFILE_USE_LDFLAGS="-fprofile-use"
722 CFLAGS="$_SAVE_CFLAGS"
724 dnl ===============================================================
725 dnl Check for .hidden assembler directive and visibility attribute.
726 dnl Borrowed from glibc configure.in
727 dnl ===============================================================
728 if test "$GNU_CC"; then
729 AC_CACHE_CHECK(for visibility(hidden) attribute,
730 ac_cv_visibility_hidden,
731 [cat > conftest.c <<EOF
732 int foo __attribute__ ((visibility ("hidden"))) = 1;
734 ac_cv_visibility_hidden=no
735 if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
736 if grep '\.hidden.*foo' conftest.s >/dev/null; then
737 ac_cv_visibility_hidden=yes
742 if test "$ac_cv_visibility_hidden" = "yes"; then
743 AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
744 AC_CACHE_CHECK(for visibility pragma support,
745 ac_cv_visibility_pragma,
746 [cat > conftest.c <<EOF
747 #pragma GCC visibility push(hidden)
749 #pragma GCC visibility push(default)
752 ac_cv_visibility_pragma=no
753 if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
754 if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
755 if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
756 ac_cv_visibility_pragma=yes
762 if test "$ac_cv_visibility_pragma" = "yes"; then
763 AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
764 # To work around a build problem on Linux x86-64 (Bugzilla bug
765 # 293438), we use the -fvisibility=hidden flag. This flag is less
766 # optimal than #pragma GCC visibility push(hidden) because the flag
767 # assumes that symbols defined outside the current source file have
768 # the default visibility. This has the advantage that we don't need
769 # to wrap system header files, but has the disadvantage that calls
770 # to hidden symbols defined in other source files cannot be
771 # optimized by the compiler. The -fvisibility=hidden flag does
772 # hide and export symbols correctly.
773 #VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
774 #WRAP_SYSTEM_INCLUDES=1
775 VISIBILITY_FLAGS="-fvisibility=hidden"
776 WRAP_SYSTEM_INCLUDES=
781 fi # SKIP_COMPILER_CHECKS
783 dnl ========================================================
784 dnl Checks for programs.
785 dnl ========================================================
786 if test -z "$SKIP_PATH_CHECKS"; then
787 AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
788 elif test -z "$PERL"; then
792 dnl ========================================================
793 dnl Default platform specific options
794 dnl ========================================================
799 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
807 if test -n "$CROSS_COMPILE"; then
808 OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
810 OS_TEST="${target_cpu}"
811 case "${target_os}" in
812 linux*) OS_ARCH=Linux ;;
813 solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;;
814 mingw*) OS_ARCH=WINNT CPU_ARCH=x86 ;;
815 cygwin*) OS_ARCH=WINNT ;;
816 darwin*) OS_ARCH=Darwin ;;
817 riscos*) OS_ARCH=RISCOS ;;
820 OS_ARCH=`uname -s | sed -e 's|/|_|g'`
821 OS_RELEASE=`uname -r`
825 if test "$OS_ARCH" = "AIX"; then
826 OS_RELEASE=`uname -v`.`uname -r`
829 if test "$OS_ARCH" = "FreeBSD"; then
830 OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
833 if test "$OS_ARCH" = "Linux"; then
834 OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
835 OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
838 #######################################################################
839 # Master "Core Components" macros for getting the OS target #
840 #######################################################################
843 # Note: OS_TARGET should be specified on the command line for gmake.
844 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
845 # The difference between the Win95 target and the WinNT target is that
846 # the WinNT target uses Windows NT specific features not available
847 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
848 # at lesser performance (the Win95 target uses threads; the WinNT target
851 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
856 # The following hack allows one to build on a WIN95 machine (as if
857 # s/he were cross-compiling on a WINNT host for a WIN95 target).
858 # It also accomodates for MKS's uname.exe. If you never intend
859 # to do development on a WIN95 machine, you don't need this hack.
870 CYGWIN_9*|CYGWIN_ME*)
871 OS_ARCH='CYGWIN_NT-4.0'
877 # On WIN32, we also define the variable CPU_ARCH.
883 # If uname -s returns "Windows_NT", we assume that we are using
884 # the uname.exe in MKS toolkit.
886 # The -r option of MKS uname only returns the major version number.
887 # So we need to use its -v option to get the minor version number.
888 # Moreover, it doesn't have the -p option, so we need to use uname -m.
891 OS_MINOR_RELEASE=`uname -v`
892 if test "$OS_MINOR_RELEASE" = "00"; then
895 OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
898 # MKS's uname -m returns "586" on a Pentium machine.
900 if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
904 CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
906 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
907 # the uname.exe in the Cygwin tools.
908 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
909 # the uname.exe in the MSYS tools.
910 # If uname -s returns "MSYS_NT-6.3", we assume that we are using
911 # the uname.exe in the MSYS2 tools.
913 OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
917 # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
919 if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
925 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
927 if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
931 if test -z "$OS_TARGET"; then
934 if test "$OS_TARGET" = "WIN95"; then
937 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
939 dnl ========================================================
940 dnl = ARM toolchain tweaks
941 dnl ========================================================
944 MOZ_ALIGN=toolchain-default
947 arm*-android*|arm*-linuxandroid*)
956 if test -n "$MOZ_PLATFORM_MAEMO"; then
961 if test "$MOZ_PLATFORM_MAEMO" = 6; then
967 dnl Kept for compatibility with some buildbot mozconfig
968 AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
971 [ --with-thumb[[=yes|no|toolchain-default]]]
972 [ Use Thumb instruction set (-mthumb)],
973 if test -z "$GNU_CC"; then
974 AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
978 AC_ARG_WITH(thumb-interwork,
979 [ --with-thumb-interwork[[=yes|no|toolchain-default]]
980 Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
981 if test -z "$GNU_CC"; then
982 AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchain-defaults])
984 MOZ_THUMB_INTERWORK=$withval)
987 [ --with-arch=[[type|toolchain-default]]
988 Use specific CPU features (-march=type)],
989 if test -z "$GNU_CC"; then
990 AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchain-defaults])
995 [ --with-fpu=[[type|toolchain-default]]
996 Use specific FPU type (-mfpu=type)],
997 if test -z "$GNU_CC"; then
998 AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchain-defaults])
1002 AC_ARG_WITH(float-abi,
1003 [ --with-float-abi=[[type|toolchain-default]]
1004 Use specific arm float ABI (-mfloat-abi=type)],
1005 if test -z "$GNU_CC"; then
1006 AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchain-defaults])
1008 MOZ_FLOAT_ABI=$withval)
1010 AC_ARG_WITH(soft-float,
1011 [ --with-soft-float[[=yes|no|toolchain-default]]
1012 Use soft float library (-msoft-float)],
1013 if test -z "$GNU_CC"; then
1014 AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchain-defaults])
1016 MOZ_SOFT_FLOAT=$withval)
1019 toolchain-default|"")
1023 arch_flag="-march=$MOZ_ARCH"
1027 case "$MOZ_THUMB" in
1030 thumb_flag="-mthumb"
1037 _SAVE_CFLAGS="$CFLAGS"
1039 AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
1042 CFLAGS="$_SAVE_CFLAGS"
1047 case "$MOZ_THUMB_INTERWORK" in
1049 thumb_interwork_flag="-mthumb-interwork"
1052 thumb_interwork_flag="-mno-thumb-interwork"
1054 *) # toolchain-default
1055 thumb_interwork_flag=""
1060 toolchain-default|"")
1064 fpu_flag="-mfpu=$MOZ_FPU"
1068 case "$MOZ_FLOAT_ABI" in
1069 toolchain-default|"")
1073 float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
1077 case "$MOZ_SOFT_FLOAT" in
1079 soft_float_flag="-msoft-float"
1082 soft_float_flag="-mno-soft-float"
1084 *) # toolchain-default
1089 case "$MOZ_ALIGN" in
1090 toolchain-default|"")
1094 align_flag="-mno-unaligned-access"
1097 align_flag="-munaligned-access"
1104 if test -n "$align_flag"; then
1105 _SAVE_CFLAGS="$CFLAGS"
1106 CFLAGS="$CFLAGS $align_flag"
1107 AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
1108 AC_TRY_COMPILE([],[],,align_flag="")
1109 CFLAGS="$_SAVE_CFLAGS"
1112 dnl Use echo to avoid accumulating space characters
1113 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
1114 if test -n "$all_flags"; then
1115 _SAVE_CFLAGS="$CFLAGS"
1117 AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
1118 AC_TRY_COMPILE([],[return 0;],
1119 AC_MSG_RESULT([yes]),
1122 CFLAGS="$_SAVE_CFLAGS $all_flags"
1123 CXXFLAGS="$CXXFLAGS $all_flags"
1124 ASFLAGS="$ASFLAGS $all_flags"
1125 if test -n "$thumb_flag"; then
1126 LDFLAGS="$LDFLAGS $thumb_flag"
1130 dnl ========================================================
1131 dnl Override of system specific host options
1132 dnl ========================================================
1138 NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
1139 if test `echo "${PATH}" | grep -c \;` = 0; then
1140 CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
1144 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1148 dnl ========================================================
1149 dnl Override of system specific target options
1150 dnl ========================================================
1157 DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
1158 AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
1159 case "${target_os}" in
1161 AC_DEFINE(AIX_RENAME_SELECT)
1162 AC_DEFINE(_PR_NO_LARGE_FILES)
1163 AIX_LINK_OPTS='-bnso -berok'
1164 PR_MD_ASFILES=os_AIX.s
1167 AC_DEFINE(AIX_TIMERS)
1168 AC_DEFINE(_PR_NO_LARGE_FILES)
1172 AIX_LINK_OPTS='-bnso -berok'
1173 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
1174 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
1177 AC_DEFINE(AIX_TIMERS)
1178 AC_DEFINE(_PR_HAVE_OFF64_T)
1179 AIX_LINK_OPTS='-brtl -bnso -berok'
1182 AC_DEFINE(AIX_TIMERS)
1183 AC_DEFINE(_PR_HAVE_OFF64_T)
1184 AC_DEFINE(AIX4_3_PLUS)
1185 AC_DEFINE(HAVE_SOCKLEN_T)
1186 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1188 AIX_LINK_OPTS='-brtl -bnso -berok'
1191 AC_DEFINE(AIX_TIMERS)
1192 AC_DEFINE(_PR_HAVE_OFF64_T)
1193 AC_DEFINE(AIX4_3_PLUS)
1194 AC_DEFINE(HAVE_SOCKLEN_T)
1195 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1197 AIX_LINK_OPTS='-brtl -bnso -berok'
1200 CFLAGS="$CFLAGS -qro -qroconst"
1201 AIX_WRAP='$(DIST)/lib/aixwrap.o'
1202 AIX_TMP='./_aix_tmp.o'
1203 if test -n "$USE_64"; then
1204 MDCPUCFG_H=_aix64.cfg
1207 MDCPUCFG_H=_aix32.cfg
1210 RESOLVE_LINK_SYMBOLS=1
1216 AC_DEFINE(HAVE_BSD_FLOCK)
1217 AC_DEFINE(HAVE_SOCKLEN_T)
1218 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1220 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1222 if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
1223 AC_DEFINE(HAS_CONNECTX)
1225 AS='$(CC) -x assembler-with-cpp'
1226 CFLAGS="$CFLAGS -Wall -fno-common"
1227 case "${target_cpu}" in
1232 if test -n "$USE_64"; then
1245 if test "`echo $CC | grep -c '\-arch '`" = "0"; then
1248 CC="$CC -arch arm64"
1251 CC="$CC -arch $CPU_ARCH"
1255 AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
1257 DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1259 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1260 STRIP="$STRIP -x -S"
1263 MDCPUCFG_H=_darwin.cfg
1264 PR_MD_CSRCS=darwin.c
1265 PR_MD_ASFILES=os_Darwin.s
1267 if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1268 dnl Use the specified value
1269 export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1270 elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1271 dnl No value specified on the command line or in the environment,
1272 dnl use the lesser of the library's minimum or the architecture's
1274 case "${target_cpu}" in
1276 dnl Architecture minimum 10.3
1277 export MACOSX_DEPLOYMENT_TARGET=10.3
1280 dnl Architecture minimum 10.4
1281 export MACOSX_DEPLOYMENT_TARGET=10.4
1286 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1287 dnl in use. NEXT_ROOT will be set and exported if it's needed for
1290 if test "$MACOS_SDK_DIR"; then
1291 dnl Sync this section with the one in Mozilla's top level.
1293 if test ! -d "$MACOS_SDK_DIR"; then
1294 AC_MSG_ERROR([SDK not found. When using --with-macos-sdk, you must
1295 specify a valid SDK. SDKs are installed when the optional cross-development
1296 tools are selected during the Xcode/Developer Tools installation.])
1300 CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1301 GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1302 GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1304 GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1305 if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1306 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1307 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1308 SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1311 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1313 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1315 dnl CPP needs to be set for AC_CHECK_HEADER.
1316 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1319 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1321 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1322 dnl The build host is running Tiger (10.4) or earlier.
1323 dnl ld support for -syslibroot is compiler-agnostic, but
1324 dnl only available on Tiger and later. On Tiger and
1325 dnl earlier build hosts, just rely on NEXT_ROOT, because
1326 dnl it's not been shown to cause any problems.
1327 MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}"
1329 dnl The build host is running Leopard (10.5) or later.
1330 dnl With NEXT_ROOT set, the linker will still not apply
1331 dnl it when resolving dependencies. This causes problems
1332 dnl on Leopard, where an SDK depends on frameworks which
1333 dnl were present in earlier OS releases (and the associated
1334 dnl SDK) but not in Leopard. -syslibroot does not have
1335 dnl this problem, but it results in harmless warnings when
1336 dnl NEXT_ROOT is set. NEXT_ROOT needs to remain set even
1337 dnl on Leopard because the compiler uses it too.
1338 MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1341 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1342 export NEXT_ROOT=$MACOS_SDK_DIR
1344 if test -n "$CROSS_COMPILE" ; then
1345 dnl NEXT_ROOT will be in the environment, but it
1346 dnl shouldn't be set for the build host. HOST_CXX is
1347 dnl presently unused.
1348 HOST_CC="NEXT_ROOT= $HOST_CC"
1349 HOST_CXX="NEXT_ROOT= $HOST_CXX"
1352 dnl gcc >= 4.0 uses different paths than above, but knows
1353 dnl how to find them itself.
1354 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1356 dnl CPP needs to be set for AC_CHECK_HEADER.
1357 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1359 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1360 dnl has an ld that supports -syslibroot. Don't set
1361 dnl NEXT_ROOT because it will be ignored and cause
1362 dnl warnings when -syslibroot is specified.
1363 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1364 dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1365 dnl based on the -isysroot it receives.
1366 LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1368 dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1370 LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1377 if test -z "$USE_NSPR_THREADS"; then
1382 AC_DEFINE(HAVE_BSD_FLOCK)
1383 AC_DEFINE(HAVE_SOCKLEN_T)
1384 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1385 CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1386 MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1387 if test "$MOZ_OBJFORMAT" = "elf"; then
1392 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1394 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1395 MDCPUCFG_H=_freebsd.cfg
1396 PR_MD_CSRCS=freebsd.c
1402 AC_DEFINE(_HPUX_SOURCE)
1403 # HPUX report the POLLHUP event for a socket when the
1404 # shutdown(SHUT_WR) operation is called for the remote end, even though
1405 # the socket is still writeable. Use select(), instead of poll(), to
1406 # workaround this problem.
1407 AC_DEFINE(_PR_POLL_WITH_SELECT)
1408 AC_DEFINE(_USE_BIG_FDS)
1409 DSO_LDOPTS='-b +h $(notdir $@)'
1411 if test "$OS_TEST" = "ia64"; then
1413 DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1414 CPU_ARCH_TAG=_$OS_TEST
1415 if test -z "$USE_64"; then
1418 PR_MD_ASFILES=os_HPUX_ia64.s
1422 PR_MD_ASFILES=os_HPUX.s
1424 if test -n "$USE_64"; then
1425 MDCPUCFG_H=_hpux64.cfg
1427 MDCPUCFG_H=_hpux32.cfg
1429 if test -z "$GNU_CC"; then
1435 ASFLAGS="$ASFLAGS -x assembler-with-cpp"
1438 if test -n "$MOZILLA_CLIENT"; then
1439 DEFAULT_IMPL_STRATEGY=_EMU
1442 if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1443 AC_DEFINE(_PR_NO_LARGE_FILES)
1446 if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1447 AC_DEFINE(_PR_NEED_H_ERRNO)
1450 if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1451 AC_DEFINE(HAVE_INT_LOCALTIME_R)
1454 if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1455 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1458 # HP-UX 11i v2 (B.11.23) or higher
1460 case "$OS_RELEASE" in
1461 [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1467 if test "$OS_RELEASE" = "B.10.01"; then
1469 DEFAULT_IMPL_STRATEGY=_EMU
1472 if test "$OS_RELEASE" = "B.10.10"; then
1474 AC_DEFINE(HPUX10_10)
1475 DEFAULT_IMPL_STRATEGY=_PTH
1478 if test "$OS_RELEASE" = "B.10.20"; then
1480 AC_DEFINE(HPUX10_20)
1481 if test -z "$GNU_CC"; then
1482 CFLAGS="$CFLAGS +DAportable +DS1.1"
1483 CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1485 DEFAULT_IMPL_STRATEGY=_PTH
1488 if test "$OS_RELEASE" = "B.10.30"; then
1490 AC_DEFINE(HPUX10_30)
1491 if test -z "$GNU_CC"; then
1492 CFLAGS="$CFLAGS +DAportable +DS1.1"
1493 CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1495 DEFAULT_IMPL_STRATEGY=_PTH
1498 if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1501 AC_DEFINE(_LARGEFILE64_SOURCE)
1502 AC_DEFINE(_PR_HAVE_OFF64_T)
1503 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1504 if test -z "$GNU_CC"; then
1505 if test -z "$USE_64"; then
1506 if test "$OS_TEST" = "ia64"; then
1507 CFLAGS="$CFLAGS +DD32"
1508 CXXFLAGS="$CXXFLAGS +DD32"
1510 CFLAGS="$CFLAGS +DAportable +DS2.0"
1511 CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1514 if test "$OS_TEST" = "ia64"; then
1515 CFLAGS="$CFLAGS +DD64"
1516 CXXFLAGS="$CXXFLAGS +DD64"
1518 CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1519 CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1523 DEFAULT_IMPL_STRATEGY=_PTH
1526 if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1530 elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1532 if test "$USE_NSPR_THREADS"; then
1535 if test "$USE_USER_PTHREADS"; then
1541 *-linux*|*-gnu*|*-k*bsd*-gnu|*-android*|*-linuxandroid*)
1542 if test -z "$USE_NSPR_THREADS"; then
1547 AC_DEFINE(_GNU_SOURCE)
1548 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1549 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1551 *-android*|*-linuxandroid*)
1559 CFLAGS="$CFLAGS -Wall"
1560 CXXFLAGS="$CXXFLAGS -Wall"
1561 MDCPUCFG_H=_linux.cfg
1563 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1565 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1567 _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that
1568 # combo is not yet good at debugging inlined
1569 # functions (even when using DWARF2 as the
1572 if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1577 CPU_ARCH_TAG=_${CPU_ARCH}
1578 case "${target_cpu}" in
1582 CFLAGS="$CFLAGS -mieee"
1583 CXXFLAGS="$CXXFLAGS -mieee"
1587 PR_MD_ASFILES=os_Linux_x86.s
1590 PR_MD_ASFILES=os_Linux_ia64.s
1593 if test -n "$USE_64"; then
1594 PR_MD_ASFILES=os_Linux_x86_64.s
1595 elif test -n "$USE_X32"; then
1596 PR_MD_ASFILES=os_Linux_x86_64.s
1601 PR_MD_ASFILES=os_Linux_x86.s
1607 PR_MD_ASFILES=os_Linux_ppc.s
1610 if test -n "$USE_64"; then
1614 PR_MD_ASFILES=os_Linux_ppc.s
1620 *-mingw*|*-msys*|*-cygwin*|*-mks*)
1623 PR_MD_ARCH_DIR=windows
1624 RESOLVE_LINK_SYMBOLS=1
1626 if test -n "$GNU_CC"; then
1628 CXX="$CXX -mwindows"
1630 MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1632 # Use temp file for windres (bug 213281)
1633 RCFLAGS='-O coff --use-temp-file'
1636 AR='lib -NOLOGO -OUT:"$@"'
1638 RANLIB='echo not_ranlib'
1639 STRIP='echo not_strip'
1641 GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1646 # Determine compiler version
1648 _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
1650 CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
1651 if test -z "$CC_VERSION"; then
1652 AC_MSG_ERROR([Could not determine MSC version.])
1655 _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
1656 _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
1657 _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
1658 _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'`
1659 MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
1661 if test "$_CC_MAJOR_VERSION" -eq "14"; then
1662 dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
1663 dnl so be very specific here!
1664 dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
1665 if test $_CC_RELEASE -gt 50727; then
1667 elif test $_CC_BUILD -ge 762; then
1670 AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
1671 AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
1672 elif test $_CC_MAJOR_VERSION -ge 15; then
1674 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
1675 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
1678 if test -n "$_USE_DYNAMICBASE"; then
1679 DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
1682 # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
1683 # tape manipulation utility (or something else)
1684 if test "$MSC_VER" -ge "1400"; then
1686 _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
1689 MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
1690 if test -n "$MSMT_TOOL"; then
1691 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
1692 if test -z "$MSMANIFEST_TOOL_VERSION"; then
1693 AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
1698 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
1702 CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
1703 DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
1707 PROFILE_GEN_CFLAGS="-GL"
1708 PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
1709 PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
1710 PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
1712 if test "$MSC_VER" -ge "1800"; then
1713 dnl Visual C++ 2013 requires -FS when parallel building with
1714 dnl make -jN. If not specified, compiler sometimes emits C1041
1716 CFLAGS="$CFLAGS -FS"
1717 dnl -Gw can benefit when using linker optimization on PGO.
1718 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1719 PROFILE_GEN_CFLAGS="$PROFILE_GEN_CFLAGS -Gw"
1720 PROFILE_USE_CFLAGS="$PROFILE_USE_CFLAGS -Gw"
1723 if test -z "$MOZ_OPTIMIZE"; then
1724 CFLAGS="$CFLAGS -Od"
1727 if test "$USE_DEBUG_RTL" = 1; then
1728 if test -n "$USE_STATIC_RTL"; then
1729 CFLAGS="$CFLAGS -MTd"
1731 CFLAGS="$CFLAGS -MDd"
1734 if test -n "$USE_STATIC_RTL"; then
1735 CFLAGS="$CFLAGS -MT"
1737 CFLAGS="$CFLAGS -MD"
1741 if test -n "$MOZ_DEBUG"; then
1744 DEFINES="$DEFINES -U_DEBUG"
1747 if test -n "$MOZ_DEBUG_SYMBOLS"; then
1748 if test -n "$MOZ_OPTIMIZE"; then
1749 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
1750 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
1752 DLLFLAGS="$DLLFLAGS -DEBUG"
1753 LDFLAGS="$LDFLAGS -DEBUG"
1757 OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
1758 if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
1759 OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
1762 if test "$OS_TARGET" = "WINNT"; then
1763 CFLAGS="$CFLAGS -GT"
1764 LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1765 LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1767 LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1768 LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1772 if test -n "$USE_STATIC_TLS"; then
1773 AC_DEFINE(_PR_USE_STATIC_TLS)
1776 if test "$OS_TARGET" = "WINNT"; then
1780 # undefine WINNT as some versions of mingw gcc define it by default
1781 DEFINES="$DEFINES -UWINNT"
1782 AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
1785 if test "$CPU_ARCH" = "x86"; then
1788 CPU_ARCH_TAG=$CPU_ARCH
1791 if test "$USE_DEBUG_RTL" = 1; then
1795 case "$OS_TARGET" in
1797 MDCPUCFG_H=_winnt.cfg
1800 MDCPUCFG_H=_win95.cfg
1803 AC_MSG_ERROR([Missing OS_TARGET for ${target}. Use --enable-win32-target to set.])
1807 case "$target_cpu" in
1809 if test -n "$USE_64"; then
1813 if test -z "$GNU_CC" -a "$MSC_VER" -ge "1700"; then
1814 dnl Visual C++ 2012 defaults to -arch:SSE2. Use -arch:IA32
1815 dnl to avoid requiring SSE2.
1816 CFLAGS="$CFLAGS -arch:IA32"
1833 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1841 AC_DEFINE(HAVE_BSD_FLOCK)
1842 AC_DEFINE(HAVE_SOCKLEN_T)
1843 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1844 if test -z "$USE_NSPR_THREADS"; then
1847 MDCPUCFG_H=_netbsd.cfg
1848 PR_MD_CSRCS=netbsd.c
1850 DSO_CFLAGS='-fPIC -DPIC'
1851 CFLAGS="$CFLAGS -ansi -Wall"
1852 CXXFLAGS="$CXXFLAGS -ansi -Wall"
1853 MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1855 if test -z "$OBJECT_FMT"; then
1856 if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
1859 DSO_LDOPTS='-shared'
1863 DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
1867 if test "$LIBRUNPATH"; then
1868 DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
1875 AC_DEFINE(_QNX_SOURCE)
1876 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1879 MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
1882 OS_LIBS="$OS_LIBS -lsocket"
1883 _OPTIMIZE_FLAGS="-O1"
1884 _DEBUG_FLAGS="-gstabs"
1890 AC_DEFINE(HAVE_BSD_FLOCK)
1891 AC_DEFINE(HAVE_SOCKLEN_T)
1892 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1893 CFLAGS="$CFLAGS -ansi -Wall"
1894 CXXFLAGS="$CXXFLAGS -ansi -Wall"
1897 MDCPUCFG_H=_openbsd.cfg
1898 PR_MD_CSRCS=openbsd.c
1900 if test -z "$USE_NSPR_THREADS"; then
1903 DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
1904 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1910 AC_DEFINE(_PR_NEED_H_ERRNO)
1919 AC_DEFINE(_PR_NEED_H_ERRNO)
1921 MDCPUCFG_H=_riscos.cfg
1922 PR_MD_CSRCS=riscos.c
1924 DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1925 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1929 if test -z "$USE_NSPR_THREADS"; then
1938 AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1940 MDCPUCFG_H=_solaris.cfg
1941 PR_MD_CSRCS=solaris.c
1943 MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1944 RESOLVE_LINK_SYMBOLS=1
1945 case "${OS_RELEASE}" in
1949 # It is safe to use the -Bdirect linker flag on Solaris 10 or later.
1953 if test -n "$GNU_CC"; then
1955 if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
1958 DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore'
1959 if test -n "$USE_B_DIRECT"; then
1960 DSO_LDOPTS="$DSO_LDOPTS,-Bdirect"
1964 DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
1965 if test -n "$USE_B_DIRECT"; then
1966 DSO_LDOPTS="$DSO_LDOPTS -Bdirect"
1969 if test -n "$GNU_CC"; then
1970 CFLAGS="$CFLAGS -Wall"
1971 CXXFLAGS="$CXXFLAGS -Wall"
1972 if test -n "$USE_MDUPDATE"; then
1973 CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
1974 CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
1976 GCC_AS=`$CC -print-prog-name=as`
1977 if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
1981 CFLAGS="$CFLAGS -xstrconst"
1982 CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
1983 if test -z "$MOZ_OPTIMIZE"; then
1984 CFLAGS="$CFLAGS -xs"
1985 CXXFLAGS="$CXXFLAGS -xs"
1987 _OPTIMIZE_FLAGS=-xO4
1989 if test -z "$GNU_AS"; then
1990 ASFLAGS="$ASFLAGS -Wa,-P"
1992 if test -n "$USE_64"; then
1993 if test -n "$GNU_CC"; then
1997 if test "$OS_TEST" = "i86pc"; then
1998 CC="$CC -xarch=amd64"
1999 CXX="$CXX -xarch=amd64"
2002 CXX="$CXX -xarch=v9"
2006 if test "$OS_TEST" = "i86pc"; then
2007 if test -z "$USE_64"; then
2010 CPU_ARCH_TAG=_$OS_TEST
2011 # The default debug format, DWARF (-g), is not supported by gcc
2012 # on i386-ANY-sysv4/solaris, but the stabs format is. It is
2013 # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2014 # If your gcc uses GNU as, you do not need the -Wa,-s option.
2015 if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2016 _DEBUG_FLAGS=-gstabs
2017 if test -z "$GNU_AS"; then
2018 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2022 case "${target_os}" in
2024 AC_DEFINE(_PR_NO_LARGE_FILES)
2027 AC_DEFINE(_PR_NO_LARGE_FILES)
2030 AC_DEFINE(SOLARIS2_5)
2033 AC_DEFINE(_PR_HAVE_OFF64_T)
2034 # The lfcompile64(5) man page on Solaris 2.6 says:
2035 # For applications that do not wish to conform to the POSIX or
2036 # X/Open specifications, the 64-bit transitional interfaces
2037 # are available by default. No compile-time flags need to be
2039 # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2040 # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2041 if test -n "$GNU_CC"; then
2042 AC_DEFINE(_LARGEFILE64_SOURCE)
2046 case "${target_os}" in
2058 # Solaris 8 or higher has IPv6.
2059 AC_DEFINE(_PR_INET6)
2062 if test "$CPU_ARCH" = "sparc"; then
2063 # 64-bit Solaris SPARC requires V9 architecture, so the following
2065 if test -z "$USE_64"; then
2066 ULTRASPARC_LIBRARY=nspr_flt
2069 # Purify requires that binaries linked against nspr also
2070 # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2072 _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2073 OS_LIBS="$OS_LIBS $_librt"
2082 if test -z "$SKIP_LIBRARY_CHECKS"; then
2083 dnl ========================================================
2084 dnl Check for system libraries
2085 dnl ========================================================
2088 dnl We don't want anything to link with libdl even if it's present on OS X,
2089 dnl since it's not used and not part of the default installation.
2090 dnl The same goes for BeOS.
2091 dnl OS/2 has dlfcn in libc.
2097 AC_CHECK_LIB(dl, dlopen,
2098 [AC_CHECK_HEADER(dlfcn.h,
2099 OS_LIBS="-ldl $OS_LIBS")])
2104 dnl ========================================================
2105 dnl Check for system header files.
2106 dnl ========================================================
2108 dnl ========================================================
2109 dnl Check for typedefs and structs
2110 dnl ========================================================
2112 dnl ========================================================
2113 dnl Checks for library functions.
2114 dnl ========================================================
2115 AC_PROG_GCC_TRADITIONAL
2117 LIBS="$LIBS $OS_LIBS"
2118 AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
2119 secure_getenv __secure_getenv)
2122 dnl ========================================================
2124 dnl ========================================================
2126 dnl ======================================================
2127 dnl = Enable compiling with ccache
2128 dnl ======================================================
2130 [ --with-ccache[=path/to/ccache]
2131 Enable compiling with ccache],
2132 CCACHE=$withval, CCACHE="no")
2134 if test "$CCACHE" != "no"; then
2135 if test -n "$CCACHE"; then
2136 if test "$CCACHE" = "yes"; then
2139 if test ! -e "$CCACHE"; then
2140 AC_MSG_ERROR([$CCACHE not found])
2144 AC_PATH_PROGS(CCACHE, $CCACHE ccache)
2145 if test -z "$CCACHE" -o "$CCACHE" = ":"; then
2146 AC_MSG_ERROR([ccache not found])
2147 elif test -x "$CCACHE"; then
2151 AC_MSG_ERROR([$CCACHE is not executable])
2155 dnl ========================================================
2157 dnl = --enable-strip
2159 dnl = Enable stripping of libs and executables
2161 dnl ========================================================
2162 AC_ARG_ENABLE(strip,
2163 [ --enable-strip Enable stripping of shared libs and programs],
2164 [ if test "$enableval" = "yes"; then
2168 dnl Check for hpux options
2169 case "${target_os}" in
2171 if test -z "$GNU_CC"; then
2173 AC_CACHE_CHECK(for +Olit support,
2174 ac_cv_hpux_usable_olit_option,
2175 dnl since aCC doesn't throw an error on invalid options,
2176 dnl we have to test this the hard way
2177 [ac_cv_hpux_usable_olit_option=no
2179 echo 'int main() { return 0; }' | cat > conftest.c
2180 ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2181 if test $? -eq 0; then
2182 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2183 ac_cv_hpux_usable_olit_option=yes
2189 if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2190 CFLAGS="$CFLAGS +Olit=all"
2191 CXXFLAGS="$CXXFLAGS +Olit=all"
2193 CFLAGS="$CFLAGS +ESlit"
2194 CXXFLAGS="$CXXFLAGS +ESlit"
2200 case "$target_os" in
2205 AC_CHECK_LIB(pthreads, pthread_create,
2206 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2207 AC_CHECK_LIB(pthread, pthread_create,
2208 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2209 AC_CHECK_LIB(c_r, pthread_create,
2210 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2211 AC_CHECK_LIB(c, pthread_create,
2220 AC_ARG_WITH(pthreads,
2221 [ --with-pthreads Use system pthreads library as thread subsystem],
2222 [ if test "$withval" = "yes"; then
2223 if test -n "$_HAVE_PTHREADS"; then
2228 AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2234 [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2240 AC_ARG_ENABLE(user-pthreads,
2241 [ --enable-user-pthreads Build using userland pthreads],
2242 [ if test "$enableval" = "yes"; then
2243 if test -n "$_HAVE_PTHREADS"; then
2248 AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2252 AC_ARG_ENABLE(nspr-threads,
2253 [ --enable-nspr-threads Build using classic nspr threads],
2254 [ if test "$enableval" = "yes"; then
2260 fi # SKIP_LIBRARY_CHECKS
2263 [ --enable-ipv6 Compile ipv6 support],
2264 [ if test "$enableval" = "yes"; then
2270 if test -n "$USE_PTHREADS"; then
2271 dnl See if -pthread is supported.
2273 ac_cv_have_dash_pthread=no
2274 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2275 echo 'int main() { return 0; }' | cat > conftest.c
2276 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2277 if test $? -eq 0; then
2278 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2279 ac_cv_have_dash_pthread=yes
2280 case "$target_os" in
2282 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2285 CFLAGS="$CFLAGS -pthread"
2286 CXXFLAGS="$CXXFLAGS -pthread"
2292 AC_MSG_RESULT($ac_cv_have_dash_pthread)
2295 dnl See if -pthreads is supported.
2297 ac_cv_have_dash_pthreads=no
2298 if test "$ac_cv_have_dash_pthread" = "no"; then
2299 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2300 echo 'int main() { return 0; }' | cat > conftest.c
2301 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2302 if test $? -eq 0; then
2303 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2304 ac_cv_have_dash_pthreads=yes
2305 CFLAGS="$CFLAGS -pthreads"
2306 CXXFLAGS="$CXXFLAGS -pthreads"
2310 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2315 if test "$ac_cv_have_dash_pthreads" = "yes"; then
2320 AC_DEFINE(_REENTRANT)
2321 AC_DEFINE(_THREAD_SAFE)
2322 dnl -pthread links in -lc_r, so don't specify it explicitly.
2323 if test "$ac_cv_have_dash_pthread" = "yes"; then
2324 _PTHREAD_LDFLAGS="-pthread"
2326 _PTHREAD_LDFLAGS="-lc_r"
2330 if test "$ac_cv_have_dash_pthread" = "yes"; then
2331 _PTHREAD_LDFLAGS="-pthread"
2335 if test "$ac_cv_have_dash_pthread" = "yes"; then
2336 _PTHREAD_LDFLAGS=-pthread
2339 *-linux*|*-gnu*|*-k*bsd*-gnu)
2340 AC_DEFINE(_REENTRANT)
2345 if test -n "$USE_USER_PTHREADS"; then
2352 dnl Special thread exceptions
2356 if test -n "$USE_NSPR_THREADS"; then
2357 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2359 case "$target_os" in
2361 if test -z "$USE_PTHREADS"; then
2362 AC_DEFINE(AIX_RENAME_SELECT)
2366 if test -z "$USE_NSPR_THREADS"; then
2367 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2371 if test -z "$USE_NSPR_THREADS"; then
2372 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2374 if test -n "$USE_PTHREADS"; then
2375 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2379 if test -z "$USE_NSPR_THREADS"; then
2380 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2382 if test -n "$USE_PTHREADS"; then
2383 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2389 if test -n "$USE_NSPR_THREADS"; then
2390 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2394 if test -n "$USE_NSPR_THREADS"; then
2395 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2397 if test "$USE_PTHREADS"; then
2398 AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2399 AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2401 if test "$USE_USER_PTHREADS"; then
2402 AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2405 *-linux*|*-gnu*|*-k*bsd*-gnu)
2406 if test -n "$USE_NSPR_THREADS"; then
2407 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2410 *-mingw*|*-msys*|*-cygwin*|*-mks*)
2411 dnl win32 cannot use pthreads
2416 *-netbsd*|*-openbsd*)
2417 if test -n "$USE_NSPR_THREADS"; then
2418 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2422 if test -n "$USE_NSPR_THREADS"; then
2423 AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2425 if test -n "$USE_PTHREADS"; then
2426 AC_DEFINE(_REENTRANT)
2427 AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2428 if test "$OS_TEST" = "i86pc"; then
2429 if test -n "$USE_64"; then
2430 PR_MD_ASFILES=os_SunOS_x86_64.s
2432 PR_MD_ASFILES=os_SunOS_x86.s
2435 if test -n "$USE_64"; then
2436 PR_MD_ASFILES=os_SunOS_sparcv9.s
2442 if test -n "$USE_PTHREADS"; then
2443 AC_DEFINE(_PR_HAVE_GETHOST_R)
2444 AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2449 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2451 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2452 dnl make sure that we use it.
2453 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2454 _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2457 if test -n "$_SAVE_DEBUG_FLAGS"; then
2458 _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2461 if test -n "$MOZ_OPTIMIZE"; then
2462 CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2463 CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2466 if test -n "$MOZ_DEBUG_SYMBOLS"; then
2467 CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2468 CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2471 if test -n "$MOZ_OPTIMIZE"; then
2477 if test -n "$USE_64"; then
2481 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2483 dnl ========================================================
2484 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2485 dnl ========================================================
2486 case "$target_os" in
2488 CC="\$(CYGWIN_WRAPPER) $CC"
2489 CXX="\$(CYGWIN_WRAPPER) $CXX"
2490 RC="\$(CYGWIN_WRAPPER) $RC"
2494 dnl ========================================================
2495 dnl = Use malloc wrapper lib
2496 dnl ========================================================
2497 AC_ARG_ENABLE(wrap-malloc,
2498 [ --enable-wrap-malloc Wrap malloc calls (gnu linker only)],
2499 [ if test "$enableval" = "yes"; then
2503 if test -n "$_WRAP_MALLOC"; then
2504 if test -n "$GNU_CC"; then
2505 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
2506 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
2507 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
2508 WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
2510 AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
2514 dnl ========================================================
2515 dnl = Location of malloc wrapper lib
2516 dnl ========================================================
2517 AC_ARG_WITH(wrap-malloc,
2518 [ --with-wrap-malloc=SHAREDLIB Location of malloc wrapper library],
2519 WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
2521 dnl ========================================================
2522 dnl Substitution of found variables.
2523 dnl ========================================================
2524 AC_SUBST(SHELL_OVERRIDE)
2526 AC_SUBST(MOZILLA_CLIENT)
2533 AC_SUBST(HOST_CFLAGS)
2535 AC_SUBST(HOST_LDFLAGS)
2537 AC_SUBST(GCC_USE_GNU_LD)
2539 AC_SUBST(CROSS_COMPILE)
2541 AC_SUBST(MOZ_OPTIMIZE)
2543 AC_SUBST(MOZ_DEBUG_SYMBOLS)
2550 AC_SUBST(OBJECT_MODE)
2551 AC_SUBST(ENABLE_STRIP)
2553 AC_SUBST(USE_PTHREADS)
2554 AC_SUBST(USE_BTHREADS)
2555 AC_SUBST(USE_USER_PTHREADS)
2556 AC_SUBST(USE_NSPR_THREADS)
2561 AC_SUBST(MOD_MAJOR_VERSION)
2562 AC_SUBST(MOD_MINOR_VERSION)
2563 AC_SUBST(MOD_PATCH_VERSION)
2564 AC_SUBST(NSPR_MODNAME)
2565 AC_SUBST(MDCPUCFG_H)
2566 AC_SUBST(PR_MD_CSRCS)
2567 AC_SUBST(PR_MD_ASFILES)
2568 AC_SUBST(PR_MD_ARCH_DIR)
2571 AC_SUBST(OBJ_SUFFIX)
2572 AC_SUBST(LIB_SUFFIX)
2573 AC_SUBST(DLL_SUFFIX)
2574 AC_SUBST(ASM_SUFFIX)
2575 AC_SUBST(WRAP_LDFLAGS)
2577 AC_SUBST(DSO_CFLAGS)
2578 AC_SUBST(DSO_LDOPTS)
2582 AC_SUBST(OS_RELEASE)
2584 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
2599 AC_SUBST(PROFILE_GEN_CFLAGS)
2600 AC_SUBST(PROFILE_GEN_LDFLAGS)
2601 AC_SUBST(PROFILE_USE_CFLAGS)
2602 AC_SUBST(PROFILE_USE_LDFLAGS)
2605 AC_SUBST(RESOLVE_LINK_SYMBOLS)
2606 AC_SUBST(AIX_LINK_OPTS)
2607 AC_SUBST(NOSUCHFILE)
2608 AC_SUBST(MOZ_OBJFORMAT)
2609 AC_SUBST(ULTRASPARC_LIBRARY)
2612 AC_SUBST(OBJDIR_NAME)
2613 AC_SUBST(RELEASE_OBJDIR_NAME)
2620 AC_SUBST(OS_DLLFLAGS)
2621 AC_SUBST(CYGWIN_WRAPPER)
2622 AC_SUBST(VISIBILITY_FLAGS)
2623 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2624 AC_SUBST(MACOS_SDK_DIR)
2628 dnl ========================================================
2629 dnl Generate output files.
2630 dnl ========================================================
2642 lib/libc/include/Makefile
2643 lib/libc/src/Makefile
2648 pr/include/md/Makefile
2649 pr/include/obsolete/Makefile
2650 pr/include/private/Makefile
2653 pr/src/linking/Makefile
2654 pr/src/malloc/Makefile
2656 pr/src/md/${PR_MD_ARCH_DIR}/Makefile
2657 pr/src/memory/Makefile
2658 pr/src/misc/Makefile
2659 pr/src/threads/Makefile
2661 pr/tests/dll/Makefile
2664 if test "$OS_TARGET" = "Linux"; then
2665 MAKEFILES="$MAKEFILES
2668 elif test "$OS_TARGET" = "SunOS"; then
2669 MAKEFILES="$MAKEFILES
2670 pkg/solaris/Makefile
2671 pkg/solaris/SUNWpr/Makefile
2672 pkg/solaris/SUNWprd/Makefile
2676 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
2677 MAKEFILES="$MAKEFILES
2678 pr/src/threads/combined/Makefile
2680 elif test -n "$USE_PTHREADS"; then
2681 MAKEFILES="$MAKEFILES
2682 pr/src/pthreads/Makefile
2684 elif test -n "$USE_BTHREADS"; then
2685 MAKEFILES="$MAKEFILES
2686 pr/src/bthreads/Makefile
2690 if test -n "$USE_CPLUS"; then
2691 MAKEFILES="$MAKEFILES
2692 pr/src/cplus/Makefile
2693 pr/src/cplus/tests/Makefile
2697 echo $MAKEFILES > unallmakefiles
2699 AC_CONFIG_FILES([$MAKEFILES])
2700 AC_CONFIG_COMMANDS([default], [chmod +x config/nspr-config])